Browse Source

mptsd can support unicast source

wing_pn 7 years ago
parent
commit
a96815871b
1 changed files with 16 additions and 10 deletions
  1. 16
    10
      network.c

+ 16
- 10
network.c View File

202
 		}
202
 		}
203
 		// connected ok, continue
203
 		// connected ok, continue
204
 	} else {
204
 	} else {
205
-		if (!IN_MULTICAST(ntohl(r->src_sockname.sin_addr.s_addr))) {
206
-			LOGf("ERR  : %s is not multicast address\n", r->channel->source);
207
-			FATAL_ERROR;
208
-		}
205
+
206
+		char multicast = IN_MULTICAST(ntohl(r->src_sockname.sin_addr.s_addr));
207
+		
208
+		//if (!IN_MULTICAST(ntohl(r->src_sockname.sin_addr.s_addr))) {
209
+		//	LOGf("ERR  : %s is not multicast address\n", r->channel->source);
210
+		//	FATAL_ERROR;
211
+		//}
209
 		struct ip_mreq mreq;
212
 		struct ip_mreq mreq;
210
 		struct sockaddr_in receiving_from;
213
 		struct sockaddr_in receiving_from;
211
 
214
 
217
 		// LOGf("CONN : Listening on multicast socket %s srv_fd: %i retries left: %i\n", r->channel->source, r->sock, retries);
220
 		// LOGf("CONN : Listening on multicast socket %s srv_fd: %i retries left: %i\n", r->channel->source, r->sock, retries);
218
 		int on = 1;
221
 		int on = 1;
219
 		setsockopt(r->sock, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on));
222
 		setsockopt(r->sock, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on));
220
-		// subscribe to multicast group
221
-		memcpy(&mreq.imr_multiaddr, &(r->src_sockname.sin_addr), sizeof(struct in_addr));
222
-		mreq.imr_interface.s_addr = htonl(INADDR_ANY);
223
-		if (setsockopt(r->sock, IPPROTO_IP, IP_ADD_MEMBERSHIP, &mreq, sizeof(mreq)) < 0) {
224
-			LOGf("ERR  : Failed to add IP membership on %s srv_fd: %i\n", r->channel->source, r->sock);
225
-			FATAL_ERROR;
223
+		
224
+		if (multicast)  {
225
+    		// subscribe to multicast group
226
+    		memcpy(&mreq.imr_multiaddr, &(r->src_sockname.sin_addr), sizeof(struct in_addr));
227
+    		mreq.imr_interface.s_addr = htonl(INADDR_ANY);
228
+    		if (setsockopt(r->sock, IPPROTO_IP, IP_ADD_MEMBERSHIP, &mreq, sizeof(mreq)) < 0) {
229
+    			LOGf("ERR  : Failed to add IP membership on %s srv_fd: %i\n", r->channel->source, r->sock);
230
+    			FATAL_ERROR;
231
+    		}
226
 		}
232
 		}
227
 		// bind to the socket so data can be read
233
 		// bind to the socket so data can be read
228
 		memset(&receiving_from, 0, sizeof(receiving_from));
234
 		memset(&receiving_from, 0, sizeof(receiving_from));

Loading…
Cancel
Save