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 33*3c602fabSXin LI #define NETDISSECT_REWORKED 345b0fe478SBruce M Simpson #ifdef HAVE_CONFIG_H 355b0fe478SBruce M Simpson #include "config.h" 365b0fe478SBruce M Simpson #endif 375b0fe478SBruce M Simpson 385b0fe478SBruce M Simpson #include <tcpdump-stdinc.h> 395b0fe478SBruce M Simpson 405b0fe478SBruce M Simpson struct mbuf; 415b0fe478SBruce M Simpson struct rtentry; 425b0fe478SBruce M Simpson 435b0fe478SBruce M Simpson #include "interface.h" 445b0fe478SBruce M Simpson #include "extract.h" 455b0fe478SBruce M Simpson 465b0fe478SBruce M Simpson #include "atm.h" 475b0fe478SBruce M Simpson 485b0fe478SBruce M Simpson /* SunATM header for ATM packet */ 495b0fe478SBruce M Simpson #define DIR_POS 0 /* Direction (0x80 = transmit, 0x00 = receive) */ 505b0fe478SBruce M Simpson #define VPI_POS 1 /* VPI */ 515b0fe478SBruce M Simpson #define VCI_POS 2 /* VCI */ 525b0fe478SBruce M Simpson #define PKT_BEGIN_POS 4 /* Start of the ATM packet */ 535b0fe478SBruce M Simpson 545b0fe478SBruce M Simpson /* Protocol type values in the bottom for bits of the byte at SUNATM_DIR_POS. */ 555b0fe478SBruce M Simpson #define PT_LANE 0x01 /* LANE */ 565b0fe478SBruce M Simpson #define PT_LLC 0x02 /* LLC encapsulation */ 575b0fe478SBruce M Simpson 585b0fe478SBruce M Simpson /* 595b0fe478SBruce M Simpson * This is the top level routine of the printer. 'p' points 605b0fe478SBruce M Simpson * to the SunATM pseudo-header for the packet, 'h->ts' is the timestamp, 611de50e9fSSam Leffler * 'h->len' is the length of the packet off the wire, and 'h->caplen' 625b0fe478SBruce M Simpson * is the number of bytes actually captured. 635b0fe478SBruce M Simpson */ 645b0fe478SBruce M Simpson u_int 65*3c602fabSXin LI sunatm_if_print(netdissect_options *ndo, 66*3c602fabSXin LI const struct pcap_pkthdr *h, const u_char *p) 675b0fe478SBruce M Simpson { 685b0fe478SBruce M Simpson u_int caplen = h->caplen; 695b0fe478SBruce M Simpson u_int length = h->len; 705b0fe478SBruce M Simpson u_short vci; 715b0fe478SBruce M Simpson u_char vpi; 725b0fe478SBruce M Simpson u_int traftype; 735b0fe478SBruce M Simpson 745b0fe478SBruce M Simpson if (caplen < PKT_BEGIN_POS) { 75*3c602fabSXin LI ND_PRINT((ndo, "[|atm]")); 765b0fe478SBruce M Simpson return (caplen); 775b0fe478SBruce M Simpson } 785b0fe478SBruce M Simpson 79*3c602fabSXin LI if (ndo->ndo_eflag) { 80*3c602fabSXin LI ND_PRINT((ndo, p[DIR_POS] & 0x80 ? "Tx: " : "Rx: ")); 815b0fe478SBruce M Simpson } 825b0fe478SBruce M Simpson 835b0fe478SBruce M Simpson switch (p[DIR_POS] & 0x0f) { 845b0fe478SBruce M Simpson 855b0fe478SBruce M Simpson case PT_LANE: 865b0fe478SBruce M Simpson traftype = ATM_LANE; 875b0fe478SBruce M Simpson break; 885b0fe478SBruce M Simpson 895b0fe478SBruce M Simpson case PT_LLC: 905b0fe478SBruce M Simpson traftype = ATM_LLC; 915b0fe478SBruce M Simpson break; 925b0fe478SBruce M Simpson 935b0fe478SBruce M Simpson default: 945b0fe478SBruce M Simpson traftype = ATM_UNKNOWN; 955b0fe478SBruce M Simpson break; 965b0fe478SBruce M Simpson } 975b0fe478SBruce M Simpson 985b0fe478SBruce M Simpson vci = EXTRACT_16BITS(&p[VCI_POS]); 995b0fe478SBruce M Simpson vpi = p[VPI_POS]; 1005b0fe478SBruce M Simpson 1015b0fe478SBruce M Simpson p += PKT_BEGIN_POS; 1025b0fe478SBruce M Simpson caplen -= PKT_BEGIN_POS; 1035b0fe478SBruce M Simpson length -= PKT_BEGIN_POS; 104*3c602fabSXin LI atm_print(ndo, vpi, vci, traftype, p, length, caplen); 1055b0fe478SBruce M Simpson 1065b0fe478SBruce M Simpson return (PKT_BEGIN_POS); 1075b0fe478SBruce M Simpson } 108