getifaddrs

Name

getifaddrs, freeifaddrs -- get interface addresses

Synopsis

#include <ifaddrs.h>

int getifaddrs(struct ifaddrs ** ifap);

void freeifaddrs(struct ifaddrs * ifa);

Description

The getifaddrs() function creates a linked list of structures describing the network interfaces of the local system. The address of the first item is stored in memory pointed to by ifap. The data returned is dynamically allocated, and should be freed using freeifaddrs().

The list consists of structures of type ifaddrs (see Data Definitions above).

Return Value

On success, getifaddrs() returns zero; on error, -1 is returned, and errno is set appropriately.

Errors

getifaddrs() may fail and set errno for any of the errors specified for socket(), bind(), getsockname(), recvmsg(), sendto(), malloc(), or realloc().

See Also

bind(), getsockname(), socket().