Deleted Added
full compact
if_loop.c (77900) if_loop.c (78064)
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

--- 17 unchanged lines hidden (view full) ---

26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.
32 *
33 * @(#)if_loop.c 8.1 (Berkeley) 6/10/93
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

--- 17 unchanged lines hidden (view full) ---

26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.
32 *
33 * @(#)if_loop.c 8.1 (Berkeley) 6/10/93
34 * $FreeBSD: head/sys/net/if_loop.c 77900 2001-06-08 05:24:21Z peter $
34 * $FreeBSD: head/sys/net/if_loop.c 78064 2001-06-11 12:39:29Z ume $
35 */
36
37/*
38 * Loopback interface driver for protocol testing and timing.
39 */
40
41#include "opt_atalk.h"
42#include "opt_inet.h"

--- 10 unchanged lines hidden (view full) ---

53#include <sys/sockio.h>
54#include <sys/sysctl.h>
55
56#include <net/if.h>
57#include <net/if_types.h>
58#include <net/netisr.h>
59#include <net/route.h>
60#include <net/bpf.h>
35 */
36
37/*
38 * Loopback interface driver for protocol testing and timing.
39 */
40
41#include "opt_atalk.h"
42#include "opt_inet.h"

--- 10 unchanged lines hidden (view full) ---

53#include <sys/sockio.h>
54#include <sys/sysctl.h>
55
56#include <net/if.h>
57#include <net/if_types.h>
58#include <net/netisr.h>
59#include <net/route.h>
60#include <net/bpf.h>
61#include <net/bpfdesc.h>
61
62#ifdef INET
63#include <netinet/in.h>
64#include <netinet/in_var.h>
65#endif
66
67#ifdef IPX
68#include <netipx/ipx.h>

--- 162 unchanged lines hidden (view full) ---

231 if (! (n->m_flags & M_EXT)) {
232 m_freem(n);
233 goto contiguousfail;
234 }
235
236 m_copydata(m, 0, m->m_pkthdr.len, mtod(n, caddr_t));
237 n->m_pkthdr = m->m_pkthdr;
238 n->m_len = m->m_pkthdr.len;
62
63#ifdef INET
64#include <netinet/in.h>
65#include <netinet/in_var.h>
66#endif
67
68#ifdef IPX
69#include <netipx/ipx.h>

--- 162 unchanged lines hidden (view full) ---

232 if (! (n->m_flags & M_EXT)) {
233 m_freem(n);
234 goto contiguousfail;
235 }
236
237 m_copydata(m, 0, m->m_pkthdr.len, mtod(n, caddr_t));
238 n->m_pkthdr = m->m_pkthdr;
239 n->m_len = m->m_pkthdr.len;
240 n->m_pkthdr.aux = m->m_pkthdr.aux;
241 m->m_pkthdr.aux = (struct mbuf *)NULL;
239 m_freem(m);
240 m = n;
241 }
242 if (0) {
243contiguousfail:
244 printf("looutput: mbuf allocation failed\n");
245 }
246

--- 25 unchanged lines hidden (view full) ---

272 * would normally receive via a hardware loopback.
273 *
274 * This function expects the packet to include the media header of length hlen.
275 */
276
277int
278if_simloop(ifp, m, af, hlen)
279 struct ifnet *ifp;
242 m_freem(m);
243 m = n;
244 }
245 if (0) {
246contiguousfail:
247 printf("looutput: mbuf allocation failed\n");
248 }
249

--- 25 unchanged lines hidden (view full) ---

275 * would normally receive via a hardware loopback.
276 *
277 * This function expects the packet to include the media header of length hlen.
278 */
279
280int
281if_simloop(ifp, m, af, hlen)
282 struct ifnet *ifp;
280 register struct mbuf *m;
283 struct mbuf *m;
281 int af;
282 int hlen;
283{
284 int isr;
285 struct ifqueue *inq = 0;
286
287 KASSERT((m->m_flags & M_PKTHDR) != 0, ("if_simloop: no HDR"));
288 m->m_pkthdr.rcvif = ifp;

--- 6 unchanged lines hidden (view full) ---

295 m->m_pkthdr.len -= sizeof(int);
296 m->m_data += sizeof(int);
297 }
298
299 /* Let BPF see incoming packet */
300 if (ifp->if_bpf) {
301 struct mbuf m0, *n = m;
302
284 int af;
285 int hlen;
286{
287 int isr;
288 struct ifqueue *inq = 0;
289
290 KASSERT((m->m_flags & M_PKTHDR) != 0, ("if_simloop: no HDR"));
291 m->m_pkthdr.rcvif = ifp;

--- 6 unchanged lines hidden (view full) ---

298 m->m_pkthdr.len -= sizeof(int);
299 m->m_data += sizeof(int);
300 }
301
302 /* Let BPF see incoming packet */
303 if (ifp->if_bpf) {
304 struct mbuf m0, *n = m;
305
303 /*
304 * We need to prepend the address family as
305 * a four byte field. Cons up a dummy header
306 * to pacify bpf. This is safe because bpf
307 * will only read from the mbuf (i.e., it won't
308 * try to free it or keep a pointer a to it).
309 */
310 m0.m_next = m;
311 m0.m_len = 4;
312 m0.m_data = (char *)&af;
313 n = &m0;
306 if (ifp->if_bpf->bif_dlt == DLT_NULL) {
307 /*
308 * We need to prepend the address family as
309 * a four byte field. Cons up a dummy header
310 * to pacify bpf. This is safe because bpf
311 * will only read from the mbuf (i.e., it won't
312 * try to free it or keep a pointer a to it).
313 */
314 m0.m_next = m;
315 m0.m_len = 4;
316 m0.m_data = (char *)&af;
317 n = &m0;
318 }
314 bpf_mtap(ifp, n);
315 }
316
317 /* Strip away media header */
318 if (hlen > 0) {
319 m_adj(m, hlen);
320#ifdef __alpha__
321 /* The alpha doesn't like unaligned data.

--- 136 unchanged lines hidden ---
319 bpf_mtap(ifp, n);
320 }
321
322 /* Strip away media header */
323 if (hlen > 0) {
324 m_adj(m, hlen);
325#ifdef __alpha__
326 /* The alpha doesn't like unaligned data.

--- 136 unchanged lines hidden ---