--- libelwix/src/net.c 2020/05/27 15:02:33 1.20.4.1 +++ libelwix/src/net.c 2022/09/26 19:39:23 1.22 @@ -3,7 +3,7 @@ * by Michael Pounov * * $Author: misho $ -* $Id: net.c,v 1.20.4.1 2020/05/27 15:02:33 misho Exp $ +* $Id: net.c,v 1.22 2022/09/26 19:39:23 misho Exp $ * ************************************************************************** The ELWIX and AITNET software is distributed under the following @@ -12,7 +12,7 @@ terms: All of the documentation and software included in the ELWIX and AITNET Releases is copyrighted by ELWIX - Sofia/Bulgaria -Copyright 2004 - 2020 +Copyright 2004 - 2022 by Michael Pounov . All rights reserved. Redistribution and use in source and binary forms, with or without @@ -813,20 +813,31 @@ e_network(const char *csAddr, netaddr_t * __restrict n if (mask > 128) return -1; else { +#ifndef __linux__ for (i = 0; i < 4 && (mask / 32); i++, mask -= 32) net->mask.in6.__u6_addr.__u6_addr32[i] = 0xFFFFFFFF; if (mask) net->mask.in6.__u6_addr.__u6_addr32[i] = E_CIDRMASK(mask % 32); +#else + for (i = 0; i < 4 && (mask / 32); i++, mask -= 32) + net->mask.in6.__in6_u.__u6_addr32[i] = 0xFFFFFFFF; + if (mask) + net->mask.in6.__in6_u.__u6_addr32[i] = E_CIDRMASK(mask % 32); +#endif } inet_pton(AF_INET6, szAddr, &a.in6); #ifndef __linux__ net->addr.sin6.sin6_len = sizeof net->addr.sin6; -#endif for (i = 0; i < 4; i++) net->addr.sin6.sin6_addr.__u6_addr.__u6_addr32[i] = a.in6.__u6_addr.__u6_addr32[i] & net->mask.in6.__u6_addr.__u6_addr32[i]; +#else + for (i = 0; i < 4; i++) + net->addr.sin6.sin6_addr.__in6_u.__u6_addr32[i] = + a.in6.__in6_u.__u6_addr32[i] & net->mask.in6.__in6_u.__u6_addr32[i]; +#endif } else { if (mask > 32) return -1;