ng_ether.c (62143) | ng_ether.c (62678) |
---|---|
1 2/* 3 * ng_ether.c 4 * 5 * Copyright (c) 1996-2000 Whistle Communications, Inc. 6 * All rights reserved. 7 * 8 * Subject to the following obligations and disclaimer of warranty, use and --- 23 unchanged lines hidden (view full) --- 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 * Authors: Archie Cobbs <archie@freebsd.org> 38 * Julian Elischer <julian@freebsd.org> 39 * | 1 2/* 3 * ng_ether.c 4 * 5 * Copyright (c) 1996-2000 Whistle Communications, Inc. 6 * All rights reserved. 7 * 8 * Subject to the following obligations and disclaimer of warranty, use and --- 23 unchanged lines hidden (view full) --- 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 * Authors: Archie Cobbs <archie@freebsd.org> 38 * Julian Elischer <julian@freebsd.org> 39 * |
40 * $FreeBSD: head/sys/netgraph/ng_ether.c 62143 2000-06-26 23:34:54Z archie $ | 40 * $FreeBSD: head/sys/netgraph/ng_ether.c 62678 2000-07-06 15:35:59Z julian $ |
41 */ 42 43/* 44 * ng_ether(4) netgraph node type 45 */ 46 47#include <sys/param.h> 48#include <sys/systm.h> --- 10 unchanged lines hidden (view full) --- 59#include <net/if_var.h> 60#include <net/ethernet.h> 61 62#include <netgraph/ng_message.h> 63#include <netgraph/netgraph.h> 64#include <netgraph/ng_parse.h> 65#include <netgraph/ng_ether.h> 66 | 41 */ 42 43/* 44 * ng_ether(4) netgraph node type 45 */ 46 47#include <sys/param.h> 48#include <sys/systm.h> --- 10 unchanged lines hidden (view full) --- 59#include <net/if_var.h> 60#include <net/ethernet.h> 61 62#include <netgraph/ng_message.h> 63#include <netgraph/netgraph.h> 64#include <netgraph/ng_parse.h> 65#include <netgraph/ng_ether.h> 66 |
67#define IFP2AC(IFP) ((struct arpcom *)IFP) |
|
67#define IFP2NG(ifp) ((struct ng_node *)((struct arpcom *)(ifp))->ac_netgraph) 68 69/* Per-node private data */ 70struct private { 71 struct ifnet *ifp; /* associated interface */ 72 hook_p upper; /* upper hook connection */ 73 hook_p lower; /* lower OR orphan hook connection */ 74 u_char lowerOrphan; /* whether lower is lower or orphan */ --- 414 unchanged lines hidden (view full) --- 489 490/* 491 * Handle an mbuf received on the "lower" hook. 492 */ 493static int 494ng_ether_rcv_lower(node_p node, struct mbuf *m, meta_p meta) 495{ 496 const priv_p priv = node->private; | 68#define IFP2NG(ifp) ((struct ng_node *)((struct arpcom *)(ifp))->ac_netgraph) 69 70/* Per-node private data */ 71struct private { 72 struct ifnet *ifp; /* associated interface */ 73 hook_p upper; /* upper hook connection */ 74 hook_p lower; /* lower OR orphan hook connection */ 75 u_char lowerOrphan; /* whether lower is lower or orphan */ --- 414 unchanged lines hidden (view full) --- 490 491/* 492 * Handle an mbuf received on the "lower" hook. 493 */ 494static int 495ng_ether_rcv_lower(node_p node, struct mbuf *m, meta_p meta) 496{ 497 const priv_p priv = node->private; |
498 struct ether_header *eh; |
|
497 498 /* Make sure header is fully pulled up */ 499 if (m->m_pkthdr.len < sizeof(struct ether_header)) { 500 NG_FREE_DATA(m, meta); 501 return (EINVAL); 502 } 503 if (m->m_len < sizeof(struct ether_header) 504 && (m = m_pullup(m, sizeof(struct ether_header))) == NULL) { 505 NG_FREE_META(meta); 506 return (ENOBUFS); 507 } 508 | 499 500 /* Make sure header is fully pulled up */ 501 if (m->m_pkthdr.len < sizeof(struct ether_header)) { 502 NG_FREE_DATA(m, meta); 503 return (EINVAL); 504 } 505 if (m->m_len < sizeof(struct ether_header) 506 && (m = m_pullup(m, sizeof(struct ether_header))) == NULL) { 507 NG_FREE_META(meta); 508 return (ENOBUFS); 509 } 510 |
511 /* drop in the MAC address */ 512 eh = mtod(m, struct ether_header *); 513 bcopy((IFP2AC(priv->ifp))->ac_enaddr, eh->ether_shost, 6); 514 |
|
509 /* Send it on its way */ 510 NG_FREE_META(meta); 511 return ether_output_frame(priv->ifp, m); 512} 513 514/* 515 * Handle an mbuf received on the "upper" hook. 516 */ --- 117 unchanged lines hidden --- | 515 /* Send it on its way */ 516 NG_FREE_META(meta); 517 return ether_output_frame(priv->ifp, m); 518} 519 520/* 521 * Handle an mbuf received on the "upper" hook. 522 */ --- 117 unchanged lines hidden --- |