2 ms·
There's some weird legacy parsing for IPv4 addresses with less than four components. 1.2.3.4 can be represented equivalently as 1.2.772, 1.131844, or 16909060.
by duskwuff 4y ago
There's some weird legacy parsing for IPv4 addresses with less than four components. 1.2.3.4 can be represented equivalently as 1.2.772, 1.131844, or 16909060. (Note that 772 = 0x0304, 131844 = 0x020304, and 16909060 = 0x01020304.)
TL;DR: the second "1" in "1.1" is treated as a 24-bit integer.
Longer explanation: https://blog.dave.tf/post/ip-addr-parsing/ https://blog.dave.tf/post/ip-addr-parsing/
- derefr 4y agoAha. I had thought I recalled the two-dot case being 16+16, rather than 8+24.
- duskwuff 4y agoIt was for compatibility with classful networks. If you have a class A (/8) network, you could (in principle) treat it as a single network and number all the machines on it sequentially from 12.1 to 12.16777215. Of course, nobody actually does that anymore. But the parser behavior is still out there because there's the possibility that someone is still using it...