How to validate IPv4 & IPv6 in C?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • GujjuNilesh
    New Member
    • Feb 2010
    • 1

    How to validate IPv4 & IPv6 in C?

    Hi,

    I would like to write a program, and which is going to have multiple IP addresses (can be v4 or v6) as input, and on the return I need to print which IP addresses are valid and which aren't.

    The term 'valid' means :
    1. It is not necessary to have IP in same subnet / network.
    2. It does not matter if given IP fails to ping.
    3. For IPv4, there should be 4 bots, and all number have to be in between 0 to 255. [same for IPv6 also]

    Any solution will be acceptable? using existing bulit-in libraries or manual parsing etc etc.

    Thanks in advance.
    Neal.
  • Banfa
    Recognized Expert Expert
    • Feb 2006
    • 9067

    #2
    Use the function getaddrinfo (you can google it)

    Comment

    Working...