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
8 * Wireshark - Network traffic analyzer
9 * By Gerald Combs <gerald@wireshark.org>
10 * Copyright 1998 Gerald Combs
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
31 #include <epan/packet.h>
34 static dissector_handle_t mtp_handle
;
35 static gint proto_nwmtp
= -1;
37 static int hf_nwmtp_transp_type
= -1;
38 static int hf_nwmtp_user_context
= -1;
39 static int hf_nwmtp_data_type
= -1;
40 static int hf_nwmtp_data_index
= -1;
41 static int hf_nwmtp_data_length
= -1;
44 static gint ett_mwmtp
= -1;
46 static dissector_handle_t nwmtp_handle
;
48 static const value_string nwmtp_transport_type_vals
[] = {
54 static const value_string nwmtp_data_type_vals
[] = {
59 {16, "Retrieved MSU Prio 0" },
60 {17, "Retrieved MSU Prio 0" },
61 {18, "Retrieved MSU Prio 0" },
62 {32, "Retrieval complete" },
63 {33, "Retrieval impossible" },
64 {34, "Link in service" },
65 {35, "Link out of service" },
69 static void dissect_nwmtp(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*tree
)
73 col_set_str(pinfo
->cinfo
, COL_PROTOCOL
, "NW MTP");
74 col_clear(pinfo
->cinfo
, COL_INFO
);
76 while (tvb_reported_length_remaining(tvb
, offset
) > 0) {
79 proto_item
*nwmtp_tree
;
83 /* update the info column */
84 type
= val_to_str_const(tvb_get_guint8(tvb
, offset
+ 1),
85 nwmtp_data_type_vals
, "Unknown");
86 col_set_str(pinfo
->cinfo
, COL_INFO
, type
);
88 len
= tvb_get_ntohl(tvb
, offset
+ 8);
91 ti
= proto_tree_add_protocol_format(tree
, proto_nwmtp
,
92 tvb
, offset
, len
+ 12,
93 "NexusWare C7 UDP Protocol");
95 nwmtp_tree
= proto_item_add_subtree(ti
, ett_mwmtp
);
96 proto_tree_add_item(nwmtp_tree
, hf_nwmtp_transp_type
,
97 tvb
, offset
, 1, ENC_BIG_ENDIAN
);
98 proto_tree_add_item(nwmtp_tree
, hf_nwmtp_data_type
,
99 tvb
, offset
+ 1, 1, ENC_BIG_ENDIAN
);
100 proto_tree_add_item(nwmtp_tree
, hf_nwmtp_data_index
,
101 tvb
, offset
+ 2, 2, ENC_BIG_ENDIAN
);
102 proto_tree_add_item(nwmtp_tree
, hf_nwmtp_user_context
,
103 tvb
, offset
+ 4, 4, ENC_BIG_ENDIAN
);
104 proto_tree_add_item(nwmtp_tree
, hf_nwmtp_data_length
,
105 tvb
, offset
+ 8, 4, ENC_BIG_ENDIAN
);
108 next_tvb
= tvb_new_subset(tvb
, offset
+ 12, len
, len
);
109 if (tvb_length(next_tvb
) > 0)
110 call_dissector(mtp_handle
, next_tvb
, pinfo
, tree
);
111 /* Check for overflows, which probably can't happen, but better
112 * safe than sorry. See
113 * https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=8169
115 DISSECTOR_ASSERT(len
< G_MAXUINT32
- 11);
116 DISSECTOR_ASSERT((guint64
)offset
+ len
+ 12 < G_MAXINT
);
121 void proto_register_mwmtp(void)
123 static hf_register_info hf
[] = {
124 {&hf_nwmtp_transp_type
,
125 {"Transport Type", "nwmtp.transp_type",
126 FT_UINT8
, BASE_DEC
, VALS(nwmtp_transport_type_vals
), 0x0,
127 "The Transport Type", HFILL
}
129 {&hf_nwmtp_data_type
,
130 {"Data Type", "nwmtp.data_type",
131 FT_UINT8
, BASE_DEC
, VALS(nwmtp_data_type_vals
), 0x0,
132 "The Data Type", HFILL
}
134 {&hf_nwmtp_data_index
,
135 {"Link Index", "nwmtp.link_index",
136 FT_UINT16
, BASE_DEC
, NULL
, 0x0,
139 {&hf_nwmtp_user_context
,
140 {"User Context", "nwmtp.user_context",
141 FT_UINT32
, BASE_DEC
, NULL
, 0x0,
142 "Use Context", HFILL
}
144 {&hf_nwmtp_data_length
,
145 {"Length", "nwmtp.data_length",
146 FT_UINT32
, BASE_DEC
, NULL
, 0x0,
147 "Data Length", HFILL
}
151 static gint
*ett
[] = {
156 proto_register_protocol("NexusWare C7 MTP", "MTP over NW UDP", "nw_mtp");
158 proto_register_field_array(proto_nwmtp
, hf
, array_length(hf
));
159 proto_register_subtree_array(ett
, array_length(ett
));
161 nwmtp_handle
= register_dissector("nw_mtp", dissect_nwmtp
, proto_nwmtp
);
164 void proto_reg_handoff_nwmtp(void)
167 dissector_add_handle("udp.port", nwmtp_handle
);
168 mtp_handle
= find_dissector("mtp3");
172 * Editor modelines - http://www.wireshark.org/tools/modelines.html
177 * indent-tabs-mode: t
180 * vi: set shiftwidth=8 tabstop=8 noexpandtab:
181 * :indentSize=8:tabSize=8:noTabs=false: