diff options
author | Sam Roberts <vieuxtech@gmail.com> | 2013-08-20 20:33:18 -0700 |
---|---|---|
committer | Sam Roberts <vieuxtech@gmail.com> | 2013-08-20 20:33:18 -0700 |
commit | a4693ae62c6eaced9fcc849d87f5fd3b98eb8998 (patch) | |
tree | f79c0bb22ceb0fb3542b1297aad8479764faf2bf | |
parent | a89f0f10de9b70c0bcc0ab31552a12e1a8b83921 (diff) | |
download | libnet-a4693ae62c6eaced9fcc849d87f5fd3b98eb8998.tar.gz |
Insource comments and whitespace cleanups
-rw-r--r-- | libnet/src/common.h | 2 | ||||
-rw-r--r-- | libnet/src/libnet_checksum.c | 15 |
2 files changed, 14 insertions, 3 deletions
diff --git a/libnet/src/common.h b/libnet/src/common.h index 7b9f8fb..de31704 100644 --- a/libnet/src/common.h +++ b/libnet/src/common.h @@ -43,7 +43,7 @@ * included. */ #include <netinet/in.h> -#ifndef IPPROTO_MH +#ifndef IPPROTO_MH #define IPPROTO_MH 135 /* IPv6 mobility header */ #endif diff --git a/libnet/src/libnet_checksum.c b/libnet/src/libnet_checksum.c index a5009f8..faf6d44 100644 --- a/libnet/src/libnet_checksum.c +++ b/libnet/src/libnet_checksum.c @@ -210,8 +210,13 @@ libnet_inet_checksum(libnet_t *l, uint8_t *iphdr, int protocol, int h_len, const return -1; } + /* FIXME this entire fragile exercise would be avoided if we just passed + * in the pointer to the protocol block 'q' we are checksumming, which + * we know. + */ while (ip_nh != protocol && (uint8_t*)ip6h_p + ip_hl + 1 < end) - { /* next header is not the upper layer protocol */ + { + /* next header is not the upper layer protocol */ switch (ip_nh) { case IPPROTO_DSTOPTS: @@ -222,9 +227,15 @@ libnet_inet_checksum(libnet_t *l, uint8_t *iphdr, int protocol, int h_len, const case IPPROTO_ESP: case IPPROTO_MH: /* - * count option headers to the header length for + * count option headers to the header length for * checksum processing */ + /* Common structure of ipv6 ext headers is: + * uint8: next header protocol + * uint8: length of this header, in multiples of 8, not + * including first eight octets + * The pointer arithmetic below follows from above. + */ ip_nh = *((uint8_t*)ip6h_p+ip_hl); /* next next header */ ip_hl += (*((uint8_t*)ip6h_p+ip_hl+1)+1)*8; /* ext header length */ break; |