2016-02-09 15:16:15 +00:00
|
|
|
/* mplog.c
|
|
|
|
*
|
|
|
|
* File format support for Micropross mplog files
|
|
|
|
* Copyright (c) 2016 by Martin Kaiser <martin@kaiser.cx>
|
|
|
|
*
|
|
|
|
* Wireshark - Network traffic analyzer
|
|
|
|
* By Gerald Combs <gerald@wireshark.org>
|
|
|
|
* Copyright 1998 Gerald Combs
|
|
|
|
*
|
2018-02-18 21:40:50 +00:00
|
|
|
* SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
*/
|
2016-02-09 15:16:15 +00:00
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
The mplog file format logs the communication between a contactless
|
|
|
|
smartcard and a card reader. Such files contain information about the
|
|
|
|
physical layer as well as the bytes exchanged between devices.
|
|
|
|
Some commercial logging and testing tools by the French company Micropross
|
|
|
|
use this format.
|
|
|
|
|
|
|
|
The information used for implementing this wiretap module were
|
|
|
|
obtained from reverse-engineering. There is no publicly available
|
|
|
|
documentation of the mplog file format.
|
|
|
|
|
|
|
|
Mplog files start with the string "MPCSII". This string is part of
|
|
|
|
the header which is in total 0x80 bytes long.
|
|
|
|
|
|
|
|
Following the header, the file is a sequence of 8 byte-blocks.
|
|
|
|
data (one byte)
|
|
|
|
block type (one byte)
|
|
|
|
timestamp (six bytes)
|
|
|
|
|
|
|
|
The timestamp is a counter in little-endian format. The counter is in
|
|
|
|
units of 10ns.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
|
|
|
#include <string.h>
|
|
|
|
#include <wtap-int.h>
|
|
|
|
#include <file_wrappers.h>
|
|
|
|
|
|
|
|
#include "mplog.h"
|
|
|
|
|
|
|
|
/* the block types */
|
|
|
|
#define TYPE_PCD_PICC_A 0x70
|
|
|
|
#define TYPE_PICC_PCD_A 0x71
|
|
|
|
#define TYPE_PCD_PICC_B 0x72
|
|
|
|
#define TYPE_PICC_PCD_B 0x73
|
|
|
|
#define TYPE_UNKNOWN 0xFF
|
|
|
|
|
|
|
|
#define KNOWN_TYPE(x) \
|
|
|
|
( \
|
|
|
|
((x) == TYPE_PCD_PICC_A) || \
|
|
|
|
((x) == TYPE_PICC_PCD_A) || \
|
|
|
|
((x) == TYPE_PCD_PICC_B) || \
|
|
|
|
((x) == TYPE_PICC_PCD_B) \
|
|
|
|
)
|
|
|
|
|
|
|
|
#define MPLOG_BLOCK_SIZE 8
|
|
|
|
|
2019-07-28 04:20:27 +00:00
|
|
|
/* ISO14443 pseudo-header, see https://www.kaiser.cx/pcap-iso14443.html */
|
2016-02-09 15:16:15 +00:00
|
|
|
#define ISO14443_PSEUDO_HDR_VER 0
|
|
|
|
#define ISO14443_PSEUDO_HDR_LEN 4
|
|
|
|
/* the two transfer events are the types that include a trailing CRC
|
|
|
|
the CRC is always present in mplog files */
|
|
|
|
#define ISO14443_PSEUDO_HDR_PICC_TO_PCD 0xFF
|
|
|
|
#define ISO14443_PSEUDO_HDR_PCD_TO_PICC 0xFE
|
|
|
|
|
|
|
|
|
2020-07-04 10:58:10 +00:00
|
|
|
#define ISO14443_MAX_PKT_LEN 4096
|
2016-02-09 15:16:15 +00:00
|
|
|
|
|
|
|
#define PKT_BUF_LEN (ISO14443_PSEUDO_HDR_LEN + ISO14443_MAX_PKT_LEN)
|
|
|
|
|
|
|
|
|
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 mplog_file_type_subtype = -1;
|
|
|
|
|
|
|
|
void register_mplog(void);
|
|
|
|
|
2016-02-09 15:16:15 +00:00
|
|
|
/* read the next packet, starting at the current position of fh
|
|
|
|
as we know very little about the file format, our approach is rather simple:
|
|
|
|
- we read block-by-block until a known block-type is found
|
|
|
|
- this block's type is the type of the next packet
|
|
|
|
- this block's timestamp will become the packet's timestamp
|
|
|
|
- the data byte will be our packet's first byte
|
|
|
|
- we carry on reading blocks and add the data bytes
|
|
|
|
of all blocks of "our" type
|
|
|
|
- if a different well-known block type is found, this is the end of
|
|
|
|
our packet, we go back one block so that this block can be picked
|
|
|
|
up as the start of the next packet
|
|
|
|
- if two blocks of our packet's block type are more than 200us apart,
|
|
|
|
we treat this as a packet boundary as described above
|
|
|
|
*/
|
2018-02-09 00:19:12 +00:00
|
|
|
static gboolean mplog_read_packet(FILE_T fh, wtap_rec *rec,
|
2016-02-09 15:16:15 +00:00
|
|
|
Buffer *buf, int *err, gchar **err_info)
|
|
|
|
{
|
|
|
|
guint8 *p, *start_p;
|
|
|
|
/* --- the last block of a known type --- */
|
|
|
|
guint64 last_ctr = 0;
|
|
|
|
/* --- the current block --- */
|
|
|
|
guint8 block[MPLOG_BLOCK_SIZE]; /* the entire block */
|
|
|
|
guint8 data, type; /* its data and block type bytes */
|
|
|
|
guint64 ctr; /* its timestamp counter */
|
|
|
|
/* --- the packet we're assembling --- */
|
|
|
|
gint pkt_bytes = 0;
|
|
|
|
guint8 pkt_type = TYPE_UNKNOWN;
|
|
|
|
/* the timestamp of the packet's first block,
|
|
|
|
this will become the packet's timestamp */
|
|
|
|
guint64 pkt_ctr = 0;
|
|
|
|
|
|
|
|
|
|
|
|
ws_buffer_assure_space(buf, PKT_BUF_LEN);
|
|
|
|
p = ws_buffer_start_ptr(buf);
|
|
|
|
start_p = p;
|
|
|
|
|
|
|
|
/* leave space for the iso14443 pseudo header
|
|
|
|
we can't create it until we've seen the entire packet */
|
|
|
|
p += ISO14443_PSEUDO_HDR_LEN;
|
|
|
|
|
|
|
|
do {
|
2016-04-19 01:18:12 +00:00
|
|
|
if (!wtap_read_bytes_or_eof(fh, block, sizeof(block), err, err_info)) {
|
|
|
|
/* If we've already read some data, if this failed with an EOF,
|
|
|
|
so that *err is 0, it's a short read. */
|
|
|
|
if (pkt_bytes != 0) {
|
|
|
|
if (*err == 0)
|
|
|
|
*err = WTAP_ERR_SHORT_READ;
|
|
|
|
}
|
2016-02-09 15:16:15 +00:00
|
|
|
break;
|
2016-04-19 01:18:12 +00:00
|
|
|
}
|
2016-02-09 15:16:15 +00:00
|
|
|
data = block[0];
|
|
|
|
type = block[1];
|
|
|
|
ctr = pletoh48(&block[2]);
|
|
|
|
|
|
|
|
if (pkt_type == TYPE_UNKNOWN) {
|
|
|
|
if (KNOWN_TYPE(type)) {
|
|
|
|
pkt_type = type;
|
|
|
|
pkt_ctr = ctr;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (type == pkt_type) {
|
|
|
|
if (last_ctr != 0) {
|
|
|
|
/* if the distance to the last byte of the
|
|
|
|
same type is larger than 200us, this is very likely the
|
|
|
|
first byte of a new packet -> go back one block and exit
|
|
|
|
ctr and last_ctr are in units of 10ns
|
|
|
|
at 106kbit/s, it takes approx 75us to send one byte */
|
|
|
|
if (ctr - last_ctr > 200*100) {
|
|
|
|
file_seek(fh, -MPLOG_BLOCK_SIZE, SEEK_CUR, err);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
*p++ = data;
|
|
|
|
pkt_bytes++;
|
|
|
|
last_ctr = ctr;
|
|
|
|
}
|
|
|
|
else if (KNOWN_TYPE(type)) {
|
|
|
|
file_seek(fh, -MPLOG_BLOCK_SIZE, SEEK_CUR, err);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
} while (pkt_bytes < ISO14443_MAX_PKT_LEN);
|
|
|
|
|
|
|
|
if (pkt_type == TYPE_UNKNOWN)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
start_p[0] = ISO14443_PSEUDO_HDR_VER;
|
|
|
|
|
|
|
|
if (pkt_type==TYPE_PCD_PICC_A || pkt_type==TYPE_PCD_PICC_B)
|
|
|
|
start_p[1] = ISO14443_PSEUDO_HDR_PCD_TO_PICC;
|
|
|
|
else
|
|
|
|
start_p[1] = ISO14443_PSEUDO_HDR_PICC_TO_PCD;
|
|
|
|
|
|
|
|
start_p[2] = pkt_bytes >> 8;
|
|
|
|
start_p[3] = pkt_bytes & 0xFF;
|
|
|
|
|
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->rec_header.packet_header.pkt_encap = WTAP_ENCAP_ISO14443;
|
|
|
|
rec->presence_flags = WTAP_HAS_TS | WTAP_HAS_CAP_LEN;
|
|
|
|
rec->ts.secs = (time_t)((pkt_ctr*10)/(1000*1000*1000));
|
|
|
|
rec->ts.nsecs = (int)((pkt_ctr*10)%(1000*1000*1000));
|
|
|
|
rec->rec_header.packet_header.caplen = ISO14443_PSEUDO_HDR_LEN + pkt_bytes;
|
|
|
|
rec->rec_header.packet_header.len = rec->rec_header.packet_header.caplen;
|
2016-02-09 15:16:15 +00:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static gboolean
|
2019-04-05 01:56:27 +00:00
|
|
|
mplog_read(wtap *wth, wtap_rec *rec, Buffer *buf, int *err,
|
|
|
|
gchar **err_info, gint64 *data_offset)
|
2016-02-09 15:16:15 +00:00
|
|
|
{
|
|
|
|
*data_offset = file_tell(wth->fh);
|
|
|
|
|
2019-04-05 01:56:27 +00:00
|
|
|
return mplog_read_packet(wth->fh, rec, buf, err, err_info);
|
2016-02-09 15:16:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static gboolean
|
2018-02-09 00:19:12 +00:00
|
|
|
mplog_seek_read(wtap *wth, gint64 seek_off, wtap_rec *rec, Buffer *buf,
|
|
|
|
int *err, gchar **err_info)
|
2016-02-09 15:16:15 +00:00
|
|
|
{
|
|
|
|
if (-1 == file_seek(wth->random_fh, seek_off, SEEK_SET, err))
|
|
|
|
return FALSE;
|
|
|
|
|
2018-02-09 00:19:12 +00:00
|
|
|
if (!mplog_read_packet(wth->random_fh, rec, buf, err, err_info)) {
|
2016-04-19 01:18:12 +00:00
|
|
|
/* Even if we got an immediate EOF, that's an error. */
|
|
|
|
if (*err == 0)
|
|
|
|
*err = WTAP_ERR_SHORT_READ;
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
return TRUE;
|
2016-02-09 15:16:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-04-19 10:04:28 +00:00
|
|
|
wtap_open_return_val mplog_open(wtap *wth, int *err, gchar **err_info)
|
2016-02-09 15:16:15 +00:00
|
|
|
{
|
|
|
|
gboolean ok;
|
2016-04-19 01:30:09 +00:00
|
|
|
guint8 magic[6];
|
2016-02-09 15:16:15 +00:00
|
|
|
|
2016-04-19 01:30:09 +00:00
|
|
|
ok = wtap_read_bytes(wth->fh, magic, 6, err, err_info);
|
2016-04-19 01:27:39 +00:00
|
|
|
if (!ok) {
|
|
|
|
if (*err != WTAP_ERR_SHORT_READ)
|
|
|
|
return WTAP_OPEN_ERROR;
|
2016-02-09 15:16:15 +00:00
|
|
|
return WTAP_OPEN_NOT_MINE;
|
2016-04-19 01:27:39 +00:00
|
|
|
}
|
2016-04-19 01:30:09 +00:00
|
|
|
if (memcmp(magic, "MPCSII", 6) != 0)
|
2016-02-09 15:16:15 +00:00
|
|
|
return WTAP_OPEN_NOT_MINE;
|
|
|
|
|
|
|
|
wth->file_encap = WTAP_ENCAP_ISO14443;
|
|
|
|
wth->snapshot_length = 0;
|
|
|
|
wth->file_tsprec = WTAP_TSPREC_NSEC;
|
|
|
|
|
|
|
|
wth->priv = NULL;
|
|
|
|
|
|
|
|
wth->subtype_read = mplog_read;
|
|
|
|
wth->subtype_seek_read = mplog_seek_read;
|
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 = mplog_file_type_subtype;
|
2016-02-09 15:16:15 +00:00
|
|
|
|
|
|
|
/* skip the file header */
|
|
|
|
if (-1 == file_seek(wth->fh, 0x80, SEEK_SET, err))
|
|
|
|
return WTAP_OPEN_ERROR;
|
|
|
|
|
|
|
|
*err = 0;
|
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);
|
|
|
|
|
2016-02-09 15:16:15 +00:00
|
|
|
return WTAP_OPEN_MINE;
|
|
|
|
}
|
|
|
|
|
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 mplog_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 mplog_info = {
|
|
|
|
"Micropross mplog", "mplog", "mplog", 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(mplog_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_mplog(void)
|
|
|
|
{
|
2021-02-24 03:10:35 +00:00
|
|
|
mplog_file_type_subtype = wtap_register_file_type_subtype(&mplog_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("MPLOG",
|
|
|
|
mplog_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
|
|
|
}
|
2016-02-09 15:16:15 +00:00
|
|
|
|
|
|
|
/*
|
2019-07-26 18:43:17 +00:00
|
|
|
* Editor modelines - https://www.wireshark.org/tools/modelines.html
|
2016-02-09 15:16:15 +00:00
|
|
|
*
|
|
|
|
* Local variables:
|
|
|
|
* c-basic-offset: 4
|
|
|
|
* tab-width: 8
|
|
|
|
* indent-tabs-mode: nil
|
|
|
|
* End:
|
|
|
|
*
|
|
|
|
* vi: set shiftwidth=4 tabstop=8 expandtab:
|
|
|
|
* :indentSize=4:tabSize=8:noTabs=true:
|
|
|
|
*/
|