IPアドレスの表記法
072なので8進かなと思ったらその通りだった。省略記法についてはどこかで読んだことがあったな。
これはPOSIXのinet_addr/inet_atopの仕様によるもので、
Values specified using IPv4 dotted decimal notation take one of the following forms:
(略)
a.b.c
When a three-part address is specified, the last part shall be interpreted as a 16-bit quantity and placed in the rightmost two bytes of the network address. This makes the three-part address format convenient for specifying Class B network addresses as "128.net.host".
で、192.168.072→192.168.0.072となり、
All numbers supplied as parts in IPv4 dotted decimal notation may be decimal, octal, or hexadecimal, as specified in the ISO C standard (that is, a leading 0x or 0X implies hexadecimal; otherwise, a leading '0' implies octal; otherwise, the number is interpreted as decimal).
で、192.168.0.58となる。
ここらへんRFC 791には見当たらなかったので、どこまで共通認識なのかはよくわからない。しかし、Windowsのpingは同様の処理になる。
しかし、ipv6に対応したinet_ptonではこのような処理は行われなくなるらしい。
where "ddd" is a one to three digit decimal number between 0 and 255 (see inet_addr()). The inet_pton() function does not accept other formats (such as the octal numbers, hexadecimal numbers, and fewer than four numbers that inet_addr() accepts).
inet_ntop