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

Bernhard Kraft kraftb at kraftb.at
Wed Mar 8 05:45:31 CET 2006


Franz Holzinger wrote:

> This would be fine with me. Inform me via email when I can replace this
> function.

Hey !


I think I got a better version and I wrote a test-suite and tested it against some
combinations of values ....


Attached is a diff with my version.

The simple outcome is: "::" must only be used once. Else the IPv6 addr isn't distinguisuable
(unique). Read that in the docs - it's written everywhere.

validIPv6Addr: checks if a IPv6 address is valid and returns it in normalized form.
I implemented this by doing a split "::" first and check that ther are at maximal 2 parts.

Then I split each of the parts for ":". you wonder what happens when the second part isn't
set because there was no "::" ?? simple: the second array is empty because I have set the
third parameter in trimExplode. when this happens the first one needs to have the correct
amount of elements.

Then those arrays will get merged again with the 0-array in the middle. the amount of 0's in
the middle array depens on how many values there are specified by the other arrays.

The combined array get's checked for valid characters, converted to lowercase, each single
word padded to 4 hex-digits and then returned.

on any error a '' string is returned.


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 :?


Files and testsuite attached


greets,
Bernhard
-- 
----------------------------------------------------------------------
"Freiheit ist immer auch die Freiheit des Andersdenkenden"
Rosa Luxemburg, 1871 - 1919
----------------------------------------------------------------------
-------------- next part --------------
A non-text attachment was scrubbed...
Name: IPv6_compare_kraftb_2006-03-08.diff
Type: text/x-patch
Size: 4483 bytes
Desc: not available
Url : http://lists.netfielders.de/pipermail/typo3-team-core/attachments/20060308/f314f6b7/attachment.bin 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: t3libdiv_testSuite.zip
Type: application/zip
Size: 51985 bytes
Desc: not available
Url : http://lists.netfielders.de/pipermail/typo3-team-core/attachments/20060308/f314f6b7/attachment.zip 
-------------- 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/f314f6b7/attachment.pgp 


More information about the TYPO3-team-core mailing list