Commit fc511cfe by pdw

Patch from Scott Bertilson <ssb@umn.edu> to remove dependence on s6_addr32.

1 parent cd57e767
Showing with 18 additions and 17 deletions
......@@ -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])
......
......@@ -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. */
......
......@@ -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])
......
......@@ -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)
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!