diff options
author | Stephen Hemminger <stephen.hemminger@vyatta.com> | 2008-10-13 12:12:33 -0700 |
---|---|---|
committer | Stephen Hemminger <stephen.hemminger@vyatta.com> | 2008-10-13 12:12:33 -0700 |
commit | d3e384e4f00aa90db4310f82f3cbe6528e256334 (patch) | |
tree | 716c9dfa64dd9fdc4b05b377a2a19b7b216c4856 /ospfd/ospf_lsa.c | |
parent | d0cee3d3d7267f8f5c1d1ffd5c5fd8802a9db987 (diff) | |
parent | 41dc3488cf127a1e23333459a0c316ded67f7ff3 (diff) | |
download | quagga-d3e384e4f00aa90db4310f82f3cbe6528e256334.tar.bz2 quagga-d3e384e4f00aa90db4310f82f3cbe6528e256334.tar.xz |
Merge branch 'master' of /home/shemminger/src/quagga into upstream
Resolve all conflicts by using upstream version.
Diffstat (limited to 'ospfd/ospf_lsa.c')
-rw-r--r-- | ospfd/ospf_lsa.c | 41 |
1 files changed, 14 insertions, 27 deletions
diff --git a/ospfd/ospf_lsa.c b/ospfd/ospf_lsa.c index 243928f4..8981b57f 100644 --- a/ospfd/ospf_lsa.c +++ b/ospfd/ospf_lsa.c @@ -32,6 +32,7 @@ #include "thread.h" #include "hash.h" #include "sockunion.h" /* for inet_aton() */ +#include "checksum.h" #include "ospfd/ospfd.h" #include "ospfd/ospf_interface.h" @@ -172,46 +173,32 @@ get_age (struct ospf_lsa *lsa) /* Fletcher Checksum -- Refer to RFC1008. */ -#define MODX 4102 -#define LSA_CHECKSUM_OFFSET 15 +/* All the offsets are zero-based. The offsets in the RFC1008 are + one-based. */ u_int16_t ospf_lsa_checksum (struct lsa_header *lsa) { - u_char *sp, *ep, *p, *q; - int c0 = 0, c1 = 0; - int x, y; - u_int16_t length; - - lsa->checksum = 0; - length = ntohs (lsa->length) - 2; - sp = (u_char *) &lsa->options; - - for (ep = sp + length; sp < ep; sp = q) - { - q = sp + MODX; - if (q > ep) - q = ep; - for (p = sp; p < q; p++) - { - c0 += *p; - c1 += c0; - } - c0 %= 255; - c1 %= 255; - } + u_char *buffer = (u_char *) &lsa->options; + int options_offset = buffer - (u_char *) &lsa->ls_age; /* should be 2 */ +<<<<<<< HEAD:ospfd/ospf_lsa.c x = (((int)length - LSA_CHECKSUM_OFFSET) * c0 - c1) % 255; if (x <= 0) x += 255; y = 510 - c0 - x; if (y > 255) y -= 255; +======= + /* Skip the AGE field */ + u_int16_t len = ntohs(lsa->length) - options_offset; +>>>>>>> 41dc3488cf127a1e23333459a0c316ded67f7ff3:ospfd/ospf_lsa.c - /* take care endian issue. */ - lsa->checksum = htons ((x << 8) + y); + /* Checksum offset starts from "options" field, not the beginning of the + lsa_header struct. The offset is 14, rather than 16. */ + int checksum_offset = (u_char *) &lsa->checksum - buffer; - return (lsa->checksum); + return fletcher_checksum(buffer, len, checksum_offset); } |