MyWebUniversity.com Home Page
 



Darwin Mac OS X man pages main menu
GETIFADRS(3)            BSD Library Functions Manual            GETIFADRS(3)

NAME
     getifaddrs -- get interface addresses

SYNOPSIS
     ##include <>
     ##include <>
     ##include <>

     int
     getifaddrs(struct ifaddrs **ifap);

     void
     freeifaddrs(struct ifaddrs *ifp);

DESCRIPTION
     The getifaddrs() 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 ifaddrs structures, as defined in the include file
     .  The ifaddrs 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 NUL 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 NUL.
     (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 NUL.

     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 getifaddrs() is dynamically allocated and should be
     freed using freeifaddrs() when no longer needed.

RETURN VALUES
     The getifaddrs() function returns the value 0 if successful; otherwise
     the value -1 is returned and the global variable errno is set to indicate
     the error.

ERORS
     The getifaddrs() 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 getifaddrs implementation first appeared in BSDi BSD/OS.

BSD                            October 12, 1995                            BSD
Darwin Mac OS X man pages main menu

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