2012-07-09 23:07:28 +00:00
|
|
|
/* peekclassic.c
|
2015-05-05 22:18:38 +00:00
|
|
|
* Routines for opening files in what Savvius (formerly WildPackets) calls
|
|
|
|
* the classic file format in the description of their "PeekRdr Sample
|
|
|
|
* Application" (C++ source code to read their capture files, downloading
|
|
|
|
* of which requires a maintenance contract, so it's not free as in beer
|
|
|
|
* and probably not as in speech, either).
|
2012-07-09 23:07:28 +00:00
|
|
|
*
|
|
|
|
* As that description says, it's used by AiroPeek and AiroPeek NX prior
|
|
|
|
* to 2.0, EtherPeek prior to 6.0, and EtherPeek NX prior to 3.0. It
|
|
|
|
* was probably also used by TokenPeek.
|
|
|
|
*
|
|
|
|
* This handles versions 5, 6, and 7 of that format (the format version
|
|
|
|
* number is what appears in the file, and is distinct from the application
|
|
|
|
* version number).
|
|
|
|
*
|
2001-02-22 22:03:31 +00:00
|
|
|
* Copyright (c) 2001, Daniel Thompson <d.thompson@gmx.net>
|
|
|
|
*
|
|
|
|
* 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-18 21:40:50 +00:00
|
|
|
* SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
*/
|
2001-02-22 22:03:31 +00:00
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
#include <errno.h>
|
|
|
|
#include <string.h>
|
2020-01-21 22:26:38 +00:00
|
|
|
|
|
|
|
#include <wsutil/epochs.h>
|
2021-03-10 09:42:51 +00:00
|
|
|
#include <wsutil/802_11-utils.h>
|
2021-05-23 23:46:43 +00:00
|
|
|
#include <wsutil/ws_assert.h>
|
2020-01-21 22:26:38 +00:00
|
|
|
|
2001-02-22 22:03:31 +00:00
|
|
|
#include "wtap-int.h"
|
|
|
|
#include "file_wrappers.h"
|
2012-07-09 23:07:28 +00:00
|
|
|
#include "peekclassic.h"
|
2020-01-21 22:26:38 +00:00
|
|
|
|
2001-02-22 22:03:31 +00:00
|
|
|
/* CREDITS
|
|
|
|
*
|
2020-10-10 23:42:05 +00:00
|
|
|
* This file decoder could not have been written without examining how
|
2002-01-18 00:48:37 +00:00
|
|
|
* tcptrace (http://www.tcptrace.org/) handles EtherPeek files.
|
2001-02-22 22:03:31 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
/* master header */
|
2012-07-09 23:07:28 +00:00
|
|
|
typedef struct peekclassic_master_header {
|
2001-02-22 22:03:31 +00:00
|
|
|
guint8 version;
|
|
|
|
guint8 status;
|
2012-07-09 23:07:28 +00:00
|
|
|
} peekclassic_master_header_t;
|
|
|
|
#define PEEKCLASSIC_MASTER_HDR_SIZE 2
|
2001-02-22 22:03:31 +00:00
|
|
|
|
2002-01-23 06:32:52 +00:00
|
|
|
/* secondary header (V5,V6,V7) */
|
2012-07-09 23:07:28 +00:00
|
|
|
typedef struct peekclassic_v567_header {
|
2001-02-22 22:03:31 +00:00
|
|
|
guint32 filelength;
|
|
|
|
guint32 numPackets;
|
|
|
|
guint32 timeDate;
|
|
|
|
guint32 timeStart;
|
|
|
|
guint32 timeStop;
|
2002-08-28 20:30:45 +00:00
|
|
|
guint32 mediaType; /* Media Type Ethernet=0 Token Ring = 1 */
|
2002-01-21 23:45:58 +00:00
|
|
|
guint32 physMedium; /* Physical Medium native=0 802.1=1 */
|
|
|
|
guint32 appVers; /* App Version Number Maj.Min.Bug.Build */
|
|
|
|
guint32 linkSpeed; /* Link Speed Bits/sec */
|
2002-08-28 20:30:45 +00:00
|
|
|
guint32 reserved[3];
|
2012-07-09 23:07:28 +00:00
|
|
|
} peekclassic_v567_header_t;
|
|
|
|
#define PEEKCLASSIC_V567_HDR_SIZE 48
|
2001-02-22 22:03:31 +00:00
|
|
|
|
|
|
|
/* full header */
|
2012-07-09 23:07:28 +00:00
|
|
|
typedef struct peekclassic_header {
|
|
|
|
peekclassic_master_header_t master;
|
2001-02-22 22:03:31 +00:00
|
|
|
union {
|
2012-07-09 23:07:28 +00:00
|
|
|
peekclassic_v567_header_t v567;
|
2001-02-22 22:03:31 +00:00
|
|
|
} secondary;
|
2012-07-09 23:07:28 +00:00
|
|
|
} peekclassic_header_t;
|
2001-02-22 22:03:31 +00:00
|
|
|
|
2001-12-05 07:19:11 +00:00
|
|
|
/*
|
2002-01-23 06:32:52 +00:00
|
|
|
* Packet header (V5, V6).
|
2001-12-05 07:19:11 +00:00
|
|
|
*
|
|
|
|
* NOTE: the time stamp, although it's a 32-bit number, is only aligned
|
|
|
|
* on a 16-bit boundary. (Does this date back to 68K Macs? The 68000
|
|
|
|
* only required 16-bit alignment of 32-bit quantities, as did the 68010,
|
|
|
|
* and the 68020/68030/68040 required no alignment.)
|
|
|
|
*
|
|
|
|
* As such, we cannot declare this as a C structure, as compilers on
|
|
|
|
* most platforms will put 2 bytes of padding before the time stamp to
|
|
|
|
* align it on a 32-bit boundary.
|
|
|
|
*
|
|
|
|
* So, instead, we #define numbers as the offsets of the fields.
|
|
|
|
*/
|
2012-07-09 23:07:28 +00:00
|
|
|
#define PEEKCLASSIC_V56_LENGTH_OFFSET 0
|
|
|
|
#define PEEKCLASSIC_V56_SLICE_LENGTH_OFFSET 2
|
|
|
|
#define PEEKCLASSIC_V56_FLAGS_OFFSET 4
|
|
|
|
#define PEEKCLASSIC_V56_STATUS_OFFSET 5
|
|
|
|
#define PEEKCLASSIC_V56_TIMESTAMP_OFFSET 6
|
|
|
|
#define PEEKCLASSIC_V56_DESTNUM_OFFSET 10
|
|
|
|
#define PEEKCLASSIC_V56_SRCNUM_OFFSET 12
|
|
|
|
#define PEEKCLASSIC_V56_PROTONUM_OFFSET 14
|
|
|
|
#define PEEKCLASSIC_V56_PROTOSTR_OFFSET 16
|
|
|
|
#define PEEKCLASSIC_V56_FILTERNUM_OFFSET 24
|
|
|
|
#define PEEKCLASSIC_V56_PKT_SIZE 26
|
2001-02-22 22:03:31 +00:00
|
|
|
|
|
|
|
/* 64-bit time in micro seconds from the (Mac) epoch */
|
2012-07-09 23:07:28 +00:00
|
|
|
typedef struct peekclassic_utime {
|
2001-02-22 22:03:31 +00:00
|
|
|
guint32 upper;
|
|
|
|
guint32 lower;
|
2012-07-09 23:07:28 +00:00
|
|
|
} peekclassic_utime;
|
2001-02-22 22:03:31 +00:00
|
|
|
|
2001-12-05 07:19:11 +00:00
|
|
|
/*
|
2002-01-23 06:32:52 +00:00
|
|
|
* Packet header (V7).
|
2001-12-05 07:19:11 +00:00
|
|
|
*
|
|
|
|
* This doesn't have the same alignment problem, but we do it with
|
|
|
|
* #defines anyway.
|
|
|
|
*/
|
2012-07-09 23:07:28 +00:00
|
|
|
#define PEEKCLASSIC_V7_PROTONUM_OFFSET 0
|
|
|
|
#define PEEKCLASSIC_V7_LENGTH_OFFSET 2
|
|
|
|
#define PEEKCLASSIC_V7_SLICE_LENGTH_OFFSET 4
|
|
|
|
#define PEEKCLASSIC_V7_FLAGS_OFFSET 6
|
|
|
|
#define PEEKCLASSIC_V7_STATUS_OFFSET 7
|
|
|
|
#define PEEKCLASSIC_V7_TIMESTAMP_OFFSET 8
|
|
|
|
#define PEEKCLASSIC_V7_PKT_SIZE 16
|
|
|
|
|
2018-11-15 02:29:48 +00:00
|
|
|
/*
|
|
|
|
* Flag bits.
|
|
|
|
*/
|
|
|
|
#define FLAGS_CONTROL_FRAME 0x01 /* Frame is a control frame */
|
2019-05-10 22:21:41 +00:00
|
|
|
#define FLAGS_HAS_CRC_ERROR 0x02 /* Frame has a CRC error */
|
2018-11-15 02:29:48 +00:00
|
|
|
#define FLAGS_HAS_FRAME_ERROR 0x04 /* Frame has a frame error */
|
|
|
|
#define FLAGS_ROUTE_INFO 0x08 /* Frame has token ring routing information */
|
|
|
|
#define FLAGS_FRAME_TOO_LONG 0x10 /* Frame too long */
|
|
|
|
#define FLAGS_FRAME_TOO_SHORT 0x20 /* Frame too short (runt) */
|
|
|
|
#define FLAGS_TRIGGER 0x40 /* Trigger packet (?) */
|
|
|
|
#define FLAGS_SNAP 0x80 /* SNAP packet (SNAP header?) */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Status bits.
|
|
|
|
*/
|
|
|
|
#define STATUS_SELECTED 0x01 /* Selected (in the *Peek GUI?) */
|
|
|
|
#define STATUS_TRUNCATED 0x02 /* Truncated (?) */
|
|
|
|
#define STATUS_APPLEPEEK 0x10 /* ApplePeek packet (?) */
|
|
|
|
#define STATUS_SLICED 0x20 /* Sliced (cut short by snaplen?) */
|
|
|
|
#define STATUS_HIDDEN 0x80 /* Hidden (in the *Peek GUI?) */
|
2001-02-22 22:03:31 +00:00
|
|
|
|
2010-02-26 07:59:54 +00:00
|
|
|
typedef struct {
|
2015-02-28 03:49:28 +00:00
|
|
|
time_t reference_time;
|
2012-07-09 23:07:28 +00:00
|
|
|
} peekclassic_t;
|
2010-02-26 07:59:54 +00:00
|
|
|
|
2019-04-05 01:56:27 +00:00
|
|
|
static gboolean peekclassic_read_v7(wtap *wth, wtap_rec *rec, Buffer *buf,
|
|
|
|
int *err, gchar **err_info, gint64 *data_offset);
|
2014-05-09 05:18:49 +00:00
|
|
|
static gboolean peekclassic_seek_read_v7(wtap *wth, gint64 seek_off,
|
2018-02-09 00:19:12 +00:00
|
|
|
wtap_rec *rec, Buffer *buf, int *err, gchar **err_info);
|
2014-05-09 05:18:49 +00:00
|
|
|
static int peekclassic_read_packet_v7(wtap *wth, FILE_T fh,
|
2018-02-09 00:19:12 +00:00
|
|
|
wtap_rec *rec, Buffer *buf, int *err, gchar **err_info);
|
2019-04-05 01:56:27 +00:00
|
|
|
static gboolean peekclassic_read_v56(wtap *wth, wtap_rec *rec, Buffer *buf,
|
|
|
|
int *err, gchar **err_info, gint64 *data_offset);
|
2014-05-09 05:18:49 +00:00
|
|
|
static gboolean peekclassic_seek_read_v56(wtap *wth, gint64 seek_off,
|
2018-02-09 00:19:12 +00:00
|
|
|
wtap_rec *rec, Buffer *buf, int *err, gchar **err_info);
|
2014-05-09 05:18:49 +00:00
|
|
|
static gboolean peekclassic_read_packet_v56(wtap *wth, FILE_T fh,
|
2018-02-09 00:19:12 +00:00
|
|
|
wtap_rec *rec, Buffer *buf, int *err, gchar **err_info);
|
2001-02-22 22:03:31 +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 peekclassic_v56_file_type_subtype = -1;
|
|
|
|
static int peekclassic_v7_file_type_subtype = -1;
|
|
|
|
|
|
|
|
void register_peekclassic(void);
|
|
|
|
|
2014-10-09 23:44:15 +00:00
|
|
|
wtap_open_return_val peekclassic_open(wtap *wth, int *err, gchar **err_info)
|
2001-02-22 22:03:31 +00:00
|
|
|
{
|
2012-07-09 23:07:28 +00:00
|
|
|
peekclassic_header_t ep_hdr;
|
2015-02-28 03:49:28 +00:00
|
|
|
time_t reference_time;
|
2018-11-15 17:52:02 +00:00
|
|
|
int file_encap;
|
2012-07-09 23:07:28 +00:00
|
|
|
peekclassic_t *peekclassic;
|
2001-02-22 22:03:31 +00:00
|
|
|
|
2012-07-09 23:07:28 +00:00
|
|
|
/* Peek classic files do not start with a magic value large enough
|
2002-01-18 00:48:37 +00:00
|
|
|
* to be unique; hence we use the following algorithm to determine
|
|
|
|
* the type of an unknown file:
|
2001-02-22 22:03:31 +00:00
|
|
|
* - populate the master header and reject file if there is no match
|
|
|
|
* - populate the secondary header and check that the reserved space
|
2002-01-23 06:32:52 +00:00
|
|
|
* is zero, and check some other fields; this isn't perfect,
|
|
|
|
* and we may have to add more checks at some point.
|
2001-02-22 22:03:31 +00:00
|
|
|
*/
|
2021-05-23 23:46:43 +00:00
|
|
|
ws_assert(sizeof(ep_hdr.master) == PEEKCLASSIC_MASTER_HDR_SIZE);
|
Add some higher-level file-read APIs and use them.
Add wtap_read_bytes(), which takes a FILE_T, a pointer, a byte count, an
error number pointer, and an error string pointer as arguments, and that
treats a short read of any sort, including a read that returns 0 bytes,
as a WTAP_ERR_SHORT_READ error, and that returns the error number and
string through its last two arguments.
Add wtap_read_bytes_or_eof(), which is similar, but that treats a read
that returns 0 bytes as an EOF, supplying an error number of 0 as an EOF
indication.
Use those in file readers; that simplifies the code and makes it less
likely that somebody will fail to supply the error number and error
string on a file read error.
Change-Id: Ia5dba2a6f81151e87b614461349d611cffc16210
Reviewed-on: https://code.wireshark.org/review/4512
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2014-10-07 01:00:57 +00:00
|
|
|
if (!wtap_read_bytes(wth->fh, &ep_hdr.master,
|
|
|
|
(int)sizeof(ep_hdr.master), err, err_info)) {
|
|
|
|
if (*err != WTAP_ERR_SHORT_READ)
|
2014-10-09 23:44:15 +00:00
|
|
|
return WTAP_OPEN_ERROR;
|
|
|
|
return WTAP_OPEN_NOT_MINE;
|
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
|
|
|
}
|
2001-02-22 22:03:31 +00:00
|
|
|
|
2003-12-18 03:43:40 +00:00
|
|
|
/*
|
|
|
|
* It appears that EtherHelp (a free application from WildPackets
|
|
|
|
* that did blind capture, saving to a file, so that you could
|
|
|
|
* give the resulting file to somebody with EtherPeek) saved
|
|
|
|
* captures in EtherPeek format except that it ORed the 0x80
|
|
|
|
* bit on in the version number.
|
|
|
|
*
|
|
|
|
* We therefore strip off the 0x80 bit in the version number.
|
|
|
|
* Perhaps there's some reason to care whether the capture
|
|
|
|
* came from EtherHelp; if we discover one, we should check
|
|
|
|
* that bit.
|
|
|
|
*/
|
|
|
|
ep_hdr.master.version &= ~0x80;
|
|
|
|
|
2001-02-22 22:03:31 +00:00
|
|
|
/* switch on the file version */
|
|
|
|
switch (ep_hdr.master.version) {
|
2002-01-18 00:25:50 +00:00
|
|
|
|
|
|
|
case 5:
|
|
|
|
case 6:
|
|
|
|
case 7:
|
|
|
|
/* get the secondary header */
|
2021-05-23 23:46:43 +00:00
|
|
|
ws_assert(sizeof(ep_hdr.secondary.v567) ==
|
2012-07-09 23:07:28 +00:00
|
|
|
PEEKCLASSIC_V567_HDR_SIZE);
|
Add some higher-level file-read APIs and use them.
Add wtap_read_bytes(), which takes a FILE_T, a pointer, a byte count, an
error number pointer, and an error string pointer as arguments, and that
treats a short read of any sort, including a read that returns 0 bytes,
as a WTAP_ERR_SHORT_READ error, and that returns the error number and
string through its last two arguments.
Add wtap_read_bytes_or_eof(), which is similar, but that treats a read
that returns 0 bytes as an EOF, supplying an error number of 0 as an EOF
indication.
Use those in file readers; that simplifies the code and makes it less
likely that somebody will fail to supply the error number and error
string on a file read error.
Change-Id: Ia5dba2a6f81151e87b614461349d611cffc16210
Reviewed-on: https://code.wireshark.org/review/4512
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2014-10-07 01:00:57 +00:00
|
|
|
if (!wtap_read_bytes(wth->fh, &ep_hdr.secondary.v567,
|
|
|
|
(int)sizeof(ep_hdr.secondary.v567), err, err_info)) {
|
2014-10-07 19:49:14 +00:00
|
|
|
if (*err != WTAP_ERR_SHORT_READ)
|
2014-10-09 23:44:15 +00:00
|
|
|
return WTAP_OPEN_ERROR;
|
|
|
|
return WTAP_OPEN_NOT_MINE;
|
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
|
|
|
}
|
2002-01-18 01:08:36 +00:00
|
|
|
|
2002-01-23 06:32:52 +00:00
|
|
|
if ((0 != ep_hdr.secondary.v567.reserved[0]) ||
|
|
|
|
(0 != ep_hdr.secondary.v567.reserved[1]) ||
|
|
|
|
(0 != ep_hdr.secondary.v567.reserved[2])) {
|
2002-01-18 00:25:50 +00:00
|
|
|
/* still unknown */
|
2014-10-09 23:44:15 +00:00
|
|
|
return WTAP_OPEN_NOT_MINE;
|
2002-01-18 00:25:50 +00:00
|
|
|
}
|
|
|
|
|
2002-01-23 06:32:52 +00:00
|
|
|
/*
|
|
|
|
* Check the mediaType and physMedium fields.
|
2012-07-09 23:07:28 +00:00
|
|
|
* We assume it's not a Peek classic file if
|
|
|
|
* these aren't values we know, rather than
|
|
|
|
* reporting them as invalid Peek classic files,
|
|
|
|
* as, given the lack of a magic number, we need
|
|
|
|
* all the checks we can get.
|
2002-01-18 00:25:50 +00:00
|
|
|
*/
|
2002-01-23 06:32:52 +00:00
|
|
|
ep_hdr.secondary.v567.mediaType =
|
2002-07-29 06:09:59 +00:00
|
|
|
g_ntohl(ep_hdr.secondary.v567.mediaType);
|
2002-01-23 06:32:52 +00:00
|
|
|
ep_hdr.secondary.v567.physMedium =
|
2002-07-29 06:09:59 +00:00
|
|
|
g_ntohl(ep_hdr.secondary.v567.physMedium);
|
2002-01-23 06:32:52 +00:00
|
|
|
|
|
|
|
switch (ep_hdr.secondary.v567.physMedium) {
|
|
|
|
|
|
|
|
case 0:
|
|
|
|
/*
|
|
|
|
* "Native" format, presumably meaning
|
|
|
|
* Ethernet or Token Ring.
|
|
|
|
*/
|
|
|
|
switch (ep_hdr.secondary.v567.mediaType) {
|
|
|
|
|
|
|
|
case 0:
|
2018-11-15 17:52:02 +00:00
|
|
|
file_encap = WTAP_ENCAP_ETHERNET;
|
2002-01-23 06:32:52 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 1:
|
2018-11-15 17:52:02 +00:00
|
|
|
file_encap = WTAP_ENCAP_TOKEN_RING;
|
2002-01-23 06:32:52 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
/*
|
2012-07-09 23:14:50 +00:00
|
|
|
* Assume this isn't a Peek classic file.
|
2002-01-23 06:32:52 +00:00
|
|
|
*/
|
2014-10-09 23:44:15 +00:00
|
|
|
return WTAP_OPEN_NOT_MINE;
|
2002-01-23 06:32:52 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 1:
|
|
|
|
switch (ep_hdr.secondary.v567.mediaType) {
|
|
|
|
|
|
|
|
case 0:
|
|
|
|
/*
|
|
|
|
* 802.11, with a private header giving
|
|
|
|
* some radio information. Presumably
|
|
|
|
* this is from AiroPeek.
|
|
|
|
*/
|
2018-11-15 17:52:02 +00:00
|
|
|
file_encap = WTAP_ENCAP_IEEE_802_11_WITH_RADIO;
|
2002-01-29 09:45:58 +00:00
|
|
|
break;
|
2002-01-23 06:32:52 +00:00
|
|
|
|
|
|
|
default:
|
|
|
|
/*
|
2012-07-09 23:14:50 +00:00
|
|
|
* Assume this isn't a Peek classic file.
|
2002-01-23 06:32:52 +00:00
|
|
|
*/
|
2014-10-09 23:44:15 +00:00
|
|
|
return WTAP_OPEN_NOT_MINE;
|
2002-01-23 06:32:52 +00:00
|
|
|
}
|
2002-02-15 11:35:13 +00:00
|
|
|
break;
|
2002-01-23 06:32:52 +00:00
|
|
|
|
|
|
|
default:
|
|
|
|
/*
|
2012-07-09 23:14:50 +00:00
|
|
|
* Assume this isn't a Peek classic file.
|
2002-01-23 06:32:52 +00:00
|
|
|
*/
|
2014-10-09 23:44:15 +00:00
|
|
|
return WTAP_OPEN_NOT_MINE;
|
2002-01-21 23:45:58 +00:00
|
|
|
}
|
2002-08-28 20:30:45 +00:00
|
|
|
|
2002-01-23 06:32:52 +00:00
|
|
|
|
|
|
|
/*
|
2012-07-09 23:14:50 +00:00
|
|
|
* Assume this is a V5, V6 or V7 Peek classic file, and
|
|
|
|
* byte swap the rest of the fields in the secondary header.
|
2002-01-23 06:32:52 +00:00
|
|
|
*
|
|
|
|
* XXX - we could check the file length if the file were
|
|
|
|
* uncompressed, but it might be compressed.
|
|
|
|
*/
|
|
|
|
ep_hdr.secondary.v567.filelength =
|
2002-07-29 06:09:59 +00:00
|
|
|
g_ntohl(ep_hdr.secondary.v567.filelength);
|
2002-01-23 06:32:52 +00:00
|
|
|
ep_hdr.secondary.v567.numPackets =
|
2002-07-29 06:09:59 +00:00
|
|
|
g_ntohl(ep_hdr.secondary.v567.numPackets);
|
2002-01-23 06:32:52 +00:00
|
|
|
ep_hdr.secondary.v567.timeDate =
|
2002-07-29 06:09:59 +00:00
|
|
|
g_ntohl(ep_hdr.secondary.v567.timeDate);
|
2002-01-23 06:32:52 +00:00
|
|
|
ep_hdr.secondary.v567.timeStart =
|
2002-07-29 06:09:59 +00:00
|
|
|
g_ntohl(ep_hdr.secondary.v567.timeStart);
|
2002-01-23 06:32:52 +00:00
|
|
|
ep_hdr.secondary.v567.timeStop =
|
2002-07-29 06:09:59 +00:00
|
|
|
g_ntohl(ep_hdr.secondary.v567.timeStop);
|
2002-01-23 06:32:52 +00:00
|
|
|
ep_hdr.secondary.v567.appVers =
|
2002-07-29 06:09:59 +00:00
|
|
|
g_ntohl(ep_hdr.secondary.v567.appVers);
|
2002-01-23 06:32:52 +00:00
|
|
|
ep_hdr.secondary.v567.linkSpeed =
|
2002-07-29 06:09:59 +00:00
|
|
|
g_ntohl(ep_hdr.secondary.v567.linkSpeed);
|
2002-01-18 00:25:50 +00:00
|
|
|
|
2015-02-28 03:49:28 +00:00
|
|
|
/* Get the reference time as a time_t */
|
2020-01-21 22:26:38 +00:00
|
|
|
reference_time = ep_hdr.secondary.v567.timeDate - EPOCH_DELTA_1904_01_01_00_00_00_UTC;
|
2002-01-18 00:25:50 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2002-01-23 06:32:52 +00:00
|
|
|
/*
|
2012-07-09 23:14:50 +00:00
|
|
|
* Assume this isn't a Peek classic file.
|
2002-01-23 06:32:52 +00:00
|
|
|
*/
|
2014-10-09 23:44:15 +00:00
|
|
|
return WTAP_OPEN_NOT_MINE;
|
2001-02-22 22:03:31 +00:00
|
|
|
}
|
|
|
|
|
2002-01-18 00:25:50 +00:00
|
|
|
/*
|
2012-07-09 23:07:28 +00:00
|
|
|
* This is a Peek classic file.
|
2002-01-18 00:25:50 +00:00
|
|
|
*
|
|
|
|
* At this point we have recognised the file type and have populated
|
|
|
|
* the whole ep_hdr structure in host byte order.
|
2001-02-22 22:03:31 +00:00
|
|
|
*/
|
2020-12-21 02:30:28 +00:00
|
|
|
peekclassic = g_new(peekclassic_t, 1);
|
2014-05-09 05:18:49 +00:00
|
|
|
wth->priv = (void *)peekclassic;
|
2012-07-09 23:07:28 +00:00
|
|
|
peekclassic->reference_time = reference_time;
|
2018-11-15 17:52:02 +00:00
|
|
|
wth->file_encap = file_encap;
|
2001-02-22 22:03:31 +00:00
|
|
|
switch (ep_hdr.master.version) {
|
2002-01-18 00:25:50 +00:00
|
|
|
|
|
|
|
case 5:
|
|
|
|
case 6:
|
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 = peekclassic_v56_file_type_subtype;
|
2014-05-09 05:18:49 +00:00
|
|
|
wth->subtype_read = peekclassic_read_v56;
|
|
|
|
wth->subtype_seek_read = peekclassic_seek_read_v56;
|
2002-01-18 00:25:50 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 7:
|
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 = peekclassic_v7_file_type_subtype;
|
2014-05-09 05:18:49 +00:00
|
|
|
wth->subtype_read = peekclassic_read_v7;
|
|
|
|
wth->subtype_seek_read = peekclassic_seek_read_v7;
|
2002-01-18 00:25:50 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
/* this is impossible */
|
2021-05-23 23:46:43 +00:00
|
|
|
ws_assert_not_reached();
|
2002-01-18 00:25:50 +00:00
|
|
|
}
|
2001-02-22 22:03:31 +00:00
|
|
|
|
2014-05-09 05:18:49 +00:00
|
|
|
wth->snapshot_length = 0; /* not available in header */
|
2014-09-28 18:37:06 +00:00
|
|
|
wth->file_tsprec = WTAP_TSPREC_USEC;
|
2001-02-22 22:03:31 +00:00
|
|
|
|
2020-07-29 08:30:54 +00:00
|
|
|
/*
|
|
|
|
* Add an IDB; we don't know how many interfaces were
|
|
|
|
* involved, so we just say one interface, about which
|
|
|
|
* we only know the link-layer type, snapshot length,
|
|
|
|
* and time stamp resolution.
|
|
|
|
*/
|
|
|
|
wtap_add_generated_idb(wth);
|
|
|
|
|
2014-10-09 23:44:15 +00:00
|
|
|
return WTAP_OPEN_MINE;
|
2001-02-22 22:03:31 +00:00
|
|
|
}
|
|
|
|
|
2019-04-05 01:56:27 +00:00
|
|
|
static gboolean peekclassic_read_v7(wtap *wth, wtap_rec *rec, Buffer *buf,
|
|
|
|
int *err, gchar **err_info, gint64 *data_offset)
|
2013-06-02 23:12:58 +00:00
|
|
|
{
|
2013-06-17 21:18:47 +00:00
|
|
|
int sliceLength;
|
2013-06-03 00:26:16 +00:00
|
|
|
|
2014-05-09 05:18:49 +00:00
|
|
|
*data_offset = file_tell(wth->fh);
|
2013-06-02 23:12:58 +00:00
|
|
|
|
2013-06-17 21:18:47 +00:00
|
|
|
/* Read the packet. */
|
2019-04-05 01:56:27 +00:00
|
|
|
sliceLength = peekclassic_read_packet_v7(wth, wth->fh, rec, buf,
|
|
|
|
err, err_info);
|
2013-06-17 21:18:47 +00:00
|
|
|
if (sliceLength < 0)
|
2014-05-23 10:50:02 +00:00
|
|
|
return FALSE;
|
2013-06-02 23:12:58 +00:00
|
|
|
|
2013-06-03 00:26:16 +00:00
|
|
|
/* Skip extra ignored data at the end of the packet. */
|
2019-04-05 01:56:27 +00:00
|
|
|
if ((guint32)sliceLength > rec->rec_header.packet_header.caplen) {
|
|
|
|
if (!wtap_read_bytes(wth->fh, NULL, sliceLength - rec->rec_header.packet_header.caplen,
|
2016-09-28 23:45:23 +00:00
|
|
|
err, err_info))
|
2014-05-23 10:50:02 +00:00
|
|
|
return FALSE;
|
2013-06-03 00:26:16 +00:00
|
|
|
}
|
|
|
|
|
2013-06-02 23:12:58 +00:00
|
|
|
/* Records are padded to an even length, so if the slice length
|
|
|
|
is odd, read the padding byte. */
|
2013-06-03 00:26:16 +00:00
|
|
|
if (sliceLength & 0x01) {
|
2016-09-28 23:45:23 +00:00
|
|
|
if (!wtap_read_bytes(wth->fh, NULL, 1, err, err_info))
|
2014-05-23 10:50:02 +00:00
|
|
|
return FALSE;
|
2013-06-02 23:12:58 +00:00
|
|
|
}
|
|
|
|
|
2014-05-23 10:50:02 +00:00
|
|
|
return TRUE;
|
2013-06-02 23:12:58 +00:00
|
|
|
}
|
|
|
|
|
2014-05-23 10:50:02 +00:00
|
|
|
static gboolean peekclassic_seek_read_v7(wtap *wth, gint64 seek_off,
|
2018-02-09 00:19:12 +00:00
|
|
|
wtap_rec *rec, Buffer *buf, int *err, gchar **err_info)
|
2013-06-02 23:12:58 +00:00
|
|
|
{
|
2014-05-09 05:18:49 +00:00
|
|
|
if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1)
|
2014-05-23 10:50:02 +00:00
|
|
|
return FALSE;
|
2013-06-02 23:12:58 +00:00
|
|
|
|
2013-06-17 21:18:47 +00:00
|
|
|
/* Read the packet. */
|
2018-02-09 00:19:12 +00:00
|
|
|
if (peekclassic_read_packet_v7(wth, wth->random_fh, rec, buf,
|
2013-06-17 21:18:47 +00:00
|
|
|
err, err_info) == -1) {
|
|
|
|
if (*err == 0)
|
|
|
|
*err = WTAP_ERR_SHORT_READ;
|
2014-05-23 10:50:02 +00:00
|
|
|
return FALSE;
|
2013-06-17 21:18:47 +00:00
|
|
|
}
|
2014-05-23 10:50:02 +00:00
|
|
|
return TRUE;
|
2013-06-02 23:12:58 +00:00
|
|
|
}
|
|
|
|
|
2015-11-26 19:42:32 +00:00
|
|
|
#define RADIO_INFO_SIZE 4
|
|
|
|
|
2014-05-09 05:18:49 +00:00
|
|
|
static int peekclassic_read_packet_v7(wtap *wth, FILE_T fh,
|
2018-02-09 00:19:12 +00:00
|
|
|
wtap_rec *rec, Buffer *buf, int *err, gchar **err_info)
|
2001-02-22 22:03:31 +00:00
|
|
|
{
|
2012-07-09 23:07:28 +00:00
|
|
|
guint8 ep_pkt[PEEKCLASSIC_V7_PKT_SIZE];
|
2011-04-12 18:21:05 +00:00
|
|
|
#if 0
|
2001-12-05 07:19:11 +00:00
|
|
|
guint16 protoNum;
|
2011-04-12 18:21:05 +00:00
|
|
|
#endif
|
2001-12-05 07:19:11 +00:00
|
|
|
guint16 length;
|
|
|
|
guint16 sliceLength;
|
|
|
|
guint8 flags;
|
|
|
|
guint8 status;
|
2005-08-26 19:40:46 +00:00
|
|
|
guint64 timestamp;
|
|
|
|
time_t tsecs;
|
|
|
|
guint32 tusecs;
|
2021-07-12 16:41:57 +00:00
|
|
|
guint32 pack_flags;
|
2015-11-26 19:42:32 +00:00
|
|
|
guint8 radio_info[RADIO_INFO_SIZE];
|
2001-02-22 22:03:31 +00:00
|
|
|
|
Add some higher-level file-read APIs and use them.
Add wtap_read_bytes(), which takes a FILE_T, a pointer, a byte count, an
error number pointer, and an error string pointer as arguments, and that
treats a short read of any sort, including a read that returns 0 bytes,
as a WTAP_ERR_SHORT_READ error, and that returns the error number and
string through its last two arguments.
Add wtap_read_bytes_or_eof(), which is similar, but that treats a read
that returns 0 bytes as an EOF, supplying an error number of 0 as an EOF
indication.
Use those in file readers; that simplifies the code and makes it less
likely that somebody will fail to supply the error number and error
string on a file read error.
Change-Id: Ia5dba2a6f81151e87b614461349d611cffc16210
Reviewed-on: https://code.wireshark.org/review/4512
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2014-10-07 01:00:57 +00:00
|
|
|
if (!wtap_read_bytes_or_eof(fh, ep_pkt, sizeof(ep_pkt), err, err_info))
|
2013-06-17 21:18:47 +00:00
|
|
|
return -1;
|
2001-02-22 22:03:31 +00:00
|
|
|
|
2001-12-05 07:19:11 +00:00
|
|
|
/* Extract the fields from the packet */
|
2011-04-12 18:21:05 +00:00
|
|
|
#if 0
|
2013-12-03 20:35:50 +00:00
|
|
|
protoNum = pntoh16(&ep_pkt[PEEKCLASSIC_V7_PROTONUM_OFFSET]);
|
2011-04-12 18:21:05 +00:00
|
|
|
#endif
|
2013-12-03 20:35:50 +00:00
|
|
|
length = pntoh16(&ep_pkt[PEEKCLASSIC_V7_LENGTH_OFFSET]);
|
|
|
|
sliceLength = pntoh16(&ep_pkt[PEEKCLASSIC_V7_SLICE_LENGTH_OFFSET]);
|
2012-07-09 23:07:28 +00:00
|
|
|
flags = ep_pkt[PEEKCLASSIC_V7_FLAGS_OFFSET];
|
|
|
|
status = ep_pkt[PEEKCLASSIC_V7_STATUS_OFFSET];
|
2013-12-03 20:35:50 +00:00
|
|
|
timestamp = pntoh64(&ep_pkt[PEEKCLASSIC_V7_TIMESTAMP_OFFSET]);
|
2001-02-22 22:03:31 +00:00
|
|
|
|
|
|
|
/* force sliceLength to be the actual length of the packet */
|
2001-12-05 07:19:11 +00:00
|
|
|
if (0 == sliceLength) {
|
|
|
|
sliceLength = length;
|
2001-02-22 22:03:31 +00:00
|
|
|
}
|
2016-04-30 02:04:17 +00:00
|
|
|
/*
|
|
|
|
* The maximum value of sliceLength and length are 65535, which
|
Allow bigger snapshot lengths for D-Bus captures.
Use WTAP_MAX_PACKET_SIZE_STANDARD, set to 256KB, for everything except
for D-Bus captures. Use WTAP_MAX_PACKET_SIZE_DBUS, set to 128MB, for
them, because that's the largest possible D-Bus message size. See
https://bugs.freedesktop.org/show_bug.cgi?id=100220
for an example of the problems caused by limiting the snapshot length to
256KB for D-Bus.
Have a snapshot length of 0 in a capture_file structure mean "there is
no snapshot length for the file"; we don't need the has_snap field in
that case, a value of 0 mean "no, we don't have a snapshot length".
In dumpcap, start out with a pipe buffer size of 2KB, and grow it as
necessary. When checking for a too-big packet from a pipe, check
against the appropriate maximum - 128MB for DLT_DBUS, 256KB for
everything else.
Change-Id: Ib2ce7a0cf37b971fbc0318024fd011e18add8b20
Reviewed-on: https://code.wireshark.org/review/21952
Petri-Dish: Guy Harris <guy@alum.mit.edu>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2017-06-05 01:58:40 +00:00
|
|
|
* are less than WTAP_MAX_PACKET_SIZE_STANDARD will ever be, so we don't
|
2016-04-30 02:04:17 +00:00
|
|
|
* need to check them.
|
|
|
|
*/
|
2001-02-22 22:03:31 +00:00
|
|
|
|
2013-06-02 23:12:58 +00:00
|
|
|
/* fill in packet header values */
|
2018-02-09 00:19:12 +00:00
|
|
|
rec->rec_type = REC_TYPE_PACKET;
|
2021-07-13 20:57:04 +00:00
|
|
|
rec->block = wtap_block_create(WTAP_BLOCK_PACKET);
|
2021-07-12 16:41:57 +00:00
|
|
|
rec->presence_flags = WTAP_HAS_TS|WTAP_HAS_CAP_LEN;
|
2013-06-02 23:12:58 +00:00
|
|
|
tsecs = (time_t) (timestamp/1000000);
|
|
|
|
tusecs = (guint32) (timestamp - tsecs*1000000);
|
2020-01-21 22:26:38 +00:00
|
|
|
rec->ts.secs = tsecs - EPOCH_DELTA_1904_01_01_00_00_00_UTC;
|
2018-02-09 00:19:12 +00:00
|
|
|
rec->ts.nsecs = tusecs * 1000;
|
|
|
|
rec->rec_header.packet_header.len = length;
|
|
|
|
rec->rec_header.packet_header.caplen = sliceLength;
|
2021-07-12 16:41:57 +00:00
|
|
|
pack_flags = 0;
|
2019-05-10 22:21:41 +00:00
|
|
|
if (flags & FLAGS_HAS_CRC_ERROR)
|
2021-07-12 16:41:57 +00:00
|
|
|
pack_flags |= PACK_FLAGS_CRC_ERROR;
|
2019-05-10 22:21:41 +00:00
|
|
|
if (flags & FLAGS_FRAME_TOO_LONG)
|
2021-07-12 16:41:57 +00:00
|
|
|
pack_flags |= PACK_FLAGS_PACKET_TOO_LONG;
|
2019-05-10 22:21:41 +00:00
|
|
|
if (flags & FLAGS_FRAME_TOO_SHORT)
|
2021-07-12 16:41:57 +00:00
|
|
|
pack_flags |= PACK_FLAGS_PACKET_TOO_SHORT;
|
2021-07-13 20:57:04 +00:00
|
|
|
wtap_block_add_uint32_option(rec->block, OPT_PKT_FLAGS, pack_flags);
|
2002-01-21 23:45:58 +00:00
|
|
|
|
2014-05-09 05:18:49 +00:00
|
|
|
switch (wth->file_encap) {
|
2003-10-01 07:11:49 +00:00
|
|
|
|
2015-11-26 19:42:32 +00:00
|
|
|
case WTAP_ENCAP_IEEE_802_11_WITH_RADIO:
|
2018-02-09 00:19:12 +00:00
|
|
|
memset(&rec->rec_header.packet_header.pseudo_header.ieee_802_11, 0, sizeof(rec->rec_header.packet_header.pseudo_header.ieee_802_11));
|
|
|
|
rec->rec_header.packet_header.pseudo_header.ieee_802_11.fcs_len = 0; /* no FCS */
|
|
|
|
rec->rec_header.packet_header.pseudo_header.ieee_802_11.decrypted = FALSE;
|
|
|
|
rec->rec_header.packet_header.pseudo_header.ieee_802_11.datapad = FALSE;
|
|
|
|
rec->rec_header.packet_header.pseudo_header.ieee_802_11.phy = PHDR_802_11_PHY_UNKNOWN;
|
2015-11-26 19:42:32 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Now process the radio information pseudo-header.
|
|
|
|
* It's a 4-byte pseudo-header, consisting of:
|
|
|
|
*
|
|
|
|
* 1 byte of data rate, in units of 500 kb/s;
|
|
|
|
*
|
|
|
|
* 1 byte of channel number;
|
|
|
|
*
|
|
|
|
* 1 byte of signal strength as a percentage of
|
|
|
|
* the maximum, i.e. (RXVECTOR RSSI/RXVECTOR RSSI_Max)*100,
|
|
|
|
* or, at least, that's what I infer it is, given what
|
|
|
|
* the WildPackets note "Converting Signal Strength
|
|
|
|
* Percentage to dBm Values" says (it also says that
|
|
|
|
* the conversion the percentage to a dBm value is
|
|
|
|
* an adapter-dependent process, so, as we don't know
|
|
|
|
* what type of adapter was used to do the capture,
|
|
|
|
* we can't do the conversion);
|
|
|
|
*
|
|
|
|
* 1 byte of unknown content (padding?).
|
|
|
|
*/
|
2018-02-09 00:19:12 +00:00
|
|
|
if (rec->rec_header.packet_header.len < RADIO_INFO_SIZE || rec->rec_header.packet_header.caplen < RADIO_INFO_SIZE) {
|
2015-11-26 19:42:32 +00:00
|
|
|
*err = WTAP_ERR_BAD_FILE;
|
2021-12-18 18:48:20 +00:00
|
|
|
*err_info = ws_strdup_printf("peekclassic: 802.11 packet has length < 4");
|
2015-11-26 19:42:32 +00:00
|
|
|
return -1;
|
|
|
|
}
|
2018-02-09 00:19:12 +00:00
|
|
|
rec->rec_header.packet_header.len -= RADIO_INFO_SIZE;
|
|
|
|
rec->rec_header.packet_header.caplen -= RADIO_INFO_SIZE;
|
2015-11-26 19:42:32 +00:00
|
|
|
sliceLength -= RADIO_INFO_SIZE;
|
|
|
|
|
|
|
|
/* read the pseudo-header */
|
|
|
|
if (!wtap_read_bytes(fh, radio_info, RADIO_INFO_SIZE, err, err_info))
|
|
|
|
return -1;
|
|
|
|
|
2018-02-09 00:19:12 +00:00
|
|
|
rec->rec_header.packet_header.pseudo_header.ieee_802_11.has_data_rate = TRUE;
|
|
|
|
rec->rec_header.packet_header.pseudo_header.ieee_802_11.data_rate = radio_info[0];
|
2015-12-09 22:26:46 +00:00
|
|
|
|
2018-02-09 00:19:12 +00:00
|
|
|
rec->rec_header.packet_header.pseudo_header.ieee_802_11.has_channel = TRUE;
|
|
|
|
rec->rec_header.packet_header.pseudo_header.ieee_802_11.channel = radio_info[1];
|
2015-12-09 22:26:46 +00:00
|
|
|
|
2018-02-09 00:19:12 +00:00
|
|
|
rec->rec_header.packet_header.pseudo_header.ieee_802_11.has_signal_percent = TRUE;
|
|
|
|
rec->rec_header.packet_header.pseudo_header.ieee_802_11.signal_percent = radio_info[2];
|
2001-02-22 22:03:31 +00:00
|
|
|
|
2021-03-10 09:42:51 +00:00
|
|
|
/*
|
|
|
|
* We don't know they PHY, but we do have the data rate;
|
|
|
|
* try to guess it based on the data rate and channel.
|
|
|
|
*/
|
|
|
|
if (RATE_IS_DSSS(rec->rec_header.packet_header.pseudo_header.ieee_802_11.data_rate)) {
|
|
|
|
/* 11b */
|
|
|
|
rec->rec_header.packet_header.pseudo_header.ieee_802_11.phy = PHDR_802_11_PHY_11B;
|
|
|
|
rec->rec_header.packet_header.pseudo_header.ieee_802_11.phy_info.info_11b.has_short_preamble = FALSE;
|
|
|
|
} else if (RATE_IS_OFDM(rec->rec_header.packet_header.pseudo_header.ieee_802_11.data_rate)) {
|
|
|
|
/* 11a or 11g, depending on the band. */
|
|
|
|
if (CHAN_IS_BG(rec->rec_header.packet_header.pseudo_header.ieee_802_11.channel)) {
|
|
|
|
/* 11g */
|
|
|
|
rec->rec_header.packet_header.pseudo_header.ieee_802_11.phy = PHDR_802_11_PHY_11G;
|
|
|
|
rec->rec_header.packet_header.pseudo_header.ieee_802_11.phy_info.info_11g.has_mode = FALSE;
|
|
|
|
} else {
|
|
|
|
/* 11a */
|
|
|
|
rec->rec_header.packet_header.pseudo_header.ieee_802_11.phy = PHDR_802_11_PHY_11A;
|
|
|
|
rec->rec_header.packet_header.pseudo_header.ieee_802_11.phy_info.info_11a.has_channel_type = FALSE;
|
|
|
|
rec->rec_header.packet_header.pseudo_header.ieee_802_11.phy_info.info_11a.has_turbo_type = FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-04-08 09:44:42 +00:00
|
|
|
/*
|
|
|
|
* The last 4 bytes appear to be random data - the length
|
|
|
|
* might include the FCS - so we reduce the length by 4.
|
|
|
|
*
|
|
|
|
* Or maybe this is just the same kind of random 4 bytes
|
|
|
|
* of junk at the end you get in Wireless Sniffer
|
|
|
|
* captures.
|
|
|
|
*/
|
2018-02-09 00:19:12 +00:00
|
|
|
if (rec->rec_header.packet_header.len < 4 || rec->rec_header.packet_header.caplen < 4) {
|
2013-06-02 23:12:58 +00:00
|
|
|
*err = WTAP_ERR_BAD_FILE;
|
2021-12-18 18:48:20 +00:00
|
|
|
*err_info = ws_strdup_printf("peekclassic: 802.11 packet has length < 8");
|
2013-06-17 21:18:47 +00:00
|
|
|
return -1;
|
2013-06-02 23:12:58 +00:00
|
|
|
}
|
2018-02-09 00:19:12 +00:00
|
|
|
rec->rec_header.packet_header.len -= 4;
|
|
|
|
rec->rec_header.packet_header.caplen -= 4;
|
2013-06-02 23:12:58 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case WTAP_ENCAP_ETHERNET:
|
|
|
|
/* XXX - it appears that if the low-order bit of
|
|
|
|
"status" is 0, there's an FCS in this frame,
|
|
|
|
and if it's 1, there's 4 bytes of 0. */
|
2018-02-09 00:19:12 +00:00
|
|
|
rec->rec_header.packet_header.pseudo_header.eth.fcs_len = (status & 0x01) ? 0 : 4;
|
2013-06-02 23:12:58 +00:00
|
|
|
break;
|
2002-04-08 09:44:42 +00:00
|
|
|
}
|
|
|
|
|
2013-06-17 21:18:47 +00:00
|
|
|
/* read the packet data */
|
2018-02-09 00:19:12 +00:00
|
|
|
if (!wtap_read_packet_bytes(fh, buf, rec->rec_header.packet_header.caplen, err, err_info))
|
2013-06-17 21:18:47 +00:00
|
|
|
return -1;
|
|
|
|
|
|
|
|
return sliceLength;
|
2001-02-22 22:03:31 +00:00
|
|
|
}
|
|
|
|
|
2019-04-05 01:56:27 +00:00
|
|
|
static gboolean peekclassic_read_v56(wtap *wth, wtap_rec *rec, Buffer *buf,
|
|
|
|
int *err, gchar **err_info, gint64 *data_offset)
|
2002-04-08 09:44:42 +00:00
|
|
|
{
|
2014-05-09 05:18:49 +00:00
|
|
|
*data_offset = file_tell(wth->fh);
|
2002-04-08 09:44:42 +00:00
|
|
|
|
2013-06-17 21:18:47 +00:00
|
|
|
/* read the packet */
|
2019-04-05 01:56:27 +00:00
|
|
|
if (!peekclassic_read_packet_v56(wth, wth->fh, rec, buf,
|
|
|
|
err, err_info))
|
2014-05-23 10:50:02 +00:00
|
|
|
return FALSE;
|
2003-10-01 07:11:49 +00:00
|
|
|
|
2013-06-02 23:12:58 +00:00
|
|
|
/*
|
|
|
|
* XXX - is the captured packet data padded to a multiple
|
|
|
|
* of 2 bytes?
|
|
|
|
*/
|
2014-05-23 10:50:02 +00:00
|
|
|
return TRUE;
|
2013-06-02 23:12:58 +00:00
|
|
|
}
|
2003-10-01 07:11:49 +00:00
|
|
|
|
2014-05-09 05:18:49 +00:00
|
|
|
static gboolean peekclassic_seek_read_v56(wtap *wth, gint64 seek_off,
|
2018-02-09 00:19:12 +00:00
|
|
|
wtap_rec *rec, Buffer *buf, int *err, gchar **err_info)
|
2013-06-02 23:12:58 +00:00
|
|
|
{
|
2014-05-09 05:18:49 +00:00
|
|
|
if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1)
|
2014-05-23 10:50:02 +00:00
|
|
|
return FALSE;
|
2003-10-01 07:11:49 +00:00
|
|
|
|
2013-06-17 21:18:47 +00:00
|
|
|
/* read the packet */
|
2018-02-09 00:19:12 +00:00
|
|
|
if (!peekclassic_read_packet_v56(wth, wth->random_fh, rec, buf,
|
2013-06-17 21:18:47 +00:00
|
|
|
err, err_info)) {
|
|
|
|
if (*err == 0)
|
|
|
|
*err = WTAP_ERR_SHORT_READ;
|
2014-05-23 10:50:02 +00:00
|
|
|
return FALSE;
|
2013-06-17 21:18:47 +00:00
|
|
|
}
|
2014-05-23 10:50:02 +00:00
|
|
|
return TRUE;
|
2002-04-08 09:44:42 +00:00
|
|
|
}
|
|
|
|
|
2014-05-09 05:18:49 +00:00
|
|
|
static gboolean peekclassic_read_packet_v56(wtap *wth, FILE_T fh,
|
2018-02-09 00:19:12 +00:00
|
|
|
wtap_rec *rec, Buffer *buf, int *err, gchar **err_info)
|
2001-02-22 22:03:31 +00:00
|
|
|
{
|
2014-05-09 05:18:49 +00:00
|
|
|
peekclassic_t *peekclassic = (peekclassic_t *)wth->priv;
|
2012-07-09 23:07:28 +00:00
|
|
|
guint8 ep_pkt[PEEKCLASSIC_V56_PKT_SIZE];
|
2001-12-05 07:19:11 +00:00
|
|
|
guint16 length;
|
|
|
|
guint16 sliceLength;
|
|
|
|
guint8 flags;
|
2019-05-10 22:21:41 +00:00
|
|
|
#if 0
|
2001-12-05 07:19:11 +00:00
|
|
|
guint8 status;
|
2011-04-12 18:21:05 +00:00
|
|
|
#endif
|
2001-12-05 07:19:11 +00:00
|
|
|
guint32 timestamp;
|
2011-04-12 18:21:05 +00:00
|
|
|
#if 0
|
2001-12-05 07:19:11 +00:00
|
|
|
guint16 destNum;
|
|
|
|
guint16 srcNum;
|
2011-04-12 18:21:05 +00:00
|
|
|
#endif
|
2013-06-02 23:12:58 +00:00
|
|
|
#if 0
|
2018-11-15 02:29:48 +00:00
|
|
|
guint16 protoNum;
|
2001-12-05 07:19:11 +00:00
|
|
|
char protoStr[8];
|
2013-06-02 23:12:58 +00:00
|
|
|
#endif
|
2021-07-13 20:57:04 +00:00
|
|
|
guint32 pack_flags;
|
2001-02-22 22:03:31 +00:00
|
|
|
|
Add some higher-level file-read APIs and use them.
Add wtap_read_bytes(), which takes a FILE_T, a pointer, a byte count, an
error number pointer, and an error string pointer as arguments, and that
treats a short read of any sort, including a read that returns 0 bytes,
as a WTAP_ERR_SHORT_READ error, and that returns the error number and
string through its last two arguments.
Add wtap_read_bytes_or_eof(), which is similar, but that treats a read
that returns 0 bytes as an EOF, supplying an error number of 0 as an EOF
indication.
Use those in file readers; that simplifies the code and makes it less
likely that somebody will fail to supply the error number and error
string on a file read error.
Change-Id: Ia5dba2a6f81151e87b614461349d611cffc16210
Reviewed-on: https://code.wireshark.org/review/4512
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2014-10-07 01:00:57 +00:00
|
|
|
if (!wtap_read_bytes_or_eof(fh, ep_pkt, sizeof(ep_pkt), err, err_info))
|
2014-09-23 01:37:50 +00:00
|
|
|
return FALSE;
|
2001-02-22 22:03:31 +00:00
|
|
|
|
2001-12-05 07:19:11 +00:00
|
|
|
/* Extract the fields from the packet */
|
2013-12-03 20:35:50 +00:00
|
|
|
length = pntoh16(&ep_pkt[PEEKCLASSIC_V56_LENGTH_OFFSET]);
|
|
|
|
sliceLength = pntoh16(&ep_pkt[PEEKCLASSIC_V56_SLICE_LENGTH_OFFSET]);
|
2012-07-09 23:07:28 +00:00
|
|
|
flags = ep_pkt[PEEKCLASSIC_V56_FLAGS_OFFSET];
|
2019-05-10 22:21:41 +00:00
|
|
|
#if 0
|
2012-07-09 23:07:28 +00:00
|
|
|
status = ep_pkt[PEEKCLASSIC_V56_STATUS_OFFSET];
|
2011-04-12 18:21:05 +00:00
|
|
|
#endif
|
2013-12-03 20:35:50 +00:00
|
|
|
timestamp = pntoh32(&ep_pkt[PEEKCLASSIC_V56_TIMESTAMP_OFFSET]);
|
2011-04-12 18:21:05 +00:00
|
|
|
#if 0
|
2013-12-03 20:35:50 +00:00
|
|
|
destNum = pntoh16(&ep_pkt[PEEKCLASSIC_V56_DESTNUM_OFFSET]);
|
|
|
|
srcNum = pntoh16(&ep_pkt[PEEKCLASSIC_V56_SRCNUM_OFFSET]);
|
|
|
|
protoNum = pntoh16(&ep_pkt[PEEKCLASSIC_V56_PROTONUM_OFFSET]);
|
2012-07-09 23:07:28 +00:00
|
|
|
memcpy(protoStr, &ep_pkt[PEEKCLASSIC_V56_PROTOSTR_OFFSET],
|
2001-12-05 07:19:11 +00:00
|
|
|
sizeof protoStr);
|
2013-06-02 23:12:58 +00:00
|
|
|
#endif
|
2001-02-22 22:03:31 +00:00
|
|
|
|
2002-01-23 06:32:52 +00:00
|
|
|
/*
|
|
|
|
* XXX - is the captured packet data padded to a multiple
|
|
|
|
* of 2 bytes?
|
|
|
|
*/
|
|
|
|
|
2001-02-22 22:03:31 +00:00
|
|
|
/* force sliceLength to be the actual length of the packet */
|
2001-12-05 07:19:11 +00:00
|
|
|
if (0 == sliceLength) {
|
|
|
|
sliceLength = length;
|
2001-02-22 22:03:31 +00:00
|
|
|
}
|
2016-04-30 02:04:17 +00:00
|
|
|
/*
|
|
|
|
* The maximum value of sliceLength and length are 65535, which
|
Allow bigger snapshot lengths for D-Bus captures.
Use WTAP_MAX_PACKET_SIZE_STANDARD, set to 256KB, for everything except
for D-Bus captures. Use WTAP_MAX_PACKET_SIZE_DBUS, set to 128MB, for
them, because that's the largest possible D-Bus message size. See
https://bugs.freedesktop.org/show_bug.cgi?id=100220
for an example of the problems caused by limiting the snapshot length to
256KB for D-Bus.
Have a snapshot length of 0 in a capture_file structure mean "there is
no snapshot length for the file"; we don't need the has_snap field in
that case, a value of 0 mean "no, we don't have a snapshot length".
In dumpcap, start out with a pipe buffer size of 2KB, and grow it as
necessary. When checking for a too-big packet from a pipe, check
against the appropriate maximum - 128MB for DLT_DBUS, 256KB for
everything else.
Change-Id: Ib2ce7a0cf37b971fbc0318024fd011e18add8b20
Reviewed-on: https://code.wireshark.org/review/21952
Petri-Dish: Guy Harris <guy@alum.mit.edu>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2017-06-05 01:58:40 +00:00
|
|
|
* are less than WTAP_MAX_PACKET_SIZE_STANDARD will ever be, so we don't
|
2016-04-30 02:04:17 +00:00
|
|
|
* need to check them.
|
|
|
|
*/
|
2001-02-22 22:03:31 +00:00
|
|
|
|
|
|
|
/* fill in packet header values */
|
2018-02-09 00:19:12 +00:00
|
|
|
rec->rec_type = REC_TYPE_PACKET;
|
2021-07-13 20:57:04 +00:00
|
|
|
rec->block = wtap_block_create(WTAP_BLOCK_PACKET);
|
2021-07-12 16:41:57 +00:00
|
|
|
rec->presence_flags = WTAP_HAS_TS|WTAP_HAS_CAP_LEN;
|
2001-02-22 22:03:31 +00:00
|
|
|
/* timestamp is in milliseconds since reference_time */
|
2018-02-09 00:19:12 +00:00
|
|
|
rec->ts.secs = peekclassic->reference_time + (timestamp / 1000);
|
|
|
|
rec->ts.nsecs = 1000 * (timestamp % 1000) * 1000;
|
|
|
|
rec->rec_header.packet_header.len = length;
|
|
|
|
rec->rec_header.packet_header.caplen = sliceLength;
|
2021-07-12 16:41:57 +00:00
|
|
|
pack_flags = 0;
|
2019-05-10 22:21:41 +00:00
|
|
|
if (flags & FLAGS_HAS_CRC_ERROR)
|
2021-07-12 16:41:57 +00:00
|
|
|
pack_flags |= PACK_FLAGS_CRC_ERROR;
|
2019-05-10 22:21:41 +00:00
|
|
|
if (flags & FLAGS_FRAME_TOO_LONG)
|
2021-07-12 16:41:57 +00:00
|
|
|
pack_flags |= PACK_FLAGS_PACKET_TOO_LONG;
|
2019-05-10 22:21:41 +00:00
|
|
|
if (flags & FLAGS_FRAME_TOO_SHORT)
|
2021-07-12 16:41:57 +00:00
|
|
|
pack_flags |= PACK_FLAGS_PACKET_TOO_SHORT;
|
2021-07-13 20:57:04 +00:00
|
|
|
wtap_block_add_uint32_option(rec->block, OPT_PKT_FLAGS, pack_flags);
|
2003-10-01 07:11:49 +00:00
|
|
|
|
2018-11-15 02:29:48 +00:00
|
|
|
switch (wth->file_encap) {
|
2003-10-01 07:11:49 +00:00
|
|
|
|
|
|
|
case WTAP_ENCAP_ETHERNET:
|
|
|
|
/* We assume there's no FCS in this frame. */
|
2018-02-09 00:19:12 +00:00
|
|
|
rec->rec_header.packet_header.pseudo_header.eth.fcs_len = 0;
|
2003-10-01 07:11:49 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2013-06-17 21:18:47 +00:00
|
|
|
/* read the packet data */
|
|
|
|
return wtap_read_packet_bytes(fh, buf, sliceLength, err, err_info);
|
2001-02-22 22:03:31 +00:00
|
|
|
}
|
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 peekclassic_v56_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 peekclassic_v56_info = {
|
|
|
|
"Savvius classic (V5 and V6)", "peekclassic56", "pkt", "tpc;apc;wpz",
|
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(peekclassic_v56_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
|
|
|
|
};
|
|
|
|
|
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 peekclassic_v7_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 peekclassic_v7_info = {
|
|
|
|
"Savvius classic (V7)", "peekclassic7", "pkt", "tpc;apc;wpz",
|
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(peekclassic_v7_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_peekclassic(void)
|
|
|
|
{
|
2021-02-24 03:10:35 +00:00
|
|
|
peekclassic_v56_file_type_subtype = wtap_register_file_type_subtype(&peekclassic_v56_info);
|
|
|
|
peekclassic_v7_file_type_subtype = wtap_register_file_type_subtype(&peekclassic_v7_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 names for backwards compatibility with the
|
|
|
|
* wtap_filetypes table in Lua.
|
|
|
|
*/
|
|
|
|
wtap_register_backwards_compatibility_lua_name("PEEKCLASSIC_V56",
|
|
|
|
peekclassic_v56_file_type_subtype);
|
|
|
|
wtap_register_backwards_compatibility_lua_name("PEEKCLASSIC_V7",
|
|
|
|
peekclassic_v7_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:
|
|
|
|
*/
|