diff mbox

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

Message ID 1447179434-18596-2-git-send-email-bordjukov@gmail.com
State Rejected
Headers show

Commit Message

Petko Bordjukov Nov. 10, 2015, 6:17 p.m. UTC
Make it possible for hostapd instances listening on the same IP to see
eachother's messages.

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

Comments

michael-dev Nov. 10, 2015, 9:43 p.m. UTC | #1
Am 10.11.2015 um 19:17 schrieb Petko Bordjukov:
> Make it possible for hostapd instances listening on the same IP to see
> eachother's messages.

Isn't IP_MULTICAST_LOOP enabled by default?

Regards,
 M. Braun
Petko Bordjukov Nov. 11, 2015, 10:39 a.m. UTC | #2
Yes, it is. Patch 2/2 is unnecessary.


On вт, 2015-11-10 at 22:43 +0100, M. Braun wrote:
> Am 10.11.2015 um 19:17 schrieb Petko Bordjukov:
> > Make it possible for hostapd instances listening on the same IP to
> > see
> > eachother's messages.
> 
> Isn't IP_MULTICAST_LOOP enabled by default?
> 
> Regards,
>  M. Braun
>
diff mbox

Patch

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",