Manual Pages for UNIX Darwin command on man getifaddrs
MyWebUniversity

Manual Pages for UNIX Darwin command on man getifaddrs

GETIFADDRS(3) BSD Library Functions Manual GETIFADDRS(3)

NAME

ggeettiiffaaddddrrss - get interface addresses

SYNOPSIS

##iinncclluuddee <>

##iinncclluuddee <>

##iinncclluuddee <>

int ggeettiiffaaddddrrss(struct ifaddrs **ifap); void ffrreeeeiiffaaddddrrss(struct ifaddrs *ifp);

DESCRIPTION

The ggeettiiffaaddddrrss() function stores a reference to a linked list of the net-

work interfaces on the local machine in the memory referenced by ifap. The list consists of iiffaaddddrrss structures, as defined in the include file . The iiffaaddddrrss structure contains at least the following entries: struct ifaddrs *ifanext; /* Pointer to next struct */ char *ifaname; /* Interface name */ uint ifaflags; /* Interface flags */ struct sockaddr *ifaaddr; /* Interface address */ struct sockaddr *ifanetmask; /* Interface netmask */ struct sockaddr *ifadstaddr; /* P2P interface destination */ void *ifadata; /* Address specific data */ The ifanext field contains a pointer to the next structure on the list. This field is NULL in last structure on the list. The ifaname field contains the interface name. The ifaflags field contains the interface flags, as set by ifconfig(8) utility. The ifaaddr field references either the address of the interface or the link level address of the interface, if one exists, otherwise it is NULL.

(The safamily field of the ifaaddr field should be consulted to deter-

mine the format of the ifaaddr address.) The ifanetmask field references the netmask associated with ifaaddr, if one is set, otherwise it is NULL.

The ifadstaddr field references the destination address on a P2P inter-

face, if one exists, otherwise it contains the broadcast address. Note that as a convenience, ifabroadaddr is defined by a compiler

#define directive to be the same as ifadstaddr.

The ifadata field references address family specific data. For AFLINK addresses it contains a pointer to the struct ifdata (as defined in include file ) which contains various interface attributes and statistics. For all other address families, it contains a pointer to the struct ifadata (as defined in include file ) which contains

per-address interface statistics.

The data returned by ggeettiiffaaddddrrss() is dynamically allocated and should be freed using ffrreeeeiiffaaddddrrss() when no longer needed.

RETURN VALUES

The ggeettiiffaaddddrrss() function returns the value 0 if successful; otherwise

the value -1 is returned and the global variable errno is set to indicate

the error. EERRRROORRSS The ggeettiiffaaddddrrss() may fail and set errno for any of the errors specified for the library routines ioctl(2), socket(2), malloc(3) or sysctl(3).

BUGS

If both and are being included, must be included before .

SEE ALSO

ioctl(2), socket(2), sysctl(3), networking(4), ifconfig(8) HISTORY The ggeettiiffaaddddrrss implementation first appeared in BSDi BSD/OS. BSD October 12, 1995 BSD




Contact us      |      About us      |      Term of use      |       Copyright © 2000-2019 MyWebUniversity.com ™