From 45f79fc53ff66a85085a0cde7d8f7d915a24f438 Mon Sep 17 00:00:00 2001 From: Emmanuel Blot Date: Sun, 12 Apr 2020 18:17:53 +0200 Subject: [PATCH] Fix socket's `bindtodevice` for Linux hosts --- pybootd/pxed.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pybootd/pxed.py b/pybootd/pxed.py index 352978e..94ba712 100644 --- a/pybootd/pxed.py +++ b/pybootd/pxed.py @@ -335,9 +335,9 @@ class BootpServer: raise BootpError('Unable to retrieve binding interface') if platform == 'linux': from socket import SO_BINDTODEVICE - sock.setsockopt(socket, SOL_SOCKET, SO_BINDTODEVICE, iface) + sock.setsockopt(SOL_SOCKET, SO_BINDTODEVICE, iface.encode()) elif platform == 'darwin': - IP_BOUND_IF = 25 + IP_BOUND_IF = 25 # unfortunately not mapped to Python sock.setsockopt(IPPROTO_IP, IP_BOUND_IF, if_nametoindex(iface)) else: raise BootpError('Bind to interface not supported on %s' %