diff options
author | rofl0r <retnyg@gmx.net> | 2013-04-09 11:00:52 +0200 |
---|---|---|
committer | rofl0r <retnyg@gmx.net> | 2013-04-09 16:52:13 +0200 |
commit | 9947ed5c2008ca7ec8461dbc0db8a2aacddcea6b (patch) | |
tree | ee7f19f86da282a73fdc34d85b1494b9f8e99424 /src/network | |
parent | 23ab8c255543a7e0876c7e1858ef0d4bbd562729 (diff) | |
download | musl-9947ed5c2008ca7ec8461dbc0db8a2aacddcea6b.tar.gz musl-9947ed5c2008ca7ec8461dbc0db8a2aacddcea6b.tar.bz2 musl-9947ed5c2008ca7ec8461dbc0db8a2aacddcea6b.tar.xz musl-9947ed5c2008ca7ec8461dbc0db8a2aacddcea6b.zip |
getifaddrs: implement proper ipv6 netmasks
Diffstat (limited to 'src/network')
-rw-r--r-- | src/network/getifaddrs.c | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/src/network/getifaddrs.c b/src/network/getifaddrs.c index 9ccf4579..a4c31782 100644 --- a/src/network/getifaddrs.c +++ b/src/network/getifaddrs.c @@ -51,8 +51,17 @@ void freeifaddrs(struct ifaddrs *ifp) static void ipv6netmask(unsigned prefix_length, struct sockaddr_in6 *sa) { - // FIXME: left for bit-wizard rich - memset(&sa->sin6_addr, -1, sizeof(sa->sin6_addr)); + unsigned char* hb = sa->sin6_addr.s6_addr; + unsigned onebytes = prefix_length / 8; + unsigned bits = prefix_length % 8; + unsigned nullbytes = 16 - onebytes; + memset(hb, -1, onebytes); + memset(hb+onebytes, 0, nullbytes); + if(bits) { + unsigned char x = -1; + x <<= 8 - bits; + hb[onebytes] = x; + } } static void dealwithipv6(stor **list, stor** head) |