1 |
1633 |
jcastillo |
/* Copyright (C) 1997, 1998 Free Software Foundation, Inc.
|
2 |
|
|
This file is part of the GNU C Library.
|
3 |
|
|
|
4 |
|
|
The GNU C Library is free software; you can redistribute it and/or
|
5 |
|
|
modify it under the terms of the GNU Library General Public License as
|
6 |
|
|
published by the Free Software Foundation; either version 2 of the
|
7 |
|
|
License, or (at your option) any later version.
|
8 |
|
|
|
9 |
|
|
The GNU C Library is distributed in the hope that it will be useful,
|
10 |
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
11 |
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
12 |
|
|
Library General Public License for more details.
|
13 |
|
|
|
14 |
|
|
You should have received a copy of the GNU Library General Public
|
15 |
|
|
License along with the GNU C Library; see the file COPYING.LIB. If not,
|
16 |
|
|
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
17 |
|
|
Boston, MA 02111-1307, USA. */
|
18 |
|
|
|
19 |
|
|
#ifndef _NET_IF_H
|
20 |
|
|
|
21 |
|
|
#define _NET_IF_H 1
|
22 |
|
|
#include <features.h>
|
23 |
|
|
|
24 |
|
|
#include <sys/types.h>
|
25 |
|
|
#include <sys/socket.h>
|
26 |
|
|
|
27 |
|
|
/* Standard interface flags. */
|
28 |
|
|
enum
|
29 |
|
|
{
|
30 |
|
|
IFF_UP = 0x1, /* Interface is up. */
|
31 |
|
|
#define IFF_UP IFF_UP
|
32 |
|
|
IFF_BROADCAST = 0x2, /* Broadcast address valid. */
|
33 |
|
|
#define IFF_BROADCAST IFF_BROADCAST
|
34 |
|
|
IFF_DEBUG = 0x4, /* Turn on debugging. */
|
35 |
|
|
#define IFF_DEBUG IFF_DEBUG
|
36 |
|
|
IFF_LOOPBACK = 0x8, /* Is a loopback net. */
|
37 |
|
|
#define IFF_LOOPBACK IFF_LOOPBACK
|
38 |
|
|
IFF_POINTOPOINT = 0x10, /* Interface is point-to-point link. */
|
39 |
|
|
#define IFF_POINTOPOINT IFF_POINTOPOINT
|
40 |
|
|
IFF_NOTRAILERS = 0x20, /* Avoid use of trailers. */
|
41 |
|
|
#define IFF_NOTRAILERS IFF_NOTRAILERS
|
42 |
|
|
IFF_RUNNING = 0x40, /* Resources allocated. */
|
43 |
|
|
#define IFF_RUNNING IFF_RUNNING
|
44 |
|
|
IFF_NOARP = 0x80, /* No address resolution protocol. */
|
45 |
|
|
#define IFF_NOARP IFF_NOARP
|
46 |
|
|
IFF_PROMISC = 0x100, /* Receive all packets. */
|
47 |
|
|
#define IFF_PROMISC IFF_PROMISC
|
48 |
|
|
|
49 |
|
|
/* Not supported */
|
50 |
|
|
IFF_ALLMULTI = 0x200, /* Receive all multicast packets. */
|
51 |
|
|
#define IFF_ALLMULTI IFF_ALLMULTI
|
52 |
|
|
|
53 |
|
|
IFF_MASTER = 0x400, /* Master of a load balancer. */
|
54 |
|
|
#define IFF_MASTER IFF_MASTER
|
55 |
|
|
IFF_SLAVE = 0x800, /* Slave of a load balancer. */
|
56 |
|
|
#define IFF_SLAVE IFF_SLAVE
|
57 |
|
|
|
58 |
|
|
IFF_MULTICAST = 0x1000, /* Supports multicast. */
|
59 |
|
|
#define IFF_MULTICAST IFF_MULTICAST
|
60 |
|
|
|
61 |
|
|
IFF_PORTSEL = 0x2000, /* Can set media type. */
|
62 |
|
|
#define IFF_PORTSEL IFF_PORTSEL
|
63 |
|
|
IFF_AUTOMEDIA = 0x4000 /* Auto media select active. */
|
64 |
|
|
#define IFF_AUTOMEDIA IFF_AUTOMEDIA
|
65 |
|
|
};
|
66 |
|
|
|
67 |
|
|
/* The ifaddr structure contains information about one address of an
|
68 |
|
|
interface. They are maintained by the different address families,
|
69 |
|
|
are allocated and attached when an address is set, and are linked
|
70 |
|
|
together so all addresses for an interface can be located. */
|
71 |
|
|
|
72 |
|
|
struct ifaddr
|
73 |
|
|
{
|
74 |
|
|
struct sockaddr ifa_addr; /* Address of interface. */
|
75 |
|
|
union
|
76 |
|
|
{
|
77 |
|
|
struct sockaddr ifu_broadaddr;
|
78 |
|
|
struct sockaddr ifu_dstaddr;
|
79 |
|
|
} ifa_ifu;
|
80 |
|
|
struct iface *ifa_ifp; /* Back-pointer to interface. */
|
81 |
|
|
struct ifaddr *ifa_next; /* Next address for interface. */
|
82 |
|
|
};
|
83 |
|
|
|
84 |
|
|
#define ifa_broadaddr ifa_ifu.ifu_broadaddr /* broadcast address */
|
85 |
|
|
#define ifa_dstaddr ifa_ifu.ifu_dstaddr /* other end of link */
|
86 |
|
|
|
87 |
|
|
/* Device mapping structure. I'd just gone off and designed a
|
88 |
|
|
beautiful scheme using only loadable modules with arguments for
|
89 |
|
|
driver options and along come the PCMCIA people 8)
|
90 |
|
|
|
91 |
|
|
Ah well. The get() side of this is good for WDSETUP, and it'll be
|
92 |
|
|
handy for debugging things. The set side is fine for now and being
|
93 |
|
|
very small might be worth keeping for clean configuration. */
|
94 |
|
|
|
95 |
|
|
struct ifmap
|
96 |
|
|
{
|
97 |
|
|
unsigned long int mem_start;
|
98 |
|
|
unsigned long int mem_end;
|
99 |
|
|
unsigned short int base_addr;
|
100 |
|
|
unsigned char irq;
|
101 |
|
|
unsigned char dma;
|
102 |
|
|
unsigned char port;
|
103 |
|
|
/* 3 bytes spare */
|
104 |
|
|
};
|
105 |
|
|
|
106 |
|
|
/* Interface request structure used for socket ioctl's. All interface
|
107 |
|
|
ioctl's must have parameter definitions which begin with ifr_name.
|
108 |
|
|
The remainder may be interface specific. */
|
109 |
|
|
|
110 |
|
|
struct ifreq
|
111 |
|
|
{
|
112 |
|
|
#define IFHWADDRLEN 6
|
113 |
|
|
#define IFNAMSIZ 16
|
114 |
|
|
union
|
115 |
|
|
{
|
116 |
|
|
char ifrn_name[IFNAMSIZ]; /* Interface name, e.g. "en0". */
|
117 |
|
|
} ifr_ifrn;
|
118 |
|
|
|
119 |
|
|
union
|
120 |
|
|
{
|
121 |
|
|
struct sockaddr ifru_addr;
|
122 |
|
|
struct sockaddr ifru_dstaddr;
|
123 |
|
|
struct sockaddr ifru_broadaddr;
|
124 |
|
|
struct sockaddr ifru_netmask;
|
125 |
|
|
struct sockaddr ifru_hwaddr;
|
126 |
|
|
short int ifru_flags;
|
127 |
|
|
int ifru_ivalue;
|
128 |
|
|
int ifru_mtu;
|
129 |
|
|
struct ifmap ifru_map;
|
130 |
|
|
char ifru_slave[IFNAMSIZ]; /* Just fits the size */
|
131 |
|
|
__caddr_t ifru_data;
|
132 |
|
|
} ifr_ifru;
|
133 |
|
|
};
|
134 |
|
|
|
135 |
|
|
#define ifr_name ifr_ifrn.ifrn_name /* interface name */
|
136 |
|
|
#define ifr_hwaddr ifr_ifru.ifru_hwaddr /* MAC address */
|
137 |
|
|
#define ifr_addr ifr_ifru.ifru_addr /* address */
|
138 |
|
|
#define ifr_dstaddr ifr_ifru.ifru_dstaddr /* other end of p-p lnk */
|
139 |
|
|
#define ifr_broadaddr ifr_ifru.ifru_broadaddr /* broadcast address */
|
140 |
|
|
#define ifr_netmask ifr_ifru.ifru_netmask /* interface net mask */
|
141 |
|
|
#define ifr_flags ifr_ifru.ifru_flags /* flags */
|
142 |
|
|
#define ifr_metric ifr_ifru.ifru_ivalue /* metric */
|
143 |
|
|
#define ifr_mtu ifr_ifru.ifru_mtu /* mtu */
|
144 |
|
|
#define ifr_map ifr_ifru.ifru_map /* device map */
|
145 |
|
|
#define ifr_slave ifr_ifru.ifru_slave /* slave device */
|
146 |
|
|
#define ifr_data ifr_ifru.ifru_data /* for use by interface */
|
147 |
|
|
#define ifr_ifindex ifr_ifru.ifru_ivalue /* interface index */
|
148 |
|
|
|
149 |
|
|
|
150 |
|
|
/* Structure used in SIOCGIFCONF request. Used to retrieve interface
|
151 |
|
|
configuration for machine (useful for programs which must know all
|
152 |
|
|
networks accessible). */
|
153 |
|
|
|
154 |
|
|
struct ifconf
|
155 |
|
|
{
|
156 |
|
|
int ifc_len; /* Size of buffer. */
|
157 |
|
|
union
|
158 |
|
|
{
|
159 |
|
|
__caddr_t ifcu_buf;
|
160 |
|
|
struct ifreq *ifcu_req;
|
161 |
|
|
} ifc_ifcu;
|
162 |
|
|
};
|
163 |
|
|
#define ifc_buf ifc_ifcu.ifcu_buf /* Buffer address. */
|
164 |
|
|
#define ifc_req ifc_ifcu.ifcu_req /* Array of structures. */
|
165 |
|
|
|
166 |
|
|
#endif /* net/if.h */
|