提交 9947ed5c 编写于 作者: R rofl0r

getifaddrs: implement proper ipv6 netmasks

上级 23ab8c25
...@@ -51,8 +51,17 @@ void freeifaddrs(struct ifaddrs *ifp) ...@@ -51,8 +51,17 @@ void freeifaddrs(struct ifaddrs *ifp)
static void ipv6netmask(unsigned prefix_length, struct sockaddr_in6 *sa) static void ipv6netmask(unsigned prefix_length, struct sockaddr_in6 *sa)
{ {
// FIXME: left for bit-wizard rich unsigned char* hb = sa->sin6_addr.s6_addr;
memset(&sa->sin6_addr, -1, sizeof(sa->sin6_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) static void dealwithipv6(stor **list, stor** head)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册