Deleted Added
full compact
if_disc.c (54263) if_disc.c (71862)
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 * From: @(#)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 * From: @(#)if_loop.c 8.1 (Berkeley) 6/10/93
34 * $FreeBSD: head/sys/net/if_disc.c 54263 1999-12-07 17:39:16Z shin $
34 * $FreeBSD: head/sys/net/if_disc.c 71862 2001-01-31 07:58:58Z peter $
35 */
36
37/*
38 * Discard interface driver for protocol testing and timing.
39 * (Based on the loopback.)
40 */
41
42#include <sys/param.h>
43#include <sys/systm.h>
44#include <sys/kernel.h>
35 */
36
37/*
38 * Discard interface driver for protocol testing and timing.
39 * (Based on the loopback.)
40 */
41
42#include <sys/param.h>
43#include <sys/systm.h>
44#include <sys/kernel.h>
45#include <sys/module.h>
45#include <sys/mbuf.h>
46#include <sys/socket.h>
47#include <sys/sockio.h>
48
49#include <net/if.h>
50#include <net/if_types.h>
51#include <net/route.h>
52#include <net/bpf.h>
53
54#include "opt_inet.h"
55#include "opt_inet6.h"
56
57#ifdef TINY_DSMTU
58#define DSMTU (1024+512)
59#else
60#define DSMTU 65532
61#endif
62
46#include <sys/mbuf.h>
47#include <sys/socket.h>
48#include <sys/sockio.h>
49
50#include <net/if.h>
51#include <net/if_types.h>
52#include <net/route.h>
53#include <net/bpf.h>
54
55#include "opt_inet.h"
56#include "opt_inet6.h"
57
58#ifdef TINY_DSMTU
59#define DSMTU (1024+512)
60#else
61#define DSMTU 65532
62#endif
63
63static void discattach __P((void *dummy));
64PSEUDO_SET(discattach, if_disc);
64static void discattach __P((void));
65
66static struct ifnet discif;
67static int discoutput(struct ifnet *, struct mbuf *, struct sockaddr *,
68 struct rtentry *);
69static void discrtrequest(int cmd, struct rtentry *rt, struct sockaddr *sa);
70static int discioctl(struct ifnet *, u_long, caddr_t);
71
72/* ARGSUSED */
73static void
65
66static struct ifnet discif;
67static int discoutput(struct ifnet *, struct mbuf *, struct sockaddr *,
68 struct rtentry *);
69static void discrtrequest(int cmd, struct rtentry *rt, struct sockaddr *sa);
70static int discioctl(struct ifnet *, u_long, caddr_t);
71
72/* ARGSUSED */
73static void
74discattach(dummy)
75 void *dummy;
74discattach()
76{
77 register struct ifnet *ifp = &discif;
78
79 ifp->if_name = "ds";
80 ifp->if_mtu = DSMTU;
81 ifp->if_flags = IFF_LOOPBACK | IFF_MULTICAST;
82 ifp->if_ioctl = discioctl;
83 ifp->if_output = discoutput;
84 ifp->if_type = IFT_LOOP;
85 ifp->if_hdrlen = 0;
86 ifp->if_addrlen = 0;
87 ifp->if_snd.ifq_maxlen = 20;
88 if_attach(ifp);
89 bpfattach(ifp, DLT_NULL, sizeof(u_int));
90}
91
92static int
75{
76 register struct ifnet *ifp = &discif;
77
78 ifp->if_name = "ds";
79 ifp->if_mtu = DSMTU;
80 ifp->if_flags = IFF_LOOPBACK | IFF_MULTICAST;
81 ifp->if_ioctl = discioctl;
82 ifp->if_output = discoutput;
83 ifp->if_type = IFT_LOOP;
84 ifp->if_hdrlen = 0;
85 ifp->if_addrlen = 0;
86 ifp->if_snd.ifq_maxlen = 20;
87 if_attach(ifp);
88 bpfattach(ifp, DLT_NULL, sizeof(u_int));
89}
90
91static int
92disc_modevent(module_t mod, int type, void *data)
93{
94 switch (type) {
95 case MOD_LOAD:
96 discattach();
97 break;
98 case MOD_UNLOAD:
99 printf("if_disc module unload - not possible for this module type\n");
100 return EINVAL;
101 }
102 return 0;
103}
104
105static moduledata_t disc_mod = {
106 "if_disc",
107 disc_modevent,
108 NULL
109};
110
111DECLARE_MODULE(if_disc, disc_mod, SI_SUB_PSEUDO, SI_ORDER_ANY);
112
113static int
93discoutput(ifp, m, dst, rt)
94 struct ifnet *ifp;
95 register struct mbuf *m;
96 struct sockaddr *dst;
97 register struct rtentry *rt;
98{
99 if ((m->m_flags & M_PKTHDR) == 0)
100 panic("discoutput no HDR");

--- 103 unchanged lines hidden ---
114discoutput(ifp, m, dst, rt)
115 struct ifnet *ifp;
116 register struct mbuf *m;
117 struct sockaddr *dst;
118 register struct rtentry *rt;
119{
120 if ((m->m_flags & M_PKTHDR) == 0)
121 panic("discoutput no HDR");

--- 103 unchanged lines hidden ---