Coding Guidelines/IPv6 Support

From The Open Source Backup Wiki (Amanda, MySQL Backup, BackupPC)

Jump to: navigation, search

Socket Address Helpers

struct sockaddr_storage is a little hard to deal with naturally, especially in an environment where IPv6 support may or may not be present. common-src/sockaddr.{c,h} provide a collection of address-family-independent functions for handling socket addresses. The header file is well-commented, and serves as the definitive reference for these functions.


in common-src/util.{c,h}

This function is a wrapper around getaddrinfo (which may also be a gnulib wrapper around something else, but let's not get into that) to resolve a hostname, returning either the addresses for the name, its canonical name, or both. Details on calling this function (and deallocating the results) are in the header file.

If IPv6 is supported, the function first tries to look up an IPv6 address, potentially a V4MAPPED one. If that fails, it retries with AF_UNSPEC to potentially return an IPv4 address. If IPv6 is not supported, it makes a single call to getaddrinfo with the appropriate hints, and returns the result.

Personal tools