forked from osmocom/wireshark
text2pcap: Add Export PDU
Support Export PDU functionality from text2pcap. Related to #16724.pespin/osmux-wip
parent
a3df9fe13f
commit
0dfc6414e0
|
@ -212,6 +212,18 @@ hex. This corresponds to the `-A` option for __od__.
|
|||
direction indicators or timestamps after the first byte along with any offsets.
|
||||
--
|
||||
|
||||
-P <dissector>::
|
||||
+
|
||||
--
|
||||
Include an EXPORTED_PDU header before each packet. Specify, as a string,
|
||||
the dissector to be called for the packet (PROTO_NAME tag). Use this option
|
||||
if your dump is the payload for a single upper layer protocol (so specifying a
|
||||
link layer type would not work) and you wish to create a capture file without
|
||||
a full dummy protocol stack. Automatically sets the link layer type to
|
||||
Wirehshark Upper PDU export. Without this option, if the Upper PDU export
|
||||
link layer type (252) is selected the dissector defaults to "data".
|
||||
--
|
||||
|
||||
-q::
|
||||
+
|
||||
--
|
||||
|
|
31
text2pcap.c
31
text2pcap.c
|
@ -147,6 +147,9 @@ static guint16 hdr_data_chunk_sid = 0;
|
|||
static guint16 hdr_data_chunk_ssn = 0;
|
||||
static guint32 hdr_data_chunk_ppid = 0;
|
||||
|
||||
/* Export PDU */
|
||||
static gboolean hdr_export_pdu = FALSE;
|
||||
|
||||
/* ASCII text dump identification */
|
||||
static gboolean identify_ascii = FALSE;
|
||||
|
||||
|
@ -319,6 +322,11 @@ print_usage (FILE *output)
|
|||
" chunk header with payload protocol identifier ppi.\n"
|
||||
" Example: -S 30,40,34\n"
|
||||
"\n"
|
||||
" -P <dissector> prepend EXPORTED_PDU header with specifieddissector\n"
|
||||
" as the payload PROTO_NAME tag.\n"
|
||||
" Automatically sets link type to Upper PDU Export.\n"
|
||||
" EXPORTED_PDU payload defaults to \"data\" otherwise.\n"
|
||||
"\n"
|
||||
"Miscellaneous:\n"
|
||||
" -h display this help and exit.\n"
|
||||
" -v print version information and exit.\n"
|
||||
|
@ -369,11 +377,13 @@ parse_options(int argc, char *argv[], text_import_info_t * const info, wtap_dump
|
|||
char* err_info;
|
||||
|
||||
info->hexdump.offset_type = OFFSET_HEX;
|
||||
info->payload = "data";
|
||||
|
||||
/* Initialize the version information. */
|
||||
ws_init_version_info("Text2pcap (Wireshark)", NULL, NULL, NULL);
|
||||
|
||||
/* Scan CLI parameters */
|
||||
while ((c = ws_getopt_long(argc, argv, "aDdhqe:i:l:m:nN:o:u:s:S:t:T:v4:6:", long_options, NULL)) != -1) {
|
||||
while ((c = ws_getopt_long(argc, argv, "aDdhqe:i:l:m:nN:o:u:P:s:S:t:T:v4:6:", long_options, NULL)) != -1) {
|
||||
switch (c) {
|
||||
case 'h':
|
||||
show_help_header("Generate a capture file from an ASCII hexdump of packets.");
|
||||
|
@ -421,6 +431,12 @@ parse_options(int argc, char *argv[], text_import_info_t * const info, wtap_dump
|
|||
break;
|
||||
}
|
||||
|
||||
case 'P':
|
||||
hdr_export_pdu = TRUE;
|
||||
pcap_link_type = 252;
|
||||
info->payload = ws_optarg;
|
||||
break;
|
||||
|
||||
case 's':
|
||||
hdr_sctp = TRUE;
|
||||
hdr_data_chunk = FALSE;
|
||||
|
@ -656,6 +672,11 @@ parse_options(int argc, char *argv[], text_import_info_t * const info, wtap_dump
|
|||
return INVALID_OPTION;
|
||||
}
|
||||
|
||||
if (pcap_link_type != 252 && hdr_export_pdu) {
|
||||
cmdarg_err("Export PDU (-P) requires WIRESHARK_UPPER_PDU link type (252)");
|
||||
return INVALID_OPTION;
|
||||
}
|
||||
|
||||
if (have_hdr_ip_proto && !(hdr_ip || hdr_ipv6)) {
|
||||
/*
|
||||
* If we have an IP protocol to add to the header, but neither an
|
||||
|
@ -744,7 +765,9 @@ parse_options(int argc, char *argv[], text_import_info_t * const info, wtap_dump
|
|||
info->encapsulation = wtap_encap_type;
|
||||
info->wdh = wdh;
|
||||
|
||||
if (hdr_data_chunk) {
|
||||
if (hdr_export_pdu) {
|
||||
info->dummy_header_type = HEADER_EXPORT_PDU;
|
||||
} else if (hdr_data_chunk) {
|
||||
info->dummy_header_type = HEADER_SCTP_DATA;
|
||||
} else if (hdr_sctp) {
|
||||
info->dummy_header_type = HEADER_SCTP;
|
||||
|
@ -781,10 +804,6 @@ parse_options(int argc, char *argv[], text_import_info_t * const info, wtap_dump
|
|||
info->tag = hdr_sctp_tag;
|
||||
info->ppi = hdr_data_chunk_ppid;
|
||||
|
||||
#if 0
|
||||
info->payload = /* XXX Export PDU not supported by text2pcap yet */
|
||||
#endif
|
||||
|
||||
info->max_frame_length = max_offset;
|
||||
info->identify_ascii = identify_ascii;
|
||||
|
||||
|
|
Loading…
Reference in New Issue