Page 2 of 2

Posted: Tue Aug 15, 2006 7:23 am
by Ambush Commander
Some real teamwork is going on here. It's beautiful to watch
Not really. Feyd did all the work. :-P

Okay, so I'm going to go straight to integrating this code into the library. Are you public-domain'ing this?

Posted: Tue Aug 15, 2006 8:24 am
by feyd
Ambush Commander wrote:Okay, so I'm going to go straight to integrating this code into the library. Are you public-domain'ing this?
Yup, free-for-all.

Posted: Tue Aug 15, 2006 9:37 am
by Ollie Saunders
Oh yeah Feyd, I meant to ask is that Object code with __get and __set PD? I mean, can I use it?

Posted: Tue Aug 15, 2006 9:45 am
by feyd
ole wrote:Oh yeah Feyd, I meant to ask is that Object code with __get and __set PD? I mean, can I use it?
Well, the library it's based on is LGPL as of right now, but the code posted isn't in the library, so ... I guess that's public too.

Let's put it this way, I have no problem with people using the code I post in the forums. Although I would appreciate some note, of your choosing, in the code giving me credit for that contribution. However, it's completely optional.

Posted: Tue Aug 15, 2006 9:48 am
by Ollie Saunders
feyd wrote:Let's put it this way, I have no problem with people using the code I post in the forums. Although I would appreciate some note, of your choosing, in the code giving me credit for that contribution. However, it's completely optional.
Cool, I can do that

Posted: Wed Aug 16, 2006 3:45 pm
by Ambush Commander
Hmm, Feyd, am I correct in asserting that you can't retreive resources with just a prefix, which means that all IPv6 addresses with slashes in them are invalid for our purposes? Or am I missing something? I mean, it's not going to kill anyone if we allow them to specify a prefix (in all likelyhood, no one would be able to access the resource anyway), but I'd just like to know.

Posted: Wed Aug 16, 2006 3:49 pm
by feyd
The prefix is used to denote where the division is between interface address and node, or something like that. It isn't required, or needed to talk to an address, but is needed for routers to know how they relate to other addresses and in doing translations and such. For our purposes here, there a cute feature, but aren't required by either algorithm.

Posted: Wed Aug 16, 2006 3:52 pm
by Ambush Commander
Aha. So this should be usable out of the box.

Hmm... would the algorithm benefit from the pre-knowledge that the address is IPv6? This is because the URI RFC requires IP literals (IPv6 and all future versions) have brackets around them, so I'll know before-hand whether or not it's IPv6 or not. Edit - Doh, yes, of course, even a cursory glance of the code would have told me that. Nevermind.

Posted: Wed Aug 16, 2006 3:57 pm
by feyd
They would still have to validate the formatting, so not really. Now, if you wanted to test if the IP given is routable, then there's additionall code to add. My unit test(s) list the nonroutable masks. It wouldn't be difficult to add.

Posted: Wed Aug 16, 2006 4:05 pm
by Ambush Commander
They would still have to validate the formatting, so not really.
The only point is that if we have an IPv4 address in brackets, we have to reject it or remove the brackets. So I'm splitting out the IPv4 code so that there's differentiation.
Now, if you wanted to test if the IP given is routable, then there's additionall code to add. My unit test(s) list the nonroutable masks. It wouldn't be difficult to add.
They would be

Code: Select all

10.0.0.0 - 10.255.255.255 	/8
172.16.0.0 - 172.31.255.255 	/12
192.168.0.0 - 192.168.255.255 	/16
for IPv4? :?: (doesn't even know what they'd be for IPv6)

I'm really not knowledgeble in networking, sorry. :?

Posted: Wed Aug 16, 2006 4:27 pm
by feyd

Code: Select all

$this->AssertTrue( isValidIPv6('::/128'));                                                            //    compressed, unspecified address type, non-routable
                $this->AssertTrue( isValidIPv6('::1/128'));                                             //   compressed, loopback address type, non-routable 
                $this->AssertTrue( isValidIPv6('FE80::/10'));                           // compressed, link-local unicast, non-routable
                $this->AssertTrue( isValidIPv6('FEC0::/10'));                           // compressed, site-local unicast, deprecated
are the IPv6 non-routables. Everything else is considered a unicast, and therefore "allowed."

As for IPv4 and URI.. well, if you want to remove support for IPv4, those are in the code as $ip4 and $IPv4address in mine and the other algorithm, respectively. It's really easy to make IPv4 fail my test, change the first true to false, done. :)

I'm actually not all that well versed in the finer details of this layer of networking either. But since the idea of validating IPv6 intrigued me, I read the RFC and built what you see on the previous page. :D

Posted: Wed Aug 16, 2006 4:31 pm
by Ambush Commander
Oh. That's all of them? :oops: Hmm... I think I'll let that wait for the stable release. Trying to get the beta out tonight. ;-)
As for IPv4 and URI.. well, if you want to remove support for IPv4, those are in the code as $ip4 and $IPv4address in mine and the other algorithm, respectively. It's really easy to make IPv4 fail my test, change the first true to false, done.
Yep. My final version will be effectively useless for a casual validation of an IPv6 address, but that shouldn't be too much of a problem.
I'm actually not all that well versed in the finer details of this layer of networking either. But since the idea of validating IPv6 intrigued me, I read the RFC and built what you see on the previous page.
Ah, the power of RFCs. And Feyd. :-D