2 * Routines for UA/UDP (Universal Alcatel over UDP) packet dissection.
3 * Copyright 2012, Alcatel-Lucent Enterprise <lars.ruoff@alcatel-lucent.com>
5 * Wireshark - Network traffic analyzer
6 * By Gerald Combs <gerald@wireshark.org>
7 * Copyright 1998 Gerald Combs
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License
11 * as published by the Free Software Foundation; either version 2
12 * of the License, or (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
26 #include <epan/packet.h>
27 #include <epan/prefs.h>
29 #include "packet-rtp.h"
30 #include "packet-rtcp.h"
31 #include "packet-uaudp.h"
33 void proto_register_ua_msg(void);
34 void proto_reg_handoff_ua_msg(void);
35 /*-----------------------------------------------------------------------------
37 ---------------------------------------------------------------------------*/
40 static dissector_table_t ua_opcode_dissector_table;
43 static int proto_ua_msg = -1;
44 static gint ett_ua_msg = -1;
46 static gboolean setup_conversations_enabled = TRUE;
48 static dissector_handle_t noe_handle;
49 static dissector_handle_t ua3g_handle;
51 static void uadecode(e_ua_direction direction,
59 switch (opcode & 0x7f) /* suppression of the CP bit */
64 call_dissector(noe_handle,
65 tvb_new_subset_length(tvb, offset, length),
77 case 0x07: /* Only UA NOE */
78 case 0x08: /* Only UA NOE */
92 case 0x1F: /* case 0x9F */
97 case 0x24: /* Only IP NOE */
98 case 0x25: /* Only IP NOE */
104 case 0x2B: /* Only UA NOE */
110 case 0x32: /* Only UA NOE */
113 case 0x36: /* IP Phone */
138 case 0x50: /* Only UA NOE */
140 call_dissector_with_data(ua3g_handle,
141 tvb_new_subset_length(tvb, offset, length),
148 /* add text to the frame "INFO" column */
149 col_append_fstr(pinfo->cinfo, COL_INFO, " - UA3G Message ERR: Opcode (0x%02x) Unknown", tvb_get_guint8(tvb, (offset + 2)));
151 call_data_dissector(tvb_new_subset_length(tvb, offset, length),
161 /*-----------------------------------------------------------------------------
163 ---------------------------------------------------------------------------*/
164 static void _dissect_ua_msg(tvbuff_t *tvb,
167 e_ua_direction direction)
170 proto_item *ua_msg_item;
171 proto_tree *ua_msg_tree;
173 ua_msg_item = proto_tree_add_protocol_format(tree, proto_ua_msg, tvb, 0, -1,
174 "Universal Alcatel Protocol, %s",
175 ((direction == SYS_TO_TERM) ?
176 "System -> Terminal" : "Terminal -> System"));
178 ua_msg_tree = proto_item_add_subtree(ua_msg_item, ett_ua_msg);
180 while (tvb_offset_exists(tvb, offset))
185 length = tvb_get_letohs(tvb, offset) + 2;
186 opcode = tvb_get_guint8(tvb, offset+2);
188 /* RTP/RTCP conversation setup */
189 if (setup_conversations_enabled && (opcode==0x13) && (tvb_get_guint8(tvb, offset+3)==0x01))
191 address remote_rtp_addr;
192 guint32 remote_rtp_port;
195 remote_rtp_addr.data = NULL;
199 suboffset = offset + 5;
201 while (suboffset < offset+length)
203 switch (tvb_get_guint8(tvb, suboffset))
205 case 0x00: /* local port */
207 /*local_rtp_port = tvb_get_ntohs(tvb, suboffset+2);*/
210 case 0x01: /* remote IP */
212 set_address_tvb(&remote_rtp_addr, AT_IPv4, 4, tvb, suboffset+2);
215 case 0x02: /* remote port */
217 remote_rtp_port = tvb_get_ntohs(tvb, suboffset+2);
222 suboffset += tvb_get_guint8(tvb, suboffset+1) + 2;
225 if ((remote_rtp_addr.data != NULL) && (remote_rtp_port != 0))
227 rtp_add_address(pinfo, &remote_rtp_addr, remote_rtp_port, 0,
228 "UA", pinfo->num, 0, NULL);
229 rtcp_add_address(pinfo, &remote_rtp_addr, remote_rtp_port+1, 0,
234 uadecode(direction, ua_msg_tree, pinfo, tvb, offset, opcode, length);
241 static int dissect_ua_sys_to_term(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
243 _dissect_ua_msg(tvb, pinfo, tree, SYS_TO_TERM);
244 return tvb_captured_length(tvb);
247 static int dissect_ua_term_to_sys(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
249 _dissect_ua_msg(tvb, pinfo, tree, TERM_TO_SYS);
250 return tvb_captured_length(tvb);
254 /*-----------------------------------------------------------------------------
255 DISSECTORS REGISTRATION FUNCTIONS
256 ---------------------------------------------------------------------------*/
258 void proto_register_ua_msg(void)
260 module_t *ua_msg_module;
267 /* UA dissector registration */
268 proto_ua_msg = proto_register_protocol("Universal Alcatel Protocol", "UA", "ua");
270 register_dissector("ua_sys_to_term", dissect_ua_sys_to_term, proto_ua_msg);
271 register_dissector("ua_term_to_sys", dissect_ua_term_to_sys, proto_ua_msg);
273 /* Common subtree array registration */
274 proto_register_subtree_array(ett, array_length(ett));
276 /* Register preferences */
277 ua_msg_module = prefs_register_protocol(proto_ua_msg, NULL);
279 prefs_register_bool_preference(ua_msg_module, "setup_conversations",
280 "Setup RTP/RTCP conversations on Start RTP",
281 "Setup RTP/RTCP conversations when parsing Start RTP messages",
282 &setup_conversations_enabled);
285 void proto_reg_handoff_ua_msg(void)
288 dissector_handle_t handle_ua_msg;
290 /* hooking of UA on UAUDP */
291 /* XXX: The following is NG since the same 'pattern' is added twice */
292 handle_ua_msg = find_dissector("ua_sys_to_term");
293 dissector_add_uint("uaudp.opcode", UAUDP_DATA, handle_ua_msg);
295 handle_ua_msg = find_dissector("ua_term_to_sys");
296 dissector_add_uint("uaudp.opcode", UAUDP_DATA, handle_ua_msg);
298 /* For hooking dissectors to UA */
299 ua_opcode_dissector_table =
300 register_dissector_table("ua.opcode",
307 noe_handle = find_dissector_add_dependency("noe", proto_ua_msg);
308 ua3g_handle = find_dissector_add_dependency("ua3g", proto_ua_msg);
313 * Editor modelines - http://www.wireshark.org/tools/modelines.html
318 * indent-tabs-mode: nil
321 * vi: set shiftwidth=4 tabstop=8 expandtab:
322 * :indentSize=4:tabSize=8:noTabs=true: