Finish the two basic IPv4 address checks in pton_ntop.py - #399
I'm opening this issue to help out with #399
I will try to do my best with it. It seems like a pretty easy concept; verify the object can only be ipv4. Tons of ways to do this; re would seem the proper path.
Thoughts?
You probably don't want to use re here. The easiest way is probably to count (len()) the number of elements in part, then use enumerate() in the for statement and then you can check if you're processing the last part.
heyaa, im interested in helping with this issue i could split ip on . and count len() as p-l- suggested but is that the only thing ? validate if it has 4 octets ? wont check for restrict ip's and stuff ?
The goal is to accept formats from RFC5156:
- IPv4-Mapped Addresses:
::FFFF:0:0/96 - IPv4-Compatible Addresses:
::<ipv4-address>/96
That will be more than enough if you can implement it to get similar results as
[socket.inet_pton(socket.AF_INET6, ip6) for ip6 in ["::1.2.3.4", "::ffff:1.2.3.4"]]
Please don't forget to add unit tests.
been checking some stuff and you want the same result as [socket.inet_pton(socket.AF_INET6, ip6) for ip6 in ["::1.2.3.4", "::ffff:1.2.3.4"]] but when inet_pton is called but that if:else statment is a workaround which will disappear ?!
Hi @stryngs I was checking the code base of scapy, is this already implemented ? I can see in the pton_ntop.py there is a code to check for IPv4 and IPv6 address checks.
Hello @guedou, I have submitted a PR for this: #1555