Skip to content

Commit

Permalink
InterfaceMLD: Add error informations for sending (#5)
Browse files Browse the repository at this point in the history
Add concerned address and interface in the error message when encountering
'Network unreachable' (OSError 101)
  • Loading branch information
leoplo authored Jan 7, 2024
1 parent 48e391f commit eeb6baa
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion mld/InterfaceMLD.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,15 @@ def send(self, data: bytes, address: str = "FF02::1"):
cmsg_level = socket.IPPROTO_IPV6
cmsg_type = socket.IPV6_HOPOPTS
cmsg_data = b'\x3a\x00\x05\x02\x00\x00\x01\x00'
self._send_socket.sendmsg([data], [(cmsg_level, cmsg_type, cmsg_data)], 0, (address, 0))
try:
self._send_socket.sendmsg([data], [(cmsg_level, cmsg_type, cmsg_data)], 0, (address, 0))
except OSError as e:
if e.errno == 101:
raise OSError(
'No existing route to address %s for interface %s'
% (address, self.interface_name)
) from e
raise e

def _receive(self, raw_bytes, ancdata, src_addr):
if raw_bytes:
Expand Down

0 comments on commit eeb6baa

Please sign in to comment.