summaryrefslogtreecommitdiffstats
path: root/cpukit/libnetworking/net/if.h
diff options
context:
space:
mode:
authorRalf Corsepius <ralf.corsepius@rtems.org>2005-04-18 16:36:20 +0000
committerRalf Corsepius <ralf.corsepius@rtems.org>2005-04-18 16:36:20 +0000
commit88d99508351846afbc0047423fcfcffe27243ff4 (patch)
treefd6fd12fcd0c04500223c1ea5b26527fb106c715 /cpukit/libnetworking/net/if.h
parent2005-04-18 Ralf Corsepius <ralf.corsepius@rtems.org> (diff)
downloadrtems-88d99508351846afbc0047423fcfcffe27243ff4.tar.bz2
2005-04-18 Ralf Corsepius <ralf.corsepius@rtems.org>
* libnetworking/net/if.h: Update from FreeBSD. * libnetworking/net/if_loop.c: Reflect updates. * libnetworking/net/if_ppp.c: Reflect updates. * libnetworking/net/if_types.h: Update from FreeBSD.
Diffstat (limited to '')
-rw-r--r--cpukit/libnetworking/net/if.h264
1 files changed, 15 insertions, 249 deletions
diff --git a/cpukit/libnetworking/net/if.h b/cpukit/libnetworking/net/if.h
index efe9bbeff8..22f60a6069 100644
--- a/cpukit/libnetworking/net/if.h
+++ b/cpukit/libnetworking/net/if.h
@@ -27,7 +27,7 @@
* SUCH DAMAGE.
*
* @(#)if.h 8.1 (Berkeley) 6/10/93
- * $FreeBSD: src/sys/net/if.h,v 1.92 2004/09/08 04:50:55 brooks Exp $
+ * $FreeBSD: src/sys/net/if.h,v 1.95 2005/02/25 19:46:41 brooks Exp $
*/
/*
@@ -37,31 +37,6 @@
#ifndef _NET_IF_H_
#define _NET_IF_H_
-/*
- * Structures defining a network interface, providing a packet
- * transport mechanism (ala level 0 of the PUP protocols).
- *
- * Each interface accepts output datagrams of a specified maximum
- * length, and provides higher level routines with input datagrams
- * received from its medium.
- *
- * Output occurs when the routine if_output is called, with three parameters:
- * (*ifp->if_output)(ifp, m, dst, rt)
- * Here m is the mbuf chain to be sent and dst is the destination address.
- * The output routine encapsulates the supplied datagram if necessary,
- * and then transmits it on its medium.
- *
- * On input, each interface unwraps the data received by it, and either
- * places it on the input queue of a internetwork datagram routine
- * and posts the associated software interrupt, or passes the datagram to a raw
- * packet input routine.
- *
- * Routines exist for locating interfaces by their addresses
- * or for locating a interface on a certain network, as well as more general
- * routing and gateway routines maintaining information used to locate
- * interfaces. These routines live in the files if.c and route.c
- */
-
#include <sys/cdefs.h>
#if defined(__rtems__)
@@ -88,14 +63,6 @@
#endif
struct ifnet;
-
-/*
- * Forward structure declarations for function prototypes [sic].
- */
-struct mbuf;
-struct proc;
-struct rtentry;
-struct socket;
struct ether_header;
#endif
@@ -152,89 +119,6 @@ struct if_data {
struct timeval ifi_lastchange; /* time of last administrative change */
};
-/*
- * Structure defining a queue for a network interface.
- */
-struct ifqueue {
- struct mbuf *ifq_head;
- struct mbuf *ifq_tail;
- int ifq_len;
- int ifq_maxlen;
- int ifq_drops;
-};
-
-/*
- * Structure defining a network interface.
- *
- * (Would like to call this struct ``if'', but C isn't PL/1.)
- */
-struct ifnet {
- void *if_softc; /* pointer to driver state */
- char *if_name; /* name, e.g. ``en'' or ``lo'' */
- struct ifnet *if_next; /* all struct ifnets are chained */
- struct ifaddr *if_addrlist; /* linked list of addresses per if */
- int if_pcount; /* number of promiscuous listeners */
- struct bpf_if *if_bpf; /* packet filter structure */
- u_short if_index; /* numeric abbreviation for this if */
- short if_unit; /* sub-unit for lower level driver */
- short if_timer; /* time 'til if_watchdog called */
- short if_flags; /* up/down, broadcast, etc. */
- int if_ipending; /* interrupts pending */
- void *if_linkmib; /* link-type-specific MIB data */
- size_t if_linkmiblen; /* length of above data */
- struct if_data if_data;
-/* procedure handles */
- int (*if_output) /* output routine (enqueue) */
- __P((struct ifnet *, struct mbuf *, struct sockaddr *,
- struct rtentry *));
- void (*if_start) /* initiate output routine */
- __P((struct ifnet *));
- int (*if_done) /* output complete routine */
- __P((struct ifnet *)); /* (XXX not used; fake prototype) */
- int (*if_ioctl) /* ioctl routine */
- __P((struct ifnet *, int, caddr_t));
- void (*if_watchdog) /* timer routine */
- __P((struct ifnet *));
- int (*if_poll_recv) /* polled receive routine */
- __P((struct ifnet *, int *));
- int (*if_poll_xmit) /* polled transmit routine */
- __P((struct ifnet *, int *));
- void (*if_poll_intren) /* polled interrupt reenable routine */
- __P((struct ifnet *));
- void (*if_poll_slowinput) /* input routine for slow devices */
- __P((struct ifnet *, struct mbuf *));
- void (*if_init) /* Init routine */
- __P((void *));
- int (*if_tap) /* Packet filter routine */
- (struct ifnet *, struct ether_header *, struct mbuf *);
- struct ifqueue if_snd; /* output queue */
- struct ifqueue *if_poll_slowq; /* input queue for slow devices */
-};
-typedef void if_init_f_t __P((void *));
-
-#define if_mtu if_data.ifi_mtu
-#define if_type if_data.ifi_type
-#define if_physical if_data.ifi_physical
-#define if_addrlen if_data.ifi_addrlen
-#define if_hdrlen if_data.ifi_hdrlen
-#define if_metric if_data.ifi_metric
-#define if_baudrate if_data.ifi_baudrate
-#define if_ipackets if_data.ifi_ipackets
-#define if_ierrors if_data.ifi_ierrors
-#define if_opackets if_data.ifi_opackets
-#define if_oerrors if_data.ifi_oerrors
-#define if_collisions if_data.ifi_collisions
-#define if_ibytes if_data.ifi_ibytes
-#define if_obytes if_data.ifi_obytes
-#define if_imcasts if_data.ifi_imcasts
-#define if_omcasts if_data.ifi_omcasts
-#define if_iqdrops if_data.ifi_iqdrops
-#define if_noproto if_data.ifi_noproto
-#define if_lastchange if_data.ifi_lastchange
-#define if_recvquota if_data.ifi_recvquota
-#define if_xmitquota if_data.ifi_xmitquota
-#define if_rawoutput(if, m, sa) if_output(if, m, sa, (struct rtentry *)0)
-
#define IFF_UP 0x1 /* interface is up */
#define IFF_BROADCAST 0x2 /* broadcast address valid */
#define IFF_DEBUG 0x4 /* turn on debugging */
@@ -264,15 +148,20 @@ typedef void if_init_f_t __P((void *));
IFF_SIMPLEX|IFF_MULTICAST|IFF_ALLMULTI|IFF_SMART|IFF_PROMISC|\
IFF_POLLING)
+/*
+ * Values for if_link_state.
+ */
+#define LINK_STATE_UNKNOWN 0 /* link invalid/unknown */
+#define LINK_STATE_DOWN 1 /* link is down */
+#define LINK_STATE_UP 2 /* link is up */
/*
- * These really don't belong here, but there's no other obviously appropriate
- * location.
+ * Some convenience macros used for setting ifi_baudrate.
+ * XXX 1000 vs. 1024? --thorpej@netbsd.org
*/
-#define IFP_AUI 0
-#define IFP_10BASE2 1
-#define IFP_10BASET 2
-/* etc. */
+#define IF_Kbps(x) ((x) * 1000) /* kilobits/sec. */
+#define IF_Mbps(x) (IF_Kbps((x) * 1000)) /* megabits/sec. */
+#define IF_Gbps(x) (IF_Mbps((x) * 1000)) /* gigabits/sec. */
/*
* Bit values in if_ipending
@@ -280,103 +169,10 @@ typedef void if_init_f_t __P((void *));
#define IFI_RECV 1 /* I want to receive */
#define IFI_XMIT 2 /* I want to transmit */
-/*
- * Output queues (ifp->if_snd) and slow device input queues (*ifp->if_slowq)
- * are queues of messages stored on ifqueue structures
- * (defined above). Entries are added to and deleted from these structures
- * by these macros, which should be called with ipl raised to splimp().
- */
-#define IF_QFULL(ifq) ((ifq)->ifq_len >= (ifq)->ifq_maxlen)
-#define IF_DROP(ifq) ((ifq)->ifq_drops++)
-#define IF_ENQUEUE(ifq, m) { \
-/* printf(" IF_ENQUEUE: %p %p\n", ifq, m ); */ \
- (m)->m_nextpkt = 0; \
- if ((ifq)->ifq_tail == 0) \
- (ifq)->ifq_head = m; \
- else \
- (ifq)->ifq_tail->m_nextpkt = m; \
- (ifq)->ifq_tail = m; \
- (ifq)->ifq_len++; \
-}
-#define IF_PREPEND(ifq, m) { \
-/* printf(" IF_PREPEND: %p %p\n", ifq, m ); */ \
- (m)->m_nextpkt = (ifq)->ifq_head; \
- if ((ifq)->ifq_tail == 0) \
- (ifq)->ifq_tail = (m); \
- (ifq)->ifq_head = (m); \
- (ifq)->ifq_len++; \
-}
-#define IF_DEQUEUE(ifq, m) { \
- (m) = (ifq)->ifq_head; \
- if (m) { \
-/* printf(" IF_DEQUEUE: %p %p\n", ifq, m ); */ \
- if (((ifq)->ifq_head = (m)->m_nextpkt) == 0) \
- (ifq)->ifq_tail = 0; \
- (m)->m_nextpkt = 0; \
- (ifq)->ifq_len--; \
- } \
-}
-
-#ifdef _KERNEL
-#define IF_ENQ_DROP(ifq, m) if_enq_drop(ifq, m)
-
-#if defined(__GNUC__) && defined(MT_HEADER)
-static inline int
-if_queue_drop(struct ifqueue *ifq, struct mbuf *m)
-{
- IF_DROP(ifq);
- return 0;
-}
-
-static inline int
-if_enq_drop(struct ifqueue *ifq, struct mbuf *m)
-{
- if (IF_QFULL(ifq) &&
- !if_queue_drop(ifq, m))
- return 0;
- IF_ENQUEUE(ifq, m);
- return 1;
-}
-#else
-
-#ifdef MT_HEADER
-int if_enq_drop __P((struct ifqueue *, struct mbuf *));
-#endif
-
-#endif
-#endif /* _KERNEL */
-
#define IFQ_MAXLEN 50
#define IFNET_SLOWHZ 1 /* granularity is 1 second */
/*
- * The ifaddr structure contains information about one address
- * of an interface. They are maintained by the different address families,
- * are allocated and attached when an address is set, and are linked
- * together so all addresses for an interface can be located.
- */
-struct ifaddr {
- struct sockaddr *ifa_addr; /* address of interface */
- struct sockaddr *ifa_dstaddr; /* other end of p-to-p link */
-#define ifa_broadaddr ifa_dstaddr /* broadcast address interface */
- struct sockaddr *ifa_netmask; /* used to determine subnet */
- struct ifnet *ifa_ifp; /* back-pointer to interface */
- struct ifaddr *ifa_next; /* next address for interface */
- void (*ifa_rtrequest) /* check or clean routes (+ or -)'d */
- __P((int, struct rtentry *, struct sockaddr *));
- u_short ifa_flags; /* mostly rt_flags for cloning */
- short ifa_refcnt; /* references to this structure */
- int ifa_metric; /* cost of going out this interface */
-#ifdef notdef
- struct rtentry *ifa_rt; /* XXXX for ROUTETOIF ????? */
-#endif
- int (*ifa_claim_addr) /* check if an addr goes to this if */
- __P((struct ifaddr *, struct sockaddr *));
-
-};
-#define IFA_ROUTE RTF_UP /* route installed */
-
-/*
* Message format for use in obtaining information about interfaces
* from getkerninfo and the routing socket
*/
@@ -483,45 +279,15 @@ struct ifconf {
};
#endif /* __BSD_VISIBLE */
-#include <net/if_arp.h>
-
#ifdef _KERNEL
-#define IFAFREE(ifa) \
- if ((ifa)->ifa_refcnt <= 0) \
- ifafree(ifa); \
- else \
- (ifa)->ifa_refcnt--;
-extern struct ifnet *ifnet;
-extern int ifqmaxlen;
-extern struct ifnet loif[];
-extern int if_index;
-extern struct ifaddr **ifnet_addrs;
+/* XXX - this should go away soon. */
+#include <net/if_var.h>
-void ether_ifattach __P((struct ifnet *));
-void ether_input __P((struct ifnet *, struct ether_header *, struct mbuf *));
-int ether_output __P((struct ifnet *,
- struct mbuf *, struct sockaddr *, struct rtentry *));
-int ether_ioctl __P((struct ifnet *, int , caddr_t ));
-
-void if_attach(struct ifnet *);
-void if_down(struct ifnet *);
-void if_up(struct ifnet *);
-
-/*void ifinit __P((void));*/ /* declared in systm.h for main() */
-int ifioctl(struct socket *, int, caddr_t, struct proc *);
-int ifpromisc(struct ifnet *, int);
-
-struct ifaddr *ifa_ifwithaddr(struct sockaddr *);
-struct ifaddr *ifa_ifwithdstaddr(struct sockaddr *);
-struct ifaddr *ifa_ifwithnet(struct sockaddr *);
-struct ifaddr *ifa_ifwithroute(int, struct sockaddr *,
- struct sockaddr *);
-struct ifaddr *ifaof_ifpforaddr __P((struct sockaddr *, struct ifnet *));
void ifafree __P((struct ifaddr *));
int looutput __P((struct ifnet *,
struct mbuf *, struct sockaddr *, struct rtentry *));
-#endif /* _KERNEL */
+#endif
#endif /* !_NET_IF_H_ */