source: rtems/cpukit/libnetworking/net/if.h @ 91683dc

4.104.114.84.95
Last change on this file since 91683dc was 91683dc, checked in by Joel Sherrill <joel.sherrill@…>, on 06/17/05 at 14:37:24

2005-06-17 Joel Sherrill <joel@…>

  • libnetworking/net/if.h: Avoid use of struct mbuf to avoid unintended dependencies added by the RTEMS specific tap interface.
  • 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#endif
51
52#ifdef _KERNEL
53#include <sys/queue.h>
54#endif
55
56#if __BSD_VISIBLE
57/*
58 * <net/if.h> does not depend on <sys/time.h> on most other systems.  This
59 * helps userland compatibility.  (struct timeval ifi_lastchange)
60 */
61#ifndef _KERNEL
62#include <sys/time.h>
63#endif
64
65struct ifnet;
66struct  ether_header;
67#endif
68
69/*
70 * Length of interface external name, including terminating '\0'.
71 * Note: this is the same size as a generic device's external name.
72 */
73#define         IF_NAMESIZE     16
74#if __BSD_VISIBLE
75#define         IFNAMSIZ        IF_NAMESIZE
76#define         IF_MAXUNIT      0x7fff  /* historical value */
77#endif
78#if __BSD_VISIBLE
79
80/*
81 * Structure used to query names of interface cloners.
82 */
83
84struct if_clonereq {
85        int     ifcr_total;             /* total cloners (out) */
86        int     ifcr_count;             /* room for this many in user buffer */
87        char    *ifcr_buffer;           /* buffer for cloner names */
88};
89
90/*
91 * Structure describing information about an interface
92 * which may be of interest to management entities.
93 */
94struct if_data {
95        /* generic interface information */
96        u_char  ifi_type;               /* ethernet, tokenring, etc */
97        u_char  ifi_physical;           /* e.g., AUI, Thinnet, 10base-T, etc */
98        u_char  ifi_addrlen;            /* media address length */
99        u_char  ifi_hdrlen;             /* media header length */
100        u_char  ifi_recvquota;          /* polling quota for receive intrs */
101        u_char  ifi_xmitquota;          /* polling quota for xmit intrs */
102        u_long  ifi_mtu;                /* maximum transmission unit */
103        u_long  ifi_metric;             /* routing metric (external only) */
104        u_long  ifi_baudrate;           /* linespeed */
105        /* volatile statistics */
106        u_long  ifi_ipackets;           /* packets received on interface */
107        u_long  ifi_ierrors;            /* input errors on interface */
108        u_long  ifi_opackets;           /* packets sent on interface */
109        u_long  ifi_oerrors;            /* output errors on interface */
110        u_long  ifi_collisions;         /* collisions on csma interfaces */
111        u_long  ifi_ibytes;             /* total number of octets received */
112        u_long  ifi_obytes;             /* total number of octets sent */
113        u_long  ifi_imcasts;            /* packets received via multicast */
114        u_long  ifi_omcasts;            /* packets sent via multicast */
115        u_long  ifi_iqdrops;            /* dropped on input, this interface */
116        u_long  ifi_noproto;            /* destined for unsupported protocol */
117        u_long  ifi_recvtiming;         /* usec spent receiving when timing */
118        u_long  ifi_xmittiming;         /* usec spent xmitting when timing */
119        struct  timeval ifi_lastchange; /* time of last administrative change */
120};
121
122#define IFF_UP          0x1             /* interface is up */
123#define IFF_BROADCAST   0x2             /* broadcast address valid */
124#define IFF_DEBUG       0x4             /* turn on debugging */
125#define IFF_LOOPBACK    0x8             /* is a loopback net */
126#define IFF_POINTOPOINT 0x10            /* interface is point-to-point link */
127#define IFF_SMART       0x20            /* interface manages own routes */
128#define IFF_RUNNING     0x40            /* resources allocated */
129#define IFF_NOARP       0x80            /* no address resolution protocol */
130#define IFF_PROMISC     0x100           /* receive all packets */
131#define IFF_ALLMULTI    0x200           /* receive all multicast packets */
132#define IFF_OACTIVE     0x400           /* tx hardware queue is full */
133#define IFF_SIMPLEX     0x800           /* can't hear own transmissions */
134#define IFF_LINK0       0x1000          /* per link layer defined bit */
135#define IFF_LINK1       0x2000          /* per link layer defined bit */
136#define IFF_LINK2       0x4000          /* per link layer defined bit */
137#define IFF_ALTPHYS     IFF_LINK2       /* use alternate physical connection */
138#define IFF_MULTICAST   0x8000          /* supports multicast */
139#define IFF_POLLING     0x10000         /* Interface is in polling mode. */
140#define IFF_PPROMISC    0x20000         /* user-requested promisc mode */
141#define IFF_MONITOR     0x40000         /* user-requested monitor mode */
142#define IFF_STATICARP   0x80000         /* static ARP */
143#define IFF_NEEDSGIANT  0x100000        /* hold Giant over if_start calls */
144
145/* flags set internally only: */
146#define IFF_CANTCHANGE \
147        (IFF_BROADCAST|IFF_POINTOPOINT|IFF_RUNNING|IFF_OACTIVE|\
148            IFF_SIMPLEX|IFF_MULTICAST|IFF_ALLMULTI|IFF_SMART|IFF_PROMISC|\
149            IFF_POLLING)
150
151/*
152 * Values for if_link_state.
153 */
154#define LINK_STATE_UNKNOWN      0       /* link invalid/unknown */
155#define LINK_STATE_DOWN         1       /* link is down */
156#define LINK_STATE_UP           2       /* link is up */
157
158/*
159 * Some convenience macros used for setting ifi_baudrate.
160 * XXX 1000 vs. 1024? --thorpej@netbsd.org
161 */
162#define IF_Kbps(x)      ((x) * 1000)            /* kilobits/sec. */
163#define IF_Mbps(x)      (IF_Kbps((x) * 1000))   /* megabits/sec. */
164#define IF_Gbps(x)      (IF_Mbps((x) * 1000))   /* gigabits/sec. */
165
166#define IFQ_MAXLEN      50
167#define IFNET_SLOWHZ    1               /* granularity is 1 second */
168
169/*
170 * Message format for use in obtaining information about interfaces
171 * from getkerninfo and the routing socket
172 */
173struct if_msghdr {
174        u_short ifm_msglen;     /* to skip over non-understood messages */
175        u_char  ifm_version;    /* future binary compatibility */
176        u_char  ifm_type;       /* message type */
177        int     ifm_addrs;      /* like rtm_addrs */
178        int     ifm_flags;      /* value of if_flags */
179        u_short ifm_index;      /* index for associated ifp */
180        struct  if_data ifm_data;/* statistics and other data about if */
181};
182
183/*
184 * Message format for use in obtaining information about interface addresses
185 * from getkerninfo and the routing socket
186 */
187struct ifa_msghdr {
188        u_short ifam_msglen;    /* to skip over non-understood messages */
189        u_char  ifam_version;   /* future binary compatibility */
190        u_char  ifam_type;      /* message type */
191        int     ifam_addrs;     /* like rtm_addrs */
192        int     ifam_flags;     /* value of ifa_flags */
193        u_short ifam_index;     /* index for associated ifp */
194        int     ifam_metric;    /* value of ifa_metric */
195};
196
197/*
198 * Interface request structure used for socket
199 * ioctl's.  All interface ioctl's must have parameter
200 * definitions which begin with ifr_name.  The
201 * remainder may be interface specific.
202 */
203struct  ifreq {
204        char    ifr_name[IFNAMSIZ];             /* if name, e.g. "en0" */
205        union {
206                struct  sockaddr ifru_addr;
207                struct  sockaddr ifru_dstaddr;
208                struct  sockaddr ifru_broadaddr;
209                short   ifru_flags[2];
210                int     ifru_metric;
211                int     ifru_mtu;
212                int     ifru_phys;
213                int     ifru_media;
214                caddr_t ifru_data;
215                /* third argument must be cast to a struct mbuf * */
216                int     (*ifru_tap)(struct ifnet *, struct ether_header *, void *);
217        } ifr_ifru;
218#define ifr_addr        ifr_ifru.ifru_addr      /* address */
219#define ifr_dstaddr     ifr_ifru.ifru_dstaddr   /* other end of p-to-p link */
220#define ifr_broadaddr   ifr_ifru.ifru_broadaddr /* broadcast address */
221#define ifr_flags       ifr_ifru.ifru_flags[0]  /* flags (low 16 bits) */
222#define ifr_flagshigh   ifr_ifru.ifru_flags[1]  /* flags (high 16 bits) */
223#define ifr_metric      ifr_ifru.ifru_metric    /* metric */
224#define ifr_mtu         ifr_ifru.ifru_mtu       /* mtu */
225#define ifr_phys        ifr_ifru.ifru_phys      /* physical wire */
226#define ifr_media       ifr_ifru.ifru_media     /* physical media */
227#define ifr_data        ifr_ifru.ifru_data      /* for use by interface */
228#define ifr_tap         ifr_ifru.ifru_tap       /* tap function */
229};
230
231struct ifaliasreq {
232        char    ifra_name[IFNAMSIZ];            /* if name, e.g. "en0" */
233        struct  sockaddr ifra_addr;
234        struct  sockaddr ifra_broadaddr;
235        struct  sockaddr ifra_mask;
236};
237
238struct ifmediareq {
239        char    ifm_name[IFNAMSIZ];     /* if name, e.g. "en0" */
240        int     ifm_current;            /* current media options */
241        int     ifm_mask;               /* don't care mask */
242        int     ifm_status;             /* media status */
243        int     ifm_active;             /* active options */
244        int     ifm_count;              /* # entries in ifm_ulist array */
245        int     *ifm_ulist;             /* media words */
246};
247
248/*
249 * Structure used to retrieve aux status data from interfaces.
250 * Kernel suppliers to this interface should respect the formatting
251 * needed by ifconfig(8): each line starts with a TAB and ends with
252 * a newline.  The canonical example to copy and paste is in if_tun.c.
253 */
254
255#define IFSTATMAX       800             /* 10 lines of text */
256struct ifstat {
257        char    ifs_name[IFNAMSIZ];     /* if name, e.g. "en0" */
258        char    ascii[IFSTATMAX + 1];
259};
260
261/*
262 * Structure used in SIOCGIFCONF request.
263 * Used to retrieve interface configuration
264 * for machine (useful for programs which
265 * must know all networks accessible).
266 */
267struct  ifconf {
268        int     ifc_len;                /* size of associated buffer */
269        union {
270                caddr_t ifcu_buf;
271                struct  ifreq *ifcu_req;
272        } ifc_ifcu;
273#define ifc_buf ifc_ifcu.ifcu_buf       /* buffer address */
274#define ifc_req ifc_ifcu.ifcu_req       /* array of structures returned */
275};
276#endif /* __BSD_VISIBLE */
277
278#ifdef _KERNEL
279
280/* XXX - this should go away soon. */
281#include <net/if_var.h>
282
283void    ifafree __P((struct ifaddr *));
284
285int     looutput __P((struct ifnet *,
286           struct mbuf *, struct sockaddr *, struct rtentry *));
287#endif
288
289#endif /* !_NET_IF_H_ */
Note: See TracBrowser for help on using the repository browser.