Set TTL on SSDP Notify sockets (IPv4)

TTL is set to 2 (recommendation from UPnP Device Architecture v1.1)
This commit is contained in:
Thomas Bernard 2012-04-12 23:37:59 +02:00
parent 691c9d9947
commit 76da677016
2 changed files with 15 additions and 2 deletions

View File

@ -1,4 +1,8 @@
$Id: Changelog.txt,v 1.267 2012/04/06 17:24:36 nanard Exp $
$Id: Changelog.txt,v 1.268 2012/04/12 13:08:15 nanard Exp $
2012/04/12:
Set TTL on SSDP Notify sockets (IPv4). TTL is set to 2 (recommendation from
UPnP Device Architecture v1.1)
2012/04/06:
Implementing IPv6 support :

View File

@ -1,4 +1,4 @@
/* $Id: minissdp.c,v 1.32 2012/04/06 17:51:55 nanard Exp $ */
/* $Id: minissdp.c,v 1.33 2012/04/12 13:08:15 nanard Exp $ */
/* MiniUPnP project
* http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/
* (c) 2006-2012 Thomas Bernard
@ -170,6 +170,10 @@ OpenAndConfSSDPNotifySocket(in_addr_t addr)
int s;
unsigned char loopchar = 0;
int bcast = 1;
unsigned char ttl = 2; /* UDA v1.1 says :
The TTL for the IP packet SHOULD default to 2 and
SHOULD be configurable. */
/* TODO: Make TTL be configurable */
struct in_addr mc_if;
struct sockaddr_in sockname;
@ -195,6 +199,11 @@ OpenAndConfSSDPNotifySocket(in_addr_t addr)
return -1;
}
if(setsockopt(s, IPPROTO_IP, IP_MULTICAST_TTL, &ttl, sizeof(ttl)) < 0)
{
syslog(LOG_WARNING, "setsockopt(udp_notify, IP_MULTICAST_TTL,): %m");
}
if(setsockopt(s, SOL_SOCKET, SO_BROADCAST, &bcast, sizeof(bcast)) < 0)
{
syslog(LOG_ERR, "setsockopt(udp_notify, SO_BROADCAST): %m");