summaryrefslogtreecommitdiff
path: root/print-lane.c
diff options
context:
space:
mode:
authorguy <guy>2002-07-11 09:17:21 +0000
committerguy <guy>2002-07-11 09:17:21 +0000
commit464c44fbd1394ac006d8d99f16e80ead423c1c47 (patch)
tree27f717c30088bc1be70fc91aeab7ebea3c269fa5 /print-lane.c
parentc2b35f3e4666107c43e2c7405f2d99ad118e7565 (diff)
downloadtcpdump-464c44fbd1394ac006d8d99f16e80ead423c1c47.tar.gz
Add SunATM support, based on code from Yen Yen Lim at North Dakota State
University.
Diffstat (limited to 'print-lane.c')
-rw-r--r--print-lane.c78
1 files changed, 62 insertions, 16 deletions
diff --git a/print-lane.c b/print-lane.c
index 329e1d57..e020c3bf 100644
--- a/print-lane.c
+++ b/print-lane.c
@@ -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)