2 * Routines for NexusWare MTP3 over UDP transport
3 * Copyright 2010 by Holger Hans Peter Freyther <zecke@selfish.org>
4 * Copyright 2010 by On-Waves
6 * Wireshark - Network traffic analyzer
7 * By Gerald Combs <gerald@wireshark.org>
8 * Copyright 1998 Gerald Combs
10 * SPDX-License-Identifier: GPL-2.0-or-later
15 #include <epan/packet.h>
17 void proto_register_mwmtp(void);
18 void proto_reg_handoff_nwmtp(void);
20 static dissector_handle_t mtp_handle
;
21 static int proto_nwmtp
;
23 static int hf_nwmtp_transp_type
;
24 static int hf_nwmtp_user_context
;
25 static int hf_nwmtp_data_type
;
26 static int hf_nwmtp_data_index
;
27 static int hf_nwmtp_data_length
;
32 static dissector_handle_t nwmtp_handle
;
34 static const value_string nwmtp_transport_type_vals
[] = {
40 static const value_string nwmtp_data_type_vals
[] = {
45 {16, "Retrieved MSU Prio 0" },
46 {17, "Retrieved MSU Prio 0" },
47 {18, "Retrieved MSU Prio 0" },
48 {32, "Retrieval complete" },
49 {33, "Retrieval impossible" },
50 {34, "Link in service" },
51 {35, "Link out of service" },
55 static int dissect_nwmtp(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*tree
, void* data _U_
)
59 col_set_str(pinfo
->cinfo
, COL_PROTOCOL
, "NW MTP");
60 col_clear(pinfo
->cinfo
, COL_INFO
);
62 while (tvb_reported_length_remaining(tvb
, offset
) > 0) {
65 proto_item
*nwmtp_tree
;
69 /* update the info column */
70 type
= val_to_str_const(tvb_get_uint8(tvb
, offset
+ 1),
71 nwmtp_data_type_vals
, "Unknown");
72 col_set_str(pinfo
->cinfo
, COL_INFO
, type
);
74 len
= tvb_get_ntohl(tvb
, offset
+ 8);
77 ti
= proto_tree_add_protocol_format(tree
, proto_nwmtp
,
78 tvb
, offset
, len
+ 12,
79 "NexusWare C7 UDP Protocol");
81 nwmtp_tree
= proto_item_add_subtree(ti
, ett_mwmtp
);
82 proto_tree_add_item(nwmtp_tree
, hf_nwmtp_transp_type
,
83 tvb
, offset
, 1, ENC_BIG_ENDIAN
);
84 proto_tree_add_item(nwmtp_tree
, hf_nwmtp_data_type
,
85 tvb
, offset
+ 1, 1, ENC_BIG_ENDIAN
);
86 proto_tree_add_item(nwmtp_tree
, hf_nwmtp_data_index
,
87 tvb
, offset
+ 2, 2, ENC_BIG_ENDIAN
);
88 proto_tree_add_item(nwmtp_tree
, hf_nwmtp_user_context
,
89 tvb
, offset
+ 4, 4, ENC_BIG_ENDIAN
);
90 proto_tree_add_item(nwmtp_tree
, hf_nwmtp_data_length
,
91 tvb
, offset
+ 8, 4, ENC_BIG_ENDIAN
);
94 next_tvb
= tvb_new_subset_length(tvb
, offset
+ 12, len
);
95 if (tvb_reported_length(next_tvb
) > 0)
96 call_dissector(mtp_handle
, next_tvb
, pinfo
, tree
);
97 /* Check for overflows, which probably can't happen, but better
98 * safe than sorry. See
99 * https://gitlab.com/wireshark/wireshark/-/issues/8169
101 DISSECTOR_ASSERT(len
< UINT32_MAX
- 11);
102 DISSECTOR_ASSERT((uint64_t)offset
+ len
+ 12 < INT_MAX
);
106 return tvb_captured_length(tvb
);
109 void proto_register_mwmtp(void)
111 static hf_register_info hf
[] = {
112 {&hf_nwmtp_transp_type
,
113 {"Transport Type", "nwmtp.transp_type",
114 FT_UINT8
, BASE_DEC
, VALS(nwmtp_transport_type_vals
), 0x0,
115 "The Transport Type", HFILL
}
117 {&hf_nwmtp_data_type
,
118 {"Data Type", "nwmtp.data_type",
119 FT_UINT8
, BASE_DEC
, VALS(nwmtp_data_type_vals
), 0x0,
120 "The Data Type", HFILL
}
122 {&hf_nwmtp_data_index
,
123 {"Link Index", "nwmtp.link_index",
124 FT_UINT16
, BASE_DEC
, NULL
, 0x0,
127 {&hf_nwmtp_user_context
,
128 {"User Context", "nwmtp.user_context",
129 FT_UINT32
, BASE_DEC
, NULL
, 0x0,
130 "Use Context", HFILL
}
132 {&hf_nwmtp_data_length
,
133 {"Length", "nwmtp.data_length",
134 FT_UINT32
, BASE_DEC
, NULL
, 0x0,
135 "Data Length", HFILL
}
139 static int *ett
[] = {
144 proto_register_protocol("NexusWare C7 MTP", "MTP over NW UDP", "nw_mtp");
146 proto_register_field_array(proto_nwmtp
, hf
, array_length(hf
));
147 proto_register_subtree_array(ett
, array_length(ett
));
149 nwmtp_handle
= register_dissector("nw_mtp", dissect_nwmtp
, proto_nwmtp
);
152 void proto_reg_handoff_nwmtp(void)
154 dissector_add_for_decode_as_with_preference("udp.port", nwmtp_handle
);
155 mtp_handle
= find_dissector_add_dependency("mtp3", proto_nwmtp
);
159 * Editor modelines - https://www.wireshark.org/tools/modelines.html
164 * indent-tabs-mode: t
167 * vi: set shiftwidth=8 tabstop=8 noexpandtab:
168 * :indentSize=8:tabSize=8:noTabs=false: