2005-11-25 20:30:42 +00:00
|
|
|
/* iseries.c
|
|
|
|
*
|
|
|
|
* Wiretap Library
|
2011-05-29 19:36:21 +00:00
|
|
|
* Copyright (c) 2011 by Martin Warnes <Martin_Warnes@uk.ibm.com>
|
2005-11-25 20:30:42 +00:00
|
|
|
*
|
|
|
|
* Based on toshiba.c and vms.c
|
|
|
|
*
|
2018-02-07 11:26:45 +00:00
|
|
|
* SPDX-License-Identifier: GPL-2.0-or-later
|
2005-11-25 20:30:42 +00:00
|
|
|
*/
|
|
|
|
|
2006-03-27 16:09:47 +00:00
|
|
|
/*
|
2005-11-25 20:30:42 +00:00
|
|
|
* This module will read the contents of the iSeries (OS/400) Communication trace
|
2016-03-29 01:37:27 +00:00
|
|
|
* Both ASCII & Unicode (little-endian UCS-2) formatted traces are supported.
|
2005-11-25 20:30:42 +00:00
|
|
|
*
|
|
|
|
* iSeries Comms traces consist of a header page and a subsequent number of packet records
|
|
|
|
*
|
|
|
|
* The header page contains details on the options set during running of the trace,
|
|
|
|
* currently the following options are a requirement for this module:
|
|
|
|
*
|
|
|
|
* 1. Object protocol = ETHERNET (Default)
|
2016-03-29 01:37:27 +00:00
|
|
|
* 2. ASCII or Unicode file formats.
|
2006-03-27 16:09:47 +00:00
|
|
|
*
|
2020-10-10 23:42:05 +00:00
|
|
|
* The above can be achieved by passing option ASCII(*YES) with the trace command
|
2005-11-25 20:30:42 +00:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2006-03-27 16:09:47 +00:00
|
|
|
/* iSeries header page
|
2005-11-25 20:30:42 +00:00
|
|
|
|
|
|
|
COMMUNICATIONS TRACE Title: OS400 - OS400 trace 10/28/05 11:44:50 Page: 1
|
|
|
|
Trace Description . . . . . : OS400 - OS400 trace
|
|
|
|
Configuration object . . . . : ETH0
|
|
|
|
Type . . . . . . . . . . . . : 1 1=Line, 2=Network Interface
|
|
|
|
3=Network server
|
|
|
|
Object protocol . . . . . . : ETHERNET
|
|
|
|
Start date/Time . . . . . . : 10/28/05 11:43:00.341
|
|
|
|
End date/Time . . . . . . . : 10/28/05 11:44:22.148
|
|
|
|
Bytes collected . . . . . . : 11999
|
|
|
|
Buffer size . . . . . . . . : 2048 kilobytes
|
|
|
|
Data direction . . . . . . . : 3 1=Sent, 2=Received, 3=Both
|
|
|
|
Stop on buffer full . . . . : Y Y=Yes, N=No
|
|
|
|
Number of bytes to trace
|
|
|
|
Beginning bytes . . . . . : *MAX Value, *CALC, *MAX
|
|
|
|
Ending bytes . . . . . . : *CALC Value, *CALC
|
|
|
|
Controller name . . . . . . : *ALL *ALL, name
|
|
|
|
Data representation . . . . : 1 1=ASCII, 2=EBCDIC, 3=*CALC
|
|
|
|
Format SNA data only . . . . : N Y=Yes, N=No
|
|
|
|
Format RR, RNR commands . . : N Y=Yes, N=No
|
|
|
|
Format TCP/IP data only . . : Y Y=Yes, N=No
|
|
|
|
IP address . . . . . . . . : *ALL *ALL, address
|
|
|
|
IP address . . . . . . . . : *ALL *ALL, address
|
|
|
|
IP port . . . . . . . . . : *ALL *ALL, IP port
|
|
|
|
Format UI data only . . . . : N Y=Yes, N=No
|
|
|
|
Select Ethernet data . . . . : 3 1=802.3, 2=ETHV2, 3=Both
|
|
|
|
Format Broadcast data . . . : Y Y=Yes, N=No
|
|
|
|
*/
|
|
|
|
|
Redo the processing of lines in iSeries text packet dumps.
Process several different flavors of header lines the same: "IP Header",
"IPv6 Header", "ARP Header", "TCP Header", "UDP Header", "ICMP Header",
"ICMPv6 Hdr", "Option Hdr" - the hex data for all of them should be
included in the packet data. Process continuation lines if those
headers wrap over more than one line.
Do not assume, or require, that *any* of those be present; there is no
guarantee that "IP Header" or "IPv6 Header" will be present (there's at
least one IBM page showing a packet with "ARP Header" in a trace), and
there is no guarantee that "TCP Header" will be present (there are
traces with "UDP Header" and "ICMPv6 Hdr").
Do not impose limits, other than the overall line limit, on the amount
of hex data in header or data lines; there is no guarantee that, for
example, a TCP header is 20 bytes long (if there are TCP options, it
*will* have more than 20 bytes).
Make sure we have an even number of hex digits.
Set "caplen" to the actual number of bytes we've read, even if that's
less than the purported packet length.
svn path=/trunk/; revision=45626
2012-10-18 04:52:33 +00:00
|
|
|
/* iSeries IPv4 formatted packet records consist of a packet header line
|
|
|
|
* identifying the packet number, direction, size, timestamp,
|
|
|
|
* source/destination MAC addresses and packet type.
|
2005-11-25 20:30:42 +00:00
|
|
|
*
|
2020-10-10 23:42:05 +00:00
|
|
|
* Thereafter there will be a formatted display of the headers above
|
Redo the processing of lines in iSeries text packet dumps.
Process several different flavors of header lines the same: "IP Header",
"IPv6 Header", "ARP Header", "TCP Header", "UDP Header", "ICMP Header",
"ICMPv6 Hdr", "Option Hdr" - the hex data for all of them should be
included in the packet data. Process continuation lines if those
headers wrap over more than one line.
Do not assume, or require, that *any* of those be present; there is no
guarantee that "IP Header" or "IPv6 Header" will be present (there's at
least one IBM page showing a packet with "ARP Header" in a trace), and
there is no guarantee that "TCP Header" will be present (there are
traces with "UDP Header" and "ICMPv6 Hdr").
Do not impose limits, other than the overall line limit, on the amount
of hex data in header or data lines; there is no guarantee that, for
example, a TCP header is 20 bytes long (if there are TCP options, it
*will* have more than 20 bytes).
Make sure we have an even number of hex digits.
Set "caplen" to the actual number of bytes we've read, even if that's
less than the purported packet length.
svn path=/trunk/; revision=45626
2012-10-18 04:52:33 +00:00
|
|
|
* the link layer, such as ARP, IP, TCP, UDP, and ICMP (all but
|
|
|
|
* ICMP have either been seen in captures or on pages such as the ones
|
|
|
|
* at
|
2005-11-25 20:30:42 +00:00
|
|
|
*
|
Redo the processing of lines in iSeries text packet dumps.
Process several different flavors of header lines the same: "IP Header",
"IPv6 Header", "ARP Header", "TCP Header", "UDP Header", "ICMP Header",
"ICMPv6 Hdr", "Option Hdr" - the hex data for all of them should be
included in the packet data. Process continuation lines if those
headers wrap over more than one line.
Do not assume, or require, that *any* of those be present; there is no
guarantee that "IP Header" or "IPv6 Header" will be present (there's at
least one IBM page showing a packet with "ARP Header" in a trace), and
there is no guarantee that "TCP Header" will be present (there are
traces with "UDP Header" and "ICMPv6 Hdr").
Do not impose limits, other than the overall line limit, on the amount
of hex data in header or data lines; there is no guarantee that, for
example, a TCP header is 20 bytes long (if there are TCP options, it
*will* have more than 20 bytes).
Make sure we have an even number of hex digits.
Set "caplen" to the actual number of bytes we've read, even if that's
less than the purported packet length.
svn path=/trunk/; revision=45626
2012-10-18 04:52:33 +00:00
|
|
|
* http://www-912.ibm.com/s_dir/SLKBase.nsf/1ac66549a21402188625680b0002037e/e05fb0515bc3449686256ce600512c37?OpenDocument
|
2005-11-25 20:30:42 +00:00
|
|
|
*
|
Redo the processing of lines in iSeries text packet dumps.
Process several different flavors of header lines the same: "IP Header",
"IPv6 Header", "ARP Header", "TCP Header", "UDP Header", "ICMP Header",
"ICMPv6 Hdr", "Option Hdr" - the hex data for all of them should be
included in the packet data. Process continuation lines if those
headers wrap over more than one line.
Do not assume, or require, that *any* of those be present; there is no
guarantee that "IP Header" or "IPv6 Header" will be present (there's at
least one IBM page showing a packet with "ARP Header" in a trace), and
there is no guarantee that "TCP Header" will be present (there are
traces with "UDP Header" and "ICMPv6 Hdr").
Do not impose limits, other than the overall line limit, on the amount
of hex data in header or data lines; there is no guarantee that, for
example, a TCP header is 20 bytes long (if there are TCP options, it
*will* have more than 20 bytes).
Make sure we have an even number of hex digits.
Set "caplen" to the actual number of bytes we've read, even if that's
less than the purported packet length.
svn path=/trunk/; revision=45626
2012-10-18 04:52:33 +00:00
|
|
|
* and
|
|
|
|
*
|
|
|
|
* http://publib.boulder.ibm.com/infocenter/javasdk/v5r0/index.jsp?topic=%2Fcom.ibm.java.doc.diagnostics.50%2Fdiag%2Fproblem_determination%2Fi5os_perf_io_commstrace.html
|
|
|
|
*
|
|
|
|
* so we cannot assume that "IP Header" or "TCP Header" will appear). The
|
|
|
|
* formatted display includes lines that show the contents of some of the
|
|
|
|
* fields in the header, as well as hex strings dumps of the headers
|
|
|
|
* themselves, with tags such as "IP Header :", "ARP Header :",
|
|
|
|
* "TCP Header :", "UDP Header :", and (presumably) "ICMP Header:".
|
|
|
|
*
|
|
|
|
* If the packet contains data this is displayed as 4 groups of 16 hex digits
|
2020-10-10 23:42:05 +00:00
|
|
|
* followed by an ASCII representation of the data line.
|
Redo the processing of lines in iSeries text packet dumps.
Process several different flavors of header lines the same: "IP Header",
"IPv6 Header", "ARP Header", "TCP Header", "UDP Header", "ICMP Header",
"ICMPv6 Hdr", "Option Hdr" - the hex data for all of them should be
included in the packet data. Process continuation lines if those
headers wrap over more than one line.
Do not assume, or require, that *any* of those be present; there is no
guarantee that "IP Header" or "IPv6 Header" will be present (there's at
least one IBM page showing a packet with "ARP Header" in a trace), and
there is no guarantee that "TCP Header" will be present (there are
traces with "UDP Header" and "ICMPv6 Hdr").
Do not impose limits, other than the overall line limit, on the amount
of hex data in header or data lines; there is no guarantee that, for
example, a TCP header is 20 bytes long (if there are TCP options, it
*will* have more than 20 bytes).
Make sure we have an even number of hex digits.
Set "caplen" to the actual number of bytes we've read, even if that's
less than the purported packet length.
svn path=/trunk/; revision=45626
2012-10-18 04:52:33 +00:00
|
|
|
*
|
|
|
|
* Information from the packet header line, higher-level headers and, if
|
|
|
|
* available, data lines are extracted by the module for displaying.
|
2005-11-25 20:30:42 +00:00
|
|
|
*
|
2006-03-27 16:09:47 +00:00
|
|
|
*
|
|
|
|
Record Data Record Controller Destination Source Frame
|
|
|
|
Number S/R Length Timer Name MAC Address MAC Address Format
|
|
|
|
------ --- ------ --------------- ---------- ------------ ------------ ------
|
2005-11-25 20:30:42 +00:00
|
|
|
8 S 145 11:43:59.82956 0006299C14AE 0006299C14FE ETHV2 Type: 0800
|
|
|
|
Frame Type : IP DSCP: 0 ECN: 00-NECT Length: 145 Protocol: TCP Datagram ID: 388B
|
|
|
|
Src Addr: 10.20.144.150 Dest Addr: 10.20.144.151 Fragment Flags: DON'T,LAST
|
|
|
|
IP Header : 45000091388B40004006CC860A1490960A149097
|
|
|
|
IP Options : NONE
|
|
|
|
TCP . . . : Src Port: 6006,Unassigned Dest Port: 35366,Unassigned
|
|
|
|
SEQ Number: 2666470699 ('9EEF1D2B'X) ACK Number: 2142147535 ('7FAE93CF'X)
|
|
|
|
Code Bits: ACK PSH Window: 32648 TCP Option: NO OP
|
|
|
|
TCP Header : 17768A269EEF1D2B7FAE93CF80187F885B5600000101080A0517E0F805166DE0
|
|
|
|
Data . . . . . : 5443503200020010 0000004980000000 B800000080470103 01001E0000002000 *TCP2.......I*...*...*G........ .*
|
|
|
|
002F010080000004 0300800700C00600 4002008000000304 00800000060FB067 *./..*.....*..*..@..*.....*....*G*
|
|
|
|
FC276228786B3EB0 EF34F5F1D27EF8DF 20926820E7B322AA 739F1FB20D **'B(XK>**4***.** *H **"*S*.*. *
|
|
|
|
*/
|
|
|
|
|
Redo the processing of lines in iSeries text packet dumps.
Process several different flavors of header lines the same: "IP Header",
"IPv6 Header", "ARP Header", "TCP Header", "UDP Header", "ICMP Header",
"ICMPv6 Hdr", "Option Hdr" - the hex data for all of them should be
included in the packet data. Process continuation lines if those
headers wrap over more than one line.
Do not assume, or require, that *any* of those be present; there is no
guarantee that "IP Header" or "IPv6 Header" will be present (there's at
least one IBM page showing a packet with "ARP Header" in a trace), and
there is no guarantee that "TCP Header" will be present (there are
traces with "UDP Header" and "ICMPv6 Hdr").
Do not impose limits, other than the overall line limit, on the amount
of hex data in header or data lines; there is no guarantee that, for
example, a TCP header is 20 bytes long (if there are TCP options, it
*will* have more than 20 bytes).
Make sure we have an even number of hex digits.
Set "caplen" to the actual number of bytes we've read, even if that's
less than the purported packet length.
svn path=/trunk/; revision=45626
2012-10-18 04:52:33 +00:00
|
|
|
/* iSeries IPv6 formatted traces are similar to the IPv4 version above,
|
|
|
|
* except that the higher-level headers have "IPv6 Header:" and
|
|
|
|
* "ICMPv6 Hdr:", and data data is no longer output in groups of 16 hex
|
|
|
|
* digits.
|
|
|
|
*
|
2011-05-29 19:36:21 +00:00
|
|
|
|
|
|
|
Record Data Record Destination Source Frame
|
|
|
|
Number S/R Length Timer MAC Address MAC Address Format
|
|
|
|
------ --- ------ ------------ ------------ ------------ ------
|
|
|
|
218 S 1488 15:01:14.389 0011BC358680 00096B6BD918 ETHV2 Type: 86DD
|
|
|
|
IPv6 Data: Ver: 06 Traffic Class: 00 Flow Label: 000000
|
|
|
|
Payload Length: 1448 Next Header: 06,TCP Hop Limit: 64
|
|
|
|
Src Addr: fd00:0:0:20f2::122
|
|
|
|
Dest Addr: fd00:0:0:20a0::155
|
|
|
|
IPv6 Header: 6000000005A80640FD000000000020F20000000000000122FD000000000020A0
|
|
|
|
0000000000000155
|
|
|
|
TCP . . . : Src Port: 21246,Unassigned Dest Port: 13601,Unassigned
|
|
|
|
SEQ Number: 2282300877 ('880925CD'X) ACK Number: 3259003715 ('C2407343'X)
|
|
|
|
Code Bits: ACK Window: 65535 TCP Option: NO OP
|
|
|
|
TCP Header : 52FE3521880925CDC24073438010FFFFCFBB00000101080A0E15127000237A08
|
|
|
|
Data . . . . . : 54435032000200140000061880000000ECBEB867F0000000004CE640E6C1D9D5 *TCP2........*...***g*....L*@*****
|
|
|
|
C9D5C740E3C8C9E240C9E240E3C8C540E6C1D9D5C9D5C740C6C9C5D3C4404040 ****@****@**@***@*******@*****@@@*
|
|
|
|
4040404040404040404040404040404040404040404040404040404040404040 *@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*
|
|
|
|
*/
|
|
|
|
|
Redo the processing of lines in iSeries text packet dumps.
Process several different flavors of header lines the same: "IP Header",
"IPv6 Header", "ARP Header", "TCP Header", "UDP Header", "ICMP Header",
"ICMPv6 Hdr", "Option Hdr" - the hex data for all of them should be
included in the packet data. Process continuation lines if those
headers wrap over more than one line.
Do not assume, or require, that *any* of those be present; there is no
guarantee that "IP Header" or "IPv6 Header" will be present (there's at
least one IBM page showing a packet with "ARP Header" in a trace), and
there is no guarantee that "TCP Header" will be present (there are
traces with "UDP Header" and "ICMPv6 Hdr").
Do not impose limits, other than the overall line limit, on the amount
of hex data in header or data lines; there is no guarantee that, for
example, a TCP header is 20 bytes long (if there are TCP options, it
*will* have more than 20 bytes).
Make sure we have an even number of hex digits.
Set "caplen" to the actual number of bytes we've read, even if that's
less than the purported packet length.
svn path=/trunk/; revision=45626
2012-10-18 04:52:33 +00:00
|
|
|
/* iSeries unformatted packet record consist of the same header record as
|
|
|
|
* the formatted trace but all other records are simply unformatted data
|
|
|
|
* containing higher-level headers and packet data combined.
|
2005-11-25 20:30:42 +00:00
|
|
|
*
|
|
|
|
Record Data Record Controller Destination Source Frame Number Number Poll/
|
|
|
|
Number S/R Length Timer Name MAC Address MAC Address Format Command Sent Received Final DSAP SSAP
|
|
|
|
------ --- ------ --------------- ---------- ------------ ------------ ------ ------- ------ -------- ----- ---- ----
|
|
|
|
1 R 64 12:19:29.97108 000629ECF48E 0006D78E23C2 ETHV2 Type: 0800
|
|
|
|
Data . . . . . : 4500003C27954000 3A06CE3D9797440F 0A5964EAC4F50554 58C9915500000000 *E..<'*@.:.*=**D..YD***.TX**U....*
|
|
|
|
A00216D06A200000 020405B40402080A 1104B6C000000000 010303000B443BF1 **..*J .....*......**.........D;**
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
#include "wtap-int.h"
|
|
|
|
#include "iseries.h"
|
|
|
|
#include "file_wrappers.h"
|
|
|
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <errno.h>
|
|
|
|
|
2008-09-03 19:14:52 +00:00
|
|
|
#include <wsutil/str_util.h>
|
2016-09-07 13:15:57 +00:00
|
|
|
#include <wsutil/strtoi.h>
|
2008-09-03 19:14:52 +00:00
|
|
|
|
2012-04-22 18:44:10 +00:00
|
|
|
#define ISERIES_LINE_LENGTH 270
|
|
|
|
#define ISERIES_HDR_LINES_TO_CHECK 100
|
|
|
|
#define ISERIES_PKT_LINES_TO_CHECK 4
|
|
|
|
#define ISERIES_MAX_TRACE_LEN 99999999
|
|
|
|
#define ISERIES_FORMAT_ASCII 1
|
|
|
|
#define ISERIES_FORMAT_UNICODE 2
|
2005-11-25 20:30:42 +00:00
|
|
|
|
2016-03-29 01:37:27 +00:00
|
|
|
/*
|
|
|
|
* Magic strings - "COMMUNICATIONS TRACE", in ASCII and little-endian UCS-2.
|
|
|
|
*/
|
|
|
|
static const char iseries_hdr_magic_ascii[] = {
|
|
|
|
'C', 'O', 'M', 'M',
|
|
|
|
'U', 'N', 'I', 'C',
|
|
|
|
'A', 'T', 'I', 'O',
|
|
|
|
'N', 'S', ' ', 'T',
|
|
|
|
'R', 'A', 'C', 'E'
|
|
|
|
};
|
|
|
|
static const char iseries_hdr_magic_le_ucs_2[] = {
|
|
|
|
'C', 0x0, 'O', 0x0, 'M', 0x0, 'M', 0x0,
|
|
|
|
'U', 0x0, 'N', 0x0, 'I', 0x0, 'C', 0x0,
|
|
|
|
'A', 0x0, 'T', 0x0, 'I', 0x0, 'O', 0x0,
|
|
|
|
'N', 0x0, 'S', 0x0, ' ', 0x0, 'T', 0x0,
|
|
|
|
'R', 0x0, 'A', 0x0, 'C', 0x0, 'E', 0x0
|
|
|
|
};
|
|
|
|
|
2010-02-24 08:39:19 +00:00
|
|
|
typedef struct {
|
2012-04-22 18:44:10 +00:00
|
|
|
gboolean have_date; /* TRUE if we found a capture start date */
|
|
|
|
int year, month, day; /* The start date */
|
|
|
|
int format; /* Trace format type */
|
2010-02-24 08:39:19 +00:00
|
|
|
} iseries_t;
|
|
|
|
|
2019-04-05 01:56:27 +00:00
|
|
|
static gboolean iseries_read (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 iseries_seek_read (wtap * wth, gint64 seek_off,
|
2018-02-09 00:19:12 +00:00
|
|
|
wtap_rec *rec,
|
2014-01-02 20:47:21 +00:00
|
|
|
Buffer * buf, int *err, gchar ** err_info);
|
2014-05-09 05:18:49 +00:00
|
|
|
static gboolean iseries_check_file_type (wtap * wth, int *err, gchar **err_info,
|
2012-04-20 01:43:12 +00:00
|
|
|
int format);
|
2014-05-09 05:18:49 +00:00
|
|
|
static gint64 iseries_seek_next_packet (wtap * wth, int *err, gchar **err_info);
|
2014-05-23 10:50:02 +00:00
|
|
|
static gboolean iseries_parse_packet (wtap * wth, FILE_T fh,
|
2018-02-09 00:19:12 +00:00
|
|
|
wtap_rec *rec,
|
2014-05-23 10:50:02 +00:00
|
|
|
Buffer * buf, int *err, gchar ** err_info);
|
2006-03-22 17:37:04 +00:00
|
|
|
static int iseries_UNICODE_to_ASCII (guint8 * buf, guint bytes);
|
2008-05-29 23:30:51 +00:00
|
|
|
static gboolean iseries_parse_hex_string (const char * ascii, guint8 * buf,
|
2012-12-26 06:14:44 +00:00
|
|
|
size_t len);
|
2006-03-22 17:37:04 +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 iseries_file_type_subtype = -1;
|
|
|
|
static int iseries_unicode_file_type_subtype = -1;
|
|
|
|
|
|
|
|
void register_iseries(void);
|
|
|
|
|
2016-01-20 01:23:16 +00:00
|
|
|
/*
|
|
|
|
* XXX - it would probably be cleaner to use a UCS-2 flavor of file_gets(),
|
|
|
|
* rather than file_gets(), if we're reading a UCS-2 file.
|
|
|
|
*/
|
2014-10-09 23:44:15 +00:00
|
|
|
wtap_open_return_val
|
2014-05-09 05:18:49 +00:00
|
|
|
iseries_open (wtap * wth, int *err, gchar ** err_info)
|
2005-11-25 20:30:42 +00:00
|
|
|
{
|
2011-05-29 19:36:21 +00:00
|
|
|
gint offset;
|
|
|
|
char magic[ISERIES_LINE_LENGTH];
|
2006-03-22 17:37:04 +00:00
|
|
|
|
2005-11-25 20:30:42 +00:00
|
|
|
/*
|
2006-03-27 16:09:47 +00:00
|
|
|
* Check that file starts with a valid iSeries COMMS TRACE header
|
2011-05-29 19:36:21 +00:00
|
|
|
* by scanning for it in the first line
|
2005-11-25 20:30:42 +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 (wth->fh, &magic, sizeof magic, err, err_info))
|
2006-03-22 17:37:04 +00:00
|
|
|
{
|
2014-10-07 08:05:17 +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;
|
2005-11-25 20:30:42 +00:00
|
|
|
}
|
2006-03-22 17:37:04 +00:00
|
|
|
|
2012-04-22 18:44:10 +00:00
|
|
|
/*
|
2016-03-29 01:37:27 +00:00
|
|
|
* Check if this is a little-endian UCS-2 Unicode formatted file by scanning
|
|
|
|
* for the magic string
|
2011-05-29 19:36:21 +00:00
|
|
|
*/
|
|
|
|
offset=0;
|
2016-03-29 01:37:27 +00:00
|
|
|
while ((unsigned int)offset < (ISERIES_LINE_LENGTH - (sizeof iseries_hdr_magic_le_ucs_2)))
|
2012-04-20 01:43:12 +00:00
|
|
|
{
|
2016-03-29 01:37:27 +00:00
|
|
|
if (memcmp (magic + offset, iseries_hdr_magic_le_ucs_2, sizeof iseries_hdr_magic_le_ucs_2) == 0) {
|
2014-05-09 05:18:49 +00:00
|
|
|
if (file_seek (wth->fh, 0, SEEK_SET, err) == -1)
|
2012-04-22 18:44:10 +00:00
|
|
|
{
|
2016-03-29 01:37:27 +00:00
|
|
|
return WTAP_OPEN_ERROR;
|
2012-04-22 18:44:10 +00:00
|
|
|
}
|
|
|
|
/*
|
|
|
|
* Do some basic sanity checking to ensure we can handle the
|
|
|
|
* contents of this trace
|
|
|
|
*/
|
2014-05-09 05:18:49 +00:00
|
|
|
if (!iseries_check_file_type (wth, err, err_info, ISERIES_FORMAT_UNICODE))
|
2012-04-22 18:44:10 +00:00
|
|
|
{
|
|
|
|
if (*err == 0)
|
2014-10-09 23:44:15 +00:00
|
|
|
return WTAP_OPEN_NOT_MINE;
|
2012-04-22 18:44:10 +00:00
|
|
|
else
|
2014-10-09 23:44:15 +00:00
|
|
|
return WTAP_OPEN_ERROR;
|
2012-04-22 18:44:10 +00:00
|
|
|
}
|
|
|
|
|
2014-05-09 05:18:49 +00:00
|
|
|
wth->file_encap = WTAP_ENCAP_ETHERNET;
|
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 = iseries_unicode_file_type_subtype;
|
2014-05-09 05:18:49 +00:00
|
|
|
wth->snapshot_length = 0;
|
|
|
|
wth->subtype_read = iseries_read;
|
|
|
|
wth->subtype_seek_read = iseries_seek_read;
|
2014-09-28 18:37:06 +00:00
|
|
|
wth->file_tsprec = WTAP_TSPREC_USEC;
|
2012-04-22 18:44:10 +00:00
|
|
|
|
2014-05-09 05:18:49 +00:00
|
|
|
if (file_seek (wth->fh, 0, SEEK_SET, err) == -1)
|
2012-04-22 18:44:10 +00:00
|
|
|
{
|
2016-01-17 16:20:34 +00:00
|
|
|
return WTAP_OPEN_ERROR;
|
2012-04-22 18:44:10 +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;
|
2012-04-22 18:44:10 +00:00
|
|
|
}
|
2012-04-20 01:43:12 +00:00
|
|
|
offset += 1;
|
|
|
|
}
|
2006-03-22 17:37:04 +00:00
|
|
|
|
2012-04-22 18:44:10 +00:00
|
|
|
/*
|
|
|
|
* Check if this is a ASCII formatted file by scanning for the magic string
|
|
|
|
*/
|
|
|
|
offset=0;
|
2016-03-29 01:37:27 +00:00
|
|
|
while ((unsigned int)offset < (ISERIES_LINE_LENGTH - sizeof iseries_hdr_magic_ascii))
|
2012-04-22 18:44:10 +00:00
|
|
|
{
|
2016-03-29 01:37:27 +00:00
|
|
|
if (memcmp (magic + offset, iseries_hdr_magic_ascii, sizeof iseries_hdr_magic_ascii) == 0)
|
2012-04-22 18:44:10 +00:00
|
|
|
{
|
2014-05-09 05:18:49 +00:00
|
|
|
if (file_seek (wth->fh, 0, SEEK_SET, err) == -1)
|
2012-04-22 18:44:10 +00:00
|
|
|
{
|
2016-03-29 01:37:27 +00:00
|
|
|
return WTAP_OPEN_ERROR;
|
2012-04-22 18:44:10 +00:00
|
|
|
}
|
|
|
|
/*
|
|
|
|
* Do some basic sanity checking to ensure we can handle the
|
|
|
|
* contents of this trace
|
|
|
|
*/
|
2014-05-09 05:18:49 +00:00
|
|
|
if (!iseries_check_file_type (wth, err, err_info, ISERIES_FORMAT_ASCII))
|
2012-04-22 18:44:10 +00:00
|
|
|
{
|
|
|
|
if (*err == 0)
|
2014-10-09 23:44:15 +00:00
|
|
|
return WTAP_OPEN_NOT_MINE;
|
2012-04-22 18:44:10 +00:00
|
|
|
else
|
2014-10-09 23:44:15 +00:00
|
|
|
return WTAP_OPEN_ERROR;
|
2012-04-22 18:44:10 +00:00
|
|
|
}
|
|
|
|
|
2014-05-09 05:18:49 +00:00
|
|
|
wth->file_encap = WTAP_ENCAP_ETHERNET;
|
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 = iseries_file_type_subtype;
|
2014-05-09 05:18:49 +00:00
|
|
|
wth->snapshot_length = 0;
|
|
|
|
wth->subtype_read = iseries_read;
|
|
|
|
wth->subtype_seek_read = iseries_seek_read;
|
2014-09-28 18:37:06 +00:00
|
|
|
wth->file_tsprec = WTAP_TSPREC_USEC;
|
2012-04-22 18:44:10 +00:00
|
|
|
|
2014-05-09 05:18:49 +00:00
|
|
|
if (file_seek (wth->fh, 0, SEEK_SET, err) == -1)
|
2012-04-22 18:44:10 +00:00
|
|
|
{
|
2016-03-29 01:37:27 +00:00
|
|
|
return WTAP_OPEN_ERROR;
|
2012-04-22 18:44:10 +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;
|
2012-04-22 18:44:10 +00:00
|
|
|
}
|
|
|
|
offset += 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Neither ASCII or UNICODE so not supported */
|
2014-10-09 23:44:15 +00:00
|
|
|
return WTAP_OPEN_NOT_MINE;
|
2012-04-22 18:44:10 +00:00
|
|
|
}
|
2005-11-25 20:30:42 +00:00
|
|
|
|
|
|
|
/*
|
2006-03-27 16:09:47 +00:00
|
|
|
* Do some basic sanity checking to ensure we can handle the
|
2005-11-25 20:30:42 +00:00
|
|
|
* contents of this trace by checking the header page for
|
2020-10-10 23:42:05 +00:00
|
|
|
* requisite requirements and additional information.
|
2005-11-25 20:30:42 +00:00
|
|
|
*/
|
2006-03-22 17:37:04 +00:00
|
|
|
static gboolean
|
2014-05-09 05:18:49 +00:00
|
|
|
iseries_check_file_type (wtap * wth, int *err, gchar **err_info, int format)
|
2005-11-25 20:30:42 +00:00
|
|
|
{
|
2016-01-17 16:03:50 +00:00
|
|
|
gboolean is_iseries = FALSE;
|
2012-04-22 18:44:10 +00:00
|
|
|
guint line;
|
|
|
|
int num_items_scanned;
|
Redo the processing of lines in iSeries text packet dumps.
Process several different flavors of header lines the same: "IP Header",
"IPv6 Header", "ARP Header", "TCP Header", "UDP Header", "ICMP Header",
"ICMPv6 Hdr", "Option Hdr" - the hex data for all of them should be
included in the packet data. Process continuation lines if those
headers wrap over more than one line.
Do not assume, or require, that *any* of those be present; there is no
guarantee that "IP Header" or "IPv6 Header" will be present (there's at
least one IBM page showing a packet with "ARP Header" in a trace), and
there is no guarantee that "TCP Header" will be present (there are
traces with "UDP Header" and "ICMPv6 Hdr").
Do not impose limits, other than the overall line limit, on the amount
of hex data in header or data lines; there is no guarantee that, for
example, a TCP header is 20 bytes long (if there are TCP options, it
*will* have more than 20 bytes).
Make sure we have an even number of hex digits.
Set "caplen" to the actual number of bytes we've read, even if that's
less than the purported packet length.
svn path=/trunk/; revision=45626
2012-10-18 04:52:33 +00:00
|
|
|
char buf[ISERIES_LINE_LENGTH], protocol[9];
|
2010-02-24 08:39:19 +00:00
|
|
|
iseries_t *iseries;
|
2005-11-25 20:30:42 +00:00
|
|
|
|
|
|
|
/* Save trace format for passing between packets */
|
2020-12-21 02:30:28 +00:00
|
|
|
iseries = g_new(iseries_t, 1);
|
2012-04-22 18:44:10 +00:00
|
|
|
iseries->have_date = FALSE;
|
|
|
|
iseries->format = format;
|
2005-11-25 20:30:42 +00:00
|
|
|
|
2006-03-22 17:37:04 +00:00
|
|
|
for (line = 0; line < ISERIES_HDR_LINES_TO_CHECK; line++)
|
|
|
|
{
|
2016-01-17 16:03:50 +00:00
|
|
|
memset(buf, 0x0, sizeof(buf));
|
2014-05-09 05:18:49 +00:00
|
|
|
if (file_gets (buf, ISERIES_LINE_LENGTH, wth->fh) == NULL)
|
2012-04-20 01:43:12 +00:00
|
|
|
{
|
|
|
|
/* EOF or error. */
|
2014-05-09 05:18:49 +00:00
|
|
|
*err = file_error (wth->fh, err_info);
|
Do not call wtap_file_read_unknown_bytes() or
wtap_file_read_expected_bytes() from an open routine - open routines are
supposed to return -1 on error, 0 if the file doesn't appear to be a
file of the specified type, or 1 if the file does appear to be a file of
the specified type, but those macros will cause the caller to return
FALSE on errors (so that, even if there's an I/O error, it reports "the
file isn't a file of the specified type" rather than "we got an error
trying to read the file").
When doing reads in an open routine before we've concluded that the file
is probably of the right type, return 0, rather than -1, if we get
WTAP_ERR_SHORT_READ - if we don't have enough data to check whether a
file is of a given type, we should keep trying other types, not give up.
For reads done *after* we've concluded the file is probably of the right
type, if a read doesn't return the number of bytes we asked for, but
returns an error of 0, return WTAP_ERR_SHORT_READ - the file is
apparently cut short.
For NetMon and NetXRay/Windows Sniffer files, use a #define for the
magic number size, and use that for both magic numbers.
svn path=/trunk/; revision=46803
2012-12-27 12:19:25 +00:00
|
|
|
if (*err == WTAP_ERR_SHORT_READ)
|
2012-04-20 01:43:12 +00:00
|
|
|
*err = 0;
|
2016-01-17 16:03:50 +00:00
|
|
|
break;
|
2012-04-20 01:43:12 +00:00
|
|
|
}
|
Do not call wtap_file_read_unknown_bytes() or
wtap_file_read_expected_bytes() from an open routine - open routines are
supposed to return -1 on error, 0 if the file doesn't appear to be a
file of the specified type, or 1 if the file does appear to be a file of
the specified type, but those macros will cause the caller to return
FALSE on errors (so that, even if there's an I/O error, it reports "the
file isn't a file of the specified type" rather than "we got an error
trying to read the file").
When doing reads in an open routine before we've concluded that the file
is probably of the right type, return 0, rather than -1, if we get
WTAP_ERR_SHORT_READ - if we don't have enough data to check whether a
file is of a given type, we should keep trying other types, not give up.
For reads done *after* we've concluded the file is probably of the right
type, if a read doesn't return the number of bytes we asked for, but
returns an error of 0, return WTAP_ERR_SHORT_READ - the file is
apparently cut short.
For NetMon and NetXRay/Windows Sniffer files, use a #define for the
magic number size, and use that for both magic numbers.
svn path=/trunk/; revision=46803
2012-12-27 12:19:25 +00:00
|
|
|
|
2016-01-20 00:49:05 +00:00
|
|
|
/*
|
|
|
|
* Check that we are dealing with an ETHERNET trace
|
|
|
|
*/
|
|
|
|
if (iseries->format == ISERIES_FORMAT_UNICODE)
|
|
|
|
{
|
|
|
|
iseries_UNICODE_to_ASCII ((guint8 *)buf, ISERIES_LINE_LENGTH);
|
|
|
|
}
|
|
|
|
ascii_strup_inplace (buf);
|
|
|
|
num_items_scanned = sscanf (buf,
|
|
|
|
"%*[ \n\t]OBJECT PROTOCOL%*[ .:\n\t]%8s",
|
|
|
|
protocol);
|
|
|
|
if (num_items_scanned == 1)
|
|
|
|
{
|
|
|
|
if (memcmp (protocol, "ETHERNET", 8) == 0)
|
|
|
|
{
|
|
|
|
*err = 0;
|
|
|
|
is_iseries = TRUE;
|
|
|
|
}
|
|
|
|
}
|
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
|
|
|
|
2016-01-20 00:49:05 +00:00
|
|
|
/*
|
|
|
|
* The header is the only place where the date part of the timestamp is held, so
|
|
|
|
* extract it here and store for all packets to access
|
|
|
|
*/
|
|
|
|
num_items_scanned = sscanf (buf,
|
|
|
|
"%*[ \n\t]START DATE/TIME%*[ .:\n\t]%2d/%2d/%2d",
|
|
|
|
&iseries->month, &iseries->day,
|
|
|
|
&iseries->year);
|
|
|
|
if (num_items_scanned == 3)
|
|
|
|
{
|
|
|
|
iseries->have_date = TRUE;
|
|
|
|
}
|
2005-11-25 20:30:42 +00:00
|
|
|
}
|
2016-01-17 16:03:50 +00:00
|
|
|
|
|
|
|
if (is_iseries)
|
|
|
|
wth->priv = (void *) iseries;
|
|
|
|
else
|
|
|
|
g_free(iseries);
|
|
|
|
|
|
|
|
return is_iseries;
|
2005-11-25 20:30:42 +00:00
|
|
|
}
|
|
|
|
|
2006-03-27 16:09:47 +00:00
|
|
|
/*
|
|
|
|
* Find the next packet and parse it; called from wtap_read().
|
2005-11-25 20:30:42 +00:00
|
|
|
*/
|
2014-05-23 10:50:02 +00:00
|
|
|
static gboolean
|
2019-04-05 01:56:27 +00:00
|
|
|
iseries_read (wtap * wth, wtap_rec *rec, Buffer *buf, int *err,
|
|
|
|
gchar ** err_info, gint64 *data_offset)
|
2005-11-25 20:30:42 +00:00
|
|
|
{
|
2006-11-05 22:46:44 +00:00
|
|
|
gint64 offset;
|
2006-03-22 17:37:04 +00:00
|
|
|
|
2006-03-27 16:09:47 +00:00
|
|
|
/*
|
|
|
|
* Locate the next packet
|
2005-11-25 20:30:42 +00:00
|
|
|
*/
|
2014-05-09 05:18:49 +00:00
|
|
|
offset = iseries_seek_next_packet (wth, err, err_info);
|
2013-05-17 09:37:02 +00:00
|
|
|
if (offset < 0)
|
2005-11-25 20:30:42 +00:00
|
|
|
return FALSE;
|
2013-06-17 21:18:47 +00:00
|
|
|
*data_offset = offset;
|
2006-03-22 17:37:04 +00:00
|
|
|
|
2006-03-27 16:09:47 +00:00
|
|
|
/*
|
|
|
|
* Parse the packet and extract the various fields
|
2005-11-25 20:30:42 +00:00
|
|
|
*/
|
2019-04-05 01:56:27 +00:00
|
|
|
return iseries_parse_packet (wth, wth->fh, rec, buf, err, err_info);
|
2005-11-25 20:30:42 +00:00
|
|
|
}
|
|
|
|
|
2006-03-27 16:09:47 +00:00
|
|
|
/*
|
2005-11-25 20:30:42 +00:00
|
|
|
* Seeks to the beginning of the next packet, and returns the
|
2013-05-17 09:37:02 +00:00
|
|
|
* byte offset. Returns -1 on failure or EOF; on EOF, sets
|
|
|
|
* *err to 0, and, on failure, sets *err to the error and *err_info
|
|
|
|
* to null or an additional error string.
|
2005-11-25 20:30:42 +00:00
|
|
|
*/
|
2006-11-05 22:46:44 +00:00
|
|
|
static gint64
|
2014-05-09 05:18:49 +00:00
|
|
|
iseries_seek_next_packet (wtap * wth, int *err, gchar **err_info)
|
2005-11-25 20:30:42 +00:00
|
|
|
{
|
2014-05-09 05:18:49 +00:00
|
|
|
iseries_t *iseries = (iseries_t *)wth->priv;
|
2012-04-22 18:44:10 +00:00
|
|
|
char buf[ISERIES_LINE_LENGTH],type[5];
|
|
|
|
int line, num_items_scanned;
|
|
|
|
gint64 cur_off;
|
|
|
|
long buflen;
|
2005-11-25 20:30:42 +00:00
|
|
|
|
2006-03-22 17:37:04 +00:00
|
|
|
for (line = 0; line < ISERIES_MAX_TRACE_LEN; line++)
|
|
|
|
{
|
2014-05-09 05:18:49 +00:00
|
|
|
if (file_gets (buf, ISERIES_LINE_LENGTH, wth->fh) == NULL)
|
2012-04-20 01:43:12 +00:00
|
|
|
{
|
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);
|
2013-05-17 09:37:02 +00:00
|
|
|
return -1;
|
2012-04-20 01:43:12 +00:00
|
|
|
}
|
2019-03-24 14:37:21 +00:00
|
|
|
/* Convert UNICODE to ASCII if required and determine */
|
|
|
|
/* the number of bytes to rewind to beginning of record. */
|
|
|
|
if (iseries->format == ISERIES_FORMAT_UNICODE)
|
|
|
|
{
|
|
|
|
/* buflen is #bytes to 1st 0x0A */
|
|
|
|
buflen = iseries_UNICODE_to_ASCII ((guint8 *) buf, ISERIES_LINE_LENGTH);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* Else buflen is just length of the ASCII string */
|
|
|
|
buflen = (long) strlen (buf);
|
|
|
|
}
|
|
|
|
ascii_strup_inplace (buf);
|
2019-03-25 09:20:10 +00:00
|
|
|
/* Check we have enough data in the line */
|
|
|
|
if (buflen < 78)
|
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
2019-03-24 14:37:21 +00:00
|
|
|
/* If packet header found return the offset */
|
|
|
|
num_items_scanned =
|
|
|
|
sscanf (buf+78,
|
|
|
|
"%*[ \n\t]ETHV2%*[ .:\n\t]TYPE%*[ .:\n\t]%4s",type);
|
|
|
|
if (num_items_scanned == 1)
|
|
|
|
{
|
|
|
|
/* Rewind to beginning of line */
|
|
|
|
cur_off = file_tell (wth->fh);
|
|
|
|
if (cur_off == -1)
|
|
|
|
{
|
|
|
|
*err = file_error (wth->fh, err_info);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
if (file_seek (wth->fh, cur_off - buflen, SEEK_SET, err) == -1)
|
|
|
|
{
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
return cur_off - buflen;
|
|
|
|
}
|
2005-11-25 20:30:42 +00:00
|
|
|
}
|
2006-03-22 17:37:04 +00:00
|
|
|
|
2012-12-27 22:59:39 +00:00
|
|
|
*err = WTAP_ERR_BAD_FILE;
|
|
|
|
*err_info =
|
|
|
|
g_strdup_printf ("iseries: next packet header not found within %d lines",
|
|
|
|
ISERIES_MAX_TRACE_LEN);
|
2005-11-25 20:30:42 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2006-03-27 16:09:47 +00:00
|
|
|
/*
|
|
|
|
* Read packets in random-access fashion
|
2005-11-25 20:30:42 +00:00
|
|
|
*/
|
2014-05-23 10:50:02 +00:00
|
|
|
static gboolean
|
2018-02-09 00:19:12 +00:00
|
|
|
iseries_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)
|
2005-11-25 20:30:42 +00:00
|
|
|
{
|
2006-03-22 17:37:04 +00:00
|
|
|
|
2005-11-25 20:30:42 +00:00
|
|
|
/* seek to packet location */
|
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;
|
2006-03-22 17:37:04 +00:00
|
|
|
|
2006-03-27 16:09:47 +00:00
|
|
|
/*
|
|
|
|
* Parse the packet and extract the various fields
|
2005-11-25 20:30:42 +00:00
|
|
|
*/
|
2018-02-09 00:19:12 +00:00
|
|
|
return iseries_parse_packet (wth, wth->random_fh, rec, buf,
|
2013-06-17 21:18:47 +00:00
|
|
|
err, err_info);
|
2005-11-25 20:30:42 +00:00
|
|
|
}
|
|
|
|
|
Redo the processing of lines in iSeries text packet dumps.
Process several different flavors of header lines the same: "IP Header",
"IPv6 Header", "ARP Header", "TCP Header", "UDP Header", "ICMP Header",
"ICMPv6 Hdr", "Option Hdr" - the hex data for all of them should be
included in the packet data. Process continuation lines if those
headers wrap over more than one line.
Do not assume, or require, that *any* of those be present; there is no
guarantee that "IP Header" or "IPv6 Header" will be present (there's at
least one IBM page showing a packet with "ARP Header" in a trace), and
there is no guarantee that "TCP Header" will be present (there are
traces with "UDP Header" and "ICMPv6 Hdr").
Do not impose limits, other than the overall line limit, on the amount
of hex data in header or data lines; there is no guarantee that, for
example, a TCP header is 20 bytes long (if there are TCP options, it
*will* have more than 20 bytes).
Make sure we have an even number of hex digits.
Set "caplen" to the actual number of bytes we've read, even if that's
less than the purported packet length.
svn path=/trunk/; revision=45626
2012-10-18 04:52:33 +00:00
|
|
|
static int
|
|
|
|
append_hex_digits(char *ascii_buf, int ascii_offset, int max_offset,
|
|
|
|
char *data, int *err, gchar **err_info)
|
|
|
|
{
|
|
|
|
int in_offset, out_offset;
|
|
|
|
int c;
|
|
|
|
unsigned int i;
|
|
|
|
gboolean overflow = FALSE;
|
|
|
|
|
|
|
|
in_offset = 0;
|
|
|
|
out_offset = ascii_offset;
|
|
|
|
for (;;)
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
* Process a block of up to 16 hex digits.
|
|
|
|
* The block is terminated early by an end-of-line indication (NUL,
|
|
|
|
* CR, or LF), by a space (which terminates the last block of the
|
|
|
|
* data we're processing), or by a "*", which introduces the ASCII representation
|
|
|
|
* of the data.
|
|
|
|
* All characters in the block must be upper-case hex digits;
|
|
|
|
* there might or might not be a space *after* a block, but, if so,
|
|
|
|
* that will be skipped over after the block is processed.
|
|
|
|
*/
|
|
|
|
for (i = 0; i < 16; i++, in_offset++)
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
* If we see an end-of-line indication, or an early-end-of-block
|
|
|
|
* indication (space), we're done. (Only the last block ends
|
|
|
|
* early.)
|
|
|
|
*/
|
|
|
|
c = data[in_offset] & 0xFF;
|
|
|
|
if (c == '\0' || c == ' ' || c == '*' || c == '\r' || c == '\n')
|
|
|
|
{
|
|
|
|
goto done;
|
|
|
|
}
|
2014-10-17 20:37:11 +00:00
|
|
|
if (!g_ascii_isxdigit(c) || g_ascii_islower(c))
|
Redo the processing of lines in iSeries text packet dumps.
Process several different flavors of header lines the same: "IP Header",
"IPv6 Header", "ARP Header", "TCP Header", "UDP Header", "ICMP Header",
"ICMPv6 Hdr", "Option Hdr" - the hex data for all of them should be
included in the packet data. Process continuation lines if those
headers wrap over more than one line.
Do not assume, or require, that *any* of those be present; there is no
guarantee that "IP Header" or "IPv6 Header" will be present (there's at
least one IBM page showing a packet with "ARP Header" in a trace), and
there is no guarantee that "TCP Header" will be present (there are
traces with "UDP Header" and "ICMPv6 Hdr").
Do not impose limits, other than the overall line limit, on the amount
of hex data in header or data lines; there is no guarantee that, for
example, a TCP header is 20 bytes long (if there are TCP options, it
*will* have more than 20 bytes).
Make sure we have an even number of hex digits.
Set "caplen" to the actual number of bytes we've read, even if that's
less than the purported packet length.
svn path=/trunk/; revision=45626
2012-10-18 04:52:33 +00:00
|
|
|
{
|
|
|
|
/*
|
|
|
|
* Not a hex digit, or a lower-case hex digit.
|
|
|
|
* Treat this as an indication that the line isn't a data
|
|
|
|
* line, so we just ignore it.
|
|
|
|
*
|
|
|
|
* XXX - do so only for continuation lines; treat non-hex-digit
|
|
|
|
* characters as errors for other lines?
|
|
|
|
*/
|
|
|
|
return ascii_offset; /* pretend we appended nothing */
|
|
|
|
}
|
|
|
|
if (out_offset >= max_offset)
|
|
|
|
overflow = TRUE;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ascii_buf[out_offset] = c;
|
|
|
|
out_offset++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/*
|
|
|
|
* Skip blanks, if any.
|
|
|
|
*/
|
|
|
|
for (; (data[in_offset] & 0xFF) == ' '; in_offset++)
|
|
|
|
;
|
|
|
|
}
|
|
|
|
done:
|
|
|
|
/*
|
|
|
|
* If we processed an *odd* number of hex digits, report an error.
|
|
|
|
*/
|
|
|
|
if ((i % 2) != 0)
|
|
|
|
{
|
|
|
|
*err = WTAP_ERR_BAD_FILE;
|
|
|
|
*err_info = g_strdup("iseries: odd number of hex digits in a line");
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
if (overflow)
|
|
|
|
{
|
|
|
|
*err = WTAP_ERR_BAD_FILE;
|
|
|
|
*err_info = g_strdup("iseries: more packet data than the packet length indicated");
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
return out_offset;
|
|
|
|
}
|
|
|
|
|
2016-09-07 13:15:57 +00:00
|
|
|
/* return the multiplier for nanoseconds */
|
|
|
|
static guint32
|
|
|
|
csec_multiplier(guint32 csec)
|
|
|
|
{
|
|
|
|
if (csec < 10) return 100000000;
|
|
|
|
if (csec < 100) return 10000000;
|
|
|
|
if (csec < 1000) return 1000000;
|
|
|
|
if (csec < 10000) return 100000;
|
|
|
|
if (csec < 100000) return 10000;
|
|
|
|
if (csec < 1000000) return 1000;
|
|
|
|
if (csec < 10000000) return 100;
|
|
|
|
if (csec < 100000000) return 10;
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2005-11-25 20:30:42 +00:00
|
|
|
/* Parses a packet. */
|
2014-05-23 10:50:02 +00:00
|
|
|
static gboolean
|
2018-02-09 00:19:12 +00:00
|
|
|
iseries_parse_packet (wtap * wth, FILE_T fh, wtap_rec *rec,
|
2013-06-16 00:20:00 +00:00
|
|
|
Buffer *buf, int *err, gchar **err_info)
|
2005-11-25 20:30:42 +00:00
|
|
|
{
|
2014-05-09 05:18:49 +00:00
|
|
|
iseries_t *iseries = (iseries_t *)wth->priv;
|
2012-04-22 18:44:10 +00:00
|
|
|
gint64 cur_off;
|
Redo the processing of lines in iSeries text packet dumps.
Process several different flavors of header lines the same: "IP Header",
"IPv6 Header", "ARP Header", "TCP Header", "UDP Header", "ICMP Header",
"ICMPv6 Hdr", "Option Hdr" - the hex data for all of them should be
included in the packet data. Process continuation lines if those
headers wrap over more than one line.
Do not assume, or require, that *any* of those be present; there is no
guarantee that "IP Header" or "IPv6 Header" will be present (there's at
least one IBM page showing a packet with "ARP Header" in a trace), and
there is no guarantee that "TCP Header" will be present (there are
traces with "UDP Header" and "ICMPv6 Hdr").
Do not impose limits, other than the overall line limit, on the amount
of hex data in header or data lines; there is no guarantee that, for
example, a TCP header is 20 bytes long (if there are TCP options, it
*will* have more than 20 bytes).
Make sure we have an even number of hex digits.
Set "caplen" to the actual number of bytes we've read, even if that's
less than the purported packet length.
svn path=/trunk/; revision=45626
2012-10-18 04:52:33 +00:00
|
|
|
gboolean isValid, isCurrentPacket;
|
2012-04-22 18:44:10 +00:00
|
|
|
int num_items_scanned, line, pktline, buflen;
|
2012-10-18 05:20:09 +00:00
|
|
|
int pkt_len, pktnum, hr, min, sec;
|
2016-09-07 13:15:57 +00:00
|
|
|
char direction[2], destmac[13], srcmac[13], type[5];
|
|
|
|
guint32 csec;
|
2012-04-22 18:44:10 +00:00
|
|
|
char data[ISERIES_LINE_LENGTH * 2];
|
Redo the processing of lines in iSeries text packet dumps.
Process several different flavors of header lines the same: "IP Header",
"IPv6 Header", "ARP Header", "TCP Header", "UDP Header", "ICMP Header",
"ICMPv6 Hdr", "Option Hdr" - the hex data for all of them should be
included in the packet data. Process continuation lines if those
headers wrap over more than one line.
Do not assume, or require, that *any* of those be present; there is no
guarantee that "IP Header" or "IPv6 Header" will be present (there's at
least one IBM page showing a packet with "ARP Header" in a trace), and
there is no guarantee that "TCP Header" will be present (there are
traces with "UDP Header" and "ICMPv6 Hdr").
Do not impose limits, other than the overall line limit, on the amount
of hex data in header or data lines; there is no guarantee that, for
example, a TCP header is 20 bytes long (if there are TCP options, it
*will* have more than 20 bytes).
Make sure we have an even number of hex digits.
Set "caplen" to the actual number of bytes we've read, even if that's
less than the purported packet length.
svn path=/trunk/; revision=45626
2012-10-18 04:52:33 +00:00
|
|
|
int offset;
|
|
|
|
char *ascii_buf;
|
|
|
|
int ascii_offset;
|
2012-04-22 18:44:10 +00:00
|
|
|
struct tm tm;
|
2005-11-25 20:30:42 +00:00
|
|
|
|
2006-03-27 16:09:47 +00:00
|
|
|
/*
|
|
|
|
* Check for packet headers in first 3 lines this should handle page breaks
|
2005-11-25 20:30:42 +00:00
|
|
|
* situations and the header lines output at each page throw and ensure we
|
|
|
|
* read both the captured and packet lengths.
|
|
|
|
*/
|
|
|
|
isValid = FALSE;
|
2006-03-22 17:37:04 +00:00
|
|
|
for (line = 1; line < ISERIES_PKT_LINES_TO_CHECK; line++)
|
|
|
|
{
|
2006-03-27 18:24:26 +00:00
|
|
|
if (file_gets (data, ISERIES_LINE_LENGTH, fh) == NULL)
|
2012-04-20 01:43:12 +00:00
|
|
|
{
|
|
|
|
*err = file_error (fh, err_info);
|
2014-05-23 10:50:02 +00:00
|
|
|
return FALSE;
|
2012-04-20 01:43:12 +00:00
|
|
|
}
|
2006-03-22 17:37:04 +00:00
|
|
|
/* Convert UNICODE data to ASCII */
|
2010-02-24 08:39:19 +00:00
|
|
|
if (iseries->format == ISERIES_FORMAT_UNICODE)
|
2012-04-20 01:43:12 +00:00
|
|
|
{
|
2008-02-09 23:35:28 +00:00
|
|
|
iseries_UNICODE_to_ASCII ((guint8 *)data, ISERIES_LINE_LENGTH);
|
2012-04-20 01:43:12 +00:00
|
|
|
}
|
2012-04-22 18:44:10 +00:00
|
|
|
ascii_strup_inplace (data);
|
2006-03-22 17:37:04 +00:00
|
|
|
num_items_scanned =
|
2012-04-20 01:43:12 +00:00
|
|
|
sscanf (data,
|
2016-09-07 13:15:57 +00:00
|
|
|
"%*[ \n\t]%6d%*[ *\n\t]%1s%*[ \n\t]%6d%*[ \n\t]%2d:%2d:%2d.%9u%*[ \n\t]"
|
2012-04-22 18:44:10 +00:00
|
|
|
"%12s%*[ \n\t]%12s%*[ \n\t]ETHV2%*[ \n\t]TYPE:%*[ \n\t]%4s",
|
2016-09-07 13:15:57 +00:00
|
|
|
&pktnum, direction, &pkt_len, &hr, &min, &sec, &csec, destmac,
|
2012-04-20 01:43:12 +00:00
|
|
|
srcmac, type);
|
2015-11-30 04:29:55 +00:00
|
|
|
if (num_items_scanned == 10)
|
2012-04-20 01:43:12 +00:00
|
|
|
{
|
2015-11-30 04:29:55 +00:00
|
|
|
if (pktnum < 0)
|
|
|
|
{
|
|
|
|
*err = WTAP_ERR_BAD_FILE;
|
|
|
|
*err_info = g_strdup ("iseries: packet header has a negative packet number");
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (pkt_len < 0)
|
|
|
|
{
|
|
|
|
*err = WTAP_ERR_BAD_FILE;
|
|
|
|
*err_info = g_strdup ("iseries: packet header has a negative packet length");
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (hr < 0)
|
|
|
|
{
|
|
|
|
*err = WTAP_ERR_BAD_FILE;
|
|
|
|
*err_info = g_strdup ("iseries: packet header has a negative hour in the time stamp");
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (hr > 23)
|
|
|
|
{
|
|
|
|
*err = WTAP_ERR_BAD_FILE;
|
|
|
|
*err_info = g_strdup ("iseries: packet header has a hour in the time stamp greater than 23");
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (min < 0)
|
|
|
|
{
|
|
|
|
*err = WTAP_ERR_BAD_FILE;
|
|
|
|
*err_info = g_strdup ("iseries: packet header has a negative minute in the time stamp");
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (min > 59)
|
|
|
|
{
|
|
|
|
*err = WTAP_ERR_BAD_FILE;
|
|
|
|
*err_info = g_strdup ("iseries: packet header has a minute in the time stamp greater than 59");
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (sec < 0)
|
|
|
|
{
|
|
|
|
*err = WTAP_ERR_BAD_FILE;
|
|
|
|
*err_info = g_strdup ("iseries: packet header has a negative second in the time stamp");
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Yes, 60, even though the time-conversion routines on most OSes
|
|
|
|
* might not handle leap seconds.
|
|
|
|
*/
|
|
|
|
if (sec > 60)
|
|
|
|
{
|
|
|
|
*err = WTAP_ERR_BAD_FILE;
|
|
|
|
*err_info = g_strdup ("iseries: packet header has a second in the time stamp greater than 60");
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2016-05-02 00:58:49 +00:00
|
|
|
if (strlen(destmac) != 12)
|
|
|
|
{
|
|
|
|
*err = WTAP_ERR_BAD_FILE;
|
|
|
|
*err_info = g_strdup ("iseries: packet header has a destination MAC address shorter than 6 bytes");
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (strlen(srcmac) != 12)
|
|
|
|
{
|
|
|
|
*err = WTAP_ERR_BAD_FILE;
|
|
|
|
*err_info = g_strdup ("iseries: packet header has a source MAC address shorter than 6 bytes");
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (strlen(type) != 4)
|
|
|
|
{
|
|
|
|
*err = WTAP_ERR_BAD_FILE;
|
|
|
|
*err_info = g_strdup ("iseries: packet header has an Ethernet type/length field than 2 bytes");
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2012-04-20 01:43:12 +00:00
|
|
|
/* OK! We found the packet header line */
|
|
|
|
isValid = TRUE;
|
|
|
|
/*
|
2012-10-18 05:20:09 +00:00
|
|
|
* XXX - The Capture length returned by the iSeries trace doesn't
|
|
|
|
* seem to include the Ethernet header, so we add its length here.
|
2016-05-02 00:02:12 +00:00
|
|
|
*
|
|
|
|
* Check the length first, just in case it's *so* big that, after
|
|
|
|
* adding the Ethernet header length, it overflows.
|
2012-04-20 01:43:12 +00:00
|
|
|
*/
|
2021-01-20 03:02:01 +00:00
|
|
|
if ((guint)pkt_len > WTAP_MAX_PACKET_SIZE_STANDARD - 14)
|
2016-05-02 00:02:12 +00:00
|
|
|
{
|
|
|
|
/*
|
|
|
|
* Probably a corrupt capture file; don't blow up trying
|
|
|
|
* to allocate space for an immensely-large packet, and
|
|
|
|
* don't think it's a really *small* packet because it
|
|
|
|
* overflowed. (Calculate the size as a 64-bit value in
|
|
|
|
* the error message, to avoid an overflow.)
|
|
|
|
*/
|
|
|
|
*err = WTAP_ERR_BAD_FILE;
|
|
|
|
*err_info = g_strdup_printf("iseries: File has %" G_GUINT64_FORMAT "-byte packet, bigger than maximum of %u",
|
|
|
|
(guint64)pkt_len + 14,
|
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
|
|
|
WTAP_MAX_PACKET_SIZE_STANDARD);
|
2016-05-02 00:02:12 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
Redo the processing of lines in iSeries text packet dumps.
Process several different flavors of header lines the same: "IP Header",
"IPv6 Header", "ARP Header", "TCP Header", "UDP Header", "ICMP Header",
"ICMPv6 Hdr", "Option Hdr" - the hex data for all of them should be
included in the packet data. Process continuation lines if those
headers wrap over more than one line.
Do not assume, or require, that *any* of those be present; there is no
guarantee that "IP Header" or "IPv6 Header" will be present (there's at
least one IBM page showing a packet with "ARP Header" in a trace), and
there is no guarantee that "TCP Header" will be present (there are
traces with "UDP Header" and "ICMPv6 Hdr").
Do not impose limits, other than the overall line limit, on the amount
of hex data in header or data lines; there is no guarantee that, for
example, a TCP header is 20 bytes long (if there are TCP options, it
*will* have more than 20 bytes).
Make sure we have an even number of hex digits.
Set "caplen" to the actual number of bytes we've read, even if that's
less than the purported packet length.
svn path=/trunk/; revision=45626
2012-10-18 04:52:33 +00:00
|
|
|
pkt_len += 14;
|
2012-04-20 01:43:12 +00:00
|
|
|
break;
|
|
|
|
}
|
2005-11-25 20:30:42 +00:00
|
|
|
}
|
|
|
|
|
2006-03-27 16:09:47 +00:00
|
|
|
/*
|
2005-11-25 20:30:42 +00:00
|
|
|
* If no packet header found we exit at this point and inform the user.
|
2006-03-22 17:37:04 +00:00
|
|
|
*/
|
|
|
|
if (!isValid)
|
|
|
|
{
|
2011-12-13 09:53:50 +00:00
|
|
|
*err = WTAP_ERR_BAD_FILE;
|
2006-03-22 17:37:04 +00:00
|
|
|
*err_info = g_strdup ("iseries: packet header isn't valid");
|
2014-05-23 10:50:02 +00:00
|
|
|
return FALSE;
|
2006-03-22 17:37:04 +00:00
|
|
|
}
|
|
|
|
|
2018-02-09 00:19:12 +00:00
|
|
|
rec->rec_type = REC_TYPE_PACKET;
|
|
|
|
rec->presence_flags = WTAP_HAS_CAP_LEN;
|
2012-02-25 23:24:34 +00:00
|
|
|
|
2006-03-27 16:09:47 +00:00
|
|
|
/*
|
2005-11-25 20:30:42 +00:00
|
|
|
* If we have Wiretap Header then populate it here
|
|
|
|
*
|
2012-10-18 05:20:09 +00:00
|
|
|
* Timer resolution on the iSeries is hardware dependent. We determine
|
|
|
|
* the resolution based on how many digits we see.
|
2005-11-25 20:30:42 +00:00
|
|
|
*/
|
2010-02-24 08:39:19 +00:00
|
|
|
if (iseries->have_date)
|
2006-03-22 17:37:04 +00:00
|
|
|
{
|
2018-02-09 00:19:12 +00:00
|
|
|
rec->presence_flags |= WTAP_HAS_TS;
|
2012-04-22 18:44:10 +00:00
|
|
|
tm.tm_year = 100 + iseries->year;
|
|
|
|
tm.tm_mon = iseries->month - 1;
|
|
|
|
tm.tm_mday = iseries->day;
|
|
|
|
tm.tm_hour = hr;
|
|
|
|
tm.tm_min = min;
|
|
|
|
tm.tm_sec = sec;
|
|
|
|
tm.tm_isdst = -1;
|
2018-02-09 00:19:12 +00:00
|
|
|
rec->ts.secs = mktime (&tm);
|
|
|
|
rec->ts.nsecs = csec * csec_multiplier(csec);
|
2006-03-22 17:37:04 +00:00
|
|
|
}
|
2005-11-25 20:30:42 +00:00
|
|
|
|
2018-02-09 00:19:12 +00:00
|
|
|
rec->rec_header.packet_header.len = pkt_len;
|
|
|
|
rec->rec_header.packet_header.pkt_encap = WTAP_ENCAP_ETHERNET;
|
|
|
|
rec->rec_header.packet_header.pseudo_header.eth.fcs_len = -1;
|
2008-05-28 15:01:16 +00:00
|
|
|
|
2016-05-02 01:00:00 +00:00
|
|
|
/*
|
2016-05-02 00:58:49 +00:00
|
|
|
* Allocate a buffer big enough to hold the claimed packet length
|
|
|
|
* worth of byte values; each byte will be two hex digits, so the
|
|
|
|
* buffer's size should be twice the packet length.
|
|
|
|
*
|
|
|
|
* (There is no need to null-terminate the buffer.)
|
|
|
|
*/
|
|
|
|
ascii_buf = (char *)g_malloc (pkt_len*2);
|
|
|
|
ascii_offset = 0;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Copy in the Ethernet header.
|
|
|
|
*
|
|
|
|
* The three fields have already been checked to have the right length
|
|
|
|
* (6 bytes, hence 12 characters, of hex-dump destination and source
|
|
|
|
* addresses, and 2 bytes, hence 4 characters, of hex-dump type/length).
|
|
|
|
*
|
|
|
|
* pkt_len is guaranteed to be >= 14, so 2*pkt_len is guaranteed to be
|
|
|
|
* >= 28, so we don't need to do any bounds checking.
|
|
|
|
*/
|
|
|
|
memcpy(&ascii_buf[0], destmac, 12);
|
|
|
|
ascii_offset += 12;
|
|
|
|
memcpy(&ascii_buf[12], srcmac, 12);
|
|
|
|
ascii_offset += 12;
|
|
|
|
memcpy(&ascii_buf[24], type, 4);
|
|
|
|
ascii_offset += 4;
|
Redo the processing of lines in iSeries text packet dumps.
Process several different flavors of header lines the same: "IP Header",
"IPv6 Header", "ARP Header", "TCP Header", "UDP Header", "ICMP Header",
"ICMPv6 Hdr", "Option Hdr" - the hex data for all of them should be
included in the packet data. Process continuation lines if those
headers wrap over more than one line.
Do not assume, or require, that *any* of those be present; there is no
guarantee that "IP Header" or "IPv6 Header" will be present (there's at
least one IBM page showing a packet with "ARP Header" in a trace), and
there is no guarantee that "TCP Header" will be present (there are
traces with "UDP Header" and "ICMPv6 Hdr").
Do not impose limits, other than the overall line limit, on the amount
of hex data in header or data lines; there is no guarantee that, for
example, a TCP header is 20 bytes long (if there are TCP options, it
*will* have more than 20 bytes).
Make sure we have an even number of hex digits.
Set "caplen" to the actual number of bytes we've read, even if that's
less than the purported packet length.
svn path=/trunk/; revision=45626
2012-10-18 04:52:33 +00:00
|
|
|
|
2006-03-27 16:09:47 +00:00
|
|
|
/*
|
2012-12-27 22:59:39 +00:00
|
|
|
* Start reading packet contents
|
2006-03-22 17:37:04 +00:00
|
|
|
*/
|
2005-11-25 20:30:42 +00:00
|
|
|
isCurrentPacket = TRUE;
|
2012-04-22 18:44:10 +00:00
|
|
|
|
2005-11-25 20:30:42 +00:00
|
|
|
/* loop through packet lines and breakout when the next packet header is read */
|
2006-03-22 17:37:04 +00:00
|
|
|
pktline = 0;
|
|
|
|
while (isCurrentPacket)
|
|
|
|
{
|
|
|
|
pktline++;
|
|
|
|
/* Read the next line */
|
2006-03-27 18:24:26 +00:00
|
|
|
if (file_gets (data, ISERIES_LINE_LENGTH, fh) == NULL)
|
2012-04-20 01:43:12 +00:00
|
|
|
{
|
2012-12-27 22:59:39 +00:00
|
|
|
*err = file_error (fh, err_info);
|
|
|
|
if (*err == 0)
|
2012-04-20 01:43:12 +00:00
|
|
|
{
|
2012-12-27 22:59:39 +00:00
|
|
|
/* Hit the EOF without an error */
|
2012-04-20 01:43:12 +00:00
|
|
|
break;
|
|
|
|
}
|
2012-12-27 22:59:39 +00:00
|
|
|
goto errxit;
|
2012-04-20 01:43:12 +00:00
|
|
|
}
|
2005-11-25 20:30:42 +00:00
|
|
|
|
2006-10-04 17:36:40 +00:00
|
|
|
/* Convert UNICODE data to ASCII and determine line length */
|
2010-02-24 08:39:19 +00:00
|
|
|
if (iseries->format == ISERIES_FORMAT_UNICODE)
|
2012-04-20 01:43:12 +00:00
|
|
|
{
|
2008-02-09 23:35:28 +00:00
|
|
|
buflen = iseries_UNICODE_to_ASCII ((guint8 *)data, ISERIES_LINE_LENGTH);
|
2012-04-20 01:43:12 +00:00
|
|
|
}
|
2006-03-22 17:37:04 +00:00
|
|
|
else
|
2012-04-20 01:43:12 +00:00
|
|
|
{
|
|
|
|
/* Else bytes to rewind is just length of ASCII string */
|
|
|
|
buflen = (int) strlen (data);
|
|
|
|
}
|
2005-11-25 20:30:42 +00:00
|
|
|
|
2012-04-22 18:44:10 +00:00
|
|
|
/*
|
Redo the processing of lines in iSeries text packet dumps.
Process several different flavors of header lines the same: "IP Header",
"IPv6 Header", "ARP Header", "TCP Header", "UDP Header", "ICMP Header",
"ICMPv6 Hdr", "Option Hdr" - the hex data for all of them should be
included in the packet data. Process continuation lines if those
headers wrap over more than one line.
Do not assume, or require, that *any* of those be present; there is no
guarantee that "IP Header" or "IPv6 Header" will be present (there's at
least one IBM page showing a packet with "ARP Header" in a trace), and
there is no guarantee that "TCP Header" will be present (there are
traces with "UDP Header" and "ICMPv6 Hdr").
Do not impose limits, other than the overall line limit, on the amount
of hex data in header or data lines; there is no guarantee that, for
example, a TCP header is 20 bytes long (if there are TCP options, it
*will* have more than 20 bytes).
Make sure we have an even number of hex digits.
Set "caplen" to the actual number of bytes we've read, even if that's
less than the purported packet length.
svn path=/trunk/; revision=45626
2012-10-18 04:52:33 +00:00
|
|
|
* Skip leading white space.
|
2012-04-20 01:43:12 +00:00
|
|
|
*/
|
2014-10-17 20:37:11 +00:00
|
|
|
for (offset = 0; g_ascii_isspace(data[offset]); offset++)
|
Redo the processing of lines in iSeries text packet dumps.
Process several different flavors of header lines the same: "IP Header",
"IPv6 Header", "ARP Header", "TCP Header", "UDP Header", "ICMP Header",
"ICMPv6 Hdr", "Option Hdr" - the hex data for all of them should be
included in the packet data. Process continuation lines if those
headers wrap over more than one line.
Do not assume, or require, that *any* of those be present; there is no
guarantee that "IP Header" or "IPv6 Header" will be present (there's at
least one IBM page showing a packet with "ARP Header" in a trace), and
there is no guarantee that "TCP Header" will be present (there are
traces with "UDP Header" and "ICMPv6 Hdr").
Do not impose limits, other than the overall line limit, on the amount
of hex data in header or data lines; there is no guarantee that, for
example, a TCP header is 20 bytes long (if there are TCP options, it
*will* have more than 20 bytes).
Make sure we have an even number of hex digits.
Set "caplen" to the actual number of bytes we've read, even if that's
less than the purported packet length.
svn path=/trunk/; revision=45626
2012-10-18 04:52:33 +00:00
|
|
|
;
|
2011-05-29 19:36:21 +00:00
|
|
|
|
Redo the processing of lines in iSeries text packet dumps.
Process several different flavors of header lines the same: "IP Header",
"IPv6 Header", "ARP Header", "TCP Header", "UDP Header", "ICMP Header",
"ICMPv6 Hdr", "Option Hdr" - the hex data for all of them should be
included in the packet data. Process continuation lines if those
headers wrap over more than one line.
Do not assume, or require, that *any* of those be present; there is no
guarantee that "IP Header" or "IPv6 Header" will be present (there's at
least one IBM page showing a packet with "ARP Header" in a trace), and
there is no guarantee that "TCP Header" will be present (there are
traces with "UDP Header" and "ICMPv6 Hdr").
Do not impose limits, other than the overall line limit, on the amount
of hex data in header or data lines; there is no guarantee that, for
example, a TCP header is 20 bytes long (if there are TCP options, it
*will* have more than 20 bytes).
Make sure we have an even number of hex digits.
Set "caplen" to the actual number of bytes we've read, even if that's
less than the purported packet length.
svn path=/trunk/; revision=45626
2012-10-18 04:52:33 +00:00
|
|
|
/*
|
|
|
|
* The higher-level header information starts at an offset of
|
|
|
|
* 22 characters. The header tags are 14 characters long.
|
|
|
|
*
|
|
|
|
* XXX - for IPv6, if the next header isn't the last header,
|
|
|
|
* the intermediate headers do *NOT* appear to be shown in
|
|
|
|
* the dump file *at all*, so the packet *cannot* be
|
|
|
|
* reconstructed!
|
|
|
|
*/
|
|
|
|
if (offset == 22)
|
|
|
|
{
|
|
|
|
if (strncmp(data + 22, "IP Header : ", 14) == 0 ||
|
|
|
|
strncmp(data + 22, "IPv6 Header: ", 14) == 0 ||
|
|
|
|
strncmp(data + 22, "ARP Header : ", 14) == 0 ||
|
|
|
|
strncmp(data + 22, "TCP Header : ", 14) == 0 ||
|
|
|
|
strncmp(data + 22, "UDP Header : ", 14) == 0 ||
|
|
|
|
strncmp(data + 22, "ICMP Header: ", 14) == 0 ||
|
|
|
|
strncmp(data + 22, "ICMPv6 Hdr: ", 14) == 0 ||
|
|
|
|
strncmp(data + 22, "Option Hdr: ", 14) == 0)
|
2012-04-20 01:43:12 +00:00
|
|
|
{
|
Redo the processing of lines in iSeries text packet dumps.
Process several different flavors of header lines the same: "IP Header",
"IPv6 Header", "ARP Header", "TCP Header", "UDP Header", "ICMP Header",
"ICMPv6 Hdr", "Option Hdr" - the hex data for all of them should be
included in the packet data. Process continuation lines if those
headers wrap over more than one line.
Do not assume, or require, that *any* of those be present; there is no
guarantee that "IP Header" or "IPv6 Header" will be present (there's at
least one IBM page showing a packet with "ARP Header" in a trace), and
there is no guarantee that "TCP Header" will be present (there are
traces with "UDP Header" and "ICMPv6 Hdr").
Do not impose limits, other than the overall line limit, on the amount
of hex data in header or data lines; there is no guarantee that, for
example, a TCP header is 20 bytes long (if there are TCP options, it
*will* have more than 20 bytes).
Make sure we have an even number of hex digits.
Set "caplen" to the actual number of bytes we've read, even if that's
less than the purported packet length.
svn path=/trunk/; revision=45626
2012-10-18 04:52:33 +00:00
|
|
|
ascii_offset = append_hex_digits(ascii_buf, ascii_offset,
|
2016-05-02 00:52:45 +00:00
|
|
|
pkt_len*2,
|
Redo the processing of lines in iSeries text packet dumps.
Process several different flavors of header lines the same: "IP Header",
"IPv6 Header", "ARP Header", "TCP Header", "UDP Header", "ICMP Header",
"ICMPv6 Hdr", "Option Hdr" - the hex data for all of them should be
included in the packet data. Process continuation lines if those
headers wrap over more than one line.
Do not assume, or require, that *any* of those be present; there is no
guarantee that "IP Header" or "IPv6 Header" will be present (there's at
least one IBM page showing a packet with "ARP Header" in a trace), and
there is no guarantee that "TCP Header" will be present (there are
traces with "UDP Header" and "ICMPv6 Hdr").
Do not impose limits, other than the overall line limit, on the amount
of hex data in header or data lines; there is no guarantee that, for
example, a TCP header is 20 bytes long (if there are TCP options, it
*will* have more than 20 bytes).
Make sure we have an even number of hex digits.
Set "caplen" to the actual number of bytes we've read, even if that's
less than the purported packet length.
svn path=/trunk/; revision=45626
2012-10-18 04:52:33 +00:00
|
|
|
data + 22 + 14, err,
|
|
|
|
err_info);
|
|
|
|
if (ascii_offset == -1)
|
2012-04-20 01:43:12 +00:00
|
|
|
{
|
Redo the processing of lines in iSeries text packet dumps.
Process several different flavors of header lines the same: "IP Header",
"IPv6 Header", "ARP Header", "TCP Header", "UDP Header", "ICMP Header",
"ICMPv6 Hdr", "Option Hdr" - the hex data for all of them should be
included in the packet data. Process continuation lines if those
headers wrap over more than one line.
Do not assume, or require, that *any* of those be present; there is no
guarantee that "IP Header" or "IPv6 Header" will be present (there's at
least one IBM page showing a packet with "ARP Header" in a trace), and
there is no guarantee that "TCP Header" will be present (there are
traces with "UDP Header" and "ICMPv6 Hdr").
Do not impose limits, other than the overall line limit, on the amount
of hex data in header or data lines; there is no guarantee that, for
example, a TCP header is 20 bytes long (if there are TCP options, it
*will* have more than 20 bytes).
Make sure we have an even number of hex digits.
Set "caplen" to the actual number of bytes we've read, even if that's
less than the purported packet length.
svn path=/trunk/; revision=45626
2012-10-18 04:52:33 +00:00
|
|
|
/* Bad line. */
|
2014-05-23 10:50:02 +00:00
|
|
|
return FALSE;
|
2012-04-20 01:43:12 +00:00
|
|
|
}
|
Redo the processing of lines in iSeries text packet dumps.
Process several different flavors of header lines the same: "IP Header",
"IPv6 Header", "ARP Header", "TCP Header", "UDP Header", "ICMP Header",
"ICMPv6 Hdr", "Option Hdr" - the hex data for all of them should be
included in the packet data. Process continuation lines if those
headers wrap over more than one line.
Do not assume, or require, that *any* of those be present; there is no
guarantee that "IP Header" or "IPv6 Header" will be present (there's at
least one IBM page showing a packet with "ARP Header" in a trace), and
there is no guarantee that "TCP Header" will be present (there are
traces with "UDP Header" and "ICMPv6 Hdr").
Do not impose limits, other than the overall line limit, on the amount
of hex data in header or data lines; there is no guarantee that, for
example, a TCP header is 20 bytes long (if there are TCP options, it
*will* have more than 20 bytes).
Make sure we have an even number of hex digits.
Set "caplen" to the actual number of bytes we've read, even if that's
less than the purported packet length.
svn path=/trunk/; revision=45626
2012-10-18 04:52:33 +00:00
|
|
|
continue;
|
2012-04-20 01:43:12 +00:00
|
|
|
}
|
|
|
|
}
|
2012-04-22 18:44:10 +00:00
|
|
|
|
2012-04-20 01:43:12 +00:00
|
|
|
/*
|
Redo the processing of lines in iSeries text packet dumps.
Process several different flavors of header lines the same: "IP Header",
"IPv6 Header", "ARP Header", "TCP Header", "UDP Header", "ICMP Header",
"ICMPv6 Hdr", "Option Hdr" - the hex data for all of them should be
included in the packet data. Process continuation lines if those
headers wrap over more than one line.
Do not assume, or require, that *any* of those be present; there is no
guarantee that "IP Header" or "IPv6 Header" will be present (there's at
least one IBM page showing a packet with "ARP Header" in a trace), and
there is no guarantee that "TCP Header" will be present (there are
traces with "UDP Header" and "ICMPv6 Hdr").
Do not impose limits, other than the overall line limit, on the amount
of hex data in header or data lines; there is no guarantee that, for
example, a TCP header is 20 bytes long (if there are TCP options, it
*will* have more than 20 bytes).
Make sure we have an even number of hex digits.
Set "caplen" to the actual number of bytes we've read, even if that's
less than the purported packet length.
svn path=/trunk/; revision=45626
2012-10-18 04:52:33 +00:00
|
|
|
* Is this a data line?
|
|
|
|
*
|
|
|
|
* The "Data" starts at an offset of 8.
|
2012-04-20 01:43:12 +00:00
|
|
|
*/
|
Redo the processing of lines in iSeries text packet dumps.
Process several different flavors of header lines the same: "IP Header",
"IPv6 Header", "ARP Header", "TCP Header", "UDP Header", "ICMP Header",
"ICMPv6 Hdr", "Option Hdr" - the hex data for all of them should be
included in the packet data. Process continuation lines if those
headers wrap over more than one line.
Do not assume, or require, that *any* of those be present; there is no
guarantee that "IP Header" or "IPv6 Header" will be present (there's at
least one IBM page showing a packet with "ARP Header" in a trace), and
there is no guarantee that "TCP Header" will be present (there are
traces with "UDP Header" and "ICMPv6 Hdr").
Do not impose limits, other than the overall line limit, on the amount
of hex data in header or data lines; there is no guarantee that, for
example, a TCP header is 20 bytes long (if there are TCP options, it
*will* have more than 20 bytes).
Make sure we have an even number of hex digits.
Set "caplen" to the actual number of bytes we've read, even if that's
less than the purported packet length.
svn path=/trunk/; revision=45626
2012-10-18 04:52:33 +00:00
|
|
|
if (offset == 9)
|
2012-04-20 01:43:12 +00:00
|
|
|
{
|
Redo the processing of lines in iSeries text packet dumps.
Process several different flavors of header lines the same: "IP Header",
"IPv6 Header", "ARP Header", "TCP Header", "UDP Header", "ICMP Header",
"ICMPv6 Hdr", "Option Hdr" - the hex data for all of them should be
included in the packet data. Process continuation lines if those
headers wrap over more than one line.
Do not assume, or require, that *any* of those be present; there is no
guarantee that "IP Header" or "IPv6 Header" will be present (there's at
least one IBM page showing a packet with "ARP Header" in a trace), and
there is no guarantee that "TCP Header" will be present (there are
traces with "UDP Header" and "ICMPv6 Hdr").
Do not impose limits, other than the overall line limit, on the amount
of hex data in header or data lines; there is no guarantee that, for
example, a TCP header is 20 bytes long (if there are TCP options, it
*will* have more than 20 bytes).
Make sure we have an even number of hex digits.
Set "caplen" to the actual number of bytes we've read, even if that's
less than the purported packet length.
svn path=/trunk/; revision=45626
2012-10-18 04:52:33 +00:00
|
|
|
if (strncmp(data + 9, "Data . . . . . : ", 18) == 0)
|
2012-04-20 01:43:12 +00:00
|
|
|
{
|
Redo the processing of lines in iSeries text packet dumps.
Process several different flavors of header lines the same: "IP Header",
"IPv6 Header", "ARP Header", "TCP Header", "UDP Header", "ICMP Header",
"ICMPv6 Hdr", "Option Hdr" - the hex data for all of them should be
included in the packet data. Process continuation lines if those
headers wrap over more than one line.
Do not assume, or require, that *any* of those be present; there is no
guarantee that "IP Header" or "IPv6 Header" will be present (there's at
least one IBM page showing a packet with "ARP Header" in a trace), and
there is no guarantee that "TCP Header" will be present (there are
traces with "UDP Header" and "ICMPv6 Hdr").
Do not impose limits, other than the overall line limit, on the amount
of hex data in header or data lines; there is no guarantee that, for
example, a TCP header is 20 bytes long (if there are TCP options, it
*will* have more than 20 bytes).
Make sure we have an even number of hex digits.
Set "caplen" to the actual number of bytes we've read, even if that's
less than the purported packet length.
svn path=/trunk/; revision=45626
2012-10-18 04:52:33 +00:00
|
|
|
ascii_offset = append_hex_digits(ascii_buf, ascii_offset,
|
2016-05-02 00:52:45 +00:00
|
|
|
pkt_len*2,
|
Redo the processing of lines in iSeries text packet dumps.
Process several different flavors of header lines the same: "IP Header",
"IPv6 Header", "ARP Header", "TCP Header", "UDP Header", "ICMP Header",
"ICMPv6 Hdr", "Option Hdr" - the hex data for all of them should be
included in the packet data. Process continuation lines if those
headers wrap over more than one line.
Do not assume, or require, that *any* of those be present; there is no
guarantee that "IP Header" or "IPv6 Header" will be present (there's at
least one IBM page showing a packet with "ARP Header" in a trace), and
there is no guarantee that "TCP Header" will be present (there are
traces with "UDP Header" and "ICMPv6 Hdr").
Do not impose limits, other than the overall line limit, on the amount
of hex data in header or data lines; there is no guarantee that, for
example, a TCP header is 20 bytes long (if there are TCP options, it
*will* have more than 20 bytes).
Make sure we have an even number of hex digits.
Set "caplen" to the actual number of bytes we've read, even if that's
less than the purported packet length.
svn path=/trunk/; revision=45626
2012-10-18 04:52:33 +00:00
|
|
|
data + 9 + 18, err,
|
|
|
|
err_info);
|
|
|
|
if (ascii_offset == -1)
|
2012-04-20 01:43:12 +00:00
|
|
|
{
|
Redo the processing of lines in iSeries text packet dumps.
Process several different flavors of header lines the same: "IP Header",
"IPv6 Header", "ARP Header", "TCP Header", "UDP Header", "ICMP Header",
"ICMPv6 Hdr", "Option Hdr" - the hex data for all of them should be
included in the packet data. Process continuation lines if those
headers wrap over more than one line.
Do not assume, or require, that *any* of those be present; there is no
guarantee that "IP Header" or "IPv6 Header" will be present (there's at
least one IBM page showing a packet with "ARP Header" in a trace), and
there is no guarantee that "TCP Header" will be present (there are
traces with "UDP Header" and "ICMPv6 Hdr").
Do not impose limits, other than the overall line limit, on the amount
of hex data in header or data lines; there is no guarantee that, for
example, a TCP header is 20 bytes long (if there are TCP options, it
*will* have more than 20 bytes).
Make sure we have an even number of hex digits.
Set "caplen" to the actual number of bytes we've read, even if that's
less than the purported packet length.
svn path=/trunk/; revision=45626
2012-10-18 04:52:33 +00:00
|
|
|
/* Bad line. */
|
2014-05-23 10:50:02 +00:00
|
|
|
return FALSE;
|
2012-04-20 01:43:12 +00:00
|
|
|
}
|
Redo the processing of lines in iSeries text packet dumps.
Process several different flavors of header lines the same: "IP Header",
"IPv6 Header", "ARP Header", "TCP Header", "UDP Header", "ICMP Header",
"ICMPv6 Hdr", "Option Hdr" - the hex data for all of them should be
included in the packet data. Process continuation lines if those
headers wrap over more than one line.
Do not assume, or require, that *any* of those be present; there is no
guarantee that "IP Header" or "IPv6 Header" will be present (there's at
least one IBM page showing a packet with "ARP Header" in a trace), and
there is no guarantee that "TCP Header" will be present (there are
traces with "UDP Header" and "ICMPv6 Hdr").
Do not impose limits, other than the overall line limit, on the amount
of hex data in header or data lines; there is no guarantee that, for
example, a TCP header is 20 bytes long (if there are TCP options, it
*will* have more than 20 bytes).
Make sure we have an even number of hex digits.
Set "caplen" to the actual number of bytes we've read, even if that's
less than the purported packet length.
svn path=/trunk/; revision=45626
2012-10-18 04:52:33 +00:00
|
|
|
continue;
|
2012-04-20 01:43:12 +00:00
|
|
|
}
|
Redo the processing of lines in iSeries text packet dumps.
Process several different flavors of header lines the same: "IP Header",
"IPv6 Header", "ARP Header", "TCP Header", "UDP Header", "ICMP Header",
"ICMPv6 Hdr", "Option Hdr" - the hex data for all of them should be
included in the packet data. Process continuation lines if those
headers wrap over more than one line.
Do not assume, or require, that *any* of those be present; there is no
guarantee that "IP Header" or "IPv6 Header" will be present (there's at
least one IBM page showing a packet with "ARP Header" in a trace), and
there is no guarantee that "TCP Header" will be present (there are
traces with "UDP Header" and "ICMPv6 Hdr").
Do not impose limits, other than the overall line limit, on the amount
of hex data in header or data lines; there is no guarantee that, for
example, a TCP header is 20 bytes long (if there are TCP options, it
*will* have more than 20 bytes).
Make sure we have an even number of hex digits.
Set "caplen" to the actual number of bytes we've read, even if that's
less than the purported packet length.
svn path=/trunk/; revision=45626
2012-10-18 04:52:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Is this a continuation of a previous header or data line?
|
|
|
|
* That's blanks followed by hex digits; first try the
|
|
|
|
* "no column separators" form.
|
|
|
|
*
|
|
|
|
* Continuations of header lines begin at an offset of 36;
|
|
|
|
* continuations of data lines begin at an offset of 27.
|
|
|
|
*/
|
|
|
|
if (offset == 36 || offset == 27)
|
|
|
|
{
|
|
|
|
ascii_offset = append_hex_digits(ascii_buf, ascii_offset,
|
2016-05-02 00:52:45 +00:00
|
|
|
pkt_len*2,
|
Redo the processing of lines in iSeries text packet dumps.
Process several different flavors of header lines the same: "IP Header",
"IPv6 Header", "ARP Header", "TCP Header", "UDP Header", "ICMP Header",
"ICMPv6 Hdr", "Option Hdr" - the hex data for all of them should be
included in the packet data. Process continuation lines if those
headers wrap over more than one line.
Do not assume, or require, that *any* of those be present; there is no
guarantee that "IP Header" or "IPv6 Header" will be present (there's at
least one IBM page showing a packet with "ARP Header" in a trace), and
there is no guarantee that "TCP Header" will be present (there are
traces with "UDP Header" and "ICMPv6 Hdr").
Do not impose limits, other than the overall line limit, on the amount
of hex data in header or data lines; there is no guarantee that, for
example, a TCP header is 20 bytes long (if there are TCP options, it
*will* have more than 20 bytes).
Make sure we have an even number of hex digits.
Set "caplen" to the actual number of bytes we've read, even if that's
less than the purported packet length.
svn path=/trunk/; revision=45626
2012-10-18 04:52:33 +00:00
|
|
|
data + offset, err,
|
|
|
|
err_info);
|
|
|
|
if (ascii_offset == -1)
|
2012-04-20 01:43:12 +00:00
|
|
|
{
|
Redo the processing of lines in iSeries text packet dumps.
Process several different flavors of header lines the same: "IP Header",
"IPv6 Header", "ARP Header", "TCP Header", "UDP Header", "ICMP Header",
"ICMPv6 Hdr", "Option Hdr" - the hex data for all of them should be
included in the packet data. Process continuation lines if those
headers wrap over more than one line.
Do not assume, or require, that *any* of those be present; there is no
guarantee that "IP Header" or "IPv6 Header" will be present (there's at
least one IBM page showing a packet with "ARP Header" in a trace), and
there is no guarantee that "TCP Header" will be present (there are
traces with "UDP Header" and "ICMPv6 Hdr").
Do not impose limits, other than the overall line limit, on the amount
of hex data in header or data lines; there is no guarantee that, for
example, a TCP header is 20 bytes long (if there are TCP options, it
*will* have more than 20 bytes).
Make sure we have an even number of hex digits.
Set "caplen" to the actual number of bytes we've read, even if that's
less than the purported packet length.
svn path=/trunk/; revision=45626
2012-10-18 04:52:33 +00:00
|
|
|
/* Bad line. */
|
2014-05-23 10:50:02 +00:00
|
|
|
return FALSE;
|
2012-04-20 01:43:12 +00:00
|
|
|
}
|
Redo the processing of lines in iSeries text packet dumps.
Process several different flavors of header lines the same: "IP Header",
"IPv6 Header", "ARP Header", "TCP Header", "UDP Header", "ICMP Header",
"ICMPv6 Hdr", "Option Hdr" - the hex data for all of them should be
included in the packet data. Process continuation lines if those
headers wrap over more than one line.
Do not assume, or require, that *any* of those be present; there is no
guarantee that "IP Header" or "IPv6 Header" will be present (there's at
least one IBM page showing a packet with "ARP Header" in a trace), and
there is no guarantee that "TCP Header" will be present (there are
traces with "UDP Header" and "ICMPv6 Hdr").
Do not impose limits, other than the overall line limit, on the amount
of hex data in header or data lines; there is no guarantee that, for
example, a TCP header is 20 bytes long (if there are TCP options, it
*will* have more than 20 bytes).
Make sure we have an even number of hex digits.
Set "caplen" to the actual number of bytes we've read, even if that's
less than the purported packet length.
svn path=/trunk/; revision=45626
2012-10-18 04:52:33 +00:00
|
|
|
continue;
|
2012-04-20 01:43:12 +00:00
|
|
|
}
|
2006-03-22 17:37:04 +00:00
|
|
|
|
2006-03-27 16:09:47 +00:00
|
|
|
/*
|
|
|
|
* If we see the identifier for the next packet then rewind and set
|
|
|
|
* isCurrentPacket FALSE
|
2006-03-22 17:37:04 +00:00
|
|
|
*/
|
2012-04-22 18:44:10 +00:00
|
|
|
ascii_strup_inplace (data);
|
2012-04-20 01:43:12 +00:00
|
|
|
/* If packet header found return the offset */
|
|
|
|
num_items_scanned =
|
|
|
|
sscanf (data+78,
|
|
|
|
"%*[ \n\t]ETHV2%*[ .:\n\t]TYPE%*[ .:\n\t]%4s",type);
|
2011-05-29 19:36:21 +00:00
|
|
|
if ((num_items_scanned == 1) && pktline > 1)
|
2012-04-20 01:43:12 +00:00
|
|
|
{
|
|
|
|
isCurrentPacket = FALSE;
|
2012-04-22 18:44:10 +00:00
|
|
|
cur_off = file_tell( fh);
|
2012-04-20 01:43:12 +00:00
|
|
|
if (cur_off == -1)
|
|
|
|
{
|
|
|
|
/* Error. */
|
|
|
|
*err = file_error (fh, err_info);
|
2012-04-22 18:44:10 +00:00
|
|
|
goto errxit;
|
2012-04-20 01:43:12 +00:00
|
|
|
}
|
|
|
|
if (file_seek (fh, cur_off - buflen, SEEK_SET, err) == -1)
|
|
|
|
{
|
2012-04-22 18:44:10 +00:00
|
|
|
/* XXX: need to set err_info ?? */
|
|
|
|
goto errxit;
|
2012-04-20 01:43:12 +00:00
|
|
|
}
|
|
|
|
}
|
2005-11-25 20:30:42 +00:00
|
|
|
}
|
2006-03-22 17:37:04 +00:00
|
|
|
|
2012-04-20 01:43:12 +00:00
|
|
|
/*
|
Redo the processing of lines in iSeries text packet dumps.
Process several different flavors of header lines the same: "IP Header",
"IPv6 Header", "ARP Header", "TCP Header", "UDP Header", "ICMP Header",
"ICMPv6 Hdr", "Option Hdr" - the hex data for all of them should be
included in the packet data. Process continuation lines if those
headers wrap over more than one line.
Do not assume, or require, that *any* of those be present; there is no
guarantee that "IP Header" or "IPv6 Header" will be present (there's at
least one IBM page showing a packet with "ARP Header" in a trace), and
there is no guarantee that "TCP Header" will be present (there are
traces with "UDP Header" and "ICMPv6 Hdr").
Do not impose limits, other than the overall line limit, on the amount
of hex data in header or data lines; there is no guarantee that, for
example, a TCP header is 20 bytes long (if there are TCP options, it
*will* have more than 20 bytes).
Make sure we have an even number of hex digits.
Set "caplen" to the actual number of bytes we've read, even if that's
less than the purported packet length.
svn path=/trunk/; revision=45626
2012-10-18 04:52:33 +00:00
|
|
|
* Make the captured length be the amount of bytes we've read (which
|
|
|
|
* is half the number of characters of hex dump we have).
|
|
|
|
*
|
|
|
|
* XXX - this can happen for IPv6 packets if the next header isn't the
|
|
|
|
* last header.
|
2005-11-25 20:30:42 +00:00
|
|
|
*/
|
2018-02-09 00:19:12 +00:00
|
|
|
rec->rec_header.packet_header.caplen = ((guint32) ascii_offset)/2;
|
2005-11-25 20:30:42 +00:00
|
|
|
|
2013-06-16 00:20:00 +00:00
|
|
|
/* Make sure we have enough room for the packet. */
|
2018-02-09 00:19:12 +00:00
|
|
|
ws_buffer_assure_space (buf, rec->rec_header.packet_header.caplen);
|
2013-06-16 00:20:00 +00:00
|
|
|
/* Convert ascii data to binary and return in the frame buffer */
|
2016-05-02 00:58:49 +00:00
|
|
|
iseries_parse_hex_string (ascii_buf, ws_buffer_start_ptr (buf), ascii_offset);
|
2006-03-22 17:37:04 +00:00
|
|
|
|
2012-04-22 18:44:10 +00:00
|
|
|
/* free buffer allocs and return */
|
2006-03-22 17:37:04 +00:00
|
|
|
*err = 0;
|
Redo the processing of lines in iSeries text packet dumps.
Process several different flavors of header lines the same: "IP Header",
"IPv6 Header", "ARP Header", "TCP Header", "UDP Header", "ICMP Header",
"ICMPv6 Hdr", "Option Hdr" - the hex data for all of them should be
included in the packet data. Process continuation lines if those
headers wrap over more than one line.
Do not assume, or require, that *any* of those be present; there is no
guarantee that "IP Header" or "IPv6 Header" will be present (there's at
least one IBM page showing a packet with "ARP Header" in a trace), and
there is no guarantee that "TCP Header" will be present (there are
traces with "UDP Header" and "ICMPv6 Hdr").
Do not impose limits, other than the overall line limit, on the amount
of hex data in header or data lines; there is no guarantee that, for
example, a TCP header is 20 bytes long (if there are TCP options, it
*will* have more than 20 bytes).
Make sure we have an even number of hex digits.
Set "caplen" to the actual number of bytes we've read, even if that's
less than the purported packet length.
svn path=/trunk/; revision=45626
2012-10-18 04:52:33 +00:00
|
|
|
g_free (ascii_buf);
|
2014-05-23 10:50:02 +00:00
|
|
|
return TRUE;
|
2012-04-22 18:44:10 +00:00
|
|
|
|
|
|
|
errxit:
|
Redo the processing of lines in iSeries text packet dumps.
Process several different flavors of header lines the same: "IP Header",
"IPv6 Header", "ARP Header", "TCP Header", "UDP Header", "ICMP Header",
"ICMPv6 Hdr", "Option Hdr" - the hex data for all of them should be
included in the packet data. Process continuation lines if those
headers wrap over more than one line.
Do not assume, or require, that *any* of those be present; there is no
guarantee that "IP Header" or "IPv6 Header" will be present (there's at
least one IBM page showing a packet with "ARP Header" in a trace), and
there is no guarantee that "TCP Header" will be present (there are
traces with "UDP Header" and "ICMPv6 Hdr").
Do not impose limits, other than the overall line limit, on the amount
of hex data in header or data lines; there is no guarantee that, for
example, a TCP header is 20 bytes long (if there are TCP options, it
*will* have more than 20 bytes).
Make sure we have an even number of hex digits.
Set "caplen" to the actual number of bytes we've read, even if that's
less than the purported packet length.
svn path=/trunk/; revision=45626
2012-10-18 04:52:33 +00:00
|
|
|
g_free (ascii_buf);
|
2014-05-23 10:50:02 +00:00
|
|
|
return FALSE;
|
2005-11-25 20:30:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Simple routine to convert an UNICODE buffer to ASCII
|
2006-03-27 16:09:47 +00:00
|
|
|
*
|
2005-11-25 20:30:42 +00:00
|
|
|
* XXX - This may be possible with iconv or similar
|
|
|
|
*/
|
2006-03-22 17:37:04 +00:00
|
|
|
static int
|
|
|
|
iseries_UNICODE_to_ASCII (guint8 * buf, guint bytes)
|
2005-11-25 20:30:42 +00:00
|
|
|
{
|
2012-04-22 18:44:10 +00:00
|
|
|
guint i;
|
2006-03-22 17:37:04 +00:00
|
|
|
guint8 *bufptr;
|
2012-04-22 18:44:10 +00:00
|
|
|
|
2005-11-25 20:30:42 +00:00
|
|
|
bufptr = buf;
|
2006-03-22 17:37:04 +00:00
|
|
|
|
|
|
|
for (i = 0; i < bytes; i++)
|
|
|
|
{
|
|
|
|
switch (buf[i])
|
2012-04-20 01:43:12 +00:00
|
|
|
{
|
2012-04-22 18:44:10 +00:00
|
|
|
case 0xFE:
|
|
|
|
case 0xFF:
|
|
|
|
case 0x00:
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
*bufptr = buf[i];
|
|
|
|
bufptr++;
|
2012-04-20 01:43:12 +00:00
|
|
|
}
|
2019-03-24 21:23:32 +00:00
|
|
|
if (buf[i] == 0x0A)
|
2019-03-25 09:20:10 +00:00
|
|
|
break;
|
2005-11-25 20:30:42 +00:00
|
|
|
}
|
2019-03-25 09:20:10 +00:00
|
|
|
g_assert(bufptr < buf + bytes);
|
|
|
|
*bufptr = '\0';
|
2006-03-22 17:37:04 +00:00
|
|
|
return i;
|
2005-11-25 20:30:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Simple routine to convert an ASCII hex string to binary data
|
|
|
|
* Requires ASCII hex data and buffer to populate with binary data
|
|
|
|
*/
|
2006-03-22 17:37:04 +00:00
|
|
|
static gboolean
|
2012-12-26 06:14:44 +00:00
|
|
|
iseries_parse_hex_string (const char * ascii, guint8 * buf, size_t len)
|
2006-03-22 17:37:04 +00:00
|
|
|
{
|
2012-12-26 06:14:44 +00:00
|
|
|
size_t i;
|
|
|
|
int byte;
|
2012-04-22 18:44:10 +00:00
|
|
|
gint hexvalue;
|
2008-05-29 23:30:51 +00:00
|
|
|
guint8 bytevalue;
|
2006-03-22 17:37:04 +00:00
|
|
|
|
|
|
|
byte = 0;
|
2012-12-26 06:56:17 +00:00
|
|
|
for (i = 0; i < len; i++)
|
2006-03-22 17:37:04 +00:00
|
|
|
{
|
2008-05-29 23:30:51 +00:00
|
|
|
hexvalue = g_ascii_xdigit_value(ascii[i]);
|
2006-03-22 17:37:04 +00:00
|
|
|
i++;
|
2008-05-29 23:30:51 +00:00
|
|
|
if (hexvalue == -1)
|
2012-04-20 01:43:12 +00:00
|
|
|
return FALSE; /* not a valid hex digit */
|
2008-05-29 23:30:51 +00:00
|
|
|
bytevalue = (guint8)(hexvalue << 4);
|
|
|
|
if (i >= len)
|
2012-04-20 01:43:12 +00:00
|
|
|
return FALSE; /* only one hex digit of the byte is present */
|
2008-05-29 23:30:51 +00:00
|
|
|
hexvalue = g_ascii_xdigit_value(ascii[i]);
|
|
|
|
if (hexvalue == -1)
|
2012-04-20 01:43:12 +00:00
|
|
|
return FALSE; /* not a valid hex digit */
|
2008-05-29 23:30:51 +00:00
|
|
|
bytevalue |= (guint8) hexvalue;
|
|
|
|
buf[byte] = bytevalue;
|
2006-03-22 17:37:04 +00:00
|
|
|
byte++;
|
|
|
|
}
|
2005-11-25 20:30:42 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
2012-04-22 18:44:10 +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 iseries_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 iseries_info = {
|
|
|
|
"IBM iSeries comm. trace (ASCII)", "iseries_ascii", "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(iseries_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 iseries_unicode_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 iseries_unicode_info = {
|
|
|
|
"IBM iSeries comm. trace (Unicode)", "iseries_unicode", "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(iseries_unicode_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_iseries(void)
|
|
|
|
{
|
2021-02-24 03:10:35 +00:00
|
|
|
iseries_file_type_subtype = wtap_register_file_type_subtype(&iseries_info);
|
|
|
|
iseries_unicode_file_type_subtype = wtap_register_file_type_subtype(&iseries_unicode_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("ISERIES",
|
|
|
|
iseries_file_type_subtype);
|
|
|
|
wtap_register_backwards_compatibility_lua_name("ISERIES_UNICODE",
|
|
|
|
iseries_unicode_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
|
|
|
}
|
|
|
|
|
2012-04-22 18:44:10 +00:00
|
|
|
/*
|
2019-07-26 18:43:17 +00:00
|
|
|
* Editor modelines - https://www.wireshark.org/tools/modelines.html
|
2012-04-22 18:44:10 +00:00
|
|
|
*
|
|
|
|
* Local variables:
|
|
|
|
* c-basic-offset: 2
|
|
|
|
* tab-width: 8
|
|
|
|
* indent-tabs-mode: nil
|
|
|
|
* End:
|
|
|
|
*
|
|
|
|
* vi: set shiftwidth=2 tabstop=8 expandtab:
|
|
|
|
* :indentSize=2:tabSize=8:noTabs=true:
|
|
|
|
*/
|