Deleted Added
full compact
ng_iface.c (147256) ng_iface.c (147611)
1/*
2 * ng_iface.c
3 */
4
5/*-
6 * Copyright (c) 1996-1999 Whistle Communications, Inc.
7 * All rights reserved.
8 *

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

32 * SERVICES, LOSS OF USE, DATA OR PROFITS, HOWEVER CAUSED AND UNDER ANY
33 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
34 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
35 * THIS SOFTWARE, EVEN IF WHISTLE COMMUNICATIONS IS ADVISED OF THE POSSIBILITY
36 * OF SUCH DAMAGE.
37 *
38 * Author: Archie Cobbs <archie@freebsd.org>
39 *
1/*
2 * ng_iface.c
3 */
4
5/*-
6 * Copyright (c) 1996-1999 Whistle Communications, Inc.
7 * All rights reserved.
8 *

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

32 * SERVICES, LOSS OF USE, DATA OR PROFITS, HOWEVER CAUSED AND UNDER ANY
33 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
34 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
35 * THIS SOFTWARE, EVEN IF WHISTLE COMMUNICATIONS IS ADVISED OF THE POSSIBILITY
36 * OF SUCH DAMAGE.
37 *
38 * Author: Archie Cobbs <archie@freebsd.org>
39 *
40 * $FreeBSD: head/sys/netgraph/ng_iface.c 147256 2005-06-10 16:49:24Z brooks $
40 * $FreeBSD: head/sys/netgraph/ng_iface.c 147611 2005-06-26 18:11:11Z dwmalone $
41 * $Whistle: ng_iface.c,v 1.33 1999/11/01 09:24:51 julian Exp $
42 */
43
44/*
45 * This node is also a system networking interface. It has
46 * a hook for each protocol (IP, AppleTalk, IPX, etc). Packets
47 * are simply relayed between the interface and the hooks.
48 *

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

347
348static int
349ng_iface_output(struct ifnet *ifp, struct mbuf *m,
350 struct sockaddr *dst, struct rtentry *rt0)
351{
352 const priv_p priv = (priv_p) ifp->if_softc;
353 const iffam_p iffam = get_iffam_from_af(dst->sa_family);
354 int len, error = 0;
41 * $Whistle: ng_iface.c,v 1.33 1999/11/01 09:24:51 julian Exp $
42 */
43
44/*
45 * This node is also a system networking interface. It has
46 * a hook for each protocol (IP, AppleTalk, IPX, etc). Packets
47 * are simply relayed between the interface and the hooks.
48 *

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

347
348static int
349ng_iface_output(struct ifnet *ifp, struct mbuf *m,
350 struct sockaddr *dst, struct rtentry *rt0)
351{
352 const priv_p priv = (priv_p) ifp->if_softc;
353 const iffam_p iffam = get_iffam_from_af(dst->sa_family);
354 int len, error = 0;
355 u_int32_t af;
355
356 /* Check interface flags */
357 if ((ifp->if_flags & (IFF_UP|IFF_RUNNING)) != (IFF_UP|IFF_RUNNING)) {
358 m_freem(m);
359 return (ENETDOWN);
360 }
361
356
357 /* Check interface flags */
358 if ((ifp->if_flags & (IFF_UP|IFF_RUNNING)) != (IFF_UP|IFF_RUNNING)) {
359 m_freem(m);
360 return (ENETDOWN);
361 }
362
362 /* BPF writes need to be handled specially */
363 /* BPF writes need to be handled specially. */
363 if (dst->sa_family == AF_UNSPEC) {
364 if (dst->sa_family == AF_UNSPEC) {
364 if (m->m_len < 4 && (m = m_pullup(m, 4)) == NULL)
365 return (ENOBUFS);
366 dst->sa_family = (sa_family_t)*mtod(m, int32_t *);
367 m->m_data += 4;
368 m->m_len -= 4;
369 m->m_pkthdr.len -= 4;
365 bcopy(dst->sa_data, &af, sizeof(af));
366 dst->sa_family = af;
370 }
371
372 /* Berkeley packet filter */
373 ng_iface_bpftap(ifp, m, dst->sa_family);
374
375 /* Check address family to determine hook (if known) */
376 if (iffam == NULL) {
377 m_freem(m);

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

503
504 /* Give this node the same name as the interface (if possible) */
505 if (ng_name_node(node, ifp->if_xname) != 0)
506 log(LOG_WARNING, "%s: can't acquire netgraph name\n",
507 ifp->if_xname);
508
509 /* Attach the interface */
510 if_attach(ifp);
367 }
368
369 /* Berkeley packet filter */
370 ng_iface_bpftap(ifp, m, dst->sa_family);
371
372 /* Check address family to determine hook (if known) */
373 if (iffam == NULL) {
374 m_freem(m);

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

500
501 /* Give this node the same name as the interface (if possible) */
502 if (ng_name_node(node, ifp->if_xname) != 0)
503 log(LOG_WARNING, "%s: can't acquire netgraph name\n",
504 ifp->if_xname);
505
506 /* Attach the interface */
507 if_attach(ifp);
511 bpfattach(ifp, DLT_NULL, sizeof(u_int));
508 bpfattach(ifp, DLT_NULL, sizeof(u_int32_t));
512
513 /* Done */
514 return (0);
515}
516
517/*
518 * Give our ok for a hook to be added
519 */

--- 253 unchanged lines hidden ---
509
510 /* Done */
511 return (0);
512}
513
514/*
515 * Give our ok for a hook to be added
516 */

--- 253 unchanged lines hidden ---