Skip to content

IPv6 does not work with link-local addresses #61

@maspiess

Description

@maspiess

The IPv6 implementation does work with "::1" but not with link-local addresses. For this to work I have replaced some lines in the client:

def _connect(self):
    """Helper to establish socket communication"""

    ipv6 = type(ipaddress.ip_address(self._ecu_ip_address)) == ipaddress.IPv6Address

    self._tcp_sock = socket.socket(self._address_family, socket.SOCK_STREAM)
    self._tcp_sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, True)
    self._tcp_sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, True)
    if self._client_ip_address is not None:
        if ipv6:
            ip_address, scope_id = self._client_ip_address.split("%")
            interface_index = socket.if_nametoindex(scope_id)
            self._tcp_sock.bind((ip_address, 0, 0, interface_index))
        else:
            self._tcp_sock.bind((self._client_ip_address, 0))

This works for me when called with a "...%..." address (same for UDP port), I'm not an expert on IPv6 though.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions