add code to force ifup on wireless device
author"Luc Saillard <luc@saillard.org>"
Mon Jun 16 15:56:53 2008 +0200 (2 months ago)
changeset 8788a11d40d460
parent 86448baefd3f8d
child 887aacee387a38
add code to force ifup on wireless device
mkinstalldirs
src/plugins/net.c
--- a/mkinstalldirs Mon Jun 16 13:01:16 2008 +0200
+++ b/mkinstalldirs Mon Jun 16 15:56:53 2008 +0200
@@ -1,7 +1,7 @@
#! /bin/sh
# mkinstalldirs --- make directory hierarchy
-scriptversion=2006-05-11.19
+scriptversion=2005-06-29.22
# Original author: Noah Friedman <friedman@prep.ai.mit.edu>
# Created: 1993-05-16
@@ -11,9 +11,6 @@ scriptversion=2006-05-11.19
# bugs to <bug-automake@gnu.org> or send patches to
# <automake-patches@gnu.org>.
-nl='
-'
-IFS=" "" $nl"
errstatus=0
dirmode=
--- a/src/plugins/net.c Mon Jun 16 13:01:16 2008 +0200
+++ b/src/plugins/net.c Mon Jun 16 15:56:53 2008 +0200
@@ -33,6 +33,7 @@
#include <linux/ethtool.h>
#include <linux/sockios.h>
#include <time.h>
+#include <linux/wireless.h>
#include "trace.h"
@@ -197,6 +198,23 @@ net_interface_detect_using_ethtool(int f
return 0;
}
+static int
+net_interface_has_wireless_extension(int fd, const char *iface)
+{
+ struct iwreq req;
+
+ memset(&req, 0, sizeof(req));
+ strcpy(req.ifr_name, iface);
+ if (ioctl(fd, SIOCGIWNAME, &req) == -1)
+ {
+ trace("ioctl(SIOCGIWNAME) failed: %s\n", strerror(errno));
+ return -1;
+ }
+
+ return 0;
+}
+
+
/*
* Use SIOCGIFFLAGS to get interface beat status
*
@@ -254,6 +272,17 @@ net_monitor(int fd, const char *iface)
int old_status, status, flags;
int polltime = DEFAULT_POLLTIME;
time_t last_time_changed = 0;
+
+ status = net_interface_has_wireless_extension(fd, iface);
+ if (status == 0)
+ {
+ /* We have a wifi interface, so report that we are always connected */
+ ifup(iface);
+ sleep(3);
+ ifup(iface);
+ return 0;
+ }
+
flags = net_interface_get_flags(fd, iface);
if (flags & IFF_LOOPBACK)