diff options
author | Gerald Combs <gerald@wireshark.org> | 1999-09-13 03:49:04 +0000 |
---|---|---|
committer | Gerald Combs <gerald@wireshark.org> | 1999-09-13 03:49:04 +0000 |
commit | f4f6b71d0c047a1590ba4f00e5b3cae32bcd644b (patch) | |
tree | 2ca76f151b64cf3ee4f92754e15a1d868bd17fa0 /wiretap | |
parent | f5e3d82e504a81599b8ab59d2320eb30b5d3530f (diff) |
Add support for "wdd" trace output.
svn path=/trunk/; revision=673
Diffstat (limited to 'wiretap')
-rw-r--r-- | wiretap/ascend-grammar.y | 78 | ||||
-rw-r--r-- | wiretap/ascend-scanner.l | 179 | ||||
-rw-r--r-- | wiretap/ascend.c | 51 |
3 files changed, 230 insertions, 78 deletions
diff --git a/wiretap/ascend-grammar.y b/wiretap/ascend-grammar.y index dc244bf9ad..99e5b7debc 100644 --- a/wiretap/ascend-grammar.y +++ b/wiretap/ascend-grammar.y @@ -11,6 +11,18 @@ XMIT-iguana:241:(task: B04E12C0, time: 1975432.85) 53 octets @ 8009EB16 [0010]: 00 7A 06 D8 B1 CF 00 FB 08 CE 41 62 12 00 50 20 [0020]: 29 7C 4C 71 9C 9A 6A 93 A4 60 12 22 38 3F 10 00 [0030]: 00 02 04 05 B4 + + Example 'wdd' output data: + +Date: 01/12/1990. Time: 12:22:33 +Cause an attempt to place call to 14082750382 +WD_DIALOUT_DISP: chunk 2515EE type IP. +(task: 251790, time: 994953.28) 44 octets @ 2782B8 + [0000]: 00 C0 7B 71 45 6C 00 60 08 16 AA 51 08 00 45 00 + [0010]: 00 2C 66 1C 40 00 80 06 53 F6 AC 14 00 18 CC 47 + [0020]: C8 45 0A 31 00 50 3B D9 5B 75 00 00 + + */ %{ @@ -39,6 +51,7 @@ ascend_pkthdr *header; struct ascend_phdr *pseudo_header; char *pkt_data; FILE *nfh = NULL; +struct tm wddt; %} @@ -48,36 +61,31 @@ guint32 d; char b; } -%token <s> USERNAME HEXNUM KEYWORD COUNTER -%token <d> PREFIX SESSNUM TASKNUM TIMEVAL OCTETS +%token <s> STRING KEYWORD COUNTER +%token <d> WDS_PREFIX DECNUM HEXNUM %token <b> BYTE -%type <s> username hexnum dataln datagroup -%type <d> prefix sessnum tasknum timeval octets +%type <s> string dataln datagroup +%type <d> wds_prefix decnum hexnum %type <b> byte bytegroup %% data_packet: - | header datagroup + | wds_hdr datagroup + | wdd_hdr datagroup ; -prefix: PREFIX; - -username: USERNAME; +wds_prefix: WDS_PREFIX; -sessnum: SESSNUM; +string: STRING; -tasknum: TASKNUM; - -timeval: TIMEVAL; - -octets: OCTETS; +decnum: DECNUM; hexnum: HEXNUM; -/* 1 2 3 4 5 6 7 8 9 10 11 */ -header: prefix username sessnum KEYWORD tasknum KEYWORD timeval timeval octets KEYWORD HEXNUM { +/* 1 2 3 4 5 6 7 8 9 10 11 */ +wds_hdr: wds_prefix string decnum KEYWORD hexnum KEYWORD decnum decnum decnum KEYWORD HEXNUM { wirelen = $9; caplen = ($9 < ASCEND_MAX_PKT_LEN) ? $9 : ASCEND_MAX_PKT_LEN; if (bcount > 0 && bcount <= caplen) @@ -89,12 +97,48 @@ header: prefix username sessnum KEYWORD tasknum KEYWORD timeval timeval octets K /* pseudo_header->user is set in ascend-scanner.l */ pseudo_header->type = $1; pseudo_header->sess = $3; + pseudo_header->call_num[0] = '\0'; + pseudo_header->chunk = 0; pseudo_header->task = $5; } bcur = 0; } ; +/* +Date: 01/12/1990. Time: 12:22:33 +Cause an attempt to place call to 14082750382 +WD_DIALOUT_DISP: chunk 2515EE type IP. +(task: 251790, time: 994953.28) 44 octets @ 2782B8 +*/ +/* 1 2 3 4 5 6 6 6 9 10 11 12 13 14 15 16 17 18 19 20 21*/ +wdd_hdr: KEYWORD decnum decnum decnum KEYWORD decnum decnum decnum KEYWORD string KEYWORD hexnum KEYWORD KEYWORD hexnum KEYWORD decnum decnum decnum KEYWORD HEXNUM { + wddt.tm_sec = $4; + wddt.tm_min = $3; + wddt.tm_hour = $2; + wddt.tm_mday = $6; + wddt.tm_mon = $7; + wddt.tm_year = ($8 > 1970) ? $8 - 1900 : 70; + + wirelen = $19; + caplen = ($19 < ASCEND_MAX_PKT_LEN) ? $19 : ASCEND_MAX_PKT_LEN; + if (bcount > 0 && bcount <= caplen) + caplen = bcount; + else + secs = mktime(&wddt); + usecs = $18; + if (pseudo_header != NULL) { + /* pseudo_header->call_num is set in ascend-scanner.l */ + pseudo_header->type = ASCEND_PFX_WDD; + pseudo_header->user[0] = '\0'; + pseudo_header->sess = 0; + pseudo_header->chunk = $12; + pseudo_header->task = $15; + } + + bcur = 0; +} +; byte: BYTE { if (bcur < caplen) { @@ -114,7 +158,7 @@ byte: BYTE { } ; -/* There must be a better way to do this... */ +/* XXX There must be a better way to do this... */ bytegroup: byte | byte byte | byte byte byte diff --git a/wiretap/ascend-scanner.l b/wiretap/ascend-scanner.l index 2b7f21545b..97e8738363 100644 --- a/wiretap/ascend-scanner.l +++ b/wiretap/ascend-scanner.l @@ -24,66 +24,80 @@ H [A-Fa-f0-9] XPFX XMIT- RPFX RECV- -EPFX "ETHER " -%s sc_user -%s sc_sess -%s sc_task -%s sc_time_s -%s sc_time_u -%s sc_octets -%s sc_counter -%s sc_byte +WDD_DATE "Date:" +WDD_TIME "Time:" +WDD_CAUSE "Cause an attempt to place call to " +WDD_CALLNUM [^\n\r\t ]+ +WDD_CHUNK "WD_DIALOUT_DISP: chunk" +WDD_TYPE "type "[^\n\r\t ]+ + +%s sc_gen_task +%s sc_gen_time_s +%s sc_gen_time_u +%s sc_gen_octets +%s sc_gen_counter +%s sc_gen_byte + +%s sc_wds_user +%s sc_wds_sess + +%s sc_wdd_date_d +%s sc_wdd_date_m +%s sc_wdd_date_y +%s sc_wdd_time +%s sc_wdd_time_h +%s sc_wdd_time_m +%s sc_wdd_time_s +%s sc_wdd_cause +%s sc_wdd_callnum +%s sc_wdd_chunk +%s sc_wdd_chunknum +%s sc_wdd_type %% -<INITIAL,sc_byte>{EPFX} { - BEGIN(sc_user); - ascendlval.d = ASCEND_PFX_ETHER; - return PREFIX; +<INITIAL,sc_gen_byte>{XPFX} { + BEGIN(sc_wds_user); + ascendlval.d = ASCEND_PFX_WDS_X; + return WDS_PREFIX; } -<INITIAL,sc_byte>{XPFX} { - BEGIN(sc_user); - ascendlval.d = ASCEND_PFX_PPP_X; - return PREFIX; +<INITIAL,sc_gen_byte>{RPFX} { + BEGIN(sc_wds_user); + ascendlval.d = ASCEND_PFX_WDS_R; + return WDS_PREFIX; } -<INITIAL,sc_byte>{RPFX} { - BEGIN(sc_user); - ascendlval.d = ASCEND_PFX_PPP_R; - return PREFIX; -} - -<sc_user>[^:]+ { - BEGIN(sc_sess); +<sc_wds_user>[^:]+ { + BEGIN(sc_wds_sess); if (pseudo_header != NULL) { strncpy(pseudo_header->user, ascendtext, ASCEND_MAX_STR_LEN); pseudo_header->user[ASCEND_MAX_STR_LEN - 1] = '\0'; } - return USERNAME; + return STRING; } -<sc_sess>{D}+ { - BEGIN(sc_task); +<sc_wds_sess>{D}+ { + BEGIN(sc_gen_task); ascendlval.d = strtol(ascendtext, NULL, 10); - return SESSNUM; + return DECNUM; } -<sc_task>{H}+ { - BEGIN(sc_time_s); +<sc_gen_task>{H}+ { + BEGIN(sc_gen_time_s); ascendlval.d = strtoul(ascendtext, NULL, 16); - return TASKNUM; + return HEXNUM; } -<sc_time_s>{D}+ { - BEGIN(sc_time_u); +<sc_gen_time_s>{D}+ { + BEGIN(sc_gen_time_u); ascendlval.d = strtol(ascendtext, NULL, 10); - return TIMEVAL; + return DECNUM; } -<sc_time_u>{D}+ { - BEGIN(sc_octets); +<sc_gen_time_u>{D}+ { + BEGIN(sc_gen_octets); /* We have the fractional portion of the time. We want it converted to microseconds. */ mul = 1000000; @@ -91,25 +105,102 @@ EPFX "ETHER " for (scratch = ascendlval.d; scratch > 0; scratch /= 10) mul /= 10; ascendlval.d *= mul; - return TIMEVAL; + return DECNUM; } -<sc_octets>{D}+ { - BEGIN(sc_counter); +<sc_gen_octets>{D}+ { + BEGIN(sc_gen_counter); ascendlval.d = strtol(ascendtext, NULL, 10); - return OCTETS; + return DECNUM; } -<sc_counter,sc_byte>"["{H}{4}"]:" { - BEGIN(sc_byte); +<sc_gen_counter,sc_gen_byte>"["{H}{4}"]:" { + BEGIN(sc_gen_byte); return COUNTER; } -<sc_byte>{H}{2} { +<sc_gen_byte>{H}{2} { ascendlval.b = strtol(ascendtext, NULL, 16); return BYTE; } +<INITIAL,sc_gen_byte>{WDD_DATE} { + BEGIN(sc_wdd_date_d); + return KEYWORD; +} + +<sc_wdd_date_d>{D}{2} { + BEGIN(sc_wdd_date_m); + ascendlval.d = strtol(ascendtext, NULL, 10); + return DECNUM; +} + +<sc_wdd_date_m>{D}{2} { + BEGIN(sc_wdd_date_y); + ascendlval.d = strtol(ascendtext, NULL, 10); + return DECNUM; +} + +<sc_wdd_date_y>{D}{4} { + BEGIN(sc_wdd_time); + ascendlval.d = strtol(ascendtext, NULL, 10); + return DECNUM; +} + +<sc_wdd_time>{WDD_TIME} { + BEGIN(sc_wdd_time_h); + return KEYWORD; +} + +<sc_wdd_time_h>{D}{2} { + BEGIN(sc_wdd_time_m); + ascendlval.d = strtol(ascendtext, NULL, 10); + return DECNUM; +} + +<sc_wdd_time_m>{D}{2} { + BEGIN(sc_wdd_time_s); + ascendlval.d = strtol(ascendtext, NULL, 10); + return DECNUM; +} + +<sc_wdd_time_s>{D}{2} { + BEGIN(sc_wdd_cause); + ascendlval.d = strtol(ascendtext, NULL, 10); + return DECNUM; +} + +<sc_wdd_cause>{WDD_CAUSE} { + BEGIN(sc_wdd_callnum); + return KEYWORD; +} + +<sc_wdd_callnum>{WDD_CALLNUM} { + BEGIN(sc_wdd_chunk); + if (pseudo_header != NULL) { + strncpy(pseudo_header->call_num, ascendtext, ASCEND_MAX_STR_LEN); + pseudo_header->call_num[ASCEND_MAX_STR_LEN - 1] = '\0'; + } + return STRING; +} + +<sc_wdd_chunk>{WDD_CHUNK} { + BEGIN(sc_wdd_chunknum); + return KEYWORD; +} + +<sc_wdd_chunknum>{H}+ { + BEGIN(sc_wdd_type); + ascendlval.d = strtoul(ascendtext, NULL, 16); + return HEXNUM; +} + +<sc_wdd_type>{WDD_TYPE} { + BEGIN(sc_gen_task); + return KEYWORD; +} + + {H}+ { return HEXNUM; } task:|time:|octets { return KEYWORD; } diff --git a/wiretap/ascend.c b/wiretap/ascend.c index 54efbf5425..3443893d65 100644 --- a/wiretap/ascend.c +++ b/wiretap/ascend.c @@ -1,6 +1,6 @@ /* ascend.c * - * $Id: ascend.c,v 1.4 1999/09/11 22:36:38 gerald Exp $ + * $Id: ascend.c,v 1.5 1999/09/13 03:49:04 gerald Exp $ * * Wiretap Library * Copyright (c) 1998 by Gilbert Ramirez <gram@verdict.uthscsa.edu> @@ -63,25 +63,28 @@ XMIT-iguana:241:(task: B04E12C0, time: 1975432.85) 53 octets @ 8009EB16 /* How far into the file we should look for packet headers */ #define ASCEND_MAX_SEEK 1000000 +/* XXX Should we replace this with a more generalized array? */ /* Magic numbers for Ascend wandsession/wanopening/ether-display data */ -static const char ascend_xmagic[] = { 'X', 'M', 'I', 'T', '-' }; -static const char ascend_rmagic[] = { 'R', 'E', 'C', 'V', '-' }; -static const char ascend_emagic[] = { 'E', 'T', 'H', 'E', 'R', ' ' }; +static const char ascend_xmagic[] = { 'X', 'M', 'I', 'T', '-' }; +static const char ascend_rmagic[] = { 'R', 'E', 'C', 'V', '-' }; +static const char ascend_w1magic[] = { 'D', 'a', 't', 'e', ':', }; +static const char ascend_w2magic[] = { 'W', 'D', '_', 'D', 'I', 'A', 'L', 'O', 'U', 'T', '_', 'D', 'I', 'S', 'P', ':' }; -#define ASCEND_X_SIZE (sizeof ascend_xmagic / sizeof ascend_xmagic[0]) -#define ASCEND_R_SIZE (sizeof ascend_rmagic / sizeof ascend_rmagic[0]) -#define ASCEND_E_SIZE (sizeof ascend_emagic / sizeof ascend_emagic[0]) +#define ASCEND_X_SIZE (sizeof ascend_xmagic / sizeof ascend_xmagic[0]) +#define ASCEND_R_SIZE (sizeof ascend_rmagic / sizeof ascend_rmagic[0]) +#define ASCEND_W1_SIZE (sizeof ascend_w1magic / sizeof ascend_w1magic[0]) +#define ASCEND_W2_SIZE (sizeof ascend_w2magic / sizeof ascend_w2magic[0]) static int ascend_read(wtap *wth, int *err); /* Seeks to the beginning of the next packet, and returns the - byte offset. Returns 0 on failure. A valid offset is 0; since + byte offset. Returns -1 on failure. A valid offset is 0; since that causes problems with wtap_loop, offsets are incremented by one. */ /* XXX - Handle I/O errors. */ static int ascend_seek(wtap *wth, int max_seek) { - int byte, bytes_read = 0; - int x_level = 0, r_level = 0, e_level = 0; + int byte, bytes_read = 0, date_off = 0; + int x_level = 0, r_level = 0, w1_level = 0, w2_level = 0; while (((byte = fgetc(wth->fh)) != EOF) && bytes_read < max_seek) { if (byte == ascend_xmagic[x_level]) { @@ -90,20 +93,34 @@ static int ascend_seek(wtap *wth, int max_seek) fseek(wth->fh, -(ASCEND_X_SIZE), SEEK_CUR); return ftell(wth->fh) + 1; } - } else if (byte == ascend_rmagic[r_level]) { + } else { + x_level = 0; + } + if (byte == ascend_rmagic[r_level]) { r_level++; if (r_level >= ASCEND_R_SIZE) { fseek(wth->fh, -(ASCEND_R_SIZE), SEEK_CUR); return ftell(wth->fh) + 1; } - } else if (byte == ascend_emagic[e_level]) { - e_level++; - if (e_level >= ASCEND_E_SIZE) { - fseek(wth->fh, -(ASCEND_E_SIZE), SEEK_CUR); - return ftell(wth->fh) + 1; + } else { + r_level = 0; + } + if (byte == ascend_w1magic[w1_level]) { + w1_level++; + if (w1_level >= ASCEND_W1_SIZE) { + date_off = ftell(wth->fh) - ASCEND_W1_SIZE + 1; + } + } else { + w1_level = 0; + } + if (byte == ascend_w2magic[w2_level]) { + w2_level++; + if (w2_level >= ASCEND_W2_SIZE && date_off) { + fseek(wth->fh, date_off - 1, SEEK_SET); + return date_off; } } else { - x_level = r_level = e_level = 0; + w2_level = 0; } bytes_read++; } |