X-Git-Url: https://git.tcpdump.org/tcpdump/blobdiff_plain/fb1b6d808f19faae76526a2e3eed52a75fb22ff1..383670e8f3f5b51d1017d8c1a678aa7eaf1f2b4d:/print-sunatm.c diff --git a/print-sunatm.c b/print-sunatm.c index e6f19e85..0fe5eee8 100644 --- a/print-sunatm.c +++ b/print-sunatm.c @@ -29,29 +29,20 @@ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ -#ifndef lint -static const char rcsid[] _U_ = - "@(#) $Header: /tcpdump/master/tcpdump/print-sunatm.c,v 1.8 2004-03-17 23:24:38 guy Exp $ (LBL)"; -#endif + +/* \summary: SunATM DLPI capture printer */ #ifdef HAVE_CONFIG_H -#include "config.h" +#include #endif -#include - -struct mbuf; -struct rtentry; - -#include -#include +#include "netdissect-stdinc.h" -#include "interface.h" +#define ND_LONGJMP_FROM_TCHECK +#include "netdissect.h" #include "extract.h" -#include "addrtoname.h" #include "atm.h" -#include "atmuni31.h" /* SunATM header for ATM packet */ #define DIR_POS 0 /* Direction (0x80 = transmit, 0x00 = receive) */ @@ -69,8 +60,9 @@ struct rtentry; * 'h->len' is the length of the packet off the wire, and 'h->caplen' * is the number of bytes actually captured. */ -u_int -sunatm_if_print(const struct pcap_pkthdr *h, const u_char *p) +void +sunatm_if_print(netdissect_options *ndo, + const struct pcap_pkthdr *h, const u_char *p) { u_int caplen = h->caplen; u_int length = h->len; @@ -78,19 +70,13 @@ sunatm_if_print(const struct pcap_pkthdr *h, const u_char *p) u_char vpi; u_int traftype; - if (caplen < PKT_BEGIN_POS) { - printf("[|atm]"); - return (caplen); - } + ndo->ndo_protocol = "sunatm"; - if (eflag) { - if (p[DIR_POS] & 0x80) - printf("Tx: "); - else - printf("Rx: "); + if (ndo->ndo_eflag) { + ND_PRINT(GET_U_1(p + DIR_POS) & 0x80 ? "Tx: " : "Rx: "); } - switch (p[DIR_POS] & 0x0f) { + switch (GET_U_1(p + DIR_POS) & 0x0f) { case PT_LANE: traftype = ATM_LANE; @@ -105,13 +91,12 @@ sunatm_if_print(const struct pcap_pkthdr *h, const u_char *p) break; } - vci = EXTRACT_16BITS(&p[VCI_POS]); - vpi = p[VPI_POS]; + vpi = GET_U_1(p + VPI_POS); + vci = GET_BE_U_2(p + VCI_POS); p += PKT_BEGIN_POS; caplen -= PKT_BEGIN_POS; length -= PKT_BEGIN_POS; - atm_print(vpi, vci, traftype, p, length, caplen); - - return (PKT_BEGIN_POS); + ndo->ndo_ll_hdr_len += PKT_BEGIN_POS; + atm_print(ndo, vpi, vci, traftype, p, length, caplen); }