[PATCH 2/2] IAPP: Set IP_MULTICAST_LOOP on listening socket

Petko Bordjukov bordjukov at gmail.com
Tue Nov 10 10:17:14 PST 2015


Make it possible for hostapd instances listening on the same IP to see
eachother's messages.

Signed-off-by: Petko Bordjukov <bordjukov at gmail.com>
---
 src/ap/iapp.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/src/ap/iapp.c b/src/ap/iapp.c
index 61776d8..a568b03 100644
--- a/src/ap/iapp.c
+++ b/src/ap/iapp.c
@@ -386,6 +386,7 @@ struct iapp_data * iapp_init(struct hostapd_data *hapd, const char *iface)
 	struct iapp_data *iapp;
 	struct ip_mreqn mreq;
 	int reuseport = 1;
+	int multicast_loop = 1;
 
 	iapp = os_zalloc(sizeof(*iapp));
 	if (iapp == NULL)
@@ -477,6 +478,14 @@ struct iapp_data * iapp_init(struct hostapd_data *hapd, const char *iface)
 		return NULL;
 	}
 
+	if (setsockopt(iapp->udp_sock, IPPROTO_IP, IP_MULTICAST_LOOP, &multicast_loop,
+		       sizeof(multicast_loop)) < 0) {
+		wpa_printf(MSG_INFO, "iapp_init - setsockopt[UDP,IP_MULTICAST_LOOP]: %s",
+			   strerror(errno));
+		iapp_deinit(iapp);
+		return NULL;
+	}
+
 	iapp->packet_sock = socket(PF_PACKET, SOCK_RAW, htons(ETH_P_ALL));
 	if (iapp->packet_sock < 0) {
 		wpa_printf(MSG_INFO, "iapp_init - socket[PF_PACKET,SOCK_RAW]: %s",
-- 
2.6.2




More information about the Hostap mailing list