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 * |
38 * $FreeBSD: head/sys/netgraph/ng_iface.c 111888 2003-03-04 23:19:55Z jlemon $ |
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> |
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; |
732 int isr; |
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 */ |
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); |
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 --- |