1*5160Swnj /* if.h 4.5 81/12/02 */ 24945Swnj 34945Swnj /* 45104Swnj * Structures defining a network interface, providing a packet 55104Swnj * transport mechanism (ala level 0 of the PUP protocols). 65104Swnj * 75104Swnj * Each interface accepts output datagrams of a specified maximum 85104Swnj * length, and provides higher level routines with input datagrams 95104Swnj * received from its medium. 105104Swnj * 115104Swnj * Output occurs when the routine if_output is called, with three parameters: 125104Swnj * (*ifp->if_output)(ifp, m, pf) 135104Swnj * Here m is the mbuf chain to be sent and pf is the protocol family 145104Swnj * of the internetwork datagram format in which the data is wrapped 155104Swnj * (e.g. PF_PUP or PF_INET). The output routine encapsulates the 165104Swnj * supplied datagram if necessary, and then transmits it on its medium. 175104Swnj * 185104Swnj * On input, each interface unwraps the data received by it, and either 195104Swnj * places it on the input queue of a internetwork datagram routine 205104Swnj * and posts the associated software interrupt, or passes the datagram to a raw 215104Swnj * packet input routine. 225104Swnj * 235104Swnj * Routines exist for locating interfaces by their internet addresses 245104Swnj * or for locating a interface on a certain network, as well as more general 255104Swnj * routing and gateway routines maintaining information used to locate 265104Swnj * 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 */ 405104Swnj struct ifqueue { 415104Swnj struct mbuf *ifq_head; 425104Swnj struct mbuf *ifq_tail; 435104Swnj } if_snd; /* output queue */ 445104Swnj /* procedure handles */ 455104Swnj int (*if_init)(); /* init routine */ 465083Swnj int (*if_output)(); /* output routine */ 475083Swnj int (*if_ubareset)(); /* uba reset routine */ 485104Swnj /* generic interface statistics */ 495104Swnj int if_collisions; /* collisions on csma interfaces */ 505104Swnj int if_ierrors; /* input errors */ 515104Swnj int if_oerrors; /* output errors */ 525104Swnj /* end statistics */ 534951Swnj struct ifnet *if_next; 544945Swnj }; 554945Swnj 565104Swnj /* 575104Swnj * Output queues (ifp->if_snd) and internetwork datagram level (pup level 1) 585104Swnj * input routines have queues of messages stored on ifqueue structures 595104Swnj * (defined above). Entries are added to and deleted from these structures 605104Swnj * by these macros, which should be called with ipl raised to splimp(). 615104Swnj */ 625083Swnj #define IF_ENQUEUE(ifq, m) { \ 635083Swnj (m)->m_act = 0; \ 645083Swnj if ((ifq)->ifq_tail == 0) \ 65*5160Swnj (ifq)->ifq_head = m; \ 665083Swnj else \ 675083Swnj (ifq)->ifq_tail->m_act = m; \ 68*5160Swnj (ifq)->ifq_tail = m; \ 695083Swnj } 705083Swnj #define IF_DEQUEUE(ifq, m) { \ 715083Swnj (m) = (ifq)->ifq_head; \ 725083Swnj if (m) { \ 735083Swnj if (((ifq)->ifq_head = (m)->m_act) == 0) \ 745083Swnj (ifq)->ifq_tail = 0; \ 755083Swnj (m)->m_act = 0; \ 765083Swnj } \ 775083Swnj } 784945Swnj 794945Swnj #ifdef KERNEL 805083Swnj #ifdef INET 815083Swnj struct ifqueue ipintrq; /* ip packet input queue */ 825083Swnj #endif 835104Swnj struct ifqueue rawintrq; /* raw packet input queue */ 844945Swnj struct ifnet *ifnet; 855083Swnj struct ifnet *if_ifwithaddr(), *if_ifonnetof(), *if_gatewayfor(); 865104Swnj struct in_addr if_makeaddr(); 874945Swnj #endif 88