diff options
Diffstat (limited to 'usr.sbin/vmd/vmd.c')
| -rw-r--r-- | usr.sbin/vmd/vmd.c | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/usr.sbin/vmd/vmd.c b/usr.sbin/vmd/vmd.c index 8053b02620f..9423081df1e 100644 --- a/usr.sbin/vmd/vmd.c +++ b/usr.sbin/vmd/vmd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: vmd.c,v 1.104 2018/10/15 10:35:41 reyk Exp $ */ +/* $OpenBSD: vmd.c,v 1.105 2018/11/21 12:31:47 reyk Exp $ */ /* * Copyright (c) 2015 Reyk Floeter <reyk@openbsd.org> @@ -1923,6 +1923,25 @@ prefixlen2mask(uint8_t prefixlen) } void +prefixlen2mask6(uint8_t prefixlen, struct in6_addr *mask) +{ + struct in6_addr s6; + int i; + + if (prefixlen > 128) + prefixlen = 128; + + memset(&s6, 0, sizeof(s6)); + for (i = 0; i < prefixlen / 8; i++) + s6.s6_addr[i] = 0xff; + i = prefixlen % 8; + if (i) + s6.s6_addr[prefixlen / 8] = 0xff00 >> i; + + memcpy(mask, &s6, sizeof(s6)); +} + +void getmonotime(struct timeval *tv) { struct timespec ts; |
