Deleted Added
full compact
ng_iface.c (106933) ng_iface.c (111888)
1
2/*
3 * ng_iface.c
4 *
5 * Copyright (c) 1996-1999 Whistle Communications, Inc.
6 * All rights reserved.
7 *
8 * Subject to the following obligations and disclaimer of warranty, use and
9 * redistribution of this software, in source or object code forms, with or

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

31 * SERVICES, LOSS OF USE, DATA OR PROFITS, HOWEVER CAUSED AND UNDER ANY
32 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
33 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
34 * THIS SOFTWARE, EVEN IF WHISTLE COMMUNICATIONS IS ADVISED OF THE POSSIBILITY
35 * OF SUCH DAMAGE.
36 *
37 * Author: Archie Cobbs <archie@freebsd.org>
38 *
1/*
2 * ng_iface.c
3 *
4 * Copyright (c) 1996-1999 Whistle Communications, Inc.
5 * All rights reserved.
6 *
7 * Subject to the following obligations and disclaimer of warranty, use and
8 * redistribution of this software, in source or object code forms, with or

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

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

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

53
54#include <sys/param.h>
55#include <sys/systm.h>
56#include <sys/errno.h>
57#include <sys/kernel.h>
58#include <sys/malloc.h>
59#include <sys/mbuf.h>
60#include <sys/errno.h>
39 * $Whistle: ng_iface.c,v 1.33 1999/11/01 09:24:51 julian Exp $
40 */
41
42/*
43 * This node is also a system networking interface. It has
44 * a hook for each protocol (IP, AppleTalk, IPX, etc). Packets
45 * are simply relayed between the interface and the hooks.
46 *

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

52
53#include <sys/param.h>
54#include <sys/systm.h>
55#include <sys/errno.h>
56#include <sys/kernel.h>
57#include <sys/malloc.h>
58#include <sys/mbuf.h>
59#include <sys/errno.h>
60#include <sys/random.h>
61#include <sys/sockio.h>
62#include <sys/socket.h>
63#include <sys/syslog.h>
64#include <sys/libkern.h>
65
66#include <net/if.h>
67#include <net/if_types.h>
61#include <sys/sockio.h>
62#include <sys/socket.h>
63#include <sys/syslog.h>
64#include <sys/libkern.h>
65
66#include <net/if.h>
67#include <net/if_types.h>
68#include <net/intrq.h>
69#include <net/bpf.h>
68#include <net/bpf.h>
69#include <net/netisr.h>
70
71#include <netinet/in.h>
72
73#include <netgraph/ng_message.h>
74#include <netgraph/netgraph.h>
75#include <netgraph/ng_parse.h>
76#include <netgraph/ng_iface.h>
77#include <netgraph/ng_cisco.h>

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

724 */
725static int
726ng_iface_rcvdata(hook_p hook, item_p item)
727{
728 const priv_p priv = NG_NODE_PRIVATE(NG_HOOK_NODE(hook));
729 const iffam_p iffam = get_iffam_from_hook(priv, hook);
730 struct ifnet *const ifp = priv->ifp;
731 struct mbuf *m;
70
71#include <netinet/in.h>
72
73#include <netgraph/ng_message.h>
74#include <netgraph/netgraph.h>
75#include <netgraph/ng_parse.h>
76#include <netgraph/ng_iface.h>
77#include <netgraph/ng_cisco.h>

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

724 */
725static int
726ng_iface_rcvdata(hook_p hook, item_p item)
727{
728 const priv_p priv = NG_NODE_PRIVATE(NG_HOOK_NODE(hook));
729 const iffam_p iffam = get_iffam_from_hook(priv, hook);
730 struct ifnet *const ifp = priv->ifp;
731 struct mbuf *m;
732 int isr;
732
733 NGI_GET_M(item, m);
734 NG_FREE_ITEM(item);
735 /* Sanity checks */
736 KASSERT(iffam != NULL, ("%s: iffam", __func__));
737 KASSERT(m->m_flags & M_PKTHDR, ("%s: not pkthdr", __func__));
738 if (m == NULL)
739 return (EINVAL);

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

748
749 /* Note receiving interface */
750 m->m_pkthdr.rcvif = ifp;
751
752 /* Berkeley packet filter */
753 ng_iface_bpftap(ifp, m, iffam->family);
754
755 /* Send packet */
733
734 NGI_GET_M(item, m);
735 NG_FREE_ITEM(item);
736 /* Sanity checks */
737 KASSERT(iffam != NULL, ("%s: iffam", __func__));
738 KASSERT(m->m_flags & M_PKTHDR, ("%s: not pkthdr", __func__));
739 if (m == NULL)
740 return (EINVAL);

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

749
750 /* Note receiving interface */
751 m->m_pkthdr.rcvif = ifp;
752
753 /* Berkeley packet filter */
754 ng_iface_bpftap(ifp, m, iffam->family);
755
756 /* Send packet */
756 return family_enqueue(iffam->family, m);
757 switch (iffam->family) {
758#ifdef INET
759 case AF_INET:
760 isr = NETISR_IP;
761 break;
762#endif
763#ifdef INET6
764 case AF_INET6:
765 isr = NETISR_IPV6;
766 break;
767#endif
768#ifdef IPX
769 case AF_IPX:
770 isr = NETISR_IPX;
771 break;
772#endif
773#ifdef NS
774 case AF_NS:
775 isr = NETISR_NS;
776 break;
777#endif
778#ifdef NETATALK
779 case AF_APPLETALK:
780 isr = NETISR_ATALK2;
781 break;
782#endif
783#ifdef NATM
784 case AF_NATM:
785 isr = NETISR_NATM;
786 break;
787#endif
788#ifdef ATM_CORE
789 case AF_ATM:
790 isr = NETISR_ATM;
791 break;
792#endif
793 default:
794 m_freem(m);
795 return (EAFNOSUPPORT);
796 }
797 /* First chunk of an mbuf contains good junk */
798 if (harvest.point_to_point)
799 random_harvest(m, 16, 3, 0, RANDOM_NET);
800 netisr_dispatch(isr, m);
801 return (0);
757}
758
759/*
760 * Shutdown and remove the node and its associated interface.
761 */
762static int
763ng_iface_shutdown(node_p node)
764{

--- 29 unchanged lines hidden ---
802}
803
804/*
805 * Shutdown and remove the node and its associated interface.
806 */
807static int
808ng_iface_shutdown(node_p node)
809{

--- 29 unchanged lines hidden ---