Example Code

Validate IP address

Code and Documents

Attachment

I needed to validate an IPv6 address. Unfortunately LabVIEW doesn't provide support to validate any IP addresses therefore I created my own validation function. I used the code from http://crisp.tweakblogs.net/blog/3049/ipv6-validation-more-caveats.html and ported it to LabVIEW, so the credits go to him. 

This VI includes the following functions;

  • ip2long
  • long2ip
  • explode
  • substr_count
  • strpos
  • strrpos
  • number_to_boolean (little unnecessary but I dislike using the "greater then 0" vi to indicate that I just want to have my number converted to a boolean.)
  • Validate IPv4
  • Validate IPv6 

The string functions from php I just converted them to LabVIEW because I think these can always come out in handy. When I'm doing something different with strings.

Enjoy!

ps. if anyone has a better function of one of the subvi's or validation vi's I'm glad to hear about it.

Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.

Comments
William1225
Active Participant
Active Participant
on

Hi WG-,

 

Very appreciated to your kindly sharing, it is helpful to me to check if the IP string is IPv4 or IPv6.

Contributors