Quick routine to validate an IPV4 address :
FUNCTION validateIP4Address%:ip$
LOCAL section$[]
LOCAL loop$
DIM section$[0]
IF SPLITSTR(ip$,section$[],".")<>4 THEN RETURN FALSE
FOREACH loop$ IN section$[]
IF LEN(loop$)<1 OR LEN(loop$)>3 THEN RETURN FALSE
IF isNumber(loop$)=FALSE THEN RETURN FALSE
NEXT
RETURN TRUE
ENDFUNCTION
FUNCTION isNumber%:text$
LOCAL loop%
LOCAL one$
FOR loop%=0 TO LEN(text$)-1
one$=MID$(text$,loop%,1)
IF one$<"0" OR one$>"9" THEN RETURN FALSE
NEXT
loop%=INTEGER(text$)
IF loop%<0 OR loop%>255 THEN RETURN FALSE
RETURN TRUE
ENDFUNCTION
Would like to find decent IPV6 validation code, but there is nothing simple around at the moment.
No problems, here are the RFC. (not sure if it's the newest...) ;)
http://www.faqs.org/rfcs/rfc2373.html
Trouble is, there are allowed shortcuts for the different sections :(
Yes, there was supposed to be an ironic smile up there somewhere... :-)
True :)