[TYPO3-core] RFC: Bug 331: Support IPv6 addresses

Bernhard Kraft kraftb at kraftb.at
Wed Mar 8 16:33:00 CET 2006


Franz Holzinger wrote:

> It's not so easy to find with Google because you have 100 000 matches.
> 
> http://www.tldp.org/HOWTO/Linux+IPv6-HOWTO/x439.html

thx. tldp.org is what I used.


> You have changed interface of the original function and allow a wildcard.

Yes. As those wildcards are already there for IPv4 I think we should keep it
that "*" matches a whole "subpart" of an IP either v4 or v6.


>>I do comparison and masking by using boolean arithmetic. just simple shifts and bit-wise &'s.
>>
>>I also changed cmpIPv4 to this style ... I tought it would be much faster but only about
>>2%. does that count :?
>>
>>
>> 
>>
> 
> I do not understand why your version of the validIPv6Addr function
> should be faster to put the ip into an array and call the regexp in a
> loop. Here you  did not use bit shifts or bitwise '&'.

Ok. The cmpIPv6 routine works the following way:

When an IP-Mask which hasn't a mask gets encountered the "old-school" match-algorythm where
ever full IP-part of the IP-to-check (separated by :) is checked against the single parts
of the current IP from the list to check against.

When now an IP with mask is encountered the number of bit's the mask has is put into an
variable. and a loop get's run through for each single part of the IP:
1. When the mask still has more or equal than 16-bits this means that the full current
part has to get compared (each part has 2bytes = 16bit).
2. When the mask has less than 16-bit I do the boolean-magic again:
              $maskInt = ~((1<<(16-$mask))-1) & 0xffff;
              if (($testI & $maskInt)!=($baseParts[$x] & $maskInt)) {
But this time for single 16-bit values and not for a whole 32-bit value like IPv4 is.

I can't do ONE compare of the list-value to the test-value cause those addresses are
128-bit long. I could split them up in 4x32bit checks but that would almost be the
same as the current 8x16bit checks.

I think it's faster than you code because you have this IPv6 Hex2bin ... and I think this
one is not really fast. I do a compare right now ... a moment please ....

ok. result: i can't compare them. you version franz, doesn't seem to properly expand the
"::" - shortcut. "::" means that this space has to get filled with "0000" IP elements - howmany
there are required to have an 8x16-bit IP address.

Just one example of the attached output of my test-program:

The IPv6 Address "4030:00bc:0000:00a4:0267:01ff:fe01:7352" didn't match "4030:00bc::/48" altough it should !

4030:00bc::/48 would be:
4030:00bc:0000:0000::0000:0000:0000:0000 / 48

and 48 bits are 16 * 3 =

4030:00bc:0000

and this of course matches the first part (first 3 elements) of "4030:00bc:0000:00a4:0267:01ff:fe01:7352".


In the output rather not look at the:
Negatively failed negative test :
lines they are just a result of testing if the cmpIP method works also with lists of IP's properly.


greets,
Bernhard
-- 
----------------------------------------------------------------------
"Freiheit ist immer auch die Freiheit des Andersdenkenden"
Rosa Luxemburg, 1871 - 1919
----------------------------------------------------------------------
-------------- next part --------------
A non-text attachment was scrubbed...
Name: out.txt.gz
Type: application/x-gzip
Size: 21623 bytes
Desc: not available
Url : http://lists.netfielders.de/pipermail/typo3-team-core/attachments/20060308/91c49955/attachment.bin 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 256 bytes
Desc: OpenPGP digital signature
Url : http://lists.netfielders.de/pipermail/typo3-team-core/attachments/20060308/91c49955/attachment.pgp 


More information about the TYPO3-team-core mailing list