Date: Sun, 13 Oct 2002 09:25:00 -0400 From: Craig Rodrigues <rodrigc@attbi.com> To: freebsd-net@freebsd.org Subject: How to add bpf support to if_atmsubr.c? Message-ID: <20021013092500.A35284@attbi.com>
next in thread | raw e-mail | index | archive | help
--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 <net/if_atm.h> #include <netinet/in.h> +#include <net/bpf.h> #include <netinet/if_atm.h> #include <netinet/if_ether.h> /* XXX: for ETHERTYPE_* */ #if defined(INET) || defined(INET6) @@ -66,6 +67,15 @@ #include <netnatm/natm.h> #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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20021013092500.A35284>