diff options
Diffstat (limited to 'ospfd')
-rw-r--r-- | ospfd/ospf_lsa.c | 12 | ||||
-rw-r--r-- | ospfd/ospf_packet.c | 2 |
2 files changed, 13 insertions, 1 deletions
diff --git a/ospfd/ospf_lsa.c b/ospfd/ospf_lsa.c index 493209a0..5579d8ef 100644 --- a/ospfd/ospf_lsa.c +++ b/ospfd/ospf_lsa.c @@ -192,6 +192,18 @@ ospf_lsa_checksum (struct lsa_header *lsa) return fletcher_checksum(buffer, len, checksum_offset); } +int +ospf_lsa_checksum_valid (struct lsa_header *lsa) +{ + u_char *buffer = (u_char *) &lsa->options; + int options_offset = buffer - (u_char *) &lsa->ls_age; /* should be 2 */ + + /* Skip the AGE field */ + u_int16_t len = ntohs(lsa->length) - options_offset; + + return(fletcher_checksum(buffer, len, FLETCHER_CHECKSUM_VALIDATE) == 0); +} + /* Create OSPF LSA. */ diff --git a/ospfd/ospf_packet.c b/ospfd/ospf_packet.c index 351fb210..ede59088 100644 --- a/ospfd/ospf_packet.c +++ b/ospfd/ospf_packet.c @@ -1590,7 +1590,7 @@ ospf_ls_upd_list_lsa (struct ospf_neighbor *nbr, struct stream *s, /* Validate the LSA's LS checksum. */ sum = lsah->checksum; - if (sum != ospf_lsa_checksum (lsah)) + if (! ospf_lsa_checksum_valid (lsah)) { /* (bug #685) more details in a one-line message make it possible * to identify problem source on the one hand and to have a better |