source: vendor/emx/current/include/net/if.h

Last change on this file was 18, checked in by bird, 23 years ago

Initial revision

  • Property cvs2svn:cvs-rev set to 1.1
  • Property svn:eol-style set to native
  • Property svn:executable set to *
File size: 12.7 KB
Line 
1/* Modifed for emx by hv 1994,1996
2 *
3 * Copyright (c) 1982, 1986, 1989 Regents of the University of California.
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * 3. All advertising materials mentioning features or use of this software
15 * must display the following acknowledgement:
16 * This product includes software developed by the University of
17 * California, Berkeley and its contributors.
18 * 4. Neither the name of the University nor the names of its contributors
19 * may be used to endorse or promote products derived from this software
20 * without specific prior written permission.
21 *
22 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
23 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
26 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 * SUCH DAMAGE.
33 *
34 * from: @(#)if.h 7.11 (Berkeley) 3/19/91
35 * $Id: if.h,v 1.7 1994/02/10 17:16:33 mycroft Exp $
36 */
37
38#ifndef _NET_IF_H_
39#define _NET_IF_H_
40
41#if defined (__cplusplus)
42extern "C" {
43#endif
44
45/*
46 * Structures defining a network interface, providing a packet
47 * transport mechanism (ala level 0 of the PUP protocols).
48 *
49 * Each interface accepts output datagrams of a specified maximum
50 * length, and provides higher level routines with input datagrams
51 * received from its medium.
52 *
53 * Output occurs when the routine if_output is called, with three parameters:
54 * (*ifp->if_output)(ifp, m, dst)
55 * Here m is the mbuf chain to be sent and dst is the destination address.
56 * The output routine encapsulates the supplied datagram if necessary,
57 * and then transmits it on its medium.
58 *
59 * On input, each interface unwraps the data received by it, and either
60 * places it on the input queue of a internetwork datagram routine
61 * and posts the associated software interrupt, or passes the datagram to a raw
62 * packet input routine.
63 *
64 * Routines exist for locating interfaces by their addresses
65 * or for locating a interface on a certain network, as well as more general
66 * routing and gateway routines maintaining information used to locate
67 * interfaces. These routines live in the files if.c and route.c
68 */
69/* XXX fast fix for SNMP, going away soon */
70#include <sys/time.h>
71
72#ifdef TCPIPV4
73#pragma pack(1)
74#else
75#pragma pack(4)
76#endif
77
78
79/*
80 * Structure defining a queue for a network interface.
81 *
82 * (Would like to call this struct ``if'', but C isn't PL/1.)
83 */
84/*forward*/ struct mbuf;
85/*forward*/ struct ifaddr;
86struct ifnet {
87 char *if_name; /* name, e.g. ``en'' or ``lo'' */
88 short if_unit; /* sub-unit for lower level driver */
89 short if_mtu; /* maximum transmission unit */
90 short if_flags; /* up/down, broadcast, etc. */
91 short if_timer; /* time 'til if_watchdog called */
92 int if_metric; /* routing metric (external only) */
93 struct ifaddr *if_addrlist; /* linked list of addresses per if */
94 struct ifqueue {
95 struct mbuf *ifq_head;
96 struct mbuf *ifq_tail;
97#ifndef TCPIPV4
98 int ifq_len;
99 int ifq_maxlen;
100 int ifq_drops;
101#else
102 short ifq_len;
103 short ifq_maxlen;
104 u_short ifq_drops;
105#endif
106 } if_snd; /* output queue */
107/* procedure handles */
108 int (*if_init)(void); /* IBMSOCKETS */
109 int (*if_output)(void); /* output routine (enqueue) */
110 int (*if_ioctl)(void); /* ioctl routine */
111 int (*if_reset)(void); /* bus reset routine */
112 int (*if_watchdog)(void); /* timer routine */
113/* generic interface statistics */
114#ifndef TCPIPV4
115 int if_ipackets; /* packets received on interface */
116 int if_ierrors; /* input errors on interface */
117 int if_opackets; /* packets sent on interface */
118 int if_oerrors; /* output errors on interface */
119 int if_collisions; /* collisions on csma interfaces */
120#else
121 u_short if_ipackets; /* packets received on interface */
122 u_short if_ierrors; /* input errors on interface */
123 u_short if_opackets; /* packets sent on interface */
124 u_short if_oerrors; /* output errors on interface */
125 u_short if_collisions; /* collisions on csma interfaces */
126#endif
127/* end statistics */
128 struct ifnet *if_next;
129
130/* the following structures are special for OS/2 TCP/IP only */
131 u_char if_adapternum; /* adapter number */
132 u_int if_adaptype;
133 u_int if_broadcast;
134 u_long if_speed;
135
136#define IF_RTTSCALE 1000
137 u_short if_rtt; /* Est interface rtt in ms */
138 u_short if_rttvar; /* Est interface rttvar in ms */
139 u_short if_rttmin; /* Fixed interface rttmin in ms */
140 u_short if_sendpipe; /* Send socket buffer/window size */
141 u_short if_recvpipe; /* Recv socket buffer/window size */
142 u_short if_ssthresh; /* Gateway buffer limit (slow strt) */
143#ifdef TCPIPV4
144 u_long if_eflags; /* Extended flags */
145 struct ifqueue if_traceq; /* packet trace queue */
146 u_short if_segsize; /* segment size for interface */
147 u_short if_use576; /* use 576 or 1460 as def. mss if */
148 /* going through a router */
149 u_short if_rfc1469; /* using broadcast or functional */
150 /* addr for IP Multicast */
151#define IFF_RFC1469_BC 1 /* use broadcast */
152#define IFF_RFC1469_FA 2 /* use functional address */
153#define IFF_RFC1469_MA 3 /* use multicast address */
154#endif
155};
156
157#ifndef TCPIPV4
158struct ifmib {
159 int ifNumber; /* number of network interfaces */
160 struct iftable {
161 int ifIndex; /* index of this interface */
162 char ifDescr[45]; /* description */
163 int ifType; /* type of the interface */
164 int ifMtu; /* MTU of the interface */
165 char ifPhysAddr[6]; /* MTU of the interface */
166 int ifOperStatus;
167 u_long ifSpeed;
168 u_long ifLastChange;
169 u_long ifInOctets;
170 u_long ifOutOctets;
171 u_long ifOutDiscards;
172 u_long ifInDiscards;
173 u_long ifInErrors;
174 u_long ifOutErrors;
175 u_long ifInUnknownProtos;
176 u_long ifInUcastPkts;
177 u_long ifOutUcastPkts;
178 u_long ifInNUcastPkts;
179 u_long ifOutNUcastPkts;
180 } iftable[20];
181};
182#else /* TCP/IP V4 */
183
184#ifndef IFMIB_ENTRIES
185#define IFMIB_ENTRIES 42
186#endif
187
188struct ifmib {
189 short ifNumber; /* number of network interfaces */
190 struct iftable {
191 short ifIndex; /* index of this interface */
192 char ifDescr[45]; /* description */
193 short ifType; /* type of the interface */
194 short ifMtu; /* MTU of the interface */
195 char ifPhysAddr[6]; /* MTU of the interface */
196 short ifOperStatus;
197 u_long ifSpeed;
198 u_long ifLastChange;
199 u_long ifInOctets;
200 u_long ifOutOctets;
201 u_long ifOutDiscards;
202 u_long ifInDiscards;
203 u_long ifInErrors;
204 u_long ifOutErrors;
205 u_long ifInUnknownProtos;
206 u_long ifInUcastPkts;
207 u_long ifOutUcastPkts;
208 u_long ifInNUcastPkts;
209 u_long ifOutNUcastPkts;
210 } iftable[IFMIB_ENTRIES];
211};
212#endif /* TCP/IP V4 */
213#pragma pack()
214
215#define IFF_UP 0x1 /* interface is up */
216#define IFF_BROADCAST 0x2 /* broadcast address valid */
217#define IFF_DEBUG 0x4 /* turn on debugging */
218#define IFF_LOOPBACK 0x8 /* is a loopback net */
219#define IFF_POINTOPOINT 0x10 /* interface is point-to-point link */
220#define IFF_NOTRAILERS 0x20 /* avoid use of trailers */
221#define IFF_RUNNING 0x40 /* resources allocated */
222#define IFF_NOARP 0x80 /* no address resolution protocol */
223/* next two not supported now, but reserved: */
224#define IFF_PROMISC 0x100 /* receive all packets */
225#define IFF_ALLMULTI 0x200 /* receive all multicast packets */
226#define IFF_OACTIVE 0x400 /* transmission in progress */
227#define IFF_SIMPLEX 0x800 /* can't hear own transmissions */
228#define IFF_BRIDGE 0x1000 /* support token ring routine field */
229#define IFF_SNAP 0x2000 /* support extended SNAP header */
230#define IFF_ETHER 0x4000 /* ethernet interface */
231#define IFF_LOOPBRD 0x8000 /* ethernet interface */
232
233/*hv: flags set internally only */
234#ifdef BSD_TCPCOMPAT
235#define IFF_CANTCHANGE \
236 (IFF_BROADCAST|IFF_POINTOPOINT|IFF_RUNNING|IFF_OACTIVE| \
237 IFF_SIMPLEX|IFF_MULTICAST)
238#else
239#define IFF_CANTCHANGE (IFF_BROADCAST | IFF_POINTOPOINT | IFF_RUNNING)
240#endif
241
242#ifdef TCPIPV4
243/* packet tracing extension */
244#define IFFE_PKTTRACE 0x00000001 /* trace datalink where possible */
245#define IFFE_IPTRACE 0x00000002 /* trace ONLY IP packets */
246
247struct pkt_trace_hdr {
248 u_short pt_htype; /* header type */
249#define HT_IP 0x01 /* IP */
250#define HT_ETHER 0x06 /* Ethernet */
251#define HT_ISO88023 0x07 /* CSMA CD */
252#define HT_ISO88025 0x09 /* Token Ring */
253#define HT_SLIP 0x1c /* Serial Line IP */
254#define HT_PPP 0x18 /* PPP IP */
255 u_short pt_len; /* in: pt_buf len, out: packet len */
256 caddr_t pt_data; /* packet ATTN: This is a _Seg16 addr! */
257 u_long pt_tstamp; /* time stamp in milliseconds */
258};
259
260#endif /* TCP/IP V4 */
261
262/*
263 * Output queues (ifp->if_snd) and internetwork datagram level (pup level 1)
264 * input routines have queues of messages stored on ifqueue structures
265 * (defined above). Entries are added to and deleted from these structures
266 * by these macros, which should be called with ipl raised to splimp().
267 */
268#define IF_QFULL(ifq) ((ifq)->ifq_len >= (ifq)->ifq_maxlen)
269#define IF_DROP(ifq) ((ifq)->ifq_drops++)
270#define IF_ENQUEUE(ifq, m) {\
271 (m)->m_act=0;\
272 if ((ifq)->ifq_tail==0)\
273 (ifq)->ifq_head=m;\
274 else\
275 (ifq)->ifq_tail->m_act=m;\
276 (ifq)->ifq_tail=m;\
277 (ifq)->ifq_len++;\
278}
279#define IF_PREPEND(ifq, m) {\
280 (m)->m_act=(ifq)->ifq_head;\
281 if ((ifq)->ifq_tail==0)\
282 (ifq)->ifq_tail=(m);\
283 (ifq)->ifq_head=(m);\
284 (ifq)->ifq_len++;\
285}
286#define IF_DEQUEUE(ifq, m) {\
287 (m)=(ifq)->ifq_head;\
288 if (m) {\
289 if (((ifq)->ifq_head=(m)->m_act)==0)\
290 (ifq)->ifq_tail=0;\
291 (m)->m_act=0;\
292 (ifq)->ifq_len--;\
293 }\
294}
295#define IF_ADJ(m) {\
296 (m)->m_off+=sizeof(struct ifnet*);\
297 (m)->m_len-=sizeof(struct ifnet*);\
298 if ((m)->m_len==0) {\
299 struct mbuf *n;\
300 MFREE((m), n);\
301 (m) = n;\
302 }\
303}
304#define IF_DEQUEUEIF(ifq, m, ifp) {\
305 (m)=(ifq)->ifq_head;\
306 if (m) {\
307 if (((ifq)->ifq_head=(m)->m_act)==0)\
308 (ifq)->ifq_tail=0;\
309 (m)->m_act=0;\
310 (ifq)->ifq_len--;\
311 (ifp)=*(mtod((m), struct ifnet**));\
312 IF_ADJ(m);\
313 }\
314}
315
316#define IFQ_MAXLEN 50
317#define IFNET_SLOWHZ 1 /* granularity is 1 second */
318
319/*
320 * The ifaddr structure contains information about one address
321 * of an interface. They are maintained by the different address families,
322 * are allocated and attached when an address is set, and are linked
323 * together so all addresses for an interface can be located.
324 */
325struct ifaddr {
326 struct sockaddr ifa_addr; /* address of interface */
327 union {
328 struct sockaddr ifu_broadaddr; /* broadcast address interface */
329 struct sockaddr ifu_dstaddr; /* other end of p-to-p link */
330 } ifa_ifu;
331#define ifa_broadaddr ifa_ifu.ifu_broadaddr
332#define ifa_dstaddr ifa_ifu.ifu_dstaddr
333 struct ifnet *ifa_ifp; /* back-pointer to interface */
334 struct ifaddr *ifa_next; /* next address for interface */
335};
336
337/*
338 * Interface request structure used for socket
339 * ioctl's. All interface ioctl's must have parameter
340 * definitions which begin with ifr_name. The
341 * remainder may be interface specific.
342 */
343struct ifreq {
344#define IFNAMSIZ 16
345 char ifr_name[IFNAMSIZ]; /* if name, e.g. "en0" */
346 union {
347 struct sockaddr ifru_addr;
348 struct sockaddr ifru_dstaddr;
349 struct sockaddr ifru_broadaddr;
350 short ifru_flags;
351 int ifru_metric;
352 caddr_t ifru_data;
353 } ifr_ifru;
354#define ifr_addr ifr_ifru.ifru_addr /* address */
355#define ifr_dstaddr ifr_ifru.ifru_dstaddr /* other end of p-to-p link */
356#define ifr_broadaddr ifr_ifru.ifru_broadaddr /* broadcast address */
357#define ifr_flags ifr_ifru.ifru_flags /* flags */
358#define ifr_metric ifr_ifru.ifru_metric /* metric */
359#define ifr_data ifr_ifru.ifru_data /* for use by interface */
360};
361
362/*
363 * Structure used in SIOCGIFCONF request.
364 * Used to retrieve interface configuration
365 * for machine (useful for programs which
366 * must know all networks accessible).
367 */
368struct ifconf {
369 int ifc_len; /* size of associated buffer */
370 union {
371 caddr_t ifcu_buf;
372 struct ifreq *ifcu_req;
373 } ifc_ifcu;
374#define ifc_buf ifc_ifcu.ifcu_buf /* buffer address */
375#define ifc_req ifc_ifcu.ifcu_req /* array of structures returned */
376};
377
378#include <net/if_arp.h>
379
380#if defined (__cplusplus)
381}
382#endif
383
384#endif /* _NET_IF_H_ */
Note: See TracBrowser for help on using the repository browser.