From 78d51c7b15fc92383c6c68b46966248bdaf2bf1a Mon Sep 17 00:00:00 2001 From: glebius Date: Mon, 6 Apr 2015 09:42:23 +0000 Subject: Stop including if_var.h from userland. Sponsored by: Nginx, Inc. --- sbin/ifconfig/af_inet.c | 1 - sbin/ifconfig/af_inet6.c | 1 - sbin/ifconfig/af_nd6.c | 1 - sbin/ifconfig/carp.c | 1 - sbin/ifconfig/ifconfig.c | 1 - sbin/ifconfig/ifvlan.c | 1 - sbin/ifconfig/ifvxlan.c | 1 - 7 files changed, 7 deletions(-) (limited to 'sbin/ifconfig') diff --git a/sbin/ifconfig/af_inet.c b/sbin/ifconfig/af_inet.c index c733373..3c3a757 100644 --- a/sbin/ifconfig/af_inet.c +++ b/sbin/ifconfig/af_inet.c @@ -46,7 +46,6 @@ static const char rcsid[] = #include #include -#include /* for struct ifaddr */ #include #include #include diff --git a/sbin/ifconfig/af_inet6.c b/sbin/ifconfig/af_inet6.c index bff66e0..8a18401 100644 --- a/sbin/ifconfig/af_inet6.c +++ b/sbin/ifconfig/af_inet6.c @@ -48,7 +48,6 @@ static const char rcsid[] = #include #include -#include /* for struct ifaddr */ #include #include #include diff --git a/sbin/ifconfig/af_nd6.c b/sbin/ifconfig/af_nd6.c index 3a510a5..9a1be79 100644 --- a/sbin/ifconfig/af_nd6.c +++ b/sbin/ifconfig/af_nd6.c @@ -46,7 +46,6 @@ static const char rcsid[] = #include #include -#include #include #include #include diff --git a/sbin/ifconfig/carp.c b/sbin/ifconfig/carp.c index 2c58fcb..adff153 100644 --- a/sbin/ifconfig/carp.c +++ b/sbin/ifconfig/carp.c @@ -36,7 +36,6 @@ #include #include -#include #include #include #include diff --git a/sbin/ifconfig/ifconfig.c b/sbin/ifconfig/ifconfig.c index 9d38a27..4a79992 100644 --- a/sbin/ifconfig/ifconfig.c +++ b/sbin/ifconfig/ifconfig.c @@ -51,7 +51,6 @@ static const char rcsid[] = #include #include -#include #include #include #include diff --git a/sbin/ifconfig/ifvlan.c b/sbin/ifconfig/ifvlan.c index cefcbbc..1a3fbaa 100644 --- a/sbin/ifconfig/ifvlan.c +++ b/sbin/ifconfig/ifvlan.c @@ -40,7 +40,6 @@ #include #include -#include #include #include diff --git a/sbin/ifconfig/ifvxlan.c b/sbin/ifconfig/ifvxlan.c index 9aa84a2..48f5331 100644 --- a/sbin/ifconfig/ifvxlan.c +++ b/sbin/ifconfig/ifvxlan.c @@ -39,7 +39,6 @@ __FBSDID("$FreeBSD$"); #include #include -#include #include #include #include -- cgit v1.1 From 363cef70bb6cd59b2fe8f695078eeb99ed91814c Mon Sep 17 00:00:00 2001 From: erj Date: Tue, 7 Apr 2015 21:31:17 +0000 Subject: ifmedia changes: - Extend the number of available subtypes for Ethernet media by using some of the ifmedia word's option bits to help denote subtypes. As a result, the number of possible Ethernet subtype values increases from 31 to 511. - Use some of those new values to define new media types. - lacp_compose_key() recgonizes the new Ethernet media types added. (Change made as required by a comment in if_media.h) - New ioctl, SIOGIFXMEDIA, to handle getting the new extended media types. SIOCGIFMEDIA is retained for backwards compatibility. - Changes to ifconfig to allow it to handle the new extended media types. Submitted by: mike@karels.net (original), hselasky Reviewed by: jfvogel, gnn, hselasky Approved by: jfvogel (mentor), gnn (mentor) Differential Revision: http://reviews.freebsd.org/D1965 --- sbin/ifconfig/ifmedia.c | 32 ++++++++++++++++++++++++++------ 1 file changed, 26 insertions(+), 6 deletions(-) (limited to 'sbin/ifconfig') diff --git a/sbin/ifconfig/ifmedia.c b/sbin/ifconfig/ifmedia.c index 0b0daa3..eee3391 100644 --- a/sbin/ifconfig/ifmedia.c +++ b/sbin/ifconfig/ifmedia.c @@ -109,11 +109,17 @@ media_status(int s) { struct ifmediareq ifmr; int *media_list, i; + int xmedia = 1; (void) memset(&ifmr, 0, sizeof(ifmr)); (void) strncpy(ifmr.ifm_name, name, sizeof(ifmr.ifm_name)); - if (ioctl(s, SIOCGIFMEDIA, (caddr_t)&ifmr) < 0) { + /* + * Check if interface supports extended media types. + */ + if (ioctl(s, SIOCGIFXMEDIA, (caddr_t)&ifmr) < 0) + xmedia = 0; + if (xmedia == 0 && ioctl(s, SIOCGIFMEDIA, (caddr_t)&ifmr) < 0) { /* * Interface doesn't support SIOC{G,S}IFMEDIA. */ @@ -130,8 +136,13 @@ media_status(int s) err(1, "malloc"); ifmr.ifm_ulist = media_list; - if (ioctl(s, SIOCGIFMEDIA, (caddr_t)&ifmr) < 0) - err(1, "SIOCGIFMEDIA"); + if (xmedia) { + if (ioctl(s, SIOCGIFXMEDIA, (caddr_t)&ifmr) < 0) + err(1, "SIOCGIFXMEDIA"); + } else { + if (ioctl(s, SIOCGIFMEDIA, (caddr_t)&ifmr) < 0) + err(1, "SIOCGIFMEDIA"); + } printf("\tmedia: "); print_media_word(ifmr.ifm_current, 1); @@ -194,6 +205,7 @@ ifmedia_getstate(int s) { static struct ifmediareq *ifmr = NULL; int *mwords; + int xmedia = 1; if (ifmr == NULL) { ifmr = (struct ifmediareq *)malloc(sizeof(struct ifmediareq)); @@ -213,7 +225,10 @@ ifmedia_getstate(int s) * the current media type and the top-level type. */ - if (ioctl(s, SIOCGIFMEDIA, (caddr_t)ifmr) < 0) { + if (ioctl(s, SIOCGIFXMEDIA, (caddr_t)ifmr) < 0) { + xmedia = 0; + } + if (xmedia == 0 && ioctl(s, SIOCGIFMEDIA, (caddr_t)ifmr) < 0) { err(1, "SIOCGIFMEDIA"); } @@ -225,8 +240,13 @@ ifmedia_getstate(int s) err(1, "malloc"); ifmr->ifm_ulist = mwords; - if (ioctl(s, SIOCGIFMEDIA, (caddr_t)ifmr) < 0) - err(1, "SIOCGIFMEDIA"); + if (xmedia) { + if (ioctl(s, SIOCGIFXMEDIA, (caddr_t)ifmr) < 0) + err(1, "SIOCGIFXMEDIA"); + } else { + if (ioctl(s, SIOCGIFMEDIA, (caddr_t)ifmr) < 0) + err(1, "SIOCGIFMEDIA"); + } } return ifmr; -- cgit v1.1