From owner-freebsd-net Sun Oct 13 6:24:26 2002 Delivered-To: freebsd-net@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id D8F1A37B401 for ; Sun, 13 Oct 2002 06:24:21 -0700 (PDT) Received: from dibbler.ne.client2.attbi.com (dibbler.ne.client2.attbi.com [24.61.41.247]) by mx1.FreeBSD.org (Postfix) with ESMTP id 4840543E75 for ; Sun, 13 Oct 2002 06:24:21 -0700 (PDT) (envelope-from rodrigc@attbi.com) Received: from dibbler.ne.client2.attbi.com (localhost.ne.attbi.com [127.0.0.1]) by dibbler.ne.client2.attbi.com (8.12.6/8.12.5) with ESMTP id g9DDP1CK035991 for ; Sun, 13 Oct 2002 09:25:01 -0400 (EDT) (envelope-from rodrigc@dibbler.ne.client2.attbi.com) Received: (from rodrigc@localhost) by dibbler.ne.client2.attbi.com (8.12.6/8.12.6/Submit) id g9DDP1d3035987 for freebsd-net@freebsd.org; Sun, 13 Oct 2002 09:25:01 -0400 (EDT) Date: Sun, 13 Oct 2002 09:25:00 -0400 From: Craig Rodrigues To: freebsd-net@freebsd.org Subject: How to add bpf support to if_atmsubr.c? Message-ID: <20021013092500.A35284@attbi.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="LZvS9be/3tNcYl/X" Content-Disposition: inline User-Agent: Mutt/1.2.5.1i Sender: owner-freebsd-net@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.org --LZvS9be/3tNcYl/X Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Hi, I am on a -current system, using patches from Harti Brandt's Netgraph ATM work: http://www.fokus.fhg.de/research/cc/cats/employees/hartmut.brandt/ngatm/ I am trying to add bpf support to /src/sys/net/if_atmsubr.c so that I can use tcpdump when sending traffic over my ATM card. I've got things mostly working, but I think I'm using the wrong arguments in the bpfattach() call (I'm not familiar with bpf and just guessed, based on looking at files in the same directory). Here is the line I used: bpfattach(ifp, DLT_ATM_RFC1483, sizeof(u_int)); What should I really be using? I am attaching the patch I am using, which incorporates patches from Harti Brandt, and bpf fixes from me. Thanks. -- Craig Rodrigues http://www.gis.net/~craigr rodrigc@attbi.com --LZvS9be/3tNcYl/X Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="patch-if_atmsubr.c" --- if_atmsubr.c.orig Fri Jun 15 03:32:25 2001 +++ if_atmsubr.c Sun Oct 13 04:05:16 2002 @@ -57,6 +57,7 @@ #include #include +#include #include #include /* XXX: for ETHERTYPE_* */ #if defined(INET) || defined(INET6) @@ -66,6 +67,15 @@ #include #endif +void (*ng_atm_attach_p)(struct ifnet *); +void (*ng_atm_detach_p)(struct ifnet *); +int (*ng_atm_output_p)(struct ifnet *, struct mbuf **); +void (*ng_atm_input_p)(struct ifnet *, struct mbuf **, + struct atm_pseudohdr *, void *); +void (*ng_atm_input_orphan_p)(struct ifnet *, struct mbuf *, + struct atm_pseudohdr *, void *); +void (*ng_atm_message_p)(struct ifnet *, u_int32_t, u_int32_t); + #ifndef ETHERTYPE_IPV6 #define ETHERTYPE_IPV6 0x86dd #endif @@ -199,6 +209,16 @@ } } + if (ng_atm_output_p != NULL) { + if ((error = (*ng_atm_output_p)(ifp, &m)) != 0) { + if (m != NULL) + m_freem(m); + return (error); + } + if (m == NULL) + return (0); + } + /* * Queue message on interface, and start output if interface * not yet active. @@ -234,6 +254,16 @@ } ifp->if_ibytes += m->m_pkthdr.len; + if (ifp->if_bpf != NULL) { + bpf_mtap(ifp, m); + } + + if (ng_atm_input_p != NULL) { + (*ng_atm_input_p)(ifp, &m, ah, rxhand); + if (m == NULL) + return; + } + if (rxhand) { #ifdef NATM struct natmpcb *npcb = rxhand; @@ -244,9 +274,10 @@ inq = &natmintrq; m->m_pkthdr.rcvif = rxhand; /* XXX: overload */ #else +/* printf("atm_input: NATM detected but not configured in kernel\n"); - m_freem(m); - return; +*/ + goto dropit; #endif } else { /* @@ -287,7 +318,13 @@ break; #endif default: - m_freem(m); +#ifndef NATM + dropit: +#endif + if (ng_atm_input_orphan_p != NULL) + (*ng_atm_input_orphan_p)(ifp, m, ah, rxhand); + else + m_freem(m); return; } } @@ -330,4 +367,36 @@ break; } +} + +void +atm_ifdetach(ifp) + register struct ifnet *ifp; +{ + +} + +void +atm_ifattach1(struct ifnet *ifp) +{ + atm_ifattach(ifp); + bpfattach(ifp, DLT_ATM_RFC1483, sizeof(u_int)); + if(ng_atm_attach_p) + (*ng_atm_attach_p)(ifp); +} + +void +atm_ifdetach1(struct ifnet *ifp) +{ + if(ng_atm_detach_p) + (*ng_atm_detach_p)(ifp); + bpfdetach(ifp); + atm_ifdetach(ifp); +} + +void +atm_message(struct ifnet *ifp, u_int32_t msg, u_int32_t arg) +{ + if(ng_atm_message_p) + (*ng_atm_message_p)(ifp, msg, arg); } --LZvS9be/3tNcYl/X-- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-net" in the body of the message