diff options
author | Gerald Combs <gerald@wireshark.org> | 1999-09-11 22:36:38 +0000 |
---|---|---|
committer | Gerald Combs <gerald@wireshark.org> | 1999-09-11 22:36:38 +0000 |
commit | feda83f7e000cc96c045f24a4b8581f794ab2ea0 (patch) | |
tree | c131f7fe521ff9d8cd29f44247b4373fd851d1a8 /wiretap | |
parent | 4ac044cc3e8a7bbb4b8d65eb8939ae6b3c2a9ec4 (diff) |
Added Guy's patch to use the pseudo header facility to pass up the Ascend
metadata.
Also added filter items for the session and task number.
svn path=/trunk/; revision=664
Diffstat (limited to 'wiretap')
-rw-r--r-- | wiretap/ascend-grammar.y | 32 | ||||
-rw-r--r-- | wiretap/ascend-scanner.l | 8 | ||||
-rw-r--r-- | wiretap/ascend.c | 19 | ||||
-rw-r--r-- | wiretap/ascend.h | 20 | ||||
-rw-r--r-- | wiretap/wtap.h | 19 |
5 files changed, 58 insertions, 40 deletions
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 { |