Home

Awesome

As of 1.3, CakePHP covers IPv6 validation out of the box, and you could probably just store those addresses as varchars in your database and be done with it.

But that won't let you do calculations like looking up free addresses inside a range.

The best way to store an IPv6 would probably be to use an 128bit integer, but MySQL does not support this, and I haven't found any plans of doing so.

mysql-udf-ipv6 involves compiling, making your app less portable.

Then there are several hacks possible.

I finally decided to do a PHP implementation cause app servers scale better than dbs. I only use raw sql when it's strictly necessary, e.g. when doing full searches.

Usage example

<?php
Class Ipv6Range extends IcingAppModel {
    public $actsAs = array(
        'Ipv6.Ipv6able' => array(
            'field_address' => 'address',
            'field_bits' => 'bits',
            'field_size' => 'size',
        ),
    );
}

The size field will be automatically set whenever a user changes the bits field, so you can hide it from the interface. But it's useful when you're trying to find to which range an IPv6 ip belongs.

Thanks to