diff options
author | pst <pst@FreeBSD.org> | 1995-04-26 18:10:58 +0000 |
---|---|---|
committer | pst <pst@FreeBSD.org> | 1995-04-26 18:10:58 +0000 |
commit | 321a03d090577e9d6eb90169b5ded161378501ea (patch) | |
tree | 1e8321bb9cb38240fa0ad1fef8d725457a725bb8 /sys/net | |
parent | a153267748ead18b28287e3a1a46a720b15d4f8a (diff) | |
download | FreeBSD-src-321a03d090577e9d6eb90169b5ded161378501ea.zip FreeBSD-src-321a03d090577e9d6eb90169b5ded161378501ea.tar.gz |
Cleanup loopback interface support.
Reviewed by: wollman
Diffstat (limited to 'sys/net')
-rw-r--r-- | sys/net/if.h | 4 | ||||
-rw-r--r-- | sys/net/if_loop.c | 40 |
2 files changed, 26 insertions, 18 deletions
diff --git a/sys/net/if.h b/sys/net/if.h index 56a292d..987e5c4 100644 --- a/sys/net/if.h +++ b/sys/net/if.h @@ -31,7 +31,7 @@ * SUCH DAMAGE. * * @(#)if.h 8.1 (Berkeley) 6/10/93 - * $Id: if.h,v 1.15 1994/12/30 06:46:21 davidg Exp $ + * $Id: if.h,v 1.16 1995/03/16 18:14:24 bde Exp $ */ #ifndef _NET_IF_H_ @@ -350,7 +350,7 @@ struct ifconf { (ifa)->ifa_refcnt--; extern struct ifnet *ifnet; -extern struct ifnet loif; +extern struct ifnet loif[]; void ether_ifattach __P((struct ifnet *)); void ether_input __P((struct ifnet *, struct ether_header *, struct mbuf *)); diff --git a/sys/net/if_loop.c b/sys/net/if_loop.c index f990dac..708da73 100644 --- a/sys/net/if_loop.c +++ b/sys/net/if_loop.c @@ -31,12 +31,14 @@ * SUCH DAMAGE. * * @(#)if_loop.c 8.1 (Berkeley) 6/10/93 - * $Id: if_loop.c,v 1.7 1995/03/04 04:28:50 davidg Exp $ + * $Id: if_loop.c,v 1.8 1995/03/20 19:20:41 wollman Exp $ */ /* * Loopback interface driver for protocol testing and timing. */ +#include "loop.h" +#if NLOOP > 0 #include <sys/param.h> #include <sys/systm.h> @@ -79,26 +81,31 @@ #define LOMTU 16384 #endif -struct ifnet loif; +struct ifnet loif[NLOOP]; /* ARGSUSED */ void loopattach(void) { - register struct ifnet *ifp = &loif; - - ifp->if_name = "lo"; - ifp->if_mtu = LOMTU; - ifp->if_flags = IFF_LOOPBACK | IFF_MULTICAST; - ifp->if_ioctl = loioctl; - ifp->if_output = looutput; - ifp->if_type = IFT_LOOP; - ifp->if_hdrlen = 0; - ifp->if_addrlen = 0; - if_attach(ifp); + register struct ifnet *ifp; + register int i = 0; + + for (ifp = loif; i < NLOOP; ifp++) { + ifp->if_name = "lo"; + ifp->if_next = NULL; + ifp->if_unit = i++; + ifp->if_mtu = LOMTU; + ifp->if_flags = IFF_LOOPBACK | IFF_MULTICAST; + ifp->if_ioctl = loioctl; + ifp->if_output = looutput; + ifp->if_type = IFT_LOOP; + ifp->if_hdrlen = 0; + ifp->if_addrlen = 0; + if_attach(ifp); #if NBPFILTER > 0 - bpfattach(&ifp->if_bpf, ifp, DLT_NULL, sizeof(u_int)); + bpfattach(&ifp->if_bpf, ifp, DLT_NULL, sizeof(u_int)); #endif + } } PSEUDO_SET(loopattach, if_loop); @@ -117,7 +124,7 @@ looutput(ifp, m, dst, rt) panic("looutput no HDR"); ifp->if_lastchange = time; #if NBPFILTER > 0 - if (loif.if_bpf) { + if (ifp->if_bpf) { /* * We need to prepend the address family as * a four byte field. Cons up a dummy header @@ -132,7 +139,7 @@ looutput(ifp, m, dst, rt) m0.m_len = 4; m0.m_data = (char *)⁡ - bpf_mtap(loif.if_bpf, &m0); + bpf_mtap(ifp->if_bpf, &m0); } #endif m->m_pkthdr.rcvif = ifp; @@ -251,3 +258,4 @@ loioctl(ifp, cmd, data) } return (error); } +#endif /* NLOOP > 0 */ |