sctp_getpaddrs and sctp_freepaddrs subroutines

Returns all peer addresses in an association.

Library

/usr/lib/libsctp.a

Syntax

#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/sctp.h>

int sctp_getpaddrs(int sd, sctp_assoc_t assoc_id, struct sockaddr **addrs);
void sctp_freepaddrs(struct sockaddr *addrs);

Description

The sctp_getpaddrs subroutine returns all the peer addresses in an association. On return, the addrs parameter points to a dynamically allocated packed array of the sockaddr structures of the appropriate type for each address. You must use the sctp_freepaddrs subroutine to free the memory.
Note: The in or out parameter addrs must not be NULL.

If the sd parameter is an IPv4 socket, the addresses returned are all IPv4 addresses. If the sd parameter is an IPv6 socket, the addresses returned can be a mix of IPv4 or IPv6 addresses. For one-to-many style sockets, the id field specifies the association to query. For one-to-one style sockets, the id field is ignored.

The sctp_freepaddrs subroutine frees all the resources allocated by the sctp_getpaddrs subroutine.

Return value

On success, the sctp_getpaddrs subroutine returns the number of peer addresses in the association. If there is no association on this socket, 0 is returned and the value of the *addrs field is undefined. On error, the sctp_getpaddrs subroutine returns -1, and the value of the *addrs field is undefined.