1999-10-31 17:46:11 +00:00
|
|
|
|
/* toshiba.c
|
|
|
|
|
*
|
|
|
|
|
* Wiretap Library
|
2001-11-13 23:55:44 +00:00
|
|
|
|
* Copyright (c) 1998 by Gilbert Ramirez <gram@alumni.rice.edu>
|
2002-08-28 20:30:45 +00:00
|
|
|
|
*
|
2018-02-07 11:26:45 +00:00
|
|
|
|
* SPDX-License-Identifier: GPL-2.0-or-later
|
1999-10-31 17:46:11 +00:00
|
|
|
|
*/
|
2002-03-04 00:25:35 +00:00
|
|
|
|
|
1999-10-31 17:46:11 +00:00
|
|
|
|
#include "config.h"
|
2000-05-19 23:07:04 +00:00
|
|
|
|
#include "wtap-int.h"
|
1999-10-31 17:46:11 +00:00
|
|
|
|
#include "toshiba.h"
|
2000-01-13 07:09:20 +00:00
|
|
|
|
#include "file_wrappers.h"
|
1999-10-31 17:46:11 +00:00
|
|
|
|
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
|
|
/* 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
|
2000-03-04 14:22:29 +00:00
|
|
|
|
* detail levels. Be sure to choose the 'dump' level to get the hex dump.
|
1999-10-31 17:46:11 +00:00
|
|
|
|
* 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
|
2002-08-28 20:30:45 +00:00
|
|
|
|
]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!...|..
|
|
|
|
|
|
1999-10-31 17:46:11 +00:00
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/* 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])
|
|
|
|
|
|
2019-04-05 01:56:27 +00:00
|
|
|
|
static gboolean toshiba_read(wtap *wth, wtap_rec *rec, Buffer *buf,
|
|
|
|
|
int *err, gchar **err_info, gint64 *data_offset);
|
2014-05-23 10:50:02 +00:00
|
|
|
|
static gboolean toshiba_seek_read(wtap *wth, gint64 seek_off,
|
2018-02-09 00:19:12 +00:00
|
|
|
|
wtap_rec *rec, Buffer *buf, int *err, gchar **err_info);
|
2002-03-05 08:40:27 +00:00
|
|
|
|
static gboolean parse_single_hex_dump_line(char* rec, guint8 *buf,
|
|
|
|
|
guint byte_offset);
|
2018-02-09 00:19:12 +00:00
|
|
|
|
static gboolean parse_toshiba_packet(FILE_T fh, wtap_rec *rec,
|
2013-06-17 21:18:47 +00:00
|
|
|
|
Buffer *buf, int *err, gchar **err_info);
|
1999-10-31 17:46:11 +00:00
|
|
|
|
|
wiretap: register most built-in file types from its module.
Remove most of the built-in file types from the table in
wiretap/file_access.c and, instead, have the file types register
themselves, using wtap_register_file_type_subtypes().
This reduces the source code changes needed to add a new file type from
three (add the handler, add the file type to the table in file_access.c,
add a #define for the file type in wiretap/wtap.h) to one (add the
handler). (It also requires adding the handler's source file to
wiretap/CMakeLists.txt, but that's required in both cases.)
A few remain because the WTAP_FILE_TYPE_SUBTYPE_ #define is used
elsewhere; that needs to be fixed.
Fix the wiretap/CMakefile.txt file to scan k12text.l, as that now
contains a registration routine. In the process, avoid scanning files
that don't implement a file type and won't ever have a registration
routine.
Add a Lua routine to fetch the total number of file types; we use that
in some code to construct the wtap_filetypes table, which we need to do
in order to continue to have all the values that used to come from the
WTAP_FILE_TYPE_SUBTYPE_ types.
While we're at it, add modelines to a file that lacked them.
2021-02-14 08:34:10 +00:00
|
|
|
|
static int toshiba_file_type_subtype = -1;
|
|
|
|
|
|
|
|
|
|
void register_toshiba(void);
|
|
|
|
|
|
1999-10-31 17:46:11 +00:00
|
|
|
|
/* Seeks to the beginning of the next packet, and returns the
|
2011-04-21 09:41:52 +00:00
|
|
|
|
byte offset. Returns -1 on failure, and sets "*err" to the error
|
|
|
|
|
and "*err_info" to null or an additional error string. */
|
2014-05-09 05:18:49 +00:00
|
|
|
|
static gint64 toshiba_seek_next_packet(wtap *wth, int *err, gchar **err_info)
|
1999-10-31 17:46:11 +00:00
|
|
|
|
{
|
2015-01-02 00:45:22 +00:00
|
|
|
|
int byte;
|
|
|
|
|
guint level = 0;
|
|
|
|
|
gint64 cur_off;
|
|
|
|
|
|
|
|
|
|
while ((byte = file_getc(wth->fh)) != EOF) {
|
|
|
|
|
if (byte == toshiba_rec_magic[level]) {
|
|
|
|
|
level++;
|
|
|
|
|
if (level >= TOSHIBA_REC_MAGIC_SIZE) {
|
|
|
|
|
/* note: we're leaving file pointer right after the magic characters */
|
|
|
|
|
cur_off = file_tell(wth->fh);
|
|
|
|
|
if (cur_off == -1) {
|
|
|
|
|
/* Error. */
|
|
|
|
|
*err = file_error(wth->fh, err_info);
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
return cur_off + 1;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
level = 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
/* EOF or error. */
|
|
|
|
|
*err = file_error(wth->fh, err_info);
|
|
|
|
|
return -1;
|
1999-10-31 17:46:11 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#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.
|
|
|
|
|
*
|
2002-03-04 00:25:35 +00:00
|
|
|
|
* Returns TRUE if it is, FALSE if it isn't or if we get an I/O error;
|
2011-04-21 09:41:52 +00:00
|
|
|
|
* if we get an I/O error, "*err" will be set to a non-zero value and
|
|
|
|
|
* "*err_info" will be set to null or an additional error string.
|
1999-10-31 17:46:11 +00:00
|
|
|
|
*/
|
2014-05-09 05:18:49 +00:00
|
|
|
|
static gboolean toshiba_check_file_type(wtap *wth, int *err, gchar **err_info)
|
1999-10-31 17:46:11 +00:00
|
|
|
|
{
|
|
|
|
|
char buf[TOSHIBA_LINE_LENGTH];
|
2001-10-25 20:29:24 +00:00
|
|
|
|
guint i, reclen, level, line;
|
2001-12-08 07:46:54 +00:00
|
|
|
|
char byte;
|
1999-10-31 17:46:11 +00:00
|
|
|
|
|
|
|
|
|
buf[TOSHIBA_LINE_LENGTH-1] = 0;
|
|
|
|
|
|
|
|
|
|
for (line = 0; line < TOSHIBA_HEADER_LINES_TO_CHECK; line++) {
|
2014-05-09 05:18:49 +00:00
|
|
|
|
if (file_gets(buf, TOSHIBA_LINE_LENGTH, wth->fh) == NULL) {
|
Do not call wtap_file_read_unknown_bytes() or
wtap_file_read_expected_bytes() from an open routine - open routines are
supposed to return -1 on error, 0 if the file doesn't appear to be a
file of the specified type, or 1 if the file does appear to be a file of
the specified type, but those macros will cause the caller to return
FALSE on errors (so that, even if there's an I/O error, it reports "the
file isn't a file of the specified type" rather than "we got an error
trying to read the file").
When doing reads in an open routine before we've concluded that the file
is probably of the right type, return 0, rather than -1, if we get
WTAP_ERR_SHORT_READ - if we don't have enough data to check whether a
file is of a given type, we should keep trying other types, not give up.
For reads done *after* we've concluded the file is probably of the right
type, if a read doesn't return the number of bytes we asked for, but
returns an error of 0, return WTAP_ERR_SHORT_READ - the file is
apparently cut short.
For NetMon and NetXRay/Windows Sniffer files, use a #define for the
magic number size, and use that for both magic numbers.
svn path=/trunk/; revision=46803
2012-12-27 12:19:25 +00:00
|
|
|
|
/* EOF or error. */
|
2014-05-09 05:18:49 +00:00
|
|
|
|
*err = file_error(wth->fh, err_info);
|
Do not call wtap_file_read_unknown_bytes() or
wtap_file_read_expected_bytes() from an open routine - open routines are
supposed to return -1 on error, 0 if the file doesn't appear to be a
file of the specified type, or 1 if the file does appear to be a file of
the specified type, but those macros will cause the caller to return
FALSE on errors (so that, even if there's an I/O error, it reports "the
file isn't a file of the specified type" rather than "we got an error
trying to read the file").
When doing reads in an open routine before we've concluded that the file
is probably of the right type, return 0, rather than -1, if we get
WTAP_ERR_SHORT_READ - if we don't have enough data to check whether a
file is of a given type, we should keep trying other types, not give up.
For reads done *after* we've concluded the file is probably of the right
type, if a read doesn't return the number of bytes we asked for, but
returns an error of 0, return WTAP_ERR_SHORT_READ - the file is
apparently cut short.
For NetMon and NetXRay/Windows Sniffer files, use a #define for the
magic number size, and use that for both magic numbers.
svn path=/trunk/; revision=46803
2012-12-27 12:19:25 +00:00
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
1999-10-31 17:46:11 +00:00
|
|
|
|
|
Do not call wtap_file_read_unknown_bytes() or
wtap_file_read_expected_bytes() from an open routine - open routines are
supposed to return -1 on error, 0 if the file doesn't appear to be a
file of the specified type, or 1 if the file does appear to be a file of
the specified type, but those macros will cause the caller to return
FALSE on errors (so that, even if there's an I/O error, it reports "the
file isn't a file of the specified type" rather than "we got an error
trying to read the file").
When doing reads in an open routine before we've concluded that the file
is probably of the right type, return 0, rather than -1, if we get
WTAP_ERR_SHORT_READ - if we don't have enough data to check whether a
file is of a given type, we should keep trying other types, not give up.
For reads done *after* we've concluded the file is probably of the right
type, if a read doesn't return the number of bytes we asked for, but
returns an error of 0, return WTAP_ERR_SHORT_READ - the file is
apparently cut short.
For NetMon and NetXRay/Windows Sniffer files, use a #define for the
magic number size, and use that for both magic numbers.
svn path=/trunk/; revision=46803
2012-12-27 12:19:25 +00:00
|
|
|
|
reclen = (guint) strlen(buf);
|
|
|
|
|
if (reclen < TOSHIBA_HDR_MAGIC_SIZE) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
1999-10-31 17:46:11 +00:00
|
|
|
|
|
Do not call wtap_file_read_unknown_bytes() or
wtap_file_read_expected_bytes() from an open routine - open routines are
supposed to return -1 on error, 0 if the file doesn't appear to be a
file of the specified type, or 1 if the file does appear to be a file of
the specified type, but those macros will cause the caller to return
FALSE on errors (so that, even if there's an I/O error, it reports "the
file isn't a file of the specified type" rather than "we got an error
trying to read the file").
When doing reads in an open routine before we've concluded that the file
is probably of the right type, return 0, rather than -1, if we get
WTAP_ERR_SHORT_READ - if we don't have enough data to check whether a
file is of a given type, we should keep trying other types, not give up.
For reads done *after* we've concluded the file is probably of the right
type, if a read doesn't return the number of bytes we asked for, but
returns an error of 0, return WTAP_ERR_SHORT_READ - the file is
apparently cut short.
For NetMon and NetXRay/Windows Sniffer files, use a #define for the
magic number size, and use that for both magic numbers.
svn path=/trunk/; revision=46803
2012-12-27 12:19:25 +00:00
|
|
|
|
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;
|
1999-10-31 17:46:11 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
Do not call wtap_file_read_unknown_bytes() or
wtap_file_read_expected_bytes() from an open routine - open routines are
supposed to return -1 on error, 0 if the file doesn't appear to be a
file of the specified type, or 1 if the file does appear to be a file of
the specified type, but those macros will cause the caller to return
FALSE on errors (so that, even if there's an I/O error, it reports "the
file isn't a file of the specified type" rather than "we got an error
trying to read the file").
When doing reads in an open routine before we've concluded that the file
is probably of the right type, return 0, rather than -1, if we get
WTAP_ERR_SHORT_READ - if we don't have enough data to check whether a
file is of a given type, we should keep trying other types, not give up.
For reads done *after* we've concluded the file is probably of the right
type, if a read doesn't return the number of bytes we asked for, but
returns an error of 0, return WTAP_ERR_SHORT_READ - the file is
apparently cut short.
For NetMon and NetXRay/Windows Sniffer files, use a #define for the
magic number size, and use that for both magic numbers.
svn path=/trunk/; revision=46803
2012-12-27 12:19:25 +00:00
|
|
|
|
else {
|
|
|
|
|
level = 0;
|
|
|
|
|
}
|
1999-10-31 17:46:11 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2002-03-04 00:25:35 +00:00
|
|
|
|
*err = 0;
|
1999-10-31 17:46:11 +00:00
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2014-10-09 23:44:15 +00:00
|
|
|
|
wtap_open_return_val toshiba_open(wtap *wth, int *err, gchar **err_info)
|
1999-10-31 17:46:11 +00:00
|
|
|
|
{
|
2001-03-10 06:33:58 +00:00
|
|
|
|
/* Look for Toshiba header */
|
2014-05-09 05:18:49 +00:00
|
|
|
|
if (!toshiba_check_file_type(wth, err, err_info)) {
|
Do not call wtap_file_read_unknown_bytes() or
wtap_file_read_expected_bytes() from an open routine - open routines are
supposed to return -1 on error, 0 if the file doesn't appear to be a
file of the specified type, or 1 if the file does appear to be a file of
the specified type, but those macros will cause the caller to return
FALSE on errors (so that, even if there's an I/O error, it reports "the
file isn't a file of the specified type" rather than "we got an error
trying to read the file").
When doing reads in an open routine before we've concluded that the file
is probably of the right type, return 0, rather than -1, if we get
WTAP_ERR_SHORT_READ - if we don't have enough data to check whether a
file is of a given type, we should keep trying other types, not give up.
For reads done *after* we've concluded the file is probably of the right
type, if a read doesn't return the number of bytes we asked for, but
returns an error of 0, return WTAP_ERR_SHORT_READ - the file is
apparently cut short.
For NetMon and NetXRay/Windows Sniffer files, use a #define for the
magic number size, and use that for both magic numbers.
svn path=/trunk/; revision=46803
2012-12-27 12:19:25 +00:00
|
|
|
|
if (*err != 0 && *err != WTAP_ERR_SHORT_READ)
|
2014-10-09 23:44:15 +00:00
|
|
|
|
return WTAP_OPEN_ERROR;
|
|
|
|
|
return WTAP_OPEN_NOT_MINE;
|
1999-10-31 17:46:11 +00:00
|
|
|
|
}
|
|
|
|
|
|
2014-05-09 05:18:49 +00:00
|
|
|
|
wth->file_encap = WTAP_ENCAP_PER_PACKET;
|
wiretap: register most built-in file types from its module.
Remove most of the built-in file types from the table in
wiretap/file_access.c and, instead, have the file types register
themselves, using wtap_register_file_type_subtypes().
This reduces the source code changes needed to add a new file type from
three (add the handler, add the file type to the table in file_access.c,
add a #define for the file type in wiretap/wtap.h) to one (add the
handler). (It also requires adding the handler's source file to
wiretap/CMakeLists.txt, but that's required in both cases.)
A few remain because the WTAP_FILE_TYPE_SUBTYPE_ #define is used
elsewhere; that needs to be fixed.
Fix the wiretap/CMakefile.txt file to scan k12text.l, as that now
contains a registration routine. In the process, avoid scanning files
that don't implement a file type and won't ever have a registration
routine.
Add a Lua routine to fetch the total number of file types; we use that
in some code to construct the wtap_filetypes table, which we need to do
in order to continue to have all the values that used to come from the
WTAP_FILE_TYPE_SUBTYPE_ types.
While we're at it, add modelines to a file that lacked them.
2021-02-14 08:34:10 +00:00
|
|
|
|
wth->file_type_subtype = toshiba_file_type_subtype;
|
2014-05-09 05:18:49 +00:00
|
|
|
|
wth->snapshot_length = 0; /* not known */
|
|
|
|
|
wth->subtype_read = toshiba_read;
|
|
|
|
|
wth->subtype_seek_read = toshiba_seek_read;
|
2014-09-28 18:37:06 +00:00
|
|
|
|
wth->file_tsprec = WTAP_TSPREC_CSEC;
|
1999-10-31 17:46:11 +00:00
|
|
|
|
|
2014-10-09 23:44:15 +00:00
|
|
|
|
return WTAP_OPEN_MINE;
|
1999-10-31 17:46:11 +00:00
|
|
|
|
}
|
|
|
|
|
|
2005-04-03 11:00:49 +00:00
|
|
|
|
/* Find the next packet and parse it; called from wtap_read(). */
|
2019-04-05 01:56:27 +00:00
|
|
|
|
static gboolean toshiba_read(wtap *wth, wtap_rec *rec, Buffer *buf,
|
|
|
|
|
int *err, gchar **err_info, gint64 *data_offset)
|
1999-10-31 17:46:11 +00:00
|
|
|
|
{
|
2006-11-05 22:46:44 +00:00
|
|
|
|
gint64 offset;
|
1999-10-31 17:46:11 +00:00
|
|
|
|
|
|
|
|
|
/* Find the next packet */
|
2014-05-09 05:18:49 +00:00
|
|
|
|
offset = toshiba_seek_next_packet(wth, err, err_info);
|
2002-03-04 00:25:35 +00:00
|
|
|
|
if (offset < 1)
|
2014-05-23 10:50:02 +00:00
|
|
|
|
return FALSE;
|
2000-09-07 05:34:23 +00:00
|
|
|
|
*data_offset = offset;
|
2013-06-17 21:18:47 +00:00
|
|
|
|
|
|
|
|
|
/* Parse the packet */
|
2019-04-05 01:56:27 +00:00
|
|
|
|
return parse_toshiba_packet(wth->fh, rec, buf, err, err_info);
|
1999-10-31 17:46:11 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Used to read packets in random-access fashion */
|
2014-05-23 10:50:02 +00:00
|
|
|
|
static gboolean
|
2014-05-09 05:18:49 +00:00
|
|
|
|
toshiba_seek_read(wtap *wth, gint64 seek_off,
|
2018-02-09 00:19:12 +00:00
|
|
|
|
wtap_rec *rec, Buffer *buf,
|
Have the Wiretap open, read, and seek-and-read routines return, in
addition to an error code, an error info string, for
WTAP_ERR_UNSUPPORTED, WTAP_ERR_UNSUPPORTED_ENCAP, and
WTAP_ERR_BAD_RECORD errors. Replace the error messages logged with
"g_message()" for those errors with g_strdup()ed or g_strdup_printf()ed
strings returned as the error info string, and change the callers of
those routines to, for those errors, put the info string into the
printed message or alert box for the error.
Add messages for cases where those errors were returned without printing
an additional message.
Nobody uses the error code from "cf_read()" - "cf_read()" puts up the
alert box itself for failures; get rid of the error code, so it just
returns a success/failure indication.
Rename "file_read_error_message()" to "cf_read_error_message()", as it
handles read errors from Wiretap, and have it take an error info string
as an argument. (That handles a lot of the work of putting the info
string into the error message.)
Make some variables in "ascend-grammar.y" static.
Check the return value of "erf_read_header()" in "erf_seek_read()".
Get rid of an unused #define in "i4btrace.c".
svn path=/trunk/; revision=9852
2004-01-25 21:55:17 +00:00
|
|
|
|
int *err, gchar **err_info)
|
1999-10-31 17:46:11 +00:00
|
|
|
|
{
|
2014-05-09 05:18:49 +00:00
|
|
|
|
if (file_seek(wth->random_fh, seek_off - 1, SEEK_SET, err) == -1)
|
2014-05-23 10:50:02 +00:00
|
|
|
|
return FALSE;
|
2000-05-18 09:09:50 +00:00
|
|
|
|
|
2018-02-09 00:19:12 +00:00
|
|
|
|
if (!parse_toshiba_packet(wth->random_fh, rec, buf, err, err_info)) {
|
2013-06-17 21:18:47 +00:00
|
|
|
|
if (*err == 0)
|
|
|
|
|
*err = WTAP_ERR_SHORT_READ;
|
2014-05-23 10:50:02 +00:00
|
|
|
|
return FALSE;
|
1999-10-31 17:46:11 +00:00
|
|
|
|
}
|
2014-05-23 10:50:02 +00:00
|
|
|
|
return TRUE;
|
1999-10-31 17:46:11 +00:00
|
|
|
|
}
|
|
|
|
|
|
2013-06-17 21:18:47 +00:00
|
|
|
|
/* Parses a packet. */
|
|
|
|
|
static gboolean
|
2018-02-09 00:19:12 +00:00
|
|
|
|
parse_toshiba_packet(FILE_T fh, wtap_rec *rec, Buffer *buf,
|
2012-10-17 20:28:22 +00:00
|
|
|
|
int *err, gchar **err_info)
|
1999-10-31 17:46:11 +00:00
|
|
|
|
{
|
2018-02-09 00:19:12 +00:00
|
|
|
|
union wtap_pseudo_header *pseudo_header = &rec->rec_header.packet_header.pseudo_header;
|
1999-10-31 17:46:11 +00:00
|
|
|
|
char line[TOSHIBA_LINE_LENGTH];
|
|
|
|
|
int num_items_scanned;
|
2016-05-01 23:29:41 +00:00
|
|
|
|
int pkt_len, pktnum, hr, min, sec, csec;
|
1999-11-11 05:36:16 +00:00
|
|
|
|
char channel[10], direction[10];
|
2013-06-17 21:18:47 +00:00
|
|
|
|
int i, hex_lines;
|
|
|
|
|
guint8 *pd;
|
1999-10-31 17:46:11 +00:00
|
|
|
|
|
|
|
|
|
/* Our file pointer should be on the line containing the
|
|
|
|
|
* summary information for a packet. Read in that line and
|
|
|
|
|
* extract the useful information
|
|
|
|
|
*/
|
1999-11-18 07:04:29 +00:00
|
|
|
|
if (file_gets(line, TOSHIBA_LINE_LENGTH, fh) == NULL) {
|
2011-04-21 09:41:52 +00:00
|
|
|
|
*err = file_error(fh, err_info);
|
1999-10-31 17:46:11 +00:00
|
|
|
|
if (*err == 0) {
|
|
|
|
|
*err = WTAP_ERR_SHORT_READ;
|
|
|
|
|
}
|
2013-06-17 21:18:47 +00:00
|
|
|
|
return FALSE;
|
1999-10-31 17:46:11 +00:00
|
|
|
|
}
|
|
|
|
|
|
1999-11-11 19:19:17 +00:00
|
|
|
|
/* Find text in line after "[No.". Limit the length of the
|
|
|
|
|
* two strings since we have fixed buffers for channel[] and
|
|
|
|
|
* direction[] */
|
2011-04-07 23:16:05 +00:00
|
|
|
|
num_items_scanned = sscanf(line, "%9d] %2d:%2d:%2d.%9d %9s %9s",
|
1999-11-11 05:36:16 +00:00
|
|
|
|
&pktnum, &hr, &min, &sec, &csec, channel, direction);
|
1999-10-31 17:46:11 +00:00
|
|
|
|
|
1999-11-11 05:36:16 +00:00
|
|
|
|
if (num_items_scanned != 7) {
|
2011-12-13 09:53:50 +00:00
|
|
|
|
*err = WTAP_ERR_BAD_FILE;
|
Have the Wiretap open, read, and seek-and-read routines return, in
addition to an error code, an error info string, for
WTAP_ERR_UNSUPPORTED, WTAP_ERR_UNSUPPORTED_ENCAP, and
WTAP_ERR_BAD_RECORD errors. Replace the error messages logged with
"g_message()" for those errors with g_strdup()ed or g_strdup_printf()ed
strings returned as the error info string, and change the callers of
those routines to, for those errors, put the info string into the
printed message or alert box for the error.
Add messages for cases where those errors were returned without printing
an additional message.
Nobody uses the error code from "cf_read()" - "cf_read()" puts up the
alert box itself for failures; get rid of the error code, so it just
returns a success/failure indication.
Rename "file_read_error_message()" to "cf_read_error_message()", as it
handles read errors from Wiretap, and have it take an error info string
as an argument. (That handles a lot of the work of putting the info
string into the error message.)
Make some variables in "ascend-grammar.y" static.
Check the return value of "erf_read_header()" in "erf_seek_read()".
Get rid of an unused #define in "i4btrace.c".
svn path=/trunk/; revision=9852
2004-01-25 21:55:17 +00:00
|
|
|
|
*err_info = g_strdup("toshiba: record header isn't valid");
|
2013-06-17 21:18:47 +00:00
|
|
|
|
return FALSE;
|
1999-10-31 17:46:11 +00:00
|
|
|
|
}
|
|
|
|
|
|
2000-03-04 14:22:29 +00:00
|
|
|
|
/* Scan lines until we find the OFFSET line. In a "telnet" trace,
|
|
|
|
|
* this will be the next line. But if you save your telnet session
|
|
|
|
|
* to a file from within a Windows-based telnet client, it may
|
|
|
|
|
* put in line breaks at 80 columns (or however big your "telnet" box
|
|
|
|
|
* is). CRT (a Windows telnet app from VanDyke) does this.
|
|
|
|
|
* Here we assume that 80 columns will be the minimum size, and that
|
|
|
|
|
* the OFFSET line is not broken in the middle. It's the previous
|
|
|
|
|
* line that is normally long and can thus be broken at column 80.
|
|
|
|
|
*/
|
|
|
|
|
do {
|
|
|
|
|
if (file_gets(line, TOSHIBA_LINE_LENGTH, fh) == NULL) {
|
2011-04-21 09:41:52 +00:00
|
|
|
|
*err = file_error(fh, err_info);
|
2000-03-04 14:22:29 +00:00
|
|
|
|
if (*err == 0) {
|
|
|
|
|
*err = WTAP_ERR_SHORT_READ;
|
|
|
|
|
}
|
2013-06-17 21:18:47 +00:00
|
|
|
|
return FALSE;
|
1999-10-31 17:46:11 +00:00
|
|
|
|
}
|
2000-03-04 14:22:29 +00:00
|
|
|
|
|
|
|
|
|
/* Check for "OFFSET 0001-0203" at beginning of line */
|
|
|
|
|
line[16] = '\0';
|
|
|
|
|
|
|
|
|
|
} while (strcmp(line, "OFFSET 0001-0203") != 0);
|
1999-10-31 17:46:11 +00:00
|
|
|
|
|
2016-05-01 23:29:41 +00:00
|
|
|
|
num_items_scanned = sscanf(line+64, "LEN=%9d", &pkt_len);
|
1999-10-31 17:46:11 +00:00
|
|
|
|
if (num_items_scanned != 1) {
|
2011-12-13 09:53:50 +00:00
|
|
|
|
*err = WTAP_ERR_BAD_FILE;
|
Have the Wiretap open, read, and seek-and-read routines return, in
addition to an error code, an error info string, for
WTAP_ERR_UNSUPPORTED, WTAP_ERR_UNSUPPORTED_ENCAP, and
WTAP_ERR_BAD_RECORD errors. Replace the error messages logged with
"g_message()" for those errors with g_strdup()ed or g_strdup_printf()ed
strings returned as the error info string, and change the callers of
those routines to, for those errors, put the info string into the
printed message or alert box for the error.
Add messages for cases where those errors were returned without printing
an additional message.
Nobody uses the error code from "cf_read()" - "cf_read()" puts up the
alert box itself for failures; get rid of the error code, so it just
returns a success/failure indication.
Rename "file_read_error_message()" to "cf_read_error_message()", as it
handles read errors from Wiretap, and have it take an error info string
as an argument. (That handles a lot of the work of putting the info
string into the error message.)
Make some variables in "ascend-grammar.y" static.
Check the return value of "erf_read_header()" in "erf_seek_read()".
Get rid of an unused #define in "i4btrace.c".
svn path=/trunk/; revision=9852
2004-01-25 21:55:17 +00:00
|
|
|
|
*err_info = g_strdup("toshiba: OFFSET line doesn't have valid LEN item");
|
2013-06-17 21:18:47 +00:00
|
|
|
|
return FALSE;
|
1999-10-31 17:46:11 +00:00
|
|
|
|
}
|
2016-05-01 23:29:41 +00:00
|
|
|
|
if (pkt_len < 0) {
|
|
|
|
|
*err = WTAP_ERR_BAD_FILE;
|
|
|
|
|
*err_info = g_strdup("toshiba: packet header has a negative packet length");
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
2021-01-20 03:02:01 +00:00
|
|
|
|
if ((guint)pkt_len > WTAP_MAX_PACKET_SIZE_STANDARD) {
|
2016-04-29 22:19:49 +00:00
|
|
|
|
/*
|
|
|
|
|
* Probably a corrupt capture file; don't blow up trying
|
|
|
|
|
* to allocate space for an immensely-large packet.
|
|
|
|
|
*/
|
|
|
|
|
*err = WTAP_ERR_BAD_FILE;
|
|
|
|
|
*err_info = g_strdup_printf("toshiba: File has %u-byte packet, bigger than maximum of %u",
|
2021-01-20 03:02:01 +00:00
|
|
|
|
(guint)pkt_len, WTAP_MAX_PACKET_SIZE_STANDARD);
|
2016-04-29 22:19:49 +00:00
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
1999-10-31 17:46:11 +00:00
|
|
|
|
|
2018-02-09 00:19:12 +00:00
|
|
|
|
rec->rec_type = REC_TYPE_PACKET;
|
2021-08-30 02:12:13 +00:00
|
|
|
|
rec->block = wtap_block_create(WTAP_BLOCK_PACKET);
|
2018-02-09 00:19:12 +00:00
|
|
|
|
rec->presence_flags = WTAP_HAS_TS|WTAP_HAS_CAP_LEN;
|
|
|
|
|
rec->ts.secs = hr * 3600 + min * 60 + sec;
|
|
|
|
|
rec->ts.nsecs = csec * 10000000;
|
|
|
|
|
rec->rec_header.packet_header.caplen = pkt_len;
|
|
|
|
|
rec->rec_header.packet_header.len = pkt_len;
|
2013-06-17 21:18:47 +00:00
|
|
|
|
|
2000-05-18 09:09:50 +00:00
|
|
|
|
switch (channel[0]) {
|
|
|
|
|
case 'B':
|
2018-02-09 00:19:12 +00:00
|
|
|
|
rec->rec_header.packet_header.pkt_encap = WTAP_ENCAP_ISDN;
|
2002-10-31 07:12:42 +00:00
|
|
|
|
pseudo_header->isdn.uton = (direction[0] == 'T');
|
2004-01-05 17:33:28 +00:00
|
|
|
|
pseudo_header->isdn.channel = (guint8)
|
2002-10-31 07:12:42 +00:00
|
|
|
|
strtol(&channel[1], NULL, 10);
|
2000-05-18 09:09:50 +00:00
|
|
|
|
break;
|
1999-10-31 17:46:11 +00:00
|
|
|
|
|
2000-05-18 09:09:50 +00:00
|
|
|
|
case 'D':
|
2018-02-09 00:19:12 +00:00
|
|
|
|
rec->rec_header.packet_header.pkt_encap = WTAP_ENCAP_ISDN;
|
2002-10-31 07:12:42 +00:00
|
|
|
|
pseudo_header->isdn.uton = (direction[0] == 'T');
|
|
|
|
|
pseudo_header->isdn.channel = 0;
|
2000-05-18 09:09:50 +00:00
|
|
|
|
break;
|
2002-08-28 20:30:45 +00:00
|
|
|
|
|
2000-05-18 09:09:50 +00:00
|
|
|
|
default:
|
2018-02-09 00:19:12 +00:00
|
|
|
|
rec->rec_header.packet_header.pkt_encap = WTAP_ENCAP_ETHERNET;
|
2003-10-01 07:11:49 +00:00
|
|
|
|
/* XXX - is there an FCS in the frame? */
|
|
|
|
|
pseudo_header->eth.fcs_len = -1;
|
2000-05-18 09:09:50 +00:00
|
|
|
|
break;
|
1999-10-31 17:46:11 +00:00
|
|
|
|
}
|
2013-06-16 00:20:00 +00:00
|
|
|
|
|
|
|
|
|
/* Make sure we have enough room for the packet */
|
2016-04-29 22:19:49 +00:00
|
|
|
|
ws_buffer_assure_space(buf, pkt_len);
|
2014-08-02 11:00:48 +00:00
|
|
|
|
pd = ws_buffer_start_ptr(buf);
|
2002-08-28 20:30:45 +00:00
|
|
|
|
|
1999-10-31 17:46:11 +00:00
|
|
|
|
/* 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++) {
|
1999-11-18 07:04:29 +00:00
|
|
|
|
if (file_gets(line, TOSHIBA_LINE_LENGTH, fh) == NULL) {
|
2011-04-21 09:41:52 +00:00
|
|
|
|
*err = file_error(fh, err_info);
|
1999-10-31 17:46:11 +00:00
|
|
|
|
if (*err == 0) {
|
|
|
|
|
*err = WTAP_ERR_SHORT_READ;
|
|
|
|
|
}
|
2002-03-05 08:40:27 +00:00
|
|
|
|
return FALSE;
|
1999-10-31 17:46:11 +00:00
|
|
|
|
}
|
2013-06-16 00:20:00 +00:00
|
|
|
|
if (!parse_single_hex_dump_line(line, pd, i * 16)) {
|
2011-12-13 09:53:50 +00:00
|
|
|
|
*err = WTAP_ERR_BAD_FILE;
|
Have the Wiretap open, read, and seek-and-read routines return, in
addition to an error code, an error info string, for
WTAP_ERR_UNSUPPORTED, WTAP_ERR_UNSUPPORTED_ENCAP, and
WTAP_ERR_BAD_RECORD errors. Replace the error messages logged with
"g_message()" for those errors with g_strdup()ed or g_strdup_printf()ed
strings returned as the error info string, and change the callers of
those routines to, for those errors, put the info string into the
printed message or alert box for the error.
Add messages for cases where those errors were returned without printing
an additional message.
Nobody uses the error code from "cf_read()" - "cf_read()" puts up the
alert box itself for failures; get rid of the error code, so it just
returns a success/failure indication.
Rename "file_read_error_message()" to "cf_read_error_message()", as it
handles read errors from Wiretap, and have it take an error info string
as an argument. (That handles a lot of the work of putting the info
string into the error message.)
Make some variables in "ascend-grammar.y" static.
Check the return value of "erf_read_header()" in "erf_seek_read()".
Get rid of an unused #define in "i4btrace.c".
svn path=/trunk/; revision=9852
2004-01-25 21:55:17 +00:00
|
|
|
|
*err_info = g_strdup("toshiba: hex dump not valid");
|
2002-03-05 08:40:27 +00:00
|
|
|
|
return FALSE;
|
1999-10-31 17:46:11 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2002-03-05 08:40:27 +00:00
|
|
|
|
return TRUE;
|
1999-10-31 17:46:11 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
1 2 3 4
|
|
|
|
|
0123456789012345678901234567890123456789012345
|
2002-08-28 20:30:45 +00:00
|
|
|
|
0000 : FF03 003D C000 0008 2145 0000 3A12 6500 ...=....!E..:.e.
|
|
|
|
|
0010 : 003F 11E6 58CF C11A 8897 A401 0804 0400 .?..X...........
|
|
|
|
|
0020 : 0100 01 ...
|
1999-10-31 17:46:11 +00:00
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#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
|
2001-10-25 20:29:24 +00:00
|
|
|
|
parse_single_hex_dump_line(char* rec, guint8 *buf, guint byte_offset) {
|
1999-10-31 17:46:11 +00:00
|
|
|
|
|
|
|
|
|
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:
|
2014-10-07 05:01:12 +00:00
|
|
|
|
* 1. Replace any spaces with '0's
|
|
|
|
|
* 2. Place \0's every 5 bytes (to terminate the string)
|
1999-10-31 17:46:11 +00:00
|
|
|
|
*
|
|
|
|
|
* 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;
|
|
|
|
|
}
|
2015-01-02 00:45:22 +00:00
|
|
|
|
|
wiretap: have file handlers advertise blocks and options supported.
Instead of a "supports name resolution" Boolean and bitflags for types of
comments supported, provide a list of block types that the file
type/subtype supports, with each block type having a list of options
supported. Indicate whether "supported" means "one instance" or
"multiple instances".
"Supports" doesn't just mean "can be written", it also means "could be
read".
Rename WTAP_BLOCK_IF_DESCRIPTION to WTAP_BLOCK_IF_ID_AND_INFO, to
indicate that it provides, in addition to information about the
interface, an ID (implicitly, in pcapng files, by its ordinal number)
that is associated with every packet in the file. Emphasize that in
comments - just because your capture file format can list the interfaces
on which a capture was done, that doesn't mean it supports this; it
doesn't do so if the file doesn't indicate, for every packet, on which
of those interfaces it was captured (I'm looking at *you*, Microsoft
Network Monitor...).
Use APIs to query that information to do what the "does this file
type/subtype support name resolution information", "does this file
type/subtype support all of these comment types", and "does this file
type/subtype support - and require - interface IDs" APIs did.
Provide backwards compatibility for Lua.
This allows us to eliminate the WTAP_FILE_TYPE_SUBTYPE_ values for IBM's
iptrace; do so.
2021-02-21 22:18:04 +00:00
|
|
|
|
static const struct supported_block_type toshiba_blocks_supported[] = {
|
|
|
|
|
/*
|
|
|
|
|
* We support packet blocks, with no comments or other options.
|
|
|
|
|
*/
|
|
|
|
|
{ WTAP_BLOCK_PACKET, MULTIPLE_BLOCKS_SUPPORTED, NO_OPTIONS_SUPPORTED }
|
|
|
|
|
};
|
|
|
|
|
|
wiretap: register most built-in file types from its module.
Remove most of the built-in file types from the table in
wiretap/file_access.c and, instead, have the file types register
themselves, using wtap_register_file_type_subtypes().
This reduces the source code changes needed to add a new file type from
three (add the handler, add the file type to the table in file_access.c,
add a #define for the file type in wiretap/wtap.h) to one (add the
handler). (It also requires adding the handler's source file to
wiretap/CMakeLists.txt, but that's required in both cases.)
A few remain because the WTAP_FILE_TYPE_SUBTYPE_ #define is used
elsewhere; that needs to be fixed.
Fix the wiretap/CMakefile.txt file to scan k12text.l, as that now
contains a registration routine. In the process, avoid scanning files
that don't implement a file type and won't ever have a registration
routine.
Add a Lua routine to fetch the total number of file types; we use that
in some code to construct the wtap_filetypes table, which we need to do
in order to continue to have all the values that used to come from the
WTAP_FILE_TYPE_SUBTYPE_ types.
While we're at it, add modelines to a file that lacked them.
2021-02-14 08:34:10 +00:00
|
|
|
|
static const struct file_type_subtype_info toshiba_info = {
|
|
|
|
|
"Toshiba Compact ISDN Router snoop", "toshiba", "txt", NULL,
|
wiretap: have file handlers advertise blocks and options supported.
Instead of a "supports name resolution" Boolean and bitflags for types of
comments supported, provide a list of block types that the file
type/subtype supports, with each block type having a list of options
supported. Indicate whether "supported" means "one instance" or
"multiple instances".
"Supports" doesn't just mean "can be written", it also means "could be
read".
Rename WTAP_BLOCK_IF_DESCRIPTION to WTAP_BLOCK_IF_ID_AND_INFO, to
indicate that it provides, in addition to information about the
interface, an ID (implicitly, in pcapng files, by its ordinal number)
that is associated with every packet in the file. Emphasize that in
comments - just because your capture file format can list the interfaces
on which a capture was done, that doesn't mean it supports this; it
doesn't do so if the file doesn't indicate, for every packet, on which
of those interfaces it was captured (I'm looking at *you*, Microsoft
Network Monitor...).
Use APIs to query that information to do what the "does this file
type/subtype support name resolution information", "does this file
type/subtype support all of these comment types", and "does this file
type/subtype support - and require - interface IDs" APIs did.
Provide backwards compatibility for Lua.
This allows us to eliminate the WTAP_FILE_TYPE_SUBTYPE_ values for IBM's
iptrace; do so.
2021-02-21 22:18:04 +00:00
|
|
|
|
FALSE, BLOCKS_SUPPORTED(toshiba_blocks_supported),
|
wiretap: register most built-in file types from its module.
Remove most of the built-in file types from the table in
wiretap/file_access.c and, instead, have the file types register
themselves, using wtap_register_file_type_subtypes().
This reduces the source code changes needed to add a new file type from
three (add the handler, add the file type to the table in file_access.c,
add a #define for the file type in wiretap/wtap.h) to one (add the
handler). (It also requires adding the handler's source file to
wiretap/CMakeLists.txt, but that's required in both cases.)
A few remain because the WTAP_FILE_TYPE_SUBTYPE_ #define is used
elsewhere; that needs to be fixed.
Fix the wiretap/CMakefile.txt file to scan k12text.l, as that now
contains a registration routine. In the process, avoid scanning files
that don't implement a file type and won't ever have a registration
routine.
Add a Lua routine to fetch the total number of file types; we use that
in some code to construct the wtap_filetypes table, which we need to do
in order to continue to have all the values that used to come from the
WTAP_FILE_TYPE_SUBTYPE_ types.
While we're at it, add modelines to a file that lacked them.
2021-02-14 08:34:10 +00:00
|
|
|
|
NULL, NULL, NULL
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
void register_toshiba(void)
|
|
|
|
|
{
|
2021-02-24 03:10:35 +00:00
|
|
|
|
toshiba_file_type_subtype = wtap_register_file_type_subtype(&toshiba_info);
|
wiretap: more work on file type/subtypes.
Provide a wiretap routine to get an array of all savable file
type/subtypes, sorted with pcap and pcapng at the top, followed by the
other types, sorted either by the name or the description.
Use that routine to list options for the -F flag for various commands
Rename wtap_get_savable_file_types_subtypes() to
wtap_get_savable_file_types_subtypes_for_file(), to indicate that it
provides an array of all file type/subtypes in which a given file can be
saved. Have it sort all types, other than the default type/subtype and,
if there is one, the "other" type (both of which are put at the top), by
the name or the description.
Don't allow wtap_register_file_type_subtypes() to override any existing
registrations; have them always register a new type. In that routine,
if there are any emply slots in the table, due to an entry being
unregistered, use it rather than allocating a new slot.
Don't allow unregistration of built-in types.
Rename the "dump open table" to the "file type/subtype table", as it has
entries for all types/subtypes, even if we can't write them.
Initialize that table in a routine that pre-allocates the GArray before
filling it with built-in types/subtypes, so it doesn't keep getting
reallocated.
Get rid of wtap_num_file_types_subtypes - it's just a copy of the size
of the GArray.
Don't have wtap_file_type_subtype_description() crash if handed an
file type/subtype that isn't a valid array index - just return NULL, as
we do with wtap_file_type_subtype_name().
In wtap_name_to_file_type_subtype(), don't use WTAP_FILE_TYPE_SUBTYPE_
names for the backwards-compatibility names - map those names to the
current names, and then look them up. This reduces the number of
uses of hardwired WTAP_FILE_TYPE_SUBTYPE_ values.
Clean up the type of wtap_module_count - it has no need to be a gulong.
Have built-in wiretap file handlers register names to be used for their
file type/subtypes, rather than building the table in init.lua.
Add a new Lua C function get_wtap_filetypes() to construct the
wtap_filetypes table, based on the registered names, and use it in
init.lua.
Add a #define WSLUA_INTERNAL_FUNCTION to register functions intended
only for internal use in init.lua, so they can be made available from
Lua without being documented.
Get rid of WTAP_NUM_FILE_TYPES_SUBTYPES - most code has no need to use
it, as it can just request arrays of types, and the space of
type/subtype codes can be sparse due to registration in any case, so
code has to be careful using it.
wtap_get_num_file_types_subtypes() is no longer used, so remove it. It
returns the number of elements in the file type/subtype array, which is
not necessarily the name of known file type/subtypes, as there may have
been some deregistered types, and those types do *not* get removed from
the array, they just get cleared so that they're available for future
allocation (we don't want the indices of any registered types to changes
if another type is deregistered, as those indicates are the type/subtype
values, so we can't shrink the array).
Clean up white space and remove some comments that shouldn't have been
added.
2021-02-17 06:24:47 +00:00
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Register name for backwards compatibility with the
|
|
|
|
|
* wtap_filetypes table in Lua.
|
|
|
|
|
*/
|
|
|
|
|
wtap_register_backwards_compatibility_lua_name("TOSHIBA",
|
|
|
|
|
toshiba_file_type_subtype);
|
wiretap: register most built-in file types from its module.
Remove most of the built-in file types from the table in
wiretap/file_access.c and, instead, have the file types register
themselves, using wtap_register_file_type_subtypes().
This reduces the source code changes needed to add a new file type from
three (add the handler, add the file type to the table in file_access.c,
add a #define for the file type in wiretap/wtap.h) to one (add the
handler). (It also requires adding the handler's source file to
wiretap/CMakeLists.txt, but that's required in both cases.)
A few remain because the WTAP_FILE_TYPE_SUBTYPE_ #define is used
elsewhere; that needs to be fixed.
Fix the wiretap/CMakefile.txt file to scan k12text.l, as that now
contains a registration routine. In the process, avoid scanning files
that don't implement a file type and won't ever have a registration
routine.
Add a Lua routine to fetch the total number of file types; we use that
in some code to construct the wtap_filetypes table, which we need to do
in order to continue to have all the values that used to come from the
WTAP_FILE_TYPE_SUBTYPE_ types.
While we're at it, add modelines to a file that lacked them.
2021-02-14 08:34:10 +00:00
|
|
|
|
}
|
|
|
|
|
|
2015-01-02 00:45:22 +00:00
|
|
|
|
/*
|
2019-07-26 18:43:17 +00:00
|
|
|
|
* Editor modelines - https://www.wireshark.org/tools/modelines.html
|
2015-01-02 00:45:22 +00:00
|
|
|
|
*
|
|
|
|
|
* Local variables:
|
|
|
|
|
* c-basic-offset: 8
|
|
|
|
|
* tab-width: 8
|
|
|
|
|
* indent-tabs-mode: t
|
|
|
|
|
* End:
|
|
|
|
|
*
|
|
|
|
|
* vi: set shiftwidth=8 tabstop=8 noexpandtab:
|
|
|
|
|
* :indentSize=8:tabSize=8:noTabs=false:
|
|
|
|
|
*/
|