aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--packet-ascend.c61
-rw-r--r--proto.c4
-rw-r--r--wiretap/ascend-grammar.y32
-rw-r--r--wiretap/ascend-scanner.l8
-rw-r--r--wiretap/ascend.c19
-rw-r--r--wiretap/ascend.h20
-rw-r--r--wiretap/wtap.h19
7 files changed, 102 insertions, 61 deletions
diff --git a/packet-ascend.c b/packet-ascend.c
index b1da4c2cf0..ddd5461431 100644
--- a/packet-ascend.c
+++ b/packet-ascend.c
@@ -1,7 +1,7 @@
/* packet-ascend.c
* Routines for decoding Lucent/Ascend packet traces
*
- * $Id: packet-ascend.c,v 1.2 1999/09/11 06:51:28 guy Exp $
+ * $Id: packet-ascend.c,v 1.3 1999/09/11 22:36:29 gerald Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@@ -33,20 +33,20 @@
#include <string.h>
#include "packet.h"
-#include "wiretap/ascend.h"
+static int proto_ascend = -1;
+static int hf_session_id = -1;
+static int hf_task = -1;
+
+static const value_string encaps_vals[] = {
+ {ASCEND_PFX_ETHER, "Ethernet" },
+ {ASCEND_PFX_PPP_X, "PPP Transmit"},
+ {ASCEND_PFX_PPP_R, "PPP Receive" },
+ {0, NULL } };
void
dissect_ascend( const u_char *pd, frame_data *fd, proto_tree *tree ) {
proto_tree *fh_tree;
proto_item *ti;
- ascend_pkthdr header;
- static const value_string encaps_vals[] = {
- {ASCEND_PFX_ETHER, "Ethernet" },
- {ASCEND_PFX_PPP_X, "PPP Transmit"},
- {ASCEND_PFX_PPP_R, "PPP Receive" },
- {0, NULL } };
-
- memcpy(&header, pd, ASCEND_PKTHDR_OFFSET);
/* load the top pane info. This should be overwritten by
the next protocol in the stack */
@@ -64,18 +64,24 @@ dissect_ascend( const u_char *pd, frame_data *fd, proto_tree *tree ) {
if(tree) {
ti = proto_tree_add_text(tree, 0, 0, "Lucent/Ascend packet trace" );
fh_tree = proto_item_add_subtree(ti, ETT_RAW);
- proto_tree_add_text(fh_tree, 0, 0, "Link type: %s", val_to_str(header.type,
- encaps_vals, "Unknown (%d)"));
- proto_tree_add_text(fh_tree, 0, 0, "Username: %s", header.user);
- proto_tree_add_text(fh_tree, 0, 0, "Session: %d", header.sess);
- proto_tree_add_text(fh_tree, 0, 0, "Task: %08X", header.task);
+
+ /* XXX - should these be added with "proto_tree_add_item_format()"
+ (see "dissect_packet()" for an example of how to add items
+ that aren't in the packet data in that fashion) so that we
+ can filter on them? */
+ proto_tree_add_text(fh_tree, 0, 0, "Link type: %s",
+ val_to_str(fd->pseudo_header.ascend.type, encaps_vals, "Unknown (%d)"));
+ proto_tree_add_text(fh_tree, 0, 0, "Username: %s",
+ fd->pseudo_header.ascend.user);
+ proto_tree_add_item_format(fh_tree, hf_session_id, 0, 0,
+ fd->pseudo_header.ascend.sess, "Session: %d",
+ fd->pseudo_header.ascend.sess);
+ proto_tree_add_item_format(fh_tree, hf_task, 0, 0,
+ fd->pseudo_header.ascend.task, "Task: 0x%08X",
+ fd->pseudo_header.ascend.task);
}
- /* The header is metadata, so we copy the packet data to the front */
- /* XXX Maybe we should leave it in, and mark it as metadata, so that
- it can be filtered upon? */
- memmove(pd, pd + ASCEND_PKTHDR_OFFSET, fd->cap_len);
- switch (header.type) {
+ switch (fd->pseudo_header.ascend.type) {
case ASCEND_PFX_ETHER:
dissect_eth(pd, 0, fd, tree);
break;
@@ -86,3 +92,18 @@ dissect_ascend( const u_char *pd, frame_data *fd, proto_tree *tree ) {
}
}
+void
+proto_register_ascend(void)
+{
+ static hf_register_info hf[] = {
+ { &hf_session_id,
+ { "Session ID", "ascend.sess", FT_UINT32, NULL }},
+
+ { &hf_task,
+ { "Task", "ascend.task", FT_UINT32, NULL }}
+ };
+
+ proto_ascend = proto_register_protocol("Lucent/Ascend debug output", "ascend");
+ proto_register_field_array(proto_ascend, hf, array_length(hf));
+}
+
diff --git a/proto.c b/proto.c
index 184afed38d..4e5e967252 100644
--- a/proto.c
+++ b/proto.c
@@ -1,7 +1,7 @@
/* proto.c
* Routines for protocol tree
*
- * $Id: proto.c,v 1.22 1999/09/11 16:41:18 deniel Exp $
+ * $Id: proto.c,v 1.23 1999/09/11 22:36:30 gerald Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@@ -87,6 +87,7 @@ static int proto_register_field_init(header_field_info *hfinfo, int parent);
/* centralization of registration functions */
void proto_register_aarp(void);
void proto_register_arp(void);
+void proto_register_ascend(void);
void proto_register_atalk(void);
void proto_register_atm(void);
void proto_register_bootp(void);
@@ -191,6 +192,7 @@ proto_init(void)
* just to make it easy. */
proto_register_aarp();
proto_register_arp();
+ proto_register_ascend();
proto_register_atalk();
proto_register_atm();
proto_register_bootp();
diff --git a/wiretap/ascend-grammar.y b/wiretap/ascend-grammar.y
index 07a4762281..dc244bf9ad 100644
--- a/wiretap/ascend-grammar.y
+++ b/wiretap/ascend-grammar.y
@@ -35,7 +35,8 @@ void yyerror(char *);
int bcur = 0, bcount;
guint32 secs, usecs, caplen, wirelen;
-ascend_pkthdr header;
+ascend_pkthdr *header;
+struct ascend_phdr *pseudo_header;
char *pkt_data;
FILE *nfh = NULL;
@@ -84,10 +85,12 @@ header: prefix username sessnum KEYWORD tasknum KEYWORD timeval timeval octets K
else
secs = $7;
usecs = $8;
- /* header.user is set in ascend-scanner.l */
- header.type = $1;
- header.sess = $3;
- header.task = $5;
+ if (pseudo_header != NULL) {
+ /* pseudo_header->user is set in ascend-scanner.l */
+ pseudo_header->type = $1;
+ pseudo_header->sess = $3;
+ pseudo_header->task = $5;
+ }
bcur = 0;
}
@@ -95,16 +98,17 @@ header: prefix username sessnum KEYWORD tasknum KEYWORD timeval timeval octets K
byte: BYTE {
if (bcur < caplen) {
- pkt_data[bcur + ASCEND_PKTHDR_OFFSET] = $1;
+ pkt_data[bcur] = $1;
bcur++;
}
if (bcur >= caplen) {
- header.secs = secs;
- header.usecs = usecs;
- header.caplen = caplen;
- header.len = wirelen;
- memcpy(pkt_data, &header, ASCEND_PKTHDR_OFFSET);
+ if (header != NULL) {
+ header->secs = secs;
+ header->usecs = usecs;
+ header->caplen = caplen;
+ header->len = wirelen;
+ }
YYACCEPT;
}
}
@@ -160,15 +164,17 @@ init_parse_ascend()
/* Parse the capture file. Return the offset of the next packet, or zero
if there is none. */
int
-parse_ascend(FILE *fh, void *pd, int len)
+parse_ascend(FILE *fh, void *pd, struct ascend_phdr *phdr,
+ ascend_pkthdr *hdr, int len)
{
/* yydebug = 1; */
ascend_init_lexer(fh, nfh);
pkt_data = pd;
+ pseudo_header = phdr;
+ header = hdr;
bcount = len;
- /* Skip errors until we get something parsed. */
if (yyparse())
return 0;
else
diff --git a/wiretap/ascend-scanner.l b/wiretap/ascend-scanner.l
index e70f162778..2b7f21545b 100644
--- a/wiretap/ascend-scanner.l
+++ b/wiretap/ascend-scanner.l
@@ -10,7 +10,7 @@
#include "ascend.h"
#include "ascend-grammar.h"
-extern ascend_pkthdr header;
+struct ascend_phdr *pseudo_header;
int at_eof;
int mul, scratch;
@@ -57,8 +57,10 @@ EPFX "ETHER "
<sc_user>[^:]+ {
BEGIN(sc_sess);
- strncpy(header.user, ascendtext, ASCEND_MAX_STR_LEN);
- header.user[ASCEND_MAX_STR_LEN - 1] = '\0';
+ if (pseudo_header != NULL) {
+ strncpy(pseudo_header->user, ascendtext, ASCEND_MAX_STR_LEN);
+ pseudo_header->user[ASCEND_MAX_STR_LEN - 1] = '\0';
+ }
return USERNAME;
}
diff --git a/wiretap/ascend.c b/wiretap/ascend.c
index 3ff602e35f..54efbf5425 100644
--- a/wiretap/ascend.c
+++ b/wiretap/ascend.c
@@ -1,6 +1,6 @@
/* ascend.c
*
- * $Id: ascend.c,v 1.3 1999/09/11 07:07:41 guy Exp $
+ * $Id: ascend.c,v 1.4 1999/09/11 22:36:38 gerald Exp $
*
* Wiretap Library
* Copyright (c) 1998 by Gilbert Ramirez <gram@verdict.uthscsa.edu>
@@ -129,13 +129,18 @@ int ascend_open(wtap *wth, int *err)
wth->subtype_read = ascend_read;
wth->capture.ascend = g_malloc(sizeof(ascend_t));
+ /* MAXen and Pipelines report the time since reboot. In order to keep
+ from reporting packet times near the epoch, we subtract the first
+ packet's timestamp from the capture file's ctime, which gives us an
+ offset that we can apply to each packet.
+ */
fstat(fileno(wth->fh), &statbuf);
wth->capture.ascend->inittime = statbuf.st_ctime;
wth->capture.ascend->adjusted = 0;
wth->capture.ascend->seek_add = -1;
init_parse_ascend();
-
+
return 1;
}
@@ -157,15 +162,13 @@ static int ascend_read(wtap *wth, int *err)
if (offset < 1) {
return 0;
}
- if (! parse_ascend(wth->fh, buf, 0)) {
+ if (! parse_ascend(wth->fh, buf, &wth->phdr.pseudo_header.ascend, &header, 0)) {
*err = WTAP_ERR_BAD_RECORD;
return -1;
}
- buffer_assure_space(wth->frame_buffer, wth->snapshot_length +
- ASCEND_PKTHDR_OFFSET);
+ buffer_assure_space(wth->frame_buffer, wth->snapshot_length);
- memcpy(&header, buf, ASCEND_PKTHDR_OFFSET);
if (! wth->capture.ascend->adjusted) {
wth->capture.ascend->adjusted = 1;
if (wth->capture.ascend->inittime > header.secs)
@@ -177,12 +180,12 @@ static int ascend_read(wtap *wth, int *err)
wth->phdr.len = header.len;
wth->phdr.pkt_encap = wth->file_encap;
wth->data_offset = offset;
-
+
return offset;
}
int ascend_seek_read (FILE *fh, int seek_off, guint8 *pd, int len)
{
fseek(fh, seek_off - 1, SEEK_SET);
- return parse_ascend(fh, pd, len);
+ return parse_ascend(fh, pd, NULL, NULL, len);
}
diff --git a/wiretap/ascend.h b/wiretap/ascend.h
index fb7accd6de..c9db11ae1d 100644
--- a/wiretap/ascend.h
+++ b/wiretap/ascend.h
@@ -1,6 +1,6 @@
/* ascend.h
*
- * $Id: ascend.h,v 1.2 1999/09/11 06:49:42 guy Exp $
+ * $Id: ascend.h,v 1.3 1999/09/11 22:36:38 gerald Exp $
*
* Wiretap Library
* Copyright (c) 1998 by Gilbert Ramirez <gram@verdict.uthscsa.edu>
@@ -21,29 +21,19 @@
*
*/
-#define ASCEND_MAX_STR_LEN 64
#define ASCEND_MAX_DATA_ROWS 8
#define ASCEND_MAX_DATA_COLS 16
#define ASCEND_MAX_PKT_LEN (ASCEND_MAX_DATA_ROWS * ASCEND_MAX_DATA_COLS)
-#define ASCEND_PFX_ETHER 1
-#define ASCEND_PFX_PPP_X 2
-#define ASCEND_PFX_PPP_R 3
-
typedef struct {
- guint16 type; /* ASCEND_PFX_*, as defined above */
- char user[ASCEND_MAX_STR_LEN]; /* Username, from header */
- guint32 sess; /* Session number */
- guint32 task; /* Task number */
- guint32 secs;
- guint32 usecs;
+ time_t secs;
+ time_t usecs;
guint32 caplen;
guint32 len;
} ascend_pkthdr;
-#define ASCEND_PKTHDR_OFFSET sizeof(ascend_pkthdr)
-
int ascend_open(wtap *wth, int *err);
void init_parse_ascend();
-int parse_ascend(FILE *fh, void *pd, int len);
+int parse_ascend(FILE *fh, void *pd, struct ascend_phdr *phdr,
+ ascend_pkthdr *hdr, int len);
int ascend_seek_read (FILE *fh, int seek_off, guint8 *pd, int len);
diff --git a/wiretap/wtap.h b/wiretap/wtap.h
index 10bb64db5a..6f46121182 100644
--- a/wiretap/wtap.h
+++ b/wiretap/wtap.h
@@ -1,6 +1,6 @@
/* wtap.h
*
- * $Id: wtap.h,v 1.36 1999/09/11 04:50:44 gerald Exp $
+ * $Id: wtap.h,v 1.37 1999/09/11 22:36:38 gerald Exp $
*
* Wiretap Library
* Copyright (c) 1998 by Gilbert Ramirez <gram@verdict.uthscsa.edu>
@@ -189,6 +189,22 @@ struct ngsniffer_atm_phdr {
guint32 aal5t_chksum; /* checksum for AAL5 packet */
};
+/* Packet "pseudo-header" for the output from "wandsession", "wannext",
+ "wandisplay", and similar commands on Lucent/Ascend access equipment. */
+
+#define ASCEND_MAX_STR_LEN 64
+
+#define ASCEND_PFX_ETHER 1
+#define ASCEND_PFX_PPP_X 2
+#define ASCEND_PFX_PPP_R 3
+
+struct ascend_phdr {
+ guint16 type; /* ASCEND_PFX_*, as defined above */
+ char user[ASCEND_MAX_STR_LEN]; /* Username, from header */
+ guint32 sess; /* Session number */
+ guint32 task; /* Task number */
+};
+
/*
* Bits in AppTrafType.
*
@@ -244,6 +260,7 @@ struct ngsniffer_atm_phdr {
union pseudo_header {
struct x25_phdr x25;
struct ngsniffer_atm_phdr ngsniffer_atm;
+ struct ascend_phdr ascend;
};
struct wtap_pkthdr {