summaryrefslogtreecommitdiffstats
path: root/net.c
diff options
context:
space:
mode:
authorRoy Marples <roy@marples.name>2008-09-03 23:36:46 +0000
committerRoy Marples <roy@marples.name>2008-09-03 23:36:46 +0000
commitb332752859d595fc7f7c8fb73c3da3cd21e95b6d (patch)
tree9458ddd095a1fb12e625d99003f595dae5aec124 /net.c
parent26ab34ee2033ef098d367df1ea5d77fd7c22a592 (diff)
downloaddhcpcd-b332752859d595fc7f7c8fb73c3da3cd21e95b6d.tar.xz
Work around broken linux headers when including wireless.h
Diffstat (limited to 'net.c')
-rw-r--r--net.c28
1 files changed, 15 insertions, 13 deletions
diff --git a/net.c b/net.c
index 826bf382..53db602e 100644
--- a/net.c
+++ b/net.c
@@ -31,29 +31,32 @@
#include <sys/socket.h>
#include <sys/time.h>
+#include <arpa/inet.h>
#include <net/if.h>
#include <net/if_arp.h>
-#include <arpa/inet.h>
#include <netinet/in_systm.h>
-#ifdef __linux__
-# include <linux/wireless.h>
-# include <netinet/ether.h>
-# include <netpacket/packet.h>
-#endif
#include <netinet/in.h>
#include <netinet/ip.h>
#define __FAVOR_BSD /* Nasty glibc hack so we can use BSD semantics for UDP */
#include <netinet/udp.h>
#undef __FAVOR_BSD
+#ifdef AF_LINK
+# include <net/if_dl.h>
+#endif
#ifdef SIOCGIFMEDIA
# include <net/if_media.h>
#endif
#ifdef BSD
# include <net80211/ieee80211_ioctl.h>
#endif
-#include <arpa/inet.h>
-#ifdef AF_LINK
-# include <net/if_dl.h>
+#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 <linux/wireless.h>
#endif
#include <ctype.h>
@@ -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));