* Copyright (c) 1982, 1986 Regents of the University of California.
* Redistribution and use in source and binary forms are permitted
* provided that this notice is preserved and that due credit is given
* to the University of California at Berkeley. The name of the University
* may not be used to endorse or promote products derived from this
* software without specific prior written permission. This software
* is provided ``as is'' without express or implied warranty.
* @(#)if_loop.c 7.3 (Berkeley) %G%
* Loopback interface driver for protocol testing and timing.
#include "../net/netisr.h"
#include "../net/route.h"
#include "../machine/mtpr.h"
#include "../netinet/in.h"
#include "../netinet/in_systm.h"
#include "../netinet/in_var.h"
#include "../netinet/ip.h"
#include "../netns/ns_if.h"
int looutput(), loioctl();
register struct ifnet
*ifp
= &loif
;
ifp
->if_flags
= IFF_LOOPBACK
;
ifp
->if_output
= looutput
;
register struct mbuf
*m0
;
register struct ifqueue
*ifq
;
* Place interface pointer before the data
* for the receiving protocol.
if (m0
->m_off
<= MMAXOFF
&&
m0
->m_off
>= MMINOFF
+ sizeof(struct ifnet
*)) {
m0
->m_off
-= sizeof(struct ifnet
*);
m0
->m_len
+= sizeof(struct ifnet
*);
MGET(m
, M_DONTWAIT
, MT_HEADER
);
if (m
== (struct mbuf
*)0)
m
->m_len
= sizeof(struct ifnet
*);
*(mtod(m0
, struct ifnet
**)) = ifp
;
switch (dst
->sa_family
) {
printf("lo%d: can't handle af%d\n", ifp
->if_unit
,
* Process an ioctl request.
register struct ifnet
*ifp
;
* Everything else is done at a higher level.