]> The Tcpdump Group git mirrors - tcpdump/commitdiff
Add SunATM support, based on code from Yen Yen Lim at North Dakota State
authorguy <guy>
Thu, 11 Jul 2002 09:17:21 +0000 (09:17 +0000)
committerguy <guy>
Thu, 11 Jul 2002 09:17:21 +0000 (09:17 +0000)
University.

13 files changed:
CREDITS
FILES
Makefile.in
atm.h [new file with mode: 0644]
atmuni31.h [new file with mode: 0644]
interface.h
lane.h
print-arp.c
print-atm.c
print-lane.c
print-sunatm.c [new file with mode: 0644]
tcpdump.1
tcpdump.c

diff --git a/CREDITS b/CREDITS
index 0b18ea3a98682259535c0e42207c32f10d549f1f..27b014b89c516c52d2d3435e0baf52f52d7fc918 100644 (file)
--- a/CREDITS
+++ b/CREDITS
@@ -88,6 +88,7 @@ Additional people who have contributed patches:
        Tony Li                         <[email protected]>
        Uns Lider                       <[email protected]>
        Wilbert de Graaf                <[email protected]>
+       Yen Yen Lim
 
 The original LBL crew:
        Steve McCanne
diff --git a/FILES b/FILES
index 8fcee549d5f758e1fc05e158d0cd4c02ef490334..814b0870b10a2c93373572ea0f2205fb2c304d99 100644 (file)
--- a/FILES
+++ b/FILES
@@ -14,6 +14,8 @@ ah.h
 appletalk.h
 arcnet.h
 atime.awk
+atm.h
+atmuni31.h
 bootp.h
 bpf_dump.c
 chdlc.h
@@ -147,6 +149,7 @@ print-sll.c
 print-smb.c
 print-snmp.c
 print-stp.c
+print-sunatm.c
 print-sunrpc.c
 print-tcp.c
 print-telnet.c
index 4e67524021a2c7fdac05b4b1e4918ca75f62a21f..4cd3e90870c61a023423f72be153f20bde25bdea 100644 (file)
@@ -17,7 +17,7 @@
 #  WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
 #  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
 #
-# @(#) $Header: /tcpdump/master/tcpdump/Makefile.in,v 1.264 2002-07-11 08:09:46 guy Exp $ (LBL)
+# @(#) $Header: /tcpdump/master/tcpdump/Makefile.in,v 1.265 2002-07-11 09:17:22 guy Exp $ (LBL)
 
 #
 # Various configurable paths (remember to edit Makefile.in, not Makefile)
@@ -80,10 +80,10 @@ CSRC =      addrtoname.c gmt2local.c machdep.c parsenfsfh.c \
        print-ospf.c print-pflog.c print-pim.c print-ppp.c \
        print-pppoe.c print-pptp.c print-radius.c print-raw.c \
        print-rip.c print-rx.c print-sctp.c print-sl.c print-sll.c \
-       print-snmp.c print-stp.c print-sunrpc.c print-tcp.c \
-       print-telnet.c print-tftp.c print-timed.c print-token.c \
-       print-udp.c print-vjc.c print-vrrp.c print-wb.c print-zephyr.c \
-       setsignal.c tcpdump.c util.c
+       print-snmp.c print-stp.c print-sunatm.c print-sunrpc.c \
+       print-tcp.c print-telnet.c print-tftp.c print-timed.c \
+       print-token.c print-udp.c print-vjc.c print-vrrp.c \
+       print-wb.c print-zephyr.c setsignal.c tcpdump.c util.c
 
 LOCALSRC = @LOCALSRC@
 GENSRC = version.c
diff --git a/atm.h b/atm.h
new file mode 100644 (file)
index 0000000..a4611c0
--- /dev/null
+++ b/atm.h
@@ -0,0 +1,25 @@
+/*
+ * Copyright (c) 2002 Guy Harris.
+ *                All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that: (1) source code
+ * distributions retain the above copyright notice and this paragraph
+ * in its entirety, and (2) distributions including binary code include
+ * the above copyright notice and this paragraph in its entirety in
+ * the documentation or other materials provided with the distribution.
+ * The name of Guy Harris may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * @(#) $Header: /tcpdump/master/tcpdump/atm.h,v 1.1 2002-07-11 09:17:22 guy Exp $
+ */
+
+/*
+ * Traffic types for ATM.
+ */
+#define ATM_UNKNOWN    0       /* Unknown */
+#define ATM_LANE       1       /* LANE */
+#define ATM_LLC                2       /* LLC encapsulation */
diff --git a/atmuni31.h b/atmuni31.h
new file mode 100644 (file)
index 0000000..a0e9a4e
--- /dev/null
@@ -0,0 +1,85 @@
+/*
+ * Copyright (c) 1997 Yen Yen Lim and North Dakota State University
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *      This product includes software developed by Yen Yen Lim and
+        North Dakota State University
+ * 4. The name of the author may not be used to endorse or promote products
+ *    derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/* Based on UNI3.1 standard by ATM Forum */
+
+/* ATM traffic types based on VPI=0 and (the following VCI */
+#define PPC                    0x05    /* Point-to-point signal msg */
+#define BCC                    0x02    /* Broadcast signal msg */
+#define OAMF4SC                        0x03    /* Segment OAM F4 flow cell */
+#define OAMF4EC                        0x04    /* End-to-end OAM F4 flow cell */
+#define METAC                  0x01    /* Meta signal msg */
+#define ILMIC                  0x10    /* ILMI msg */
+
+/* Q.2931 signalling messages */
+#define CALL_PROCEED           0x02    /* call proceeding */
+#define CONNECT                        0x07    /* connect */
+#define CONNECT_ACK            0x0f    /* connect_ack */
+#define SETUP                  0x05    /* setup */
+#define RELEASE                        0x4d    /* release */
+#define RELEASE_DONE           0x5a    /* release_done */
+#define RESTART                        0x46    /* restart */
+#define RESTART_ACK            0x4e    /* restart ack */
+#define STATUS                 0x7d    /* status */
+#define STATUS_ENQ             0x75    /* status ack */
+#define ADD_PARTY              0x80    /* add party */
+#define ADD_PARTY_ACK          0x81    /* add party ack */
+#define ADD_PARTY_REJ          0x82    /* add party rej */
+#define DROP_PARTY             0x83    /* drop party */
+#define DROP_PARTY_ACK         0x84    /* drop party ack */
+
+/* Information Element Parameters in the signalling messages */
+#define CAUSE                  0x08    /* cause */
+#define ENDPT_REF              0x54    /* endpoint reference */
+#define AAL_PARA               0x58    /* ATM adaptation layer parameters */
+#define TRAFF_DESCRIP          0x59    /* atm traffic descriptors */
+#define CONNECT_ID             0x5a    /* connection identifier */
+#define QOS_PARA               0x5c    /* quality of service parameters */
+#define B_HIGHER               0x5d    /* broadband higher layer information */
+#define B_BEARER               0x5e    /* broadband bearer capability */
+#define B_LOWER                        0x5f    /* broadband lower information */
+#define CALLING_PARTY          0x6c    /* calling party number */
+#define CALLED_PARTY           0x70    /* called party nmber */
+
+#define Q2931                  0x09
+
+/* Q.2931 signalling general messages format */
+#define PROTO_POS       0      /* offset of protocol discriminator */
+#define CALL_REF_POS    2      /* offset of call reference value */
+#define MSG_TYPE_POS    5      /* offset of message type */
+#define MSG_LEN_POS     7      /* offset of mesage length */
+#define IE_BEGIN_POS    9      /* offset of first information element */
+
+/* format of signalling messages */
+#define TYPE_POS       0
+#define LEN_POS                2
+#define FIELD_BEGIN_POS 4
index 6848d2f1a4c05a8ba321a8f0ed34656210c151ea..ddc3547fc1830eae4fcafb36c733773597caccad 100644 (file)
@@ -18,7 +18,7 @@
  * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  *
- * @(#) $Header: /tcpdump/master/tcpdump/interface.h,v 1.189 2002-07-11 08:27:03 guy Exp $ (LBL)
+ * @(#) $Header: /tcpdump/master/tcpdump/interface.h,v 1.190 2002-07-11 09:17:22 guy Exp $ (LBL)
  */
 
 #ifndef tcpdump_interface_h
@@ -202,7 +202,10 @@ extern int snap_print(const u_char *, u_int, u_int, const u_char *,
 extern void aarp_print(const u_char *, u_int);
 extern void arp_print(const u_char *, u_int, u_int);
 extern void atalk_print(const u_char *, u_int);
+extern void atm_print(u_int, u_int, u_int, const u_char *, u_int, u_int);
 extern void atm_if_print(u_char *, const struct pcap_pkthdr *, const u_char *);
+extern void bpfatm_if_print(u_char *, const struct pcap_pkthdr *, const u_char *);
+extern void sunatm_if_print(u_char *, const struct pcap_pkthdr *, const u_char *);
 extern void bootp_print(const u_char *, u_int, u_short, u_short);
 extern void bgp_print(const u_char *, int);
 extern void beep_print(const u_char *, u_int);
@@ -264,6 +267,7 @@ extern int vjc_print(register const char *, register u_int, u_short);
 extern void raw_if_print(u_char *, const struct pcap_pkthdr *, const u_char *);
 extern void rip_print(const u_char *, u_int);
 extern void sl_if_print(u_char *, const struct pcap_pkthdr *, const u_char *);
+extern void lane_print(const u_char *, u_int, u_int);
 extern void lane_if_print(u_char *, const struct pcap_pkthdr *,const u_char *);
 extern void cip_if_print(u_char *, const struct pcap_pkthdr *,const u_char *);
 extern void sl_bsdos_if_print(u_char *, const struct pcap_pkthdr *,
diff --git a/lane.h b/lane.h
index 796cdc499e05e1cfb947950788327f1a7fc34312..691d9622d5d9424379518c773e887b3410a880f8 100644 (file)
--- a/lane.h
+++ b/lane.h
@@ -20,7 +20,7 @@
  *
  */
 
-/* $Id: lane.h,v 1.4 2002-06-11 17:08:39 itojun Exp $ */
+/* $Id: lane.h,v 1.5 2002-07-11 09:17:23 guy Exp $ */
 
 #ifndef ETHER_ADDR_LEN
 #define ETHER_ADDR_LEN 6
@@ -32,3 +32,10 @@ struct lecdatahdr_8023 {
   u_int8_t h_source[ETHER_ADDR_LEN];
   u_int16_t h_type;
 };
+
+struct lane_controlhdr {
+  u_int16_t lec_header;
+  u_int8_t lec_proto;
+  u_int8_t lec_vers;
+  u_int16_t lec_opcode;
+};
index 5b0d410b2cb2286434bdb54171de897b70c3adfa..93a5a220da4a5203389d185397dc142e12487022 100644 (file)
@@ -21,7 +21,7 @@
 
 #ifndef lint
 static const char rcsid[] =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-arp.c,v 1.53 2002-04-25 04:37:31 guy Exp $ (LBL)";
+    "@(#) $Header: /tcpdump/master/tcpdump/print-arp.c,v 1.54 2002-07-11 09:17:23 guy Exp $ (LBL)";
 #endif
 
 #ifdef HAVE_CONFIG_H
@@ -98,8 +98,123 @@ struct      arp_pkthdr {
 #define THA(ap) (ar_tha(ap))
 #define TPA(ap) (ar_tpa(ap))
 
+/*
+ * ATM Address Resolution Protocol.
+ *
+ * See RFC 2225 for protocol description.  ARP packets are variable
+ * in size; the arphdr structure defines the fixed-length portion.
+ * Protocol type values are the same as those for 10 Mb/s Ethernet.
+ * It is followed by the variable-sized fields ar_sha, arp_spa,
+ * arp_tha and arp_tpa in that order, according to the lengths
+ * specified.  Field names used correspond to RFC 826.
+ */
+struct atmarp_pkthdr {
+       u_short ar_hrd;         /* format of hardware address */
+#define ARPHRD_ATM2225 19      /* ATM (RFC 2225) */
+       u_short ar_pro;         /* format of protocol address */
+       u_char  ar_shtl;        /* length of hardware address */
+       u_char  ar_sstl;        /* length of hardware address */
+       u_short ar_op;          /* same as regular ARP */
+       u_char  ar_spln;
+       u_char  ar_thtl;
+       u_char  ar_tstl;
+       u_char  ar_tpln;
+/*
+ * The remaining fields are variable in size,
+ * according to the sizes above.
+ */
+#ifdef COMMENT_ONLY
+       u_char  ar_sha[];       /* sender hardware address */
+       u_char  ar_spa[];       /* sender protocol address */
+       u_char  ar_tha[];       /* target hardware address */
+       u_char  ar_tpa[];       /* target protocol address */
+#endif
+#define ar_sha(ap)     (((const u_char *)((ap)+1))+0)
+#define ar_spa(ap)     (((const u_char *)((ap)+1))+  (ap)->ar_hln)
+#define ar_tha(ap)     (((const u_char *)((ap)+1))+  (ap)->ar_hln+(ap)->ar_pln)
+#define ar_tpa(ap)     (((const u_char *)((ap)+1))+2*(ap)->ar_hln+(ap)->ar_pln)
+};
+
 static u_char ezero[6];
 
+static void
+atmarp_print(const u_char *bp, u_int length, u_int caplen)
+{
+       const struct arp_pkthdr *ap;
+       u_short pro, hrd, op;
+
+       ap = (const struct arp_pkthdr *)bp;
+       TCHECK(*ap);
+       if ((const u_char *)(ar_tpa(ap) + PLN(ap)) > snapend) {
+               (void)printf("truncated-arp");
+               default_print((const u_char *)ap, length);
+               return;
+       }
+
+       hrd = EXTRACT_16BITS(&HRD(ap));
+       if (hrd == ARPHRD_ATM2225)
+               atmarp_print(bp, length, caplen);
+       pro = EXTRACT_16BITS(&PRO(ap));
+       op = EXTRACT_16BITS(&OP(ap));
+
+       if (pro != ETHERTYPE_IP && pro != ETHERTYPE_TRAIL) {
+               (void)printf("arp-#%d for proto #%d (%d) hardware #%d (%d)",
+                               op, pro, PLN(ap), hrd, HLN(ap));
+               return;
+       }
+       if (pro == ETHERTYPE_TRAIL)
+               (void)printf("trailer-");
+       switch (op) {
+
+       case ARPOP_REQUEST:
+               (void)printf("arp who-has %s", ipaddr_string(TPA(ap)));
+               if (memcmp((const char *)ezero, (const char *)THA(ap), HLN(ap)) != 0)
+                       (void)printf(" (%s)",
+                           linkaddr_string(THA(ap), HLN(ap)));
+               (void)printf(" tell %s", ipaddr_string(SPA(ap)));
+               break;
+
+       case ARPOP_REPLY:
+               (void)printf("arp reply %s", ipaddr_string(SPA(ap)));
+               (void)printf(" is-at %s", linkaddr_string(SHA(ap), HLN(ap)));
+               break;
+
+       case ARPOP_REVREQUEST:
+               (void)printf("rarp who-is %s tell %s",
+                       linkaddr_string(THA(ap), HLN(ap)),
+                       linkaddr_string(SHA(ap), HLN(ap)));
+               break;
+
+       case ARPOP_REVREPLY:
+               (void)printf("rarp reply %s at %s",
+                       linkaddr_string(THA(ap), HLN(ap)),
+                       ipaddr_string(TPA(ap)));
+               break;
+
+       case ARPOP_INVREQUEST:
+               (void)printf("invarp who-is %s tell %s",
+                       linkaddr_string(THA(ap), HLN(ap)),
+                       linkaddr_string(SHA(ap), HLN(ap)));
+               break;
+
+       case ARPOP_INVREPLY:
+               (void)printf("invarp reply %s at %s",
+                       linkaddr_string(THA(ap), HLN(ap)),
+                       ipaddr_string(TPA(ap)));
+               break;
+
+       default:
+               (void)printf("arp-#%d", op);
+               default_print((const u_char *)ap, caplen);
+               return;
+       }
+       if (hrd != ARPHRD_ETHER)
+               printf(" hardware #%d", hrd);
+       return;
+trunc:
+       (void)printf("[|arp]");
+}
+
 void
 arp_print(const u_char *bp, u_int length, u_int caplen)
 {
@@ -114,8 +229,10 @@ arp_print(const u_char *bp, u_int length, u_int caplen)
                return;
        }
 
-       pro = EXTRACT_16BITS(&PRO(ap));
        hrd = EXTRACT_16BITS(&HRD(ap));
+       if (hrd == ARPHRD_ATM2225)
+               atmarp_print(bp, length, caplen);
+       pro = EXTRACT_16BITS(&PRO(ap));
        op = EXTRACT_16BITS(&OP(ap));
 
        if (pro != ETHERTYPE_IP && pro != ETHERTYPE_TRAIL) {
@@ -152,6 +269,18 @@ arp_print(const u_char *bp, u_int length, u_int caplen)
                        ipaddr_string(TPA(ap)));
                break;
 
+       case ARPOP_INVREQUEST:
+               (void)printf("invarp who-is %s tell %s",
+                       linkaddr_string(THA(ap), HLN(ap)),
+                       linkaddr_string(SHA(ap), HLN(ap)));
+               break;
+
+       case ARPOP_INVREPLY:
+               (void)printf("invarp reply %s at %s",
+                       linkaddr_string(THA(ap), HLN(ap)),
+                       ipaddr_string(TPA(ap)));
+               break;
+
        default:
                (void)printf("arp-#%d", op);
                default_print((const u_char *)ap, caplen);
index 9623ea71bc80b703e87788b971ceceb6ad1d65c0..6104c361aabf6b6346b6681b426a7541d94f3cb0 100644 (file)
@@ -20,7 +20,7 @@
  */
 #ifndef lint
 static const char rcsid[] =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-atm.c,v 1.23 2002-04-07 10:05:40 guy Exp $ (LBL)";
+    "@(#) $Header: /tcpdump/master/tcpdump/print-atm.c,v 1.24 2002-07-11 09:17:23 guy Exp $ (LBL)";
 #endif
 
 #ifdef HAVE_CONFIG_H
@@ -38,8 +38,11 @@ static const char rcsid[] =
 #include <string.h>
 
 #include "interface.h"
+#include "extract.h"
 #include "addrtoname.h"
 #include "ethertype.h"
+#include "atm.h"
+#include "atmuni31.h"
 
 #include "ether.h"
 
@@ -62,12 +65,9 @@ atm_llc_print(const u_char *p, int length, int caplen)
        memset(&ehdr, '\0', sizeof ehdr);
 
        /*
-        * Some printers want to get back at the ethernet addresses,
-        * and/or check that they're not walking off the end of the packet.
-        * Rather than pass them all the way down, we set these globals.
-        */
-       snapend = p + caplen;
-       /*
+        * Some printers want to get back at the ethernet addresses.
+        * Rather than pass it all the way down, we set this global.
+        *
         * Actually, the only printers that use packetp are print-arp.c
         * and print-bootp.c, and they assume that packetp points to an
         * Ethernet header.  The right thing to do is to fix them to know
@@ -106,6 +106,14 @@ atm_if_print(u_char *user, const struct pcap_pkthdr *h, const u_char *p)
                printf("[|atm]");
                goto out;
        }
+
+       /*
+        * Some printers want to check that they're not walking off the
+        * end of the packet.
+        * Rather than pass it all the way down, we set this global.
+        */
+       snapend = p + caplen;
+
        if (p[0] != 0xaa || p[1] != 0xaa || p[2] != 0x03) {
                /*
                 * XXX - assume 802.6 MAC header from Fore driver.
@@ -128,7 +136,127 @@ atm_if_print(u_char *user, const struct pcap_pkthdr *h, const u_char *p)
                default_print(p, caplen);
  out:
        putchar('\n');
-       --infodelay;
-       if (infoprint)
-               info(0);
+}
+
+/*
+ * ATM signalling.
+ */
+static struct tok msgtype2str[] = {
+       { CALL_PROCEED,         "Call_proceeding" },
+       { CONNECT,              "Connect" },
+       { CONNECT_ACK,          "Connect_ack" },
+       { SETUP,                "Setup" },
+       { RELEASE,              "Release" },
+       { RELEASE_DONE,         "Release_complete" },
+       { RESTART,              "Restart" },
+       { RESTART_ACK,          "Restart_ack" },
+       { STATUS,               "Status" },
+       { STATUS_ENQ,           "Status_enquiry" },
+       { ADD_PARTY,            "Add_party" },
+       { ADD_PARTY_ACK,        "Add_party_ack" },
+       { ADD_PARTY_REJ,        "Add_party_reject" },
+       { DROP_PARTY,           "Drop_party" },
+       { DROP_PARTY_ACK,       "Drop_party_ack" },
+       { 0,                    NULL }
+};
+
+static void
+sig_print(const u_char *p, int caplen)
+{
+       bpf_u_int32 call_ref;
+
+       if (caplen < PROTO_POS) {
+               printf("[|atm]");
+               return;
+       }
+       if (p[PROTO_POS] == Q2931) {
+               /*
+                * protocol:Q.2931 for User to Network Interface 
+                * (UNI 3.1) signalling
+                */
+               printf("Q.2931");
+               if (caplen < MSG_TYPE_POS) {
+                       printf(" [|atm]");
+                       return;
+               }
+               printf(":%s ",
+                   tok2str(msgtype2str, "msgtype#%d", p[MSG_TYPE_POS]));
+
+               if (caplen < CALL_REF_POS+3) {
+                       printf("[|atm]");
+                       return;
+               }
+               call_ref = EXTRACT_24BITS(&p[CALL_REF_POS]);
+               printf("CALL_REF:0x%06x", call_ref);
+       } else {
+               /* SCCOP with some unknown protocol atop it */
+               printf("SSCOP, proto %d ", p[PROTO_POS]);
+       }
+}
+
+/*
+ * Print an ATM PDU (such as an AAL5 PDU).
+ */
+void
+atm_print(u_int vpi, u_int vci, u_int traftype, const u_char *p, u_int length,
+    u_int caplen)
+{
+       if (eflag)
+               printf("VPI:%u VCI:%u ", vpi, vci);
+
+       /*
+        * Some printers want to check that they're not walking off the
+        * end of the packet.
+        * Rather than pass it all the way down, we set this global.
+        */
+       snapend = p + caplen;
+
+       if (vpi == 0) {
+               switch (vci) {
+
+               case PPC:
+                       sig_print(p, caplen);
+                       goto out;
+
+               case BCC:
+                       printf("broadcast sig: ");
+                       goto out;
+
+               case OAMF4SC:
+                       printf("oamF4(segment): ");
+                       goto out;
+
+               case OAMF4EC:
+                       printf("oamF4(end): ");
+                       goto out;
+
+               case METAC:
+                       printf("meta: ");
+                       goto out;
+
+               case ILMIC:
+                       printf("ilmi: ");
+                       snmp_print(p, length);
+                       goto out;
+               }
+       }
+
+       switch (traftype) {
+
+       case ATM_LLC:
+       default:
+               /*
+                * Assumes traffic is LLC if unknown.
+                */
+               atm_llc_print(p, length, caplen);
+               break;
+
+       case ATM_LANE:
+               lane_print(p, length, caplen);
+               break;
+       }
+
+out:
+       if (xflag)
+               default_print(p, caplen);
 }
index 329e1d57bc170ec54b353eda028dafffaac98991..e020c3bfbce32d99facde5d9c3fd4701c3ad0379 100644 (file)
@@ -22,7 +22,7 @@
 
 #ifndef lint
 static const char rcsid[] =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-lane.c,v 1.13 2002-06-11 17:08:51 itojun Exp $ (LBL)";
+    "@(#) $Header: /tcpdump/master/tcpdump/print-lane.c,v 1.14 2002-07-11 09:17:24 guy Exp $ (LBL)";
 #endif
 
 #ifdef HAVE_CONFIG_H
@@ -45,20 +45,40 @@ static const char rcsid[] =
 #include "ether.h"
 #include "lane.h"
 
+static const struct tok lecop2str[] = {
+       { 0x0001,       "configure request" },
+       { 0x0101,       "configure response" },
+       { 0x0002,       "join request" },
+       { 0x0102,       "join response" },
+       { 0x0003,       "ready query" },
+       { 0x0103,       "ready indication" },
+       { 0x0004,       "register request" },
+       { 0x0104,       "register response" },
+       { 0x0005,       "unregister request" },
+       { 0x0105,       "unregister response" },
+       { 0x0006,       "ARP request" },
+       { 0x0106,       "ARP response" },
+       { 0x0007,       "flush request" },
+       { 0x0107,       "flush response" },
+       { 0x0008,       "NARP request" },
+       { 0x0009,       "topology request" },
+       { 0,            NULL }
+};
+
 static inline void
-lane_print(register const u_char *bp, int length)
+lane_hdr_print(register const u_char *bp, int length)
 {
        register const struct lecdatahdr_8023 *ep;
 
        ep = (const struct lecdatahdr_8023 *)bp;
        if (qflag)
-               (void)printf("lecid:%d %s %s %d: ",
+               (void)printf("lecid:%x %s %s %d: ",
                             ntohs(ep->le_header),
                             etheraddr_string(ep->h_source),
                             etheraddr_string(ep->h_dest),
                             length);
        else
-               (void)printf("lecid:%d %s %s %s %d: ",
+               (void)printf("lecid:%x %s %s %s %d: ",
                             ntohs(ep->le_header),
                             etheraddr_string(ep->h_source),
                             etheraddr_string(ep->h_dest),
@@ -71,33 +91,47 @@ lane_print(register const u_char *bp, int length)
  * to the ether header of the packet, 'h->tv' is the timestamp,
  * 'h->length' is the length of the packet off the wire, and 'h->caplen'
  * is the number of bytes actually captured.
+ *
+ * This assumes 802.3, not 802.5, LAN emulation.
  */
 void
-lane_if_print(u_char *user, const struct pcap_pkthdr *h, const u_char *p)
+lane_print(const u_char *p, u_int length, u_int caplen)
 {
-       int caplen = h->caplen;
-       int length = h->len;
+       struct lane_controlhdr *lec;
        struct lecdatahdr_8023 *ep;
        u_short ether_type;
        u_short extracted_ethertype;
 
-       ++infodelay;
-       ts_print(&h->ts);
+       if (caplen < sizeof(struct lane_controlhdr)) {
+               printf("[|lane]");
+               return;
+       }
+
+       lec = (struct lane_controlhdr *)p;
+       if (ntohs(lec->lec_header) == 0xff00) {
+               /*
+                * LE Control.
+                */
+               printf("lec: proto %x vers %x %s",
+                   lec->lec_proto, lec->lec_vers,
+                   tok2str(lecop2str, "opcode-#%u", ntohs(lec->lec_opcode)));
+               return;
+       }
 
        if (caplen < sizeof(struct lecdatahdr_8023)) {
                printf("[|lane]");
-               goto out;
+               return;
        }
 
        if (eflag)
-               lane_print(p, length);
+               lane_hdr_print(p, length);
 
        /*
         * Some printers want to get back at the ethernet addresses,
         * and/or check that they're not walking off the end of the packet.
         * Rather than pass them all the way down, we set these globals.
         */
-       packetp = p;
+       packetp = p + 2;        /* skip the LECID */
        snapend = p + caplen;
 
        length -= sizeof(struct lecdatahdr_8023);
@@ -111,13 +145,13 @@ lane_if_print(u_char *user, const struct pcap_pkthdr *h, const u_char *p)
         * Is it (gag) an 802.3 encapsulation?
         */
        extracted_ethertype = 0;
-       if (ether_type < ETHERMTU) {
+       if (ether_type <= ETHERMTU) {
                /* Try to print the LLC-layer header & higher layers */
                if (llc_print(p, length, caplen, ep->h_source, ep->h_dest,
                    &extracted_ethertype) == 0) {
                        /* ether_type not known, print raw packet */
                        if (!eflag)
-                               lane_print((u_char *)ep, length + sizeof(*ep));
+                               lane_hdr_print((u_char *)ep, length + sizeof(*ep));
                        if (extracted_ethertype) {
                                printf("(LLC %s) ",
                               etherproto_string(htons(extracted_ethertype)));
@@ -129,13 +163,25 @@ lane_if_print(u_char *user, const struct pcap_pkthdr *h, const u_char *p)
            &extracted_ethertype) == 0) {
                /* ether_type not known, print raw packet */
                if (!eflag)
-                       lane_print((u_char *)ep, length + sizeof(*ep));
+                       lane_hdr_print((u_char *)ep, length + sizeof(*ep));
                if (!xflag && !qflag)
                        default_print(p, caplen);
        }
        if (xflag)
                default_print(p, caplen);
- out:
+}
+
+void
+lane_if_print(u_char *user, const struct pcap_pkthdr *h, const u_char *p)
+{
+       int caplen = h->caplen;
+       int length = h->len;
+
+       ++infodelay;
+       ts_print(&h->ts);
+
+       lane_print(p, length, caplen);
+
        putchar('\n');
        --infodelay;
        if (infoprint)
diff --git a/print-sunatm.c b/print-sunatm.c
new file mode 100644 (file)
index 0000000..0f9f6f5
--- /dev/null
@@ -0,0 +1,123 @@
+/*
+ * Copyright (c) 1997 Yen Yen Lim and North Dakota State University
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *      This product includes software developed by Yen Yen Lim and
+       North Dakota State University
+ * 4. The name of the author may not be used to endorse or promote products
+ *    derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <sys/param.h>
+#include <sys/time.h>
+#include <sys/socket.h>
+struct mbuf;
+struct rtentry;
+#include <netinet/in.h>
+#include <stdio.h>
+#include <pcap.h>
+
+#include "interface.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) */
+#define VPI_POS                1       /* VPI */
+#define VCI_POS                2       /* VCI */
+#define PKT_BEGIN_POS   4      /* Start of the ATM packet */
+
+/* Protocol type values in the bottom for bits of the byte at SUNATM_DIR_POS. */
+#define PT_LANE                0x01    /* LANE */
+#define PT_LLC         0x02    /* LLC encapsulation */
+
+/*
+ * This is the top level routine of the printer.  'p' is the points
+ * to the SunATM pseudo-header for the packet, 'h->tv' is the timestamp,
+ * 'h->length' is the length of the packet off the wire, and 'h->caplen'
+ * is the number of bytes actually captured.
+ */
+void
+sunatm_if_print(u_char *user, const struct pcap_pkthdr *h, const u_char *p)
+{
+       u_int caplen = h->caplen;
+       u_int length = h->len;
+       u_short vci;
+       u_char vpi;
+       u_int traftype;
+
+       ts_print(&h->ts);
+
+       if (caplen < PKT_BEGIN_POS) {
+               printf("[|atm]");
+               goto out;
+       }
+
+       if (eflag) {
+               if (p[DIR_POS] & 0x80)
+                       printf("Tx: ");
+               else
+                       printf("Rx: ");
+       }
+
+       switch (p[DIR_POS] & 0x0f) {
+
+       case PT_LANE:
+               traftype = ATM_LANE;
+               break;
+
+       case PT_LLC:
+               traftype = ATM_LLC;
+               break;
+
+       default:
+               traftype = ATM_UNKNOWN;
+               break;
+       }
+
+       vci = EXTRACT_16BITS(&p[VCI_POS]);
+       vpi = p[VPI_POS];
+
+       p += PKT_BEGIN_POS;
+       caplen -= PKT_BEGIN_POS;
+       length -= PKT_BEGIN_POS;
+       atm_print(vpi, vci, traftype, p, length, caplen);
+
+ out:
+       putchar('\n');
+       --infodelay;
+       if (infoprint)
+               info(0);
+}
index c8c7bfdc7bdd76d473a84d97d3087a2353ecc0d1..1924e115602f05889ad9b0174014272b94405b99 100644 (file)
--- a/tcpdump.1
+++ b/tcpdump.1
@@ -1,4 +1,4 @@
-.\" @(#) $Header: /tcpdump/master/tcpdump/Attic/tcpdump.1,v 1.122 2002-06-24 21:06:23 fenner Exp $ (LBL)
+.\" @(#) $Header: /tcpdump/master/tcpdump/Attic/tcpdump.1,v 1.123 2002-07-11 09:17:24 guy Exp $ (LBL)
 .\"
 .\" Copyright (c) 1987, 1988, 1989, 1990, 1991, 1992, 1994, 1995, 1996, 1997
 .\"    The Regents of the University of California.  All rights reserved.
@@ -781,6 +781,52 @@ Abbreviations for:
 .in -.5i
 where \fIp\fR is one of the above protocols.
 Note that \fItcpdump\fR does an incomplete job of parsing these protocols.
+.IP "\fBvpi\fP \fIn\fR
+True if the packet is an ATM packet, for SunATM on Solaris, with a
+virtual path identifier of
+.IR n .
+.IP "\fBvci\fP \fIn\fR
+True if the packet is an ATM packet, for SunATM on Solaris, with a
+virtual channel identifier of
+.IR n .
+.IP \fBlane\fP
+True if the packet is an ATM packet, for SunATM on Solaris, and is
+an ATM LANE packet.
+.IP \fBllc\fP
+True if the packet is an ATM packet, for SunATM on Solaris, and is
+an LLC-encapsulated packet.
+.IP \fBoamf4s\fP
+True if the packet is an ATM packet, for SunATM on Solaris, and is
+a segment OAM F4 flow cell (VPI=0 & VCI=3).
+.IP \fBoamf4e\fP
+True if the packet is an ATM packet, for SunATM on Solaris, and is
+an end-to-end OAM F4 flow cell (VPI=0 & VCI=4).
+.IP \fBoamf4\fP
+True if the packet is an ATM packet, for SunATM on Solaris, and is
+a segment or end-to-end OAM F4 flow cell (VPI=0 & (VCI=3 | VCI=4)).
+.IP \fBoam\fP
+True if the packet is an ATM packet, for SunATM on Solaris, and is
+a segment or end-to-end OAM F4 flow cell (VPI=0 & (VCI=3 | VCI=4)).
+.IP \fBmetac\fP
+True if the packet is an ATM packet, for SunATM on Solaris, and is
+on a meta signaling circuit (VPI=0 & VCI=1).
+.IP \fBbcc\fP
+True if the packet is an ATM packet, for SunATM on Solaris, and is
+on a broadcast signaling circuit (VPI=0 & VCI=2).
+.IP \fBsc\fP
+True if the packet is an ATM packet, for SunATM on Solaris, and is
+on a signaling circuit (VPI=0 & VCI=5).
+.IP \fBilmic\fP
+True if the packet is an ATM packet, for SunATM on Solaris, and is
+on an ILMI circuit (VPI=0 & VCI=16).
+.IP \fBconnectmsg\fP
+True if the packet is an ATM packet, for SunATM on Solaris, and is
+on a signaling circuit and is a Q.2931 Setup, Call Proceeding, Connect,
+Connect Ack, Release, or Release Done message.
+.IP \fBmetaconnect\fP
+True if the packet is an ATM packet, for SunATM on Solaris, and is
+on a meta signaling circuit and is a Q.2931 Setup, Call Proceeding, Connect,
+Release, or Release Done message.
 .IP  "\fIexpr relop expr\fR"
 True if the relation holds, where \fIrelop\fR is one of >, <, >=, <=, =, !=,
 and \fIexpr\fR is an arithmetic expression composed of integer constants
index 30fdce8b60feaca67c45f194bd7899b15edadae6..43fad291cfd1e2be244ad34eb126027e055e9722 100644 (file)
--- a/tcpdump.c
+++ b/tcpdump.c
@@ -30,7 +30,7 @@ static const char copyright[] =
     "@(#) Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 2000\n\
 The Regents of the University of California.  All rights reserved.\n";
 static const char rcsid[] =
-    "@(#) $Header: /tcpdump/master/tcpdump/tcpdump.c,v 1.178 2002-07-11 08:09:47 guy Exp $ (LBL)";
+    "@(#) $Header: /tcpdump/master/tcpdump/tcpdump.c,v 1.179 2002-07-11 09:17:25 guy Exp $ (LBL)";
 #endif
 
 /*
@@ -167,6 +167,9 @@ static struct printer printers[] = {
 #endif
 #ifdef DLT_FRELAY
        { fr_if_print,          DLT_FRELAY },
+#endif
+#ifdef DLT_SUNATM
+       { sunatm_if_print,      DLT_SUNATM },
 #endif
        { NULL,                 0 },
 };