minissdpd: revert "listen on only 1 IPv4 if only 1 interface is specified"

because it prevents broadcast messages to be received
see 7ec7cec59e
and 6d379d54f5
This commit is contained in:
Thomas Bernard 2014-11-28 15:50:06 +01:00
parent 3665f1913d
commit 186c504070
3 changed files with 15 additions and 1 deletions

View File

@ -1,5 +1,9 @@
$Id: Changelog.txt,v 1.36 2014/11/06 10:13:36 nanard Exp $ $Id: Changelog.txt,v 1.36 2014/11/06 10:13:36 nanard Exp $
2014/11/28:
revert "listen on only 1 IPv4 if only 1 interface is specified"
because it prevents broadcast messages to be received
2014/11/06: 2014/11/06:
listen on only 1 IPv4 if only 1 interface is specified listen on only 1 IPv4 if only 1 interface is specified
also when ENABLE_IPV6 is not defined also when ENABLE_IPV6 is not defined

View File

@ -1,4 +1,4 @@
/* $Id: config.h,v 1.4 2011/05/23 12:22:29 nanard Exp $ */ /* $Id: config.h,v 1.6 2012/09/27 15:40:29 nanard Exp $ */
/* MiniUPnP project /* MiniUPnP project
* http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/ * http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/
* (c) 2006-2011 Thomas Bernard * (c) 2006-2011 Thomas Bernard
@ -19,4 +19,10 @@
/* Maximum number of network interface we can listen on */ /* Maximum number of network interface we can listen on */
#define MAX_IF_ADDR 8 #define MAX_IF_ADDR 8
/* Uncomment the following line in order to make minissdpd
* listen on 1.2.3.4:1900 instead of *:1900
* Note : it prevents broadcast packets to be received,
* at least with linux */
/*#define SSDP_LISTEN_ON_SPECIFIC_ADDR*/
#endif #endif

View File

@ -195,6 +195,7 @@ OpenAndConfSSDPReceiveSocket(int n_listen_addr,
struct sockaddr_in * sa = (struct sockaddr_in *)&sockname; struct sockaddr_in * sa = (struct sockaddr_in *)&sockname;
sa->sin_family = AF_INET; sa->sin_family = AF_INET;
sa->sin_port = htons(SSDP_PORT); sa->sin_port = htons(SSDP_PORT);
#ifdef SSDP_LISTEN_ON_SPECIFIC_ADDR
if(n_listen_addr == 1) if(n_listen_addr == 1)
{ {
sa->sin_addr.s_addr = GetIfAddrIPv4(listen_addr[0]); sa->sin_addr.s_addr = GetIfAddrIPv4(listen_addr[0]);
@ -207,6 +208,7 @@ OpenAndConfSSDPReceiveSocket(int n_listen_addr,
} }
} }
else else
#endif /* SSDP_LISTEN_ON_SPECIFIC_ADDR */
sa->sin_addr.s_addr = htonl(INADDR_ANY); sa->sin_addr.s_addr = htonl(INADDR_ANY);
sockname_len = sizeof(struct sockaddr_in); sockname_len = sizeof(struct sockaddr_in);
} }
@ -214,6 +216,7 @@ OpenAndConfSSDPReceiveSocket(int n_listen_addr,
memset(&sockname, 0, sizeof(struct sockaddr_in)); memset(&sockname, 0, sizeof(struct sockaddr_in));
sockname.sin_family = AF_INET; sockname.sin_family = AF_INET;
sockname.sin_port = htons(SSDP_PORT); sockname.sin_port = htons(SSDP_PORT);
#ifdef SSDP_LISTEN_ON_SPECIFIC_ADDR
if(n_listen_addr == 1) if(n_listen_addr == 1)
{ {
sockname.sin_addr.s_addr = GetIfAddrIPv4(listen_addr[0]); sockname.sin_addr.s_addr = GetIfAddrIPv4(listen_addr[0]);
@ -226,6 +229,7 @@ OpenAndConfSSDPReceiveSocket(int n_listen_addr,
} }
} }
else else
#endif /* SSDP_LISTEN_ON_SPECIFIC_ADDR */
sockname.sin_addr.s_addr = htonl(INADDR_ANY); sockname.sin_addr.s_addr = htonl(INADDR_ANY);
sockname_len = sizeof(struct sockaddr_in); sockname_len = sizeof(struct sockaddr_in);
#endif /* ENABLE_IPV6 */ #endif /* ENABLE_IPV6 */