1 /* if_loop.c 4.2 81/12/02 */ 2 3 /* 4 * Loopback interface driver for protocol testing and timing. 5 */ 6 7 #include "../h/param.h" 8 #include "../h/systm.h" 9 #include "../h/mbuf.h" 10 #include "../h/socket.h" 11 #include "../net/in.h" 12 #include "../net/in_systm.h" 13 #include "../net/if.h" 14 #include "../net/ip.h" 15 #include "../net/ip_var.h" 16 #include "../h/mtpr.h" 17 18 #define LONET 254 19 #define LOMTU 1024 20 21 struct ifnet loif; 22 int looutput(); 23 24 loattach() 25 { 26 register struct ifnet *ifp = &loif; 27 28 ifp->if_mtu = LOMTU; 29 ifp->if_net = LONET; 30 ifp->if_output = looutput; 31 ifp->if_next = ifnet; 32 if_attach(ifp); 33 } 34 35 looutput(ifp, m0, pf) 36 struct ifnet *ifp; 37 struct mbuf *m0; 38 int pf; 39 { 40 int s = splimp(); 41 42 switch (pf) { 43 44 #ifdef INET 45 case PF_INET: 46 IF_ENQUEUE(&ipintrq, m0); 47 setipintr(); 48 break; 49 #endif 50 51 default: 52 splx(s); 53 printf("lo%d: can't encapsulate pf%d\n", ifp->if_unit, pf); 54 m_freem(m0); 55 return (0); 56 } 57 splx(s); 58 return (1); 59 } 60