TCP/IP Programming Manual
addresses. Table 7 lists the currently defined address-testing macros and the return value for a
valid test. To use these macros, include the following file in your application:
#include <in6.h>
The address-testing macros return true if the address is of the specified type, otherwise, they return
false. The scope-testing macros test the scope of a multicast address and return true if the address
is a multicast address of the specified scope or false if the address is either not a multicast address
or not of the specified scope. IN6_IS_ADDR_LINKLOCAL and IN6_IS_ADDR_SITELOCAL return
true only for the two local-use IPv6 unicast addresses; these two macros do not return true for IPv6
multicast addresses of either link-local scope or site-local scope.
Table 7 Address and Scope-Testing Macros
Scope-Testing MacrosAddress-Testing Macros
int IN6_IS_ADDR_MC_NODELOCAL
(const struct in6_addr *);
int IN6_IS_ADDR_UNSPECIFIED
(const struct in6_addr *);
int IN6_IS_ADDR_MC_LINKLOCAL
(const struct in6_addr *);
int IN6_IS_ADDR_LOOPBACK
(const struct in6_addr *);
int IN6_IS_ADDR_MC_SITELOCAL
(const struct in6_addr *);
int IN6_IS_ADDR_MULTICAST
(const struct in6_addr *);
int IN6_IS_ADDR_MC_ORGLOCAL
(const struct in6_addr *);
int IN6_IS_ADDR_LINKLOCAL
(const struct in6_addr *);
int IN6_IS_ADDR_MC_GLOBAL
(const struct in6_addr *);
int IN6_IS_ADDR_SITELOCAL
(const struct in6_addr *);
int IN6_IS_ADDR_V4MAPPED
(const struct in6_addr *);
int IN6_IS_ADDR_V4COMPAT
(const struct in6_addr *);
Porting Applications to Use AF_INET6 Sockets
AF_INET6 sockets enable applications to communicate using the IPv6 protocol, IPv4 protocol, or
both. For IPv6 communication, RFC 2553, Basic Socket Interface Extensions for IPv6, specifies
changes to the BSD socket Applications Programming Interface (API). Table 2-2 summarizes these
changes.
Table 8 Summary of IPv6 Extensions to the BSD Socket API
ChangesCategory
None; basic syntax of socket functions stays the same. Applications must
cast pointers to the protocol-specific address structures into pointers to the
Core function calls
generic sockaddr address structure when using the socket functions. See
Making Structure Changes (page 54) for information on creating Internet
applications.
Specifies a new sockaddr_in6 structure for IPv6 communications and a
sockaddr_storage structure for protocol-independent communication.
Socket address structure
The sockaddr_in structure remains for IPv4 communications. See Making
Structure Changes (page 54) for more information.
Specifies the getnameinfo, getaddrinfo, getipnodebyname, and
getipnodebyaddr functions for protocol-independent (IPv4 and IPv6)
Name-to-address translation
communication. The gethostbyaddr and gethostbyname functions
remain for IPv4 communications only. See Making Library Routine Changes
(page 56) for more information.
Specifies the inet_pton and inet_ntop functions for
protocol-independent (IPv4 and IPv6) address conversion. The inet_ntoa
Address conversion functions
Porting Applications to Use AF_INET6 Sockets 53