[arin-tech-discuss] zero-padded IP addresses in "startAddress" and "endAddress" values

Jimmy Hess mysidia at gmail.com
Thu Mar 29 23:20:09 EDT 2012

On Thu, Mar 29, 2012 at 8:56 AM, Andy Newton <andy at arin.net> wrote:

I would say that ad-hoc textual representation is dangerous when
presented in an API for remote use,  because it visually _resembles_
an IP so closely that it may confuse a human into thinking it is a
valid IP address,   but  the leading zeros make it non-compliant with
the standard representation of an IP address;   the result is
ill-defined, and the octal interpretation is very common.

The leading zeros make the IP addresses unparseable by standard APIs.
I'll give you a  "padded" string has its uses,  but that should be the
responsibility of the application,
and it makes sense to omit the dots in that case to avoid any confusion.

Interoperability with applications utilizing standard APIs should also
be preferred over supporting hacks to facilitate programming in
languages that lack them.

Remote interfaces should utilize the standard representation of IP
addresses,  either the standard textual representation of an IP
address,   or an  internal format that won't likely lead to confusion
or errors, such as the decimal IP address in network byte order.

The  "zero padding"  is non-standard  and    results in something that
cannot be parsed so well with standard APIs for interpreting IP

For example,
   ""   actually  indicates the IP address ""

[root at orb1 ~ ]# ping -c 5
PING ( 56(84) bytes of data.

cat <<END > blah.c
>#include <stdio.h>
>#include <arpa/inet.h>
>int main()
>    char* input = "";    struct in_addr address;
>    if ( inet_aton(input, &address) != -1) {
>       printf("%s == %s == %d == %X\n", input, inet_ntoa(address), htonl(address.s_addr), >htonl(address.s_addr));
>    }
$ ./blah == == 168826912 == A101820

> Seth,
> Let me offer the technical basis you are asking for.
> Zero padding IP addresses is useful for comparing IP addresses to each other as strings. Many languages and most databases do not have IP address data types, so zero padding enables easy comparison via string methods found in all languages and databases. This is particularly useful for determining if an IP address is greater than a starting address and less than an ending address, which is an easy approach for using a database to store IP address ranges and determining if a given IP address falls within that range.
> That is what David is meaning when he says the data from Reg-RWS is to be interpreted by machines.
> Is this helpful information?
> Andy Newton,
> Chief Engineer, ARIN
> _______________________________________________
> arin-tech-discuss mailing list
> arin-tech-discuss at arin.net
> http://lists.arin.net/mailman/listinfo/arin-tech-discuss


More information about the arin-tech-discuss mailing list