if_loop.c (147256) | if_loop.c (147611) |
---|---|
1/*- 2 * Copyright (c) 1982, 1986, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 13 unchanged lines hidden (view full) --- 22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 * SUCH DAMAGE. 28 * 29 * @(#)if_loop.c 8.2 (Berkeley) 1/9/95 | 1/*- 2 * Copyright (c) 1982, 1986, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 13 unchanged lines hidden (view full) --- 22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 * SUCH DAMAGE. 28 * 29 * @(#)if_loop.c 8.2 (Berkeley) 1/9/95 |
30 * $FreeBSD: head/sys/net/if_loop.c 147256 2005-06-10 16:49:24Z brooks $ | 30 * $FreeBSD: head/sys/net/if_loop.c 147611 2005-06-26 18:11:11Z dwmalone $ |
31 */ 32 33/* 34 * Loopback interface driver for protocol testing and timing. 35 */ 36 37#include "opt_atalk.h" 38#include "opt_inet.h" --- 112 unchanged lines hidden (view full) --- 151 if_initname(ifp, ifc->ifc_name, unit); 152 ifp->if_mtu = LOMTU; 153 ifp->if_flags = IFF_LOOPBACK | IFF_MULTICAST; 154 ifp->if_ioctl = loioctl; 155 ifp->if_output = looutput; 156 ifp->if_snd.ifq_maxlen = ifqmaxlen; 157 ifp->if_softc = sc; 158 if_attach(ifp); | 31 */ 32 33/* 34 * Loopback interface driver for protocol testing and timing. 35 */ 36 37#include "opt_atalk.h" 38#include "opt_inet.h" --- 112 unchanged lines hidden (view full) --- 151 if_initname(ifp, ifc->ifc_name, unit); 152 ifp->if_mtu = LOMTU; 153 ifp->if_flags = IFF_LOOPBACK | IFF_MULTICAST; 154 ifp->if_ioctl = loioctl; 155 ifp->if_output = looutput; 156 ifp->if_snd.ifq_maxlen = ifqmaxlen; 157 ifp->if_softc = sc; 158 if_attach(ifp); |
159 bpfattach(ifp, DLT_NULL, sizeof(u_int)); | 159 bpfattach(ifp, DLT_NULL, sizeof(u_int32_t)); |
160 mtx_lock(&lo_mtx); 161 LIST_INSERT_HEAD(&lo_list, sc, sc_next); 162 mtx_unlock(&lo_mtx); 163 if (loif == NULL) 164 loif = ifp; 165 166 return (0); 167} --- 26 unchanged lines hidden (view full) --- 194 195int 196looutput(ifp, m, dst, rt) 197 struct ifnet *ifp; 198 register struct mbuf *m; 199 struct sockaddr *dst; 200 register struct rtentry *rt; 201{ | 160 mtx_lock(&lo_mtx); 161 LIST_INSERT_HEAD(&lo_list, sc, sc_next); 162 mtx_unlock(&lo_mtx); 163 if (loif == NULL) 164 loif = ifp; 165 166 return (0); 167} --- 26 unchanged lines hidden (view full) --- 194 195int 196looutput(ifp, m, dst, rt) 197 struct ifnet *ifp; 198 register struct mbuf *m; 199 struct sockaddr *dst; 200 register struct rtentry *rt; 201{ |
202 u_int32_t af; 203 |
|
202 M_ASSERTPKTHDR(m); /* check if we have the packet header */ 203 204 if (rt && rt->rt_flags & (RTF_REJECT|RTF_BLACKHOLE)) { 205 m_freem(m); 206 return (rt->rt_flags & RTF_BLACKHOLE ? 0 : 207 rt->rt_flags & RTF_HOST ? EHOSTUNREACH : ENETUNREACH); 208 } 209 210 ifp->if_opackets++; 211 ifp->if_obytes += m->m_pkthdr.len; | 204 M_ASSERTPKTHDR(m); /* check if we have the packet header */ 205 206 if (rt && rt->rt_flags & (RTF_REJECT|RTF_BLACKHOLE)) { 207 m_freem(m); 208 return (rt->rt_flags & RTF_BLACKHOLE ? 0 : 209 rt->rt_flags & RTF_HOST ? EHOSTUNREACH : ENETUNREACH); 210 } 211 212 ifp->if_opackets++; 213 ifp->if_obytes += m->m_pkthdr.len; |
214 215 /* BPF writes need to be handled specially. */ 216 if (dst->sa_family == AF_UNSPEC) { 217 bcopy(dst->sa_data, &af, sizeof(af)); 218 dst->sa_family = af; 219 } 220 |
|
212#if 1 /* XXX */ 213 switch (dst->sa_family) { 214 case AF_INET: 215 case AF_INET6: 216 case AF_IPX: 217 case AF_APPLETALK: 218 break; 219 default: --- 24 unchanged lines hidden (view full) --- 244 int hlen; 245{ 246 int isr; 247 248 M_ASSERTPKTHDR(m); 249 m_tag_delete_nonpersistent(m); 250 m->m_pkthdr.rcvif = ifp; 251 | 221#if 1 /* XXX */ 222 switch (dst->sa_family) { 223 case AF_INET: 224 case AF_INET6: 225 case AF_IPX: 226 case AF_APPLETALK: 227 break; 228 default: --- 24 unchanged lines hidden (view full) --- 253 int hlen; 254{ 255 int isr; 256 257 M_ASSERTPKTHDR(m); 258 m_tag_delete_nonpersistent(m); 259 m->m_pkthdr.rcvif = ifp; 260 |
252 /* BPF write needs to be handled specially */ 253 if (af == AF_UNSPEC) { 254 KASSERT(m->m_len >= sizeof(int), ("if_simloop: m_len")); 255 af = *(mtod(m, int *)); 256 m->m_len -= sizeof(int); 257 m->m_pkthdr.len -= sizeof(int); 258 m->m_data += sizeof(int); 259 } 260 | |
261 /* Let BPF see incoming packet */ 262 if (ifp->if_bpf) { 263 if (ifp->if_bpf->bif_dlt == DLT_NULL) { 264 u_int32_t af1 = af; /* XXX beware sizeof(af) != 4 */ 265 /* 266 * We need to prepend the address family. 267 */ 268 bpf_mtap2(ifp->if_bpf, &af1, sizeof(af1), m); --- 126 unchanged lines hidden --- | 261 /* Let BPF see incoming packet */ 262 if (ifp->if_bpf) { 263 if (ifp->if_bpf->bif_dlt == DLT_NULL) { 264 u_int32_t af1 = af; /* XXX beware sizeof(af) != 4 */ 265 /* 266 * We need to prepend the address family. 267 */ 268 bpf_mtap2(ifp->if_bpf, &af1, sizeof(af1), m); --- 126 unchanged lines hidden --- |