set IPv6 Hop limit to 10

This commit is contained in:
Thomas Bernard 2016-02-19 14:20:31 +01:00
parent fd82e4c2d9
commit 984a6f144e
1 changed files with 10 additions and 1 deletions

View File

@ -1,7 +1,7 @@
/* $Id: minissdp.c,v 1.77 2015/08/26 07:36:52 nanard Exp $ */
/* MiniUPnP project
* http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/
* (c) 2006-2015 Thomas Bernard
* (c) 2006-2016 Thomas Bernard
* This software is subject to the conditions detailed
* in the LICENCE file provided within the distribution */
@ -296,6 +296,9 @@ OpenAndConfSSDPNotifySocketIPv6(unsigned int if_index)
{
int s;
unsigned int loop = 0;
/* UDA 2.0 : The hop limit of each IP packet for a Site-Local scope
* multicast message SHALL be configurable and SHOULD default to 10 */
int hop_limit = 10;
struct sockaddr_in6 sockname;
s = socket(PF_INET6, SOCK_DGRAM, 0);
@ -316,6 +319,12 @@ OpenAndConfSSDPNotifySocketIPv6(unsigned int if_index)
close(s);
return -1;
}
if(setsockopt(s, IPPROTO_IPV6, IPV6_MULTICAST_HOPS, &hop_limit, sizeof(hop_limit)) < 0)
{
syslog(LOG_ERR, "setsockopt(udp_notify, IPV6_MULTICAST_HOPS): %m");
close(s);
return -1;
}
/* bind() socket before using sendto() is not mandatory
* (sendto() will implicitly bind the socket when called on