2 * Routines for pcaplog dissection
3 * Copyright 2023, Dr. Lars Völker <lars.voelker@technica-engineering.de>
5 * Wireshark - Network traffic analyzer
6 * By Gerald Combs <gerald@wireshark.org>
7 * Copyright 1998 Gerald Combs
9 * SPDX-License-Identifier: GPL-2.0-or-later
15 #define WS_LOG_DOMAIN "pcaplog"
17 #define PEN_VCTR 46254
19 #include <wireshark.h>
21 #include <epan/packet.h>
22 #include <epan/addr_resolv.h>
24 void proto_reg_handoff_pcaplog(void);
25 void proto_register_pcaplog(void);
27 static int proto_pcaplog
;
28 static int hf_pcaplog_type
;
29 static int hf_pcaplog_length
;
30 static int hf_pcaplog_data
;
32 static dissector_handle_t pcaplog_handle
;
33 static dissector_handle_t xml_handle
;
35 static int ett_pcaplog
;
36 static int ett_pcaplog_data
;
39 dissect_pcaplog(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*tree
,
44 proto_item
*pcaplog_item
;
45 proto_tree
*pcaplog_tree
;
47 proto_tree
*pt_pcaplog_data
;
49 pcaplog_item
= proto_tree_add_item(tree
, proto_pcaplog
, tvb
, 0, -1, ENC_NA
);
50 pcaplog_tree
= proto_item_add_subtree(pcaplog_item
, ett_pcaplog
);
52 proto_tree_add_item_ret_uint(pcaplog_tree
, hf_pcaplog_type
, tvb
, 0, 4, ENC_LITTLE_ENDIAN
, &data_type
);
53 proto_tree_add_item_ret_uint(pcaplog_tree
, hf_pcaplog_length
, tvb
, 4, 4, ENC_LITTLE_ENDIAN
, &data_length
);
54 pi_tmp
= proto_tree_add_item(pcaplog_tree
, hf_pcaplog_data
, tvb
, 8, data_length
, ENC_NA
);
55 pt_pcaplog_data
= proto_item_add_subtree(pi_tmp
, ett_pcaplog_data
);
57 col_set_str(pinfo
->cinfo
, COL_PROTOCOL
, "pcaplog");
58 col_add_fstr(pinfo
->cinfo
, COL_INFO
, "Custom Block: PEN = %s (%d), will%s be copied",
59 enterprises_lookup(pinfo
->rec
->rec_header
.custom_block_header
.pen
, "Unknown"),
60 pinfo
->rec
->rec_header
.custom_block_header
.pen
,
61 pinfo
->rec
->rec_header
.custom_block_header
.copy_allowed
? "" : " not");
63 /* at least data_types 1-3 seem XML-based */
64 if (data_type
> 0 && data_type
<= 3) {
65 call_dissector(xml_handle
, tvb_new_subset_remaining(tvb
, 8), pinfo
, pt_pcaplog_data
);
67 call_data_dissector(tvb_new_subset_remaining(tvb
, 8), pinfo
, pt_pcaplog_data
);
69 return tvb_captured_length(tvb
);
73 proto_register_pcaplog(void)
75 static hf_register_info hf
[] = {
77 { "Date Type", "pcaplog.data_type",
78 FT_UINT32
, BASE_DEC
, NULL
, 0x0,
82 { "Data Length", "pcaplog.data_length",
83 FT_UINT32
, BASE_DEC
, NULL
, 0x0,
87 { "Data", "pcaplog.data",
88 FT_BYTES
, BASE_NONE
, NULL
, 0x0,
97 proto_pcaplog
= proto_register_protocol("pcaplog",
98 "pcaplog", "pcaplog");
100 proto_register_field_array(proto_pcaplog
, hf
, array_length(hf
));
101 proto_register_subtree_array(ett
, array_length(ett
));
103 pcaplog_handle
= register_dissector("pcaplog", dissect_pcaplog
,
109 proto_reg_handoff_pcaplog(void)
111 xml_handle
= find_dissector_add_dependency("xml", proto_pcaplog
);
112 dissector_add_uint("pcapng_custom_block", PEN_VCTR
, pcaplog_handle
);