diff options
Diffstat (limited to 'src/lib/libc/net/getifaddrs.3')
| -rw-r--r-- | src/lib/libc/net/getifaddrs.3 | 159 |
1 files changed, 159 insertions, 0 deletions
diff --git a/src/lib/libc/net/getifaddrs.3 b/src/lib/libc/net/getifaddrs.3 new file mode 100644 index 0000000000..9287b3b734 --- /dev/null +++ b/src/lib/libc/net/getifaddrs.3 | |||
| @@ -0,0 +1,159 @@ | |||
| 1 | .\" $OpenBSD: getifaddrs.3,v 1.10 2003/05/30 21:37:59 jmc Exp $ | ||
| 2 | .\" BSDI getifaddrs.3,v 2.5 2000/02/23 14:51:59 dab Exp | ||
| 3 | .\" | ||
| 4 | .\" Copyright (c) 1995, 1999 | ||
| 5 | .\" Berkeley Software Design, Inc. All rights reserved. | ||
| 6 | .\" | ||
| 7 | .\" Redistribution and use in source and binary forms, with or without | ||
| 8 | .\" modification, are permitted provided that the following conditions | ||
| 9 | .\" are met: | ||
| 10 | .\" 1. Redistributions of source code must retain the above copyright | ||
| 11 | .\" notice, this list of conditions and the following disclaimer. | ||
| 12 | .\" | ||
| 13 | .\" THIS SOFTWARE IS PROVIDED BY Berkeley Software Design, Inc. ``AS IS'' AND | ||
| 14 | .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
| 15 | .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
| 16 | .\" ARE DISCLAIMED. IN NO EVENT SHALL Berkeley Software Design, Inc. BE LIABLE | ||
| 17 | .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
| 18 | .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
| 19 | .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
| 20 | .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
| 21 | .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
| 22 | .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
| 23 | .\" SUCH DAMAGE. | ||
| 24 | .Dd October 12, 1995 | ||
| 25 | .Dt GETIFADDRS 3 | ||
| 26 | .Os | ||
| 27 | .Sh NAME | ||
| 28 | .Nm getifaddrs | ||
| 29 | .Nd get interface addresses | ||
| 30 | .Sh SYNOPSIS | ||
| 31 | .Fd #include <sys/types.h> | ||
| 32 | .Fd #include <sys/socket.h> | ||
| 33 | .Fd #include <ifaddrs.h> | ||
| 34 | .Ft int | ||
| 35 | .Fn getifaddrs "struct ifaddrs **ifap" | ||
| 36 | .Ft void | ||
| 37 | .Fn freeifaddrs "struct ifaddrs *ifap" | ||
| 38 | .Sh DESCRIPTION | ||
| 39 | The | ||
| 40 | .Fn getifaddrs | ||
| 41 | function stores a reference to a linked list of the network interfaces | ||
| 42 | on the local machine in the memory referenced by | ||
| 43 | .Fa ifap . | ||
| 44 | The list consists of | ||
| 45 | .Nm ifaddrs | ||
| 46 | structures, as defined in the include file | ||
| 47 | .Aq Pa ifaddrs.h . | ||
| 48 | The | ||
| 49 | .Nm ifaddrs | ||
| 50 | structure contains at least the following entries: | ||
| 51 | .Bd -literal | ||
| 52 | struct ifaddrs *ifa_next; /* Pointer to next struct */ | ||
| 53 | char *ifa_name; /* Interface name */ | ||
| 54 | u_int ifa_flags; /* Interface flags */ | ||
| 55 | struct sockaddr *ifa_addr; /* Interface address */ | ||
| 56 | struct sockaddr *ifa_netmask; /* Interface netmask */ | ||
| 57 | struct sockaddr *ifa_broadaddr; /* Interface broadcast address */ | ||
| 58 | struct sockaddr *ifa_dstaddr; /* P2P interface destination */ | ||
| 59 | void *ifa_data; /* Address specific data */ | ||
| 60 | .Ed | ||
| 61 | .Pp | ||
| 62 | .Bl -tag -width Ds | ||
| 63 | .It Fa ifa_next | ||
| 64 | Contains a pointer to the next structure on the list. | ||
| 65 | This field is set to | ||
| 66 | .Dv NULL | ||
| 67 | in last structure on the list. | ||
| 68 | .It Fa ifa_name | ||
| 69 | Contains the interface name. | ||
| 70 | .It Fa ifa_flags | ||
| 71 | Contains the interface flags, as set by | ||
| 72 | .Xr ifconfig 8 . | ||
| 73 | .It Fa ifa_addr | ||
| 74 | References either the address of the interface or the link level | ||
| 75 | address of the interface, if one exists, otherwise it is | ||
| 76 | .Dv NULL . | ||
| 77 | (The | ||
| 78 | .Fa sa_family | ||
| 79 | field of the | ||
| 80 | .Fa ifa_addr | ||
| 81 | field should be consulted to determine the format of the | ||
| 82 | .Fa ifa_addr | ||
| 83 | address.) | ||
| 84 | .It Fa ifa_netmask | ||
| 85 | References the netmask associated with | ||
| 86 | .Fa ifa_addr , | ||
| 87 | if one is set, otherwise it is | ||
| 88 | .Dv NULL . | ||
| 89 | .It Fa ifa_broadaddr | ||
| 90 | This field, which should only be referenced for non-P2P interfaces, | ||
| 91 | references the broadcast address associated with | ||
| 92 | .Fa ifa_addr , | ||
| 93 | if one exists, otherwise it is | ||
| 94 | .Dv NULL . | ||
| 95 | .It Fa ifa_dstaddr | ||
| 96 | References the destination address on a P2P interface, | ||
| 97 | if one exists, otherwise it is | ||
| 98 | .Dv NULL . | ||
| 99 | .It Fa ifa_data | ||
| 100 | References address family specific data. | ||
| 101 | For | ||
| 102 | .Dv AF_LINK | ||
| 103 | addresses it contains a pointer to the | ||
| 104 | .Li struct if_data | ||
| 105 | (as defined in include file | ||
| 106 | .Aq Pa net/if.h ) | ||
| 107 | which contains various interface attributes and statistics. | ||
| 108 | For all other address families, it contains a pointer to the | ||
| 109 | .Li struct ifa_data | ||
| 110 | (as defined in include file | ||
| 111 | .Aq Pa net/if.h ) | ||
| 112 | which contains per-address interface statistics. | ||
| 113 | .El | ||
| 114 | .Pp | ||
| 115 | The data returned by | ||
| 116 | .Fn getifaddrs | ||
| 117 | is dynamically allocated and should be freed using | ||
| 118 | .Fn freeifaddrs | ||
| 119 | when no longer needed. | ||
| 120 | .Sh RETURN VALUES | ||
| 121 | Upon successful completion, a value of 0 is returned. | ||
| 122 | Otherwise, a value of \-1 is returned and | ||
| 123 | .Va errno | ||
| 124 | is set to indicate the error. | ||
| 125 | .Sh ERRORS | ||
| 126 | The | ||
| 127 | .Fn getifaddrs | ||
| 128 | may fail and set | ||
| 129 | .Va errno | ||
| 130 | for any of the errors specified for the library routines | ||
| 131 | .Xr ioctl 2 , | ||
| 132 | .Xr socket 2 , | ||
| 133 | .Xr malloc 3 , | ||
| 134 | or | ||
| 135 | .Xr sysctl 3 . | ||
| 136 | .Sh SEE ALSO | ||
| 137 | .Xr ioctl 2 , | ||
| 138 | .Xr socket 2 , | ||
| 139 | .Xr sysctl 3 , | ||
| 140 | .Xr networking 4 , | ||
| 141 | .Xr ifconfig 8 | ||
| 142 | .Sh HISTORY | ||
| 143 | The | ||
| 144 | .Fn getifaddrs | ||
| 145 | function first appeared in BSDI BSD/OS. | ||
| 146 | The function is supplied on | ||
| 147 | .Ox | ||
| 148 | since | ||
| 149 | .Ox 2.7 . | ||
| 150 | .Sh BUGS | ||
| 151 | If both | ||
| 152 | .Aq Pa net/if.h | ||
| 153 | and | ||
| 154 | .Aq Pa ifaddrs.h | ||
| 155 | are being included, | ||
| 156 | .Aq Pa net/if.h | ||
| 157 | .Em must | ||
| 158 | be included before | ||
| 159 | .Aq Pa ifaddrs.h . | ||
