[Python-modules-commits] [python-zeroconf] 01/08: Fix multicast TTL and LOOP options on OpenBSD

Ruben Undheim rubund-guest at moszumanska.debian.org
Wed Apr 13 19:10:13 UTC 2016


This is an automated email from the git hooks/post-receive script.

rubund-guest pushed a commit to branch upstream
in repository python-zeroconf.

commit 0f46a0609931e6dc299c0473312e434e84abe7b0
Author: Alessio Sergi <al3hex at gmail.com>
Date:   Sun Nov 29 09:29:29 2015 +0100

    Fix multicast TTL and LOOP options on OpenBSD
    
    IP_MULTICAST_TTL and IP_MULTICAST_LOOP socket options on OpenBSD don't
    accept int, only unsigned char. Otherwise you will get an error:
    [Errno 22] Invalid argument.
---
 zeroconf.py | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/zeroconf.py b/zeroconf.py
index 2d67563..bf2402e 100644
--- a/zeroconf.py
+++ b/zeroconf.py
@@ -1308,8 +1308,12 @@ def new_socket():
             if not err.errno == errno.ENOPROTOOPT:
                 raise
 
-    s.setsockopt(socket.IPPROTO_IP, socket.IP_MULTICAST_TTL, 255)
-    s.setsockopt(socket.IPPROTO_IP, socket.IP_MULTICAST_LOOP, 1)
+    # OpenBSD needs the ttl and loop values for the IP_MULTICAST_TTL and
+    # IP_MULTICAST_LOOP socket options as an unsigned char.
+    ttl = struct.pack(b'B', 255)
+    s.setsockopt(socket.IPPROTO_IP, socket.IP_MULTICAST_TTL, ttl)
+    loop = struct.pack(b'B', 1)
+    s.setsockopt(socket.IPPROTO_IP, socket.IP_MULTICAST_LOOP, loop)
 
     s.bind(('', _MDNS_PORT))
     return s

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/python-modules/packages/python-zeroconf.git



More information about the Python-modules-commits mailing list