summaryrefslogtreecommitdiffstats
path: root/if-linux.c
diff options
context:
space:
mode:
authorRoy Marples <roy@marples.name>2008-09-17 10:32:55 +0000
committerRoy Marples <roy@marples.name>2008-09-17 10:32:55 +0000
commitf52769ba71d9fac5acbe71a435e6018f2eacd571 (patch)
tree563f7540d02f80a77c5879341d7f635a8efefd20 /if-linux.c
parent065125d478bfa3d0814c8a67fa0bad5fd442270b (diff)
downloaddhcpcd-f52769ba71d9fac5acbe71a435e6018f2eacd571.tar.xz
Move wireless detection from net.c into if-bsd.c and if-linux.c
Diffstat (limited to 'if-linux.c')
-rw-r--r--if-linux.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/if-linux.c b/if-linux.c
index 590bad18..3fecfe04 100644
--- a/if-linux.c
+++ b/if-linux.c
@@ -39,6 +39,14 @@
#include <netinet/ether.h>
#include <netpacket/packet.h>
+# 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>
+
#include <errno.h>
#include <ctype.h>
#include <fnmatch.h>
@@ -65,6 +73,22 @@ static void (*nl_add)(const char *) = NULL;
static void (*nl_remove)(const char *) = NULL;
int
+if_wireless(const char *ifname)
+{
+ int s, retval = -1;
+ struct ifreq ifr;
+
+ if ((s = socket(AF_INET, SOCK_DGRAM, 0)) == -1)
+ return retval;
+ memset(&ifr, 0, sizeof(ifr));
+ strlcpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name));
+ if (ioctl(s, SIOCGIWNAME, &ifr) == 0)
+ retval = 0;
+ close(s);
+ return retval;
+}
+
+int
open_link_socket(void)
{
int fd;