Commit | Line | Data |
---|---|---|
e740a894 | 1 | /* if.h 4.7 82/01/24 */ |
665ce890 BJ |
2 | |
3 | /* | |
f1b2fa5b BJ |
4 | * Structures defining a network interface, providing a packet |
5 | * transport mechanism (ala level 0 of the PUP protocols). | |
6 | * | |
7 | * Each interface accepts output datagrams of a specified maximum | |
8 | * length, and provides higher level routines with input datagrams | |
9 | * received from its medium. | |
10 | * | |
11 | * Output occurs when the routine if_output is called, with three parameters: | |
12 | * (*ifp->if_output)(ifp, m, pf) | |
13 | * Here m is the mbuf chain to be sent and pf is the protocol family | |
14 | * of the internetwork datagram format in which the data is wrapped | |
15 | * (e.g. PF_PUP or PF_INET). The output routine encapsulates the | |
16 | * supplied datagram if necessary, and then transmits it on its medium. | |
17 | * | |
18 | * On input, each interface unwraps the data received by it, and either | |
19 | * places it on the input queue of a internetwork datagram routine | |
20 | * and posts the associated software interrupt, or passes the datagram to a raw | |
21 | * packet input routine. | |
22 | * | |
23 | * Routines exist for locating interfaces by their internet addresses | |
24 | * or for locating a interface on a certain network, as well as more general | |
25 | * routing and gateway routines maintaining information used to locate | |
26 | * interfaces. These routines live in the files if.c and ip_ggp.c. | |
8a13b737 | 27 | */ |
8a13b737 BJ |
28 | |
29 | /* | |
30 | * Structure defining a queue for a network interface. | |
665ce890 BJ |
31 | * |
32 | * (Would like to call this struct ``if'', but C isn't PL/1.) | |
33 | */ | |
34 | struct ifnet { | |
b454c3ea | 35 | char *if_name; /* name, e.g. ``en'' or ``lo'' */ |
665ce890 | 36 | short if_unit; /* sub-unit for lower level driver */ |
665ce890 BJ |
37 | short if_mtu; /* maximum transmission unit */ |
38 | short if_net; /* network number of interface */ | |
8a13b737 | 39 | int if_host[2]; /* local net host number */ |
665ce890 | 40 | struct in_addr if_addr; /* internet address of interface */ |
f1b2fa5b BJ |
41 | struct ifqueue { |
42 | struct mbuf *ifq_head; | |
43 | struct mbuf *ifq_tail; | |
44 | } if_snd; /* output queue */ | |
45 | /* procedure handles */ | |
46 | int (*if_init)(); /* init routine */ | |
8a13b737 BJ |
47 | int (*if_output)(); /* output routine */ |
48 | int (*if_ubareset)(); /* uba reset routine */ | |
f1b2fa5b | 49 | /* generic interface statistics */ |
b454c3ea BJ |
50 | int if_ipackets; /* packets received on interface */ |
51 | int if_ierrors; /* input errors on interface */ | |
52 | int if_opackets; /* packets sent on interface */ | |
53 | int if_oerrors; /* output errors on interface */ | |
f1b2fa5b | 54 | int if_collisions; /* collisions on csma interfaces */ |
f1b2fa5b | 55 | /* end statistics */ |
4ad99bae | 56 | struct ifnet *if_next; |
665ce890 BJ |
57 | }; |
58 | ||
f1b2fa5b BJ |
59 | /* |
60 | * Output queues (ifp->if_snd) and internetwork datagram level (pup level 1) | |
61 | * input routines have queues of messages stored on ifqueue structures | |
62 | * (defined above). Entries are added to and deleted from these structures | |
63 | * by these macros, which should be called with ipl raised to splimp(). | |
64 | */ | |
8a13b737 BJ |
65 | #define IF_ENQUEUE(ifq, m) { \ |
66 | (m)->m_act = 0; \ | |
67 | if ((ifq)->ifq_tail == 0) \ | |
405c9168 | 68 | (ifq)->ifq_head = m; \ |
8a13b737 BJ |
69 | else \ |
70 | (ifq)->ifq_tail->m_act = m; \ | |
405c9168 | 71 | (ifq)->ifq_tail = m; \ |
8a13b737 | 72 | } |
e740a894 BJ |
73 | #define IF_PREPEND(ifq, m) { \ |
74 | (m)->m_act = (ifq)->ifq_head; \ | |
75 | (ifq)->ifq_head = (m); \ | |
76 | } | |
8a13b737 BJ |
77 | #define IF_DEQUEUE(ifq, m) { \ |
78 | (m) = (ifq)->ifq_head; \ | |
79 | if (m) { \ | |
80 | if (((ifq)->ifq_head = (m)->m_act) == 0) \ | |
81 | (ifq)->ifq_tail = 0; \ | |
82 | (m)->m_act = 0; \ | |
83 | } \ | |
84 | } | |
665ce890 BJ |
85 | |
86 | #ifdef KERNEL | |
8a13b737 BJ |
87 | #ifdef INET |
88 | struct ifqueue ipintrq; /* ip packet input queue */ | |
89 | #endif | |
f1b2fa5b | 90 | struct ifqueue rawintrq; /* raw packet input queue */ |
665ce890 | 91 | struct ifnet *ifnet; |
8a13b737 | 92 | struct ifnet *if_ifwithaddr(), *if_ifonnetof(), *if_gatewayfor(); |
f1b2fa5b | 93 | struct in_addr if_makeaddr(); |
665ce890 | 94 | #endif |