-.\" $FreeBSD: src/lib/libc/net/getifaddrs.3,v 1.1.2.4 2001/08/31 10:15:14 ru Exp $
.\" $KAME: getifaddrs.3,v 1.4 2000/05/17 14:13:14 itojun Exp $
.\" BSDI getifaddrs.3,v 2.5 2000/02/23 14:51:59 dab Exp
.\"
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
+.\"
+.\" $FreeBSD: src/lib/libc/net/getifaddrs.3,v 1.10 2005/02/09 18:03:13 ru Exp $
+.\"
.Dd October 12, 1995
.Dt GETIFADDRS 3
.Os
.Nm getifaddrs
.Nd get interface addresses
.Sh SYNOPSIS
-.Fd #include <sys/types.h>
-.Fd #include <sys/socket.h>
-.Fd #include <ifaddrs.h>
+.In sys/types.h
+.In sys/socket.h
+.In ifaddrs.h
.Ft int
.Fn getifaddrs "struct ifaddrs **ifap"
.Ft void
The list consists of
.Nm ifaddrs
structures, as defined in the include file
-.Aq Pa ifaddrs.h .
+.In ifaddrs.h .
The
.Nm ifaddrs
structure contains at least the following entries:
u_int ifa_flags; /* Interface flags */
struct sockaddr *ifa_addr; /* Interface address */
struct sockaddr *ifa_netmask; /* Interface netmask */
- struct sockaddr *ifa_broadaddr; /* Interface broadcast address */
+.\" struct sockaddr *ifa_broadaddr; /* Interface broadcast address */
struct sockaddr *ifa_dstaddr; /* P2P interface destination */
void *ifa_data; /* Address specific data */
.Ed
if one is set, otherwise it is NULL.
.Pp
The
-.Li ifa_broadaddr
-field,
-which should only be referenced for non-P2P interfaces,
-references the broadcast address associated with
-.Li ifa_addr ,
-if one exists, otherwise it is NULL.
-.Pp
-The
.Li ifa_dstaddr
field references the destination address on a P2P interface,
-if one exists, otherwise it is NULL.
+if one exists, otherwise it contains the broadcast address.
+.Pp
+Note that as a convenience,
+.Li ifa_broadaddr
+is defined by a compiler
+.Li #define
+directive to be the same as
+.Li ifa_dstaddr .
.Pp
The
.Li ifa_data
-field references address family specific data. For
+field references address family specific data.
+For
.Dv AF_LINK
addresses it contains a pointer to the
.Fa struct if_data
(as defined in include file
-.Aq Pa net/if.h )
+.In net/if.h )
which contains various interface attributes and statistics.
For all other address families, it contains a pointer to the
.Fa struct ifa_data
(as defined in include file
-.Aq Pa net/if.h )
+.In net/if.h )
which contains per-address interface statistics.
.Pp
The data returned by
.Xr malloc 3
or
.Xr sysctl 3 .
-.Sh BUGS
-If both
-.Aq Pa net/if.h
-and
-.Aq Pa ifaddrs.h
-are being included,
-.Aq Pa net/if.h
-.Em must
-be included before
-.Aq Pa ifaddrs.h .
.Sh SEE ALSO
.Xr ioctl 2 ,
.Xr socket 2 ,
.Nm
implementation first appeared in BSDi
.Bsx .
+.Sh BUGS
+If both
+.In net/if.h
+and
+.In ifaddrs.h
+are being included,
+.In net/if.h
+.Em must
+be included before
+.In ifaddrs.h .