2 * Routines for DisplayPort AUX-Channel monitor dissection
3 * Copyright 2018, Dirk Eibach, Guntermann & Drunck GmbH <dirk.eibach@gdsys.cc>
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
14 #include <epan/packet.h>
15 #include <epan/conversation.h>
16 #include <epan/proto_data.h>
17 #include <wiretap/wtap.h>
19 #include "packet-dpaux.h"
23 DPAUXMON_DATA_END
= 0x01,
24 DPAUXMON_EVENT
= 0x02,
25 DPAUXMON_START
= 0x03,
27 DPAUXMON_TS_OVERFLOW
= 0x84,
30 void proto_reg_handoff_dpauxmon(void);
31 void proto_register_dpauxmon(void);
33 static dissector_handle_t dpaux_handle
;
34 static dissector_handle_t dpauxmon_handle
;
36 /* Initialize the protocol and registered fields */
37 static int proto_dpauxmon
;
39 static int hf_packet_type
;
47 static int * const input_fields
[] = {
55 /* Initialize the subtree pointers */
56 static int ett_dpauxmon
;
58 static const value_string packet_type_vals
[] = {
59 { DPAUXMON_DATA
, "Data" },
60 { DPAUXMON_EVENT
, "Event" },
61 { DPAUXMON_START
, "Start" },
62 { DPAUXMON_STOP
, "Stop" },
63 { DPAUXMON_TS_OVERFLOW
, "Timestamp Overflow" },
67 static const value_string origin_vals
[] = {
74 dissect_dpauxmon(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*tree
,
78 proto_tree
*dpauxmon_tree
;
81 col_set_str(pinfo
->cinfo
, COL_PROTOCOL
, "DPAUXMON");
82 col_set_str(pinfo
->cinfo
, COL_RES_DL_DST
, "N/A");
83 col_set_str(pinfo
->cinfo
, COL_RES_DL_SRC
, "Internal");
85 /* create display subtree for the protocol */
86 ti
= proto_tree_add_item(tree
, proto_dpauxmon
, tvb
, 0, -1, ENC_NA
);
87 dpauxmon_tree
= proto_item_add_subtree(ti
, ett_dpauxmon
);
89 proto_tree_add_item_ret_uint(dpauxmon_tree
, hf_packet_type
, tvb
, 0, 1, ENC_NA
, &packet_type
);
90 col_add_fstr(pinfo
->cinfo
, COL_INFO
, "DisplayPort AUX channel - %s", val_to_str_const(packet_type
, packet_type_vals
, "Unknown"));
92 switch (packet_type
) {
94 struct dpaux_info dpaux_info
;
96 dpaux_info
.from_source
= tvb_get_uint8(tvb
, 1);
97 proto_tree_add_uint(dpauxmon_tree
, hf_origin
, tvb
, 1, 1, dpaux_info
.from_source
);
99 call_dissector_with_data(dpaux_handle
, tvb_new_subset_remaining(tvb
, 2),
100 pinfo
, dpauxmon_tree
, &dpaux_info
);
105 proto_tree_add_bitmask(dpauxmon_tree
, tvb
, 1, hf_inputs
, 0, input_fields
,
110 case DPAUXMON_TS_OVERFLOW
:
114 return tvb_captured_length(tvb
);
118 proto_register_dpauxmon(void)
120 /* Setup protocol subtree array */
121 static int *ett
[] = {
125 /* Setup list of header fields See Section 1.5 of README.dissector for
127 static hf_register_info hf
[] = {
129 { "Packet Type", "dpauxmon.packet_type",
130 FT_UINT8
, BASE_DEC
, VALS(packet_type_vals
), 0,
134 { "Origin", "dpauxmon.origin",
135 FT_UINT8
, BASE_DEC
, VALS(origin_vals
), 0,
139 { "Inputs", "dpauxmon.inputs",
140 FT_UINT8
, BASE_HEX
, NULL
, 0,
144 { "Hotplug Detect", "dpauxmon.hpd",
145 FT_BOOLEAN
, 4, NULL
, 0x1,
149 { "IN0", "dpauxmon.in0",
150 FT_BOOLEAN
, 4, NULL
, 0x2,
154 { "IN1", "dpauxmon.in1",
155 FT_BOOLEAN
, 4, NULL
, 0x4,
159 { "IN2", "dpauxmon.in2",
160 FT_BOOLEAN
, 4, NULL
, 0x8,
165 /* Register the protocol name and description */
166 proto_dpauxmon
= proto_register_protocol("DPAUXMON DisplayPort AUX channel monitor", "DPAUXMON", "dpauxmon");
167 proto_register_field_array(proto_dpauxmon
, hf
, array_length(hf
));
168 proto_register_subtree_array(ett
, array_length(ett
));
170 dpauxmon_handle
= register_dissector("dpauxmon", dissect_dpauxmon
, proto_dpauxmon
);
174 proto_reg_handoff_dpauxmon(void)
176 static bool initialized
= false;
178 dpaux_handle
= find_dissector_add_dependency("dpaux", proto_dpauxmon
);
183 dissector_delete_uint("wtap_encap", WTAP_ENCAP_DPAUXMON
, dpauxmon_handle
);
186 dissector_add_uint("wtap_encap", WTAP_ENCAP_DPAUXMON
, dpauxmon_handle
);
190 * Editor modelines - https://www.wireshark.org/tools/modelines.html
195 * indent-tabs-mode: nil
198 * vi: set shiftwidth=4 tabstop=8 expandtab:
199 * :indentSize=4:tabSize=8:noTabs=true: