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