Revert "TODO epan/dissectors/asn1/kerberos/packet-kerberos-template.c new GSS flags"
[wireshark-sm.git] / epan / dissectors / packet-ua.c
blob1b677cf68923dd7b2b6092d51e0c41d0f2e1d44c
1 /* packet-ua.c
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 * SPDX-License-Identifier: GPL-2.0-or-later
12 #include "config.h"
14 #include <epan/packet.h>
16 #include "packet-uaudp.h"
18 void proto_register_ua_msg(void);
19 void proto_reg_handoff_ua_msg(void);
20 /*-----------------------------------------------------------------------------
21 GLOBALS
22 ---------------------------------------------------------------------------*/
24 #if 0
25 static dissector_table_t ua_opcode_dissector_table;
26 #endif
28 static int proto_ua_msg;
29 static int ett_ua_msg;
31 static dissector_handle_t noe_handle;
32 static dissector_handle_t ua3g_handle;
34 static void uadecode(e_ua_direction direction,
35 proto_tree *tree,
36 packet_info *pinfo,
37 tvbuff_t *tvb,
38 int offset,
39 int opcode,
40 int length)
42 switch (opcode & 0x7f) /* suppression of the CP bit */
44 case 0x15:
45 case 0x16:
47 call_dissector(noe_handle,
48 tvb_new_subset_length(tvb, offset, length),
49 pinfo,
50 tree);
51 break;
53 case 0x00:
54 case 0x01:
55 case 0x02:
56 case 0x03:
57 case 0x04:
58 case 0x05:
59 case 0x06:
60 case 0x07: /* Only UA NOE */
61 case 0x08: /* Only UA NOE */
62 case 0x09:
63 case 0x0A:
64 case 0x0B:
65 case 0x0C:
66 case 0x0D:
67 case 0x0E:
68 case 0x0F:
69 case 0x11:
70 case 0x12:
71 case 0x13:
72 case 0x14:
73 case 0x17:
74 case 0x18:
75 case 0x1F: /* case 0x9F */
76 case 0x20:
77 case 0x21:
78 case 0x22:
79 case 0x23:
80 case 0x24: /* Only IP NOE */
81 case 0x25: /* Only IP NOE */
82 case 0x26:
83 case 0x27:
84 case 0x28:
85 case 0x29:
86 case 0x2A:
87 case 0x2B: /* Only UA NOE */
88 case 0x2C:
89 case 0x2D:
90 case 0x2E:
91 case 0x30:
92 case 0x31:
93 case 0x32: /* Only UA NOE */
94 case 0x33:
95 case 0x35:
96 case 0x36: /* IP Phone */
97 case 0x38:
98 case 0x39:
99 case 0x3A:
100 case 0x3B:
101 case 0x3C:
102 case 0x3D:
103 case 0x3E:
104 case 0x3F:
105 case 0x40:
106 case 0x41:
107 case 0x42:
108 case 0x43:
109 case 0x44:
110 case 0x45:
111 case 0x46:
112 case 0x47:
113 case 0x48:
114 case 0x49:
115 case 0x4A:
116 case 0x4B:
117 case 0x4C:
118 case 0x4D:
119 case 0x4E:
120 case 0x4F:
121 case 0x50: /* Only UA NOE */
123 call_dissector_with_data(ua3g_handle,
124 tvb_new_subset_length(tvb, offset, length),
125 pinfo,
126 tree, &direction);
127 break;
129 default:
131 /* add text to the frame "INFO" column */
132 col_append_fstr(pinfo->cinfo, COL_INFO, " - UA3G Message ERR: Opcode (0x%02x) Unknown", tvb_get_uint8(tvb, (offset + 2)));
134 call_data_dissector(tvb_new_subset_length(tvb, offset, length),
135 pinfo,
136 tree);
137 break;
144 /*-----------------------------------------------------------------------------
145 UA DISSECTOR
146 ---------------------------------------------------------------------------*/
147 static void _dissect_ua_msg(tvbuff_t *tvb,
148 packet_info *pinfo,
149 proto_tree *tree,
150 e_ua_direction direction)
152 int offset = 0;
153 proto_item *ua_msg_item;
154 proto_tree *ua_msg_tree;
156 ua_msg_item = proto_tree_add_protocol_format(tree, proto_ua_msg, tvb, 0, -1,
157 "Universal Alcatel Protocol, %s",
158 ((direction == SYS_TO_TERM) ?
159 "System -> Terminal" : "Terminal -> System"));
161 ua_msg_tree = proto_item_add_subtree(ua_msg_item, ett_ua_msg);
163 while (tvb_offset_exists(tvb, offset))
165 int length = tvb_get_letohs(tvb, offset) + 2;
166 int opcode = tvb_get_uint8(tvb, offset+2);
168 uadecode(direction, ua_msg_tree, pinfo, tvb, offset, opcode, length);
170 offset += length;
175 static int dissect_ua_sys_to_term(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
177 _dissect_ua_msg(tvb, pinfo, tree, SYS_TO_TERM);
178 return tvb_captured_length(tvb);
181 static int dissect_ua_term_to_sys(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
183 _dissect_ua_msg(tvb, pinfo, tree, TERM_TO_SYS);
184 return tvb_captured_length(tvb);
188 /*-----------------------------------------------------------------------------
189 DISSECTORS REGISTRATION FUNCTIONS
190 ---------------------------------------------------------------------------*/
192 void proto_register_ua_msg(void)
194 static int *ett[] =
196 &ett_ua_msg,
199 /* UA dissector registration */
200 proto_ua_msg = proto_register_protocol("Universal Alcatel Protocol", "UA", "ua");
202 register_dissector("ua_sys_to_term", dissect_ua_sys_to_term, proto_ua_msg);
203 register_dissector("ua_term_to_sys", dissect_ua_term_to_sys, proto_ua_msg);
205 /* Common subtree array registration */
206 proto_register_subtree_array(ett, array_length(ett));
209 void proto_reg_handoff_ua_msg(void)
211 #if 0 /* Future */
212 dissector_handle_t handle_ua_msg;
214 /* hooking of UA on UAUDP */
215 /* XXX: The following is NG since the same 'pattern' is added twice */
216 handle_ua_msg = find_dissector("ua_sys_to_term");
217 dissector_add_uint("uaudp.opcode", UAUDP_DATA, handle_ua_msg);
219 handle_ua_msg = find_dissector("ua_term_to_sys");
220 dissector_add_uint("uaudp.opcode", UAUDP_DATA, handle_ua_msg);
222 /* For hooking dissectors to UA */
223 ua_opcode_dissector_table =
224 register_dissector_table("ua.opcode",
225 "ua.opcode",
226 FT_UINT8,
227 BASE_HEX);
230 #endif
231 noe_handle = find_dissector_add_dependency("noe", proto_ua_msg);
232 ua3g_handle = find_dissector_add_dependency("ua3g", proto_ua_msg);
237 * Editor modelines - https://www.wireshark.org/tools/modelines.html
239 * Local variables:
240 * c-basic-offset: 4
241 * tab-width: 8
242 * indent-tabs-mode: nil
243 * End:
245 * vi: set shiftwidth=4 tabstop=8 expandtab:
246 * :indentSize=4:tabSize=8:noTabs=true: