Home | History | Annotate | Line # | Download | only in ifconfig
af_inet6.c revision 1.14
      1 /*	$NetBSD: af_inet6.c,v 1.14 2008/05/11 22:07:23 dyoung Exp $	*/
      2 
      3 /*
      4  * Copyright (c) 1983, 1993
      5  *      The Regents of the University of California.  All rights reserved.
      6  *
      7  * Redistribution and use in source and binary forms, with or without
      8  * modification, are permitted provided that the following conditions
      9  * are met:
     10  * 1. Redistributions of source code must retain the above copyright
     11  *    notice, this list of conditions and the following disclaimer.
     12  * 2. Redistributions in binary form must reproduce the above copyright
     13  *    notice, this list of conditions and the following disclaimer in the
     14  *    documentation and/or other materials provided with the distribution.
     15  * 3. Neither the name of the University nor the names of its contributors
     16  *    may be used to endorse or promote products derived from this software
     17  *    without specific prior written permission.
     18  *
     19  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
     20  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     21  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     22  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
     23  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     24  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     25  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     26  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     27  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     28  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     29  * SUCH DAMAGE.
     30  */
     31 
     32 #include <sys/cdefs.h>
     33 #ifndef lint
     34 __RCSID("$NetBSD: af_inet6.c,v 1.14 2008/05/11 22:07:23 dyoung Exp $");
     35 #endif /* not lint */
     36 
     37 #include <sys/param.h>
     38 #include <sys/ioctl.h>
     39 #include <sys/socket.h>
     40 
     41 #include <net/if.h>
     42 #include <netinet/in.h>
     43 #include <netinet/in_var.h>
     44 #include <netinet6/nd6.h>
     45 
     46 #include <err.h>
     47 #include <errno.h>
     48 #include <ifaddrs.h>
     49 #include <netdb.h>
     50 #include <string.h>
     51 #include <stdlib.h>
     52 #include <stdio.h>
     53 #include <util.h>
     54 
     55 #include "env.h"
     56 #include "parse.h"
     57 #include "extern.h"
     58 #include "af_inet6.h"
     59 #include "af_inetany.h"
     60 
     61 struct in6_ifreq    in6_ridreq = {
     62 	.ifr_addr = {
     63 		.sin6_family = AF_INET6,
     64 		.sin6_addr = {
     65 			.s6_addr =
     66 			    {0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff}
     67 		}
     68 	}
     69 };
     70 
     71 struct in6_aliasreq in6_addreq = {
     72 	.ifra_prefixmask = {
     73 		.sin6_len = sizeof(in6_addreq.ifra_prefixmask),
     74 		.sin6_addr = {
     75 			.s6_addr =
     76 			    {0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff}}},
     77 	.ifra_lifetime = {
     78 		  .ia6t_pltime = ND6_INFINITE_LIFETIME
     79 		, .ia6t_vltime = ND6_INFINITE_LIFETIME
     80 	}
     81 };
     82 
     83 static const struct kwinst ia6flagskw[] = {
     84 	  IFKW("anycast",	IN6_IFF_ANYCAST)
     85 	, IFKW("tentative",	IN6_IFF_TENTATIVE)
     86 	, IFKW("deprecated",	IN6_IFF_DEPRECATED)
     87 };
     88 
     89 static struct pinteger parse_pltime = PINTEGER_INITIALIZER(&parse_pltime,
     90     "pltime", 0, setia6pltime, "pltime", &command_root.pb_parser);
     91 
     92 static struct pinteger parse_vltime = PINTEGER_INITIALIZER(&parse_vltime,
     93     "vltime", 0, setia6vltime, "vltime", &command_root.pb_parser);
     94 
     95 static const struct kwinst inet6kw[] = {
     96 	  {.k_word = "pltime", .k_nextparser = &parse_pltime.pi_parser}
     97 	, {.k_word = "vltime", .k_nextparser = &parse_vltime.pi_parser}
     98 	, {.k_word = "eui64", .k_key = "eui64", .k_type = KW_T_BOOL,
     99 	   .k_bool = true, .k_exec = setia6eui64,
    100 	   .k_nextparser = &command_root.pb_parser}
    101 };
    102 
    103 struct pkw ia6flags = PKW_INITIALIZER(&ia6flags, "ia6flags", setia6flags,
    104     "ia6flag", ia6flagskw, __arraycount(ia6flagskw), &command_root.pb_parser);
    105 struct pkw inet6 = PKW_INITIALIZER(&inet6, "IPv6 keywords", NULL,
    106     NULL, inet6kw, __arraycount(inet6kw), NULL);
    107 
    108 static void in6_delscopeid(struct sockaddr_in6 *sin6);
    109 static int setia6lifetime(prop_dictionary_t, int64_t, time_t *, uint32_t *);
    110 static void in6_alias(const char *, prop_dictionary_t, prop_dictionary_t,
    111     struct in6_ifreq *);
    112 
    113 static char *
    114 sec2str(time_t total)
    115 {
    116 	static char result[256];
    117 	int days, hours, mins, secs;
    118 	int first = 1;
    119 	char *p = result;
    120 	char *end = &result[sizeof(result)];
    121 	int n;
    122 
    123 	if (0) {	/*XXX*/
    124 		days = total / 3600 / 24;
    125 		hours = (total / 3600) % 24;
    126 		mins = (total / 60) % 60;
    127 		secs = total % 60;
    128 
    129 		if (days) {
    130 			first = 0;
    131 			n = snprintf(p, end - p, "%dd", days);
    132 			if (n < 0 || n >= end - p)
    133 				return(result);
    134 			p += n;
    135 		}
    136 		if (!first || hours) {
    137 			first = 0;
    138 			n = snprintf(p, end - p, "%dh", hours);
    139 			if (n < 0 || n >= end - p)
    140 				return(result);
    141 			p += n;
    142 		}
    143 		if (!first || mins) {
    144 			first = 0;
    145 			n = snprintf(p, end - p, "%dm", mins);
    146 			if (n < 0 || n >= end - p)
    147 				return(result);
    148 			p += n;
    149 		}
    150 		snprintf(p, end - p, "%ds", secs);
    151 	} else
    152 		snprintf(p, end - p, "%lu", (u_long)total);
    153 
    154 	return(result);
    155 }
    156 
    157 static int
    158 prefix(void *val, int size)
    159 {
    160 	u_char *pname = (u_char *)val;
    161 	int byte, bit, plen = 0;
    162 
    163 	for (byte = 0; byte < size; byte++, plen += 8)
    164 		if (pname[byte] != 0xff)
    165 			break;
    166 	if (byte == size)
    167 		return (plen);
    168 	for (bit = 7; bit != 0; bit--, plen++)
    169 		if (!(pname[byte] & (1 << bit)))
    170 			break;
    171 	for (; bit != 0; bit--)
    172 		if (pname[byte] & (1 << bit))
    173 			return(0);
    174 	byte++;
    175 	for (; byte < size; byte++)
    176 		if (pname[byte])
    177 			return(0);
    178 	return (plen);
    179 }
    180 
    181 int
    182 setia6flags_impl(prop_dictionary_t env, struct in6_aliasreq *ifra)
    183 {
    184 	int64_t ia6flag;
    185 
    186 	if (!prop_dictionary_get_int64(env, "ia6flag", &ia6flag)) {
    187 		errno = ENOENT;
    188 		return -1;
    189 	}
    190 
    191 	if (ia6flag < 0) {
    192 		ia6flag = -ia6flag;
    193 		ifra->ifra_flags &= ~ia6flag;
    194 	} else
    195 		ifra->ifra_flags |= ia6flag;
    196 	return 0;
    197 }
    198 
    199 int
    200 setia6flags(prop_dictionary_t env, prop_dictionary_t xenv)
    201 {
    202 	return setia6flags_impl(env, &in6_addreq);
    203 }
    204 
    205 int
    206 setia6pltime_impl(prop_dictionary_t env, struct in6_aliasreq *ifra)
    207 {
    208 	int64_t pltime;
    209 
    210 	if (!prop_dictionary_get_int64(env, "pltime", &pltime)) {
    211 		errno = ENOENT;
    212 		return -1;
    213 	}
    214 
    215 	return setia6lifetime(env, pltime,
    216 	    &ifra->ifra_lifetime.ia6t_preferred,
    217 	    &ifra->ifra_lifetime.ia6t_pltime);
    218 }
    219 
    220 int
    221 setia6pltime(prop_dictionary_t env, prop_dictionary_t xenv)
    222 {
    223 	return setia6pltime_impl(env, &in6_addreq);
    224 }
    225 
    226 int
    227 setia6vltime_impl(prop_dictionary_t env, struct in6_aliasreq *ifra)
    228 {
    229 	int64_t vltime;
    230 
    231 	if (!prop_dictionary_get_int64(env, "vltime", &vltime)) {
    232 		errno = ENOENT;
    233 		return -1;
    234 	}
    235 
    236 	return setia6lifetime(env, vltime,
    237 		&ifra->ifra_lifetime.ia6t_expire,
    238 		&ifra->ifra_lifetime.ia6t_vltime);
    239 }
    240 
    241 int
    242 setia6vltime(prop_dictionary_t env, prop_dictionary_t xenv)
    243 {
    244 	return setia6vltime_impl(env, &in6_addreq);
    245 }
    246 
    247 static int
    248 setia6lifetime(prop_dictionary_t env, int64_t val, time_t *timep,
    249     uint32_t *ivalp)
    250 {
    251 	time_t t;
    252 	int af;
    253 
    254 	if ((af = getaf(env)) == -1 || af != AF_INET6) {
    255 		errx(EXIT_FAILURE,
    256 		    "inet6 address lifetime not allowed for the AF");
    257 	}
    258 
    259 	t = time(NULL);
    260 	*timep = t + val;
    261 	*ivalp = val;
    262 	return 0;
    263 }
    264 
    265 int
    266 setia6eui64_impl(prop_dictionary_t env, struct in6_aliasreq *ifra)
    267 {
    268 	char buf[2][80];
    269 	struct ifaddrs *ifap, *ifa;
    270 	const struct sockaddr_in6 *sin6 = NULL;
    271 	const struct in6_addr *lladdr = NULL;
    272 	struct in6_addr *in6;
    273 	const char *ifname;
    274 	bool doit = false;
    275 	int af;
    276 
    277 	if (!prop_dictionary_get_bool(env, "eui64", &doit) || !doit) {
    278 		errno = ENOENT;
    279 		return -1;
    280 	}
    281 
    282 	if ((ifname = getifname(env)) == NULL)
    283 		return -1;
    284 
    285 	af = getaf(env);
    286 	if (af != AF_INET6) {
    287 		errx(EXIT_FAILURE,
    288 		    "eui64 address modifier not allowed for the AF");
    289 	}
    290  	in6 = &ifra->ifra_addr.sin6_addr;
    291 	if (memcmp(&in6addr_any.s6_addr[8], &in6->s6_addr[8], 8) != 0) {
    292 		union {
    293 			struct sockaddr_in6 sin6;
    294 			struct sockaddr sa;
    295 		} any = {.sin6 = {.sin6_family = AF_INET6}};
    296 		memcpy(&any.sin6.sin6_addr, &in6addr_any,
    297 		    sizeof(any.sin6.sin6_addr));
    298 		(void)sockaddr_snprintf(buf[0], sizeof(buf[0]), "%a%%S",
    299 		    &any.sa);
    300 		(void)sockaddr_snprintf(buf[1], sizeof(buf[1]), "%a%%S",
    301 		    (const struct sockaddr *)&ifra->ifra_addr);
    302 		errx(EXIT_FAILURE, "interface index is already filled, %s | %s",
    303 		    buf[0], buf[1]);
    304 	}
    305 	if (getifaddrs(&ifap) != 0)
    306 		err(EXIT_FAILURE, "getifaddrs");
    307 	for (ifa = ifap; ifa; ifa = ifa->ifa_next) {
    308 		if (ifa->ifa_addr->sa_family == AF_INET6 &&
    309 		    strcmp(ifa->ifa_name, ifname) == 0) {
    310 			sin6 = (const struct sockaddr_in6 *)ifa->ifa_addr;
    311 			if (IN6_IS_ADDR_LINKLOCAL(&sin6->sin6_addr)) {
    312 				lladdr = &sin6->sin6_addr;
    313 				break;
    314 			}
    315 		}
    316 	}
    317 	if (!lladdr)
    318 		errx(EXIT_FAILURE, "could not determine link local address");
    319 
    320  	memcpy(&in6->s6_addr[8], &lladdr->s6_addr[8], 8);
    321 
    322 	freeifaddrs(ifap);
    323 	return 0;
    324 }
    325 
    326 int
    327 setia6eui64(prop_dictionary_t env, prop_dictionary_t xenv)
    328 {
    329 	return setia6eui64_impl(env, &in6_addreq);
    330 }
    331 
    332 /* KAME idiosyncrasy */
    333 static void
    334 in6_delscopeid(struct sockaddr_in6 *sin6)
    335 {
    336 	if (!IN6_IS_ADDR_LINKLOCAL(&sin6->sin6_addr) ||
    337 	    sin6->sin6_scope_id == 0)
    338 		return;
    339 
    340 	*(u_int16_t *)&sin6->sin6_addr.s6_addr[2] = htons(sin6->sin6_scope_id);
    341 	sin6->sin6_scope_id = 0;
    342 }
    343 
    344 /* KAME idiosyncrasy */
    345 void
    346 in6_fillscopeid(struct sockaddr_in6 *sin6)
    347 {
    348 	if (IN6_IS_ADDR_LINKLOCAL(&sin6->sin6_addr)) {
    349 		sin6->sin6_scope_id =
    350 			ntohs(*(u_int16_t *)&sin6->sin6_addr.s6_addr[2]);
    351 		sin6->sin6_addr.s6_addr[2] = sin6->sin6_addr.s6_addr[3] = 0;
    352 	}
    353 }
    354 
    355 /* XXX not really an alias */
    356 void
    357 in6_alias(const char *ifname, prop_dictionary_t env, prop_dictionary_t oenv,
    358     struct in6_ifreq *creq)
    359 {
    360 	struct in6_ifreq ifr6;
    361 	struct sockaddr_in6 *sin6;
    362 	char hbuf[NI_MAXHOST];
    363 	u_int32_t scopeid;
    364 	int s;
    365 	const int niflag = NI_NUMERICHOST;
    366 	unsigned short flags;
    367 
    368 	/* Get the non-alias address for this interface. */
    369 	if ((s = getsock(AF_INET6)) == -1) {
    370 		if (errno == EAFNOSUPPORT)
    371 			return;
    372 		err(EXIT_FAILURE, "socket");
    373 	}
    374 
    375 	sin6 = (struct sockaddr_in6 *)&creq->ifr_addr;
    376 
    377 	in6_fillscopeid(sin6);
    378 	scopeid = sin6->sin6_scope_id;
    379 	if (getnameinfo((struct sockaddr *)sin6, sin6->sin6_len,
    380 			hbuf, sizeof(hbuf), NULL, 0, niflag))
    381 		strlcpy(hbuf, "", sizeof(hbuf));	/* some message? */
    382 	printf("\tinet6 %s", hbuf);
    383 
    384 	if (getifflags(env, oenv, &flags) == -1)
    385 		err(EXIT_FAILURE, "%s: getifflags", __func__);
    386 
    387 	if (flags & IFF_POINTOPOINT) {
    388 		memset(&ifr6, 0, sizeof(ifr6));
    389 		estrlcpy(ifr6.ifr_name, ifname, sizeof(ifr6.ifr_name));
    390 		ifr6.ifr_addr = creq->ifr_addr;
    391 		if (ioctl(s, SIOCGIFDSTADDR_IN6, &ifr6) == -1) {
    392 			if (errno != EADDRNOTAVAIL)
    393 				warn("SIOCGIFDSTADDR_IN6");
    394 			memset(&ifr6.ifr_addr, 0, sizeof(ifr6.ifr_addr));
    395 			ifr6.ifr_addr.sin6_family = AF_INET6;
    396 			ifr6.ifr_addr.sin6_len = sizeof(struct sockaddr_in6);
    397 		}
    398 		sin6 = (struct sockaddr_in6 *)&ifr6.ifr_addr;
    399 		in6_fillscopeid(sin6);
    400 		hbuf[0] = '\0';
    401 		if (getnameinfo((struct sockaddr *)sin6, sin6->sin6_len,
    402 				hbuf, sizeof(hbuf), NULL, 0, niflag))
    403 			strlcpy(hbuf, "", sizeof(hbuf)); /* some message? */
    404 		printf(" -> %s", hbuf);
    405 	}
    406 
    407 	memset(&ifr6, 0, sizeof(ifr6));
    408 	estrlcpy(ifr6.ifr_name, ifname, sizeof(ifr6.ifr_name));
    409 	ifr6.ifr_addr = creq->ifr_addr;
    410 	if (ioctl(s, SIOCGIFNETMASK_IN6, &ifr6) == -1) {
    411 		if (errno != EADDRNOTAVAIL)
    412 			warn("SIOCGIFNETMASK_IN6");
    413 	} else {
    414 		sin6 = (struct sockaddr_in6 *)&ifr6.ifr_addr;
    415 		printf(" prefixlen %d", prefix(&sin6->sin6_addr,
    416 					       sizeof(struct in6_addr)));
    417 	}
    418 
    419 	memset(&ifr6, 0, sizeof(ifr6));
    420 	estrlcpy(ifr6.ifr_name, ifname, sizeof(ifr6.ifr_name));
    421 	ifr6.ifr_addr = creq->ifr_addr;
    422 	if (ioctl(s, SIOCGIFAFLAG_IN6, &ifr6) == -1) {
    423 		if (errno != EADDRNOTAVAIL)
    424 			warn("SIOCGIFAFLAG_IN6");
    425 	} else {
    426 		if (ifr6.ifr_ifru.ifru_flags6 & IN6_IFF_ANYCAST)
    427 			printf(" anycast");
    428 		if (ifr6.ifr_ifru.ifru_flags6 & IN6_IFF_TENTATIVE)
    429 			printf(" tentative");
    430 		if (ifr6.ifr_ifru.ifru_flags6 & IN6_IFF_DUPLICATED)
    431 			printf(" duplicated");
    432 		if (ifr6.ifr_ifru.ifru_flags6 & IN6_IFF_DETACHED)
    433 			printf(" detached");
    434 		if (ifr6.ifr_ifru.ifru_flags6 & IN6_IFF_DEPRECATED)
    435 			printf(" deprecated");
    436 	}
    437 
    438 	if (scopeid)
    439 		printf(" scopeid 0x%x", scopeid);
    440 
    441 	if (Lflag) {
    442 		struct in6_addrlifetime *lifetime;
    443 		memset(&ifr6, 0, sizeof(ifr6));
    444 		estrlcpy(ifr6.ifr_name, ifname, sizeof(ifr6.ifr_name));
    445 		ifr6.ifr_addr = creq->ifr_addr;
    446 		lifetime = &ifr6.ifr_ifru.ifru_lifetime;
    447 		if (ioctl(s, SIOCGIFALIFETIME_IN6, &ifr6) == -1) {
    448 			if (errno != EADDRNOTAVAIL)
    449 				warn("SIOCGIFALIFETIME_IN6");
    450 		} else if (lifetime->ia6t_preferred || lifetime->ia6t_expire) {
    451 			time_t t = time(NULL);
    452 			printf(" pltime ");
    453 			if (lifetime->ia6t_preferred) {
    454 				printf("%s", lifetime->ia6t_preferred < t
    455 					? "0"
    456 					: sec2str(lifetime->ia6t_preferred - t));
    457 			} else
    458 				printf("infty");
    459 
    460 			printf(" vltime ");
    461 			if (lifetime->ia6t_expire) {
    462 				printf("%s", lifetime->ia6t_expire < t
    463 					? "0"
    464 					: sec2str(lifetime->ia6t_expire - t));
    465 			} else
    466 				printf("infty");
    467 		}
    468 	}
    469 
    470 	printf("\n");
    471 }
    472 
    473 void
    474 in6_status(prop_dictionary_t env, prop_dictionary_t oenv, bool force)
    475 {
    476 	struct ifaddrs *ifap, *ifa;
    477 	struct in6_ifreq ifr;
    478 	const char *ifname;
    479 
    480 	if ((ifname = getifname(env)) == NULL)
    481 		err(EXIT_FAILURE, "%s: getifname", __func__);
    482 
    483 	if (getifaddrs(&ifap) != 0)
    484 		err(EXIT_FAILURE, "getifaddrs");
    485 	for (ifa = ifap; ifa; ifa = ifa->ifa_next) {
    486 		if (strcmp(ifname, ifa->ifa_name) != 0)
    487 			continue;
    488 		if (ifa->ifa_addr->sa_family != AF_INET6)
    489 			continue;
    490 		if (sizeof(ifr.ifr_addr) < ifa->ifa_addr->sa_len)
    491 			continue;
    492 
    493 		memset(&ifr, 0, sizeof(ifr));
    494 		estrlcpy(ifr.ifr_name, ifa->ifa_name, sizeof(ifr.ifr_name));
    495 		memcpy(&ifr.ifr_addr, ifa->ifa_addr, ifa->ifa_addr->sa_len);
    496 		in6_alias(ifname, env, oenv, &ifr);
    497 	}
    498 	freeifaddrs(ifap);
    499 }
    500 
    501 #define SIN6(x) ((struct sockaddr_in6 *) &(x))
    502 struct sockaddr_in6 *sin6tab[] = {
    503     SIN6(in6_ridreq.ifr_addr), SIN6(in6_addreq.ifra_addr),
    504     SIN6(in6_addreq.ifra_prefixmask), SIN6(in6_addreq.ifra_dstaddr)};
    505 
    506 void
    507 in6_getaddr(const struct paddr_prefix *pfx, int which)
    508 {
    509 	struct sockaddr_in6 *sin6 = sin6tab[which];
    510 
    511 	if (pfx->pfx_addr.sa_family != AF_INET6)
    512 		errx(EXIT_FAILURE, "%s: address family mismatch", __func__);
    513 
    514 	if (which == ADDR && pfx->pfx_len >= 0)
    515 		in6_getprefix(pfx->pfx_len, MASK);
    516 
    517 	memcpy(sin6, &pfx->pfx_addr, MIN(sizeof(*sin6), pfx->pfx_addr.sa_len));
    518 
    519 	in6_delscopeid(sin6);
    520 }
    521 
    522 void
    523 in6_getprefix(int len, int which)
    524 {
    525 	struct sockaddr_in6 *gpsin = sin6tab[which];
    526 	u_char *cp;
    527 
    528 	if (len < 0 || len > 128)
    529 		errx(EXIT_FAILURE, "%d: bad value", len);
    530 	gpsin->sin6_len = sizeof(*gpsin);
    531 	if (which != MASK)
    532 		gpsin->sin6_family = AF_INET6;
    533 	if (len == 0 || len == 128) {
    534 		memset(&gpsin->sin6_addr, 0xff, sizeof(struct in6_addr));
    535 		return;
    536 	}
    537 	memset((void *)&gpsin->sin6_addr, 0x00, sizeof(gpsin->sin6_addr));
    538 	for (cp = (u_char *)&gpsin->sin6_addr; len > 7; len -= 8)
    539 		*cp++ = 0xff;
    540 	if (len)
    541 		*cp = 0xff << (8 - len);
    542 }
    543 
    544 static int
    545 in6_pre_aifaddr(prop_dictionary_t env, struct afparam *param)
    546 {
    547 	struct in6_aliasreq *ifra = param->req.buf;
    548 
    549 	setia6eui64_impl(env, ifra);
    550 	setia6vltime_impl(env, ifra);
    551 	setia6pltime_impl(env, ifra);
    552 	setia6flags_impl(env, ifra);
    553 	in6_delscopeid(&ifra->ifra_addr);
    554 	in6_delscopeid(&ifra->ifra_dstaddr);
    555 
    556 	return 0;
    557 }
    558 
    559 void
    560 in6_commit_address(prop_dictionary_t env, prop_dictionary_t oenv)
    561 {
    562 	struct in6_ifreq in6_ifr = {
    563 		.ifr_addr = {
    564 			.sin6_family = AF_INET6,
    565 			.sin6_addr = {
    566 				.s6_addr =
    567 				    {0xff, 0xff, 0xff, 0xff,
    568 				     0xff, 0xff, 0xff, 0xff}
    569 			}
    570 		}
    571 	};
    572 	static struct sockaddr_in6 in6_defmask = {
    573 		.sin6_addr = {
    574 			.s6_addr = {0xff, 0xff, 0xff, 0xff,
    575 			            0xff, 0xff, 0xff, 0xff}
    576 		}
    577 	};
    578 
    579 	struct in6_aliasreq in6_ifra = {
    580 		.ifra_prefixmask = {
    581 			.sin6_addr = {
    582 				.s6_addr =
    583 				    {0xff, 0xff, 0xff, 0xff,
    584 				     0xff, 0xff, 0xff, 0xff}}},
    585 		.ifra_lifetime = {
    586 			  .ia6t_pltime = ND6_INFINITE_LIFETIME
    587 			, .ia6t_vltime = ND6_INFINITE_LIFETIME
    588 		}
    589 	};
    590 	struct afparam in6param = {
    591 		  .req = BUFPARAM(in6_ifra)
    592 		, .dgreq = BUFPARAM(in6_ifr)
    593 		, .name = {
    594 			{.buf = in6_ifr.ifr_name,
    595 			 .buflen = sizeof(in6_ifr.ifr_name)},
    596 			{.buf = in6_ifra.ifra_name,
    597 			 .buflen = sizeof(in6_ifra.ifra_name)}
    598 		  }
    599 		, .dgaddr = BUFPARAM(in6_ifr.ifr_addr)
    600 		, .addr = BUFPARAM(in6_ifra.ifra_addr)
    601 		, .dst = BUFPARAM(in6_ifra.ifra_dstaddr)
    602 		, .brd = BUFPARAM(in6_ifra.ifra_broadaddr)
    603 		, .mask = BUFPARAM(in6_ifra.ifra_prefixmask)
    604 		, .aifaddr = IFADDR_PARAM(SIOCAIFADDR_IN6)
    605 		, .difaddr = IFADDR_PARAM(SIOCDIFADDR_IN6)
    606 		, .gifaddr = IFADDR_PARAM(SIOCGIFADDR_IN6)
    607 		, .defmask = BUFPARAM(in6_defmask)
    608 		, .pre_aifaddr = in6_pre_aifaddr
    609 	};
    610 	commit_address(env, oenv, &in6param);
    611 }
    612