inet:ip/1

David Hopwood <>
Thu Apr 13 03:56:04 CEST 2006


Marthin Laubscher wrote:
> I don't believe it's a case of shorthand, 127.1 is the same thing as
> 127.0.0.1, which is why win telnet considers 127.1 as a legal address and
> reports in that manner. 
> 
> Try ping (incl. win) and you'll see more of what goes on
> 
> Ping 192.168.0.72   -> pinging 192.168.0.72
> Ping 192.168.72     -> pinging 192.168.0.72
> Ping 192.11010120   -> pinging 192.168.0.72
> Ping 323223559      -> pinging 192.168.0.72
> 
> Believing that the numbers in the dotted notation are "octets" will get you
> thinking that you can specify an ipv4 address in less than for octets, which
> isn't the case. It's always 4 octets. In the decimal, dotted string format
> we use, it can be specified in any one of the four formats equally (pseudo
> notation, don't try to parse this in Erlang".
> 
>   "<<A:8>>.<<B:8>>.<<C:8>>.<<D:8>>"
> =="<<A:8>>.<<B:8>>.<<C:16>>"
> =="<<A:8>>.<<B:24>>.
> =="<<A:32>>"

Note that you won't find this notation in any RFC, AFAIK. It's a Unix
(originally BSD) thing; not an IETF standard.

>From RFC 1020:

   One commonly used notation for internet host addresses divides the
   32-bit address into four 8-bit fields and specifies the value of each
   field as a decimal number with the fields separated by periods.  This
   is called the "dotted decimal" notation.  For example, the internet
   address of VENERA.ISI.EDU in dotted decimal is 010.001.000.052, or
   10.1.0.52.

(whereas inet_aton would interpret the components of 010.001.000.052 as
octal).

When IETF protocols make use of string representations of IP addresses,
they generally only specify the full dotted-decimal notation, without
shorthands, octal, or hexadecimal. For example, "http://192.168.0.72/" is
a valid URL, but "http://323223559/" isn't. Most browsers get this wrong,
because they (directly or indirectly) use inet_aton, and don't bother to
validate URLs properly. Personally, I think it's unfortunate that the APIs
of Erlang and some other recent languages are perpetuating this misfeature,
and would recommend stripping it out.

-- 
David Hopwood <>





More information about the erlang-questions mailing list