-
-
Notifications
You must be signed in to change notification settings - Fork 7k
DNSClient::inet_aton fix and new IPAddress::fromString method #3780
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
jhorck
commented
Sep 11, 2015
I proposed #2500. This fix looks good to me too, though I didn't test it.
I don't understand the comment "// TODO: add support for "a", "a.b", "a.b.c" formats"
IP addresses always have 4 bytes (IPv4). I hope fewer bytes are NEVER accepted as a valid IP address?
Build successful. Please test this code using one of the following:
http://downloads.arduino.cc/javaide/pull_requests/arduino-PR-3780-BUILD-393-linux32.tar.xz
http://downloads.arduino.cc/javaide/pull_requests/arduino-PR-3780-BUILD-393-linux64.tar.xz
http://downloads.arduino.cc/javaide/pull_requests/arduino-PR-3780-BUILD-393-windows.zip
http://downloads.arduino.cc/javaide/pull_requests/arduino-PR-3780-BUILD-393-macosx.zip
Hi @jhorck
thanks for the comment.
I don't understand the comment "// TODO: add support for "a", "a.b", "a.b.c" formats"
believe it or not you can specify the ip address using the following format:
A.A.A.A
A.A.B
A.C
D
where:
- A is an 8-bit unsigned
- B is a 16-bit unsigned
- C is a 24-bit unsigned
- D is a 32-bit unsigned
for example on my linux box I can do:
:~$ ping 2130706433
PING 2130706433 (127.0.0.1) 56(84) bytes of data.
64 bytes from 127.0.0.1: icmp_seq=1 ttl=64 time=0.056 ms
or better.
~$ ping 127.1
PING 127.1 (127.0.0.1) 56(84) bytes of data.
64 bytes from 127.0.0.1: icmp_seq=1 ttl=64 time=0.043 ms
I didn't know that until I looked to some implementations of inet_aton (for example http://www.comp.nus.edu.sg/~cs3223/doxygen-postgres9.4.0/html/dd/dbe/inet__aton_8c_source.html)
BTW it's a so rarely used feature that I guess we'll leave it unsupported.
jhorck
commented
Sep 11, 2015
@cmaglie, You're right! I didn't know that!
DNSClient::inet_aton
as reported in Bugfix DNSClient::getHostByName() #2500 (the solution proposed in Bugfix DNSClient::getHostByName() #2500 is only a partial fix)At this point
DNSClient::inet_aton
can be transformed to just an inline call toIPAddress::fromString
but this will make the Ethernet library incompatible with old cores, so the temporary compromise is that the code is duplicated until the new core becomes more widespread.