ng_ether.c (129823) | ng_ether.c (131155) |
---|---|
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 129823 2004-05-29 00:51:19Z julian $ | 40 * $FreeBSD: head/sys/netgraph/ng_ether.c 131155 2004-06-26 22:24:16Z julian $ |
41 */ 42 43/* 44 * ng_ether(4) netgraph node type 45 */ 46 47#include <sys/param.h> 48#include <sys/systm.h> --- 40 unchanged lines hidden (view full) --- 89/* Functional hooks called from if_ethersubr.c */ 90static void ng_ether_input(struct ifnet *ifp, struct mbuf **mp); 91static void ng_ether_input_orphan(struct ifnet *ifp, struct mbuf *m); 92static int ng_ether_output(struct ifnet *ifp, struct mbuf **mp); 93static void ng_ether_attach(struct ifnet *ifp); 94static void ng_ether_detach(struct ifnet *ifp); 95 96/* Other functions */ | 41 */ 42 43/* 44 * ng_ether(4) netgraph node type 45 */ 46 47#include <sys/param.h> 48#include <sys/systm.h> --- 40 unchanged lines hidden (view full) --- 89/* Functional hooks called from if_ethersubr.c */ 90static void ng_ether_input(struct ifnet *ifp, struct mbuf **mp); 91static void ng_ether_input_orphan(struct ifnet *ifp, struct mbuf *m); 92static int ng_ether_output(struct ifnet *ifp, struct mbuf **mp); 93static void ng_ether_attach(struct ifnet *ifp); 94static void ng_ether_detach(struct ifnet *ifp); 95 96/* Other functions */ |
97static int ng_ether_rcv_lower(node_p node, struct mbuf *m, meta_p meta); 98static int ng_ether_rcv_upper(node_p node, struct mbuf *m, meta_p meta); | 97static int ng_ether_rcv_lower(node_p node, struct mbuf *m); 98static int ng_ether_rcv_upper(node_p node, struct mbuf *m); |
99 100/* Netgraph node methods */ 101static ng_constructor_t ng_ether_constructor; 102static ng_rcvmsg_t ng_ether_rcvmsg; 103static ng_shutdown_t ng_ether_shutdown; 104static ng_newhook_t ng_ether_newhook; 105static ng_connect_t ng_ether_connect; 106static ng_rcvdata_t ng_ether_rcvdata; --- 373 unchanged lines hidden (view full) --- 480 * Receive data on a hook. 481 */ 482static int 483ng_ether_rcvdata(hook_p hook, item_p item) 484{ 485 const node_p node = NG_HOOK_NODE(hook); 486 const priv_p priv = NG_NODE_PRIVATE(node); 487 struct mbuf *m; | 99 100/* Netgraph node methods */ 101static ng_constructor_t ng_ether_constructor; 102static ng_rcvmsg_t ng_ether_rcvmsg; 103static ng_shutdown_t ng_ether_shutdown; 104static ng_newhook_t ng_ether_newhook; 105static ng_connect_t ng_ether_connect; 106static ng_rcvdata_t ng_ether_rcvdata; --- 373 unchanged lines hidden (view full) --- 480 * Receive data on a hook. 481 */ 482static int 483ng_ether_rcvdata(hook_p hook, item_p item) 484{ 485 const node_p node = NG_HOOK_NODE(hook); 486 const priv_p priv = NG_NODE_PRIVATE(node); 487 struct mbuf *m; |
488 meta_p meta; | |
489 490 NGI_GET_M(item, m); | 488 489 NGI_GET_M(item, m); |
491 NGI_GET_META(item, meta); | |
492 NG_FREE_ITEM(item); | 490 NG_FREE_ITEM(item); |
491 |
|
493 if (hook == priv->lower || hook == priv->orphan) | 492 if (hook == priv->lower || hook == priv->orphan) |
494 return ng_ether_rcv_lower(node, m, meta); | 493 return ng_ether_rcv_lower(node, m); |
495 if (hook == priv->upper) | 494 if (hook == priv->upper) |
496 return ng_ether_rcv_upper(node, m, meta); | 495 return ng_ether_rcv_upper(node, m); |
497 panic("%s: weird hook", __func__); 498#ifdef RESTARTABLE_PANICS /* so we don't get an error msg in LINT */ 499 return NULL; 500#endif 501} 502 503/* 504 * Handle an mbuf received on the "lower" or "orphan" hook. 505 */ 506static int | 496 panic("%s: weird hook", __func__); 497#ifdef RESTARTABLE_PANICS /* so we don't get an error msg in LINT */ 498 return NULL; 499#endif 500} 501 502/* 503 * Handle an mbuf received on the "lower" or "orphan" hook. 504 */ 505static int |
507ng_ether_rcv_lower(node_p node, struct mbuf *m, meta_p meta) | 506ng_ether_rcv_lower(node_p node, struct mbuf *m) |
508{ 509 const priv_p priv = NG_NODE_PRIVATE(node); 510 struct ifnet *const ifp = priv->ifp; 511 | 507{ 508 const priv_p priv = NG_NODE_PRIVATE(node); 509 struct ifnet *const ifp = priv->ifp; 510 |
512 /* Discard meta info */ 513 NG_FREE_META(meta); 514 | |
515 /* Check whether interface is ready for packets */ 516 if ((ifp->if_flags & (IFF_UP|IFF_RUNNING)) != (IFF_UP|IFF_RUNNING)) { 517 NG_FREE_M(m); 518 return (ENETDOWN); 519 } 520 521 /* Make sure header is fully pulled up */ 522 if (m->m_pkthdr.len < sizeof(struct ether_header)) { --- 21 unchanged lines hidden (view full) --- 544 /* Send it on its way */ 545 return ether_output_frame(ifp, m); 546} 547 548/* 549 * Handle an mbuf received on the "upper" hook. 550 */ 551static int | 511 /* Check whether interface is ready for packets */ 512 if ((ifp->if_flags & (IFF_UP|IFF_RUNNING)) != (IFF_UP|IFF_RUNNING)) { 513 NG_FREE_M(m); 514 return (ENETDOWN); 515 } 516 517 /* Make sure header is fully pulled up */ 518 if (m->m_pkthdr.len < sizeof(struct ether_header)) { --- 21 unchanged lines hidden (view full) --- 540 /* Send it on its way */ 541 return ether_output_frame(ifp, m); 542} 543 544/* 545 * Handle an mbuf received on the "upper" hook. 546 */ 547static int |
552ng_ether_rcv_upper(node_p node, struct mbuf *m, meta_p meta) | 548ng_ether_rcv_upper(node_p node, struct mbuf *m) |
553{ 554 const priv_p priv = NG_NODE_PRIVATE(node); 555 | 549{ 550 const priv_p priv = NG_NODE_PRIVATE(node); 551 |
556 /* Discard meta info */ 557 NG_FREE_META(meta); 558 | |
559 m->m_pkthdr.rcvif = priv->ifp; 560 561 /* Route packet back in */ 562 ether_demux(priv->ifp, m); 563 return (0); 564} 565 566/* --- 118 unchanged lines hidden --- | 552 m->m_pkthdr.rcvif = priv->ifp; 553 554 /* Route packet back in */ 555 ether_demux(priv->ifp, m); 556 return (0); 557} 558 559/* --- 118 unchanged lines hidden --- |