source: rtems/cpukit/libnetworking/net/if.h @ cf04e8ac

4.104.114.84.95
Last change on this file since cf04e8ac was cf04e8ac, checked in by Joel Sherrill <joel.sherrill@…>, on 09/01/06 at 19:10:01

* empty log message *

  • Property mode set to 100644
File size: 10.0 KB
Line 
1/*
2 * Copyright (c) 1982, 1986, 1989, 1993
3 *      The Regents of the University of California.  All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 *    notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 *    notice, this list of conditions and the following disclaimer in the
12 *    documentation and/or other materials provided with the distribution.
13 * 4. Neither the name of the University nor the names of its contributors
14 *    may be used to endorse or promote products derived from this software
15 *    without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * SUCH DAMAGE.
28 *
29 *      @(#)if.h        8.1 (Berkeley) 6/10/93
30 * $FreeBSD: src/sys/net/if.h,v 1.95 2005/02/25 19:46:41 brooks Exp $
31 */
32
33/*
34 * $Id$
35 */
36 
37#ifndef _NET_IF_H_
38#define _NET_IF_H_
39
40#include <sys/cdefs.h>
41
42#if defined(__rtems__)
43/*
44 * FIXME - HACK: BSD defines __BSD_VISIBLE in sys/cdefs.h
45 * RTEMS sys/cdefs.h doesn't, so we enforce it here.
46 */
47#ifndef __BSD_VISIBLE
48#define __BSD_VISIBLE 1
49#endif
50#include <inttypes.h>
51#endif
52
53#ifdef _KERNEL
54#include <sys/queue.h>
55#endif
56
57#if __BSD_VISIBLE
58/*
59 * <net/if.h> does not depend on <sys/time.h> on most other systems.  This
60 * helps userland compatibility.  (struct timeval ifi_lastchange)
61 */
62#ifndef _KERNEL
63#include <sys/time.h>
64#endif
65
66struct ifnet;
67struct  ether_header;
68#endif
69
70/*
71 * Length of interface external name, including terminating '\0'.
72 * Note: this is the same size as a generic device's external name.
73 */
74#define         IF_NAMESIZE     16
75#if __BSD_VISIBLE
76#define         IFNAMSIZ        IF_NAMESIZE
77#define         IF_MAXUNIT      0x7fff  /* historical value */
78#endif
79#if __BSD_VISIBLE
80
81/*
82 * Structure used to query names of interface cloners.
83 */
84
85struct if_clonereq {
86        int     ifcr_total;             /* total cloners (out) */
87        int     ifcr_count;             /* room for this many in user buffer */
88        char    *ifcr_buffer;           /* buffer for cloner names */
89};
90
91/*
92 * Structure describing information about an interface
93 * which may be of interest to management entities.
94 */
95struct if_data {
96        /* generic interface information */
97        u_char  ifi_type;               /* ethernet, tokenring, etc */
98        u_char  ifi_physical;           /* e.g., AUI, Thinnet, 10base-T, etc */
99        u_char  ifi_addrlen;            /* media address length */
100        u_char  ifi_hdrlen;             /* media header length */
101        u_char  ifi_recvquota;          /* polling quota for receive intrs */
102        u_char  ifi_xmitquota;          /* polling quota for xmit intrs */
103        u_long  ifi_mtu;                /* maximum transmission unit */
104        u_long  ifi_metric;             /* routing metric (external only) */
105        u_long  ifi_baudrate;           /* linespeed */
106        /* volatile statistics */
107        u_long  ifi_ipackets;           /* packets received on interface */
108        u_long  ifi_ierrors;            /* input errors on interface */
109        u_long  ifi_opackets;           /* packets sent on interface */
110        u_long  ifi_oerrors;            /* output errors on interface */
111        u_long  ifi_collisions;         /* collisions on csma interfaces */
112        u_long  ifi_ibytes;             /* total number of octets received */
113        u_long  ifi_obytes;             /* total number of octets sent */
114        u_long  ifi_imcasts;            /* packets received via multicast */
115        u_long  ifi_omcasts;            /* packets sent via multicast */
116        u_long  ifi_iqdrops;            /* dropped on input, this interface */
117        u_long  ifi_noproto;            /* destined for unsupported protocol */
118        u_long  ifi_recvtiming;         /* usec spent receiving when timing */
119        u_long  ifi_xmittiming;         /* usec spent xmitting when timing */
120        struct  timeval ifi_lastchange; /* time of last administrative change */
121};
122
123#define IFF_UP          0x1             /* interface is up */
124#define IFF_BROADCAST   0x2             /* broadcast address valid */
125#define IFF_DEBUG       0x4             /* turn on debugging */
126#define IFF_LOOPBACK    0x8             /* is a loopback net */
127#define IFF_POINTOPOINT 0x10            /* interface is point-to-point link */
128#define IFF_SMART       0x20            /* interface manages own routes */
129#define IFF_RUNNING     0x40            /* resources allocated */
130#define IFF_NOARP       0x80            /* no address resolution protocol */
131#define IFF_PROMISC     0x100           /* receive all packets */
132#define IFF_ALLMULTI    0x200           /* receive all multicast packets */
133#define IFF_OACTIVE     0x400           /* tx hardware queue is full */
134#define IFF_SIMPLEX     0x800           /* can't hear own transmissions */
135#define IFF_LINK0       0x1000          /* per link layer defined bit */
136#define IFF_LINK1       0x2000          /* per link layer defined bit */
137#define IFF_LINK2       0x4000          /* per link layer defined bit */
138#define IFF_ALTPHYS     IFF_LINK2       /* use alternate physical connection */
139#define IFF_MULTICAST   0x8000          /* supports multicast */
140#define IFF_POLLING     0x10000         /* Interface is in polling mode. */
141#define IFF_PPROMISC    0x20000         /* user-requested promisc mode */
142#define IFF_MONITOR     0x40000         /* user-requested monitor mode */
143#define IFF_STATICARP   0x80000         /* static ARP */
144#define IFF_NEEDSGIANT  0x100000        /* hold Giant over if_start calls */
145
146/* flags set internally only: */
147#define IFF_CANTCHANGE \
148        (IFF_BROADCAST|IFF_POINTOPOINT|IFF_RUNNING|IFF_OACTIVE|\
149            IFF_SIMPLEX|IFF_MULTICAST|IFF_ALLMULTI|IFF_SMART|IFF_PROMISC|\
150            IFF_POLLING)
151
152/*
153 * Values for if_link_state.
154 */
155#define LINK_STATE_UNKNOWN      0       /* link invalid/unknown */
156#define LINK_STATE_DOWN         1       /* link is down */
157#define LINK_STATE_UP           2       /* link is up */
158
159/*
160 * Some convenience macros used for setting ifi_baudrate.
161 * XXX 1000 vs. 1024? --thorpej@netbsd.org
162 */
163#define IF_Kbps(x)      ((x) * 1000)            /* kilobits/sec. */
164#define IF_Mbps(x)      (IF_Kbps((x) * 1000))   /* megabits/sec. */
165#define IF_Gbps(x)      (IF_Mbps((x) * 1000))   /* gigabits/sec. */
166
167#define IFQ_MAXLEN      50
168#define IFNET_SLOWHZ    1               /* granularity is 1 second */
169
170/*
171 * Message format for use in obtaining information about interfaces
172 * from getkerninfo and the routing socket
173 */
174struct if_msghdr {
175        u_short ifm_msglen;     /* to skip over non-understood messages */
176        u_char  ifm_version;    /* future binary compatibility */
177        u_char  ifm_type;       /* message type */
178        int     ifm_addrs;      /* like rtm_addrs */
179        int     ifm_flags;      /* value of if_flags */
180        u_short ifm_index;      /* index for associated ifp */
181        struct  if_data ifm_data;/* statistics and other data about if */
182};
183
184/*
185 * Message format for use in obtaining information about interface addresses
186 * from getkerninfo and the routing socket
187 */
188struct ifa_msghdr {
189        u_short ifam_msglen;    /* to skip over non-understood messages */
190        u_char  ifam_version;   /* future binary compatibility */
191        u_char  ifam_type;      /* message type */
192        int     ifam_addrs;     /* like rtm_addrs */
193        int     ifam_flags;     /* value of ifa_flags */
194        u_short ifam_index;     /* index for associated ifp */
195        int     ifam_metric;    /* value of ifa_metric */
196};
197
198/* forward declaration */
199struct mbuf;
200
201/*
202 * Interface request structure used for socket
203 * ioctl's.  All interface ioctl's must have parameter
204 * definitions which begin with ifr_name.  The
205 * remainder may be interface specific.
206 */
207struct  ifreq {
208        char    ifr_name[IFNAMSIZ];             /* if name, e.g. "en0" */
209        union {
210                struct  sockaddr ifru_addr;
211                struct  sockaddr ifru_dstaddr;
212                struct  sockaddr ifru_broadaddr;
213                short   ifru_flags[2];
214                int32_t ifru_metric;
215                int32_t ifru_mtu;
216                int     ifru_phys;
217                int     ifru_media;
218                caddr_t ifru_data;
219                int     (*ifru_tap)(struct ifnet *, struct ether_header *, struct mbuf *);
220        } ifr_ifru;
221#define ifr_addr        ifr_ifru.ifru_addr      /* address */
222#define ifr_dstaddr     ifr_ifru.ifru_dstaddr   /* other end of p-to-p link */
223#define ifr_broadaddr   ifr_ifru.ifru_broadaddr /* broadcast address */
224#define ifr_flags       ifr_ifru.ifru_flags[0]  /* flags (low 16 bits) */
225#define ifr_flagshigh   ifr_ifru.ifru_flags[1]  /* flags (high 16 bits) */
226#define ifr_metric      ifr_ifru.ifru_metric    /* metric */
227#define ifr_mtu         ifr_ifru.ifru_mtu       /* mtu */
228#define ifr_phys        ifr_ifru.ifru_phys      /* physical wire */
229#define ifr_media       ifr_ifru.ifru_media     /* physical media */
230#define ifr_data        ifr_ifru.ifru_data      /* for use by interface */
231#define ifr_tap         ifr_ifru.ifru_tap       /* tap function */
232};
233
234struct ifaliasreq {
235        char    ifra_name[IFNAMSIZ];            /* if name, e.g. "en0" */
236        struct  sockaddr ifra_addr;
237        struct  sockaddr ifra_broadaddr;
238        struct  sockaddr ifra_mask;
239};
240
241struct ifmediareq {
242        char    ifm_name[IFNAMSIZ];     /* if name, e.g. "en0" */
243        int     ifm_current;            /* current media options */
244        int     ifm_mask;               /* don't care mask */
245        int     ifm_status;             /* media status */
246        int     ifm_active;             /* active options */
247        int     ifm_count;              /* # entries in ifm_ulist array */
248        int     *ifm_ulist;             /* media words */
249};
250
251/*
252 * Structure used to retrieve aux status data from interfaces.
253 * Kernel suppliers to this interface should respect the formatting
254 * needed by ifconfig(8): each line starts with a TAB and ends with
255 * a newline.  The canonical example to copy and paste is in if_tun.c.
256 */
257
258#define IFSTATMAX       800             /* 10 lines of text */
259struct ifstat {
260        char    ifs_name[IFNAMSIZ];     /* if name, e.g. "en0" */
261        char    ascii[IFSTATMAX + 1];
262};
263
264/*
265 * Structure used in SIOCGIFCONF request.
266 * Used to retrieve interface configuration
267 * for machine (useful for programs which
268 * must know all networks accessible).
269 */
270struct  ifconf {
271        int     ifc_len;                /* size of associated buffer */
272        union {
273                caddr_t ifcu_buf;
274                struct  ifreq *ifcu_req;
275        } ifc_ifcu;
276#define ifc_buf ifc_ifcu.ifcu_buf       /* buffer address */
277#define ifc_req ifc_ifcu.ifcu_req       /* array of structures returned */
278};
279#endif /* __BSD_VISIBLE */
280
281#ifdef _KERNEL
282
283/* XXX - this should go away soon. */
284#include <net/if_var.h>
285
286void    ifafree __P((struct ifaddr *));
287
288int     looutput __P((struct ifnet *,
289           struct mbuf *, struct sockaddr *, struct rtentry *));
290#endif
291
292#endif /* !_NET_IF_H_ */
Note: See TracBrowser for help on using the repository browser.