aboutsummaryrefslogtreecommitdiff
path: root/sbin/ifconfig/af_nd6.c
diff options
context:
space:
mode:
authorHiroki Sato <hrs@FreeBSD.org>2011-06-05 11:37:20 +0000
committerHiroki Sato <hrs@FreeBSD.org>2011-06-05 11:37:20 +0000
commitc3cc3217bc2a4a08bd24a68d3314edb2a4e3c724 (patch)
tree2509b309d5d17a9add4768534e62e802e2d65797 /sbin/ifconfig/af_nd6.c
parentfa0fb79540eae1b43cb323183b11ffc9d77d2202 (diff)
downloadsrc-c3cc3217bc2a4a08bd24a68d3314edb2a4e3c724.tar.gz
src-c3cc3217bc2a4a08bd24a68d3314edb2a4e3c724.zip
Add the "nd6 options" line handler as af_other_status() of AF_INET6, not as an
own address family. Reviewed by: bz
Notes
Notes: svn path=/head/; revision=222711
Diffstat (limited to 'sbin/ifconfig/af_nd6.c')
-rw-r--r--sbin/ifconfig/af_nd6.c72
1 files changed, 3 insertions, 69 deletions
diff --git a/sbin/ifconfig/af_nd6.c b/sbin/ifconfig/af_nd6.c
index 5260c505c0d3..134b825a4425 100644
--- a/sbin/ifconfig/af_nd6.c
+++ b/sbin/ifconfig/af_nd6.c
@@ -63,6 +63,7 @@ static const char rcsid[] =
static int isnd6defif(int);
void setnd6flags(const char *, int, int, const struct afswtch *);
void setnd6defif(const char *, int, int, const struct afswtch *);
+void nd6_status(int);
void
setnd6flags(const char *dummyaddr __unused,
@@ -136,64 +137,13 @@ isnd6defif(int s)
return (ndifreq.ifindex == ifindex);
}
-static void
+void
nd6_status(int s)
{
struct in6_ndireq nd;
- struct rt_msghdr *rtm;
- size_t needed;
- char *buf, *next;
- int mib[6], ntry;
int s6;
int error;
- int isinet6, isdefif;
-
- /* Check if the interface has at least one IPv6 address. */
- mib[0] = CTL_NET;
- mib[1] = PF_ROUTE;
- mib[2] = 0;
- mib[3] = AF_INET6;
- mib[4] = NET_RT_IFLIST;
- mib[5] = if_nametoindex(ifr.ifr_name);
-
- /* Try to prevent a race between two sysctls. */
- ntry = 0;
- do {
- error = sysctl(mib, 6, NULL, &needed, NULL, 0);
- if (error) {
- warn("sysctl(NET_RT_IFLIST)/estimate");
- return;
- }
- buf = malloc(needed);
- if (buf == NULL) {
- warn("malloc for sysctl(NET_RT_IFLIST) failed");
- return;
- }
- if ((error = sysctl(mib, 6, buf, &needed, NULL, 0)) < 0) {
- if (errno != ENOMEM || ++ntry >= MAX_SYSCTL_TRY) {
- warn("sysctl(NET_RT_IFLIST)/get");
- free(buf);
- return;
- }
- free(buf);
- buf = NULL;
- }
- } while (buf == NULL);
-
- isinet6 = 0;
- for (next = buf; next < buf + needed; next += rtm->rtm_msglen) {
- rtm = (struct rt_msghdr *)next;
-
- if (rtm->rtm_version != RTM_VERSION)
- continue;
- if (rtm->rtm_type == RTM_NEWADDR) {
- isinet6 = 1;
- break;
- }
- }
- free(buf);
- if (!isinet6)
- return;
+ int isdefif;
memset(&nd, 0, sizeof(nd));
strncpy(nd.ifname, ifr.ifr_name, sizeof(nd.ifname));
@@ -215,19 +165,3 @@ nd6_status(int s)
(unsigned int)(nd.ndi.flags | (isdefif << 15)), ND6BITS);
putchar('\n');
}
-
-static struct afswtch af_nd6 = {
- .af_name = "nd6",
- .af_af = AF_LOCAL,
- .af_other_status= nd6_status,
-};
-
-static __constructor void
-nd6_ctor(void)
-{
-
- if (!feature_present("inet6"))
- return;
-
- af_register(&af_nd6);
-}