1) We SHOULD do this according to the RFC 6762 (Section 11, "Source
Address Check").
2) We already do it for IPv6 unicast and both multicast interfaces
3) When receiving IPv4 packet we ignore it if TTL doesn't equal 255
In other words this is a requirement for working unicast communication
between 2 umdns instances (which doesn't seem to work yet though).
Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
Acked-by: John Crispin <john@phrozen.org>
reconnect_socket4(struct uloop_timeout *timeout)
{
struct interface *iface = container_of(timeout, struct interface, reconnect);
reconnect_socket4(struct uloop_timeout *timeout)
{
struct interface *iface = container_of(timeout, struct interface, reconnect);
int yes = 1;
iface->fd.fd = usock(USOCK_UDP | USOCK_SERVER | USOCK_NONBLOCK | USOCK_IPV4ONLY,
int yes = 1;
iface->fd.fd = usock(USOCK_UDP | USOCK_SERVER | USOCK_NONBLOCK | USOCK_IPV4ONLY,
if (setsockopt(iface->fd.fd, SOL_SOCKET, SO_REUSEADDR, &yes, sizeof(yes)) < 0)
fprintf(stderr, "ioctl failed: SO_REUSEADDR\n");
if (setsockopt(iface->fd.fd, SOL_SOCKET, SO_REUSEADDR, &yes, sizeof(yes)) < 0)
fprintf(stderr, "ioctl failed: SO_REUSEADDR\n");
+ if (setsockopt(iface->fd.fd, IPPROTO_IP, IP_TTL, &ttl, sizeof(ttl)) < 0)
+ fprintf(stderr, "ioctl failed: IP_TTL\n");
+
if (setsockopt(iface->fd.fd, IPPROTO_IP, IP_RECVTTL, &yes, sizeof(yes)) < 0)
fprintf(stderr, "ioctl failed: IP_RECVTTL\n");
if (setsockopt(iface->fd.fd, IPPROTO_IP, IP_RECVTTL, &yes, sizeof(yes)) < 0)
fprintf(stderr, "ioctl failed: IP_RECVTTL\n");