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 96265 2002-05-09 20:19:00Z archie $ |
41 */ 42 43/* 44 * ng_ether(4) netgraph node type 45 */ 46 47#include <sys/param.h> 48#include <sys/systm.h> --- 573 unchanged lines hidden (view full) --- 622 623/* 624 * Handle an mbuf received on the "lower" hook. 625 */ 626static int 627ng_ether_rcv_lower(node_p node, struct mbuf *m, meta_p meta) 628{ 629 const priv_p priv = NG_NODE_PRIVATE(node); |
630 struct ifnet *const ifp = priv->ifp; |
631 |
632 /* Check whether interface is ready for packets */ 633 if ((ifp->if_flags & (IFF_UP|IFF_RUNNING)) != (IFF_UP|IFF_RUNNING)) { 634 NG_FREE_M(m); 635 NG_FREE_META(meta); 636 return (ENETDOWN); 637 } 638 |
639 /* Make sure header is fully pulled up */ 640 if (m->m_pkthdr.len < sizeof(struct ether_header)) { 641 NG_FREE_M(m); 642 NG_FREE_META(meta); 643 return (EINVAL); 644 } 645 if (m->m_len < sizeof(struct ether_header) 646 && (m = m_pullup(m, sizeof(struct ether_header))) == NULL) { 647 NG_FREE_META(meta); 648 return (ENOBUFS); 649 } 650 651 /* Drop in the MAC address if desired */ 652 if (priv->autoSrcAddr) { |
653 bcopy((IFP2AC(ifp))->ac_enaddr, |
654 mtod(m, struct ether_header *)->ether_shost, 655 ETHER_ADDR_LEN); 656 } 657 658 /* Send it on its way */ 659 NG_FREE_META(meta); |
660 return ether_output_frame(ifp, m); |
661} 662 663/* 664 * Handle an mbuf received on the "upper" hook. 665 */ 666static int 667ng_ether_rcv_upper(node_p node, struct mbuf *m, meta_p meta) 668{ --- 182 unchanged lines hidden --- |