GETIFADDRS(3SOCKET) | Sockets Library Functions | GETIFADDRS(3SOCKET) |
cc [ flag ... ] file ... -lsocket -lnsl [ library ... ] #include <sys/types.h> #include <sys/socket.h> #include <ifaddrs.h>
int getifaddrs(struct ifaddrs **ifap);
void freeifaddrs(struct ifaddrs *ifp);
struct ifaddrs { struct ifaddrs *ifa_next; char *ifa_name; uint64_t ifa_flags; struct sockaddr *ifa_addr; struct sockaddr *ifa_netmask; union { struct sockaddr *ifu_broadaddr; struct sockaddr *ifu_dstaddr; } ifa_ifu; void *ifa_data; }; #define ifa_broadaddr ifa_ifu.ifu_broadaddr #define ifa_dstaddr ifa_ifu.ifu_dstaddr
The list is traversed by following the ifa_next pointer. This member is NULL on the last structure in the list.
The ifa_name member contains the interface name.
The ifa_flags member contains the interface flags.
The ifa_addr member references the address of the interface. Use the sa_family member of this structure to determine the format of the address, as described in socket.h(3HEAD).
The ifa_netmask member references the netmask associated with ifa_addr, or NULL if one is not set.
If the IFF_BROADCAST bit is set in ifa_flags, then ifa_broadaddr is valid, or NULL if not present. If the IFF_POINTOPOINT bit is set, then ifa_dstaddr is valid, or NULL if not present. These two flags are mutually exclusive; see if_tcp(4P) for more information.
The ifa_data member is presently unused.
The memory used by getifaddrs() to back the list is dynamically allocated. It should be freed using freeifaddrs().
ATTRIBUTE TYPE | ATTRIBUTE VALUE |
Interface Stability | Committed |
MT-Level | MT-Safe |
April 18, 2013 | OmniOS |