Wouter Posted January 4, 2012 Report Share Posted January 4, 2012 (edited) VI Name: IP Validation Total VIs: strpos.vi, strrpos.vi, substr_count.vi, valid_ipv6.vi, test,vi, unittest.vi, ip2long.vi, long2ip.vi, valid_ipv4.vi Description: I saw in the svn of OpenG that there was a candidate for IP validation. But however I think I have a better one. One for IPv4 and one for IPv6, credits for the IPv6 algo goes to http://crisp.tweakbl...d-caveats).html Note: - Blockdiagram: - What are you thoughts on this VI? Would you like to see such a function in OpenG? Can you optimize the code? In which package should it be included? Should it be rejected? -edit- ups I forgot to set the unittests data I inputed in the control as default value... well you can now enter them by hand. $unitTests = array( '2001:0db8:0000:0000:0000:0000:1428:57ab' => true, '2001:0DB8:0000:0000:0000:0000:1428:57AB' => true, '2001:00db8:0000:0000:0000:0000:1428:57ab' => false, '2001:0db8:xxxx:0000:0000:0000:1428:57ab' => false, '2001:db8::1428:57ab' => true, '2001:db8::1428::57ab' => false, '2001:dx0::1234' => false, '2001:db0::12345' => false, '' => false, ':' => false, '::' => true, ':::' => false, '::::' => false, '::1' => true, ':::1' => false, '::1.2.3.4' => true, '::256.0.0.1' => false, '::01.02.03.04' => false, 'a:b:c::1.2.3.4' => true, 'a:b:c:d::1.2.3.4' => true, 'a:b:c:d:e::1.2.3.4' => true, 'a:b:c:d:e:f:1.2.3.4' => true, 'a:b:c:d:e:f:1.256.3.4' => false, 'a:b:c:d:e:f::1.2.3.4' => false, 'a:b:c:d:e:f:0:1:2' => false, 'a:b:c:d:e:f:0:1' => true, 'a::b:c:d:e:f:0:1' => false, 'a::c:d:e:f:0:1' => true, 'a::e:f:0:1' => true, 'a::e:f:0:1' => true, 'a::f:0:1' => true, 'a::0:1' => true, 'a::1' => true, 'a::' => true, '::0:1:a:b:c:d:e:f' => false, '::0:a:b:c:d:e:f' => false, '::a:b:c:d:e:f' => true, '::b:c:d:e:f' => true, '::c:d:e:f' => true, '::e:f' => true, '::e:f' => true, '::f' => true, '0:1:a:b:c:d:e:f::' => false, '0:a:b:c:d:e:f::' => false, 'a:b:c:d:e:f::' => true, 'b:c:d:e:f::' => true, 'c:d:e:f::' => true, 'd:e:f::' => true, 'e:f::' => true, 'f::' => true, 'a:b:::e:f' => false, '::a:' => false, '::a::' => false, ':a::b' => false, 'a::b:' => false, '::a:b::c' => false, 'abcde::f' => false, '10.0.0.1' => false, ':10.0.0.1' => false, '0:0:0:255.255.255.255' => false, '1fff::a88:85a3::172.31.128.1' => false, 'a:b:c:d:e:f:0::1' => false, 'a:b:c:d:e:f:0::' => false, 'a:b:c:d:e:f::0' => true, 'a:b:c:d:e:f::' => true, 'total gibberish' => false); ValidateIP.zip Edited January 4, 2012 by Wouter Quote Link to comment
asbo Posted January 4, 2012 Report Share Posted January 4, 2012 Having only gleaned a little from the VIs names, I presume it uses string/token-based analysis to validate the strings as an IP address. There exists the the "String to IP" and "IP to String" LabVIEW nodes, I wonder if these would be faster to use for IPv4 addresses? There may be OS-specific calls which are faster, In general, though, I think that these would be helpful only in data validation scenarios, rather than actual networking scenarios - if you plug in an ill-formed address, the networking node will return the correct error and you should handle it downstream. Also, your IPv6 reference link got mangled. Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.