aboutsummaryrefslogtreecommitdiffstats
path: root/src/drivers/driver_bsd.c
diff options
context:
space:
mode:
authorRoy Marples <roy@marples.name>2019-09-18 11:50:36 (GMT)
committerJouni Malinen <j@w1.fi>2019-09-19 09:16:49 (GMT)
commita3ebf71751ea50a18ff937e609cc3c987d36f389 (patch)
tree699022caefa1d8126b0dfb3f20d8062538a6e9aa /src/drivers/driver_bsd.c
parentc532abb158173aa11c97fcd66b2de3a0b971d044 (diff)
downloadhostap-a3ebf71751ea50a18ff937e609cc3c987d36f389.zip
hostap-a3ebf71751ea50a18ff937e609cc3c987d36f389.tar.gz
hostap-a3ebf71751ea50a18ff937e609cc3c987d36f389.tar.bz2
BSD: Add support for route(4) message filtering
hostapd is only interested in RTM_IEEE80211. wpa_supplicant is only interested in RTM_IEEE80211, RTM_IFINFO and RTM_IFANNOUNCE. This supports the NetBSD RO_MSGFILTER interface and the alternative DragonFlyBSD/OpenBSD interface ROUTE_MSGFILTER. Signed-off-by: Roy Marples <roy@marples.name>
Diffstat (limited to 'src/drivers/driver_bsd.c')
-rw-r--r--src/drivers/driver_bsd.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/drivers/driver_bsd.c b/src/drivers/driver_bsd.c
index 82ca061..8667ee5 100644
--- a/src/drivers/driver_bsd.c
+++ b/src/drivers/driver_bsd.c
@@ -1661,6 +1661,17 @@ static void *
bsd_global_init(void *ctx)
{
struct bsd_driver_global *global;
+#if defined(RO_MSGFILTER) || defined(ROUTE_MSGFILTER)
+ unsigned char msgfilter[] = {
+ RTM_IEEE80211,
+#ifndef HOSTAPD
+ RTM_IFINFO, RTM_IFANNOUNCE,
+#endif
+ };
+#endif
+#ifdef ROUTE_MSGFILTER
+ unsigned int i, msgfilter_mask;
+#endif
global = os_zalloc(sizeof(*global));
if (global == NULL)
@@ -1683,6 +1694,21 @@ bsd_global_init(void *ctx)
goto fail;
}
+#if defined(RO_MSGFILTER)
+ if (setsockopt(global->route, PF_ROUTE, RO_MSGFILTER,
+ &msgfilter, sizeof(msgfilter)) < 0)
+ wpa_printf(MSG_ERROR, "socket[PF_ROUTE,RO_MSGFILTER]: %s",
+ strerror(errno));
+#elif defined(ROUTE_MSGFILTER)
+ msgfilter_mask = 0;
+ for (i = 0; i < (sizeof(msgfilter) / sizeof(msgfilter[0])); i++)
+ msgfilter_mask |= ROUTE_FILTER(msgfilter[i]);
+ if (setsockopt(global->route, PF_ROUTE, ROUTE_MSGFILTER,
+ &msgfilter_mask, sizeof(msgfilter_mask)) < 0)
+ wpa_printf(MSG_ERROR, "socket[PF_ROUTE,ROUTE_MSGFILTER]: %s",
+ strerror(errno));
+#endif
+
global->event_buf_len = rtbuf_len();
global->event_buf = os_malloc(global->event_buf_len);
if (global->event_buf == NULL) {