aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPetko Bordjukov <bordjukov@gmail.com>2016-08-08 15:46:28 (GMT)
committerJouni Malinen <j@w1.fi>2016-08-18 17:01:48 (GMT)
commit72a652d785871ac49a035abd1886410068ced191 (patch)
tree1ead84133c7d80f5e27a2b98e6002cae08b15f51 /src
parent9d5d1c5dd2ba9e470de5d6ab70d35119f76c8ff2 (diff)
downloadhostap-72a652d785871ac49a035abd1886410068ced191.zip
hostap-72a652d785871ac49a035abd1886410068ced191.tar.gz
hostap-72a652d785871ac49a035abd1886410068ced191.tar.bz2
IAPP: Set SO_REUSEADDR on listening socket
Make it possible for several instances of hostapd to listen on the same network interface. Signed-off-by: Petko Bordjukov <bordjukov@gmail.com>
Diffstat (limited to 'src')
-rw-r--r--src/ap/iapp.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/ap/iapp.c b/src/ap/iapp.c
index 07672ce..2556da3 100644
--- a/src/ap/iapp.c
+++ b/src/ap/iapp.c
@@ -381,6 +381,7 @@ struct iapp_data * iapp_init(struct hostapd_data *hapd, const char *iface)
struct sockaddr_in *paddr, uaddr;
struct iapp_data *iapp;
struct ip_mreqn mreq;
+ int reuseaddr = 1;
iapp = os_zalloc(sizeof(*iapp));
if (iapp == NULL)
@@ -443,6 +444,18 @@ struct iapp_data * iapp_init(struct hostapd_data *hapd, const char *iface)
os_memset(&uaddr, 0, sizeof(uaddr));
uaddr.sin_family = AF_INET;
uaddr.sin_port = htons(IAPP_UDP_PORT);
+
+ if (setsockopt(iapp->udp_sock, SOL_SOCKET, SO_REUSEADDR, &reuseaddr,
+ sizeof(reuseaddr)) < 0) {
+ wpa_printf(MSG_INFO,
+ "iapp_init - setsockopt[UDP,SO_REUSEADDR]: %s",
+ strerror(errno));
+ /*
+ * Ignore this and try to continue. This is fine for single
+ * BSS cases, but may fail if multiple BSSes enable IAPP.
+ */
+ }
+
if (bind(iapp->udp_sock, (struct sockaddr *) &uaddr,
sizeof(uaddr)) < 0) {
wpa_printf(MSG_INFO, "iapp_init - bind[UDP]: %s",