[ipv6-ops] RE: [ipv6-ops] RFC 5952 converter tool

Aaron Hughes aaronh at tcp0.com
Wed Nov 27 22:31:01 CET 2013


Leo,

Fair enough.. Here's a quick script I just hacked together using the 5952 references:


> php foo.php 2001:db8:0:0:1:0:0:1
2001:DB8::1:0:0:1
> php foo.php 2001:0db8:0:0:1:0:0:1
2001:DB8::1:0:0:1
> php foo.php 2001:db8::1:0:0:1
2001:DB8::1:0:0:1
> php foo.php 2001:db8::0:1:0:0:1
2001:DB8::1:0:0:1
> php foo.php 2001:0db8::1:0:0:1
2001:DB8::1:0:0:1
> php foo.php 2001:db8:0:0:1::1
2001:DB8::1:0:0:1
> php foo.php 2001:db8:0000:0:1::1
2001:DB8::1:0:0:1
> php foo.php 2001:DB8:0:0:1::1
2001:DB8::1:0:0:1


> cat foo.php 
<?php

require "IPv6.php";

$ipaddress = $argv[1];

if(strstr($ipaddress,":" )) {
        $ipaddress = Net_IPv6::uncompress($ipaddress);
        $ipaddress = Net_IPv6::compress($ipaddress);
        $ipaddress = strtoupper($ipaddress);
        }

echo "$ipaddress\n";

?>

Using the pear module I just referenced:

* @category  Net
 * @package   Net_IPv6
 * @author    Alexander Merz <alexander.merz at web.de>
 * @copyright 2003-2005 The PHP Group
 * @license   http://www.opensource.org/licenses/bsd-license.php
 * @version   CVS: $Id: IPv6.php,v 1.18 2008/10/28 02:05:07 alexmerz Exp $
 * @link      http://pear.php.net/package/Net_IPv6

This should do what you are looking for reliably.

Cheers,
Aaron


On Wed, Nov 27, 2013 at 01:11:57PM -0800, Leo Vegoda wrote:
> Hi Aaron,
> 
> Aaron Hughes wrote:
> 
> > Depends on what you mean by non-RFC 5952. There are tons of functions 
> > out
> > there like pear Net_IPv6::uncompress() Net_IPv6::compress() that work 
> > well,
> > however, junk is junk so it's hard to get into proper format. Can you 
> > provide an
> > example of the source data you are referring to?
> 
> I am looking for something that could be recommended to domain registrars 
> and resellers collecting IPv6 glue from registrants. gTLD registrars are 
> contractually required to provide IPv6 addresses in RFC 5952 format (under 
> the new RAA) and I'd like to recommend a reliable tool for converting from 
> (at least) full uncompressed format.
> 
> I suppose registrars are likely to see registrants entering IPv6 addresses 
> in all sorts of formats and was hoping there might be something fairly 
> intelligent out there that can reliably convert from anything valid and 
> unambiguous into the required format.
> 
> Thanks,
> 
> Leo



-- 

Aaron Hughes 
aaronh at tcp0.com
+1-703-244-0427
Key fingerprint = AD 67 37 60 7D 73 C5 B7  33 18 3F 36 C3 1C C6 B8
http://www.tcp0.com/



More information about the ipv6-ops mailing list