]> git.ipfire.org Git - thirdparty/glibc.git/blame - sysdeps/gnu/net/if.h
Update copyright dates with scripts/update-copyrights.
[thirdparty/glibc.git] / sysdeps / gnu / net / if.h
CommitLineData
4f173e2c 1/* net/if.h -- declarations for inquiring about network interfaces
04277e02 2 Copyright (C) 1997-2019 Free Software Foundation, Inc.
df4ef2ab
UD
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
41bdb6e2
AJ
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
df4ef2ab
UD
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
41bdb6e2 13 Lesser General Public License for more details.
df4ef2ab 14
41bdb6e2 15 You should have received a copy of the GNU Lesser General Public
59ba27a6
PE
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
df4ef2ab
UD
18
19#ifndef _NET_IF_H
df4ef2ab 20#define _NET_IF_H 1
84d7b1ea 21
df4ef2ab
UD
22#include <features.h>
23
84d7b1ea
UD
24#ifdef __USE_MISC
25# include <sys/types.h>
26# include <sys/socket.h>
27#endif
28
29
30/* Length of interface name. */
31#define IF_NAMESIZE 16
32
33struct if_nameindex
34 {
35 unsigned int if_index; /* 1, 2, ... */
36 char *if_name; /* null terminated name: "eth0", ... */
37 };
38
df4ef2ab 39
84d7b1ea 40#ifdef __USE_MISC
df4ef2ab
UD
41/* Standard interface flags. */
42enum
43 {
44 IFF_UP = 0x1, /* Interface is up. */
84d7b1ea 45# define IFF_UP IFF_UP
df4ef2ab 46 IFF_BROADCAST = 0x2, /* Broadcast address valid. */
84d7b1ea 47# define IFF_BROADCAST IFF_BROADCAST
df4ef2ab 48 IFF_DEBUG = 0x4, /* Turn on debugging. */
84d7b1ea 49# define IFF_DEBUG IFF_DEBUG
df4ef2ab 50 IFF_LOOPBACK = 0x8, /* Is a loopback net. */
84d7b1ea 51# define IFF_LOOPBACK IFF_LOOPBACK
df4ef2ab 52 IFF_POINTOPOINT = 0x10, /* Interface is point-to-point link. */
84d7b1ea 53# define IFF_POINTOPOINT IFF_POINTOPOINT
df4ef2ab 54 IFF_NOTRAILERS = 0x20, /* Avoid use of trailers. */
84d7b1ea 55# define IFF_NOTRAILERS IFF_NOTRAILERS
df4ef2ab 56 IFF_RUNNING = 0x40, /* Resources allocated. */
84d7b1ea 57# define IFF_RUNNING IFF_RUNNING
df4ef2ab 58 IFF_NOARP = 0x80, /* No address resolution protocol. */
84d7b1ea 59# define IFF_NOARP IFF_NOARP
df4ef2ab 60 IFF_PROMISC = 0x100, /* Receive all packets. */
84d7b1ea 61# define IFF_PROMISC IFF_PROMISC
74015205 62
df4ef2ab
UD
63 /* Not supported */
64 IFF_ALLMULTI = 0x200, /* Receive all multicast packets. */
84d7b1ea 65# define IFF_ALLMULTI IFF_ALLMULTI
df4ef2ab
UD
66
67 IFF_MASTER = 0x400, /* Master of a load balancer. */
84d7b1ea 68# define IFF_MASTER IFF_MASTER
df4ef2ab 69 IFF_SLAVE = 0x800, /* Slave of a load balancer. */
84d7b1ea 70# define IFF_SLAVE IFF_SLAVE
df4ef2ab 71
9a0a462c 72 IFF_MULTICAST = 0x1000, /* Supports multicast. */
84d7b1ea 73# define IFF_MULTICAST IFF_MULTICAST
9a0a462c
UD
74
75 IFF_PORTSEL = 0x2000, /* Can set media type. */
84d7b1ea 76# define IFF_PORTSEL IFF_PORTSEL
1d62ae8a 77 IFF_AUTOMEDIA = 0x4000, /* Auto media select active. */
84d7b1ea 78# define IFF_AUTOMEDIA IFF_AUTOMEDIA
1d62ae8a
RM
79 IFF_DYNAMIC = 0x8000 /* Dialup device with changing addresses. */
80# define IFF_DYNAMIC IFF_DYNAMIC
df4ef2ab
UD
81 };
82
83/* The ifaddr structure contains information about one address of an
84 interface. They are maintained by the different address families,
85 are allocated and attached when an address is set, and are linked
86 together so all addresses for an interface can be located. */
87
88struct ifaddr
89 {
90 struct sockaddr ifa_addr; /* Address of interface. */
91 union
92 {
93 struct sockaddr ifu_broadaddr;
94 struct sockaddr ifu_dstaddr;
95 } ifa_ifu;
96 struct iface *ifa_ifp; /* Back-pointer to interface. */
97 struct ifaddr *ifa_next; /* Next address for interface. */
98 };
99
84d7b1ea
UD
100# define ifa_broadaddr ifa_ifu.ifu_broadaddr /* broadcast address */
101# define ifa_dstaddr ifa_ifu.ifu_dstaddr /* other end of link */
df4ef2ab
UD
102
103/* Device mapping structure. I'd just gone off and designed a
104 beautiful scheme using only loadable modules with arguments for
105 driver options and along come the PCMCIA people 8)
106
107 Ah well. The get() side of this is good for WDSETUP, and it'll be
108 handy for debugging things. The set side is fine for now and being
109 very small might be worth keeping for clean configuration. */
110
111struct ifmap
112 {
113 unsigned long int mem_start;
114 unsigned long int mem_end;
115 unsigned short int base_addr;
116 unsigned char irq;
117 unsigned char dma;
118 unsigned char port;
119 /* 3 bytes spare */
120 };
121
122/* Interface request structure used for socket ioctl's. All interface
123 ioctl's must have parameter definitions which begin with ifr_name.
124 The remainder may be interface specific. */
125
126struct ifreq
127 {
84d7b1ea
UD
128# define IFHWADDRLEN 6
129# define IFNAMSIZ IF_NAMESIZE
df4ef2ab
UD
130 union
131 {
132 char ifrn_name[IFNAMSIZ]; /* Interface name, e.g. "en0". */
133 } ifr_ifrn;
134
135 union
136 {
137 struct sockaddr ifru_addr;
138 struct sockaddr ifru_dstaddr;
139 struct sockaddr ifru_broadaddr;
140 struct sockaddr ifru_netmask;
141 struct sockaddr ifru_hwaddr;
142 short int ifru_flags;
9d187dd4 143 int ifru_ivalue;
df4ef2ab
UD
144 int ifru_mtu;
145 struct ifmap ifru_map;
146 char ifru_slave[IFNAMSIZ]; /* Just fits the size */
0f6b172f 147 char ifru_newname[IFNAMSIZ];
df4ef2ab
UD
148 __caddr_t ifru_data;
149 } ifr_ifru;
150 };
84d7b1ea
UD
151# define ifr_name ifr_ifrn.ifrn_name /* interface name */
152# define ifr_hwaddr ifr_ifru.ifru_hwaddr /* MAC address */
153# define ifr_addr ifr_ifru.ifru_addr /* address */
154# define ifr_dstaddr ifr_ifru.ifru_dstaddr /* other end of p-p lnk */
155# define ifr_broadaddr ifr_ifru.ifru_broadaddr /* broadcast address */
156# define ifr_netmask ifr_ifru.ifru_netmask /* interface net mask */
157# define ifr_flags ifr_ifru.ifru_flags /* flags */
158# define ifr_metric ifr_ifru.ifru_ivalue /* metric */
159# define ifr_mtu ifr_ifru.ifru_mtu /* mtu */
160# define ifr_map ifr_ifru.ifru_map /* device map */
161# define ifr_slave ifr_ifru.ifru_slave /* slave device */
162# define ifr_data ifr_ifru.ifru_data /* for use by interface */
163# define ifr_ifindex ifr_ifru.ifru_ivalue /* interface index */
164# define ifr_bandwidth ifr_ifru.ifru_ivalue /* link bandwidth */
165# define ifr_qlen ifr_ifru.ifru_ivalue /* queue length */
166# define ifr_newname ifr_ifru.ifru_newname /* New name */
da0debaa
UD
167# define _IOT_ifreq _IOT(_IOTS(char),IFNAMSIZ,_IOTS(char),16,0,0)
168# define _IOT_ifreq_short _IOT(_IOTS(char),IFNAMSIZ,_IOTS(short),1,0,0)
169# define _IOT_ifreq_int _IOT(_IOTS(char),IFNAMSIZ,_IOTS(int),1,0,0)
df4ef2ab
UD
170
171
172/* Structure used in SIOCGIFCONF request. Used to retrieve interface
173 configuration for machine (useful for programs which must know all
174 networks accessible). */
175
176struct ifconf
177 {
178 int ifc_len; /* Size of buffer. */
179 union
180 {
181 __caddr_t ifcu_buf;
182 struct ifreq *ifcu_req;
183 } ifc_ifcu;
184 };
84d7b1ea
UD
185# define ifc_buf ifc_ifcu.ifcu_buf /* Buffer address. */
186# define ifc_req ifc_ifcu.ifcu_req /* Array of structures. */
187# define _IOT_ifconf _IOT(_IOTS(struct ifconf),1,0,0,0,0) /* not right */
188#endif /* Misc. */
df4ef2ab 189
f43ce637 190__BEGIN_DECLS
1f205a47
UD
191
192/* Convert an interface name to an index, and vice versa. */
a784e502 193extern unsigned int if_nametoindex (const char *__ifname) __THROW;
4d3a563f 194extern char *if_indextoname (unsigned int __ifindex, char *__ifname) __THROW;
1f205a47
UD
195
196/* Return a list of all interfaces and their indices. */
4d3a563f 197extern struct if_nameindex *if_nameindex (void) __THROW;
1f205a47
UD
198
199/* Free the data returned from if_nameindex. */
4d3a563f 200extern void if_freenameindex (struct if_nameindex *__ptr) __THROW;
1f205a47 201
f43ce637
UD
202__END_DECLS
203
df4ef2ab 204#endif /* net/if.h */