Deleted Added
full compact
if_disc.c (147256) if_disc.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 * 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

--- 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 * From: @(#)if_loop.c 8.1 (Berkeley) 6/10/93
30 * $FreeBSD: head/sys/net/if_disc.c 147256 2005-06-10 16:49:24Z brooks $
30 * $FreeBSD: head/sys/net/if_disc.c 147611 2005-06-26 18:11:11Z dwmalone $
31 */
32
33/*
34 * Discard interface driver for protocol testing and timing.
35 * (Based on the loopback.)
36 */
37
38#include <sys/param.h>

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

97 ifp->if_mtu = DSMTU;
98 ifp->if_flags = IFF_LOOPBACK | IFF_MULTICAST;
99 ifp->if_ioctl = discioctl;
100 ifp->if_output = discoutput;
101 ifp->if_hdrlen = 0;
102 ifp->if_addrlen = 0;
103 ifp->if_snd.ifq_maxlen = 20;
104 if_attach(ifp);
31 */
32
33/*
34 * Discard interface driver for protocol testing and timing.
35 * (Based on the loopback.)
36 */
37
38#include <sys/param.h>

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

97 ifp->if_mtu = DSMTU;
98 ifp->if_flags = IFF_LOOPBACK | IFF_MULTICAST;
99 ifp->if_ioctl = discioctl;
100 ifp->if_output = discoutput;
101 ifp->if_hdrlen = 0;
102 ifp->if_addrlen = 0;
103 ifp->if_snd.ifq_maxlen = 20;
104 if_attach(ifp);
105 bpfattach(ifp, DLT_NULL, sizeof(u_int));
105 bpfattach(ifp, DLT_NULL, sizeof(u_int32_t));
106 mtx_lock(&disc_mtx);
107 LIST_INSERT_HEAD(&disc_softc_list, sc, sc_list);
108 mtx_unlock(&disc_mtx);
109
110 return (0);
111}
112
113static void

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

171};
172
173DECLARE_MODULE(if_disc, disc_mod, SI_SUB_PSEUDO, SI_ORDER_ANY);
174
175static int
176discoutput(struct ifnet *ifp, struct mbuf *m, struct sockaddr *dst,
177 struct rtentry *rt)
178{
106 mtx_lock(&disc_mtx);
107 LIST_INSERT_HEAD(&disc_softc_list, sc, sc_list);
108 mtx_unlock(&disc_mtx);
109
110 return (0);
111}
112
113static void

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

171};
172
173DECLARE_MODULE(if_disc, disc_mod, SI_SUB_PSEUDO, SI_ORDER_ANY);
174
175static int
176discoutput(struct ifnet *ifp, struct mbuf *m, struct sockaddr *dst,
177 struct rtentry *rt)
178{
179 u_int32_t af;
179
180 M_ASSERTPKTHDR(m);
181
180
181 M_ASSERTPKTHDR(m);
182
182 /* BPF write needs to be handled specially */
183 /* BPF writes need to be handled specially. */
183 if (dst->sa_family == AF_UNSPEC) {
184 if (dst->sa_family == AF_UNSPEC) {
184 dst->sa_family = *(mtod(m, int *));
185 m->m_len -= sizeof(int);
186 m->m_pkthdr.len -= sizeof(int);
187 m->m_data += sizeof(int);
185 bcopy(dst->sa_data, &af, sizeof(af));
186 dst->sa_family = af;
188 }
189
190 if (ifp->if_bpf) {
191 u_int af = dst->sa_family;
192 bpf_mtap2(ifp->if_bpf, &af, sizeof(af), m);
193 }
194 m->m_pkthdr.rcvif = ifp;
195

--- 69 unchanged lines hidden ---
187 }
188
189 if (ifp->if_bpf) {
190 u_int af = dst->sa_family;
191 bpf_mtap2(ifp->if_bpf, &af, sizeof(af), m);
192 }
193 m->m_pkthdr.rcvif = ifp;
194

--- 69 unchanged lines hidden ---