@@ -77,7 +77,8 @@ bool mockUDPListen (int sock, uint32_t dstaddr, uint16_t port, uint32_t mcast)
77
77
// Filling server information
78
78
servaddr.sin_family = AF_INET;
79
79
(void ) dstaddr;
80
- servaddr.sin_addr .s_addr = htonl (global_source_address);
80
+ // servaddr.sin_addr.s_addr = htonl(global_source_address);
81
+ servaddr.sin_addr .s_addr = htonl (INADDR_ANY);
81
82
servaddr.sin_port = htons (mockport);
82
83
83
84
// Bind the socket with the server address
@@ -89,15 +90,19 @@ bool mockUDPListen (int sock, uint32_t dstaddr, uint16_t port, uint32_t mcast)
89
90
else
90
91
mockverbose (" UDP server on port %d (sock=%d)\n " , mockport, sock);
91
92
93
+ if (!mcast)
94
+ mcast = inet_addr (" 224.0.0.1" ); // all hosts group
92
95
if (mcast)
93
96
{
94
97
// https://web.cs.wpi.edu/~claypool/courses/4514-B99/samples/multicast.c
95
98
// https://stackoverflow.com/questions/12681097/c-choose-interface-for-udp-multicast-socket
96
99
97
100
struct ip_mreq mreq;
98
101
mreq.imr_multiaddr .s_addr = mcast;
99
- mreq.imr_interface .s_addr = htonl (global_source_address);
100
- if (global_ipv4_netfmt)
102
+ // mreq.imr_interface.s_addr = htonl(global_source_address);
103
+ mreq.imr_interface .s_addr = htonl (INADDR_ANY);
104
+
105
+ if (host_interface)
101
106
{
102
107
#if __APPLE__
103
108
int idx = if_nametoindex (host_interface);
@@ -115,6 +120,8 @@ bool mockUDPListen (int sock, uint32_t dstaddr, uint16_t port, uint32_t mcast)
115
120
fprintf (stderr, MOCK " can't join multicast group addr %08x\n " , (int )mcast);
116
121
return false ;
117
122
}
123
+ else
124
+ mockverbose (" joined multicast group addr %08lx\n " , ntohl (mcast));
118
125
}
119
126
120
127
return true ;
0 commit comments