15b0fe478SBruce M Simpson /* 25b0fe478SBruce M Simpson * Copyright (c) 1997 Yen Yen Lim and North Dakota State University 35b0fe478SBruce M Simpson * All rights reserved. 45b0fe478SBruce M Simpson * 55b0fe478SBruce M Simpson * Redistribution and use in source and binary forms, with or without 65b0fe478SBruce M Simpson * modification, are permitted provided that the following conditions 75b0fe478SBruce M Simpson * are met: 85b0fe478SBruce M Simpson * 1. Redistributions of source code must retain the above copyright 95b0fe478SBruce M Simpson * notice, this list of conditions and the following disclaimer. 105b0fe478SBruce M Simpson * 2. Redistributions in binary form must reproduce the above copyright 115b0fe478SBruce M Simpson * notice, this list of conditions and the following disclaimer in the 125b0fe478SBruce M Simpson * documentation and/or other materials provided with the distribution. 135b0fe478SBruce M Simpson * 3. All advertising materials mentioning features or use of this software 145b0fe478SBruce M Simpson * must display the following acknowledgement: 155b0fe478SBruce M Simpson * This product includes software developed by Yen Yen Lim and 165b0fe478SBruce M Simpson North Dakota State University 175b0fe478SBruce M Simpson * 4. The name of the author may not be used to endorse or promote products 185b0fe478SBruce M Simpson * derived from this software without specific prior written permission. 195b0fe478SBruce M Simpson * 205b0fe478SBruce M Simpson * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 215b0fe478SBruce M Simpson * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 225b0fe478SBruce M Simpson * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 235b0fe478SBruce M Simpson * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, 245b0fe478SBruce M Simpson * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 255b0fe478SBruce M Simpson * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 265b0fe478SBruce M Simpson * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 275b0fe478SBruce M Simpson * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 285b0fe478SBruce M Simpson * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 295b0fe478SBruce M Simpson * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 305b0fe478SBruce M Simpson * POSSIBILITY OF SUCH DAMAGE. 315b0fe478SBruce M Simpson */ 325b0fe478SBruce M Simpson 333340d773SGleb Smirnoff /* \summary: SunATM DLPI capture printer */ 343340d773SGleb Smirnoff 355b0fe478SBruce M Simpson #ifdef HAVE_CONFIG_H 36*ee67461eSJoseph Mingrone #include <config.h> 375b0fe478SBruce M Simpson #endif 385b0fe478SBruce M Simpson 39*ee67461eSJoseph Mingrone #include "netdissect-stdinc.h" 405b0fe478SBruce M Simpson 41*ee67461eSJoseph Mingrone #define ND_LONGJMP_FROM_TCHECK 423340d773SGleb Smirnoff #include "netdissect.h" 435b0fe478SBruce M Simpson #include "extract.h" 445b0fe478SBruce M Simpson 455b0fe478SBruce M Simpson #include "atm.h" 465b0fe478SBruce M Simpson 475b0fe478SBruce M Simpson /* SunATM header for ATM packet */ 485b0fe478SBruce M Simpson #define DIR_POS 0 /* Direction (0x80 = transmit, 0x00 = receive) */ 495b0fe478SBruce M Simpson #define VPI_POS 1 /* VPI */ 505b0fe478SBruce M Simpson #define VCI_POS 2 /* VCI */ 515b0fe478SBruce M Simpson #define PKT_BEGIN_POS 4 /* Start of the ATM packet */ 525b0fe478SBruce M Simpson 535b0fe478SBruce M Simpson /* Protocol type values in the bottom for bits of the byte at SUNATM_DIR_POS. */ 545b0fe478SBruce M Simpson #define PT_LANE 0x01 /* LANE */ 555b0fe478SBruce M Simpson #define PT_LLC 0x02 /* LLC encapsulation */ 565b0fe478SBruce M Simpson 575b0fe478SBruce M Simpson /* 585b0fe478SBruce M Simpson * This is the top level routine of the printer. 'p' points 595b0fe478SBruce M Simpson * to the SunATM pseudo-header for the packet, 'h->ts' is the timestamp, 601de50e9fSSam Leffler * 'h->len' is the length of the packet off the wire, and 'h->caplen' 615b0fe478SBruce M Simpson * is the number of bytes actually captured. 625b0fe478SBruce M Simpson */ 63*ee67461eSJoseph Mingrone void 643c602fabSXin LI sunatm_if_print(netdissect_options *ndo, 653c602fabSXin LI const struct pcap_pkthdr *h, const u_char *p) 665b0fe478SBruce M Simpson { 675b0fe478SBruce M Simpson u_int caplen = h->caplen; 685b0fe478SBruce M Simpson u_int length = h->len; 695b0fe478SBruce M Simpson u_short vci; 705b0fe478SBruce M Simpson u_char vpi; 715b0fe478SBruce M Simpson u_int traftype; 725b0fe478SBruce M Simpson 73*ee67461eSJoseph Mingrone ndo->ndo_protocol = "sunatm"; 745b0fe478SBruce M Simpson 753c602fabSXin LI if (ndo->ndo_eflag) { 76*ee67461eSJoseph Mingrone ND_PRINT(GET_U_1(p + DIR_POS) & 0x80 ? "Tx: " : "Rx: "); 775b0fe478SBruce M Simpson } 785b0fe478SBruce M Simpson 79*ee67461eSJoseph Mingrone switch (GET_U_1(p + DIR_POS) & 0x0f) { 805b0fe478SBruce M Simpson 815b0fe478SBruce M Simpson case PT_LANE: 825b0fe478SBruce M Simpson traftype = ATM_LANE; 835b0fe478SBruce M Simpson break; 845b0fe478SBruce M Simpson 855b0fe478SBruce M Simpson case PT_LLC: 865b0fe478SBruce M Simpson traftype = ATM_LLC; 875b0fe478SBruce M Simpson break; 885b0fe478SBruce M Simpson 895b0fe478SBruce M Simpson default: 905b0fe478SBruce M Simpson traftype = ATM_UNKNOWN; 915b0fe478SBruce M Simpson break; 925b0fe478SBruce M Simpson } 935b0fe478SBruce M Simpson 94*ee67461eSJoseph Mingrone vpi = GET_U_1(p + VPI_POS); 95*ee67461eSJoseph Mingrone vci = GET_BE_U_2(p + VCI_POS); 965b0fe478SBruce M Simpson 975b0fe478SBruce M Simpson p += PKT_BEGIN_POS; 985b0fe478SBruce M Simpson caplen -= PKT_BEGIN_POS; 995b0fe478SBruce M Simpson length -= PKT_BEGIN_POS; 100*ee67461eSJoseph Mingrone ndo->ndo_ll_hdr_len += PKT_BEGIN_POS; 1013c602fabSXin LI atm_print(ndo, vpi, vci, traftype, p, length, caplen); 1025b0fe478SBruce M Simpson } 103