jacobschaer / python-doipclient

Pure Python ISO 13400 Client
MIT License
160 stars 52 forks source link

IPV6 can not supported #8

Closed Siogian closed 2 years ago

Siogian commented 2 years ago

IPV6 can not supported.

jacobschaer commented 2 years ago

It should be trivial to add IPV6 support, but I suspect the vast majority of ECU's in the wild are IPV4 only. If you have access to an ECU that supports IPV6 and can test, it's probably just a 3 line fix. You're welcome to make a PR.

MultiName90 commented 2 years ago

any know if son fork add the ipv6?

feuerball commented 2 years ago

quickfix (works for our ipv6 ecu):

change line 621 to self._tcp_sock = socket.socket(socket.AF_INET6, socket.SOCK_STREAM) change line 630 to self._udp_sock = socket.socket(socket.AF_INET6, socket.SOCK_DGRAM)

jacobschaer commented 2 years ago

Ok, yeah that was what I had in mind. Will need to either guess based on the string passed in or add another parameter to support both v4 and v6. But if it works for you that means it's at least a good idea.

jacobschaer commented 2 years ago

I imagine the vast majority of ECU's are Ipv4 and will be for many years, so probably just a toggle flag in the static methods and constructor to choose that defaults to v4.

MultiName90 commented 2 years ago

Actually there are 3 sites I found should change to use IPV6, the main problem I found so far to test is the ECU I'm using have a VLAN, so the announcement is not working, and for sure the rest of methods will not work.

If any have an method or idea how configure the socket to an VLAN I'm listening options

jacobschaer commented 2 years ago

What do you mean? vlan is normally not handled at the app level, it's at the OS level. You need to configure your routes properly. You can choose your src IP to bind to which lets you tell the OS which NIC to use in case it's ambiguous.

feuerball commented 2 years ago

you need to set your vlan id matching to the correspondend vlan in the network adapter

working solution might be an ipv4 vs ipv6 checker and then decide.

jacobschaer commented 2 years ago

https://github.com/jacobschaer/python-doipclient/pull/9

Have a look. I'll try it with an IPv4 ECU tomorrow, but unit tests passed.

feuerball commented 2 years ago

looks good :)

MultiName90 commented 2 years ago

you were rigth, there was no problem with the VLAN, looks is with the multicast add ff02::1, on UBUNTU its get the msg without problem, but on windows its not.

MultiName90 commented 2 years ago

On Windows its not read the multicast address ff02::1, and on Linux I have to bind the socket to the interface to recvfrom works

chobot1 commented 2 years ago

Hello, I would like just say you, that python-doipclient is good work :) We used it as a part of a student project at Czech technical university in Prague and we needed only to add IPv6 support. The rest worked like a charm. Before we finished pull request you already added IPv6 support ;) Thank you :)

MultiName90 commented 2 years ago

@chobot1 i have problems with the await_vehicle_announcement did you have a conde where its work well?

jacobschaer commented 2 years ago

@chobot1 - thanks! Have you had a chance to look at the branch for the multicast broadcast? Would be curious if that works any better.