[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [FWP] IP address regex golf



On 29 Apr 2000, at 19:28, Adam Rice wrote:

> Quoting Brian L. Matthews (blm@halcyon.com):
> > >$f='(\d+)\.';/^$f$f$f(\d+)$/&($1|$2|$3|$4)<256
> > 
> > According to man inet on my ISP's Sun, the individual parts of the 
> > text version of an IP address can be specified in octal, hex, or 
> > decimal.
> 
> This seems to be true, at least on Debian GNU/Linux:
> 
> telnet 0x7f000001
> Trying 127.0.0.1...
> Connected to 0x7f000001.
> Escape character is '^]'.
> 
> I just realised that practically every URL-aware application I've ever
> written is broken :-)

Not quite.  The problem is that 'man <ANYTHING>' is not the proper way to 
find out what something is *supposed* to be.  Most of the Unix IP-addr-
parsers share parentage and so will mostly implement the same 
"conventions", regardless of whether they're actually part of the 
standard or not...

But in this case, AFAIK the governing standard is RFC 997 and it says:

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

I haven't been able to find ANY 'official' mention in the RFCs of the 
"Berkeley extensions" to dotted-decimal notation, and as far as I've been 
able to find, nothing in the RFCs has ever used anything _other_ than the 
standard dotted decimal.  There are many references to the "four-field" 
dotted decimal notation [e.g., from RFCs 822 and 1123].

Anyhow, so IMO you can/ought to just ignore the "nonstandard" [sic! :o)]  
Unix extensions and just worry about the four-field version.  ...so now 
where were we...:o)

  /Bernie\

-- 
Bernie Cosell                     Fantasy Farm Fibers
mailto:bernie@fantasyfarm.com     Pearisburg, VA
    -->  Too many people, too few sheep  <--          

==== Want to unsubscribe from Fun With Perl?  Well, if you insist...
==== Send email to <fwp-request@technofile.org> with message _body_
====   unsubscribe