2001-10-18 20:29:56 +00:00
|
|
|
/* vms.c
|
|
|
|
*
|
|
|
|
* Wiretap Library
|
2003-01-17 23:54:19 +00:00
|
|
|
* Copyright (c) 2001 by Marc Milgram <ethereal@mmilgram.NOSPAMmail.net>
|
2001-10-18 20:29:56 +00:00
|
|
|
*
|
2018-02-07 11:26:45 +00:00
|
|
|
* SPDX-License-Identifier: GPL-2.0-or-later
|
2001-10-18 20:29:56 +00:00
|
|
|
*/
|
2002-03-04 00:25:35 +00:00
|
|
|
|
2002-03-25 21:15:54 +00:00
|
|
|
/* Notes:
|
|
|
|
* TCPIPtrace TCP fragments don't have the header line. So, we are never
|
|
|
|
* to look for that line for the first line of a packet except the first
|
|
|
|
* packet. This allows us to read fragmented packets. Define
|
|
|
|
* TCPIPTRACE_FRAGMENTS_HAVE_HEADER_LINE to expect the first line to be
|
|
|
|
* at the start of every packet.
|
|
|
|
*/
|
2001-10-18 20:29:56 +00:00
|
|
|
#include "config.h"
|
|
|
|
#include "wtap-int.h"
|
|
|
|
#include "vms.h"
|
|
|
|
#include "file_wrappers.h"
|
|
|
|
|
2016-09-06 15:58:43 +00:00
|
|
|
#include <wsutil/strtoi.h>
|
|
|
|
|
2001-10-18 20:29:56 +00:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
2003-05-20 20:17:03 +00:00
|
|
|
/* This module reads the output of the various VMS TCPIP trace utilities
|
|
|
|
* such as TCPIPTRACE, TCPTRACE and UCX$TRACE
|
|
|
|
*
|
|
|
|
* It was initially based on toshiba.c and refined with code from cosine.c
|
|
|
|
|
|
|
|
--------------------------------------------------------------------------------
|
|
|
|
Example TCPIPTRACE TCPTRACE output data:
|
2001-10-18 20:29:56 +00:00
|
|
|
|
|
|
|
TCPIPtrace full display RCV packet 8 at 10-JUL-2001 14:54:19.56
|
|
|
|
|
|
|
|
IP Version = 4, IHL = 5, TOS = 00, Total Length = 84 = ^x0054
|
|
|
|
IP Identifier = ^x178F, Flags (0=0,DF=0,MF=0),
|
|
|
|
Fragment Offset = 0 = ^x0000, Calculated Offset = 0 = ^x0000
|
|
|
|
IP TTL = 64 = ^x40, Protocol = 17 = ^x11, Header Checksum = ^x4C71
|
|
|
|
IP Source Address = 10.12.1.80
|
|
|
|
IP Destination Address = 10.12.1.50
|
|
|
|
|
|
|
|
UDP Source Port = 731, UDP Destination Port = 111
|
|
|
|
UDP Header and Datagram Length = 64 = ^x0040, Checksum = ^xB6C0
|
|
|
|
|
|
|
|
50010C0A 714C1140 00008F17 54000045 0000 E..T....@.Lq...P
|
|
|
|
27E54C3C | C0B64000 6F00DB02 | 32010C0A 0010 ...2...o.@..<L.'
|
|
|
|
02000000 A0860100 02000000 00000000 0020 ................
|
|
|
|
00000000 00000000 00000000 03000000 0030 ................
|
|
|
|
06000000 01000000 A5860100 00000000 0040 ................
|
|
|
|
00000000 0050 ....
|
2003-05-20 20:17:03 +00:00
|
|
|
--------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
Example UCX$TRACE output data:
|
2001-10-18 20:29:56 +00:00
|
|
|
|
2013-02-26 04:42:26 +00:00
|
|
|
UCX INTERnet trace RCV packet seq # = 1 at 14-MAY-2003 11:32:10.93
|
2003-05-19 20:58:18 +00:00
|
|
|
|
2013-02-26 04:42:26 +00:00
|
|
|
IP Version = 4, IHL = 5, TOS = 00, Total Length = 583 = ^x0247
|
|
|
|
IP Identifier = ^x702E, Flags (0=0,DF=0,MF=0),
|
|
|
|
Fragment Offset = 0 = ^x0000, Calculated Offset = 0 = ^x0000
|
|
|
|
IP TTL = 128 = ^x80, Protocol = 17 = ^x11, Header Checksum = ^x70EC
|
|
|
|
IP Source Address = 10.20.4.159
|
|
|
|
IP Destination Address = 10.20.4.255
|
2003-05-19 20:58:18 +00:00
|
|
|
|
2013-02-26 04:42:26 +00:00
|
|
|
UDP Source Port = 138, UDP Destination Port = 138
|
|
|
|
UDP Header and Datagram Length = 563 = ^x0233, Checksum = ^xB913
|
2003-05-19 20:58:18 +00:00
|
|
|
|
|
|
|
9F04140A 70EC1180 0000702E 47020045 0000 E..G.p.....p....
|
|
|
|
B1B80E11 | B9133302 8A008A00 | FF04140A 0010 .........3......
|
|
|
|
46484648 45200000 1D028A00 9F04140A 0020 ...........EHFHF
|
|
|
|
43414341 4341434D 454D4546 45454550 0030 PEEEFEMEMCACACAC
|
|
|
|
|
2003-05-20 20:17:03 +00:00
|
|
|
--------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
Alternate UCX$TRACE type output data:
|
|
|
|
|
|
|
|
TCPIP INTERnet trace RCV packet seq # = 1 at 23-OCT-1998 15:19:33.29
|
|
|
|
|
|
|
|
IP Version = 4, IHL = 5, TOS = 00, Total Length = 217 = ^x00D9
|
|
|
|
IP Identifier = ^x0065, Flags (0=0,DF=0,MF=0),
|
|
|
|
Fragment Offset = 0 = ^x0000, Calculated Offset = 0 = ^x0000
|
|
|
|
IP TTL = 32 = ^x20, Protocol = 17 = ^x11, Header Checksum = ^x8F6C
|
|
|
|
IP Source Address = 16.20.168.93
|
|
|
|
IP Destination Address = 16.20.255.255
|
|
|
|
|
|
|
|
UDP Source Port = 138, UDP Destination Port = 138
|
|
|
|
UDP Header and Datagram Length = 197 = ^x00C5, Checksum = ^x0E77
|
|
|
|
|
|
|
|
5DA81410 8F6C1120 00000065 D9000045 0000 E...awe.....l....]
|
|
|
|
| 0E77C500 8A008A00 | FFFF1410 0010 ..........w.
|
|
|
|
|
|
|
|
--------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
The only difference between the utilities is the Packet header line, primarily
|
|
|
|
the utility identifier and the packet sequence formats.
|
|
|
|
|
2020-10-10 23:42:05 +00:00
|
|
|
There appear to be 2 formats for packet sequencing
|
2003-05-20 20:17:03 +00:00
|
|
|
|
|
|
|
Format 1:
|
|
|
|
|
|
|
|
... packet nn at DD-MMM-YYYY hh:mm:ss.ss
|
|
|
|
|
|
|
|
Format 2:
|
|
|
|
|
|
|
|
... packet seq # = nn at DD-MMM-YYYY hh:mm:ss.ss
|
|
|
|
|
2013-06-17 21:18:47 +00:00
|
|
|
If there are other formats then code will have to be written in parse_vms_packet()
|
2003-05-20 20:17:03 +00:00
|
|
|
to handle them.
|
2003-05-19 20:58:18 +00:00
|
|
|
|
2001-10-18 20:29:56 +00:00
|
|
|
--------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
2003-05-20 20:17:03 +00:00
|
|
|
/* Magic text to check for VMS-ness of file using possible utility names
|
|
|
|
*
|
2003-05-19 20:58:18 +00:00
|
|
|
*/
|
2015-01-02 00:45:22 +00:00
|
|
|
#define VMS_HDR_MAGIC_STR1 "TCPIPtrace"
|
|
|
|
#define VMS_HDR_MAGIC_STR2 "TCPtrace"
|
|
|
|
#define VMS_HDR_MAGIC_STR3 "INTERnet trace"
|
2001-10-18 20:29:56 +00:00
|
|
|
|
|
|
|
/* Magic text for start of packet */
|
2015-01-02 00:45:22 +00:00
|
|
|
#define VMS_REC_MAGIC_STR1 VMS_HDR_MAGIC_STR1
|
|
|
|
#define VMS_REC_MAGIC_STR2 VMS_HDR_MAGIC_STR2
|
|
|
|
#define VMS_REC_MAGIC_STR3 VMS_HDR_MAGIC_STR3
|
2003-05-20 20:17:03 +00:00
|
|
|
|
|
|
|
#define VMS_HEADER_LINES_TO_CHECK 200
|
|
|
|
#define VMS_LINE_LENGTH 240
|
2001-10-18 20:29:56 +00:00
|
|
|
|
2019-04-05 01:56:27 +00:00
|
|
|
static gboolean vms_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 vms_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,
|
|
|
|
long byte_offset, int in_off, int remaining_bytes);
|
2018-02-09 00:19:12 +00:00
|
|
|
static gboolean parse_vms_packet(FILE_T fh, wtap_rec *rec,
|
2013-06-17 21:18:47 +00:00
|
|
|
Buffer *buf, int *err, gchar **err_info);
|
2001-10-18 20:29:56 +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 vms_file_type_subtype = -1;
|
|
|
|
|
|
|
|
void register_vms(void);
|
|
|
|
|
2002-03-25 21:15:54 +00:00
|
|
|
#ifdef TCPIPTRACE_FRAGMENTS_HAVE_HEADER_LINE
|
2001-10-18 20:29:56 +00:00
|
|
|
/* Seeks to the beginning of the next packet, and returns the
|
2012-12-27 22:59:39 +00:00
|
|
|
byte offset. Returns -1 on failure, and sets "*err" to the error
|
|
|
|
and sets "*err_info" to null or an additional error string. */
|
2014-05-09 05:18:49 +00:00
|
|
|
static long vms_seek_next_packet(wtap *wth, int *err, gchar **err_info)
|
2001-10-18 20:29:56 +00:00
|
|
|
{
|
2012-12-27 22:59:39 +00:00
|
|
|
long cur_off;
|
|
|
|
char buf[VMS_LINE_LENGTH];
|
2013-02-26 04:42:26 +00:00
|
|
|
|
2012-12-27 22:59:39 +00:00
|
|
|
while (1) {
|
2014-05-09 05:18:49 +00:00
|
|
|
cur_off = file_tell(wth->fh);
|
2012-12-27 22:59:39 +00:00
|
|
|
if (cur_off == -1) {
|
|
|
|
/* Error */
|
2014-05-09 05:18:49 +00:00
|
|
|
*err = file_error(wth->fh, err_info);
|
2012-12-27 22:59:39 +00:00
|
|
|
return -1;
|
|
|
|
}
|
2014-05-09 05:18:49 +00:00
|
|
|
if (file_gets(buf, sizeof(buf), wth->fh) == NULL) {
|
2012-12-27 22:59:39 +00:00
|
|
|
/* EOF or error. */
|
2014-05-09 05:18:49 +00:00
|
|
|
*err = file_error(wth->fh, err_info);
|
2012-12-27 22:59:39 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (strstr(buf, VMS_REC_MAGIC_STR1) ||
|
|
|
|
strstr(buf, VMS_REC_MAGIC_STR2) ||
|
|
|
|
strstr(buf, VMS_REC_MAGIC_STR2)) {
|
2021-04-30 10:18:25 +00:00
|
|
|
(void) g_strlcpy(hdr, buf,VMS_LINE_LENGTH);
|
2012-12-27 22:59:39 +00:00
|
|
|
return cur_off;
|
|
|
|
}
|
2001-10-18 20:29:56 +00:00
|
|
|
}
|
2012-12-27 22:59:39 +00:00
|
|
|
return -1;
|
2001-10-18 20:29:56 +00:00
|
|
|
}
|
2002-03-25 21:15:54 +00:00
|
|
|
#endif /* TCPIPTRACE_FRAGMENTS_HAVE_HEADER_LINE */
|
2001-10-18 20:29:56 +00:00
|
|
|
|
|
|
|
/* Look through the first part of a file to see if this is
|
|
|
|
* a VMS 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.
|
2001-10-18 20:29:56 +00:00
|
|
|
*
|
2013-02-26 04:42:26 +00:00
|
|
|
* Leaves file handle at beginning of line that contains the VMS Magic
|
2001-10-18 20:29:56 +00:00
|
|
|
* identifier.
|
|
|
|
*/
|
2014-05-09 05:18:49 +00:00
|
|
|
static gboolean vms_check_file_type(wtap *wth, int *err, gchar **err_info)
|
2001-10-18 20:29:56 +00:00
|
|
|
{
|
2012-12-27 22:59:39 +00:00
|
|
|
char buf[VMS_LINE_LENGTH];
|
|
|
|
guint reclen, line;
|
|
|
|
gint64 mpos;
|
2013-02-26 04:42:26 +00:00
|
|
|
|
2012-12-27 22:59:39 +00:00
|
|
|
buf[VMS_LINE_LENGTH-1] = '\0';
|
2013-02-26 04:42:26 +00:00
|
|
|
|
2012-12-27 22:59:39 +00:00
|
|
|
for (line = 0; line < VMS_HEADER_LINES_TO_CHECK; line++) {
|
2014-05-09 05:18:49 +00:00
|
|
|
mpos = file_tell(wth->fh);
|
2012-12-27 22:59:39 +00:00
|
|
|
if (mpos == -1) {
|
|
|
|
/* Error. */
|
2014-05-09 05:18:49 +00:00
|
|
|
*err = file_error(wth->fh, err_info);
|
2012-12-27 22:59:39 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
2014-05-09 05:18:49 +00:00
|
|
|
if (file_gets(buf, VMS_LINE_LENGTH, wth->fh) == NULL) {
|
2012-12-27 22:59:39 +00:00
|
|
|
/* EOF or error. */
|
2014-05-09 05:18:49 +00:00
|
|
|
*err = file_error(wth->fh, err_info);
|
2012-12-27 22:59:39 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
2013-02-26 04:42:26 +00:00
|
|
|
|
2012-12-27 22:59:39 +00:00
|
|
|
reclen = (guint) strlen(buf);
|
|
|
|
if (reclen < strlen(VMS_HDR_MAGIC_STR1) ||
|
2013-02-26 04:42:26 +00:00
|
|
|
reclen < strlen(VMS_HDR_MAGIC_STR2) ||
|
2012-12-27 22:59:39 +00:00
|
|
|
reclen < strlen(VMS_HDR_MAGIC_STR3)) {
|
|
|
|
continue;
|
|
|
|
}
|
2013-02-26 04:42:26 +00:00
|
|
|
|
2012-12-27 22:59:39 +00:00
|
|
|
if (strstr(buf, VMS_HDR_MAGIC_STR1) ||
|
|
|
|
strstr(buf, VMS_HDR_MAGIC_STR2) ||
|
|
|
|
strstr(buf, VMS_HDR_MAGIC_STR3)) {
|
|
|
|
/* Go back to the beginning of this line, so we will
|
|
|
|
* re-read it. */
|
2014-05-09 05:18:49 +00:00
|
|
|
if (file_seek(wth->fh, mpos, SEEK_SET, err) == -1) {
|
2012-12-27 22:59:39 +00:00
|
|
|
/* Error. */
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
2001-10-18 20:29:56 +00:00
|
|
|
}
|
2012-12-27 22:59:39 +00:00
|
|
|
*err = 0;
|
|
|
|
return FALSE;
|
2001-10-18 20:29:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-10-09 23:44:15 +00:00
|
|
|
wtap_open_return_val vms_open(wtap *wth, int *err, gchar **err_info)
|
2001-10-18 20:29:56 +00:00
|
|
|
{
|
|
|
|
/* Look for VMS header */
|
2014-05-09 05:18:49 +00:00
|
|
|
if (!vms_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;
|
2001-10-18 20:29:56 +00:00
|
|
|
}
|
|
|
|
|
2014-05-09 05:18:49 +00:00
|
|
|
wth->file_encap = WTAP_ENCAP_RAW_IP;
|
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 = vms_file_type_subtype;
|
2014-05-09 05:18:49 +00:00
|
|
|
wth->snapshot_length = 0; /* not known */
|
|
|
|
wth->subtype_read = vms_read;
|
|
|
|
wth->subtype_seek_read = vms_seek_read;
|
2014-09-28 18:37:06 +00:00
|
|
|
wth->file_tsprec = WTAP_TSPREC_CSEC;
|
2001-10-18 20:29:56 +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-10-18 20:29:56 +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 vms_read(wtap *wth, wtap_rec *rec, Buffer *buf,
|
|
|
|
int *err, gchar **err_info, gint64 *data_offset)
|
2001-10-18 20:29:56 +00:00
|
|
|
{
|
2006-11-05 22:46:44 +00:00
|
|
|
gint64 offset = 0;
|
2001-10-18 20:29:56 +00:00
|
|
|
|
|
|
|
/* Find the next packet */
|
2002-03-25 21:15:54 +00:00
|
|
|
#ifdef TCPIPTRACE_FRAGMENTS_HAVE_HEADER_LINE
|
2012-12-27 22:59:39 +00:00
|
|
|
offset = vms_seek_next_packet(wth, err, err_info);
|
2002-03-25 21:15:54 +00:00
|
|
|
#else
|
2014-05-09 05:18:49 +00:00
|
|
|
offset = file_tell(wth->fh);
|
2002-03-25 21:15:54 +00:00
|
|
|
#endif
|
2011-01-03 09:17:20 +00:00
|
|
|
if (offset < 1) {
|
2014-05-09 05:18:49 +00:00
|
|
|
*err = file_error(wth->fh, err_info);
|
2014-05-23 10:50:02 +00:00
|
|
|
return FALSE;
|
2011-01-03 09:17:20 +00:00
|
|
|
}
|
2001-10-18 20:29:56 +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_vms_packet(wth->fh, rec, buf, err, err_info);
|
2001-10-18 20:29:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Used to read packets in random-access fashion */
|
2002-03-05 08:40:27 +00:00
|
|
|
static gboolean
|
2018-02-09 00:19:12 +00:00
|
|
|
vms_seek_read(wtap *wth, gint64 seek_off, wtap_rec *rec,
|
2014-01-02 20:47:21 +00:00
|
|
|
Buffer *buf, int *err, gchar **err_info)
|
2001-10-18 20:29:56 +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;
|
2001-10-18 20:29:56 +00:00
|
|
|
|
2018-02-09 00:19:12 +00:00
|
|
|
if (!parse_vms_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;
|
2001-10-18 20:29:56 +00:00
|
|
|
}
|
2014-05-23 10:50:02 +00:00
|
|
|
return TRUE;
|
2001-10-18 20:29:56 +00:00
|
|
|
}
|
|
|
|
|
2002-03-25 21:15:54 +00:00
|
|
|
/* isdumpline assumes that dump lines start with some non-alphanumerics
|
|
|
|
* followed by 4 hex numbers - each 8 digits long, each hex number followed
|
|
|
|
* by 3 spaces.
|
2001-10-18 20:29:56 +00:00
|
|
|
*/
|
|
|
|
static int
|
2004-01-24 16:48:12 +00:00
|
|
|
isdumpline( gchar *line )
|
2001-10-18 20:29:56 +00:00
|
|
|
{
|
2002-03-25 21:15:54 +00:00
|
|
|
int i, j;
|
2001-10-18 20:29:56 +00:00
|
|
|
|
2014-10-17 20:37:11 +00:00
|
|
|
while (*line && !g_ascii_isalnum(*line))
|
2015-01-02 00:45:22 +00:00
|
|
|
line++;
|
2001-10-18 20:29:56 +00:00
|
|
|
|
2002-03-25 21:15:54 +00:00
|
|
|
for (j=0; j<4; j++) {
|
2015-01-02 00:45:22 +00:00
|
|
|
for (i=0; i<8; i++, line++)
|
|
|
|
if (! g_ascii_isxdigit(*line))
|
|
|
|
return FALSE;
|
2001-10-18 20:29:56 +00:00
|
|
|
|
2015-01-02 00:45:22 +00:00
|
|
|
for (i=0; i<3; i++, line++)
|
|
|
|
if (*line != ' ')
|
|
|
|
return FALSE;
|
2002-03-25 21:15:54 +00:00
|
|
|
}
|
2001-10-18 20:29:56 +00:00
|
|
|
|
2014-10-17 20:37:11 +00:00
|
|
|
return g_ascii_isspace(*line);
|
2001-10-18 20:29:56 +00:00
|
|
|
}
|
|
|
|
|
2013-06-17 21:18:47 +00:00
|
|
|
/* Parses a packet record. */
|
2012-10-19 21:05:03 +00:00
|
|
|
static gboolean
|
2018-02-09 00:19:12 +00:00
|
|
|
parse_vms_packet(FILE_T fh, wtap_rec *rec, Buffer *buf, int *err, gchar **err_info)
|
2001-10-18 20:29:56 +00:00
|
|
|
{
|
2016-09-07 04:47:27 +00:00
|
|
|
char line[VMS_LINE_LENGTH + 1];
|
|
|
|
int num_items_scanned;
|
|
|
|
guint32 pkt_len = 0;
|
|
|
|
int pktnum;
|
|
|
|
int csec = 101;
|
2004-10-01 12:31:52 +00:00
|
|
|
struct tm tm;
|
2009-04-24 12:52:02 +00:00
|
|
|
char mon[4] = {'J', 'A', 'N', 0};
|
2016-09-07 04:47:27 +00:00
|
|
|
gchar *p;
|
2016-09-07 17:43:15 +00:00
|
|
|
const gchar *endp;
|
2009-04-24 12:16:01 +00:00
|
|
|
static const gchar months[] = "JANFEBMARAPRMAYJUNJULAUGSEPOCTNOVDEC";
|
2016-09-07 04:47:27 +00:00
|
|
|
guint32 i;
|
|
|
|
int offset = 0;
|
2013-06-17 21:18:47 +00:00
|
|
|
guint8 *pd;
|
2001-10-18 20:29:56 +00:00
|
|
|
|
2004-10-01 12:31:52 +00:00
|
|
|
tm.tm_year = 1970;
|
2011-03-25 23:45:48 +00:00
|
|
|
tm.tm_mon = 0;
|
|
|
|
tm.tm_mday = 1;
|
2004-10-01 12:31:52 +00:00
|
|
|
tm.tm_hour = 1;
|
|
|
|
tm.tm_min = 1;
|
|
|
|
tm.tm_sec = 1;
|
2001-10-18 20:29:56 +00:00
|
|
|
|
|
|
|
/* Skip lines until one starts with a hex number */
|
|
|
|
do {
|
|
|
|
if (file_gets(line, VMS_LINE_LENGTH, fh) == NULL) {
|
2011-04-21 09:41:52 +00:00
|
|
|
*err = file_error(fh, err_info);
|
2015-01-02 00:45:22 +00:00
|
|
|
if ((*err == 0) && (csec != 101)) {
|
|
|
|
*err = WTAP_ERR_SHORT_READ;
|
2001-10-18 20:29:56 +00:00
|
|
|
}
|
2012-10-19 21:05:03 +00:00
|
|
|
return FALSE;
|
2001-10-18 20:29:56 +00:00
|
|
|
}
|
2015-01-02 00:45:22 +00:00
|
|
|
line[VMS_LINE_LENGTH] = '\0';
|
|
|
|
|
|
|
|
if ((csec == 101) && (p = strstr(line, "packet ")) != NULL
|
|
|
|
&& (! strstr(line, "could not save "))) {
|
|
|
|
/* Find text in line starting with "packet ". */
|
|
|
|
|
|
|
|
/* First look for the Format 1 type sequencing */
|
|
|
|
num_items_scanned = sscanf(p,
|
|
|
|
"packet %9d at %2d-%3s-%4d %2d:%2d:%2d.%9d",
|
|
|
|
&pktnum, &tm.tm_mday, mon,
|
|
|
|
&tm.tm_year, &tm.tm_hour,
|
|
|
|
&tm.tm_min, &tm.tm_sec, &csec);
|
|
|
|
/* Next look for the Format 2 type sequencing */
|
|
|
|
if (num_items_scanned != 8) {
|
|
|
|
num_items_scanned = sscanf(p,
|
|
|
|
"packet seq # = %9d at %2d-%3s-%4d %2d:%2d:%2d.%9d",
|
|
|
|
&pktnum, &tm.tm_mday, mon,
|
|
|
|
&tm.tm_year, &tm.tm_hour,
|
|
|
|
&tm.tm_min, &tm.tm_sec, &csec);
|
|
|
|
}
|
|
|
|
/* if unknown format then exit with error */
|
|
|
|
/* We will need to add code to handle new format */
|
|
|
|
if (num_items_scanned != 8) {
|
|
|
|
*err = WTAP_ERR_BAD_FILE;
|
2016-06-06 02:24:47 +00:00
|
|
|
*err_info = g_strdup("vms: header line not valid");
|
2015-01-02 00:45:22 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if ( (! pkt_len) && (p = strstr(line, "Length"))) {
|
|
|
|
p += sizeof("Length ");
|
|
|
|
while (*p && ! g_ascii_isdigit(*p))
|
|
|
|
p++;
|
|
|
|
|
|
|
|
if ( !*p ) {
|
|
|
|
*err = WTAP_ERR_BAD_FILE;
|
2016-06-06 02:24:47 +00:00
|
|
|
*err_info = g_strdup("vms: Length field not valid");
|
2015-01-02 00:45:22 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2016-09-07 17:43:15 +00:00
|
|
|
if (!ws_strtou32(p, &endp, &pkt_len) || (*endp != '\0' && !g_ascii_isspace(*endp))) {
|
2016-09-06 15:58:43 +00:00
|
|
|
*err = WTAP_ERR_BAD_FILE;
|
2021-12-18 18:48:20 +00:00
|
|
|
*err_info = ws_strdup_printf("vms: Length field '%s' not valid", p);
|
2016-09-06 15:58:43 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
2015-01-02 00:45:22 +00:00
|
|
|
break;
|
|
|
|
}
|
2001-10-18 20:29:56 +00:00
|
|
|
} while (! isdumpline(line));
|
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
|
|
|
if (pkt_len > WTAP_MAX_PACKET_SIZE_STANDARD) {
|
2016-04-30 02:10:01 +00:00
|
|
|
/*
|
|
|
|
* Probably a corrupt capture file; return an error,
|
|
|
|
* so that our caller doesn't blow up trying to allocate
|
|
|
|
* space for an immensely-large packet.
|
|
|
|
*/
|
|
|
|
*err = WTAP_ERR_BAD_FILE;
|
2021-12-18 18:48:20 +00:00
|
|
|
*err_info = ws_strdup_printf("vms: File has %u-byte packet, bigger than maximum of %u",
|
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
|
|
|
pkt_len, WTAP_MAX_PACKET_SIZE_STANDARD);
|
2016-04-30 02:10:01 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
2001-10-18 20:29:56 +00:00
|
|
|
|
2012-10-19 21:05:03 +00:00
|
|
|
p = strstr(months, mon);
|
|
|
|
if (p)
|
2015-01-02 00:45:22 +00:00
|
|
|
tm.tm_mon = (int) (p - months) / 3;
|
2012-10-19 21:05:03 +00:00
|
|
|
tm.tm_year -= 1900;
|
|
|
|
tm.tm_isdst = -1;
|
2001-10-18 20:29:56 +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;
|
|
|
|
rec->ts.secs = mktime(&tm);
|
|
|
|
rec->ts.nsecs = csec * 10000000;
|
|
|
|
rec->rec_header.packet_header.caplen = pkt_len;
|
|
|
|
rec->rec_header.packet_header.len = pkt_len;
|
2012-10-19 21:05:03 +00:00
|
|
|
|
2013-06-16 00:20:00 +00:00
|
|
|
/* Make sure we have enough room for the packet */
|
2014-08-02 11:00:48 +00:00
|
|
|
ws_buffer_assure_space(buf, pkt_len);
|
|
|
|
pd = ws_buffer_start_ptr(buf);
|
2013-06-16 00:20:00 +00:00
|
|
|
|
|
|
|
/* Convert the ASCII hex dump to binary data */
|
2002-01-30 18:58:04 +00:00
|
|
|
for (i = 0; i < pkt_len; i += 16) {
|
2015-01-02 00:45:22 +00:00
|
|
|
if (file_gets(line, VMS_LINE_LENGTH, fh) == NULL) {
|
|
|
|
*err = file_error(fh, err_info);
|
|
|
|
if (*err == 0) {
|
|
|
|
*err = WTAP_ERR_SHORT_READ;
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
line[VMS_LINE_LENGTH] = '\0';
|
|
|
|
if (i == 0) {
|
|
|
|
while (! isdumpline(line)) { /* advance to start of hex data */
|
|
|
|
if (file_gets(line, VMS_LINE_LENGTH, fh) == NULL) {
|
|
|
|
*err = file_error(fh, err_info);
|
|
|
|
if (*err == 0) {
|
|
|
|
*err = WTAP_ERR_SHORT_READ;
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
line[VMS_LINE_LENGTH] = '\0';
|
|
|
|
}
|
|
|
|
while (line[offset] && !g_ascii_isxdigit(line[offset]))
|
|
|
|
offset++;
|
|
|
|
}
|
|
|
|
if (!parse_single_hex_dump_line(line, pd, i,
|
|
|
|
offset, pkt_len - i)) {
|
|
|
|
*err = WTAP_ERR_BAD_FILE;
|
2016-06-06 02:24:47 +00:00
|
|
|
*err_info = g_strdup("vms: hex dump not valid");
|
2015-01-02 00:45:22 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
2001-10-18 20:29:56 +00:00
|
|
|
}
|
2002-01-30 18:58:04 +00:00
|
|
|
/* Avoid TCPIPTRACE-W-BUFFERSFUL, TCPIPtrace could not save n packets.
|
2011-01-03 09:17:20 +00:00
|
|
|
* errors.
|
|
|
|
*
|
|
|
|
* XXX - when we support packet drop report information in the
|
|
|
|
* Wiretap API, we should parse those lines and return "n" as
|
|
|
|
* a packet drop count. */
|
|
|
|
if (!file_gets(line, VMS_LINE_LENGTH, fh)) {
|
2015-01-02 00:45:22 +00:00
|
|
|
*err = file_error(fh, err_info);
|
|
|
|
if (*err == 0) {
|
|
|
|
/* There is no next line, so there's no "TCPIPtrace could not
|
|
|
|
* save n packets" line; not an error. */
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
return FALSE;
|
2011-01-03 09:17:20 +00:00
|
|
|
}
|
2002-03-05 08:40:27 +00:00
|
|
|
return TRUE;
|
2001-10-18 20:29:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
1 2 3 4
|
|
|
|
0123456789012345678901234567890123456789012345
|
|
|
|
50010C0A A34C0640 00009017 2C000045 0000 E..,....@.L....P
|
|
|
|
00000000 14945E52 0A00DC02 | 32010C0A 0010 ...2....R^......
|
|
|
|
0000 | B4050402 00003496 00020260 0020 `....4........
|
|
|
|
*/
|
|
|
|
|
|
|
|
#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.
|
|
|
|
*
|
|
|
|
* Returns TRUE if good hex dump, FALSE if bad.
|
|
|
|
*/
|
|
|
|
static gboolean
|
|
|
|
parse_single_hex_dump_line(char* rec, guint8 *buf, long byte_offset,
|
2019-01-04 13:12:45 +00:00
|
|
|
int in_off, int remaining_bytes) {
|
2001-10-18 20:29:56 +00:00
|
|
|
|
|
|
|
int i;
|
|
|
|
char *s;
|
|
|
|
int value;
|
2009-04-24 12:16:01 +00:00
|
|
|
static const int offsets[16] = {39,37,35,33,28,26,24,22,17,15,13,11,6,4,2,0};
|
2001-10-18 20:29:56 +00:00
|
|
|
char lbuf[3] = {0,0,0};
|
2002-08-28 20:30:45 +00:00
|
|
|
|
2001-10-18 20:29:56 +00:00
|
|
|
|
|
|
|
/* Get the byte_offset directly from the record */
|
|
|
|
s = rec;
|
2015-01-02 00:45:22 +00:00
|
|
|
value = (int)strtoul(s + 45 + in_off, NULL, 16); /* XXX - error check? */
|
2002-08-28 20:30:45 +00:00
|
|
|
|
2001-10-18 20:29:56 +00:00
|
|
|
if (value != byte_offset) {
|
2015-01-02 00:45:22 +00:00
|
|
|
return FALSE;
|
2001-10-18 20:29:56 +00:00
|
|
|
}
|
|
|
|
|
2019-01-04 13:12:45 +00:00
|
|
|
if (remaining_bytes > 16)
|
|
|
|
remaining_bytes = 16;
|
2002-01-30 18:58:04 +00:00
|
|
|
|
2001-10-18 20:29:56 +00:00
|
|
|
/* Read the octets right to left, as that is how they are displayed
|
|
|
|
* in VMS.
|
|
|
|
*/
|
|
|
|
|
2019-01-04 13:12:45 +00:00
|
|
|
for (i = 0; i < remaining_bytes; i++) {
|
2015-01-02 00:45:22 +00:00
|
|
|
lbuf[0] = rec[offsets[i] + in_off];
|
|
|
|
lbuf[1] = rec[offsets[i] + 1 + in_off];
|
2001-10-18 20:29:56 +00:00
|
|
|
|
2015-01-02 00:45:22 +00:00
|
|
|
buf[byte_offset + i] = (guint8) strtoul(lbuf, NULL, 16);
|
2001-10-18 20:29:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
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 vms_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 vms_info = {
|
|
|
|
"TCPIPtrace (VMS)", "tcpiptrace", "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(vms_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_vms(void)
|
|
|
|
{
|
2021-02-24 03:10:35 +00:00
|
|
|
vms_file_type_subtype = wtap_register_file_type_subtype(&vms_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("VMS",
|
|
|
|
vms_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: 4
|
|
|
|
* tab-width: 8
|
|
|
|
* indent-tabs-mode: nil
|
|
|
|
* End:
|
|
|
|
*
|
|
|
|
* vi: set shiftwidth=4 tabstop=8 expandtab:
|
|
|
|
* :indentSize=4:tabSize=8:noTabs=true:
|
|
|
|
*/
|