diff options
author | guy <guy> | 2002-07-11 09:17:21 +0000 |
---|---|---|
committer | guy <guy> | 2002-07-11 09:17:21 +0000 |
commit | 464c44fbd1394ac006d8d99f16e80ead423c1c47 (patch) | |
tree | 27f717c30088bc1be70fc91aeab7ebea3c269fa5 /print-atm.c | |
parent | c2b35f3e4666107c43e2c7405f2d99ad118e7565 (diff) | |
download | tcpdump-464c44fbd1394ac006d8d99f16e80ead423c1c47.tar.gz |
Add SunATM support, based on code from Yen Yen Lim at North Dakota State
University.
Diffstat (limited to 'print-atm.c')
-rw-r--r-- | print-atm.c | 148 |
1 files changed, 138 insertions, 10 deletions
diff --git a/print-atm.c b/print-atm.c index 9623ea71..6104c361 100644 --- a/print-atm.c +++ b/print-atm.c @@ -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); } |