From 76da6770169053d6ad79b16d1b2a4481c3e49051 Mon Sep 17 00:00:00 2001 From: Thomas Bernard Date: Thu, 12 Apr 2012 23:37:59 +0200 Subject: [PATCH] Set TTL on SSDP Notify sockets (IPv4) TTL is set to 2 (recommendation from UPnP Device Architecture v1.1) --- miniupnpd/Changelog.txt | 6 +++++- miniupnpd/minissdp.c | 11 ++++++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/miniupnpd/Changelog.txt b/miniupnpd/Changelog.txt index 77011fd..9789e60 100644 --- a/miniupnpd/Changelog.txt +++ b/miniupnpd/Changelog.txt @@ -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 : diff --git a/miniupnpd/minissdp.c b/miniupnpd/minissdp.c index 091ddd4..64ada70 100644 --- a/miniupnpd/minissdp.c +++ b/miniupnpd/minissdp.c @@ -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");