xref: /freebsd/lib/libc/net/getifmaddrs.3 (revision 61e21613)
1.\" Copyright (c) 2003 Bruce M. Simpson. All rights reserved.
2.\"
3.\" Redistribution and use in source and binary forms, with or without
4.\" modification, are permitted provided that the following conditions
5.\" are met:
6.\" 1. Redistributions of source code must retain the above copyright
7.\"    notice, this list of conditions and the following disclaimer.
8.\"
9.\" THIS SOFTWARE IS PROVIDED BY Bruce M. Simpson ``AS IS'' AND
10.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
11.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
12.\" ARE DISCLAIMED.  IN NO EVENT SHALL Bruce M. Simpson BE LIABLE
13.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
14.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
15.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
16.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
17.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
18.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
19.\" SUCH DAMAGE.
20.\"
21.Dd May 21, 2013
22.Dt GETIFMADDRS 3
23.Os
24.Sh NAME
25.Nm getifmaddrs
26.Nd get multicast group memberships
27.Sh SYNOPSIS
28.In ifaddrs.h
29.Ft int
30.Fn getifmaddrs "struct ifmaddrs **ifmap"
31.Ft void
32.Fn freeifmaddrs "struct ifmaddrs *ifmp"
33.Sh DESCRIPTION
34The
35.Fn getifmaddrs
36function stores a reference to a linked list of the multicast memberships
37on the local machine in the memory referenced by
38.Fa ifmap .
39The list consists of
40.Vt ifmaddrs
41structures, as defined in the include file
42.In ifaddrs.h .
43The
44.Vt ifmaddrs
45structure contains at least the following entries:
46.Bd -literal
47    struct ifmaddrs   *ifma_next;     /* Pointer to next struct */
48    struct sockaddr   *ifma_name;     /* Interface name (AF_LINK) */
49    struct sockaddr   *ifma_addr;     /* Multicast address */
50    struct sockaddr   *ifma_lladdr;   /* Link-layer translation, if any */
51.Ed
52.Pp
53The
54.Va ifma_next
55field contains a pointer to the next structure on the list.
56This field is
57.Dv NULL
58in last structure on the list.
59.Pp
60The
61.Va ifma_name
62field references an
63.Dv AF_LINK
64address structure, containing the name of the
65interface where the membership exists.
66.Pp
67The
68.Va ifma_addr
69references the address that this membership is for.
70.Pp
71The
72.Va ifma_lladdr
73field references a link-layer translation for the protocol-level address in
74.Va ifma_addr ,
75if one is set, otherwise it is
76.Dv NULL .
77.Pp
78The data returned by
79.Fn getifmaddrs
80is dynamically allocated and should be freed using
81.Fn freeifmaddrs
82when no longer needed.
83.Sh RETURN VALUES
84.Rv -std getifmaddrs
85.Sh ERRORS
86The
87.Fn getifmaddrs
88may fail and set
89.Va errno
90for any of the errors specified for the library routines
91.Xr malloc 3
92or
93.Xr sysctl 3 .
94.Sh SEE ALSO
95.Xr sysctl 3 ,
96.Xr networking 4 ,
97.Xr ifconfig 8
98.Sh HISTORY
99The
100.Fn getifmaddrs
101function first appeared in
102.Fx 5.2 .
103.Sh BUGS
104If both
105.In net/if.h
106and
107.In ifaddrs.h
108are being included,
109.In net/if.h
110.Em must
111be included before
112.In ifaddrs.h .
113