Report IN_IFF_TENTATIVE and friends.

Wait for IN_IFF_TENTATIVE to be removed with the -w flag.
This commit is contained in:
roy 2015-05-02 14:43:51 +00:00
parent 505639d2f3
commit dbb6db0ed0
1 changed files with 40 additions and 3 deletions

View File

@ -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/12/13 17:35:08 pooka Exp $");
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_dictionary_t env, prop_dictionary_t oenv,
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, prop_dictionary_t oenv)
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)
{