From f22c2ee3cd6757695e70515980fbafdfca649d75 Mon Sep 17 00:00:00 2001 From: gram Date: Sun, 31 Oct 1999 17:46:11 +0000 Subject: [PATCH] Add a module to wiretap to be able to read trace files from Toshiba's line of ISDN routers. Much like the ascend reader, this module reads an ASCII hex dump of trace data. Rearranged the order in which wiretap tries trace files, to keep the ASCII-readers (ascend and toshiba) at the end, and put the binary-readers (everything else) at the front of the list. If a telnet session of and ascend trace or toshiba trace were captured near the beginning of another trace, wiretap might think the trace was ascend or toshiba if it tried that module first. Fixed the way wtap_seek_read() selects functions to call. It was using the encap type instead of the file type. We got lucky because WTAP_ENCAP_ASCEND == WTAP_FILE_ASCEND git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@952 f5534014-38df-0310-8fa8-9805f1628bb7 --- README | 29 +++- file.c | 4 +- wiretap/AUTHORS | 15 +- wiretap/Makefile.am | 4 +- wiretap/README | 21 ++- wiretap/file.c | 21 ++- wiretap/file.h | 4 +- wiretap/toshiba.c | 410 ++++++++++++++++++++++++++++++++++++++++++++ wiretap/toshiba.h | 25 +++ wiretap/wtap.c | 19 +- wiretap/wtap.h | 6 +- 11 files changed, 526 insertions(+), 32 deletions(-) create mode 100644 wiretap/toshiba.c create mode 100644 wiretap/toshiba.h diff --git a/README b/README index a492e34c76..99c376d270 100644 --- a/README +++ b/README @@ -73,9 +73,10 @@ its infancy. However, wiretap is used in ethereal for its ability to read multiple file types. You can read the following file formats, and create display filters for them as well: -libpcap, Sniffer (uncompresed), NetXray, Sniffer Pro, snoop, -Shomiti, LANalyzer, Network Monitor, iptrace 2.0 (AIX), RADCOM's -WAN/LAN Analyzer, Lucent/Ascend access products, and HP-UX's nettl. +libpcap (tcpdump -w), Sniffer (uncompressed), NetXray, Sniffer Pro, +snoop, Shomiti, LANalyzer, Network Monitor, AIX's iptrace 2.0, +RADCOM's WAN/LAN Analyzer, Lucent/Ascend access products, HP-UX's nettl, +and Toshiba's ISDN routers. Although Ethereal can read AIX iptrace files, the documentation on AIX's iptrace packet-trace command is sparse. The 'iptrace' command @@ -103,9 +104,25 @@ the following pages: "wdd" on the Pipeline series: http://aos.ascend.com/aos:/gennavviewer.html?doc_id=0900253d80006877 -To use these commands in conjunction with Ethereal, you must capture the -trace output to a file on disk. An easy way of doing this under Unix is -to run "telnet | tee ". +Ethereal can also read dump trace output from the Toshiba "Compact Router" +line of ISDN routers (TR-600 and TR-650). You can telnet to the router +and start a dump session with "snoop dump". + +To use the Lucent/Ascend and Toshiba traces with Ethereal, you must capture +the trace output to a file on disk. The trace is happening inside the router +and the router has no way of saving the trace to a file for you. +An easy way of doing this under Unix is to run "telnet | tee ". +Or, if your system has the "script" command installed, you can save +a shell session, including telnet to a file. For example, to a file named +tracefile.out: + +$ script tracefile.out +Script started on +$ telnet router +..... do your trace, then exit from the router's telnet session. +$ exit +Script done on + IPv6 diff --git a/file.c b/file.c index 7b36ea45a4..3c9b8588cf 100644 --- a/file.c +++ b/file.c @@ -1,7 +1,7 @@ /* file.c * File I/O routines * - * $Id: file.c,v 1.115 1999/10/29 01:04:17 guy Exp $ + * $Id: file.c,v 1.116 1999/10/31 17:45:46 gram Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs @@ -1086,7 +1086,7 @@ colorize_packets(capture_file *cf) cf->count++; - wtap_seek_read (cf-> cd_t, cf->fh, fd->file_off, cf->pd, fd->cap_len); + wtap_seek_read (cf->cd_t, cf->fh, fd->file_off, cf->pd, fd->cap_len); add_packet_to_packet_list(fd, cf, cf->pd); } diff --git a/wiretap/AUTHORS b/wiretap/AUTHORS index 27b3d0cd39..22ae4f0832 100644 --- a/wiretap/AUTHORS +++ b/wiretap/AUTHORS @@ -1,9 +1,6 @@ -Original Author --------- ------ -Gilbert Ramirez Jr. - -Contributors ------------- -Guy Harris -Olivier Abad -Gerald Combs +Authors +------- +Gilbert Ramirez Jr. +Guy Harris +Olivier Abad +Gerald Combs diff --git a/wiretap/Makefile.am b/wiretap/Makefile.am index 37a628408e..ae80144818 100644 --- a/wiretap/Makefile.am +++ b/wiretap/Makefile.am @@ -1,7 +1,7 @@ # Makefile.am # Automake file for Wiretap # -# $Id: Makefile.am,v 1.23 1999/10/18 01:51:32 guy Exp $ +# $Id: Makefile.am,v 1.24 1999/10/31 17:46:04 gram Exp $ # # Ethereal - Network traffic analyzer # By Gerald Combs @@ -58,6 +58,8 @@ libwiretap_a_SOURCES = \ radcom.h \ snoop.c \ snoop.h \ + toshiba.c \ + toshiba.h \ wtap.c \ wtap.h diff --git a/wiretap/README b/wiretap/README index 4ff75b91d4..2717c092bc 100644 --- a/wiretap/README +++ b/wiretap/README @@ -1,4 +1,4 @@ -$Id: README,v 1.16 1999/08/20 07:55:49 guy Exp $ +$Id: README,v 1.17 1999/10/31 17:46:05 gram Exp $ Wiretap is a library that is being developed as a future replacement for libpcap, the current standard Unix library for packet capturing. Libpcap is @@ -96,5 +96,22 @@ RADCOM WAN/LAN Analyzers Olivier Abad has added code to read Ethernet and LAPB captures from RADCOM WAN/LAN Analyzers (see http://www.radcom-inc.com/). -Gilbert Ramirez +Lucent/Ascend access products +----------------------------- +Gerald + +HP-UX nettl +----------- +Olivier + +Toshiba ISDN Router +------------------- +An under-documented command that the router supports in a telnet session is "snoop". +If you give it the "dump" option, you'll get a hex dump of all packets across the +router (except of your own telnet session -- good thinking Toshiba!). You can +select a certain channel to sniff (LAN, B1, B2, D), but the default is all channels. +You save this hex dump to disk with 'script' or by 'telnet | tee'. Wiretap will +read the ASCII hex dump and convert it to binary data. + +Gilbert Ramirez Guy Harris diff --git a/wiretap/file.c b/wiretap/file.c index dc95eec2a4..742cddcdce 100644 --- a/wiretap/file.c +++ b/wiretap/file.c @@ -1,6 +1,6 @@ /* file.c * - * $Id: file.c,v 1.26 1999/10/18 01:51:34 guy Exp $ + * $Id: file.c,v 1.27 1999/10/31 17:46:06 gram Exp $ * * Wiretap Library * Copyright (c) 1998 by Gilbert Ramirez @@ -42,6 +42,7 @@ #include "iptrace.h" #include "netmon.h" #include "netxray.h" +#include "toshiba.h" /* The open_file_* routines should return: * @@ -58,9 +59,17 @@ * declare a "const" array of pointers to functions; putting "const" * right after "static" isn't the right answer, at least according * to GCC, which whines if I do that. + * + * Put the trace files that are merely saved telnet-sessions last, since it's + * possible that you could have captured someone a router telnet-session + * using another tool. So, a libpcap trace of an toshiba "snoop" session + * should be discovered as a libpcap file, not a toshiba file. */ static int (*open_routines[])(wtap *, int *) = { + /* Files that have magic bytes in fixed locations. These + * are easy to identify. + */ libpcap_open, lanalyzer_open, ngsniffer_open, @@ -69,8 +78,14 @@ static int (*open_routines[])(wtap *, int *) = { netmon_open, netxray_open, radcom_open, + nettl_open, + + /* Files whose magic headers are in text *somewhere* in the + * file (usually because the trace is just a saved copy of + * the telnet session). + */ ascend_open, - nettl_open + toshiba_open, }; int wtap_def_seek_read (FILE *fh, int seek_off, guint8 *pd, int len) @@ -130,6 +145,8 @@ wtap* wtap_open_offline(const char *filename, int *err) case -1: /* I/O error - give up */ + /* XXX - why pass err to open_routines[i]() if err is + * overwritten here? */ *err = errno; file_close(wth->fh); free(wth); diff --git a/wiretap/file.h b/wiretap/file.h index d30592f3fb..035970dbf4 100644 --- a/wiretap/file.h +++ b/wiretap/file.h @@ -1,6 +1,6 @@ /* file.h * - * $Id: file.h,v 1.4 1999/10/05 07:06:05 guy Exp $ + * $Id: file.h,v 1.5 1999/10/31 17:46:07 gram Exp $ * * Wiretap Library * Copyright (c) 1998 by Gilbert Ramirez @@ -33,6 +33,7 @@ #define file_close gzclose #define file_tell gztell #define file_getc gzgetc +#define file_gets(buf, len, file) gzgets((file), (buf), (len)) extern int file_error(void *fh); #else /* No zLib */ @@ -45,6 +46,7 @@ extern int file_error(void *fh); extern int file_error(FILE *fh); #define file_tell ftell #define file_getc fgetc +#define file_gets fgets #endif /* HAVE_LIBZ */ #endif /* __FILE_H__ */ diff --git a/wiretap/toshiba.c b/wiretap/toshiba.c new file mode 100644 index 0000000000..8b977f429c --- /dev/null +++ b/wiretap/toshiba.c @@ -0,0 +1,410 @@ +/* toshiba.c + * + * $Id: toshiba.c,v 1.1 1999/10/31 17:46:08 gram Exp $ + * + * Wiretap Library + * Copyright (c) 1998 by Gilbert Ramirez + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif +#include "wtap.h" +#include "buffer.h" +#include "toshiba.h" +#include "file.h" + +#include +#include +#include + +/* This module reads the output of the 'snoop' command in the Toshiba + * TR-600 and TR-650 "Compact" ISDN Routers. You can telnet to the + * router and run 'snoop' on the different channels, and at different + * detail levels. Be sure to choose 'dump' to get the hex dump. + * The 'snoop' command has nothing to do with the Solaris 'snoop' + * command, except that they both capture packets. + */ + +/* + Example 'snoop' output data: + + +Script started on Thu Sep 9 21:48:49 1999 +]0;gram@nirvana:/tmp$ telnet 10.0.0.254 +Trying 10.0.0.254... +Connected to 10.0.0.254. +Escape character is '^]'. + + +TR-600(tr600) System Console + +Login:admin +Password:******* +*--------------------------------------------------------* +| T O S H I B A T R - 6 0 0 | +| < Compact Router > | +| V1.02.02 | +| | +| (C) Copyright TOSHIBA Corp. 1997 All rights reserved. | +*--------------------------------------------------------* + +tr600>snoop dump b1 + Trace start?(on/off/dump/dtl)->dump + IP Address?->b1 +B1 Port Filetering +Trace start(Dump Mode)... + +tr600>[No.1] 00:00:09.14 B1:1 Tx 207.193.26.136->151.164.1.8 DNS SPORT=1028 LEN=38 CHKSUM=4FD4 ID=2390 Query RD QCNT=1 pow.zing.org? +OFFSET 0001-0203-0405-0607-0809-0A0B-0C0D-0E0F 0123456789ABCDEF LEN=67 +0000 : FF03 003D C000 0008 2145 0000 3A12 6500 ...=....!E..:.e. +0010 : 003F 11E6 58CF C11A 8897 A401 0804 0400 .?..X........... +0020 : 3500 264F D409 5601 0000 0100 0000 0000 5.&O..V......... +0030 : 0003 706F 7704 7A69 6E67 036F 7267 0000 ..pow.zing.org.. +0040 : 0100 01 ... + +[No.2] 00:00:09.25 B1:1 Rx 151.164.1.8->207.193.26.136 DNS DPORT=1028 LEN=193 CHKSUM=3E06 ID=2390 Answer RD RA QCNT=1 pow.zing.org? ANCNT=1 pow.zing.org=206.57.36.90 TTL=2652 +OFFSET 0001-0203-0405-0607-0809-0A0B-0C0D-0E0F 0123456789ABCDEF LEN=222 +0000 : FF03 003D C000 0013 2145 0000 D590 9340 ...=....!E.....@ +0010 : 00F7 116F 8E97 A401 08CF C11A 8800 3504 ...o..........5. +0020 : 0400 C13E 0609 5681 8000 0100 0100 0300 ...>..V......... +0030 : 0303 706F 7704 7A69 6E67 036F 7267 0000 ..pow.zing.org.. +0040 : 0100 01C0 0C00 0100 0100 000A 5C00 04CE ............\... +0050 : 3924 5A04 5A49 4E47 036F 7267 0000 0200 9$Z.ZING.org.... +0060 : 0100 016F 5B00 0D03 4841 4E03 5449 5703 ...o[...HAN.TIW. +0070 : 4E45 5400 C02E 0002 0001 0001 6F5B 0006 NET.........o[.. +0080 : 034E 5331 C02E C02E 0002 0001 0001 6F5B .NS1..........o[ +0090 : 001C 0854 414C 4945 5349 4E0D 434F 4E46 ...TALIESIN.CONF +00A0 : 4142 554C 4154 494F 4E03 434F 4D00 C042 ABULATION.COM..B +00B0 : 0001 0001 0001 51EC 0004 CE39 2406 C05B ......Q....9$..[ +00C0 : 0001 0001 0001 6F5B 0004 CE39 245A C06D ......o[...9$Z.m +00D0 : 0001 0001 0001 4521 0004 187C 1F01 ......E!...|.. + + */ + +/* Magic text to check for toshiba-ness of file */ +static const char toshiba_hdr_magic[] = +{ 'T', ' ', 'O', ' ', 'S', ' ', 'H', ' ', 'I', ' ', 'B', ' ', 'A' }; +#define TOSHIBA_HDR_MAGIC_SIZE (sizeof toshiba_hdr_magic / sizeof toshiba_hdr_magic[0]) + +/* Magic text for start of packet */ +static const char toshiba_rec_magic[] = { '[', 'N', 'o', '.' }; +#define TOSHIBA_REC_MAGIC_SIZE (sizeof toshiba_rec_magic / sizeof toshiba_rec_magic[0]) + +static int toshiba_read(wtap *wth, int *err); +static gboolean parse_single_hex_dump_line(char* rec, guint8 *buf, int byte_offset); +static int parse_toshiba_hex_dump(FILE *fh, int pkt_len, guint8* buf, int *err); +static int parse_toshiba_rec_hdr(wtap *wth, FILE *fh, int *err); +static int parse_toshiba(FILE *fh, guint8 *pd, int len); + +/* Seeks to the beginning of the next packet, and returns the + byte offset. Returns -1 on failure. */ +/* XXX - Handle I/O errors. */ +static int toshiba_seek_next_packet(wtap *wth) +{ + int byte; + int level = 0; + + while ((byte = file_getc(wth->fh)) != EOF) { + if (byte == toshiba_rec_magic[level]) { + level++; + if (level >= TOSHIBA_REC_MAGIC_SIZE) { + file_seek(wth->fh, -(TOSHIBA_REC_MAGIC_SIZE), SEEK_CUR); + return file_tell(wth->fh) + 1; + } + } else { + level = 0; + } + } + return -1; +} + +#define TOSHIBA_HEADER_LINES_TO_CHECK 200 +#define TOSHIBA_LINE_LENGTH 240 + +/* Look through the first part of a file to see if this is + * a Toshiba trace file. + * + * Returns TRUE if it is, FALSE if it isn't. + */ +static gboolean toshiba_check_file_type(wtap *wth) +{ + char buf[TOSHIBA_LINE_LENGTH]; + int reclen, i, line, byte, level; + + buf[TOSHIBA_LINE_LENGTH-1] = 0; + + for (line = 0; line < TOSHIBA_HEADER_LINES_TO_CHECK; line++) { + if (file_gets(buf, TOSHIBA_LINE_LENGTH, wth->fh) >= 0) { + + reclen = strlen(buf); + if (reclen < TOSHIBA_HDR_MAGIC_SIZE) { + continue; + } + + level = 0; + for (i = 0; i < reclen; i++) { + byte = buf[i]; + if (byte == toshiba_hdr_magic[level]) { + level++; + if (level >= TOSHIBA_HDR_MAGIC_SIZE) { + return TRUE; + } + } + else { + level = 0; + } + } + } + else { + return FALSE; + } + } + return FALSE; +} + + +/* XXX - return -1 on I/O error and actually do something with 'err'. */ +int toshiba_open(wtap *wth, int *err) +{ + /* Reset file position and look for Toshiba header */ + file_seek(wth->fh, 0, SEEK_SET); + + if (!toshiba_check_file_type(wth)) { + return 0; + } + + wth->data_offset = 0; + wth->file_encap = WTAP_ENCAP_PER_PACKET; + wth->file_type = WTAP_FILE_TOSHIBA; + wth->snapshot_length = 16384; /* just guessing */ + wth->subtype_read = toshiba_read; + + return 1; +} + +/* Find the next packet and parse it; called from wtap_loop(). */ +static int toshiba_read(wtap *wth, int *err) +{ + int offset = 0; + guint8 *buf; + int pkt_len; + + /* Find the next packet */ + offset = toshiba_seek_next_packet(wth); + if (offset < 1) { + return 0; + } + + /* Parse the header */ + pkt_len = parse_toshiba_rec_hdr(wth, wth->fh, err); + + /* Make sure we have enough room for the packet */ + buffer_assure_space(wth->frame_buffer, wth->snapshot_length); + buf = buffer_start_ptr(wth->frame_buffer); + + /* Convert the ASCII hex dump to binary data */ + parse_toshiba_hex_dump(wth->fh, pkt_len, buf, err); + + wth->data_offset = offset; + return offset; +} + +/* Used to read packets in random-access fashion */ +int +toshiba_seek_read (FILE *fh, int seek_off, guint8 *pd, int len) +{ + file_seek(fh, seek_off - 1, SEEK_SET); + return parse_toshiba(fh, pd, len); +} + +/* Used to read packets in random-access fashion */ +static int +parse_toshiba(FILE *fh, guint8 *pd, int len) +{ + int pkt_len; + int err; + + pkt_len = parse_toshiba_rec_hdr(NULL, fh, &err); + + if (pkt_len != len) { + return -1; + } + + parse_toshiba_hex_dump(fh, pkt_len, pd, &err); + + return 0; +} + +/* Parses a packet record header. */ +static int +parse_toshiba_rec_hdr(wtap *wth, FILE *fh, int *err) +{ + char line[TOSHIBA_LINE_LENGTH]; + int num_items_scanned; + int pkt_len, pktnum, hr, min, sec, csec; + char channel[10]; + + /* Our file pointer should be on the line containing the + * summary information for a packet. Read in that line and + * extract the useful information + */ + if (file_gets(line, TOSHIBA_LINE_LENGTH, fh) < 0) { + *err = file_error(fh); + if (*err == 0) { + *err = WTAP_ERR_SHORT_READ; + } + return -1; + } + + num_items_scanned = sscanf(line, "[No.%d] %d:%d:%d.%d %s:", + &pktnum, &hr, &min, &sec, &csec, channel); + + if (num_items_scanned != 6) { + *err = WTAP_ERR_BAD_RECORD; + return -1; + } + + /* The next line contains mostly junk, but it does contain the + * packet length. */ + if (file_gets(line, TOSHIBA_LINE_LENGTH, fh) < 0) { + *err = file_error(fh); + if (*err == 0) { + *err = WTAP_ERR_SHORT_READ; + } + return -1; + } + + num_items_scanned = sscanf(line+64, "LEN=%d", &pkt_len); + if (num_items_scanned != 1) { + *err = WTAP_ERR_BAD_RECORD; + return -1; + } + + if (wth) { + wth->phdr.ts.tv_sec = 0; + wth->phdr.ts.tv_usec = 0; + wth->phdr.caplen = pkt_len; + wth->phdr.len = pkt_len; + switch (channel[0]) { + case 'B': + wth->phdr.pkt_encap = WTAP_ENCAP_PPP; + break; + + case 'D': + /*wth->phdr.pkt_encap = WTAP_ENCAP_LAPD;*/ + /*wth->phdr.pkt_encap = WTAP_ENCAP_ISDN;*/ + wth->phdr.pkt_encap = WTAP_ENCAP_UNKNOWN; + break; + + default: + wth->phdr.pkt_encap = WTAP_ENCAP_ETHERNET; + break; + } + } + return pkt_len; +} + +/* Converts ASCII hex dump to binary data */ +static int +parse_toshiba_hex_dump(FILE *fh, int pkt_len, guint8* buf, int *err) +{ + char line[TOSHIBA_LINE_LENGTH]; + int i, hex_lines; + + /* Calculate the number of hex dump lines, each + * containing 16 bytes of data */ + hex_lines = pkt_len / 16 + ((pkt_len % 16) ? 1 : 0); + + for (i = 0; i < hex_lines; i++) { + if (file_gets(line, TOSHIBA_LINE_LENGTH, fh) < 0) { + *err = file_error(fh); + if (*err == 0) { + *err = WTAP_ERR_SHORT_READ; + } + return -1; + } + if (!parse_single_hex_dump_line(line, buf, i * 16)) { + *err = WTAP_ERR_BAD_RECORD; + return -1; + } + } + return 0; +} + +/* + 1 2 3 4 +0123456789012345678901234567890123456789012345 +0000 : FF03 003D C000 0008 2145 0000 3A12 6500 ...=....!E..:.e. +0010 : 003F 11E6 58CF C11A 8897 A401 0804 0400 .?..X........... +0020 : 0100 01 ... +*/ + +#define START_POS 7 +#define HEX_LENGTH ((8 * 4) + 7) /* eight clumps of 4 bytes with 7 inner spaces */ + +/* Take a string representing one line from a hex dump and converts the + * text to binary data. We check the printed offset with the offset + * we are passed to validate the record. We place the bytes in the buffer + * at the specified offset. + * + * In the process, we're going to write all over the string. + * + * Returns TRUE if good hex dump, FALSE if bad. + */ +static gboolean +parse_single_hex_dump_line(char* rec, guint8 *buf, int byte_offset) { + + int pos, i; + char *s; + unsigned long value; + guint16 word_value; + + /* Get the byte_offset directly from the record */ + rec[4] = '\0'; + s = rec; + value = strtoul(s, NULL, 16); + + if (value != byte_offset) { + return FALSE; + } + + /* Go through the substring representing the values and: + * 1. Replace any spaces with '0's + * 2. Place \0's every 5 bytes (to terminate the string) + * + * Then read the eight sets of hex bytes + */ + + for (pos = START_POS; pos < START_POS + HEX_LENGTH; pos++) { + if (rec[pos] == ' ') { + rec[pos] = '0'; + } + } + + pos = START_POS; + for (i = 0; i < 8; i++) { + rec[pos+4] = '\0'; + + word_value = (guint16) strtoul(&rec[pos], NULL, 16); + buf[byte_offset + i * 2 + 0] = (guint8) (word_value >> 8); + buf[byte_offset + i * 2 + 1] = (guint8) (word_value & 0x00ff); + pos += 5; + } + + return TRUE; +} diff --git a/wiretap/toshiba.h b/wiretap/toshiba.h new file mode 100644 index 0000000000..6d4c225808 --- /dev/null +++ b/wiretap/toshiba.h @@ -0,0 +1,25 @@ +/* toshiba.h + * + * $Id: toshiba.h,v 1.1 1999/10/31 17:46:10 gram Exp $ + * + * Wiretap Library + * Copyright (c) 1998 by Gilbert Ramirez + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + */ + +int toshiba_open(wtap *wth, int *err); +int toshiba_seek_read (FILE *fh, int seek_off, guint8 *pd, int len); diff --git a/wiretap/wtap.c b/wiretap/wtap.c index 6f4f67b849..fd0de940c0 100644 --- a/wiretap/wtap.c +++ b/wiretap/wtap.c @@ -1,6 +1,6 @@ /* wtap.c * - * $Id: wtap.c,v 1.26 1999/10/18 01:51:32 guy Exp $ + * $Id: wtap.c,v 1.27 1999/10/31 17:46:10 gram Exp $ * * Wiretap Library * Copyright (c) 1998 by Gilbert Ramirez @@ -30,6 +30,7 @@ #include "file.h" #include "buffer.h" #include "ascend.h" +#include "toshiba.h" FILE* wtap_file(wtap *wth) { @@ -75,7 +76,7 @@ const char *wtap_file_type_string(wtap *wth) return "snoop"; case WTAP_FILE_IPTRACE: - return "iptrace"; + return "AIX iptrace"; case WTAP_FILE_NETMON_1_x: return "Microsoft Network Monitor 1.x"; @@ -99,7 +100,10 @@ const char *wtap_file_type_string(wtap *wth) return "Lucent/Ascend access server trace"; case WTAP_FILE_NETTL: - return "HP-UX nettl traces"; + return "HP-UX nettl trace"; + + case WTAP_FILE_TOSHIBA: + return "Toshiba Compact ISDN Router snoop trace"; default: g_error("Unknown capture file type %d", wth->file_type); @@ -215,13 +219,16 @@ int wtap_loop(wtap *wth, int count, wtap_handler callback, u_char* user, return TRUE; /* success */ } -int wtap_seek_read(int encaps, FILE *fh, int seek_off, guint8 *pd, int len) +int wtap_seek_read(int file_type, FILE *fh, int seek_off, guint8 *pd, int len) { - switch (encaps) { + switch (file_type) { - case WTAP_ENCAP_ASCEND: + case WTAP_FILE_ASCEND: return ascend_seek_read(fh, seek_off, pd, len); + case WTAP_FILE_TOSHIBA: + return toshiba_seek_read(fh, seek_off, pd, len); + default: return wtap_def_seek_read(fh, seek_off, pd, len); } diff --git a/wiretap/wtap.h b/wiretap/wtap.h index fbf7fa479e..6f73d558ea 100644 --- a/wiretap/wtap.h +++ b/wiretap/wtap.h @@ -1,6 +1,6 @@ /* wtap.h * - * $Id: wtap.h,v 1.45 1999/10/19 04:41:52 guy Exp $ + * $Id: wtap.h,v 1.46 1999/10/31 17:46:11 gram Exp $ * * Wiretap Library * Copyright (c) 1998 by Gilbert Ramirez @@ -113,6 +113,7 @@ #define WTAP_FILE_RADCOM 13 #define WTAP_FILE_ASCEND 14 #define WTAP_FILE_NETTL 15 +#define WTAP_FILE_TOSHIBA 16 /* * Maximum packet size we'll support. @@ -291,7 +292,6 @@ typedef void (*wtap_handler)(u_char*, const struct wtap_pkthdr*, int, const u_char *); struct wtap; -struct bpf_instruction; struct Buffer; typedef int (*subtype_read_func)(struct wtap*, int*); @@ -357,7 +357,7 @@ int wtap_file_encap(wtap *wth); const char *wtap_file_type_string(wtap *wth); const char *wtap_strerror(int err); void wtap_close(wtap *wth); -int wtap_seek_read (int encaps, FILE *fh, int seek_off, guint8 *pd, int len); +int wtap_seek_read (int file_type, FILE *fh, int seek_off, guint8 *pd, int len); int wtap_def_seek_read (FILE *fh, int seek_off, guint8 *pd, int len); wtap_dumper* wtap_dump_open(const char *filename, int filetype, int encap, -- 2.34.1