--- libelwix/src/net.c 2013/06/03 11:48:26 1.2.2.2 +++ libelwix/src/net.c 2013/06/03 14:00:26 1.3 @@ -3,7 +3,7 @@ * by Michael Pounov * * $Author: misho $ -* $Id: net.c,v 1.2.2.2 2013/06/03 11:48:26 misho Exp $ +* $Id: net.c,v 1.3 2013/06/03 14:00:26 misho Exp $ * ************************************************************************** The ELWIX and AITNET software is distributed under the following @@ -300,12 +300,18 @@ e_innet(netaddr_t * __restrict net, inaddr_t * __restr switch (net->addr.sa.sa_family) { case AF_INET: - ret = net->addr.sin.sin_addr.s_addr & net->mask.in.s_addr; - ret -= addr->in.s_addr & net->mask.in.s_addr; + for (i = 0; i < sizeof(struct in_addr); i++) { + ret = ((caddr_t) &net->addr.sin.sin_addr.s_addr)[i] & + net->mask.in.s4_addr[i]; + ret -= addr->in.s4_addr[i] & net->mask.in.s4_addr[i]; + if (ret) + break; + } break; case AF_INET6: for (i = 0; i < sizeof(struct in6_addr); i++) { - ret = net->addr.sin6.sin6_addr.s6_addr[i] & net->mask.in6.s6_addr[i]; + ret = net->addr.sin6.sin6_addr.s6_addr[i] & + net->mask.in6.s6_addr[i]; ret -= addr->in6.s6_addr[i] & net->mask.in6.s6_addr[i]; if (ret) break;