HPlogo HP-UX IPv6 Porting Guide: HP-UX 11i v2 September 2004 > Appendix A IPv4 to IPv6 Quick Reference Guide

Summary: Source Code Symbols and Function Changes

» 

Technical documentation

Complete book in PDF

 » Table of Contents

The following tables cover changes in the source code symbols and functions that Socket Application programmers need to be aware of when porting code to support IPv6.

Changes to Symbols, Data Structures, and Function Calls

Table A-1  Changes to Symbols, Data Structures, and Function Calls

Search source code for:Replace with:

Symbols

AF_INET
PF_INET
AF_INET6
PF_INET6

Data Structures

sockaddr_in
u_short sin_family
in_port_t sin_port
sin_addr struct in_addr
sockaddr_in6
shorts in6_family;
u_short sin6_port;
uint32_t sin6_flowinfo;
struct in6_addr sin6_addr;
uint32_t sin6_scope_id
ifreq
ifconf
struct if_laddrreq
struct if_laddrconf
Function Calls

gethostbyname()getaddrinfo() or getipnodebyname(),
freeaddrinfo()
gethostbyaddr()getipnodebyaddr(),getnameinfo(),
freeaddrinfo()
inet_ntoa()
inet_addr() or inet_aton()
inet_ntop()
inet_pton()

 

Watch for hard-coded data structure sizes

Watch for sizeof(struct sockaddr_in) = sizeof(struct sockaddr) = 16 in pre-ported applications. The IPv6 address data structure sockaddr_in6 is larger than the traditional sockaddr_in data structure.

Multicast and IPv4 Options

Table A-2 Multicast and IPv4 Options

IPv4

IPv6Comments
IN_CLASSA
IN_CLASSB
IN_CLASSC
IN_CLASSD

None. IPv6 addressing is classless.

 

Loopback Address

Table A-3 Loopback Address

IPv4IPv6Comments
INADDR_LOOPBACKin6addr_loopbackin6adr_loopback is an in6_addr structure

 

Wildcard Address

Table A-4 Wildcard Address

IPv4

IPv6Comments
INADDR_ANYin6addr_anyin6addr_any is an in6_addr structure

 

Multicast Defaults

Table A-5 Multicast Defaults

IPv4

IPv6Comments
IP_DEFAULT_MULTICAST_LOOP
IP_DEFAULT_MULTICAST_TTL
IPV6_DEFAULT_MULTICAST_LOOP
IPV6_DEFAULT_MULTICAST_HOPS

 

IPv6 Multicast Options

Table A-6 IPv6 Multicast Options

IPv4IPv6Comments
IP_MULTICAST_IF
IP_MULTICAST_TTL
IP_MULTICAST_LOOP
IP_ADD_MEMBERSHIP
IP_DROP_MEMBERSHIP
IPV6_MULTICAST_IF
IPV6_MULTICAST_HOPS
IPV6_MULTICAST_LOOP
IPV6_JOIN_GROUP
IPV6_LEAVE_GROUP
 

 

NOTE: When setting the getsockopt() and setsockopt() level parameter, use IPPROTO_IPV6 level for all IPV6_* options listed here.

IP Packet Options

Table A-7 IP Packet Options

IP_OPTIONSIPV6_PKTOPTIONSComments
IP_RECVDSTADDR
IP_RECVIF
IPV6_DESTOPTS
IPV6_HOPLIMIT
IPV6_HOPOPTS
IPV6_NEXTHOP
IPV6_PKTINFO
IPV6_PKTINFO
IPV6_PKTINFO
Receive Destination options
Unicast hop limit for receiving packets
Receive hop-by-hop options
Set next-hop address
Set packet information
Return destination IP address
Return received interface index

IPV6_RTHDR

Send or receive routing header

IP_TTL
ip_mreq
IPv6_UNICAST_HOPS
ipv6_IP_OPTIONSmreq
Default unicast hop limit

 

NOTE: Bundle the seven options above into a single setsockopt() call using IPV6_PKTOPTIONS.

Types of Service Options

Table A-8 Types of Service Options

IP_TOS

Still under discussion by IETF IPng working group.

 

Multicast Group, IP Address, and IPv6 Interface Index

Table A-9 Multicast Group, IP Address, and IPv6 Interface Index

IPv4IPv6Comments
struct in_addr imr_multicaststruct in6_addr
ipv6mr_multiaddr
Multicast address of group
struct in_addrimr_interfaceuint32
ipv6mr_interface
IPv4: local IP address of interface
IPv6: interface index

 

© 2004 Hewlett-Packard Development Company, L.P.