Module Name: src Committed By: roy Date: Sat May 2 14:43:51 UTC 2015
Modified Files: src/sbin/ifconfig: af_inet.c Log Message: Report IN_IFF_TENTATIVE and friends. Wait for IN_IFF_TENTATIVE to be removed with the -w flag. To generate a diff of this commit: cvs rdiff -u -r1.15 -r1.16 src/sbin/ifconfig/af_inet.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sbin/ifconfig/af_inet.c diff -u src/sbin/ifconfig/af_inet.c:1.15 src/sbin/ifconfig/af_inet.c:1.16 --- src/sbin/ifconfig/af_inet.c:1.15 Mon Dec 13 17:35:08 2010 +++ src/sbin/ifconfig/af_inet.c Sat May 2 14:43:51 2015 @@ -1,4 +1,4 @@ -/* $NetBSD: af_inet.c,v 1.15 2010/12/13 17:35:08 pooka Exp $ */ +/* $NetBSD: af_inet.c,v 1.16 2015/05/02 14:43:51 roy Exp $ */ /* * Copyright (c) 1983, 1993 @@ -31,7 +31,7 @@ #include <sys/cdefs.h> #ifndef lint -__RCSID("$NetBSD: af_inet.c,v 1.15 2010/12/13 17:35:08 pooka Exp $"); +__RCSID("$NetBSD: af_inet.c,v 1.16 2015/05/02 14:43:51 roy Exp $"); #endif /* not lint */ #include <sys/param.h> @@ -62,12 +62,14 @@ __RCSID("$NetBSD: af_inet.c,v 1.15 2010/ static void in_constructor(void) __attribute__((constructor)); static void in_status(prop_dictionary_t, prop_dictionary_t, bool); static void in_commit_address(prop_dictionary_t, prop_dictionary_t); +static bool in_addr_tentative(struct ifaddrs *ifa); static void in_alias(const char *, prop_dictionary_t, prop_dictionary_t, struct in_aliasreq *); static struct afswtch af = { .af_name = "inet", .af_af = AF_INET, .af_status = in_status, - .af_addr_commit = in_commit_address + .af_addr_commit = in_commit_address, + .af_addr_tentative = in_addr_tentative }; static void @@ -137,6 +139,21 @@ in_alias(const char *ifname, prop_dictio strlcpy(hbuf, "", sizeof(hbuf)); /* some message? */ printf(" broadcast %s", hbuf); } + +#ifdef IN_IFF_TENTATIVE + memcpy(&ifr.ifr_addr, &creq->ifra_addr, creq->ifra_addr.sin_len); + if (prog_ioctl(s, SIOCGIFAFLAG_IN, &ifr) == -1) { + if (errno != EADDRNOTAVAIL) + warn("SIOCGIFAFLAG_IN"); + } else { + if (ifr.ifr_addrflags & IN_IFF_TENTATIVE) + printf(" tentative"); + if (ifr.ifr_addrflags & IN_IFF_DUPLICATED) + printf(" duplicated"); + if (ifr.ifr_addrflags & IN_IFF_DETACHED) + printf(" detached"); + } +#endif } static void @@ -203,6 +220,26 @@ in_commit_address(prop_dictionary_t env, commit_address(env, oenv, &inparam); } +static bool +in_addr_tentative(struct ifaddrs *ifa) +{ +#ifdef IN_IFF_TENTATIVE + int s; + struct ifreq ifr; + + memset(&ifr, 0, sizeof(ifr)); + strncpy(ifr.ifr_name, ifa->ifa_name, sizeof(ifr.ifr_name)); + ifr.ifr_addr = *ifa->ifa_addr; + if ((s = getsock(AF_INET)) == -1) + err(EXIT_FAILURE, "%s: getsock", __func__); + if (ioctl(s, SIOCGIFAFLAG_IN, &ifr) == -1) + err(EXIT_FAILURE, "SIOCGIFAFLAG_IN"); + return ifr.ifr_addrflags & IN_IFF_TENTATIVE ? true : false; +#else + return false; +#endif +} + static void in_constructor(void) {