Deleted Added
full compact
ng_ether.c (90249) ng_ether.c (96265)
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 90249 2002-02-05 18:27:30Z archie $
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);
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;
630
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
631 /* Make sure header is fully pulled up */
632 if (m->m_pkthdr.len < sizeof(struct ether_header)) {
633 NG_FREE_M(m);
634 NG_FREE_META(meta);
635 return (EINVAL);
636 }
637 if (m->m_len < sizeof(struct ether_header)
638 && (m = m_pullup(m, sizeof(struct ether_header))) == NULL) {
639 NG_FREE_META(meta);
640 return (ENOBUFS);
641 }
642
643 /* Drop in the MAC address if desired */
644 if (priv->autoSrcAddr) {
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) {
645 bcopy((IFP2AC(priv->ifp))->ac_enaddr,
653 bcopy((IFP2AC(ifp))->ac_enaddr,
646 mtod(m, struct ether_header *)->ether_shost,
647 ETHER_ADDR_LEN);
648 }
649
650 /* Send it on its way */
651 NG_FREE_META(meta);
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);
652 return ether_output_frame(priv->ifp, m);
660 return ether_output_frame(ifp, m);
653}
654
655/*
656 * Handle an mbuf received on the "upper" hook.
657 */
658static int
659ng_ether_rcv_upper(node_p node, struct mbuf *m, meta_p meta)
660{

--- 182 unchanged lines hidden ---
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 ---