CVS commit: src/external/bsd/wpa/dist/src/drivers

2021-01-01 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Fri Jan  1 14:57:14 UTC 2021

Modified Files:
src/external/bsd/wpa/dist/src/drivers: driver_bsd.c

Log Message:
wpa: If route socket overflows, sync drivers to system interfaces

Messages such as RTM_IFNFO or RTM_IFANNOUNCE could have been lost.
As such, sync the state of our internal driver to the state of the
system interfaces as reported by getifaddrs(2).

This change requires the routing socket be placed in non-blocking
mode. While here, set the routing and inet sockets to close on exec.


To generate a diff of this commit:
cvs rdiff -u -r1.37 -r1.38 src/external/bsd/wpa/dist/src/drivers/driver_bsd.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/external/bsd/wpa/dist/src/drivers/driver_bsd.c
diff -u src/external/bsd/wpa/dist/src/drivers/driver_bsd.c:1.37 src/external/bsd/wpa/dist/src/drivers/driver_bsd.c:1.38
--- src/external/bsd/wpa/dist/src/drivers/driver_bsd.c:1.37	Tue Jul 21 10:34:16 2020
+++ src/external/bsd/wpa/dist/src/drivers/driver_bsd.c	Fri Jan  1 14:57:14 2021
@@ -16,7 +16,9 @@
 #include "common/ieee802_11_defs.h"
 #include "common/wpa_common.h"
 
+#include 
 #include 
+#include 
 #include 
 
 #ifdef __NetBSD__
@@ -615,6 +617,108 @@ bsd_set_opt_ie(void *priv, const u8 *ie,
 	return 0;
 }
 
+#ifdef SO_RERROR
+static void
+bsd_route_overflow(int sock, void *ctx, struct bsd_driver_global *global)
+{
+	char event_buf[2048]; /* max size of a single route(4) msg */
+	int n;
+	struct ifaddrs *ifaddrs, *ifa;
+	struct bsd_driver_data *drv;
+	struct sockaddr_dl *sdl;
+	union wpa_event_data event;
+
+	/* We need to match the system state, so drain the route
+	 * socket to avoid stale messages. */
+	do {
+		n = read(sock, event_buf, sizeof(event_buf));
+	} while (n != -1 || errno == ENOBUFS);
+
+	if (getifaddrs() == -1) {
+		wpa_printf(MSG_ERROR, "%s getifaddrs() failed: %s",
+			   __func__, strerror(errno));
+			   return;
+	}
+
+	/* add or update existing interfaces */
+	for (ifa = ifaddrs; ifa != NULL; ifa = ifa->ifa_next) {
+		if (ifa->ifa_addr == NULL ||
+		ifa->ifa_addr->sa_family != AF_LINK)
+			continue;
+		sdl = (struct sockaddr_dl *)(void *)ifa->ifa_addr;
+		drv = bsd_get_drvname(global, ifa->ifa_name);
+		if (drv != NULL &&
+		(drv->ifindex != sdl->sdl_index || drv->if_removed)) {
+			wpa_printf(MSG_DEBUG,
+			"RTM_IFANNOUNCE: Interface '%s' added",
+			drv->ifname);
+			drv->ifindex = sdl->sdl_index;
+			drv->if_removed = 0;
+			event.interface_status.ievent = EVENT_INTERFACE_ADDED;
+			os_strlcpy(event.interface_status.ifname, ifa->ifa_name,
+			sizeof(event.interface_status.ifname));
+			wpa_supplicant_event(drv->ctx, EVENT_INTERFACE_STATUS,
+	 );
+		}
+		if (drv == NULL &&
+		(drv = bsd_get_drvindex(global, sdl->sdl_index)) != NULL) {
+			/* Driver name is invalid */
+			wpa_printf(MSG_DEBUG,
+			"RTM_IFANNOUNCE: Interface '%s' removed",
+			drv->ifname);
+			drv->if_removed = 1;
+			event.interface_status.ievent = EVENT_INTERFACE_REMOVED;
+			os_strlcpy(event.interface_status.ifname, drv->ifname,
+			sizeof(event.interface_status.ifname));
+			wpa_supplicant_event(drv->ctx, EVENT_INTERFACE_STATUS,
+	 );
+		}
+	}
+
+	/* punt missing interfaces and update flags */
+	dl_list_for_each(drv, >ifaces, struct bsd_driver_data, list) {
+		for (ifa = ifaddrs; ifa != NULL; ifa = ifa->ifa_next) {
+			if (ifa->ifa_addr == NULL ||
+			ifa->ifa_addr->sa_family != AF_LINK)
+continue;
+			sdl = (struct sockaddr_dl *)(void *)ifa->ifa_addr;
+			if (os_strcmp(drv->ifname, ifa->ifa_name) == 0)
+break;
+		}
+		if (ifa == NULL && !drv->if_removed) {
+			wpa_printf(MSG_DEBUG,
+			"RTM_IFANNOUNCE: Interface '%s' removed",
+			drv->ifname);
+			drv->if_removed = 1;
+			event.interface_status.ievent = EVENT_INTERFACE_REMOVED;
+			os_strlcpy(event.interface_status.ifname, drv->ifname,
+			sizeof(event.interface_status.ifname));
+			wpa_supplicant_event(drv->ctx, EVENT_INTERFACE_STATUS,
+	 );
+		}
+		if (ifa == NULL)
+			continue;
+
+		if ((ifa->ifa_flags & IFF_UP) == 0 &&
+		(drv->flags & IFF_UP) != 0) {
+			wpa_printf(MSG_DEBUG, "RTM_IFINFO: Interface '%s' DOWN",
+   drv->ifname);
+			wpa_supplicant_event(drv->ctx, EVENT_INTERFACE_DISABLED,
+	 NULL);
+		} else if ((ifa->ifa_flags & IFF_UP) != 0 &&
+		(drv->flags & IFF_UP) == 0) {
+			wpa_printf(MSG_DEBUG, "RTM_IFINFO: Interface '%s' UP",
+   drv->ifname);
+			wpa_supplicant_event(drv->ctx, EVENT_INTERFACE_ENABLED,
+	 NULL);
+		}
+		drv->flags = ifa->ifa_flags;
+	}
+
+	freeifaddrs(ifaddrs);
+}
+#endif
+
 static void
 bsd_wireless_event_receive(int sock, void *ctx, void *sock_ctx)
 {
@@ -635,6 +739,10 @@ bsd_wireless_event_receive(int sock, voi
 		if (errno != EINTR && errno != EAGAIN)
 			wpa_printf(MSG_ERROR, "%s read() failed: %s",
    __func__, strerror(errno));
+#ifdef SO_RERROR
+		if 

CVS commit: src/external/bsd/wpa/dist/src/drivers

2021-01-01 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Fri Jan  1 14:57:14 UTC 2021

Modified Files:
src/external/bsd/wpa/dist/src/drivers: driver_bsd.c

Log Message:
wpa: If route socket overflows, sync drivers to system interfaces

Messages such as RTM_IFNFO or RTM_IFANNOUNCE could have been lost.
As such, sync the state of our internal driver to the state of the
system interfaces as reported by getifaddrs(2).

This change requires the routing socket be placed in non-blocking
mode. While here, set the routing and inet sockets to close on exec.


To generate a diff of this commit:
cvs rdiff -u -r1.37 -r1.38 src/external/bsd/wpa/dist/src/drivers/driver_bsd.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/external/bsd/wpa/dist/src/drivers

2020-07-21 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Tue Jul 21 10:34:16 UTC 2020

Modified Files:
src/external/bsd/wpa/dist/src/drivers: driver_bsd.c

Log Message:
wpa_supplicant: don't log SIOCG80211 errors during interface setup

Unless debugging.
wpa_supplicant will log it failed to initialized the driver for the
interface anyway so this just silences some noise for users.


To generate a diff of this commit:
cvs rdiff -u -r1.36 -r1.37 src/external/bsd/wpa/dist/src/drivers/driver_bsd.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/external/bsd/wpa/dist/src/drivers

2020-07-21 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Tue Jul 21 10:34:16 UTC 2020

Modified Files:
src/external/bsd/wpa/dist/src/drivers: driver_bsd.c

Log Message:
wpa_supplicant: don't log SIOCG80211 errors during interface setup

Unless debugging.
wpa_supplicant will log it failed to initialized the driver for the
interface anyway so this just silences some noise for users.


To generate a diff of this commit:
cvs rdiff -u -r1.36 -r1.37 src/external/bsd/wpa/dist/src/drivers/driver_bsd.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/external/bsd/wpa/dist/src/drivers/driver_bsd.c
diff -u src/external/bsd/wpa/dist/src/drivers/driver_bsd.c:1.36 src/external/bsd/wpa/dist/src/drivers/driver_bsd.c:1.37
--- src/external/bsd/wpa/dist/src/drivers/driver_bsd.c:1.36	Wed Jan 29 12:05:08 2020
+++ src/external/bsd/wpa/dist/src/drivers/driver_bsd.c	Tue Jul 21 10:34:16 2020
@@ -137,7 +137,9 @@ bsd_get80211(void *priv, struct ieee8021
 	ireq->i_data = arg;
 
 	if (ioctl(drv->global->sock, SIOCG80211, ireq) < 0) {
-		wpa_printf(MSG_ERROR, "ioctl[SIOCG80211, op=%u, "
+		int level = drv->if_removed ? MSG_DEBUG : MSG_ERROR;
+
+		wpa_printf(level, "ioctl[SIOCG80211, op=%u, "
 			   "arg_len=%u]: %s", op, arg_len, strerror(errno));
 		return -1;
 	}
@@ -1467,6 +1469,9 @@ wpa_driver_bsd_init(void *ctx, const cha
 	drv->global = priv;
 	os_strlcpy(drv->ifname, ifname, sizeof(drv->ifname));
 
+	/* Set the interface as removed until proven to work. */
+	drv->if_removed = 1;
+
 	if (!GETPARAM(drv, IEEE80211_IOC_ROAMING, drv->prev_roaming)) {
 		wpa_printf(MSG_DEBUG, "%s: failed to get roaming state: %s",
 			__func__, strerror(errno));
@@ -1490,6 +1495,9 @@ wpa_driver_bsd_init(void *ctx, const cha
 	if (bsd_get_iface_flags(drv) < 0)
 		goto fail;
 
+	/* Proven to work, lets go! */
+	drv->if_removed = 0;
+
 	drv->opmode = get80211opmode(drv);
 	dl_list_add(>global->ifaces, >list);
 



CVS commit: src/external/bsd/wpa/dist/src/drivers

2020-01-29 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Wed Jan 29 12:05:08 UTC 2020

Modified Files:
src/external/bsd/wpa/dist/src/drivers: driver_bsd.c

Log Message:
wpa: reduce diff with upstream


To generate a diff of this commit:
cvs rdiff -u -r1.35 -r1.36 src/external/bsd/wpa/dist/src/drivers/driver_bsd.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/external/bsd/wpa/dist/src/drivers/driver_bsd.c
diff -u src/external/bsd/wpa/dist/src/drivers/driver_bsd.c:1.35 src/external/bsd/wpa/dist/src/drivers/driver_bsd.c:1.36
--- src/external/bsd/wpa/dist/src/drivers/driver_bsd.c:1.35	Wed Jan 29 11:57:36 2020
+++ src/external/bsd/wpa/dist/src/drivers/driver_bsd.c	Wed Jan 29 12:05:08 2020
@@ -9,11 +9,12 @@
 
 #include "includes.h"
 #include 
-#include 
 
 #include "common.h"
 #include "driver.h"
 #include "eloop.h"
+#include "common/ieee802_11_defs.h"
+#include "common/wpa_common.h"
 
 #include 
 #include 
@@ -43,8 +44,6 @@
 #include 
 #endif
 
-#include "common/ieee802_11_defs.h"
-#include "common/wpa_common.h"
 #include "l2_packet/l2_packet.h"
 
 struct bsd_driver_global {
@@ -138,7 +137,7 @@ bsd_get80211(void *priv, struct ieee8021
 	ireq->i_data = arg;
 
 	if (ioctl(drv->global->sock, SIOCG80211, ireq) < 0) {
-		wpa_printf(MSG_ERROR, "ioctl[SIOCS80211, op=%u, "
+		wpa_printf(MSG_ERROR, "ioctl[SIOCG80211, op=%u, "
 			   "arg_len=%u]: %s", op, arg_len, strerror(errno));
 		return -1;
 	}
@@ -1570,7 +1569,7 @@ bsd_global_init(void *ctx)
 #ifdef RO_MSGFILTER
 	if (setsockopt(global->route, PF_ROUTE, RO_MSGFILTER,
 	, sizeof(msgfilter)) < 0)
-		wpa_printf(MSG_ERROR, "setsockopt[PF_ROUTE,RO_MSGFILTER]: %s",
+		wpa_printf(MSG_ERROR, "socket[PF_ROUTE,RO_MSGFILTER]: %s",
 			   strerror(errno));
 #endif
 



CVS commit: src/external/bsd/wpa/dist/src/drivers

2020-01-29 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Wed Jan 29 12:05:08 UTC 2020

Modified Files:
src/external/bsd/wpa/dist/src/drivers: driver_bsd.c

Log Message:
wpa: reduce diff with upstream


To generate a diff of this commit:
cvs rdiff -u -r1.35 -r1.36 src/external/bsd/wpa/dist/src/drivers/driver_bsd.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/external/bsd/wpa/dist/src/drivers

2020-01-29 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Wed Jan 29 11:57:36 UTC 2020

Modified Files:
src/external/bsd/wpa/dist/src/drivers: driver_bsd.c

Log Message:
wpa: Fix the maximum size of a route(4) msg to 2048

This mirrors other programs which parse route(4) messages and will
match upstream.


To generate a diff of this commit:
cvs rdiff -u -r1.34 -r1.35 src/external/bsd/wpa/dist/src/drivers/driver_bsd.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/external/bsd/wpa/dist/src/drivers

2020-01-29 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Wed Jan 29 11:57:36 UTC 2020

Modified Files:
src/external/bsd/wpa/dist/src/drivers: driver_bsd.c

Log Message:
wpa: Fix the maximum size of a route(4) msg to 2048

This mirrors other programs which parse route(4) messages and will
match upstream.


To generate a diff of this commit:
cvs rdiff -u -r1.34 -r1.35 src/external/bsd/wpa/dist/src/drivers/driver_bsd.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/external/bsd/wpa/dist/src/drivers/driver_bsd.c
diff -u src/external/bsd/wpa/dist/src/drivers/driver_bsd.c:1.34 src/external/bsd/wpa/dist/src/drivers/driver_bsd.c:1.35
--- src/external/bsd/wpa/dist/src/drivers/driver_bsd.c:1.34	Wed Jan 29 11:46:47 2020
+++ src/external/bsd/wpa/dist/src/drivers/driver_bsd.c	Wed Jan 29 11:57:36 2020
@@ -51,7 +51,6 @@ struct bsd_driver_global {
 	void		*ctx;
 	int		sock;			/* socket for 802.11 ioctls */
 	int		route;			/* routing socket for events */
-	struct iovec	event_iov[1];
 	struct dl_list	ifaces;			/* list of interfaces */
 };
 
@@ -75,50 +74,6 @@ struct bsd_driver_data {
 
 /* Generic functions for hostapd and wpa_supplicant */
 
-#define IOVEC_BUFSIZ		256
-ssize_t
-recvmsg_realloc(int fd, struct msghdr *msg, int flags)
-{
-	struct iovec *iov;
-	ssize_t slen;
-	size_t len;
-	void *n;
-
-	/* Assume we are reallocing the last iovec. */
-	iov = >msg_iov[msg->msg_iovlen - 1];
-
-	for (;;) {
-		/* Passing MSG_TRUNC should return the actual size needed. */
-		slen = recvmsg(fd, msg, flags | MSG_PEEK | MSG_TRUNC);
-		if (slen == -1)
-			return -1;
-		if (!(msg->msg_flags & MSG_TRUNC))
-			break;
-
-		len = (size_t)slen;
-
-		/* Some kernels return the size of the receive buffer
-		 * on truncation, not the actual size needed.
-		 * So grow the buffer and try again. */
-		if (iov->iov_len == len)
-			len = roundup(len + 1, IOVEC_BUFSIZ);
-		else if (iov->iov_len > len)
-			break;
-		if ((n = realloc(iov->iov_base, len)) == NULL)
-			return -1;
-		iov->iov_base = n;
-		iov->iov_len = len;
-	}
-
-	slen = recvmsg(fd, msg, flags);
-	if (slen != -1 && msg->msg_flags & MSG_TRUNC) {
-		/* This should not be possible ... */
-		errno = ENOBUFS;
-		return -1;
-	}
-	return slen;
-}
-
 static struct bsd_driver_data *
 bsd_get_drvindex(void *priv, unsigned int ifindex)
 {
@@ -662,6 +617,7 @@ bsd_set_opt_ie(void *priv, const u8 *ie,
 static void
 bsd_wireless_event_receive(int sock, void *ctx, void *sock_ctx)
 {
+	char event_buf[2048]; /* max size of a single route(4) msg */
 	struct bsd_driver_global *global = sock_ctx;
 	struct bsd_driver_data *drv;
 	struct if_announcemsghdr *ifan;
@@ -672,9 +628,8 @@ bsd_wireless_event_receive(int sock, voi
 	struct ieee80211_leave_event *leave;
 	struct ieee80211_join_event *join;
 	int n;
-	struct msghdr msg = { .msg_iov = global->event_iov, .msg_iovlen = 1};
 
-	n = recvmsg_realloc(sock, , 0);
+	n = read(sock, event_buf, sizeof(event_buf));
 	if (n < 0) {
 		if (errno != EINTR && errno != EAGAIN)
 			wpa_printf(MSG_ERROR, "%s read() failed: %s",
@@ -682,7 +637,7 @@ bsd_wireless_event_receive(int sock, voi
 		return;
 	}
 
-	rtm = (struct rt_msghdr *) global->event_iov[0].iov_base;
+	rtm = (struct rt_msghdr *) event_buf;
 	if (rtm->rtm_version != RTM_VERSION) {
 		wpa_printf(MSG_DEBUG, "Invalid routing message version=%d",
 			   rtm->rtm_version);
@@ -1639,7 +1594,6 @@ bsd_global_deinit(void *priv)
 	eloop_unregister_read_sock(global->route);
 	(void) close(global->route);
 	(void) close(global->sock);
-	free(global->event_iov[0].iov_base);
 	os_free(global);
 }
 



CVS commit: src/external/bsd/wpa/dist/src/drivers

2020-01-29 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Wed Jan 29 11:45:54 UTC 2020

Modified Files:
src/external/bsd/wpa/dist/src/drivers: driver_bsd.c

Log Message:
wpa: Don't set or remove IFF_UP

Now that both hostapd and wpa_supplicant react to interface flag
changes, there is no need to set or remove IFF_UP.

It should be an administrative flag only.


To generate a diff of this commit:
cvs rdiff -u -r1.32 -r1.33 src/external/bsd/wpa/dist/src/drivers/driver_bsd.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/external/bsd/wpa/dist/src/drivers/driver_bsd.c
diff -u src/external/bsd/wpa/dist/src/drivers/driver_bsd.c:1.32 src/external/bsd/wpa/dist/src/drivers/driver_bsd.c:1.33
--- src/external/bsd/wpa/dist/src/drivers/driver_bsd.c:1.32	Wed Jan 29 11:44:43 2020
+++ src/external/bsd/wpa/dist/src/drivers/driver_bsd.c	Wed Jan 29 11:45:54 2020
@@ -337,9 +337,8 @@ bsd_send_mlme_param(void *priv, const u8
 }
 
 static int
-bsd_ctrl_iface(void *priv, int enable)
+bsd_get_iface_flags(struct bsd_driver_data *drv)
 {
-	struct bsd_driver_data *drv = priv;
 	struct ifreq ifr;
 
 	os_memset(, 0, sizeof(ifr));
@@ -351,24 +350,6 @@ bsd_ctrl_iface(void *priv, int enable)
 		return -1;
 	}
 	drv->flags = ifr.ifr_flags;
-
-	if (enable) {
-		if (ifr.ifr_flags & IFF_UP)
-			return 0;
-		ifr.ifr_flags |= IFF_UP;
-	} else {
-		if (!(ifr.ifr_flags & IFF_UP))
-			return 0;
-		ifr.ifr_flags &= ~IFF_UP;
-	}
-
-	if (ioctl(drv->global->sock, SIOCSIFFLAGS, ) < 0) {
-		wpa_printf(MSG_ERROR, "ioctl[SIOCSIFFLAGS]: %s",
-			   strerror(errno));
-		return -1;
-	}
-
-	drv->flags = ifr.ifr_flags;
 	return 0;
 }
 
@@ -582,7 +563,7 @@ bsd_set_ieee8021x(void *priv, struct wpa
 			   __func__);
 		return -1;
 	}
-	return bsd_ctrl_iface(priv, 1);
+	return 0;
 }
 
 static void
@@ -980,8 +961,7 @@ bsd_init(struct hostapd_data *hapd, stru
 	if (l2_packet_get_own_addr(drv->sock_xmit, params->own_addr))
 		goto bad;
 
-	/* mark down during setup */
-	if (bsd_ctrl_iface(drv, 0) < 0)
+	if (bsd_get_iface_flags(drv) < 0)
 		goto bad;
 
 	if (bsd_set_mediaopt(drv, IFM_OMASK, IFM_IEEE80211_HOSTAP) < 0) {
@@ -1006,8 +986,6 @@ bsd_deinit(void *priv)
 {
 	struct bsd_driver_data *drv = priv;
 
-	if (drv->ifindex != 0)
-		bsd_ctrl_iface(drv, 0);
 	if (drv->sock_xmit != NULL)
 		l2_packet_deinit(drv->sock_xmit);
 	os_free(drv);
@@ -1015,13 +993,6 @@ bsd_deinit(void *priv)
 
 
 static int
-bsd_commit(void *priv)
-{
-	return bsd_ctrl_iface(priv, 1);
-}
-
-
-static int
 bsd_set_sta_authorized(void *priv, const u8 *addr,
 		   unsigned int total_flags, unsigned int flags_or,
 		   unsigned int flags_and)
@@ -1274,8 +1245,11 @@ wpa_driver_bsd_scan(void *priv, struct w
 	}
 
 	/* NB: interface must be marked UP to do a scan */
-	if (bsd_ctrl_iface(drv, 1) < 0)
+	if (!(drv->flags & IFF_UP)) {
+		wpa_printf(MSG_DEBUG, "%s: interface is not up, cannot scan",
+		   __func__);
 		return -1;
+	}
 
 #ifdef IEEE80211_IOC_SCAN_MAX_SSID
 	os_memset(, 0, sizeof(sr));
@@ -1565,7 +1539,7 @@ wpa_driver_bsd_init(void *ctx, const cha
 		goto fail;
 
 	/* Down interface during setup. */
-	if (bsd_ctrl_iface(drv, 0) < 0)
+	if (bsd_get_iface_flags(drv) < 0)
 		goto fail;
 
 	drv->opmode = get80211opmode(drv);
@@ -1586,9 +1560,6 @@ wpa_driver_bsd_deinit(void *priv)
 	if (drv->ifindex != 0 && !drv->if_removed) {
 		wpa_driver_bsd_set_wpa(drv, 0);
 
-		/* NB: mark interface down */
-		bsd_ctrl_iface(drv, 0);
-
 		wpa_driver_bsd_set_wpa_internal(drv, drv->prev_wpa,
 		drv->prev_privacy);
 
@@ -1694,7 +1665,6 @@ const struct wpa_driver_ops wpa_driver_b
 	.sta_disassoc		= bsd_sta_disassoc,
 	.sta_deauth		= bsd_sta_deauth,
 	.sta_set_flags		= bsd_set_sta_authorized,
-	.commit			= bsd_commit,
 #else /* HOSTAPD */
 	.init2			= wpa_driver_bsd_init,
 	.deinit			= wpa_driver_bsd_deinit,



CVS commit: src/external/bsd/wpa/dist/src/drivers

2020-01-29 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Wed Jan 29 11:46:47 UTC 2020

Modified Files:
src/external/bsd/wpa/dist/src/drivers: driver_bsd.c

Log Message:
wpa: Remove an outdated comment

With interface matching support, wpa_supplicant can wait for an
interface to appear.


To generate a diff of this commit:
cvs rdiff -u -r1.33 -r1.34 src/external/bsd/wpa/dist/src/drivers/driver_bsd.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/external/bsd/wpa/dist/src/drivers/driver_bsd.c
diff -u src/external/bsd/wpa/dist/src/drivers/driver_bsd.c:1.33 src/external/bsd/wpa/dist/src/drivers/driver_bsd.c:1.34
--- src/external/bsd/wpa/dist/src/drivers/driver_bsd.c:1.33	Wed Jan 29 11:45:54 2020
+++ src/external/bsd/wpa/dist/src/drivers/driver_bsd.c	Wed Jan 29 11:46:47 2020
@@ -1502,12 +1502,6 @@ wpa_driver_bsd_init(void *ctx, const cha
 	if (drv == NULL)
 		return NULL;
 
-	/*
-	 * NB: We require the interface name be mappable to an index.
-	 * This implies we do not support having wpa_supplicant
-	 * wait for an interface to appear.  This seems ok; that
-	 * doesn't belong here; it's really the job of devd.
-	 */
 	drv->ifindex = if_nametoindex(ifname);
 	if (drv->ifindex == 0) {
 		wpa_printf(MSG_DEBUG, "%s: interface %s does not exist",



CVS commit: src/external/bsd/wpa/dist/src/drivers

2020-01-29 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Wed Jan 29 11:46:47 UTC 2020

Modified Files:
src/external/bsd/wpa/dist/src/drivers: driver_bsd.c

Log Message:
wpa: Remove an outdated comment

With interface matching support, wpa_supplicant can wait for an
interface to appear.


To generate a diff of this commit:
cvs rdiff -u -r1.33 -r1.34 src/external/bsd/wpa/dist/src/drivers/driver_bsd.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/external/bsd/wpa/dist/src/drivers

2020-01-29 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Wed Jan 29 11:45:54 UTC 2020

Modified Files:
src/external/bsd/wpa/dist/src/drivers: driver_bsd.c

Log Message:
wpa: Don't set or remove IFF_UP

Now that both hostapd and wpa_supplicant react to interface flag
changes, there is no need to set or remove IFF_UP.

It should be an administrative flag only.


To generate a diff of this commit:
cvs rdiff -u -r1.32 -r1.33 src/external/bsd/wpa/dist/src/drivers/driver_bsd.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/external/bsd/wpa/dist/src/drivers

2020-01-29 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Wed Jan 29 11:44:43 UTC 2020

Modified Files:
src/external/bsd/wpa/dist/src/drivers: driver_bsd.c

Log Message:
wpa: Share route(4) processing with hostapd and wpa_supplicant.

There is little point in having both and it brings interface
addition/removal and IFF_UP notifications to hostapd.


To generate a diff of this commit:
cvs rdiff -u -r1.31 -r1.32 src/external/bsd/wpa/dist/src/drivers/driver_bsd.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/external/bsd/wpa/dist/src/drivers/driver_bsd.c
diff -u src/external/bsd/wpa/dist/src/drivers/driver_bsd.c:1.31 src/external/bsd/wpa/dist/src/drivers/driver_bsd.c:1.32
--- src/external/bsd/wpa/dist/src/drivers/driver_bsd.c:1.31	Wed Jan 29 11:31:40 2020
+++ src/external/bsd/wpa/dist/src/drivers/driver_bsd.c	Wed Jan 29 11:44:43 2020
@@ -132,7 +132,6 @@ bsd_get_drvindex(void *priv, unsigned in
 	return NULL;
 }
 
-#ifndef HOSTAPD
 static struct bsd_driver_data *
 bsd_get_drvname(void *priv, const char *ifname)
 {
@@ -145,7 +144,6 @@ bsd_get_drvname(void *priv, const char *
 	}
 	return NULL;
 }
-#endif /* HOSTAPD */
 
 static int
 bsd_set80211(void *priv, int op, int val, const void *arg, int arg_len)
@@ -680,6 +678,154 @@ bsd_set_opt_ie(void *priv, const u8 *ie,
 	return 0;
 }
 
+static void
+bsd_wireless_event_receive(int sock, void *ctx, void *sock_ctx)
+{
+	struct bsd_driver_global *global = sock_ctx;
+	struct bsd_driver_data *drv;
+	struct if_announcemsghdr *ifan;
+	struct if_msghdr *ifm;
+	struct rt_msghdr *rtm;
+	union wpa_event_data event;
+	struct ieee80211_michael_event *mic;
+	struct ieee80211_leave_event *leave;
+	struct ieee80211_join_event *join;
+	int n;
+	struct msghdr msg = { .msg_iov = global->event_iov, .msg_iovlen = 1};
+
+	n = recvmsg_realloc(sock, , 0);
+	if (n < 0) {
+		if (errno != EINTR && errno != EAGAIN)
+			wpa_printf(MSG_ERROR, "%s read() failed: %s",
+   __func__, strerror(errno));
+		return;
+	}
+
+	rtm = (struct rt_msghdr *) global->event_iov[0].iov_base;
+	if (rtm->rtm_version != RTM_VERSION) {
+		wpa_printf(MSG_DEBUG, "Invalid routing message version=%d",
+			   rtm->rtm_version);
+		return;
+	}
+	os_memset(, 0, sizeof(event));
+	switch (rtm->rtm_type) {
+	case RTM_IEEE80211:
+		ifan = (struct if_announcemsghdr *) rtm;
+		drv = bsd_get_drvindex(global, ifan->ifan_index);
+		if (drv == NULL)
+			return;
+		switch (ifan->ifan_what) {
+		case RTM_IEEE80211_ASSOC:
+		case RTM_IEEE80211_REASSOC:
+			if (drv->is_ap)
+break;
+			wpa_supplicant_event(drv->ctx, EVENT_ASSOC, NULL);
+			break;
+		case RTM_IEEE80211_DISASSOC:
+			if (drv->is_ap)
+break;
+			wpa_supplicant_event(drv->ctx, EVENT_DISASSOC, NULL);
+			break;
+		case RTM_IEEE80211_SCAN:
+			if (drv->is_ap)
+break;
+			wpa_supplicant_event(drv->ctx, EVENT_SCAN_RESULTS,
+	 NULL);
+			break;
+		case RTM_IEEE80211_LEAVE:
+			leave = (struct ieee80211_leave_event *) [1];
+			drv_event_disassoc(drv->ctx, leave->iev_addr);
+			break;
+		case RTM_IEEE80211_JOIN:
+#ifdef RTM_IEEE80211_REJOIN
+		case RTM_IEEE80211_REJOIN:
+#endif
+			join = (struct ieee80211_join_event *) [1];
+			bsd_new_sta(drv, drv->ctx, join->iev_addr);
+			break;
+		case RTM_IEEE80211_REPLAY:
+			/* ignore */
+			break;
+		case RTM_IEEE80211_MICHAEL:
+			mic = (struct ieee80211_michael_event *) [1];
+			wpa_printf(MSG_DEBUG,
+"Michael MIC failure wireless event: "
+"keyix=%u src_addr=" MACSTR, mic->iev_keyix,
+MAC2STR(mic->iev_src));
+			os_memset(, 0, sizeof(event));
+			event.michael_mic_failure.unicast =
+!IEEE80211_IS_MULTICAST(mic->iev_dst);
+			event.michael_mic_failure.src = mic->iev_src;
+			wpa_supplicant_event(drv->ctx,
+	 EVENT_MICHAEL_MIC_FAILURE, );
+			break;
+		}
+		break;
+	case RTM_IFANNOUNCE:
+		ifan = (struct if_announcemsghdr *) rtm;
+		switch (ifan->ifan_what) {
+		case IFAN_DEPARTURE:
+			drv = bsd_get_drvindex(global, ifan->ifan_index);
+			if (drv)
+drv->if_removed = 1;
+			event.interface_status.ievent = EVENT_INTERFACE_REMOVED;
+			break;
+		case IFAN_ARRIVAL:
+			drv = bsd_get_drvname(global, ifan->ifan_name);
+			if (drv) {
+drv->ifindex = ifan->ifan_index;
+drv->if_removed = 0;
+			}
+			event.interface_status.ievent = EVENT_INTERFACE_ADDED;
+			break;
+		default:
+			wpa_printf(MSG_DEBUG, "RTM_IFANNOUNCE: unknown action");
+			return;
+		}
+		wpa_printf(MSG_DEBUG, "RTM_IFANNOUNCE: Interface '%s' %s",
+			   ifan->ifan_name,
+			   ifan->ifan_what == IFAN_DEPARTURE ?
+"removed" : "added");
+		os_strlcpy(event.interface_status.ifname, ifan->ifan_name,
+			   sizeof(event.interface_status.ifname));
+		if (drv) {
+			wpa_supplicant_event(drv->ctx, EVENT_INTERFACE_STATUS,
+	 );
+			/*
+			 * Set ifindex to zero after sending the event as the
+			 * event might query the driver to ensure a match.
+			 */
+			if (ifan->ifan_what == IFAN_DEPARTURE)
+drv->ifindex = 0;

CVS commit: src/external/bsd/wpa/dist/src/drivers

2020-01-29 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Wed Jan 29 11:44:43 UTC 2020

Modified Files:
src/external/bsd/wpa/dist/src/drivers: driver_bsd.c

Log Message:
wpa: Share route(4) processing with hostapd and wpa_supplicant.

There is little point in having both and it brings interface
addition/removal and IFF_UP notifications to hostapd.


To generate a diff of this commit:
cvs rdiff -u -r1.31 -r1.32 src/external/bsd/wpa/dist/src/drivers/driver_bsd.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/external/bsd/wpa/dist/src/drivers

2020-01-29 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Wed Jan 29 11:31:40 UTC 2020

Modified Files:
src/external/bsd/wpa/dist/src/drivers: driver_bsd.c

Log Message:
wpa: Driver does not need to know about both wpa and hostap contexts

It will either be one or the other.
Fold hapd into ctx to match other drivers.


To generate a diff of this commit:
cvs rdiff -u -r1.30 -r1.31 src/external/bsd/wpa/dist/src/drivers/driver_bsd.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/external/bsd/wpa/dist/src/drivers

2020-01-29 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Wed Jan 29 11:31:40 UTC 2020

Modified Files:
src/external/bsd/wpa/dist/src/drivers: driver_bsd.c

Log Message:
wpa: Driver does not need to know about both wpa and hostap contexts

It will either be one or the other.
Fold hapd into ctx to match other drivers.


To generate a diff of this commit:
cvs rdiff -u -r1.30 -r1.31 src/external/bsd/wpa/dist/src/drivers/driver_bsd.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/external/bsd/wpa/dist/src/drivers/driver_bsd.c
diff -u src/external/bsd/wpa/dist/src/drivers/driver_bsd.c:1.30 src/external/bsd/wpa/dist/src/drivers/driver_bsd.c:1.31
--- src/external/bsd/wpa/dist/src/drivers/driver_bsd.c:1.30	Wed Apr 10 17:48:07 2019
+++ src/external/bsd/wpa/dist/src/drivers/driver_bsd.c	Wed Jan 29 11:31:40 2020
@@ -58,14 +58,13 @@ struct bsd_driver_global {
 struct bsd_driver_data {
 	struct dl_list	list;
 	struct bsd_driver_global *global;
-	struct hostapd_data *hapd;	/* back pointer */
+	void	*ctx;
 
 	struct l2_packet_data *sock_xmit;/* raw packet xmit socket */
 	char	ifname[IFNAMSIZ+1];	/* interface name */
 	int	flags;
 	unsigned int ifindex;		/* interface index */
 	int	if_removed;		/* has the interface been removed? */
-	void	*ctx;
 	struct wpa_driver_capa capa;	/* driver capability */
 	int	is_ap;			/* Access point mode */
 	int	prev_roaming;	/* roaming state to restore on deinit */
@@ -843,14 +842,14 @@ bsd_wireless_event_receive(int sock, voi
 			break;
 		case RTM_IEEE80211_LEAVE:
 			leave = (struct ieee80211_leave_event *) [1];
-			drv_event_disassoc(drv->hapd, leave->iev_addr);
+			drv_event_disassoc(drv->ctx, leave->iev_addr);
 			break;
 		case RTM_IEEE80211_JOIN:
 #ifdef RTM_IEEE80211_REJOIN
 		case RTM_IEEE80211_REJOIN:
 #endif
 			join = (struct ieee80211_join_event *) [1];
-			bsd_new_sta(drv, drv->hapd, join->iev_addr);
+			bsd_new_sta(drv, drv->ctx, join->iev_addr);
 			break;
 		case RTM_IEEE80211_REPLAY:
 			/* ignore */
@@ -864,7 +863,7 @@ bsd_wireless_event_receive(int sock, voi
 			os_memset(, 0, sizeof(data));
 			data.michael_mic_failure.unicast = 1;
 			data.michael_mic_failure.src = mic->iev_src;
-			wpa_supplicant_event(drv->hapd,
+			wpa_supplicant_event(drv->ctx,
 	 EVENT_MICHAEL_MIC_FAILURE, );
 			break;
 		}
@@ -876,7 +875,7 @@ static void
 handle_read(void *ctx, const u8 *src_addr, const u8 *buf, size_t len)
 {
 	struct bsd_driver_data *drv = ctx;
-	drv_event_eapol_rx(drv->hapd, src_addr, buf, len);
+	drv_event_eapol_rx(drv->ctx, src_addr, buf, len);
 }
 
 static void *
@@ -897,7 +896,7 @@ bsd_init(struct hostapd_data *hapd, stru
 		goto bad;
 	}
 
-	drv->hapd = hapd;
+	drv->ctx = hapd;
 	drv->global = params->global_priv;
 	os_strlcpy(drv->ifname, params->ifname, sizeof(drv->ifname));
 



CVS commit: src/external/bsd/wpa/dist/src/drivers

2017-04-11 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Tue Apr 11 14:15:08 UTC 2017

Modified Files:
src/external/bsd/wpa/dist/src/drivers: driver_bsd.c

Log Message:
Use RO_MSGFILTER.


To generate a diff of this commit:
cvs rdiff -u -r1.28 -r1.29 src/external/bsd/wpa/dist/src/drivers/driver_bsd.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/external/bsd/wpa/dist/src/drivers

2017-04-11 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Tue Apr 11 14:15:08 UTC 2017

Modified Files:
src/external/bsd/wpa/dist/src/drivers: driver_bsd.c

Log Message:
Use RO_MSGFILTER.


To generate a diff of this commit:
cvs rdiff -u -r1.28 -r1.29 src/external/bsd/wpa/dist/src/drivers/driver_bsd.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/external/bsd/wpa/dist/src/drivers/driver_bsd.c
diff -u src/external/bsd/wpa/dist/src/drivers/driver_bsd.c:1.28 src/external/bsd/wpa/dist/src/drivers/driver_bsd.c:1.29
--- src/external/bsd/wpa/dist/src/drivers/driver_bsd.c:1.28	Tue Apr 11 14:13:01 2017
+++ src/external/bsd/wpa/dist/src/drivers/driver_bsd.c	Tue Apr 11 14:15:08 2017
@@ -1696,6 +1696,14 @@ static void *
 bsd_global_init(void *ctx)
 {
 	struct bsd_driver_global *global;
+#ifdef RO_MSGFILTER
+	unsigned char msgfilter[] = {
+		RTM_IEEE80211,
+#ifndef HOSTAPD
+		RTM_IFINFO, RTM_IFANNOUNCE,
+#endif
+	};
+#endif
 
 	global = os_zalloc(sizeof(*global));
 	if (global == NULL)
@@ -1718,6 +1726,13 @@ bsd_global_init(void *ctx)
 		goto fail;
 	}
 
+#ifdef RO_MSGFILTER
+	if (setsockopt(global->route, PF_ROUTE, RO_MSGFILTER,
+	, sizeof(msgfilter)) < 0)
+		wpa_printf(MSG_ERROR, "setsockopt[PF_ROUTE,RO_MSGFILTER]: %s",
+			   strerror(errno));
+#endif
+
 #ifdef HOSTAPD
 	eloop_register_read_sock(global->route, bsd_wireless_event_receive,
  NULL, global);



CVS commit: src/external/bsd/wpa/dist/src/drivers

2017-04-11 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Tue Apr 11 14:13:01 UTC 2017

Modified Files:
src/external/bsd/wpa/dist/src/drivers: driver_bsd.c

Log Message:
Use recvmsg(2) to read route(4) messages.
Use a shim function for this which can grow it's buffer when needed.


To generate a diff of this commit:
cvs rdiff -u -r1.27 -r1.28 src/external/bsd/wpa/dist/src/drivers/driver_bsd.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/external/bsd/wpa/dist/src/drivers/driver_bsd.c
diff -u src/external/bsd/wpa/dist/src/drivers/driver_bsd.c:1.27 src/external/bsd/wpa/dist/src/drivers/driver_bsd.c:1.28
--- src/external/bsd/wpa/dist/src/drivers/driver_bsd.c:1.27	Thu Jan 12 19:15:10 2017
+++ src/external/bsd/wpa/dist/src/drivers/driver_bsd.c	Tue Apr 11 14:13:01 2017
@@ -9,7 +9,7 @@
 
 #include "includes.h"
 #include 
-#include 
+#include 
 
 #include "common.h"
 #include "driver.h"
@@ -45,15 +45,13 @@
 
 #include "common/ieee802_11_defs.h"
 #include "common/wpa_common.h"
-
 #include "l2_packet/l2_packet.h"
 
 struct bsd_driver_global {
 	void		*ctx;
 	int		sock;			/* socket for 802.11 ioctls */
 	int		route;			/* routing socket for events */
-	char		*event_buf;
-	size_t		event_buf_len;
+	struct iovec	event_iov[1];
 	struct dl_list	ifaces;			/* list of interfaces */
 };
 
@@ -78,6 +76,50 @@ struct bsd_driver_data {
 
 /* Generic functions for hostapd and wpa_supplicant */
 
+#define IOVEC_BUFSIZ		256
+ssize_t
+recvmsg_realloc(int fd, struct msghdr *msg, int flags)
+{
+	struct iovec *iov;
+	ssize_t slen;
+	size_t len;
+	void *n;
+
+	/* Assume we are reallocing the last iovec. */
+	iov = >msg_iov[msg->msg_iovlen - 1];
+
+	for (;;) {
+		/* Passing MSG_TRUNC should return the actual size needed. */
+		slen = recvmsg(fd, msg, flags | MSG_PEEK | MSG_TRUNC);
+		if (slen == -1)
+			return -1;
+		if (!(msg->msg_flags & MSG_TRUNC))
+			break;
+
+		len = (size_t)slen;
+
+		/* Some kernels return the size of the receive buffer
+		 * on truncation, not the actual size needed.
+		 * So grow the buffer and try again. */
+		if (iov->iov_len == len)
+			len = roundup(len + 1, IOVEC_BUFSIZ);
+		else if (iov->iov_len > len)
+			break;
+		if ((n = realloc(iov->iov_base, len)) == NULL)
+			return -1;
+		iov->iov_base = n;
+		iov->iov_len = len;
+	}
+
+	slen = recvmsg(fd, msg, flags);
+	if (slen != -1 && msg->msg_flags & MSG_TRUNC) {
+		/* This should not be possible ... */
+		errno = ENOBUFS;
+		return -1;
+	}
+	return slen;
+}
+
 static struct bsd_driver_data *
 bsd_get_drvindex(void *priv, unsigned int ifindex)
 {
@@ -637,22 +679,6 @@ bsd_set_opt_ie(void *priv, const u8 *ie,
 	return 0;
 }
 
-static size_t
-rtbuf_len(void)
-{
-	size_t len;
-
-	int mib[6] = {CTL_NET, AF_ROUTE, 0, AF_INET, NET_RT_DUMP, 0};
-
-	if (sysctl(mib, 6, NULL, , NULL, 0) < 0) {
-		wpa_printf(MSG_WARNING, "%s failed: %s", __func__,
-			   strerror(errno));
-		len = 2048;
-	}
-
-	return len;
-}
-
 #ifdef HOSTAPD
 
 /*
@@ -727,7 +753,7 @@ bsd_get_seqnum(const char *ifname, void 
 }
 
 
-static int 
+static int
 bsd_flush(void *priv)
 {
 	u8 allsta[IEEE80211_ADDR_LEN];
@@ -775,15 +801,19 @@ bsd_wireless_event_receive(int sock, voi
 {
 	struct bsd_driver_global *global = sock_ctx;
 	struct bsd_driver_data *drv;
+	struct msghdr msg;
 	struct if_announcemsghdr *ifan;
 	struct rt_msghdr *rtm;
 	struct ieee80211_michael_event *mic;
 	struct ieee80211_join_event *join;
 	struct ieee80211_leave_event *leave;
-	int n;
+	ssize_t n;
 	union wpa_event_data data;
 
-	n = read(sock, global->event_buf, global->event_buf_len);
+	memset(, 0, sizeof(msg));
+	msg.msg_iov = global->event_iov;
+	msg.msg_iovlen = 1;
+	n = recvmsg_realloc(sock, , 0);
 	if (n < 0) {
 		if (errno != EINTR && errno != EAGAIN)
 			wpa_printf(MSG_ERROR, "%s read() failed: %s",
@@ -791,7 +821,7 @@ bsd_wireless_event_receive(int sock, voi
 		return;
 	}
 
-	rtm = (struct rt_msghdr *) global->event_buf;
+	rtm = (struct rt_msghdr *) global->event_iov[0].iov_base;
 	if (rtm->rtm_version != RTM_VERSION) {
 		wpa_printf(MSG_DEBUG, "Invalid routing message version=%d",
 			   rtm->rtm_version);
@@ -1213,6 +1243,7 @@ wpa_driver_bsd_event_receive(int sock, v
 {
 	struct bsd_driver_global *global = sock_ctx;
 	struct bsd_driver_data *drv;
+	struct msghdr msg;
 	struct if_announcemsghdr *ifan;
 	struct if_msghdr *ifm;
 	struct rt_msghdr *rtm;
@@ -1220,9 +1251,12 @@ wpa_driver_bsd_event_receive(int sock, v
 	struct ieee80211_michael_event *mic;
 	struct ieee80211_leave_event *leave;
 	struct ieee80211_join_event *join;
-	int n;
+	ssize_t n;
 
-	n = read(sock, global->event_buf, global->event_buf_len);
+	memset(, 0, sizeof(msg));
+	msg.msg_iov = global->event_iov;
+	msg.msg_iovlen = 1;
+	n = recvmsg_realloc(sock, , 0);
 	if (n < 0) {
 		if (errno != EINTR && errno != EAGAIN)
 			wpa_printf(MSG_ERROR, "%s read() failed: %s",
@@ -1230,7 +1264,7 @@ wpa_driver_bsd_event_receive(int sock, v
 		return;
 	}
 
-	rtm = 

CVS commit: src/external/bsd/wpa/dist/src/drivers

2017-04-11 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Tue Apr 11 14:13:01 UTC 2017

Modified Files:
src/external/bsd/wpa/dist/src/drivers: driver_bsd.c

Log Message:
Use recvmsg(2) to read route(4) messages.
Use a shim function for this which can grow it's buffer when needed.


To generate a diff of this commit:
cvs rdiff -u -r1.27 -r1.28 src/external/bsd/wpa/dist/src/drivers/driver_bsd.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/external/bsd/wpa/dist/src/drivers

2016-04-11 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Mon Apr 11 08:57:19 UTC 2016

Modified Files:
src/external/bsd/wpa/dist/src/drivers: driver_bsd.c

Log Message:
Only FreeBSD treats rssi this way, so #ifdef it and just treat rssi
as a number for other OS.


To generate a diff of this commit:
cvs rdiff -u -r1.24 -r1.25 src/external/bsd/wpa/dist/src/drivers/driver_bsd.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/external/bsd/wpa/dist/src/drivers/driver_bsd.c
diff -u src/external/bsd/wpa/dist/src/drivers/driver_bsd.c:1.24 src/external/bsd/wpa/dist/src/drivers/driver_bsd.c:1.25
--- src/external/bsd/wpa/dist/src/drivers/driver_bsd.c:1.24	Wed Mar 23 08:51:02 2016
+++ src/external/bsd/wpa/dist/src/drivers/driver_bsd.c	Mon Apr 11 08:57:19 2016
@@ -1374,11 +1374,16 @@ wpa_driver_bsd_add_scan_entry(struct wpa
 	result->caps = sr->isr_capinfo;
 	result->qual = sr->isr_rssi;
 	result->noise = sr->isr_noise;
+
+#ifdef __FreeBSD__
 	/*
 	 * the rssi value reported by the kernel is in 0.5dB steps relative to
 	 * the reported noise floor. see ieee80211_node.h for details.
 	 */
 	result->level = sr->isr_rssi / 2 + sr->isr_noise;
+#else
+	result->level = sr->isr_rssi;
+#endif
 
 	pos = (u8 *)(result + 1);
 



CVS commit: src/external/bsd/wpa/dist/src/drivers

2016-04-11 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Mon Apr 11 08:57:19 UTC 2016

Modified Files:
src/external/bsd/wpa/dist/src/drivers: driver_bsd.c

Log Message:
Only FreeBSD treats rssi this way, so #ifdef it and just treat rssi
as a number for other OS.


To generate a diff of this commit:
cvs rdiff -u -r1.24 -r1.25 src/external/bsd/wpa/dist/src/drivers/driver_bsd.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/external/bsd/wpa/dist/src/drivers

2016-03-23 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Wed Mar 23 08:51:02 UTC 2016

Modified Files:
src/external/bsd/wpa/dist/src/drivers: driver_bsd.c

Log Message:
Only down the interface once we are sure we can work with it.


To generate a diff of this commit:
cvs rdiff -u -r1.23 -r1.24 src/external/bsd/wpa/dist/src/drivers/driver_bsd.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/external/bsd/wpa/dist/src/drivers

2016-03-23 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Wed Mar 23 08:51:02 UTC 2016

Modified Files:
src/external/bsd/wpa/dist/src/drivers: driver_bsd.c

Log Message:
Only down the interface once we are sure we can work with it.


To generate a diff of this commit:
cvs rdiff -u -r1.23 -r1.24 src/external/bsd/wpa/dist/src/drivers/driver_bsd.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/external/bsd/wpa/dist/src/drivers/driver_bsd.c
diff -u src/external/bsd/wpa/dist/src/drivers/driver_bsd.c:1.23 src/external/bsd/wpa/dist/src/drivers/driver_bsd.c:1.24
--- src/external/bsd/wpa/dist/src/drivers/driver_bsd.c:1.23	Wed Mar 23 08:48:43 2016
+++ src/external/bsd/wpa/dist/src/drivers/driver_bsd.c	Wed Mar 23 08:51:02 2016
@@ -1578,11 +1578,7 @@ wpa_driver_bsd_init(void *ctx, const cha
 
 	drv->ctx = ctx;
 	drv->global = priv;
-
 	os_strlcpy(drv->ifname, ifname, sizeof(drv->ifname));
-	/* Down interface during setup. */
-	if (bsd_ctrl_iface(drv, 0) < 0)
-		goto fail;
 
 	if (!GETPARAM(drv, IEEE80211_IOC_ROAMING, drv->prev_roaming)) {
 		wpa_printf(MSG_DEBUG, "%s: failed to get roaming state: %s",
@@ -1603,6 +1599,10 @@ wpa_driver_bsd_init(void *ctx, const cha
 	if (wpa_driver_bsd_capa(drv))
 		goto fail;
 
+	/* Down interface during setup. */
+	if (bsd_ctrl_iface(drv, 0) < 0)
+		goto fail;
+
 	drv->opmode = get80211opmode(drv);
 	dl_list_add(>global->ifaces, >list);
 



CVS commit: src/external/bsd/wpa/dist/src/drivers

2016-02-05 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Fri Feb  5 15:05:29 UTC 2016

Modified Files:
src/external/bsd/wpa/dist/src/drivers: driver_bsd.c

Log Message:
Fix is defined in wpa_common.h which the driver already pulls in.


To generate a diff of this commit:
cvs rdiff -u -r1.21 -r1.22 src/external/bsd/wpa/dist/src/drivers/driver_bsd.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/external/bsd/wpa/dist/src/drivers/driver_bsd.c
diff -u src/external/bsd/wpa/dist/src/drivers/driver_bsd.c:1.21 src/external/bsd/wpa/dist/src/drivers/driver_bsd.c:1.22
--- src/external/bsd/wpa/dist/src/drivers/driver_bsd.c:1.21	Wed Jan 20 14:43:40 2016
+++ src/external/bsd/wpa/dist/src/drivers/driver_bsd.c	Fri Feb  5 15:05:29 2016
@@ -690,9 +690,6 @@ bsd_get_seqnum(const char *ifname, void 
 	}
 
 #ifdef WORDS_BIGENDIAN
-#ifndef WPA_KEY_RSC_LEN
-#define WPA_KEY_RSC_LEN 8
-#endif
 	{
 		/*
 		 * wk.ik_keytsc is in host byte order (big endian), need to



CVS commit: src/external/bsd/wpa/dist/src/drivers

2016-02-05 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Fri Feb  5 15:05:29 UTC 2016

Modified Files:
src/external/bsd/wpa/dist/src/drivers: driver_bsd.c

Log Message:
Fix is defined in wpa_common.h which the driver already pulls in.


To generate a diff of this commit:
cvs rdiff -u -r1.21 -r1.22 src/external/bsd/wpa/dist/src/drivers/driver_bsd.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/external/bsd/wpa/dist/src/drivers

2016-01-20 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Wed Jan 20 14:43:40 UTC 2016

Modified Files:
src/external/bsd/wpa/dist/src/drivers: driver_bsd.c

Log Message:
If an interface is removed, zero the remembered ifindex.
Don't try to set properties on the interface when it is removed.


To generate a diff of this commit:
cvs rdiff -u -r1.20 -r1.21 src/external/bsd/wpa/dist/src/drivers/driver_bsd.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/external/bsd/wpa/dist/src/drivers

2016-01-20 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Wed Jan 20 14:43:40 UTC 2016

Modified Files:
src/external/bsd/wpa/dist/src/drivers: driver_bsd.c

Log Message:
If an interface is removed, zero the remembered ifindex.
Don't try to set properties on the interface when it is removed.


To generate a diff of this commit:
cvs rdiff -u -r1.20 -r1.21 src/external/bsd/wpa/dist/src/drivers/driver_bsd.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/external/bsd/wpa/dist/src/drivers/driver_bsd.c
diff -u src/external/bsd/wpa/dist/src/drivers/driver_bsd.c:1.20 src/external/bsd/wpa/dist/src/drivers/driver_bsd.c:1.21
--- src/external/bsd/wpa/dist/src/drivers/driver_bsd.c:1.20	Tue Jan 19 18:09:09 2016
+++ src/external/bsd/wpa/dist/src/drivers/driver_bsd.c	Wed Jan 20 14:43:40 2016
@@ -94,6 +94,9 @@ bsd_set80211(void *priv, int op, int val
 	struct bsd_driver_data *drv = priv;
 	struct ieee80211req ireq;
 
+	if (drv->ifindex == 0)
+		return -1;
+
 	os_memset(, 0, sizeof(ireq));
 	os_strlcpy(ireq.i_name, drv->ifname, sizeof(ireq.i_name));
 	ireq.i_type = op;
@@ -884,7 +887,8 @@ bsd_deinit(void *priv)
 {
 	struct bsd_driver_data *drv = priv;
 
-	bsd_ctrl_iface(drv, 0);
+	if (drv->ifindex != 0)
+		bsd_ctrl_iface(drv, 0);
 	if (drv->sock_xmit != NULL)
 		l2_packet_deinit(drv->sock_xmit);
 	os_free(drv);
@@ -1228,6 +1232,7 @@ wpa_driver_bsd_event_receive(int sock, v
 		switch (ifan->ifan_what) {
 		case IFAN_DEPARTURE:
 			event.interface_status.ievent = EVENT_INTERFACE_REMOVED;
+			drv->ifindex = 0;
 			break;
 		default:
 			return;
@@ -1578,16 +1583,21 @@ wpa_driver_bsd_deinit(void *priv)
 {
 	struct bsd_driver_data *drv = priv;
 
-	wpa_driver_bsd_set_wpa(drv, 0);
+	if (drv->ifindex != 0) {
+		wpa_driver_bsd_set_wpa(drv, 0);
 
-	/* NB: mark interface down */
-	bsd_ctrl_iface(drv, 0);
+		/* NB: mark interface down */
+		bsd_ctrl_iface(drv, 0);
 
-	wpa_driver_bsd_set_wpa_internal(drv, drv->prev_wpa, drv->prev_privacy);
+		wpa_driver_bsd_set_wpa_internal(drv, drv->prev_wpa,
+		drv->prev_privacy);
 
-	if (set80211param(drv, IEEE80211_IOC_ROAMING, drv->prev_roaming) < 0)
-		wpa_printf(MSG_DEBUG, "%s: failed to restore roaming state",
-			__func__);
+		if (set80211param(drv, IEEE80211_IOC_ROAMING, drv->prev_roaming)
+		< 0)
+			wpa_printf(MSG_DEBUG,
+"%s: failed to restore roaming state",
+__func__);
+	}
 
 	if (drv->sock_xmit != NULL)
 		l2_packet_deinit(drv->sock_xmit);



CVS commit: src/external/bsd/wpa/dist/src/drivers

2016-01-19 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Tue Jan 19 18:09:09 UTC 2016

Modified Files:
src/external/bsd/wpa/dist/src/drivers: driver_bsd.c

Log Message:
wpa_supplicant dropped the -w option a long time ago, lets not pretend
it still works.


To generate a diff of this commit:
cvs rdiff -u -r1.19 -r1.20 src/external/bsd/wpa/dist/src/drivers/driver_bsd.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/external/bsd/wpa/dist/src/drivers/driver_bsd.c
diff -u src/external/bsd/wpa/dist/src/drivers/driver_bsd.c:1.19 src/external/bsd/wpa/dist/src/drivers/driver_bsd.c:1.20
--- src/external/bsd/wpa/dist/src/drivers/driver_bsd.c:1.19	Tue Jan 19 17:22:57 2016
+++ src/external/bsd/wpa/dist/src/drivers/driver_bsd.c	Tue Jan 19 18:09:09 2016
@@ -1228,20 +1228,16 @@ wpa_driver_bsd_event_receive(int sock, v
 		switch (ifan->ifan_what) {
 		case IFAN_DEPARTURE:
 			event.interface_status.ievent = EVENT_INTERFACE_REMOVED;
-		default:
-#if 1
-			event.interface_status.ievent = EVENT_INTERFACE_ADDED;
 			break;
-#else
+		default:
 			return;
-#endif
 		}
 		wpa_printf(MSG_DEBUG, "RTM_IFANNOUNCE: Interface '%s' %s",
 			   event.interface_status.ifname,
 			   ifan->ifan_what == IFAN_DEPARTURE ?
 "removed" : "added");
 		wpa_supplicant_event(drv->ctx, EVENT_INTERFACE_STATUS, );
-		return;
+		break;
 	case RTM_IEEE80211:
 		ifan = (struct if_announcemsghdr *) rtm;
 		drv = bsd_get_drvindex(global, ifan->ifan_index);



CVS commit: src/external/bsd/wpa/dist/src/drivers

2016-01-19 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Tue Jan 19 18:09:09 UTC 2016

Modified Files:
src/external/bsd/wpa/dist/src/drivers: driver_bsd.c

Log Message:
wpa_supplicant dropped the -w option a long time ago, lets not pretend
it still works.


To generate a diff of this commit:
cvs rdiff -u -r1.19 -r1.20 src/external/bsd/wpa/dist/src/drivers/driver_bsd.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/external/bsd/wpa/dist/src/drivers

2016-01-19 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Tue Jan 19 15:08:29 UTC 2016

Modified Files:
src/external/bsd/wpa/dist/src/drivers: driver_bsd.c

Log Message:
Don't log RTM messages we aren't interested in at all.


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/external/bsd/wpa/dist/src/drivers/driver_bsd.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/external/bsd/wpa/dist/src/drivers/driver_bsd.c
diff -u src/external/bsd/wpa/dist/src/drivers/driver_bsd.c:1.12 src/external/bsd/wpa/dist/src/drivers/driver_bsd.c:1.13
--- src/external/bsd/wpa/dist/src/drivers/driver_bsd.c:1.12	Thu Jan 14 21:19:41 2016
+++ src/external/bsd/wpa/dist/src/drivers/driver_bsd.c	Tue Jan 19 15:08:29 2016
@@ -1327,32 +1327,9 @@ wpa_driver_bsd_event_receive(int sock, v
 			wpa_printf(MSG_DEBUG, "RTM_IFINFO: Interface '%s' "
 			"if=%x drv=%x", event.interface_status.ifname,
 			ifm->ifm_flags, drv->flags);
- 		}
+		}
 		drv->flags = ifm->ifm_flags;
 		break;
-#ifdef RTM_OIFINFO
-	case RTM_OIFINFO:
-		wpa_printf(MSG_DEBUG, "RTM_OIFINFO ignored");
-		break;
-#endif
-#ifdef RTM_OOIFINFO
-	case RTM_OOIFINFO:
-		wpa_printf(MSG_DEBUG, "RTM_OOIFINFO ignored");
-		break;
-#endif
-#ifdef RTM_LOSING
-	case RTM_LOSING:
-		wpa_printf(MSG_DEBUG, "RTM_LOSING ignored");
-		break;
-#endif
-#ifdef RTM_MISS
-	case RTM_MISS:
-		wpa_printf(MSG_DEBUG, "RTM_MISS ignored");
-		break;
-#endif
-	default:
-		wpa_printf(MSG_DEBUG, "RTM_???: %d", rtm->rtm_type);
-		break;
 	}
 }
 



Re: CVS commit: src/external/bsd/wpa/dist/src/drivers

2016-01-19 Thread Christos Zoulas
In article <20160119150829.60108f...@cvs.netbsd.org>,
Roy Marples  wrote:
>-=-=-=-=-=-
>
>Module Name:   src
>Committed By:  roy
>Date:  Tue Jan 19 15:08:29 UTC 2016
>
>Modified Files:
>   src/external/bsd/wpa/dist/src/drivers: driver_bsd.c
>
>Log Message:
>Don't log RTM messages we aren't interested in at all.

But these were debugging printfs...

christos



CVS commit: src/external/bsd/wpa/dist/src/drivers

2016-01-19 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Tue Jan 19 15:08:29 UTC 2016

Modified Files:
src/external/bsd/wpa/dist/src/drivers: driver_bsd.c

Log Message:
Don't log RTM messages we aren't interested in at all.


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/external/bsd/wpa/dist/src/drivers/driver_bsd.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/external/bsd/wpa/dist/src/drivers

2016-01-19 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Tue Jan 19 15:18:20 UTC 2016

Modified Files:
src/external/bsd/wpa/dist/src/drivers: driver_bsd.c

Log Message:
Remove added debug to sync more with upstream.


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/external/bsd/wpa/dist/src/drivers/driver_bsd.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/external/bsd/wpa/dist/src/drivers/driver_bsd.c
diff -u src/external/bsd/wpa/dist/src/drivers/driver_bsd.c:1.13 src/external/bsd/wpa/dist/src/drivers/driver_bsd.c:1.14
--- src/external/bsd/wpa/dist/src/drivers/driver_bsd.c:1.13	Tue Jan 19 15:08:29 2016
+++ src/external/bsd/wpa/dist/src/drivers/driver_bsd.c	Tue Jan 19 15:18:20 2016
@@ -1237,10 +1237,10 @@ wpa_driver_bsd_event_receive(int sock, v
 			return;
 #endif
 		}
-		wpa_printf(MSG_DEBUG, "RTM_IFANNOUNCE: Interface '%s' %s (%d)",
+		wpa_printf(MSG_DEBUG, "RTM_IFANNOUNCE: Interface '%s' %s",
 			   event.interface_status.ifname,
 			   ifan->ifan_what == IFAN_DEPARTURE ?
-"removed" : "added", ifan->ifan_what);
+"removed" : "added");
 		wpa_supplicant_event(ctx, EVENT_INTERFACE_STATUS, );
 		return;
 	case RTM_IEEE80211:
@@ -1250,22 +1250,16 @@ wpa_driver_bsd_event_receive(int sock, v
 		case RTM_IEEE80211_REASSOC:
 			if (drv->is_ap)
 break;
-			wpa_printf(MSG_DEBUG, "RTM_IEEE80211: (re)assoc (%d)",
-			ifan->ifan_what);
 			wpa_supplicant_event(ctx, EVENT_ASSOC, NULL);
 			break;
 		case RTM_IEEE80211_DISASSOC:
 			if (drv->is_ap)
 break;
-			wpa_printf(MSG_DEBUG, "RTM_IEEE80211: disassoc (%d)",
-			ifan->ifan_what);
 			wpa_supplicant_event(ctx, EVENT_DISASSOC, NULL);
 			break;
 		case RTM_IEEE80211_SCAN:
 			if (drv->is_ap)
 break;
-			wpa_printf(MSG_DEBUG, "RTM_IEEE80211: scan result (%d)",
-			ifan->ifan_what);
 			wpa_supplicant_event(ctx, EVENT_SCAN_RESULTS, NULL);
 			break;
 		case RTM_IEEE80211_LEAVE:
@@ -1280,8 +1274,6 @@ wpa_driver_bsd_event_receive(int sock, v
 			bsd_new_sta(drv, ctx, join->iev_addr);
 			break;
 		case RTM_IEEE80211_REPLAY:
-			wpa_printf(MSG_DEBUG, "RTM_IEEE80211: replay (%d)",
-			ifan->ifan_what);
 			/* ignore */
 			break;
 		case RTM_IEEE80211_MICHAEL:
@@ -1297,10 +1289,6 @@ wpa_driver_bsd_event_receive(int sock, v
 			wpa_supplicant_event(ctx, EVENT_MICHAEL_MIC_FAILURE,
 );
 			break;
-		default:
-			wpa_printf(MSG_DEBUG, "RTM_IEEE80211: ??? (%d)",
-			ifan->ifan_what);
-			break;
 		}
 		break;
 	case RTM_IFINFO:



CVS commit: src/external/bsd/wpa/dist/src/drivers

2016-01-19 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Tue Jan 19 15:18:20 UTC 2016

Modified Files:
src/external/bsd/wpa/dist/src/drivers: driver_bsd.c

Log Message:
Remove added debug to sync more with upstream.


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/external/bsd/wpa/dist/src/drivers/driver_bsd.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/external/bsd/wpa/dist/src/drivers

2016-01-19 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Tue Jan 19 15:27:57 UTC 2016

Modified Files:
src/external/bsd/wpa/dist/src/drivers: driver_bsd.c

Log Message:
Remove pointless check


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 src/external/bsd/wpa/dist/src/drivers/driver_bsd.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/external/bsd/wpa/dist/src/drivers

2016-01-19 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Tue Jan 19 15:27:57 UTC 2016

Modified Files:
src/external/bsd/wpa/dist/src/drivers: driver_bsd.c

Log Message:
Remove pointless check


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 src/external/bsd/wpa/dist/src/drivers/driver_bsd.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/external/bsd/wpa/dist/src/drivers/driver_bsd.c
diff -u src/external/bsd/wpa/dist/src/drivers/driver_bsd.c:1.14 src/external/bsd/wpa/dist/src/drivers/driver_bsd.c:1.15
--- src/external/bsd/wpa/dist/src/drivers/driver_bsd.c:1.14	Tue Jan 19 15:18:20 2016
+++ src/external/bsd/wpa/dist/src/drivers/driver_bsd.c	Tue Jan 19 15:27:57 2016
@@ -870,11 +870,9 @@ bsd_init(struct hostapd_data *hapd, stru
 
 	return drv;
 bad:
-	if (drv != NULL) {
-		if (drv->sock_xmit != NULL)
-			l2_packet_deinit(drv->sock_xmit);
-		os_free(drv);
-	}
+	if (drv->sock_xmit != NULL)
+		l2_packet_deinit(drv->sock_xmit);
+	os_free(drv);
 	return NULL;
 }
 



CVS commit: src/external/bsd/wpa/dist/src/drivers

2016-01-19 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Tue Jan 19 15:45:00 UTC 2016

Modified Files:
src/external/bsd/wpa/dist/src/drivers: driver_bsd.c

Log Message:
Revert an older change as upstream now calculates level from rssi and noise.


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/external/bsd/wpa/dist/src/drivers/driver_bsd.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/external/bsd/wpa/dist/src/drivers

2016-01-19 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Tue Jan 19 15:49:07 UTC 2016

Modified Files:
src/external/bsd/wpa/dist/src/drivers: driver_bsd.c

Log Message:
Syntax (no functional change)


To generate a diff of this commit:
cvs rdiff -u -r1.16 -r1.17 src/external/bsd/wpa/dist/src/drivers/driver_bsd.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/external/bsd/wpa/dist/src/drivers

2016-01-19 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Tue Jan 19 15:49:07 UTC 2016

Modified Files:
src/external/bsd/wpa/dist/src/drivers: driver_bsd.c

Log Message:
Syntax (no functional change)


To generate a diff of this commit:
cvs rdiff -u -r1.16 -r1.17 src/external/bsd/wpa/dist/src/drivers/driver_bsd.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/external/bsd/wpa/dist/src/drivers/driver_bsd.c
diff -u src/external/bsd/wpa/dist/src/drivers/driver_bsd.c:1.16 src/external/bsd/wpa/dist/src/drivers/driver_bsd.c:1.17
--- src/external/bsd/wpa/dist/src/drivers/driver_bsd.c:1.16	Tue Jan 19 15:45:00 2016
+++ src/external/bsd/wpa/dist/src/drivers/driver_bsd.c	Tue Jan 19 15:49:07 2016
@@ -1613,7 +1613,7 @@ wpa_driver_bsd_get_capa(void *priv, stru
 #endif /* HOSTAPD */
 
 static void *
-bsd_global_init()
+bsd_global_init(void)
 {
 	struct bsd_driver_global *global;
 



CVS commit: src/external/bsd/wpa/dist/src/drivers

2016-01-19 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Tue Jan 19 16:47:44 UTC 2016

Modified Files:
src/external/bsd/wpa/dist/src/drivers: driver_bsd.c

Log Message:
Use the interface index from the correc structure according to the message
to find the driver instead of assuming that rtm_index is corect.


To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.18 src/external/bsd/wpa/dist/src/drivers/driver_bsd.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/external/bsd/wpa/dist/src/drivers

2016-01-19 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Tue Jan 19 16:47:44 UTC 2016

Modified Files:
src/external/bsd/wpa/dist/src/drivers: driver_bsd.c

Log Message:
Use the interface index from the correc structure according to the message
to find the driver instead of assuming that rtm_index is corect.


To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.18 src/external/bsd/wpa/dist/src/drivers/driver_bsd.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/external/bsd/wpa/dist/src/drivers/driver_bsd.c
diff -u src/external/bsd/wpa/dist/src/drivers/driver_bsd.c:1.17 src/external/bsd/wpa/dist/src/drivers/driver_bsd.c:1.18
--- src/external/bsd/wpa/dist/src/drivers/driver_bsd.c:1.17	Tue Jan 19 15:49:07 2016
+++ src/external/bsd/wpa/dist/src/drivers/driver_bsd.c	Tue Jan 19 16:47:44 2016
@@ -777,12 +777,12 @@ bsd_wireless_event_receive(int sock, voi
 			   rtm->rtm_version);
 		return;
 	}
-	drv = bsd_get_drvindex(global, rtm->rtm_index);
-	if (drv == NULL)
-		return;
 	switch (rtm->rtm_type) {
 	case RTM_IEEE80211:
 		ifan = (struct if_announcemsghdr *) rtm;
+		drv = bsd_get_drvindex(global, ifan->ifan_index);
+		if (drv == NULL)
+			return;
 		switch (ifan->ifan_what) {
 		case RTM_IEEE80211_ASSOC:
 		case RTM_IEEE80211_REASSOC:
@@ -1214,14 +1214,13 @@ wpa_driver_bsd_event_receive(int sock, v
 			   rtm->rtm_version);
 		return;
 	}
-	drv = bsd_get_drvindex(global, rtm->rtm_index);
-	if (drv == NULL)
-		return;
-	ctx = drv->ctx;
 	os_memset(, 0, sizeof(event));
 	switch (rtm->rtm_type) {
 	case RTM_IFANNOUNCE:
 		ifan = (struct if_announcemsghdr *) rtm;
+		drv = bsd_get_drvindex(global, ifan->ifan_index);
+		if (drv == NULL)
+			return;
 		os_strlcpy(event.interface_status.ifname, drv->ifname,
 			   sizeof(event.interface_status.ifname));
 		switch (ifan->ifan_what) {
@@ -1239,37 +1238,40 @@ wpa_driver_bsd_event_receive(int sock, v
 			   event.interface_status.ifname,
 			   ifan->ifan_what == IFAN_DEPARTURE ?
 "removed" : "added");
-		wpa_supplicant_event(ctx, EVENT_INTERFACE_STATUS, );
+		wpa_supplicant_event(drv->ctx, EVENT_INTERFACE_STATUS, );
 		return;
 	case RTM_IEEE80211:
 		ifan = (struct if_announcemsghdr *) rtm;
+		drv = bsd_get_drvindex(global, ifan->ifan_index);
+		if (drv == NULL)
+			return;
 		switch (ifan->ifan_what) {
 		case RTM_IEEE80211_ASSOC:
 		case RTM_IEEE80211_REASSOC:
 			if (drv->is_ap)
 break;
-			wpa_supplicant_event(ctx, EVENT_ASSOC, NULL);
+			wpa_supplicant_event(drv->ctx, EVENT_ASSOC, NULL);
 			break;
 		case RTM_IEEE80211_DISASSOC:
 			if (drv->is_ap)
 break;
-			wpa_supplicant_event(ctx, EVENT_DISASSOC, NULL);
+			wpa_supplicant_event(drv->ctx, EVENT_DISASSOC, NULL);
 			break;
 		case RTM_IEEE80211_SCAN:
 			if (drv->is_ap)
 break;
-			wpa_supplicant_event(ctx, EVENT_SCAN_RESULTS, NULL);
+			wpa_supplicant_event(drv->ctx, EVENT_SCAN_RESULTS, NULL);
 			break;
 		case RTM_IEEE80211_LEAVE:
 			leave = (struct ieee80211_leave_event *) [1];
-			drv_event_disassoc(ctx, leave->iev_addr);
+			drv_event_disassoc(drv->ctx, leave->iev_addr);
 			break;
 		case RTM_IEEE80211_JOIN:
 #ifdef RTM_IEEE80211_REJOIN
 		case RTM_IEEE80211_REJOIN:
 #endif
 			join = (struct ieee80211_join_event *) [1];
-			bsd_new_sta(drv, ctx, join->iev_addr);
+			bsd_new_sta(drv, drv->ctx, join->iev_addr);
 			break;
 		case RTM_IEEE80211_REPLAY:
 			/* ignore */
@@ -1284,13 +1286,16 @@ wpa_driver_bsd_event_receive(int sock, v
 			os_memset(, 0, sizeof(event));
 			event.michael_mic_failure.unicast =
 !IEEE80211_IS_MULTICAST(mic->iev_dst);
-			wpa_supplicant_event(ctx, EVENT_MICHAEL_MIC_FAILURE,
-);
+			wpa_supplicant_event(drv->ctx,
+EVENT_MICHAEL_MIC_FAILURE, );
 			break;
 		}
 		break;
 	case RTM_IFINFO:
 		ifm = (struct if_msghdr *) rtm;
+		drv = bsd_get_drvindex(global, ifm->ifm_index);
+		if (drv == NULL)
+			return;
 		if ((ifm->ifm_flags & IFF_UP) == 0 &&
 		(drv->flags & IFF_UP) != 0) {
 			os_strlcpy(event.interface_status.ifname, drv->ifname,
@@ -1298,7 +1303,8 @@ wpa_driver_bsd_event_receive(int sock, v
 			event.interface_status.ievent = EVENT_INTERFACE_REMOVED;
 			wpa_printf(MSG_DEBUG, "RTM_IFINFO: Interface '%s' DOWN",
    event.interface_status.ifname);
-			wpa_supplicant_event(ctx, EVENT_INTERFACE_STATUS, );
+			wpa_supplicant_event(drv->ctx, EVENT_INTERFACE_STATUS,
+	 );
 		} else if ((ifm->ifm_flags & IFF_UP) != 0 &&
 		(drv->flags & IFF_UP) == 0) {
 			os_strlcpy(event.interface_status.ifname, drv->ifname,
@@ -1306,7 +1312,8 @@ wpa_driver_bsd_event_receive(int sock, v
 			event.interface_status.ievent = EVENT_INTERFACE_ADDED;
 			wpa_printf(MSG_DEBUG, "RTM_IFINFO: Interface '%s' UP",
    event.interface_status.ifname);
-			wpa_supplicant_event(ctx, EVENT_INTERFACE_STATUS, );
+			wpa_supplicant_event(drv->ctx, EVENT_INTERFACE_STATUS,
+	 );
 		} else {
 			os_strlcpy(event.interface_status.ifname, drv->ifname,
 

CVS commit: src/external/bsd/wpa/dist/src/drivers

2016-01-19 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Tue Jan 19 17:22:57 UTC 2016

Modified Files:
src/external/bsd/wpa/dist/src/drivers: driver_bsd.c

Log Message:
Downing the interface now disables it instead of removing it.


To generate a diff of this commit:
cvs rdiff -u -r1.18 -r1.19 src/external/bsd/wpa/dist/src/drivers/driver_bsd.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/external/bsd/wpa/dist/src/drivers/driver_bsd.c
diff -u src/external/bsd/wpa/dist/src/drivers/driver_bsd.c:1.18 src/external/bsd/wpa/dist/src/drivers/driver_bsd.c:1.19
--- src/external/bsd/wpa/dist/src/drivers/driver_bsd.c:1.18	Tue Jan 19 16:47:44 2016
+++ src/external/bsd/wpa/dist/src/drivers/driver_bsd.c	Tue Jan 19 17:22:57 2016
@@ -288,6 +288,7 @@ bsd_ctrl_iface(void *priv, int enable)
 			   strerror(errno));
 		return -1;
 	}
+	drv->flags = ifr.ifr_flags;
 
 	if (enable) {
 		if (ifr.ifr_flags & IFF_UP)
@@ -305,6 +306,7 @@ bsd_ctrl_iface(void *priv, int enable)
 		return -1;
 	}
 
+	drv->flags = ifr.ifr_flags;
 	return 0;
 }
 
@@ -1298,28 +1300,16 @@ wpa_driver_bsd_event_receive(int sock, v
 			return;
 		if ((ifm->ifm_flags & IFF_UP) == 0 &&
 		(drv->flags & IFF_UP) != 0) {
-			os_strlcpy(event.interface_status.ifname, drv->ifname,
-   sizeof(event.interface_status.ifname));
-			event.interface_status.ievent = EVENT_INTERFACE_REMOVED;
 			wpa_printf(MSG_DEBUG, "RTM_IFINFO: Interface '%s' DOWN",
-   event.interface_status.ifname);
-			wpa_supplicant_event(drv->ctx, EVENT_INTERFACE_STATUS,
-	 );
+   drv->ifname);
+			wpa_supplicant_event(drv->ctx, EVENT_INTERFACE_DISABLED,
+	 NULL);
 		} else if ((ifm->ifm_flags & IFF_UP) != 0 &&
 		(drv->flags & IFF_UP) == 0) {
-			os_strlcpy(event.interface_status.ifname, drv->ifname,
-sizeof(event.interface_status.ifname));
-			event.interface_status.ievent = EVENT_INTERFACE_ADDED;
 			wpa_printf(MSG_DEBUG, "RTM_IFINFO: Interface '%s' UP",
-   event.interface_status.ifname);
-			wpa_supplicant_event(drv->ctx, EVENT_INTERFACE_STATUS,
-	 );
-		} else {
-			os_strlcpy(event.interface_status.ifname, drv->ifname,
-sizeof(event.interface_status.ifname));
-			wpa_printf(MSG_DEBUG, "RTM_IFINFO: Interface '%s' "
-			"if=%x drv=%x", event.interface_status.ifname,
-			ifm->ifm_flags, drv->flags);
+   drv->ifname);
+			wpa_supplicant_event(drv->ctx, EVENT_INTERFACE_ENABLED,
+	 NULL);
 		}
 		drv->flags = ifm->ifm_flags;
 		break;



CVS commit: src/external/bsd/wpa/dist/src/drivers

2016-01-19 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Tue Jan 19 17:22:57 UTC 2016

Modified Files:
src/external/bsd/wpa/dist/src/drivers: driver_bsd.c

Log Message:
Downing the interface now disables it instead of removing it.


To generate a diff of this commit:
cvs rdiff -u -r1.18 -r1.19 src/external/bsd/wpa/dist/src/drivers/driver_bsd.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/external/bsd/wpa/dist/src/drivers

2016-01-14 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Thu Jan 14 21:19:41 UTC 2016

Modified Files:
src/external/bsd/wpa/dist/src/drivers: driver_bsd.c

Log Message:
Create global init to handle socket calls and route messages.
Register each interface inside the global driver so that
routing messages can find the interface based on rtm_ifindex.


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/external/bsd/wpa/dist/src/drivers/driver_bsd.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/external/bsd/wpa/dist/src/drivers/driver_bsd.c
diff -u src/external/bsd/wpa/dist/src/drivers/driver_bsd.c:1.11 src/external/bsd/wpa/dist/src/drivers/driver_bsd.c:1.12
--- src/external/bsd/wpa/dist/src/drivers/driver_bsd.c:1.11	Wed Apr  1 19:45:14 2015
+++ src/external/bsd/wpa/dist/src/drivers/driver_bsd.c	Thu Jan 14 21:19:41 2016
@@ -47,12 +47,20 @@
 
 #include "l2_packet/l2_packet.h"
 
+struct bsd_driver_global {
+	int		sock;			/* socket for 802.11 ioctls */
+	int		route;			/* routing socket for events */
+	char		*event_buf;
+	size_t		event_buf_len;
+	struct dl_list	ifaces;			/* list of interfaces */
+};
+
 struct bsd_driver_data {
+	struct dl_list	list;
+	struct bsd_driver_global *global;
 	struct hostapd_data *hapd;	/* back pointer */
 
-	int	sock;			/* open socket for 802.11 ioctls */
 	struct l2_packet_data *sock_xmit;/* raw packet xmit socket */
-	int	route;			/* routing socket for events */
 	char	ifname[IFNAMSIZ+1];	/* interface name */
 	int	flags;
 	unsigned int ifindex;		/* interface index */
@@ -63,12 +71,23 @@ struct bsd_driver_data {
 	int	prev_privacy;	/* privacy state to restore on deinit */
 	int	prev_wpa;	/* wpa state to restore on deinit */
 	enum ieee80211_opmode opmode;	/* operation mode */
-	char	*event_buf;
-	size_t	event_buf_len;
 };
 
 /* Generic functions for hostapd and wpa_supplicant */
 
+static struct bsd_driver_data *
+bsd_get_drvindex(void *priv, unsigned int ifindex)
+{
+	struct bsd_driver_global *global = priv;
+	struct bsd_driver_data *drv;
+
+	dl_list_for_each(drv, >ifaces, struct bsd_driver_data, list) {
+		if (drv->ifindex == ifindex)
+			return drv;
+	}
+	return NULL;
+}
+
 static int
 bsd_set80211(void *priv, int op, int val, const void *arg, int arg_len)
 {
@@ -82,7 +101,7 @@ bsd_set80211(void *priv, int op, int val
 	ireq.i_data = (void *) arg;
 	ireq.i_len = arg_len;
 
-	if (ioctl(drv->sock, SIOCS80211, ) < 0) {
+	if (ioctl(drv->global->sock, SIOCS80211, ) < 0) {
 		wpa_printf(MSG_ERROR, "ioctl[SIOCS80211, op=%u, val=%u, "
 			   "arg_len=%u]: %s", op, val, arg_len,
 			   strerror(errno));
@@ -103,7 +122,7 @@ bsd_get80211(void *priv, struct ieee8021
 	ireq->i_len = arg_len;
 	ireq->i_data = arg;
 
-	if (ioctl(drv->sock, SIOCG80211, ireq) < 0) {
+	if (ioctl(drv->global->sock, SIOCG80211, ireq) < 0) {
 		wpa_printf(MSG_ERROR, "ioctl[SIOCS80211, op=%u, "
 			   "arg_len=%u]: %s", op, arg_len, strerror(errno));
 		return -1;
@@ -144,7 +163,7 @@ bsd_get_ssid(void *priv, u8 *ssid, int l
 	os_memset(, 0, sizeof(ifr));
 	os_strlcpy(ifr.ifr_name, drv->ifname, sizeof(ifr.ifr_name));
 	ifr.ifr_data = (void *)
-	if (ioctl(drv->sock, SIOCG80211NWID, ) < 0 ||
+	if (ioctl(drv->global->sock, SIOCG80211NWID, ) < 0 ||
 	nwid.i_len > IEEE80211_NWID_LEN)
 		return -1;
 	os_memcpy(ssid, nwid.i_nwid, nwid.i_len);
@@ -167,7 +186,7 @@ bsd_set_ssid(void *priv, const u8 *ssid,
 	os_memset(, 0, sizeof(ifr));
 	os_strlcpy(ifr.ifr_name, drv->ifname, sizeof(ifr.ifr_name));
 	ifr.ifr_data = (void *)
-	return ioctl(drv->sock, SIOCS80211NWID, );
+	return ioctl(drv->global->sock, SIOCS80211NWID, );
 #else
 	return set80211var(drv, IEEE80211_IOC_SSID, ssid, ssid_len);
 #endif
@@ -182,7 +201,7 @@ bsd_get_if_media(void *priv)
 	os_memset(, 0, sizeof(ifmr));
 	os_strlcpy(ifmr.ifm_name, drv->ifname, sizeof(ifmr.ifm_name));
 
-	if (ioctl(drv->sock, SIOCGIFMEDIA, ) < 0) {
+	if (ioctl(drv->global->sock, SIOCGIFMEDIA, ) < 0) {
 		wpa_printf(MSG_ERROR, "%s: SIOCGIFMEDIA %s", __func__,
 			   strerror(errno));
 		return -1;
@@ -201,7 +220,7 @@ bsd_set_if_media(void *priv, int media)
 	os_strlcpy(ifr.ifr_name, drv->ifname, sizeof(ifr.ifr_name));
 	ifr.ifr_media = media;
 
-	if (ioctl(drv->sock, SIOCSIFMEDIA, ) < 0) {
+	if (ioctl(drv->global->sock, SIOCSIFMEDIA, ) < 0) {
 		wpa_printf(MSG_ERROR, "%s: SIOCSIFMEDIA %s", __func__,
 			   strerror(errno));
 		return -1;
@@ -264,7 +283,7 @@ bsd_ctrl_iface(void *priv, int enable)
 	os_memset(, 0, sizeof(ifr));
 	os_strlcpy(ifr.ifr_name, drv->ifname, sizeof(ifr.ifr_name));
 
-	if (ioctl(drv->sock, SIOCGIFFLAGS, ) < 0) {
+	if (ioctl(drv->global->sock, SIOCGIFFLAGS, ) < 0) {
 		wpa_printf(MSG_ERROR, "ioctl[SIOCGIFFLAGS]: %s",
 			   strerror(errno));
 		return -1;
@@ -280,7 +299,7 @@ bsd_ctrl_iface(void *priv, int enable)
 		ifr.ifr_flags &= ~IFF_UP;
 	}
 
-	if (ioctl(drv->sock, SIOCSIFFLAGS, ) < 0) {
+	if (ioctl(drv->global->sock, SIOCSIFFLAGS, ) < 0) {
 		

CVS commit: src/external/bsd/wpa/dist/src/drivers

2016-01-14 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Thu Jan 14 21:19:41 UTC 2016

Modified Files:
src/external/bsd/wpa/dist/src/drivers: driver_bsd.c

Log Message:
Create global init to handle socket calls and route messages.
Register each interface inside the global driver so that
routing messages can find the interface based on rtm_ifindex.


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/external/bsd/wpa/dist/src/drivers/driver_bsd.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/external/bsd/wpa/dist/src/drivers

2014-06-29 Thread Jonathan A. Kollasch
Module Name:src
Committed By:   jakllsch
Date:   Sun Jun 29 23:10:48 UTC 2014

Modified Files:
src/external/bsd/wpa/dist/src/drivers: driver_bsd.c

Log Message:
Pass the scan result RSSI to the WPA code in a way that it understands.


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/external/bsd/wpa/dist/src/drivers/driver_bsd.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/external/bsd/wpa/dist/src/drivers/driver_bsd.c
diff -u src/external/bsd/wpa/dist/src/drivers/driver_bsd.c:1.8 src/external/bsd/wpa/dist/src/drivers/driver_bsd.c:1.9
--- src/external/bsd/wpa/dist/src/drivers/driver_bsd.c:1.8	Wed May 28 14:36:41 2014
+++ src/external/bsd/wpa/dist/src/drivers/driver_bsd.c	Sun Jun 29 23:10:48 2014
@@ -1354,7 +1354,7 @@ wpa_driver_bsd_add_scan_entry(struct wpa
 	result-freq = sr-isr_freq;
 	result-beacon_int = sr-isr_intval;
 	result-caps = sr-isr_capinfo;
-	result-qual = sr-isr_rssi;
+	result-level = sr-isr_rssi;
 	result-noise = sr-isr_noise;
 
 	pos = (u8 *)(result + 1);



CVS commit: src/external/bsd/wpa/dist/src/drivers

2014-06-29 Thread Jonathan A. Kollasch
Module Name:src
Committed By:   jakllsch
Date:   Sun Jun 29 23:10:48 UTC 2014

Modified Files:
src/external/bsd/wpa/dist/src/drivers: driver_bsd.c

Log Message:
Pass the scan result RSSI to the WPA code in a way that it understands.


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/external/bsd/wpa/dist/src/drivers/driver_bsd.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/external/bsd/wpa/dist/src/drivers

2014-05-28 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed May 28 14:36:41 UTC 2014

Modified Files:
src/external/bsd/wpa/dist/src/drivers: driver_bsd.c

Log Message:
CID 272959: NULL deref


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/external/bsd/wpa/dist/src/drivers/driver_bsd.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/external/bsd/wpa/dist/src/drivers/driver_bsd.c
diff -u src/external/bsd/wpa/dist/src/drivers/driver_bsd.c:1.7 src/external/bsd/wpa/dist/src/drivers/driver_bsd.c:1.8
--- src/external/bsd/wpa/dist/src/drivers/driver_bsd.c:1.7	Thu Jan  2 21:08:17 2014
+++ src/external/bsd/wpa/dist/src/drivers/driver_bsd.c	Wed May 28 10:36:41 2014
@@ -853,12 +853,13 @@ bsd_init(struct hostapd_data *hapd, stru
 
 	return drv;
 bad:
-	if (drv-sock_xmit != NULL)
-		l2_packet_deinit(drv-sock_xmit);
-	if (drv-sock = 0)
-		close(drv-sock);
-	if (drv != NULL)
+	if (drv != NULL) {
+		if (drv-sock_xmit != NULL)
+			l2_packet_deinit(drv-sock_xmit);
+		if (drv-sock = 0)
+			close(drv-sock);
 		os_free(drv);
+	}
 	return NULL;
 }
 



CVS commit: src/external/bsd/wpa/dist/src/drivers

2014-05-28 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed May 28 14:36:41 UTC 2014

Modified Files:
src/external/bsd/wpa/dist/src/drivers: driver_bsd.c

Log Message:
CID 272959: NULL deref


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/external/bsd/wpa/dist/src/drivers/driver_bsd.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/external/bsd/wpa/dist/src/drivers

2012-05-13 Thread Takeshi Nakayama
Module Name:src
Committed By:   nakayama
Date:   Sun May 13 10:21:02 UTC 2012

Modified Files:
src/external/bsd/wpa/dist/src/drivers: driver_bsd.c

Log Message:
Make WPA works on big-endian machines.

Need byte swapping to copy seq to member ik_keyrsc.  The code is
borrowed from driver_madwifi.c.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/external/bsd/wpa/dist/src/drivers/driver_bsd.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/external/bsd/wpa/dist/src/drivers/driver_bsd.c
diff -u src/external/bsd/wpa/dist/src/drivers/driver_bsd.c:1.4 src/external/bsd/wpa/dist/src/drivers/driver_bsd.c:1.5
--- src/external/bsd/wpa/dist/src/drivers/driver_bsd.c:1.4	Sat Dec 25 20:45:49 2010
+++ src/external/bsd/wpa/dist/src/drivers/driver_bsd.c	Sun May 13 10:21:02 2012
@@ -347,7 +347,19 @@ bsd_set_key(const char *ifname, void *pr
 	if (wk.ik_keyix != IEEE80211_KEYIX_NONE  set_tx)
 		wk.ik_flags |= IEEE80211_KEY_DEFAULT;
 	wk.ik_keylen = key_len;
+#ifdef WORDS_BIGENDIAN
+#define WPA_KEY_RSC_LEN 8
+	{
+		size_t i;
+		u8 tmp[WPA_KEY_RSC_LEN];
+		os_memset(tmp, 0, sizeof(tmp));
+		for (i = 0; i  seq_len; i++)
+			tmp[WPA_KEY_RSC_LEN - i - 1] = seq[i];
+		os_memcpy(wk.ik_keyrsc, tmp, WPA_KEY_RSC_LEN);
+	}
+#else /* WORDS_BIGENDIAN */
 	os_memcpy(wk.ik_keyrsc, seq, seq_len);
+#endif /* WORDS_BIGENDIAN */
 	os_memcpy(wk.ik_keydata, key, key_len);
 
 	return set80211var(priv, IEEE80211_IOC_WPAKEY, wk, sizeof(wk));



CVS commit: src/external/bsd/wpa/dist/src/drivers

2012-05-13 Thread Takeshi Nakayama
Module Name:src
Committed By:   nakayama
Date:   Sun May 13 10:21:02 UTC 2012

Modified Files:
src/external/bsd/wpa/dist/src/drivers: driver_bsd.c

Log Message:
Make WPA works on big-endian machines.

Need byte swapping to copy seq to member ik_keyrsc.  The code is
borrowed from driver_madwifi.c.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/external/bsd/wpa/dist/src/drivers/driver_bsd.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/external/bsd/wpa/dist/src/drivers

2010-12-25 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sat Dec 25 20:45:50 UTC 2010

Modified Files:
src/external/bsd/wpa/dist/src/drivers: driver_bsd.c

Log Message:
fix debugging:
- don't print junk for the interface name
- parse and print known rtm messages we get


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/external/bsd/wpa/dist/src/drivers/driver_bsd.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/external/bsd/wpa/dist/src/drivers/driver_bsd.c
diff -u src/external/bsd/wpa/dist/src/drivers/driver_bsd.c:1.3 src/external/bsd/wpa/dist/src/drivers/driver_bsd.c:1.4
--- src/external/bsd/wpa/dist/src/drivers/driver_bsd.c:1.3	Thu Aug  5 10:03:17 2010
+++ src/external/bsd/wpa/dist/src/drivers/driver_bsd.c	Sat Dec 25 15:45:49 2010
@@ -1258,22 +1258,41 @@
 			wpa_supplicant_event(ctx, EVENT_INTERFACE_STATUS, event);
 		} else if ((ifm-ifm_flags  IFF_UP) != 0 
 		(drv-flags  IFF_UP) == 0) {
-			strlcpy(event.interface_status.ifname, drv-ifname,
+			os_strlcpy(event.interface_status.ifname, drv-ifname,
 sizeof(event.interface_status.ifname));
 			event.interface_status.ievent = EVENT_INTERFACE_ADDED;
 			wpa_printf(MSG_DEBUG, RTM_IFINFO: Interface '%s' UP,
    event.interface_status.ifname);
 			wpa_supplicant_event(ctx, EVENT_INTERFACE_STATUS, event);
 		} else {
+			os_strlcpy(event.interface_status.ifname, drv-ifname,
+sizeof(event.interface_status.ifname));
 			wpa_printf(MSG_DEBUG, RTM_IFINFO: Interface '%s' 
 			if=%x drv=%x, event.interface_status.ifname,
 			ifm-ifm_flags, drv-flags);
  		}
 		drv-flags = ifm-ifm_flags;
 		break;
+#ifdef RTM_OIFINFO
+	case RTM_OIFINFO:
+		wpa_printf(MSG_DEBUG, RTM_OIFINFO ignored);
+		break;
+#endif
+#ifdef RTM_OOIFINFO
+	case RTM_OOIFINFO:
+		wpa_printf(MSG_DEBUG, RTM_OOIFINFO ignored);
+		break;
+#endif
+#ifdef RTM_LOSING
 	case RTM_LOSING:
-		wpa_printf(MSG_DEBUG, RTM_LOSING: %d, rtm-rtm_type);
+		wpa_printf(MSG_DEBUG, RTM_LOSING ignored);
+		break;
+#endif
+#ifdef RTM_MISS
+	case RTM_MISS:
+		wpa_printf(MSG_DEBUG, RTM_MISS ignored);
 		break;
+#endif
 	default:
 		wpa_printf(MSG_DEBUG, RTM_???: %d, rtm-rtm_type);
 		break;



CVS commit: src/external/bsd/wpa/dist/src/drivers

2010-12-25 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sat Dec 25 20:45:50 UTC 2010

Modified Files:
src/external/bsd/wpa/dist/src/drivers: driver_bsd.c

Log Message:
fix debugging:
- don't print junk for the interface name
- parse and print known rtm messages we get


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/external/bsd/wpa/dist/src/drivers/driver_bsd.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/external/bsd/wpa/dist/src/drivers

2010-08-05 Thread Tom Spindler
Module Name:src
Committed By:   dogcow
Date:   Thu Aug  5 14:03:17 UTC 2010

Modified Files:
src/external/bsd/wpa/dist/src/drivers: driver_bsd.c

Log Message:
Fix build on big-endian hosts.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/external/bsd/wpa/dist/src/drivers/driver_bsd.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/external/bsd/wpa/dist/src/drivers/driver_bsd.c
diff -u src/external/bsd/wpa/dist/src/drivers/driver_bsd.c:1.2 src/external/bsd/wpa/dist/src/drivers/driver_bsd.c:1.3
--- src/external/bsd/wpa/dist/src/drivers/driver_bsd.c:1.2	Wed Aug  4 17:12:34 2010
+++ src/external/bsd/wpa/dist/src/drivers/driver_bsd.c	Thu Aug  5 14:03:17 2010
@@ -626,6 +626,9 @@
 	}
 
 #ifdef WORDS_BIGENDIAN
+#ifndef WPA_KEY_RSC_LEN
+#define WPA_KEY_RSC_LEN 8
+#endif
 	{
 		/*
 		 * wk.ik_keytsc is in host byte order (big endian), need to



CVS commit: src/external/bsd/wpa/dist/src/drivers

2010-08-05 Thread Tom Spindler
Module Name:src
Committed By:   dogcow
Date:   Thu Aug  5 14:03:17 UTC 2010

Modified Files:
src/external/bsd/wpa/dist/src/drivers: driver_bsd.c

Log Message:
Fix build on big-endian hosts.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/external/bsd/wpa/dist/src/drivers/driver_bsd.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.