forked from osmocom/wireshark
text2pcap: Support OFFSET_NONE
This commit is contained in:
parent
f63571c3e8
commit
8cafcfa5a9
|
@ -23,7 +23,7 @@ text2pcap - Generate a capture file from an ASCII hexdump of packets
|
||||||
[ *-n* ]
|
[ *-n* ]
|
||||||
[ *-N* <intf-name> ]
|
[ *-N* <intf-name> ]
|
||||||
[ *-m* <max-packet> ]
|
[ *-m* <max-packet> ]
|
||||||
[ *-o* hex|oct|dec ]
|
[ *-o* hex|oct|dec|none ]
|
||||||
[ *-q* ]
|
[ *-q* ]
|
||||||
[ *-s* <srcport>,<destport>,<tag> ]
|
[ *-s* <srcport>,<destport>,<tag> ]
|
||||||
[ *-S* <srcport>,<destport>,<ppi> ]
|
[ *-S* <srcport>,<destport>,<ppi> ]
|
||||||
|
@ -202,11 +202,14 @@ Specify a name for the interface included when writing a pcapng format
|
||||||
file. By default no name is defined.
|
file. By default no name is defined.
|
||||||
--
|
--
|
||||||
|
|
||||||
-o hex|oct|dec::
|
-o hex|oct|dec|none::
|
||||||
+
|
+
|
||||||
--
|
--
|
||||||
Specify the radix for the offsets (hex, octal or decimal). Defaults to
|
Specify the radix for the offsets (hex, octal, decimal, or none). Defaults to
|
||||||
hex. This corresponds to the `-A` option for __od__.
|
hex. This corresponds to the `-A` option for __od__.
|
||||||
|
|
||||||
|
*NOTE:* With __-o none__, only one packet will be created, ignoring any
|
||||||
|
direction indicators or timestamps after the first byte along with any offsets.
|
||||||
--
|
--
|
||||||
|
|
||||||
-q::
|
-q::
|
||||||
|
@ -243,15 +246,12 @@ into the SCTP header.
|
||||||
+
|
+
|
||||||
--
|
--
|
||||||
Treats the text before the packet as a date/time code; __timefmt__ is a
|
Treats the text before the packet as a date/time code; __timefmt__ is a
|
||||||
format string of the sort supported by strftime(3).
|
format string supported by strftime(3), supplemented with the field
|
||||||
Example: The time "10:15:14.5476" has the format code "%H:%M:%S."
|
descriptor "%f" for fractional seconds up to nanoseconds.
|
||||||
|
Example: The time "10:15:14.5476" has the format code "%H:%M:%S.%f"
|
||||||
The special format string __ISO__ indicates that the string should be
|
The special format string __ISO__ indicates that the string should be
|
||||||
parsed according to the ISO-8601 specification.
|
parsed according to the ISO-8601 specification.
|
||||||
|
|
||||||
*NOTE:* The subsecond component delimiter must be specified (.) but no
|
|
||||||
pattern is required; the remaining number is assumed to be fractions of
|
|
||||||
a second.
|
|
||||||
|
|
||||||
*NOTE:* Date/time fields from the current date/time are
|
*NOTE:* Date/time fields from the current date/time are
|
||||||
used as the default for unspecified fields.
|
used as the default for unspecified fields.
|
||||||
--
|
--
|
||||||
|
|
21
text2pcap.c
21
text2pcap.c
|
@ -171,9 +171,6 @@ static char *output_filename;
|
||||||
|
|
||||||
static wtap_dumper* wdh;
|
static wtap_dumper* wdh;
|
||||||
|
|
||||||
/* Offset base to parse */
|
|
||||||
static guint32 offset_base = 16;
|
|
||||||
|
|
||||||
/* Encapsulation type; see wiretap/wtap.h for details */
|
/* Encapsulation type; see wiretap/wtap.h for details */
|
||||||
static guint32 wtap_encap_type = 1; /* Default is WTAP_ENCAP_ETHERNET */
|
static guint32 wtap_encap_type = 1; /* Default is WTAP_ENCAP_ETHERNET */
|
||||||
|
|
||||||
|
@ -259,7 +256,7 @@ print_usage (FILE *output)
|
||||||
" <outfile> specifies output filename (use - for standard output)\n"
|
" <outfile> specifies output filename (use - for standard output)\n"
|
||||||
"\n"
|
"\n"
|
||||||
"Input:\n"
|
"Input:\n"
|
||||||
" -o hex|oct|dec parse offsets as (h)ex, (o)ctal or (d)ecimal;\n"
|
" -o hex|oct|dec|none parse offsets as (h)ex, (o)ctal, (d)ecimal, or (n)one;\n"
|
||||||
" default is hex.\n"
|
" default is hex.\n"
|
||||||
" -t <timefmt> treat the text before the packet as a date/time code;\n"
|
" -t <timefmt> treat the text before the packet as a date/time code;\n"
|
||||||
" the specified argument is a format string of the sort\n"
|
" the specified argument is a format string of the sort\n"
|
||||||
|
@ -375,6 +372,7 @@ parse_options(int argc, char *argv[], text_import_info_t * const info, wtap_dump
|
||||||
int err;
|
int err;
|
||||||
char* err_info;
|
char* err_info;
|
||||||
|
|
||||||
|
info->hexdump.offset_type = OFFSET_HEX;
|
||||||
/* Initialize the version information. */
|
/* Initialize the version information. */
|
||||||
ws_init_version_info("Text2pcap (Wireshark)", NULL, NULL, NULL);
|
ws_init_version_info("Text2pcap (Wireshark)", NULL, NULL, NULL);
|
||||||
|
|
||||||
|
@ -394,15 +392,16 @@ parse_options(int argc, char *argv[], text_import_info_t * const info, wtap_dump
|
||||||
case 'n': use_pcapng = TRUE; break;
|
case 'n': use_pcapng = TRUE; break;
|
||||||
case 'N': interface_name = ws_optarg; break;
|
case 'N': interface_name = ws_optarg; break;
|
||||||
case 'o':
|
case 'o':
|
||||||
if (ws_optarg[0] != 'h' && ws_optarg[0] != 'o' && ws_optarg[0] != 'd') {
|
if (ws_optarg[0] != 'h' && ws_optarg[0] != 'o' && ws_optarg[0] != 'd' && ws_optarg[0] != 'n') {
|
||||||
cmdarg_err("Bad argument for '-o': %s", ws_optarg);
|
cmdarg_err("Bad argument for '-o': %s", ws_optarg);
|
||||||
print_usage(stderr);
|
print_usage(stderr);
|
||||||
return INVALID_OPTION;
|
return INVALID_OPTION;
|
||||||
}
|
}
|
||||||
switch (ws_optarg[0]) {
|
switch (ws_optarg[0]) {
|
||||||
case 'o': offset_base = 8; break;
|
case 'o': info->hexdump.offset_type = OFFSET_OCT; break;
|
||||||
case 'h': offset_base = 16; break;
|
case 'h': info->hexdump.offset_type = OFFSET_HEX; break;
|
||||||
case 'd': offset_base = 10; break;
|
case 'd': info->hexdump.offset_type = OFFSET_DEC; break;
|
||||||
|
case 'n': info->hexdump.offset_type = OFFSET_NONE; break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'e':
|
case 'e':
|
||||||
|
@ -743,12 +742,6 @@ parse_options(int argc, char *argv[], text_import_info_t * const info, wtap_dump
|
||||||
info->import_text_filename = input_filename;
|
info->import_text_filename = input_filename;
|
||||||
info->output_filename = output_filename;
|
info->output_filename = output_filename;
|
||||||
info->hexdump.import_text_FILE = input_file;
|
info->hexdump.import_text_FILE = input_file;
|
||||||
switch (offset_base) {
|
|
||||||
case (16): info->hexdump.offset_type = OFFSET_HEX; break;
|
|
||||||
case (10): info->hexdump.offset_type = OFFSET_DEC; break;
|
|
||||||
case (8): info->hexdump.offset_type = OFFSET_OCT; break;
|
|
||||||
default: info->hexdump.offset_type = OFFSET_HEX; break;
|
|
||||||
}
|
|
||||||
info->hexdump.has_direction = has_direction;
|
info->hexdump.has_direction = has_direction;
|
||||||
info->timestamp_format = ts_fmt;
|
info->timestamp_format = ts_fmt;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue