From: Roy Marples Date: Wed, 3 Sep 2008 23:36:46 +0000 (+0000) Subject: Work around broken linux headers when including wireless.h X-Git-Tag: v5.0.0~309 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b332752859d595fc7f7c8fb73c3da3cd21e95b6d;p=thirdparty%2Fdhcpcd.git Work around broken linux headers when including wireless.h --- diff --git a/net.c b/net.c index 826bf382..53db602e 100644 --- a/net.c +++ b/net.c @@ -31,29 +31,32 @@ #include #include +#include #include #include -#include #include -#ifdef __linux__ -# include -# include -# include -#endif #include #include #define __FAVOR_BSD /* Nasty glibc hack so we can use BSD semantics for UDP */ #include #undef __FAVOR_BSD +#ifdef AF_LINK +# include +#endif #ifdef SIOCGIFMEDIA # include #endif #ifdef BSD # include #endif -#include -#ifdef AF_LINK -# include +#ifdef __linux__ +# define SIOCGIWNAME 0x8B01 +/* FIXME: Some linux kernel verisons DO NOT like this include + * They have the error: + * /usr/include/linux/if.h:92: error: redefinition of `struct ifmap' + * We work around this by defining the above ioctl and using an ifreq + * structure which seems to work fine. */ +//# include #endif #include @@ -189,7 +192,8 @@ init_interface(const char *ifname) struct ifreq ifr; struct interface *iface = NULL; #if defined(SIOCGIWNAME) - struct iwreq iwr; +// FIXME: See comment in includes above +// struct iwreq iwr; #elif defined(SIOCG80211NWID) struct ieee80211_nwid nwid; #elif defined(IEEE80211_IOC_SSID) @@ -253,9 +257,7 @@ init_interface(const char *ifname) * We do this so we prefer other interfaces if they provide * similar configuration on the same subnet. */ #if defined(SIOCGIWNAME) /* Linux */ - memset(&iwr, 0, sizeof(iwr)); - strlcpy(iwr.ifr_name, ifname, sizeof(iwr.ifr_name)); - if (ioctl(s, SIOCGIWNAME, &iwr) != -1) + if (ioctl(s, SIOCGIWNAME, &ifr) != -1) iface->metric += 100; #elif defined(SIOCG80211NWID) /* NetBSD */ memset(&nwid, 0, sizeof(nwid));