Set TTL to 255 for outgoing IPv4 unicast packets
[project/mdnsd.git] / interface.c
index 587b188..76820c7 100644 (file)
@@ -389,6 +389,7 @@ static void
 reconnect_socket4(struct uloop_timeout *timeout)
 {
        struct interface *iface = container_of(timeout, struct interface, reconnect);
+       int ttl = 255;
        int yes = 1;
 
        iface->fd.fd = usock(USOCK_UDP | USOCK_SERVER | USOCK_NONBLOCK | USOCK_IPV4ONLY,
@@ -404,6 +405,9 @@ reconnect_socket4(struct uloop_timeout *timeout)
        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");