On Fri, 2005-12-09 at 11:50 +0100, Jakob Hirsch wrote:
> The dotted notation is a standard way to represent IPv4 addresses (which
> are simply 32bit values). If there are less than 4 numbers, the notation
> is disambigious, as long as there is no clear standard how it has to be
> done. TTBOMK, there is none, but I'll be happy to stand corrected if you
> can show me one.
inet_addr has always behaved like this, and POSIX documents it:
============================================================
All Internet addresses shall be returned in network order (bytes
ordered from left to right).
Values specified using IPv4 dotted decimal notation take one of
the following forms:
a.b.c.d
When four parts are specified, each shall be interpreted
as a byte of data and assigned, from left to right, to
the four bytes of an Internet address.
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".
a.b
When a two-part address is supplied, the last part shall
be interpreted as a 24-bit quantity and placed in the
rightmost three bytes of the network address. This makes
the two-part address format convenient for specifying
Class A network addresses as "net.host".
a
When only one part is given, the value shall be stored
directly in the network address without any byte
rearrangement.
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).
============================================================
I would give you a direct link, but I think I would expose and make
available my (free) registration at
http://www.unix.org/single_unix_specification/
in particular the "a" form is a popular way of obfuscating IP-addresses
for phishers. try "ping 0x81f00a09".
--
Kjetil T.