Hi, For IP address validation, 'm using network address and service translation API getaddrinfo(). It is used to validate the configured machine is IPV4 or IPV6 by checking retrieved struct addrinfo member ai_family contents.
---------------------------------------------------------------------------------------------- For example: IPV4 Address => A.B.C.D IPV6 Address => Aa:Bb:Cc:Dd:Ee <snip> struct addrinfo AddrHints, *res; memset(&AddrHints, 0, sizeof(AddrHints)); AddrHints.ai_flags = AI_NUMERICHOST; service =NULL; Node = (IPV4 or IPV6 address) getaddrinfo(Node, NULL , &AddrHints, &res); if(res->ai_family == AF_INET6) { ... } if(res->ai_family == AF_INET) { ... } </snip> ---------------------------------------------------------------------------------------------- CASE 1: FULL IPV4 or IPV6 address as node parameter If we provide Full IPV4 or IPV6 address as mentioned above with the retrieved struct addrinfo member ai_family contents the proper information. FULL ip address E.g. [node = "A.B.C.D" or "Aa:Bb:Cc:Dd:Ee"] CASE 2 :Partial IPV4 When a partial IPV4 address is provided in node parameter of getaddrinfo(), it returns correctly ai_family as INET (means its a IPV4) Partial IPV4 ip address [node = "A.B.C"] CASE 3: Partial IPV6 When a partial IPV6 address is provided in node parameter of getaddrinfo(), it returns the res contents with INET6 as the ai_family. Partial IPV6 ip address [node = "Aa:Bb:Cc"] This seems to contradict with the information provided in Solaris man pages. As per man pages reference :http://www.manpages.info/sunos/inet.7.html <snip> IPv6 Addresses There are three conventional forms for representing IPv6 addresses as strings: 1. The preferred form is x:x:x:x:x:x:x:x, where the 'x's are the hexadecimal values of the eight 16-bit pieces of the address, for example, 1080:0:0:0:8:800:200C:417A Note that it is not necessary to write the leading zeros in an individual field. However, there must be at least one numeral in every field </snip> In the last line it clearly specifies that if the IPv6 address is written in x:x:x:x:x:x:x:x format it should be complete and not partial. But this is not the behavior observed in case of getaddrinfo() with partial IPV6 address. On the other hand Linux gives expected output when partial IPv6 address is given i.e it returns error code. Linux => 2.6.18-92.1.10.el5.xs5.0.0.39xen #1 SMP Thu Oct 2 07:35:45 EDT 2008 x86_64 x86_64 x86_64 GNU/Linux Solaris => SunOS 5.10 Generic_142909-17 sun4u sparc SUNW,Sun-Fire-V440 Can some one look into this ? Please comment ... -- This message posted from opensolaris.org _______________________________________________ networking-discuss mailing list networking-discuss@opensolaris.org