source: trunk/src/emx/include/net/if.h@ 1303

Last change on this file since 1303 was 183, checked in by bird, 23 years ago

#434: Initial tcpip header merges.

  • Property cvs2svn:cvs-rev set to 1.2
  • Property svn:eol-style set to native
  • Property svn:executable set to *
File size: 18.8 KB
Line 
1/* Modifed for emx by hv 1994,1996
2 * Modified for gcc/os2 by bird 2003
3 *
4 * Copyright (c) 1982, 1986, 1989 Regents of the University of California.
5 * 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 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * 3. All advertising materials mentioning features or use of this software
16 * must display the following acknowledgement:
17 * This product includes software developed by the University of
18 * California, Berkeley and its contributors.
19 * 4. Neither the name of the University nor the names of its contributors
20 * may be used to endorse or promote products derived from this software
21 * without specific prior written permission.
22 *
23 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
24 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
27 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
29 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
32 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33 * SUCH DAMAGE.
34 *
35 * from: @(#)if.h 7.11 (Berkeley) 3/19/91
36 * $Id: if.h,v 1.7 1994/02/10 17:16:33 mycroft Exp $
37 */
38
39#ifndef _NET_IF_H_
40#define _NET_IF_H_
41
42#if defined (__cplusplus)
43extern "C" {
44#endif
45
46/* XXX fast fix for SNMP, going away soon */
47#include <sys/time.h>
48
49
50#ifdef TCPV40HDRS
51/*
52 * Structures defining a network interface, providing a packet
53 * transport mechanism (ala level 0 of the PUP protocols).
54 *
55 * Each interface accepts output datagrams of a specified maximum
56 * length, and provides higher level routines with input datagrams
57 * received from its medium.
58 *
59 * Output occurs when the routine if_output is called, with three parameters:
60 * (*ifp->if_output)(ifp, m, dst)
61 * Here m is the mbuf chain to be sent and dst is the destination address.
62 * The output routine encapsulates the supplied datagram if necessary,
63 * and then transmits it on its medium.
64 *
65 * On input, each interface unwraps the data received by it, and either
66 * places it on the input queue of a internetwork datagram routine
67 * and posts the associated software interrupt, or passes the datagram to a raw
68 * packet input routine.
69 *
70 * Routines exist for locating interfaces by their addresses
71 * or for locating a interface on a certain network, as well as more general
72 * routing and gateway routines maintaining information used to locate
73 * interfaces. These routines live in the files if.c and route.c
74 */
75
76/*
77 * Structure defining a queue for a network interface.
78 *
79 * (Would like to call this struct ``if'', but C isn't PL/1.)
80 */
81#pragma pack(1)
82struct mbuf;
83struct ifaddr;
84struct ifnet {
85 char *if_name; /* name, e.g. ``en'' or ``lo'' */
86 short if_unit; /* sub-unit for lower level driver */
87 short if_mtu; /* maximum transmission unit */
88 short if_flags; /* up/down, broadcast, etc. */
89 short if_timer; /* time 'til if_watchdog called */
90 int if_metric; /* routing metric (external only) */
91 struct ifaddr *if_addrlist; /* linked list of addresses per if */
92 struct ifqueue {
93 struct mbuf *ifq_head;
94 struct mbuf *ifq_tail;
95 short ifq_len;
96 short ifq_maxlen;
97 u_short ifq_drops;
98 } if_snd; /* output queue */
99/* procedure handles */
100 int (*if_init)(void); /* IBMSOCKETS */
101 int (*if_output)(void); /* output routine (enqueue) */
102 int (*if_ioctl)(void); /* ioctl routine */
103 int (*if_reset)(void); /* bus reset routine */
104 int (*if_watchdog)(void); /* timer routine */
105/* generic interface statistics */
106 u_short if_ipackets; /* packets received on interface */
107 u_short if_ierrors; /* input errors on interface */
108 u_short if_opackets; /* packets sent on interface */
109 u_short if_oerrors; /* output errors on interface */
110 u_short if_collisions; /* collisions on csma interfaces */
111/* end statistics */
112 struct ifnet *if_next;
113
114#ifdef __OS2__
115/* the following structures are special for OS/2 TCP/IP only */
116 u_char if_adapternum; /* adapter number */
117 u_int if_adaptype;
118 u_int if_broadcast;
119 u_long if_speed;
120
121 /* Interface TCP estimates/controls. Serves the same */
122 /* purpose as the per-route values in BSD-Reno, but I didn't */
123 /* have to touch any of the route manipulation code. */
124 u_short if_rtt; /* Est interface rtt in ms */
125 u_short if_rttvar; /* Est interface rttvar in ms */
126 u_short if_rttmin; /* Fixed interface rttmin in ms */
127 u_short if_sendpipe; /* Send socket buffer/window size */
128 u_short if_recvpipe; /* Recv socket buffer/window size */
129 u_short if_ssthresh; /* Gateway buffer limit (slow strt) */
130 u_long if_eflags; /* Extended Flags */
131 struct ifqueue if_traceq; /* packet trace queue */
132 u_short if_segsize; /* segment size for interface*/
133 u_short if_use576; /* use 576 or 1460 as def. mss if going thru a router */
134 /* Token Ring IP multicast flag */
135 u_short if_rfc1469; /* using broadcast or functional address */
136 /* for IP Mulitcast */
137#define IF_RTTSCALE 1000
138#endif /* __OS2__ */
139};
140#pragma pack()
141#endif /*TCPV40HDRS*/
142
143#ifndef IFMIB_ENTRIES
144#define IFMIB_ENTRIES 42
145#endif
146
147#ifdef TCPV40HDRS
148#pragma pack(1)
149struct ifmib {
150 short ifNumber; /* number of network interfaces */
151 struct iftable {
152 short ifIndex; /* index of this interface */
153 char ifDescr[45]; /* description */
154 short ifType; /* type of the interface */
155 short ifMtu; /* MTU of the interface */
156 char ifPhysAddr[6]; /* MTU of the interface */
157 short ifOperStatus;
158 u_long ifSpeed;
159 u_long ifLastChange;
160 u_long ifInOctets;
161 u_long ifOutOctets;
162 u_long ifOutDiscards;
163 u_long ifInDiscards;
164 u_long ifInErrors;
165 u_long ifOutErrors;
166 u_long ifInUnknownProtos;
167 u_long ifInUcastPkts;
168 u_long ifOutUcastPkts;
169 u_long ifInNUcastPkts;
170 u_long ifOutNUcastPkts;
171 } iftable[IFMIB_ENTRIES];
172};
173#pragma pack()
174
175#else /*TCPV40HDRS*/
176
177#pragma pack(1) /* force on doubleword boundary */
178struct iftable {
179 short iftIndex; /* index of this interface */
180 char iftDescr[45]; /* description */
181 short iftType; /* type of the interface */
182 short iftMtu; /* MTU of the interface */
183 char iftPhysAddr[6]; /* MTU of the interface */
184 short iftOperStatus;
185 u_long iftSpeed;
186 u_long iftLastChange;
187 u_long iftInOctets;
188 u_long iftOutOctets;
189 u_long iftOutDiscards;
190 u_long iftInDiscards;
191 u_long iftInErrors;
192 u_long iftOutErrors;
193 u_long iftInUnknownProtos;
194 u_long iftInUcastPkts;
195 u_long iftOutUcastPkts;
196 u_long iftInNUcastPkts;
197 u_long iftOutNUcastPkts;
198};
199struct ifmib {
200 short ifNumber;
201 struct iftable iftable[IFMIB_ENTRIES];
202};
203#pragma pack() /* reset to default packing */
204
205#define IFC_ALLRTSBCAST 0x0001
206#define IFC_802_3 0x0002
207#define IFC_FDDI 0x0004
208#define IFC_NOREDIR 0x0010
209
210#define OPERSTATUS_UP 0x1
211#define OPERSTATUS_DOWN 0x2
212#define OPERSTATUS_TESTING 0x3
213#endif /*TCPV40HDRS*/
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#ifndef TCPV40HDRS
222#define IFF_LINK2 IFF_NOTRAILERS /* was trailers, not used */
223#endif
224#define IFF_RUNNING 0x40 /* resources allocated */
225#define IFF_NOARP 0x80 /* no address resolution protocol */
226#define IFF_PROMISC 0x100 /* receive all packets */
227#define IFF_ALLMULTI 0x200 /* receive all multicast packets */
228#define IFF_DEFMTU 0x400 /* default mtu of 1500 */
229#define IFF_MULTICAST 0x800 /* supports multicast */
230/*
231 * The IFF_MULTICAST flag indicates that the network can support the
232 * transmission and reception of higher-level (e.g., IP) multicast packets.
233 * It is independent of hardware support for multicasting; for example,
234 * point-to-point links or pure broadcast networks may well support
235 * higher-level multicasts.
236 */
237#define IFF_BRIDGE 0x1000 /* support token ring routine field */
238#define IFF_SNAP 0x2000 /* support extended SAP header */
239#define IFF_ETHER 0x4000 /* ethernet interface */
240#define IFF_LOOPBRD 0x8000 /* ethernet interface */
241#ifndef TCPV40HDRS
242#define IFF_SIMPLEX 0x10000 /* can't hear own transmissions */
243#define IFF_OACTIVE 0x20000 /* transmission in progress */
244#define IFF_802_3 0x40000 /* */
245#define IFF_CANONICAL 0x80000 /* */
246#define IFF_RUNNINGBLK 0x100000 /* threads waited for intf running */
247#endif
248
249#define IFF_RFC1469_BC 1 /* using broadcast */
250#define IFF_RFC1469_FA 2 /* using functional address */
251#define IFF_RFC1469_MA 3 /* using mulitcast address */
252
253/*hv: flags set internally only */
254#ifdef TCPV40HDRS
255#define IFF_CANTCHANGE (IFF_BROADCAST | IFF_POINTOPOINT | IFF_RUNNING)
256#else
257#define IFF_CANTCHANGE \
258 (IFF_BROADCAST|IFF_POINTOPOINT|IFF_RUNNING|IFF_OACTIVE| \
259 IFF_SIMPLEX|IFF_MULTICAST|IFF_ALLMULTI)
260#endif
261
262/* packet tracing extension */
263#define IFFE_PKTTRACE 0x00000001 /* trace datalink where possible */
264#define IFFE_IPTRACE 0x00000002 /* trace ONLY IP packets */
265
266#ifndef TCPV40HDRS
267#pragma pack(1)
268#endif
269struct pkt_trace_hdr {
270 u_short pt_htype; /* header type */
271 u_short pt_len; /* in: pt_buf len, out: packet len */
272 caddr_t pt_data; /* packet ATTN: This is a _Seg16 addr! */
273 u_long pt_tstamp; /* time stamp in milliseconds */
274};
275#ifndef TCPV40HDRS
276#pragma pack()
277#endif
278#define HT_IP 0x01 /* IP */
279#define HT_ETHER 0x06 /* Ethernet */
280#define HT_ISO88023 0x07 /* CSMA CD */
281#define HT_ISO88025 0x09 /* Token Ring */
282#define HT_SLIP 0x1c /* Serial Line IP */
283#define HT_PPP 0x18 /* PPP IP */
284
285#ifndef TCPV40HDRS
286/* genric interface information */
287#pragma pack(1)
288struct if_data {
289 u_char ifi_type; /* ethernet, tokenring, etc */
290 u_char ifi_addrlen; /* media address length */
291 u_char ifi_hdrlen; /* media header length */
292 u_long ifi_mtu; /* maximum transmission unit */
293 u_long ifi_metric; /* routing metric (external only) */
294 u_long ifi_baudrate; /* linespeed */
295 /* volatile statistics */
296 u_long ifi_collisions; /* collisions on csma interfaces */
297 u_long ifi_ibytes; /* total number of octets received */
298 u_long ifi_obytes; /* total number of octets sent */
299 u_long ifi_oqdrops; /* dropped on output, this interface */
300 u_long ifi_iqdrops; /* dropped on input, this interface */
301 u_long ifi_ierrors; /* input errors on interface */
302 u_long ifi_oerrors; /* output errors on interface */
303 u_long ifi_noproto; /* destined for unsupported protocol */
304 u_long ifi_ipackets; /* packets received on interface */
305 u_long ifi_opackets; /* packets sent on interface */
306 u_long ifi_imcasts; /* packets received via multicast */
307 u_long ifi_omcasts; /* packets sent via multicast */
308 short ifi_OperStatus; /* SNMP Oper Status */
309 struct timeval ifi_lastchange;/* last updated */
310 u_char ifi_descr[45]; /* description of the interface */
311};
312#pragma pack()
313
314/*
315 * Message format for use in obtaining information about interfaces
316 * from getkerninfo and the routing socket
317 */
318#pragma pack(1)
319struct if_msghdr {
320 u_short ifm_msglen; /* to skip over non-understood messages */
321 u_char ifm_version; /* future binary compatability */
322 u_char ifm_type; /* message type */
323 int ifm_addrs; /* like rtm_addrs */
324 int ifm_flags; /* value of if_flags */
325 u_short ifm_index; /* index for associated ifp */
326 struct if_data ifm_data;/* statistics and other data about if */
327};
328#pragma pack()
329
330/*
331 * Message format for use in obtaining information about interface addresses
332 * from getkerninfo and the routing socket
333 */
334#pragma pack(1)
335struct ifa_msghdr {
336 u_short ifam_msglen; /* to skip over non-understood messages */
337 u_char ifam_version; /* future binary compatability */
338 u_char ifam_type; /* message type */
339 int ifam_addrs; /* like rtm_addrs */
340 int ifam_flags; /* value of ifa_flags */
341 u_short ifam_index; /* index for associated ifp */
342 int ifam_metric; /* value of ifa_metric */
343};
344#pragma pack()
345#endif /*!TCPV40HDRS*/
346
347#ifdef TCPV40HDRS
348/*
349 * Output queues (ifp->if_snd) and internetwork datagram level (pup level 1)
350 * input routines have queues of messages stored on ifqueue structures
351 * (defined above). Entries are added to and deleted from these structures
352 * by these macros, which should be called with ipl raised to splimp().
353 */
354#define IF_QFULL(ifq) ((ifq)->ifq_len >= (ifq)->ifq_maxlen)
355#define IF_DROP(ifq) ((ifq)->ifq_drops++)
356#define IF_ENQUEUE(ifq, m) {\
357 (m)->m_act=0;\
358 if ((ifq)->ifq_tail==0)\
359 (ifq)->ifq_head=m;\
360 else\
361 (ifq)->ifq_tail->m_act=m;\
362 (ifq)->ifq_tail=m;\
363 (ifq)->ifq_len++;\
364}
365#define IF_PREPEND(ifq, m) {\
366 (m)->m_act=(ifq)->ifq_head;\
367 if ((ifq)->ifq_tail==0)\
368 (ifq)->ifq_tail=(m);\
369 (ifq)->ifq_head=(m);\
370 (ifq)->ifq_len++;\
371}
372/*
373 * Packets destined for level-1 protocol input routines
374 * have a pointer to the receiving interface prepended to the data.
375 * IF_DEQUEUEIF extracts and returns this pointer when dequeueing the packet.
376 * IF_ADJ should be used otherwise to adjust for its presence.
377 */
378#define IF_ADJ(m) {\
379 (m)->m_off+=sizeof(struct ifnet*);\
380 (m)->m_len-=sizeof(struct ifnet*);\
381 if ((m)->m_len==0) {\
382 struct mbuf *n;\
383 MFREE((m), n);\
384 (m) = n;\
385 }\
386}
387#define IF_DEQUEUEIF(ifq, m, ifp) {\
388 (m)=(ifq)->ifq_head;\
389 if (m) {\
390 if (((ifq)->ifq_head=(m)->m_act)==0)\
391 (ifq)->ifq_tail=0;\
392 (m)->m_act=0;\
393 (ifq)->ifq_len--;\
394 (ifp)=*(mtod((m), struct ifnet**));\
395 IF_ADJ(m);\
396 }\
397}
398#define IF_DEQUEUE(ifq, m) {\
399 (m)=(ifq)->ifq_head;\
400 if (m) {\
401 if (((ifq)->ifq_head=(m)->m_act)==0)\
402 (ifq)->ifq_tail=0;\
403 (m)->m_act=0;\
404 (ifq)->ifq_len--;\
405 }\
406}
407
408#define IFQ_MAXLEN 50
409#define IFNET_SLOWHZ 1 /* granularity is 1 second */
410
411/*
412 * The ifaddr structure contains information about one address
413 * of an interface. They are maintained by the different address families,
414 * are allocated and attached when an address is set, and are linked
415 * together so all addresses for an interface can be located.
416 */
417struct ifaddr {
418 struct sockaddr ifa_addr; /* address of interface */
419 union {
420 struct sockaddr ifu_broadaddr; /* broadcast address interface */
421 struct sockaddr ifu_dstaddr; /* other end of p-to-p link */
422 } ifa_ifu;
423#define ifa_broadaddr ifa_ifu.ifu_broadaddr
424#define ifa_dstaddr ifa_ifu.ifu_dstaddr
425 struct ifnet *ifa_ifp; /* back-pointer to interface */
426 struct ifaddr *ifa_next; /* next address for interface */
427};
428#endif /*TCPV40HDRS*/
429
430/*
431 * Interface request structure used for socket
432 * ioctl's. All interface ioctl's must have parameter
433 * definitions which begin with ifr_name. The
434 * remainder may be interface specific.
435 */
436#ifndef TCPV40HDRS
437#pragma pack(1)
438#endif
439struct ifreq {
440#define IFNAMSIZ 16
441 char ifr_name[IFNAMSIZ]; /* if name, e.g. "en0" */
442 union {
443 struct sockaddr ifru_addr;
444 struct sockaddr ifru_dstaddr;
445 struct sockaddr ifru_broadaddr;
446 short ifru_flags;
447 int ifru_metric;
448 caddr_t ifru_data;
449 } ifr_ifru;
450#define ifr_addr ifr_ifru.ifru_addr /* address */
451#define ifr_dstaddr ifr_ifru.ifru_dstaddr /* other end of p-to-p link */
452#define ifr_broadaddr ifr_ifru.ifru_broadaddr /* broadcast address */
453#define ifr_flags ifr_ifru.ifru_flags /* flags */
454#define ifr_metric ifr_ifru.ifru_metric /* metric */
455#define ifr_data ifr_ifru.ifru_data /* for use by interface */
456#ifndef TCPV40HDRS
457#define ifr_eflags ifr_ifru.ifru_data /* Extended flags */
458#endif
459};
460#ifndef TCPV40HDRS
461#pragma pack()
462#endif
463
464#ifndef TCPV40HDRS
465#pragma pack(1)
466struct ifaliasreq {
467 char ifra_name[IFNAMSIZ]; /* if name, e.g. "en0" */
468 struct sockaddr ifra_addr;
469 struct sockaddr ifra_broadaddr;
470 struct sockaddr ifra_mask;
471};
472#pragma pack()
473#endif
474
475/*
476 * Structure used in SIOCGIFCONF request.
477 * Used to retrieve interface configuration
478 * for machine (useful for programs which
479 * must know all networks accessible).
480 */
481#ifndef TCPV40HDRS
482#pragma pack(1) /* paranoia I believe */
483#endif
484struct ifconf {
485 int ifc_len; /* size of associated buffer */
486 union {
487 caddr_t ifcu_buf;
488 struct ifreq *ifcu_req;
489 } ifc_ifcu;
490#define ifc_buf ifc_ifcu.ifcu_buf /* buffer address */
491#define ifc_req ifc_ifcu.ifcu_req /* array of structures returned */
492};
493#ifndef TCPV40HDRS
494#pragma pack()
495#endif
496
497#include <net/if_arp.h>
498
499#if defined (__cplusplus)
500}
501#endif
502
503#ifndef TCPV40HDRS
504#include <netinet/in.h>
505
506#pragma pack(1)
507struct in_aliasreq {
508 char ifra_name[IFNAMSIZ]; /* if name, e.g. "en0" */
509 struct sockaddr_in ifra_addr;
510 struct sockaddr_in ifra_broadaddr;
511#define ifra_dstaddr ifra_broadaddr
512 struct sockaddr_in ifra_mask;
513};
514#pragma pack()
515
516#pragma pack(1)
517struct addrreq { /* get multicast addresses */
518 char ifr_name[IFNAMSIZ];
519 struct sockaddr ifr_addrs;
520 u_long maddr[MAX_IN_MULTI];
521};
522#pragma pack()
523
524#pragma pack(1)
525struct statatreq {
526 u_long addr;
527 short interface;
528 u_long mask;
529 u_long broadcast;
530};
531#pragma pack()
532
533/* PPP statistics table. Moved here from previous ifstat.h */
534struct ifstat {
535 u_long iftLastChange;
536 u_long iftInOctets;
537 u_long iftOutOctets;
538 u_long iftOutDiscards;
539 u_long iftInDiscards;
540 u_long iftInErrors;
541 u_long iftOutErrors;
542 u_long iftInUnknownProtos;
543 u_long iftInUcastPkts;
544 u_long iftOutUcastPkts;
545 u_long iftInNUcastPkts;
546 u_long iftOutNUcastPkts;
547};
548#endif /*!TCPV40HDRS*/
549
550#endif /* _NET_IF_H_ */
Note: See TracBrowser for help on using the repository browser.