How to port your applications to IPv6:

GENERAL IDEAS

 Include files:
  - sometimes <arpa/inet.h> is not included
  and functions like inet_ntoa are explicitly defined.
  It is far better to include <arpa/inet.h> !
  - flowlabel and priority stuff is in <netinet/ip6.h>
  (IPv4 tos is in <netinet/ip.h>)

 Address manipulation routines:
  - inet_aton/inet_addr are replaced by ascii2addr/inet_pton
  - inet_ntoa is replaced by addr2ascii/inet_ntop
  - inet_network/inet_makeaddr/inet_lnaof/inet_netof
  are obsolete because IPv6 has no very explicit notion of network.
  (note: these function should not be used in common IPv4 applications).

 Programming style advice:
 application must not have to know the layout of IPv6 addresses,
 only the size (16 octets) and alignment (8 octets)

 Resolver (aka DNS) routines:
  - gethostbyname is replaced by hostname2addr/RES_USE_INET6
  (note: these functions work on addresses in numeric form
  then it can (should) be called directly (ie not when
  inet_aton/inet_addr, now ascii2addr/inet_pton fail))
  - gethostbyaddr is addr2hostname/RES_USE_INET6

 New basic API:
  - try to use inet_pton/inet_ntop and the RES_USE_INET6
  option or if needed gethostbyname2.

 Sockaddr length (4.4BSD/Net3 style):
  - for portable software put an #ifdef SIN6_LEN

 Type Of Service:
 replaced by the priority field but usage is a bit different:
  - set priority/flowlabels in bind (passive) or connect/sendto (active)
  - inetd should know what to use if accept is done there
  - IPv4 accept does not copy the TOS (it is one legitimate usage
  of is_ipv4_addr)
  - magic mapping of tos/priority is local to this implementation

 Explicit usage of IPv4:
  - ftp/ftpd can use foobar (aka RFC 1639)
  - talk/talkd are garbage (run a Garbage Collector on it)

 Broadcast:
  - move to multicast!

EXAMPLES

First example: telnet
 - general ideas are applied!
 - the TOS stuff is replaced by explicit flowlabel/priority management
 (note: sin6_flowlabel name should change)
 - <arpa/inet.h> et <netinet/ip6.h> include files are added
 and explicit declaration of address manipulation functions removed
 - default flowlabel/priority is "interactive" (== low delay)
 (note: the #define names are local to the implementation)
 (note: don't forget that sin6_flowlabel is network order)
 - if SIN6_LEN is defined (4.4BSD/Net3 style) then sin6_len must
 be set to sizeof(struct sockaddr_in6) (verified by the kernel)
 - source routing option has not been (yet) translated

Second example: ftp
 - same than telnet
 - foobar use IN6_IS_ADDR_V4MAPPED on the peer address in order
 to switch between IPv4 and IPv6 "long" form of PORT/PASV
 (legimate usage of IN6_IS_ADDR_V4MAPPED and IPv4-mapped IPv6 address
 exact layout because of the very ancient design of FTP)
 - one case of IP_TOS option setting because of TCP/IPv4 accept
 "bad" semantic on tos (should be fixed in the kernel ?)
 
Third example: tftp
 - same than telnet
 - socket system call should be used with an explicit protocol
 (matter of taste until a new stream or datagram protocol is defined)
 - the "port" bug is still here (find and fix it)

Forth example: inetd
 - new problem: sockaddr_in6 structure is bigger than sockaddr structure
 (use the good one or an union, in fact real multi-protocol is possible
 only if the maximal size of an address is known. In BSD 128 octets
 are enough in any cases today)

