inet:ip/1

Marthin Laubscher marthin@REDACTED
Thu Apr 13 00:45:03 CEST 2006


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>>"

ATB/Marthin

> -----Original Message-----
> From: owner-erlang-questions@REDACTED [mailto:owner-erlang-
> questions@REDACTED] On Behalf Of Serge Aleynikov
> Sent: 12 April 2006 23:47
> To: Per Hedeland; erlang-questions@REDACTED
> Subject: Re: inet:ip/1
> 
> Thanks for clarification.
> 
> Something not useful, yet we have to live with it.  Saidly, it makes
> validation of IP address entries quite difficult, as one cannot use
> inet:ip like functions to distinguish shorthand notations from errors.
> 
> BTW, Windows' telnet doesn't seem to recognize this shorthand form:
> 
> c:\>telnet 1.2.3
> Connecting To 1.2.3...
> 
> Serge
> 
> Per Hedeland wrote:
> > Serge Aleynikov <serge@REDACTED> wrote:
> >
> >>Moreover, the kernel/inet_parse.erl has the following comment for
> >>ipv4_address/1:
> >>
> >>%% Parse IPv4 address:
> >>%%    d1.d2.d3.d4
> >>%%    d1.d2.d4
> >>%%    d1.d4
> >>%%    d4
> >>%%
> >>%% Return {ok, IP} | {error, einval}
> >>
> >>I wonder what it was that authors were trying to accomplish.
> >
> >
> > It's the standard, is what it is:
> >
> > $ telnet 1.2.3
> > Trying 1.2.0.3...
> > ^C
> > $ telnet 1.2
> > Trying 1.0.0.2...
> >
> > Though admittedly an old and not very useful standard... See the section
> > INTERNET ADDRESSES on e.g.
> > http://www.freebsd.org/cgi/man.cgi?query=inet_aton for a description of
> > the logic, such as it is (feel free to ignore the part about the VAX:-).
> > The above commands are from a Linux box, i.e. it's not (Free)BSD-
> > specific, but of course the logic is not described in Linux man pages.
> >
> > --Per Hedeland







More information about the erlang-questions mailing list