minissdpd/openssdpsocket.c: listen on only 1 IPv4 if only 1 interface is specified

This commit is contained in:
Thomas Bernard 2014-05-02 09:52:43 +02:00
parent 69dac1ef50
commit 6d379d54f5
2 changed files with 17 additions and 2 deletions

View File

@ -1,4 +1,7 @@
$Id: Changelog.txt,v 1.33 2014/02/03 15:45:07 nanard Exp $
$Id: Changelog.txt,v 1.34 2014/05/01 21:05:14 nanard Exp $
2014/05/01:
listen on only 1 IPv4 if only 1 interface is specified
2014/02/03:
silently ignore EAGAIN, EWOULDBLOCK, EINTR of recv calls

View File

@ -192,7 +192,19 @@ OpenAndConfSSDPReceiveSocket(int n_listen_addr,
struct sockaddr_in * sa = (struct sockaddr_in *)&sockname;
sa->sin_family = AF_INET;
sa->sin_port = htons(SSDP_PORT);
sa->sin_addr.s_addr = htonl(INADDR_ANY);
if(n_listen_addr == 1)
{
sa->sin_addr.s_addr = GetIfAddrIPv4(listen_addr[0]);
if(sa->sin_addr.s_addr == INADDR_NONE)
{
syslog(LOG_ERR, "no IPv4 address for interface %s",
listen_addr[0]);
close(s);
return -1;
}
}
else
sa->sin_addr.s_addr = htonl(INADDR_ANY);
sockname_len = sizeof(struct sockaddr_in);
}
#else