Summary
In this chapter, we covered the basic information required for adding IPv6 support to applications, including how the basic sockets API has been expanded to accommodate IPv6 and new functions for doing name/address translation. Naturally, there is quite a bit more to the basic API in RFC 3493 that we have not covered, including:
The functions
if_nametoindex,if_indextoname,if_nameindex, andif_freenameindexto find a list of interfaces and convert them from names to integers, which can then in turn be used to control multicast.Various socket options for controlling multicast transmission (
IPV6_MULTICAST_IF,IPV6_MULTICAST_HOPS,IPV6_MULTICAST_LOOP) and reception (IPV6_JOIN_GROUP,IPV6_LEAVE_GROUP).The
IN6_IS_ADDR_*family of functions that allow the classification of unicast and multicast addresses.
The prototypes for new functions introduced by the basic API are shown in Example 8-12. The advanced API goes even further allowing fine control of IPv6's routing, destination options and hop-by-hop headers. Coverage of these advanced features is beyond the realm of deployment and those interested should consult RFC 3493 and Stevens's UNIX Network Programming.
Example 8-12. Prototypes for new sockets API functions
#include <net/if.h> unsigned int if_nametoindex(const char *ifname); char *if_indextoname(unsigned int ifindex, char *ifname); struct if_nameindex *if_nameindex(void); void if_freenameindex(struct if_nameindex *ptr); #include <arpa/inet.h> const char *inet_ntop(int af, ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access