Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sbin/ifconfig Report IN_IFF_TENTATIVE and friends.
details: https://anonhg.NetBSD.org/src/rev/92d764e2dab6
branches: trunk
changeset: 337879:92d764e2dab6
user: roy <roy%NetBSD.org@localhost>
date: Sat May 02 14:43:51 2015 +0000
description:
Report IN_IFF_TENTATIVE and friends.
Wait for IN_IFF_TENTATIVE to be removed with the -w flag.
diffstat:
sbin/ifconfig/af_inet.c | 43 ++++++++++++++++++++++++++++++++++++++++---
1 files changed, 40 insertions(+), 3 deletions(-)
diffs (83 lines):
diff -r f40cac8e8ae3 -r 92d764e2dab6 sbin/ifconfig/af_inet.c
--- a/sbin/ifconfig/af_inet.c Sat May 02 14:41:32 2015 +0000
+++ b/sbin/ifconfig/af_inet.c Sat May 02 14:43:51 2015 +0000
@@ -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 @@
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 @@
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 @@
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)
{
Home |
Main Index |
Thread Index |
Old Index