1*5104Swnj /* if.h 4.4 81/11/29 */ 24945Swnj 34945Swnj /* 4*5104Swnj * Structures defining a network interface, providing a packet 5*5104Swnj * transport mechanism (ala level 0 of the PUP protocols). 6*5104Swnj * 7*5104Swnj * Each interface accepts output datagrams of a specified maximum 8*5104Swnj * length, and provides higher level routines with input datagrams 9*5104Swnj * received from its medium. 10*5104Swnj * 11*5104Swnj * Output occurs when the routine if_output is called, with three parameters: 12*5104Swnj * (*ifp->if_output)(ifp, m, pf) 13*5104Swnj * Here m is the mbuf chain to be sent and pf is the protocol family 14*5104Swnj * of the internetwork datagram format in which the data is wrapped 15*5104Swnj * (e.g. PF_PUP or PF_INET). The output routine encapsulates the 16*5104Swnj * supplied datagram if necessary, and then transmits it on its medium. 17*5104Swnj * 18*5104Swnj * On input, each interface unwraps the data received by it, and either 19*5104Swnj * places it on the input queue of a internetwork datagram routine 20*5104Swnj * and posts the associated software interrupt, or passes the datagram to a raw 21*5104Swnj * packet input routine. 22*5104Swnj * 23*5104Swnj * Routines exist for locating interfaces by their internet addresses 24*5104Swnj * or for locating a interface on a certain network, as well as more general 25*5104Swnj * routing and gateway routines maintaining information used to locate 26*5104Swnj * interfaces. These routines live in the files if.c and ip_ggp.c. 275083Swnj */ 285083Swnj 295083Swnj /* 305083Swnj * Structure defining a queue for a network interface. 314945Swnj * 324945Swnj * (Would like to call this struct ``if'', but C isn't PL/1.) 334945Swnj */ 344945Swnj struct ifnet { 354945Swnj short if_unit; /* sub-unit for lower level driver */ 364945Swnj short if_mtu; /* maximum transmission unit */ 374945Swnj short if_net; /* network number of interface */ 385083Swnj int if_host[2]; /* local net host number */ 394945Swnj struct in_addr if_addr; /* internet address of interface */ 40*5104Swnj struct ifqueue { 41*5104Swnj struct mbuf *ifq_head; 42*5104Swnj struct mbuf *ifq_tail; 43*5104Swnj } if_snd; /* output queue */ 44*5104Swnj /* procedure handles */ 45*5104Swnj int (*if_init)(); /* init routine */ 465083Swnj int (*if_output)(); /* output routine */ 475083Swnj int (*if_ubareset)(); /* uba reset routine */ 48*5104Swnj /* generic interface statistics */ 49*5104Swnj int if_collisions; /* collisions on csma interfaces */ 50*5104Swnj int if_ierrors; /* input errors */ 51*5104Swnj int if_oerrors; /* output errors */ 52*5104Swnj /* end statistics */ 534951Swnj struct ifnet *if_next; 544945Swnj }; 554945Swnj 56*5104Swnj /* 57*5104Swnj * Output queues (ifp->if_snd) and internetwork datagram level (pup level 1) 58*5104Swnj * input routines have queues of messages stored on ifqueue structures 59*5104Swnj * (defined above). Entries are added to and deleted from these structures 60*5104Swnj * by these macros, which should be called with ipl raised to splimp(). 61*5104Swnj */ 625083Swnj #define IF_ENQUEUE(ifq, m) { \ 635083Swnj (m)->m_act = 0; \ 645083Swnj if ((ifq)->ifq_tail == 0) \ 655083Swnj (ifq)->ifq_head = (ifq)->ifq_tail = m; \ 665083Swnj else \ 675083Swnj (ifq)->ifq_tail->m_act = m; \ 685083Swnj } 695083Swnj #define IF_DEQUEUE(ifq, m) { \ 705083Swnj (m) = (ifq)->ifq_head; \ 715083Swnj if (m) { \ 725083Swnj if (((ifq)->ifq_head = (m)->m_act) == 0) \ 735083Swnj (ifq)->ifq_tail = 0; \ 745083Swnj (m)->m_act = 0; \ 755083Swnj } \ 765083Swnj } 774945Swnj 784945Swnj #ifdef KERNEL 795083Swnj #ifdef INET 805083Swnj struct ifqueue ipintrq; /* ip packet input queue */ 815083Swnj #endif 82*5104Swnj struct ifqueue rawintrq; /* raw packet input queue */ 834945Swnj struct ifnet *ifnet; 845083Swnj struct ifnet *if_ifwithaddr(), *if_ifonnetof(), *if_gatewayfor(); 85*5104Swnj struct in_addr if_makeaddr(); 864945Swnj #endif 87