diff --git a/addr_hash.c b/addr_hash.c index 135709c..70e5ff1 100644 --- a/addr_hash.c +++ b/addr_hash.c @@ -43,7 +43,7 @@ int hash(void* key) { addr_pair* ap = (addr_pair*)key; if (ap->af == AF_INET6) { - uint32_t* addr6 = ap->src6.s6_addr32; + uint32_t* addr6 = (uint32_t*)ap->src6.s6_addr; hash = ( hash_uint32(addr6[0]) + hash_uint32(addr6[1]) @@ -51,7 +51,7 @@ int hash(void* key) { + hash_uint32(addr6[3]) + ap->src_port) % 0xFF; - addr6 = ap->dst6.s6_addr32; + addr6 = (uint32_t*)ap->dst6.s6_addr; hash = ( hash + hash_uint32(addr6[0]) + hash_uint32(addr6[1]) + hash_uint32(addr6[2]) diff --git a/iftop.c b/iftop.c index d372180..e1c2953 100644 --- a/iftop.c +++ b/iftop.c @@ -328,11 +328,11 @@ static void handle_ip_packet(struct ip* iptr, int hw_dir) /* First reduce the participating addresses using the netfilter prefix. * We need scratch pads to do this. */ - for (j=0; j < 4; ++j) { - scribdst.s6_addr32[j] = ip6tr->ip6_dst.s6_addr32[j] - & options.netfilter6mask.s6_addr32[j]; - scribsrc.s6_addr32[j] = ip6tr->ip6_src.s6_addr32[j] - & options.netfilter6mask.s6_addr32[j]; + for (j=0; j < 16; ++j) { + scribdst.s6_addr[j] = ip6tr->ip6_dst.s6_addr[j] + & options.netfilter6mask.s6_addr[j]; + scribsrc.s6_addr[j] = ip6tr->ip6_src.s6_addr[j] + & options.netfilter6mask.s6_addr[j]; } /* Now look for any hits. */ diff --git a/ns_hash.c b/ns_hash.c index 947cbef..219de95 100644 --- a/ns_hash.c +++ b/ns_hash.c @@ -29,7 +29,7 @@ static int __inline__ hash_uint32(uint32_t n) { int ns_hash_hash(void* key) { int hash; - uint32_t* addr6 = ((struct in6_addr *) key)->s6_addr32; + uint32_t* addr6 = (uint32_t*)((struct in6_addr *) key)->s6_addr; hash = ( hash_uint32(addr6[0]) + hash_uint32(addr6[1]) diff --git a/options.c b/options.c index 02e091a..1f61cbb 100644 --- a/options.c +++ b/options.c @@ -163,7 +163,7 @@ void options_set_defaults() { } static void die(char *msg) { - fprintf(stderr, msg); + fprintf(stderr, "%s", msg); exit(1); } @@ -538,18 +538,19 @@ int options_config_get_net_filter6() { } else { int bl, rem; - const uint32_t mm = 0xffffffff; - uint32_t part = mm; + const uint8_t mm = 0xff; + uint8_t part = mm; - bl = n / 32; - rem = n % 32; - part <<= 32 - rem; + bl = n / 8; + rem = n % 8; + part <<= 8 - rem; for (j=0; j < bl; ++j) - options.netfilter6mask.s6_addr32[j] = htonl(mm); + options.netfilter6mask.s6_addr[j] = mm; + if (rem > 0) - options.netfilter6mask.s6_addr32[bl] = htonl(part); + options.netfilter6mask.s6_addr[bl] = part; options.netfilter6 = 1; - } + } } else { if (inet_pton(AF_INET6, mask, &options.netfilter6mask) != 0)