bind2addrsel Subroutine

Purpose

Binds a socket to an address according to address selection preferences.

Library

Library (libc.a)

Syntax

#include <netinet/in.h>
int bind2addrsel(int socket,const struct sockaddr *dstaddr, socklen_t dstaddrlen)

Description

When establishing a communication with a distant address, AIX® uses a address selection algorithm to define what local address will be used to communicate with a distant address. This algorithm uses a set of ordered rules (RFC 3484) to choose this local address. Some of these rules use the type of address for this selection. By default, public addresses are preferred over temporary addresses; CGA addresses are preferred over non CGA addresses; home addresses are preferred over care-of addresses. An application may prefer the use other preference choices (for example use a temporary address rather that a public address) for the rules using the type of address. If these rules are applied, these preferences will be used. The application can express these preferences using a setsockopt call with the IPV6_ADDR_PREFERENCES option and a combination of the following flags:

The application will then call bind2addrsel. bind2addrsel binds a socket to a local address selected to communicate with the given destination address according to the address selection preferences.

Parameters

Item Description
socket Specifies the unique socket name
dstaddr Points to a sockaddr structure containing the destination address. The sin6_family field of this sockaddr structure must be set to AF_INET6.
dstaddrlen Specifies the size of the sockaddr structure pointed by dstaddr.

Return Values

Upon successful completion, the subroutine returns 0

If unsuccessful, the subroutine returns -1 and errno is set accordingly: