aboutsummaryrefslogtreecommitdiffstats
path: root/src/drivers/driver_atheros.c
diff options
context:
space:
mode:
authorJouni Malinen <j@w1.fi>2010-01-03 20:08:26 (GMT)
committerJouni Malinen <j@w1.fi>2010-01-03 20:08:26 (GMT)
commit34f2f814e08a08806e81047198bca08537bfa5bc (patch)
tree894b605fa55d3788ee5f9d2f34c17c2b0d57ae97 /src/drivers/driver_atheros.c
parent9c3a2284de0d967689955d166619d0704207142e (diff)
downloadhostap-34f2f814e08a08806e81047198bca08537bfa5bc.zip
hostap-34f2f814e08a08806e81047198bca08537bfa5bc.tar.gz
hostap-34f2f814e08a08806e81047198bca08537bfa5bc.tar.bz2
Share a single Linux ioctl helper fo setting interface up/down
Number of Linux driver wrappers included this more or less identical function, so lets add a new helper file to be able to share some more code between the driver wrappers.
Diffstat (limited to 'src/drivers/driver_atheros.c')
-rw-r--r--src/drivers/driver_atheros.c42
1 files changed, 6 insertions, 36 deletions
diff --git a/src/drivers/driver_atheros.c b/src/drivers/driver_atheros.c
index 3d04294..4428731 100644
--- a/src/drivers/driver_atheros.c
+++ b/src/drivers/driver_atheros.c
@@ -64,6 +64,7 @@
#include "l2_packet/l2_packet.h"
#include "common/ieee802_11_defs.h"
#include "netlink.h"
+#include "linux_ioctl.h"
struct madwifi_driver_data {
@@ -270,39 +271,6 @@ madwifi_configure_wpa(struct madwifi_driver_data *drv,
return 0;
}
-
-static int
-madwifi_set_iface_flags(void *priv, int dev_up)
-{
- struct madwifi_driver_data *drv = priv;
- struct ifreq ifr;
-
- wpa_printf(MSG_DEBUG, "%s: dev_up=%d", __func__, dev_up);
-
- if (drv->ioctl_sock < 0)
- return -1;
-
- memset(&ifr, 0, sizeof(ifr));
- os_strlcpy(ifr.ifr_name, drv->iface, IFNAMSIZ);
-
- if (ioctl(drv->ioctl_sock, SIOCGIFFLAGS, &ifr) != 0) {
- perror("ioctl[SIOCGIFFLAGS]");
- return -1;
- }
-
- if (dev_up)
- ifr.ifr_flags |= IFF_UP;
- else
- ifr.ifr_flags &= ~IFF_UP;
-
- if (ioctl(drv->ioctl_sock, SIOCSIFFLAGS, &ifr) != 0) {
- perror("ioctl[SIOCSIFFLAGS]");
- return -1;
- }
-
- return 0;
-}
-
static int
madwifi_set_ieee8021x(void *priv, struct wpa_bss_params *params)
{
@@ -1132,7 +1100,8 @@ madwifi_init(struct hostapd_data *hapd, struct wpa_init_params *params)
goto bad;
}
- madwifi_set_iface_flags(drv, 0); /* mark down during setup */
+ /* mark down during setup */
+ linux_set_iface_flags(drv->ioctl_sock, drv->iface, 0);
madwifi_set_privacy(drv->iface, drv, 0); /* default to no privacy */
madwifi_receive_probe_req(drv);
@@ -1158,7 +1127,7 @@ madwifi_deinit(void *priv)
struct madwifi_driver_data *drv = priv;
netlink_deinit(drv->netlink);
- (void) madwifi_set_iface_flags(drv, 0);
+ (void) linux_set_iface_flags(drv->ioctl_sock, drv->iface, 0);
if (drv->ioctl_sock >= 0)
close(drv->ioctl_sock);
if (drv->sock_recv != NULL && drv->sock_recv != drv->sock_xmit)
@@ -1222,7 +1191,8 @@ madwifi_set_countermeasures(void *priv, int enabled)
static int
madwifi_commit(void *priv)
{
- return madwifi_set_iface_flags(priv, 1);
+ struct madwifi_driver_data *drv = priv;
+ return linux_set_iface_flags(drv->ioctl_sock, drv->iface, 1);
}
const struct wpa_driver_ops wpa_driver_atheros_ops = {