Witness: working witness.cnf
[wireshark-wip.git] / asn1 / h248 / packet-h248-template.c
blob7d18842906c4af1e0921f2b27756714121d163d3
1 /* packet-h248.c
2 * Routines for H.248/MEGACO packet dissection
4 * Ronnie Sahlberg 2004
6 * Luis Ontanon 2005 - Context and Transaction Tracing
8 * $Id$
10 * Wireshark - Network traffic analyzer
11 * By Gerald Combs <gerald@wireshark.org>
12 * Copyright 1998 Gerald Combs
14 * This program is free software; you can redistribute it and/or
15 * modify it under the terms of the GNU General Public License
16 * as published by the Free Software Foundation; either version 2
17 * of the License, or (at your option) any later version.
19 * This program is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
24 * You should have received a copy of the GNU General Public License
25 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
28 #include "config.h"
30 #include "packet-h248.h"
31 #include <epan/exceptions.h>
32 #include <epan/tap.h>
33 #include <epan/wmem/wmem.h>
34 #include "packet-tpkt.h"
35 #include <ctype.h>
36 #include "packet-mtp3.h"
38 #define PNAME "H.248 MEGACO"
39 #define PSNAME "H248"
40 #define PFNAME "h248"
42 /* Initialize the protocol and registered fields */
43 static int proto_h248 = -1;
44 static int hf_248_magic_num = -1;
45 static int hf_h248_mtpaddress_ni = -1;
46 static int hf_h248_mtpaddress_pc = -1;
47 static int hf_h248_pkg_name = -1;
48 static int hf_248_pkg_param = -1;
49 static int hf_h248_event_name = -1;
50 static int hf_h248_signal_name = -1;
51 static int hf_h248_signal_code = -1;
52 static int hf_h248_event_code = -1;
53 static int hf_h248_pkg_bcp_BNCChar_PDU = -1;
57 static int hf_h248_context_id = -1;
58 static int hf_h248_term_wild_type = -1;
59 static int hf_h248_term_wild_level = -1;
60 static int hf_h248_term_wild_position = -1;
62 static int hf_h248_no_pkg = -1;
63 static int hf_h248_no_sig = -1;
64 static int hf_h248_no_evt = -1;
65 static int hf_h248_param = -1;
67 static int hf_h248_serviceChangeReasonStr = -1;
68 static int hf_h248_transactionId64 = -1;
69 static int hf_h248_context_id64 = -1;
71 /* h248v1 support */
72 static int hf_h248_auditValueReplyV1 = -1;
74 #include "packet-h248-hf.c"
76 /* Initialize the subtree pointers */
77 static gint ett_h248 = -1;
78 static gint ett_mtpaddress = -1;
79 static gint ett_packagename = -1;
80 static gint ett_codec = -1;
81 static gint ett_wildcard = -1;
83 static gint ett_h248_no_pkg = -1;
84 static gint ett_h248_no_sig = -1;
85 static gint ett_h248_no_evt = -1;
87 static int h248_tap = -1;
89 static gcp_hf_ett_t h248_arrel = {{-1,-1,-1,-1,-1,-1},{-1,-1,-1,-1}};
91 #include "packet-h248-ett.c"
93 static expert_field ei_h248_errored_command = EI_INIT;
94 static expert_field ei_h248_transactionId64 = EI_INIT;
95 static expert_field ei_h248_context_id64 = EI_INIT;
97 static dissector_table_t subdissector_table;
99 static wmem_tree_t* msgs = NULL;
100 static wmem_tree_t* trxs = NULL;
101 static wmem_tree_t* ctxs_by_trx = NULL;
102 static wmem_tree_t* ctxs = NULL;
104 static gboolean keep_persistent_data = FALSE;
105 static guint global_udp_port = 2945;
106 static guint global_tcp_port = 2945;
107 static gboolean h248_desegment = TRUE;
111 static proto_tree *h248_tree;
112 static tvbuff_t* h248_tvb;
114 static dissector_handle_t h248_handle;
115 static dissector_handle_t h248_term_handle;
116 static dissector_handle_t h248_tpkt_handle;
118 /* Forward declarations */
119 static int dissect_h248_ServiceChangeReasonStr(gboolean implicit_tag, tvbuff_t *tvb, int offset, asn1_ctx_t *actx, proto_tree *tree, int hf_index);
121 /* h248v1 support */
122 static int dissect_h248_AuditReplyV1(gboolean implicit_tag, tvbuff_t *tvb, int offset, asn1_ctx_t *actx, proto_tree *tree, int hf_index);
124 static int dissect_h248_EventParameterV1(gboolean implicit_tag, tvbuff_t *tvb, int offset, asn1_ctx_t *actx, proto_tree *tree, int hf_index);
125 static int dissect_h248_SigParameterV1(gboolean implicit_tag, tvbuff_t *tvb, int offset, asn1_ctx_t *actx, proto_tree *tree, int hf_index);
126 static int dissect_h248_SigParamValueV1(gboolean implicit_tag, tvbuff_t *tvb, int offset, asn1_ctx_t *actx, proto_tree *tree, int hf_index);
127 static int dissect_h248_ValueV1(gboolean implicit_tag, tvbuff_t *tvb, int offset, asn1_ctx_t *actx, proto_tree *tree, int hf_index);
128 #if 0
129 static const value_string context_id_type[] = {
130 {NULL_CONTEXT,"0 (Null Context)"},
131 {CHOOSE_CONTEXT,"$ (Choose Context)"},
132 {ALL_CONTEXTS,"* (All Contexts)"},
133 {0,NULL}
135 #endif
137 /* the following value_strings are used to build defalut packages.
138 To add additional detail to a package, build a register a h248_package_t structure
141 static const value_string base_package_name_vals[] = {
142 { 0x0000, "Media stream properties H.248.1 Annex C" },
143 { 0x0001, "Generic H.248.1 Annex E" },
144 { 0x0002, "root H.248.1 Annex E" },
145 { 0x0003, "tonegen H.248.1 Annex E" },
146 { 0x0004, "tonedet H.248.1 Annex E" },
147 { 0x0005, "dg H.248.1 Annex E" },
148 { 0x0006, "dd H.248.1 Annex E" },
149 { 0x0007, "cg H.248.1 Annex E" },
150 { 0x0008, "cd H.248.1 Annex E" },
151 { 0x0009, "al H.248.1 Annex E" },
152 { 0x000a, "ct H.248.1 Annex E" },
153 { 0x000b, "nt H.248.1 Annex E" },
154 { 0x000c, "rtp H.248.1 Annex E" },
155 { 0x000d, "tdmc H.248.1 Annex E" },
156 { 0x000e, "ftmd H.248.1 Annex E" },
157 { 0x000f, "txc H.248.2" }, /* H.248.2 */
158 { 0x0010, "txp H.248.2" },
159 { 0x0011, "ctyp H.248.2" },
160 { 0x0012, "fax H.248.2" },
161 { 0x0013, "ipfax H.248.2" },
162 { 0x0014, "dis H.248.3" }, /* H.248.3 */
163 { 0x0015, "key H.248.3" },
164 { 0x0016, "kp H.248.3" },
165 { 0x0017, "labelkey H.248.3" },
166 { 0x0018, "kf H.248.3" },
167 { 0x0019, "ind H.248.3" },
168 { 0x001a, "ks H.248.3" },
169 { 0x001b, "anci H.248.3" },
170 { 0x001c, "dtd H.248.6" }, /* H.248.6 */
171 { 0x001d, "an H.248.7" }, /* H.248.7 */
172 { 0x001e, "Bearer Characteristics Q.1950 Annex A" }, /* Q.1950 Annex A */
173 { 0x001f, "Bearer Network Connection Cut Q.1950 Annex A" },
174 { 0x0020, "Reuse Idle Q.1950 Annex A" },
175 { 0x0021, "Generic Bearer Connection Q.1950 Annex A" },
176 { 0x0022, "Bearer Control Tunnelling Q.1950 Annex A" },
177 { 0x0023, "Basic Call Progress Tones Q.1950 Annex A" },
178 { 0x0024, "Expanded Call Progress Tones Q.1950 Annex A" },
179 { 0x0025, "Basic Services Tones Q.1950 Annex A" },
180 { 0x0026, "Expanded Services Tones Q.1950 Annex A" },
181 { 0x0027, "Intrusion Tones Q.1950 Annex A" },
182 { 0x0028, "Business Tones Q.1950 Annex A" },
183 { 0x0029, "Media Gateway Resource Congestion Handling H.248.10" }, /* H.248.10 */
184 { 0x002a, "H245 package H248.12" }, /* H.248.12 */
185 { 0x002b, "H323 bearer control package H.248.12" }, /* H.248.12 */
186 { 0x002c, "H324 package H.248.12" }, /* H.248.12 */
187 { 0x002d, "H245 command package H.248.12" }, /* H.248.12 */
188 { 0x002e, "H245 indication package H.248.12" }, /* H.248.12 */
189 { 0x002f, "3G User Plane" }, /* 3GPP TS 29.232 v4.1.0 */
190 { 0x0030, "3G Circuit Switched Data" },
191 { 0x0031, "3G TFO Control" },
192 { 0x0032, "3G Expanded Call Progress Tones" },
193 { 0x0033, "Advanced Audio Server (AAS Base)" }, /* H.248.9 */
194 { 0x0034, "AAS Digit Collection" }, /* H.248.9 */
195 { 0x0035, "AAS Recording" }, /* H.248.9 */
196 { 0x0036, "AAS Segment Management" }, /* H.248.9 */
197 { 0x0037, "Quality Alert Ceasing" }, /* H.248.13 */
198 { 0x0038, "Conferencing Tones Generation" }, /* H.248.27 */
199 { 0x0039, "Diagnostic Tones Generation" }, /* H.248.27 */
200 { 0x003a, "Carrier Tones Generation Package H.248.23" }, /* H.248.27 */
201 { 0x003b, "Enhanced Alerting Package H.248.23" }, /* H.248.23 */
202 { 0x003c, "Analog Display Signalling Package H.248.23" }, /* H.248.23 */
203 { 0x003d, "Multi-Frequency Tone Generation Package H.248.24" }, /* H.248.24 */
204 { 0x003e, "H.248.23Multi-Frequency Tone Detection Package H.248.24" }, /* H.248.24 */
205 { 0x003f, "Basic CAS Package H.248.25" }, /* H.248.25 */
206 { 0x0040, "Robbed Bit Signalling Package H.248.25" }, /* H.248.25 */
207 { 0x0041, "Operator Services and Emergency Services Package H.248.25" },
208 { 0x0042, "Operator Services Extension Package H.248.25" },
209 { 0x0043, "Extended Analog Line Supervision Package H.248.26" },
210 { 0x0044, "Automatic Metering Package H.248.26" },
211 { 0x0045, "Inactivity Timer Package H.248.14" },
212 { 0x0046, "3G Modification of Link Characteristics Bearer Capability" }, /* 3GPP TS 29.232 v4.4.0 */
213 { 0x0047, "Base Announcement Syntax H.248.9" },
214 { 0x0048, "Voice Variable Syntax H.248.9" },
215 { 0x0049, "Announcement Set Syntax H.248.9" },
216 { 0x004a, "Phrase Variable Syntax H.248.9" },
217 { 0x004b, "Basic NAS package" },
218 { 0x004c, "NAS incoming package" },
219 { 0x004d, "NAS outgoing package" },
220 { 0x004e, "NAS control package" },
221 { 0x004f, "NAS root package" },
222 { 0x0050, "Profile Handling Package H.248.18" },
223 { 0x0051, "Media Gateway Overload Control Package H.248.11" },
224 { 0x0052, "Extended DTMF Detection Package H.248.16" },
225 { 0x0053, "Quiet Termination Line Test" },
226 { 0x0054, "Loopback Line Test Response" }, /* H.248.17 */
227 { 0x0055, "ITU 404Hz Line Test" }, /* H.248.17 */
228 { 0x0056, "ITU 816Hz Line Test" }, /* H.248.17 */
229 { 0x0057, "ITU 1020Hz Line Test" }, /* H.248.17 */
230 { 0x0058, "ITU 2100Hz Disable Tone Line Test" }, /* H.248.17 */
231 { 0x0059, "ITU 2100Hz Disable Echo Canceller Tone Line Test" }, /* H.248.17 */
232 { 0x005a, "ITU 2804Hz Tone Line Test" }, /* H.248.17 */
233 { 0x005b, "ITU Noise Test Tone Line Test" }, /* H.248.17 */
234 { 0x005c, "ITU Digital Pseudo Random Test Line Test" }, /* H.248.17 */
235 { 0x005d, "ITU ATME No.2 Test Line Response" }, /* H.248.17 */
236 { 0x005e, "ANSI 1004Hz Test Tone Line Test" }, /* H.248.17 */
237 { 0x005f, "ANSI Test Responder Line Test" }, /* H.248.17 */
238 { 0x0060, "ANSI 2225Hz Test Progress Tone Line Test" }, /* H.248.17 */
239 { 0x0061, "ANSI Digital Test Signal Line Test" }, /* H.248.17 */
240 { 0x0062, "ANSI Inverting Loopback Line Test Response" }, /* H.248.17 */
241 { 0x0063, "Extended H.324 Packages H.248.12 Annex A" },
242 { 0x0064, "Extended H.245 Command Package H.248.12 Annex A" },
243 { 0x0065, "Extended H.245 Indication Package H.248.12 Annex A" },
244 { 0x0066, "Enhanced DTMF Detection Package H.248.16" },
245 { 0x0067, "Connection Group Identity Package Q.1950 Annex E" },
246 { 0x0068, "CTM Text Transport 3GPP TS 29.232 v5.2.0" },
247 { 0x0069, "SPNE Control Package Q.115.0" },
248 { 0x006a, "Semi-permanent Connection Package H.248.21" },
249 { 0x006b, "Shared Risk Group Package H.248.22" },
250 { 0x006c, "isuptn Annex B of ITU-T Rec. J.171" },
251 { 0x006d, "Basic CAS Addressing Package H.248.25" },
252 { 0x006e, "Floor Control Package H.248.19" },
253 { 0x006f, "Indication of Being Viewed Package H.248.19" },
254 { 0x0070, "Volume Control Package H.248.19" },
255 { 0x0071, "UNASSIGNED" },
256 { 0x0072, "Volume Detection Package H.248.19" },
257 { 0x0073, "Volume Level Mixing Package H.248.19" },
258 { 0x0074, "Mixing Volume Level Control Package H.248.19" },
259 { 0x0075, "Voice Activated Video Switch Package H.248.19" },
260 { 0x0076, "Lecture Video Mode Package H.248.19" },
261 { 0x0077, "Contributing Video Source Package H.248.19" },
262 { 0x0078, "Video Window Package H.248.19" },
263 { 0x0079, "Tiled Window Package H.248.19" },
264 { 0x007a, "Adaptive Jitter Buffer Package H.248.31" },
265 { 0x007b, "International CAS Package H.248.28" },
266 { 0x007c, "CAS Blocking Package H.248.28" },
267 { 0x007d, "International CAS Compelled Package H.248.29" },
268 { 0x007e, "International CAS Compelled with Overlap Package H.248.29" },
269 { 0x007f, "International CAS Compelled with End-to-end Package H.248.29" },
270 { 0x0080, "RTCP XR Package H.248.30" },
271 { 0x0081, "RTCP XR Burst Metrics Package H.248.30" },
272 { 0x0082, "threegcsden 3G Circuit Switched Data" }, /* 3GPP TS 29.232 v5.6.0 */
273 { 0x0083, "threegiptra 3G Circuit Switched Data" }, /* 3GPP TS 29.232 v5.6.0 */
274 { 0x0084, "threegflex 3G Circuit Switched Data" }, /* 3GPP TS 29.232 v5.6.0 */
275 { 0x0085, "H.248 PCMSB" },
276 { 0x008a, "TIPHON Extended H.248/MEGACO Package" }, /* ETSI specification TS 101 3 */
277 { 0x008b, "Differentiated Services Package" }, /* Annex A of ETSI TS 102 333 */
278 { 0x008c, "Gate Management Package" }, /* Annex B of ETSI TS 102 333 */
279 { 0x008d, "Traffic Management Package" }, /* Annex C of ETSI TS 102 333 */
280 { 0x008e, "Gate Recovery Information Package" }, /* Annex D of ETSI TS 102 333 */
281 { 0x008f, "NAT Traversal Package" }, /* Annex E of ETSI TS 102 333 */
282 { 0x0090, "MPLS Package" }, /* Annex F of ETSI TS 102 333 */
283 { 0x0091, "VLAN Package" }, /* Annex G of ETSI TS 102 333 */
284 { 0x0092, "Detailed Congestion Reporting Package" }, /* H.248.32 */
285 { 0x0093, "Stimulus Analogue Lines Package" }, /* H.248.34 */
286 { 0x0094, "icascgen" }, /* H.248.29 Annex B */
287 { 0x0095, "Coin Operated Phone Control Package" }, /* H.248.35 */
288 { 0x0096, "Metering Pulse Detection Package" }, /* H.248.26 Amendment 1 */
289 { 0x0097, "Trace Package" }, /* 3GPP TS 29.232 v6.3.0 */
290 { 0x0098, "Hanging Termination Package" }, /* H.248.36 */
291 { 0x0099, "IP NAPT Traversal Package" }, /* H.248.37 */
292 { 0x009a, "Notification Behaviour Package" }, /* H.248.1v3 */
293 { 0x009b, "Base Context Package" }, /* H.248.38 */
294 { 0x009c, "Application Data Inactivity Detection Package" }, /* H.248.40 */
295 { 0x009d, "Domain Connection Package " }, /* H.248.41 */
296 { 0x009e, "Digital Circuit Multiplication Equipment Package" }, /* H.248.42 */
297 { 0x009f, "Multi-level Precedence and Pre-emption Package" }, /* H.248.44 */
298 { 0x00a0, "MGC Information Package" }, /* H.248.45 */
299 { 0x00a1, "Text Overlay Package" }, /* H.248.19 Amendment 1 */
300 { 0x00a2, "Border and Background Package" }, /* H.248.19 Amendment 1 */
301 { 0x00a3, "Segmentation Package" }, /* H.248.1v3 */
302 { 0x00a4, "ETSI notification behaviour package" }, /* ETSI ES 283 039-3 */
303 { 0x00a5, "ETSI notification rate package" }, /* ETSI ES 283 039-4 */
304 { 0x00a6, "Automatic Speech Recognition Package" }, /* H.248.9 Amendment 1 */
305 { 0x00a7, "Set extension to basic syntax for TTS enhancement Package" },/* H.248.9 Amendment 1 */
306 { 0x00a8, "Advanced audio server base package for TTS enhancement" }, /* H.248.9 Amendment 1 */
307 { 0x00a9, "Multimedia Play Package" }, /* H.248.9 Amendment 1 */
308 { 0x00aa, "Floor Status Detection Package" }, /* H.248.19 Amendment 2 */
309 { 0x00ab, "Floor Control Policy Package" }, /* H.248.19 Amendment 2 */
310 { 0x00ac, "Address Reporting Package" }, /* H.248.37 Amendment 1 */
311 { 0x00ad, "Connection Capability Control Package" }, /* H.248.46 */
312 { 0x00ae, "Statistic Conditional Reporting Package" }, /* H.248.47 Amendment 1 */
313 { 0x00af, "RTCP HR QoS Statistics Package" }, /* H.248.48 */
314 { 0x00b0, "Received RTCP XR Package" }, /* H.248.30 (01/2007) */
315 { 0x00b1, "Received RTCP XR Burst Metrics Package" }, /* H.248.30 (01/2007) */
316 { 0x00b2, "ASCI Group call package" }, /* 3GPP TS 29.232 v7.4.0 */
317 { 0x00b3, "Multimedia Recording Package" }, /* H.248.9 Amendment 1 */
318 { 0x00b4, "H.245 Transport Package" }, /* H.248.12 Amendment 2 */
319 { 0x00b5, "RTCP Handling package" }, /* H.248.57 */
320 { 0x00b6, "Gate Management - Outgoing Destination Address/Port Filtering Package" },/* H.248.43 */
321 { 0x00b7, "Gate Management - Incoming Protocol Filtering Package" }, /* H.248.43 */
322 { 0x00b8, "Gate Management - Outgoing Protocol Filtering Package" }, /* H.248.43 */
323 { 0x00b9, "Gate Management - Incoming Filtering Behaviour Package" }, /* H.248.43 */
324 { 0x00ba, "Gate Management - Outgoing Filtering Behaviour Package" }, /* H.248.43 */
325 { 0x00bb, "Session Description Protocol RFC Package" }, /* H.248.49 */
326 { 0x00bc, "Session Description Protocol Capabilities Package" }, /* H.248.49 */
327 { 0x00bd, "NAT Traversal Toolkit - STUN Base Package" }, /* H.248.50 */
328 { 0x00be, "NAT Traversal Toolkit - MG STUN Client Package" }, /* H.248.50 */
329 { 0x00bf, "NAT Traversal Toolkit - MG TURN Client Package" }, /* H.248.50 */
330 { 0x00c0, "NAT Traversal Toolkit - MGC STUN Client Package" }, /* H.248.50 */
331 { 0x00c1, "NAT Traversal Toolkit - STUN Information Package" }, /* H.248.50 */
332 { 0x00c2, "NAT Traversal Toolkit - MG Act-as STUN Server Package" }, /* H.248.50 */
333 { 0x00c3, "NAT Traversal Toolkit - Originate STUN Continuity Check Package" }, /* H.248.50 */
334 { 0x00c4, "NAT Traversal Toolkit - MGC Originated STUN Request Package" }, /* H.248.50 */
335 { 0x00c5, "NAT Traversal Toolkit - RTP NOOP Request Package" }, /* H.248.50 */
336 { 0x00c6, "Termination Connection Model Package" }, /* H.248.51 */
337 { 0x00c7, "QoS Class Package" }, /* H.248.52 */
338 { 0x00c8, "Traffic Policing Statistics Package" }, /* H.248.53 */
339 { 0x00c9, "Packet Size Package" }, /* H.248.53 */
340 { 0x00ca, "Pull Mode Package" }, /* H.248.55 */
341 { 0x00cb, "RTP Application Data Package" }, /* H.248.58 */
342 { 0x00cc, "Event Timestamp Notification Package" }, /* H.248.59 */
343 { 0x00cd, "Resource Management Rules Package" }, /* H.248.63 */
344 { 0x00ce, "Resource Management Configuration Package" }, /* H.248.63 */
345 { 0x00cf, "Abstract Resource Management Packages" }, /* H.248.63 */
346 { 0x00d0, "IP layer octets count statistics Package" }, /* H.248.61 */
347 { 0x00d1, "Content of Communication Identity Package" }, /* H.248.60 */
348 { 0x00d2, "RSVP extension package" }, /* H.248.65 */
349 { 0x00d3, "GCP Transport Mode Indication Package" }, /* H.248.67 */
350 { 0x00d4, "IP Router Package" }, /* H.248.64 */
351 { 0x00d5, "Media Resource Identification Package" }, /* H.248.66 */
352 { 0x00d6, "Range Format Support Package" }, /* H.248.66 */
353 { 0x00d7, "Media Resource Description Expiry Package" }, /* H.248.66 */
354 { 0x00d8, "Media Block Size Package" }, /* H.248.66 */
355 { 0x00d9, "RTSP Media Resource Syntax Package" }, /* H.248.66 */
356 { 0x00da, "RTSP Play Package" }, /* H.248.66 */
357 { 0x00db, "Signal Pause Package" }, /* H.248.66 */
358 { 0x00dc, "Data Delivery Speed Adjustme Package" }, /* H.248.66 */
359 { 0x00dd, "Playback Relative Scale Adjustment Package" }, /* H.248.66 */
360 { 0x00de, "RTP Information Package" }, /* H.248.66 */
361 { 0x00df, "RTP Interleaving Package" }, /* H.248.66 */
362 { 0x00e0, "IP Realm Availability Package" }, /* H.248.41 Amendment 1 */
363 { 0x00e1, "General IP Header QoS Octet Package" }, /* H.248.52 */
364 { 0x00e2, "Re-answer Package" }, /* H.248.62 */
365 { 0x00e3, "3G Interface Type package" }, /* 3GPP TS 29.232 v8.4.0 */
366 { 0x00e4, "Latch Statistics Package" }, /* H.248.37 */
367 { 0x00e5, "Floor Control Signalling Package" }, /* H.248.19 Amendment 2 */
368 { 0x00e6, "Include Participant in Mix Package" }, /* H.248.19 Amendment 2 */
369 { 0x00e7, "Speaker Reporting Package" }, /* H.248.19 Amendment 2 */
370 { 0x00e8, "IP Layer Packet Count Statistics Package" }, /* H.248.61 */
371 { 0x00e9, "Removal of Digits and Tones Package" }, /* H.248.68 */
372 { 0x00ea, "MSRP Statistics Package" }, /* H.248.69 */
373 { 0x00eb, "MSRP Connection Status Package" }, /* H.248.69 */
374 { 0x00ec, "Play Message Package" }, /* H.248.69 */
375 { 0x00ed, "Delete Stored Message Package" }, /* H.248.69 */
376 { 0x00ee, "Message Session Information Package" }, /* H.248.69 */
377 { 0x00ef, "Message Filtering Package" }, /* H.248.69 */
378 { 0x00f0, "Stored Message Information Package" }, /* H.248.69 */
379 { 0x00f1, "Record Message Package" }, /* H.248.69 */
380 { 0x00f2, "Digit Dialling Method Information Package" }, /* H.248.70 */
381 { 0x00f3, "Digit Dialling Method Information for Extended Digitmap Detection Package" }, /* H.248.70 */
382 { 0x00f4, "Digit Dialling Method Information for Enhanced Digitmap Detection Package" }, /* H.248.70 */
383 { 0x00f5, "Received RTCP Package " }, /* H.248.71 */
384 { 0x00f6, "RTP Cumulative Loss Package" }, /* H.248.71 */
385 { 0x00f7, "H.245 Transport Package for SPC use" }, /* H.248.72 */
386 { 0x00f8, "MONA Preference Package" }, /* H.248.72 */
387 { 0x00f9, "TDM Gain Control Package" }, /* H.248.73 */
388 { 0x00fa, "Media Start Package" }, /* H.248.74 */
389 { 0x00fb, "Trim Package" }, /* H.248.74 */
390 { 0x00fc, "Enhanced Recording Package" }, /* H.248.74 */
391 { 0x00fd, "Enhanced ASR Package" }, /* H.248.74 */
392 { 0x00fe, "Enhanced TTS Package" }, /* H.248.74 */
393 { 0x00ff, "Play Offset Control Package" }, /* H.248.74 */
394 { 0x0100, "Enhanced DTMF Detection Package" }, /* H.248.9 Revised 2009 */
395 { 0x0101, "IP Router NAT Package" }, /* H.248.64 */
396 { 0x0102, "Voice Enrolled Grammar Package" }, /* H.248.74 */
397 { 0x0103, "Filter Group Package" }, /* H.248.76 */
398 { 0x0104, "RTCP Source Description Package" }, /* H.248.71 */
399 { 0x0105, "Speaker Verification and Identification Package" }, /* H.248.74 */
400 { 0x0106, "Package Identifier Publishing and Application Package" }, /* H.248 */
401 { 0x0107, "Secure RTP Package " }, /* H.248.77 */
402 { 0x0108, "MGC Controlled Bearer Level ALG Package" }, /* H.248.78 */
403 { 0x0109, "Enhanced Revised Offer/Answer SDP Support Package" }, /* H.248.80 */
404 { 0x010a, "Enhanced SDP Media Capabilities Negotiation Support Package" }, /* H.248.80 */
405 { 0x8000, "Ericsson IU" },
406 { 0x8001, "Ericsson UMTS and GSM Circuit" },
407 { 0x8002, "Ericsson Tone Generator Package" },
408 { 0x8003, "Ericsson Line Test Package" },
409 { 0x8004, "Nokia Advanced TFO Package" },
410 { 0x8005, "Nokia IWF Package" },
411 { 0x8006, "Nokia Root Package" },
412 { 0x8007, "Nokia Trace Package" },
413 { 0x8008, "Ericsson V5.2 Layer" },
414 { 0x8009, "Ericsson Detailed Termination Information Package" },
415 { 0x800a, "Nokia Bearer Characteristics Package" },
416 { 0x800b, "Nokia Test Call Package" },
417 { 0x800c, "Nokia Extended Continuity Package" },
418 { 0x800d, "Nokia IPnwR Package" },
419 { 0x800e, "Ericsson Tracing Enhancements Package" },
420 { 0x800f, "Ericsson Partially Wildcarded TerminationID Package" },
421 { 0x8010, "SCTP Stream Handling Package" },
422 {0, NULL}
426 * This table consist of PackageName + EventName and its corresponding string
429 static const value_string base_event_name_vals[] = {
430 { 0x00000000, "Media stream properties H.248.1 Annex C" },
431 { 0x00010000, "g H.248.1 Annex E" },
432 { 0x00010001, "g/Cause" },
433 { 0x00010002, "g/Signal Completion" },
434 { 0x00040000, "tonedet H.248.1 Annex E" },
435 { 0x00040001, "tonedet/std(Start tone detected)" },
436 { 0x00040002, "tonedet/etd(End tone detected)" },
437 { 0x00040003, "tonedet/ltd(Long tone detected)" },
438 { 0x00060000, "dd H.248.1 Annex E" },
439 { 0x00060001, "dd/std" },
440 { 0x00060002, "dd/etd" },
441 { 0x00060003, "dd/ltd" },
442 { 0x00060004, "dd, DigitMap Completion Event" },
443 { 0x00060010, "dd/d0, DTMF character 0" },
444 { 0x00060011, "dd/d1, DTMF character 1" },
445 { 0x00060012, "dd/d2, DTMF character 2" },
446 { 0x00060013, "dd/d3, DTMF character 3" },
447 { 0x00060014, "dd/d4, DTMF character 4" },
448 { 0x00060015, "dd/d5, DTMF character 5" },
449 { 0x00060016, "dd/d6, DTMF character 6" },
450 { 0x00060017, "dd/d7, DTMF character 7" },
451 { 0x00060018, "dd/d8, DTMF character 8" },
452 { 0x00060019, "dd/d9, DTMF character 9" },
453 { 0x0006001a, "dd/a, DTMF character A" },
454 { 0x0006001b, "dd/b, DTMF character B" },
455 { 0x0006001c, "dd/c, DTMF character C" },
456 { 0x0006001d, "dd/d, DTMF character D" },
457 { 0x00060020, "dd/" "*, DTMF character *" }, /* XXX: hack so checkAPIs & etc won't see a 'start of comment' */
458 { 0x00060021, "dd/#, DTMF character #" },
459 { 0x00080030, "cd, Dial Tone" },
460 { 0x00080031, "cd, Ringing Tone" },
461 { 0x00080032, "cd, Busy Tone" },
462 { 0x00080033, "cd, Congestion Tone" },
463 { 0x00080034, "cd, Special Information Tone" },
464 { 0x00080035, "cd, (Recording) Warning Tone" },
465 { 0x00080036, "cd, Payphone Recognition Tone" },
466 { 0x00080037, "cd, Call Waiting Tone" },
467 { 0x00080038, "cd, Caller Waiting Tone" },
468 { 0x00090004, "al, onhook" },
469 { 0x00090005, "al, offhook" },
470 { 0x00090006, "al, flashhook" },
471 { 0x0009ffff, "al, *" },
472 { 0x000a0005, "ct, Completion of Continuity test" },
473 { 0x000b0005, "nt, network failure" },
474 { 0x000b0006, "nt, quality alert" },
475 { 0x000c0001, "rtp, Payload Transition" },
476 { 0x00210000, "Generic Bearer Connection Q.1950 Annex A" },
477 { 0x00210001, "GB/BNCChange" },
478 { 0x00220001, "BT/TIND (Tunnel Indication)" },
479 { 0x002a0001, "H.245/h245msg (Incoming H.245 Message)" },
480 { 0x002a0004, "H.245/h245ChC (H.245 Channel Closed)" },
481 { 0x00450000, "Inactivity Timer H.248.14" },
482 { 0x00450001, "it/ito" },
483 { 0x00450002, "it/ito" },
484 { 0x00460001, "threegmlc/mod_link_supp (Bearer Modification Support Event)" },
485 { 0x00980000, "Hanging Termination Package" },
486 { 0x00980001, "Termination Heartbeat" },
487 { 0x800a0000, "Nokia Bearer Characteristics Package" },
488 {0, NULL}
492 * This table consist of PackageName + SignalName and its corresponding string
494 static const value_string base_signal_name_vals[] = {
495 { 0x00000000, "Media stream properties H.248.1 Annex C" },
496 { 0x00010000, "g H.248.1 Annex E" },
497 { 0x00030001, "tonegen/pt(Play tone)" },
498 { 0x00050010, "dg, DTMF character 0" },
499 { 0x00050011, "dg, DTMF character 1" },
500 { 0x00050012, "dg, DTMF character 2" },
501 { 0x00050013, "dg, DTMF character 3" },
502 { 0x00050014, "dg, DTMF character 4" },
503 { 0x00050015, "dg, DTMF character 5" },
504 { 0x00050016, "dg, DTMF character 6" },
505 { 0x00050017, "dg, DTMF character 7" },
506 { 0x00050018, "dg, DTMF character 8" },
507 { 0x00050019, "dg, DTMF character 9" },
508 { 0x0005001a, "dg, DTMF character A" },
509 { 0x0005001b, "dg, DTMF character B" },
510 { 0x0005001c, "dg, DTMF character C" },
511 { 0x0005001d, "dg, DTMF character D" },
512 { 0x00050020, "dg, DTMF character *" },
513 { 0x00050021, "dg, DTMF character #" },
514 { 0x00070030, "cg, Dial Tone" },
515 { 0x00070031, "cg/rt (Ringing Tone)" },
516 { 0x00070032, "cg, Busy Tone" },
517 { 0x00070033, "cg, Congestion Tone" },
518 { 0x00070034, "cg, Special Information Tone" },
519 { 0x00070035, "cg, (Recording) Warning Tone" },
520 { 0x00070036, "cg, Payphone Recognition Tone" },
521 { 0x00070037, "cg, Call Waiting Tone" },
522 { 0x00070038, "cg, Caller Waiting Tone" },
523 { 0x00090002, "al, ring" },
524 { 0x0009ffff, "al, *" },
525 { 0x000a0003, "ct, Continuity test" },
526 { 0x000a0004, "ct, Continuity respond" },
527 { 0x00210000, "GB Generic Bearer Connection Q.1950 Annex A" },
528 { 0x00210001, "GB/EstBNC(Establish BNC)" },
529 { 0x00210002, "GB/ModBNC (Modify BNC)" },
530 { 0x00210003, "GB/RelBNC(Release BNC)" },
531 { 0x002a0001, "H.245/cs (channel state)" },
532 { 0x002a0002, "H.245/termtype (Terminal Type)" },
533 { 0x002c0001, "H.324/cmod (Communication mode)" },
534 { 0x002c0002, "H.324/muxlv (Highest Multiplexing level)" },
535 { 0x002c0003, "H.324/demux (Demultiplex)" },
536 { 0x002c0004, "H.324/h223capr (Remote H.223 capability)" },
537 { 0x002c0005, "H.324/muxtbl_in (Incoming Multiplex Table)" },
538 { 0x002c0006, "H.324/muxtbl_out (Outgoing Multiplex Table)" },
539 { 0x800a0000, "Nokia Bearer Characteristics Package" },
540 {0, NULL}
544 static const value_string h248_reasons[] = {
545 { 400, "Syntax error in message"},
546 { 401, "Protocol Error"},
547 { 402, "Unauthorized"},
548 { 403, "Syntax error in transaction request"},
549 { 406, "Version Not Supported"},
550 { 410, "Incorrect identifier"},
551 { 411, "The transaction refers to an unknown ContextId"},
552 { 412, "No ContextIDs available"},
553 { 413, "Number of transactions in message exceeds maximum"}, /* [H.248.8 (08/07)] */
554 { 421, "Unknown action or illegal combination of actions"},
555 { 422, "Syntax Error in Action"},
556 { 430, "Unknown TerminationID"},
557 { 431, "No TerminationID matched a wildcard"},
558 { 432, "Out of TerminationIDs or No TerminationID available"},
559 { 433, "TerminationID is already in a Context"},
560 { 434, "Max number of Terminations in a Context exceeded"},
561 { 435, "Termination ID is not in specified Context"},
562 { 440, "Unsupported or unknown Package"},
563 { 441, "Missing Remote or Local Descriptor"},
564 { 442, "Syntax Error in Command"},
565 { 443, "Unsupported or Unknown Command"},
566 { 444, "Unsupported or Unknown Descriptor"},
567 { 445, "Unsupported or Unknown Property"},
568 { 446, "Unsupported or Unknown Parameter"},
569 { 447, "Descriptor not legal in this command"},
570 { 448, "Descriptor appears twice in a command"},
571 { 449, "Unsupported or Unknown Parameter or Property Value"},
572 { 450, "No such property in this package"},
573 { 451, "No such event in this package"},
574 { 452, "No such signal in this package"},
575 { 453, "No such statistic in this package"},
576 { 454, "No such parameter value in this package"},
577 { 455, "Property illegal in this Descriptor"},
578 { 456, "Property appears twice in this Descriptor"},
579 { 457, "Missing parameter in signal or event"},
580 { 458, "Unexpected Event/Request ID"},
581 { 459, "Unsupported or Unknown Profile"},
582 { 460, "Unable to set statistic on stream"},
583 { 461, "Unsupported or Unknown Profile"}, /*[H.248.18] */
585 { 471, "Implied Add for Multiplex failure"},
586 { 472, "Required Information Missing"}, /*[H.248.8 (08/07)] */
587 { 473, "Conflicting Property Values"}, /*[H.248.8 (08/07)] */
588 { 474, "Invalid SDP Syntax"}, /*[H.248.49] */
589 { 475, "Unable to pause the playout of the signal"}, /*[H.248.66] */
590 { 476, "Unable to adjust the data delivery speed of the Signal"}, /*[H.248.66] */
592 { 477, "Unable to adjust the playback relative scale of the signal"}, /*[H.248.66] */
594 { 478, "Behaviour Contradicts Resource Rule"}, /*[H.248.63] */
596 { 500, "Internal software Failure in MG"},
597 { 501, "Not Implemented"},
598 { 502, "Not ready"},
599 { 503, "Service Unavailable"},
600 { 504, "Command Received from unauthorized entity"},
601 { 505, "Transaction Request Received before a Service Change Reply has been received"},
602 { 506, "Number of Transaction Pendings Exceeded"},
603 { 510, "Insufficient resources"},
604 { 511, "Temporarily Busy"}, /* [H.248.8 (08/07)] */
605 { 512, "Media Gateway unequipped to detect requested Event"},
606 { 513, "Media Gateway unequipped to generate requested Signals"},
607 { 514, "Media Gateway cannot send the specified announcement"},
608 { 515, "Unsupported Media Type"},
609 { 517, "Unsupported or invalid mode"},
610 { 518, "Event buffer full"},
611 { 519, "Out of space to store digit map"},
612 { 520, "Digit Map undefined in the MG"},
613 { 521, "Termination is ServiceChangeing"},
614 { 522, "Functionality Requested in Topology Triple Not Supported"},
615 { 526, "Insufficient bandwidth"},
616 { 529, "Internal hardware failure in MG"},
617 { 530, "Temporary Network failure"},
618 { 531, "Permanent Network failure"},
619 { 532, "Audited Property, Statistic, Event or Signal does not exist"},
620 { 533, "Response exceeds maximum transport PDU size"},
621 { 534, "Illegal write or read only property"},
622 { 540, "Unexpected initial hook state"},
623 { 541, "Unexpected Spare Bit State"}, /* [H.248.33] */
624 { 542, "Command is not allowed on this termination"},
625 { 543, "MGC requested event detection timestamp not supported"}, /* [H.248.8 (08/07)] */
626 { 581, "Does Not Exist"},
627 { 600, "Illegal syntax within an announcement specification"},
628 { 601, "Variable type not supported"},
629 { 602, "Variable value out of range"},
630 { 603, "Category not supported"},
631 { 604, "Selector type not supported"},
632 { 605, "Selector value not supported"},
633 { 606, "Unknown segment ID"},
634 { 607, "Mismatch between play specification and provisioned data"},
635 { 608, "Provisioning error"},
636 { 609, "Invalid offset"},
637 { 610, "No free segment IDs"},
638 { 611, "Temporary segment not found"},
639 { 612, "Segment in use"},
640 { 613, "ISP port limit overrun"},
641 { 614, "No modems available"},
642 { 615, "Calling number unacceptable"},
643 { 616, "Called number unacceptable"},
644 { 617, "Reserved for H.248.9 return code"}, /* [H.248.9] */
645 { 618, "Reserved for H.248.9 return code"}, /* [H.248.9] */
646 { 622, "Reserved for H.248.9 return code"}, /* [H.248.9] */
647 { 623, "Reserved for H.248.9 return code"}, /* [H.248.9] */
648 { 624, "Reserved for H.248.9 return code"}, /* [H.248.9] */
649 { 625, "Reserved for H.248.9 return code"}, /* [H.248.9 Amendment 1] */
650 { 626, "Reserved for H.248.9 return code"}, /* [H.248.9 Amendment 1] */
651 { 627, "Reserved for H.248.9 return code"}, /* [H.248.9 Amendment 1] */
652 { 628, "Reserved for H.248.9 return code"}, /* [H.248.9 Amendment 1] */
653 { 629, "Reserved for H.248.9 return code"}, /* [H.248.9 Amendment 1] */
654 { 700, "Sieve Script Syntax Error"}, /* [H.248.69] */
655 { 701, "Unsupported Sieve Require Error"}, /* [H.248.69] */
656 { 702, "Sieve Actions Exceeded Error"}, /* [H.248.69] */
658 { 900, "Service Restored"},
659 { 901, "Cold Boot"},
660 { 902, "Warm Boot"},
661 { 903, "MGC Directed Change"},
662 { 904, "Termination malfunctioning"},
663 { 905, "Termination taken out of service"},
664 { 906, "Loss of lower layer connectivity (e.g. downstream sync)"},
665 { 907, "Transmission Failure"},
666 { 908, "MG Impending Failure"},
667 { 909, "MGC Impending Failure"},
668 { 910, "Media Capability Failure"},
669 { 911, "Modem Capability Failure"},
670 { 912, "Mux Capability Failure"},
671 { 913, "Signal Capability Failure"},
672 { 914, "Event Capability Failure"},
673 { 915, "State Loss"},
674 { 916, "Packages Change"},
675 { 917, "Capabilities Change"},
676 { 918, "Cancel Graceful"},
677 { 919, "Warm Failover"},
678 { 920, "Cold Failover"},
679 {0,NULL}
681 static value_string_ext h248_reasons_ext = VALUE_STRING_EXT_INIT(h248_reasons);
683 static const value_string wildcard_modes[] = {
684 { 0, "Choose" },
685 { 1, "All" },
686 { 0, NULL }
689 static const value_string wildcard_levels[] = {
690 { 0, "This One Level" },
691 { 1, "This Level and those below" },
692 { 0, NULL }
695 static h248_curr_info_t curr_info = {NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL};
696 static guint32 error_code;
697 static guint32 h248_version = 0; /* h248v1 support */
698 static gcp_wildcard_t wild_term;
699 static guint8 wild_card = 0xFF; /* place to store wildcardField */
701 extern void h248_param_ber_integer(proto_tree* tree, tvbuff_t* tvb, packet_info* pinfo, int hfid, h248_curr_info_t* u _U_, void* implicit) {
702 asn1_ctx_t asn1_ctx;
703 asn1_ctx_init(&asn1_ctx, ASN1_ENC_BER, TRUE, pinfo);
704 dissect_ber_integer(implicit ? *((gboolean*)implicit) : FALSE, &asn1_ctx, tree, tvb, 0, hfid, NULL);
707 extern void h248_param_ber_octetstring(proto_tree* tree, tvbuff_t* tvb, packet_info* pinfo, int hfid, h248_curr_info_t* u _U_, void* implicit) {
708 asn1_ctx_t asn1_ctx;
709 asn1_ctx_init(&asn1_ctx, ASN1_ENC_BER, TRUE, pinfo);
710 dissect_ber_octet_string(implicit ? *((gboolean*)implicit) : FALSE, &asn1_ctx, tree, tvb, 0, hfid, NULL);
713 extern void h248_param_ber_boolean(proto_tree* tree, tvbuff_t* tvb, packet_info* pinfo, int hfid, h248_curr_info_t* u _U_, void* implicit) {
714 asn1_ctx_t asn1_ctx;
715 asn1_ctx_init(&asn1_ctx, ASN1_ENC_BER, TRUE, pinfo);
716 dissect_ber_boolean(implicit ? *((gboolean*)implicit) : FALSE, &asn1_ctx, tree, tvb, 0, hfid, NULL);
719 extern void h248_param_bytes_item(proto_tree* tree,
720 tvbuff_t* tvb,
721 packet_info* pinfo _U_,
722 int hfid,
723 h248_curr_info_t* h248_info _U_,
724 void* lenp ) {
725 int len = lenp ? *((int*)lenp) : -1;
726 proto_tree_add_item(tree,hfid,tvb,0,len,ENC_NA);
729 extern void h248_param_uint_item(proto_tree* tree,
730 tvbuff_t* tvb,
731 packet_info* pinfo _U_,
732 int hfid,
733 h248_curr_info_t* h248_info _U_,
734 void* lenp ) {
735 int len = lenp ? *((int*)lenp) : -1;
736 proto_tree_add_item(tree,hfid,tvb,0,len,ENC_BIG_ENDIAN);
739 extern void h248_param_external_dissector(proto_tree* tree, tvbuff_t* tvb, packet_info* pinfo , int hfid _U_, h248_curr_info_t* u _U_, void* dissector_hdl) {
740 call_dissector((dissector_handle_t) dissector_hdl,tvb,pinfo,tree);
744 static const h248_package_t no_package = { 0xffff, &hf_h248_no_pkg, &ett_h248_no_pkg, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL };
745 static const h248_pkg_sig_t no_signal = { 0, &hf_h248_no_sig, &ett_h248_no_sig, NULL, NULL };
746 static const h248_pkg_param_t no_param = { 0, &hf_h248_param, h248_param_uint_item, NULL };
747 static const h248_pkg_evt_t no_event = { 0, &hf_h248_no_evt, &ett_h248_no_evt, NULL, NULL };
749 const h248_package_t *find_package_id(guint16 pkgid);
750 static GTree* packages = NULL;
752 extern void h248_param_PkgdName(proto_tree* tree, tvbuff_t* tvb, packet_info* pinfo , int hfid _U_, h248_curr_info_t* u1 _U_, void* u2 _U_) {
753 tvbuff_t *new_tvb = NULL;
754 proto_tree *package_tree=NULL;
755 guint16 name_major, name_minor;
756 const h248_package_t* pkg = NULL;
757 int offset = 0;
758 asn1_ctx_t asn1_ctx;
759 asn1_ctx_init(&asn1_ctx, ASN1_ENC_BER, TRUE, pinfo);
761 offset = dissect_ber_octet_string(FALSE, &asn1_ctx, tree, tvb, offset, hfid , &new_tvb);
763 if (new_tvb) {
764 /* this field is always 4 bytes so just read it into two integers */
765 name_major=tvb_get_ntohs(new_tvb, 0);
766 name_minor=tvb_get_ntohs(new_tvb, 2);
767 pkg = find_package_id(name_major);
768 /* do the prettification */
769 proto_item_append_text(asn1_ctx.created_item, " %s (%04x)",
770 val_to_str(0, pkg->param_names, "Unknown Package"),
771 name_major);
773 if(tree){
774 proto_item* pi;
775 const gchar* strval;
777 package_tree = proto_item_add_subtree(asn1_ctx.created_item, ett_packagename);
778 proto_tree_add_uint_format(package_tree, hf_h248_pkg_name, tvb, offset-4, 2, name_major,
779 "%s (0x%04x)", val_to_str(0, pkg->param_names, "Unknown Package"), name_major);
781 pi = proto_tree_add_uint(package_tree, hf_248_pkg_param, tvb, offset-2, 2, name_minor);
783 if (pkg->signal_names && ( strval = try_val_to_str(name_minor, pkg->signal_names) )) {
784 strval = wmem_strdup_printf(wmem_packet_scope(), "%s (%d)",strval,name_minor);
785 } else {
786 strval = wmem_strdup_printf(wmem_packet_scope(), "Unknown (%d)",name_minor);
789 proto_item_set_text(pi,"Signal ID: %s", strval);
796 static int dissect_h248_trx_id(gboolean implicit_tag, packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset, guint32* trx_id_p) {
797 guint64 trx_id = 0;
798 gint8 ber_class;
799 gboolean pc;
800 gint32 tag;
801 guint32 len;
802 guint32 i;
804 if(!implicit_tag){
805 offset=dissect_ber_identifier(pinfo, tree, tvb, offset, &ber_class, &pc, &tag);
806 offset=dissect_ber_length(pinfo, tree, tvb, offset, &len, NULL);
807 } else {
808 len=tvb_length_remaining(tvb, offset);
812 if (len > 8 || len < 1) {
813 THROW(BoundsError);
814 } else {
815 for(i=1;i<=len;i++){
816 trx_id=(trx_id<<8)|tvb_get_guint8(tvb, offset);
817 offset++;
819 if (trx_id > 0xffffffff) {
820 proto_item* pi = proto_tree_add_uint64(tree, hf_h248_transactionId64, tvb, offset-len, len, trx_id);
821 expert_add_info(pinfo, pi, &ei_h248_transactionId64);
823 *trx_id_p = 0;
825 } else {
826 proto_tree_add_uint(tree, hf_h248_transactionId, tvb, offset-len, len, (guint32)trx_id);
827 *trx_id_p = (guint32)trx_id;
831 return offset;
834 static int dissect_h248_ctx_id(gboolean implicit_tag, packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset, guint32* ctx_id_p) {
835 gint8 ber_class;
836 gboolean pc;
837 gint32 tag;
838 guint32 len;
839 guint64 ctx_id = 0;
840 guint32 i;
842 if(!implicit_tag){
843 offset=dissect_ber_identifier(pinfo, tree, tvb, offset, &ber_class, &pc, &tag);
844 offset=dissect_ber_length(pinfo, tree, tvb, offset, &len, NULL);
845 } else {
846 len=tvb_length_remaining(tvb, offset);
850 if (len > 8 || len < 1) {
851 THROW(BoundsError);
852 } else {
853 for(i=1;i<=len;i++){
854 ctx_id=(ctx_id<<8)|tvb_get_guint8(tvb, offset);
855 offset++;
858 if (ctx_id > 0xffffffff) {
859 proto_item* pi = proto_tree_add_uint64(tree, hf_h248_context_id64, tvb, offset-len, len, ctx_id);
860 expert_add_info(pinfo, pi, &ei_h248_context_id64);
862 *ctx_id_p = 0xfffffffd;
864 } else {
865 proto_item* pi = proto_tree_add_uint(tree, hf_h248_context_id, tvb, offset-len, len, (guint32)ctx_id);
867 if ( ctx_id == NULL_CONTEXT ) {
868 proto_item_set_text(pi,"contextId: Null Context(0)");
869 } else if ( ctx_id == CHOOSE_CONTEXT ) {
870 proto_item_set_text(pi,"contextId: $ (Choose Context = 0xfffffffe)");
871 } else if ( ctx_id == ALL_CONTEXTS ) {
872 proto_item_set_text(pi,"contextId: * (All Contexts = 0xffffffff)");
875 *ctx_id_p = (guint32) ctx_id;
879 return offset;
882 s_h248_package_t *s_find_package_id(guint16 pkgid) {
883 s_h248_package_t *s_pkg = NULL;
884 s_pkg = (s_h248_package_t *)g_tree_lookup(packages, GUINT_TO_POINTER((guint32)(pkgid)));
885 return s_pkg;
888 const h248_package_t *find_package_id(guint16 pkgid) {
889 s_h248_package_t *s_pkg = NULL;
890 s_pkg = s_find_package_id(pkgid); /*(packages, GUINT_TO_POINTER((guint32)(pkgid))); */
891 if (! s_pkg ) return &no_package;
892 return s_pkg->pkg;
895 static gint32 comparePkgID(gconstpointer a, gconstpointer b) {
896 return GPOINTER_TO_UINT(b) - GPOINTER_TO_UINT(a);
899 gboolean is_pkg_default(guint16 pkgid) {
900 s_h248_package_t *s_pkg = NULL;
901 s_pkg = (s_h248_package_t *)g_tree_lookup(packages, GUINT_TO_POINTER((guint32)(pkgid)));
902 if(! s_pkg ) return TRUE;
903 return s_pkg->is_default;
906 void h248_register_package(const h248_package_t* pkg, pkg_reg_action reg_action) {
907 h248_package_t *pkg_found = NULL, *pkg_high = NULL, *pkg_low = NULL;
908 s_h248_package_t *s_pkg = NULL;
909 value_string *vst;
910 gboolean pkg_default = FALSE;
911 gint j = 0, idx = 0, i = 0, k = 0;
912 if (! packages) {
913 /* no packaegs are yet registerd so create tree and add default packages to tree
915 packages = g_tree_new(comparePkgID); /* init tree if no entries */
916 while (base_package_name_vals[i].strptr != NULL) {
917 pkg_found = wmem_new0(wmem_epan_scope(), h248_package_t); /* create a h248 package structure */
918 pkg_found->id = base_package_name_vals[i].value;
919 vst = (value_string *)wmem_alloc0(wmem_epan_scope(), sizeof(value_string)*2);
920 vst[0].strptr = base_package_name_vals[i].strptr;
921 pkg_found->param_names = vst;
922 pkg_found->hfid = &hf_h248_pkg_name;
923 pkg_found->ett = &ett_packagename;
924 try_val_to_str_idx((pkg_found->id)<<16,base_event_name_vals, &j);
925 /* now look for events and signals that may be defined for package. If found, create value_strings */
926 if (j != -1) {
927 j++; idx=j;
928 while((base_event_name_vals[j].strptr!=NULL) && (((base_event_name_vals[j].value)>>16) == (pkg_found->id))) {
929 j++;
931 if (idx < j) {
932 vst = (value_string *)wmem_alloc0(wmem_epan_scope(), sizeof(value_string)*(j-idx+1));
933 for (k=0;idx<j;k++) {
934 vst[k].strptr = base_event_name_vals[idx].strptr;
935 vst[k].value = (base_event_name_vals[idx].value & 0xffff);
936 idx++;
938 pkg_found->event_names = vst;
941 /* now look at signals */
942 if (!try_val_to_str_idx((pkg_found->id)<<16, base_signal_name_vals, &j)) {
943 j++; idx=j;
944 while((base_signal_name_vals[j].strptr != NULL) && ((base_signal_name_vals[j].value>>16) == (pkg_found->id))) {
946 if (idx < j) {
947 vst = g_new0(value_string,j-idx+1);
948 for (k=0;idx<i;k++) {
949 vst[k].strptr = base_signal_name_vals[idx].strptr;
950 vst[k].value = (base_signal_name_vals[idx].value &0xffff);
951 idx++;
953 pkg_found->signal_names = vst;
956 s_pkg = wmem_new0(wmem_epan_scope(), s_h248_package_t);
957 s_pkg->is_default = TRUE;
958 s_pkg->pkg = pkg_found;
959 g_tree_insert(packages, GINT_TO_POINTER(pkg_found->id), (gpointer)s_pkg);
960 i++;
962 pkg_found = NULL; /* reset pointer */
964 pkg_default = is_pkg_default(pkg->id);
965 if (((reg_action==REPLACE_PKG) || (reg_action==ADD_PKG)) && pkg_default) {
966 /* add/replace in tree */
967 s_pkg = wmem_new0(wmem_epan_scope(), s_h248_package_t);
968 s_pkg->is_default = FALSE;
969 s_pkg->pkg = (h248_package_t *)pkg;
970 g_tree_replace(packages, GINT_TO_POINTER(pkg->id), (gpointer)s_pkg);
971 return;
973 if(pkg_default) reg_action = MERGE_PKG_HIGH; /* always make new package overide default */
974 s_pkg = s_find_package_id(pkg->id);
975 if (s_pkg == NULL) { /* no need to merge - package not in tree */
976 s_pkg = wmem_new0(wmem_epan_scope(), s_h248_package_t);
977 s_pkg->is_default = FALSE;
978 s_pkg->pkg = (h248_package_t *)pkg;
979 g_tree_insert(packages, GINT_TO_POINTER(pkg->id), (gpointer)s_pkg);
980 return;
982 pkg_found = s_pkg->pkg;
983 if (reg_action==MERGE_PKG_HIGH) {
984 pkg_high = (h248_package_t *)pkg;
985 pkg_low = pkg_found;
987 if (reg_action==MERGE_PKG_LOW) {
988 pkg_high = pkg_found;
989 pkg_low = (h248_package_t *)pkg;
991 /* if h248_package_t High Priority value !NULL, replace it in the found tree entry else use current entry */
992 (pkg_high->hfid ? (pkg_found->hfid=pkg_high->hfid) : (pkg_found->hfid=pkg_low->hfid));
993 (pkg_high->ett ? (pkg_found->ett=pkg_high->ett ):( pkg_found->ett=pkg_low->ett));
994 (pkg_high->param_names ? (pkg_found->param_names=pkg_high->param_names ):( pkg_found->param_names=pkg_low->param_names));
995 (pkg_high->signal_names ? (pkg_found->signal_names=pkg_high->signal_names ):( pkg_found->signal_names=pkg_low->signal_names));
996 (pkg_high->event_names ? (pkg_found->event_names=pkg_high->event_names ):( pkg_found->event_names=pkg_low->event_names));
997 (pkg_high->stats_names ? (pkg_found->stats_names=pkg_high->stats_names ):( pkg_found->stats_names=pkg_low->stats_names));
998 (pkg_high->properties ? (pkg_found->properties=pkg_high->properties ):( pkg_found->properties=pkg_low->properties));
999 (pkg_high->signals ? (pkg_found->signals=pkg_high->signals ):( pkg_found->signals=pkg_low->signals));
1000 (pkg_high->events ? (pkg_found->events=pkg_high->events ):( pkg_found->events=pkg_low->events));
1001 (pkg_high->statistics ? (pkg_found->statistics=pkg_high->statistics ):( pkg_found->statistics=pkg_low->statistics));
1002 s_pkg->pkg = pkg_found;
1003 s_pkg->is_default = FALSE;
1007 static guint32 packageandid;
1009 static int dissect_h248_PkgdName(gboolean implicit_tag, tvbuff_t *tvb, int offset, asn1_ctx_t *actx _U_, proto_tree *tree, int hf_index) {
1010 tvbuff_t *new_tvb = NULL;
1011 proto_tree *package_tree=NULL;
1012 guint16 name_major, name_minor;
1013 const h248_package_t* pkg = NULL;
1015 offset = dissect_ber_octet_string(implicit_tag, actx, tree, tvb, offset, hf_index, &new_tvb);
1017 if (new_tvb) {
1018 /* this field is always 4 bytes so just read it into two integers */
1019 name_major=tvb_get_ntohs(new_tvb, 0);
1020 name_minor=tvb_get_ntohs(new_tvb, 2);
1021 packageandid=(name_major<<16)|name_minor;
1023 pkg = find_package_id(name_major);
1024 /* do the prettification */
1025 proto_item_append_text(actx->created_item, " %s (%04x)",
1026 val_to_str(0, pkg->param_names, "Unknown Package"),
1027 name_major);
1029 if(tree){
1030 package_tree = proto_item_add_subtree(actx->created_item, ett_packagename);
1031 proto_tree_add_uint_format(package_tree, hf_h248_pkg_name, tvb, offset-4, 2, name_major,
1032 "PkgName: %s (0x%04x)", val_to_str(0, pkg->param_names, "Unknown Package"), name_major);
1036 proto_item* pi = proto_tree_add_uint(package_tree, hf_248_pkg_param, tvb, offset-2, 2, name_minor);
1037 const gchar* strval;
1039 if (pkg->param_names && ( strval = try_val_to_str(name_minor, pkg->param_names) )) {
1040 strval = wmem_strdup_printf(wmem_packet_scope(), "%s (%d)",strval,name_minor);
1041 } else {
1042 strval = wmem_strdup_printf(wmem_packet_scope(), "Unknown (%d)",name_minor);
1045 proto_item_set_text(pi,"Parameter: %s", strval);
1047 } else {
1048 pkg = &no_package;
1051 curr_info.pkg = pkg;
1053 return offset;
1056 static int dissect_h248_EventName(gboolean implicit_tag, tvbuff_t *tvb, int offset, asn1_ctx_t *actx _U_, proto_tree *tree, int hf_index) {
1057 tvbuff_t *new_tvb;
1058 proto_tree *package_tree=NULL;
1059 guint16 name_major, name_minor;
1060 const h248_package_t* pkg = NULL;
1061 const h248_pkg_evt_t* evt = NULL;
1063 offset = dissect_ber_octet_string(implicit_tag, actx, tree, tvb, offset, hf_index, &new_tvb);
1065 if (new_tvb) {
1066 /* this field is always 4 bytes so just read it into two integers */
1067 name_major=tvb_get_ntohs(new_tvb, 0);
1068 name_minor=tvb_get_ntohs(new_tvb, 2);
1069 packageandid=(name_major<<16)|name_minor;
1071 pkg = find_package_id(name_major);
1072 /* do the prettification */
1073 proto_item_append_text(actx->created_item, " %s (%04x)",
1074 val_to_str(0, pkg->param_names, "Unknown Package"),
1075 name_major);
1076 if(tree){
1077 package_tree = proto_item_add_subtree(actx->created_item, ett_packagename);
1079 proto_tree_add_uint_format(package_tree, hf_h248_pkg_name, tvb, offset-4, 2, name_major,
1080 "%s (0x%04x)", val_to_str(0, pkg->param_names, "Unknown Package"), name_major);
1082 curr_info.pkg = pkg;
1084 if (pkg->events) {
1085 for (evt = pkg->events; evt->hfid; evt++) {
1086 if (name_minor == evt->id) {
1087 break;
1091 if (! evt->hfid) evt = &no_event;
1092 } else {
1093 evt = &no_event;
1096 curr_info.evt = evt;
1099 proto_item* pi = proto_tree_add_uint(package_tree, hf_h248_event_code, tvb, offset-2, 2, name_minor);
1100 const gchar* strval;
1102 if (pkg->event_names && ( strval = try_val_to_str(name_minor, pkg->event_names) )) {
1103 strval = wmem_strdup_printf(wmem_packet_scope(), "%s (%d)",strval,name_minor);
1104 } else {
1105 strval = wmem_strdup_printf(wmem_packet_scope(), "Unknown (%d)",name_minor);
1108 proto_item_set_text(pi,"Event ID: %s", strval);
1111 } else {
1112 curr_info.pkg = &no_package;
1113 curr_info.evt = &no_event;
1116 return offset;
1121 static int dissect_h248_SignalName(gboolean implicit_tag , tvbuff_t *tvb, int offset, asn1_ctx_t *actx _U_, proto_tree *tree, int hf_index) {
1122 tvbuff_t *new_tvb;
1123 proto_tree *package_tree=NULL;
1124 guint16 name_major, name_minor;
1125 const h248_package_t* pkg = NULL;
1126 const h248_pkg_sig_t* sig;
1128 offset = dissect_ber_octet_string(implicit_tag, actx, tree, tvb, offset, hf_index, &new_tvb);
1130 if (new_tvb) {
1131 /* this field is always 4 bytes so just read it into two integers */
1132 name_major=tvb_get_ntohs(new_tvb, 0);
1133 name_minor=tvb_get_ntohs(new_tvb, 2);
1134 packageandid=(name_major<<16)|name_minor;
1136 pkg = find_package_id(name_major);
1137 /* do the prettification */
1138 proto_item_append_text(actx->created_item, " %s (%04x)",
1139 val_to_str(0, pkg->param_names, "Unknown Package"),
1140 name_major);
1141 if(tree){
1142 package_tree = proto_item_add_subtree(actx->created_item, ett_packagename);
1144 proto_tree_add_uint_format(package_tree, hf_h248_pkg_name, tvb, offset-4, 2, name_major,
1145 "%s (0x%04x)", val_to_str(0, pkg->param_names, "Unknown Package"), name_major);
1147 if (pkg->signals) {
1148 for (sig = pkg->signals; sig->hfid; sig++) {
1149 if (name_minor == sig->id) {
1150 break;
1154 if (! sig->hfid) sig = &no_signal;
1156 curr_info.pkg = pkg;
1157 curr_info.sig = sig;
1158 } else {
1159 curr_info.pkg = &no_package;
1160 curr_info.sig = &no_signal;
1164 proto_item* pi = proto_tree_add_uint(package_tree, hf_h248_signal_code, tvb, offset-2, 2, name_minor);
1165 const gchar* strval;
1167 if (pkg->signal_names && ( strval = try_val_to_str(name_minor, pkg->signal_names) )) {
1168 strval = wmem_strdup_printf(wmem_packet_scope(), "%s (%d)",strval,name_minor);
1169 } else {
1170 strval = wmem_strdup_printf(wmem_packet_scope(), "Unknown (%d)",name_minor);
1173 proto_item_set_text(pi,"Signal ID: %s", strval);
1176 } else {
1177 curr_info.pkg = &no_package;
1178 curr_info.sig = &no_signal;
1181 return offset;
1184 static int dissect_h248_PropertyID(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, asn1_ctx_t *actx _U_, proto_tree *tree, int hf_index _U_) {
1186 gint8 ber_class;
1187 gboolean pc, ind;
1188 gint32 tag;
1189 guint32 len;
1190 guint16 name_minor;
1191 int end_offset;
1192 const h248_package_t* pkg;
1193 const h248_pkg_param_t* prop;
1194 tvbuff_t *next_tvb = NULL;
1196 offset=dissect_ber_identifier(actx->pinfo, tree, tvb, offset, &ber_class, &pc, &tag);
1197 offset=dissect_ber_length(actx->pinfo, tree, tvb, offset, &len, &ind);
1198 end_offset=offset+len;
1200 if( (ber_class!=BER_CLASS_UNI)
1201 ||(tag!=BER_UNI_TAG_OCTETSTRING) ){
1202 proto_tree_add_text(tree, tvb, offset-2, 2, "H.248 BER Error: OctetString expected but Class:%d PC:%d Tag:%d was unexpected", ber_class, pc, tag);
1203 return end_offset;
1206 next_tvb = tvb_new_subset(tvb,offset,len,len);
1208 name_minor = packageandid & 0xffff;
1210 pkg = (curr_info.pkg) ? curr_info.pkg : &no_package;
1212 if (pkg->properties) {
1213 for (prop = pkg->properties; prop && prop->hfid; prop++) {
1214 if (name_minor == prop->id) {
1215 break;
1218 } else {
1219 prop = &no_param;
1221 if (prop && prop->hfid ) {
1222 if (!prop->dissector) prop = &no_param;
1223 prop->dissector(tree, next_tvb, actx->pinfo, *(prop->hfid), &curr_info, prop->data);
1226 return end_offset;
1231 static int dissect_h248_SigParameterName(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, asn1_ctx_t *actx _U_, proto_tree *tree, int hf_index _U_) {
1232 tvbuff_t *next_tvb;
1233 guint32 param_id = 0xffffffff;
1234 const h248_pkg_param_t* sigpar;
1235 const gchar* strval;
1236 proto_item* pi;
1238 offset = dissect_ber_octet_string(implicit_tag, actx, tree, tvb, offset, hf_index, &next_tvb);
1239 pi = actx->created_item;
1241 switch(tvb_length(next_tvb)) {
1242 case 4: param_id = tvb_get_ntohl(next_tvb,0); break;
1243 case 3: param_id = tvb_get_ntoh24(next_tvb,0); break;
1244 case 2: param_id = tvb_get_ntohs(next_tvb,0); break;
1245 case 1: param_id = tvb_get_guint8(next_tvb,0); break;
1246 default: break;
1249 curr_info.par = &no_param;
1251 if (curr_info.sig && curr_info.sig->parameters) {
1252 for(sigpar = curr_info.sig->parameters; sigpar->hfid; sigpar++) {
1253 if (sigpar->id == param_id) {
1254 curr_info.par = sigpar;
1255 break;
1260 if (curr_info.sig && curr_info.sig->param_names && ( strval = try_val_to_str(param_id, curr_info.sig->param_names) )) {
1261 strval = wmem_strdup_printf(wmem_packet_scope(), "%s (%d)",strval,param_id);
1262 } else {
1263 strval = wmem_strdup_printf(wmem_packet_scope(), "Unknown (%d)",param_id);
1266 proto_item_set_text(pi,"Parameter: %s", strval);
1268 return offset;
1271 static int dissect_h248_SigParamValue(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, asn1_ctx_t *actx _U_, proto_tree *tree, int hf_index _U_) {
1272 int end_offset;
1273 gint8 ber_class;
1274 gboolean pc, ind;
1275 gint32 tag;
1276 guint32 len;
1277 tvbuff_t *next_tvb = NULL;
1279 offset=dissect_ber_identifier(actx->pinfo, tree, tvb, offset, &ber_class, &pc, &tag);
1280 offset=dissect_ber_length(actx->pinfo, tree, tvb, offset, &len, &ind);
1281 end_offset=offset+len;
1283 if( (ber_class!=BER_CLASS_UNI)
1284 ||(tag!=BER_UNI_TAG_OCTETSTRING) ){
1285 proto_tree_add_text(tree, tvb, offset-2, 2, "H.248 BER Error: OctetString expected but Class:%d PC:%d Tag:%d was unexpected", ber_class, pc, tag);
1286 return end_offset;
1289 next_tvb = tvb_new_subset(tvb,offset,len,len);
1291 if ( curr_info.par && curr_info.par->dissector) {
1292 curr_info.par->dissector(tree, next_tvb, actx->pinfo, *(curr_info.par->hfid), &curr_info, curr_info.par->data);
1295 return end_offset;
1298 static int dissect_h248_SigParamValueV1(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree, int hf_index _U_) {
1299 return dissect_ber_octet_string(implicit_tag, actx, tree, tvb, offset, hf_index, NULL);
1303 static int dissect_h248_EventParameterName(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, asn1_ctx_t *actx _U_, proto_tree *tree, int hf_index _U_) {
1304 tvbuff_t *next_tvb;
1305 guint32 param_id = 0xffffffff;
1306 const h248_pkg_param_t* evtpar;
1307 const gchar* strval;
1308 proto_item* pi;
1310 offset = dissect_ber_octet_string(implicit_tag, actx, tree, tvb, offset, hf_index, &next_tvb);
1311 pi = actx->created_item;
1313 if (next_tvb) {
1314 switch(tvb_length(next_tvb)) {
1315 case 4: param_id = tvb_get_ntohl(next_tvb,0); break;
1316 case 3: param_id = tvb_get_ntoh24(next_tvb,0); break;
1317 case 2: param_id = tvb_get_ntohs(next_tvb,0); break;
1318 case 1: param_id = tvb_get_guint8(next_tvb,0); break;
1319 default: break;
1324 curr_info.par = &no_param;
1326 if (curr_info.evt && curr_info.evt->parameters) {
1327 for(evtpar = curr_info.evt->parameters; evtpar->hfid; evtpar++) {
1328 if (evtpar->id == param_id) {
1329 curr_info.par = evtpar;
1330 break;
1333 } else {
1334 curr_info.par = &no_param;
1337 if (curr_info.evt && curr_info.evt->param_names && ( strval = try_val_to_str(param_id, curr_info.evt->param_names) )) {
1338 strval = wmem_strdup_printf(wmem_packet_scope(), "%s (%d)",strval,param_id);
1339 } else {
1340 strval = wmem_strdup_printf(wmem_packet_scope(), "Unknown (%d)",param_id);
1343 proto_item_set_text(pi,"Parameter: %s", strval);
1346 return offset;
1349 static int dissect_h248_EventParamValue(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, asn1_ctx_t *actx _U_, proto_tree *tree, int hf_index _U_) {
1350 tvbuff_t *next_tvb;
1351 int end_offset;
1352 gint8 ber_class;
1353 gboolean pc, ind;
1354 gint32 tag;
1355 guint32 len;
1357 offset=dissect_ber_identifier(actx->pinfo, tree, tvb, offset, &ber_class, &pc, &tag);
1358 offset=dissect_ber_length(actx->pinfo, tree, tvb, offset, &len, &ind);
1359 end_offset=offset+len;
1361 if( (ber_class!=BER_CLASS_UNI)
1362 ||(tag!=BER_UNI_TAG_OCTETSTRING) ){
1363 proto_tree_add_text(tree, tvb, offset-2, 2, "H.248 BER Error: OctetString expected but Class:%d PC:%d Tag:%d was unexpected", ber_class, pc, tag);
1364 return end_offset;
1367 next_tvb = tvb_new_subset(tvb,offset,len,len);
1369 if ( curr_info.par && curr_info.par->dissector) {
1370 curr_info.par->dissector(tree, next_tvb, actx->pinfo, *(curr_info.par->hfid), &curr_info, curr_info.par->data);
1373 return end_offset;
1376 static int dissect_h248_EventParamValueV1(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree, int hf_index _U_) {
1377 return dissect_ber_octet_string(implicit_tag, actx, tree, tvb, offset, hf_index, &tvb);
1381 static int dissect_h248_MtpAddress(gboolean implicit_tag, tvbuff_t *tvb, int offset, asn1_ctx_t *actx _U_, proto_tree *tree, int hf_index) {
1382 tvbuff_t *new_tvb;
1383 proto_tree *mtp_tree=NULL;
1384 guint32 val;
1385 int i, len, old_offset;
1387 old_offset=offset;
1388 offset = dissect_ber_octet_string(implicit_tag, actx, tree, tvb, offset, hf_index, &new_tvb);
1390 if (new_tvb) {
1391 /* this field is either 2 or 4 bytes so just read it into an integer */
1392 val=0;
1393 len=tvb_length(new_tvb);
1394 for(i=0;i<len;i++){
1395 val= (val<<8)|tvb_get_guint8(new_tvb, i);
1398 /* do the prettification */
1399 proto_item_append_text(actx->created_item, " NI = %d, PC = %d ( %d-%d )", val&0x03,val>>2,val&0x03,val>>2);
1400 if(tree){
1401 mtp_tree = proto_item_add_subtree(actx->created_item, ett_mtpaddress);
1403 proto_tree_add_uint(mtp_tree, hf_h248_mtpaddress_ni, tvb, old_offset, offset-old_offset, val&0x03);
1404 proto_tree_add_uint(mtp_tree, hf_h248_mtpaddress_pc, tvb, old_offset, offset-old_offset, val>>2);
1407 return offset;
1410 #define H248_TAP() do { if (keep_persistent_data && curr_info.cmd) tap_queue_packet(h248_tap, actx->pinfo, curr_info.cmd); } while(0)
1412 #include "packet-h248-fn.c"
1414 static void dissect_h248_tpkt(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) {
1415 dissect_tpkt_encap(tvb, pinfo, tree, h248_desegment, h248_handle);
1418 static void
1419 dissect_h248(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
1421 proto_item *h248_item;
1422 asn1_ctx_t asn1_ctx;
1423 h248_tree = NULL;
1424 h248_tvb = NULL;
1426 asn1_ctx_init(&asn1_ctx, ASN1_ENC_BER, TRUE, pinfo);
1428 curr_info.msg = NULL;
1429 curr_info.trx = NULL;
1430 curr_info.ctx = NULL;
1431 curr_info.cmd = NULL;
1432 curr_info.term = NULL;
1433 curr_info.pkg = NULL;
1434 curr_info.evt = NULL;
1435 curr_info.sig = NULL;
1436 curr_info.stat = NULL;
1437 curr_info.par = NULL;
1439 /* Check if it is actually a text-based H.248 encoding, which we
1440 dissect with the "megaco" dissector in Wireshark. (Both
1441 encodings are MEGACO (RFC 3015) and both are H.248.)
1443 if(tvb_length(tvb)>=6){
1444 if(!tvb_strneql(tvb, 0, "MEGACO", 6)){
1445 static dissector_handle_t megaco_handle=NULL;
1446 if(!megaco_handle){
1447 megaco_handle = find_dissector("megaco");
1449 if(megaco_handle){
1450 call_dissector(megaco_handle, tvb, pinfo, tree);
1451 return;
1455 proto_item *hidden_item = NULL;
1456 guint32 magic_num = 0, offset = 0;
1457 magic_num = tvb_get_ntohl(tvb, offset);
1458 hidden_item = proto_tree_add_uint(tree, hf_248_magic_num, tvb, offset, 4, magic_num);
1459 PROTO_ITEM_SET_HIDDEN(hidden_item);
1460 if( dissector_try_uint(subdissector_table, magic_num, tvb, pinfo, tree) ) {
1461 return;
1466 /* Make entry in the Protocol column on summary display */
1467 col_set_str(pinfo->cinfo, COL_PROTOCOL, "H.248");
1469 if (tree) {
1470 h248_item = proto_tree_add_item(tree, proto_h248, tvb, 0, -1, ENC_NA);
1471 h248_tree = proto_item_add_subtree(h248_item, ett_h248);
1474 dissect_h248_MegacoMessage(FALSE, tvb, 0, &asn1_ctx, h248_tree, -1);
1478 /*--- proto_register_h248 ----------------------------------------------*/
1479 void proto_reg_handoff_h248(void);
1481 void proto_register_h248(void) {
1483 /* List of fields */
1484 static hf_register_info hf[] = {
1485 { &hf_248_magic_num,
1486 { "Magic Number for Avaya H.248", "h248.magic_num",
1487 FT_UINT32, BASE_HEX, NULL, 0,
1488 NULL, HFILL}},
1489 { &hf_h248_mtpaddress_ni,
1490 { "NI", "h248.mtpaddress.ni",
1491 FT_UINT32, BASE_DEC, NULL, 0,
1492 NULL, HFILL }},
1493 { &hf_h248_mtpaddress_pc,
1494 { "PC", "h248.mtpaddress.pc",
1495 FT_UINT32, BASE_DEC, NULL, 0,
1496 NULL, HFILL }},
1497 { &hf_h248_pkg_name,
1498 { "Package", "h248.package_name",
1499 FT_UINT16, BASE_HEX, NULL, 0,
1500 NULL, HFILL }},
1501 { &hf_248_pkg_param,
1502 { "Parameter ID", "h248.package_paramid",
1503 FT_UINT16, BASE_HEX, NULL, 0,
1504 NULL, HFILL }},
1505 { &hf_h248_signal_code,
1506 { "Signal ID", "h248.package_signalid",
1507 FT_UINT16, BASE_HEX, NULL, 0,
1508 NULL, HFILL }},
1509 { &hf_h248_event_code,
1510 { "Event ID", "h248.package_eventid",
1511 FT_UINT16, BASE_HEX, NULL, 0,
1512 NULL, HFILL }},
1513 { &hf_h248_event_name,
1514 { "Package and Event name", "h248.event_name",
1515 FT_UINT32, BASE_HEX, NULL, 0,
1516 NULL, HFILL }},
1517 { &hf_h248_signal_name,
1518 { "Package and Signal name", "h248.signal_name",
1519 FT_UINT32, BASE_HEX, NULL, 0,
1520 NULL, HFILL }},
1521 { &hf_h248_pkg_bcp_BNCChar_PDU,
1522 { "BNCChar", "h248.package_bcp.BNCChar",
1523 FT_UINT32, BASE_DEC, VALS(gcp_term_types), 0,
1524 NULL, HFILL }},
1525 { &hf_h248_context_id,
1526 { "contextId", "h248.contextId",
1527 FT_UINT32, BASE_HEX, NULL, 0,
1528 "Context ID", HFILL }},
1529 { &hf_h248_term_wild_type,
1530 { "Wildcard Mode", "h248.term.wildcard.mode",
1531 FT_UINT8, BASE_DEC, VALS(wildcard_modes), 0x80,
1532 NULL, HFILL }},
1533 { &hf_h248_term_wild_level,
1534 { "Wildcarding Level", "h248.term.wildcard.level",
1535 FT_UINT8, BASE_DEC, VALS(wildcard_levels), 0x40,
1536 NULL, HFILL }},
1537 { &hf_h248_term_wild_position,
1538 { "Wildcarding Position", "h248.term.wildcard.pos",
1539 FT_UINT8, BASE_DEC, NULL, 0x3F,
1540 NULL, HFILL }},
1542 { &hf_h248_no_pkg,
1543 { "Unknown Package", "h248.pkg.unknown",
1544 FT_BYTES, BASE_NONE, NULL, 0,
1545 NULL, HFILL }},
1546 { &hf_h248_no_sig,
1547 { "Unknown Signal", "h248.pkg.unknown.sig",
1548 FT_BYTES, BASE_NONE, NULL, 0,
1549 NULL, HFILL }},
1550 { &hf_h248_no_evt,
1551 { "Unknown Event", "h248.pkg.unknown.evt",
1552 FT_BYTES, BASE_NONE, NULL, 0,
1553 NULL, HFILL }},
1554 { &hf_h248_param,
1555 { "Parameter", "h248.pkg.unknown.param",
1556 FT_BYTES, BASE_NONE, NULL, 0,
1557 NULL, HFILL }},
1558 { &hf_h248_serviceChangeReasonStr,
1559 { "ServiceChangeReasonStr", "h248.serviceChangeReasonstr",
1560 FT_STRING, BASE_NONE, NULL, 0,
1561 "h248.IA5String", HFILL }},
1562 { &hf_h248_context_id64,
1563 { "contextId", "h248.contextId",
1564 FT_UINT64, BASE_HEX, NULL, 0,
1565 "Context ID", HFILL }},
1566 { &hf_h248_transactionId64,
1567 { "transactionId", "h248.transactionId",
1568 FT_UINT64, BASE_DEC, NULL, 0,
1569 NULL, HFILL }},
1571 /* h248v1 support */
1572 { &hf_h248_auditValueReplyV1,
1573 { "auditValueReplyV1", "h248.auditValueReplyV1",
1574 FT_NONE, BASE_NONE, NULL, 0,
1575 NULL, HFILL }},
1577 #include "packet-h248-hfarr.c"
1579 GCP_HF_ARR_ELEMS("h248",h248_arrel)
1583 /* List of subtrees */
1584 static gint *ett[] = {
1585 &ett_h248,
1586 &ett_mtpaddress,
1587 &ett_packagename,
1588 &ett_codec,
1589 &ett_wildcard,
1590 &ett_h248_no_pkg,
1591 &ett_h248_no_sig,
1592 &ett_h248_no_evt,
1593 GCP_ETT_ARR_ELEMS(h248_arrel),
1595 #include "packet-h248-ettarr.c"
1598 static ei_register_info ei[] = {
1599 { &ei_h248_errored_command, { "h248.errored_command", PI_RESPONSE_CODE, PI_WARN, "Errored Command", EXPFILL }},
1600 { &ei_h248_transactionId64, { "h248.transactionId.error", PI_MALFORMED, PI_WARN, "Transaction ID invalid", EXPFILL }},
1601 { &ei_h248_context_id64, { "h248.contextId.error", PI_MALFORMED, PI_WARN, "Context ID invalid", EXPFILL }},
1604 expert_module_t* expert_h248;
1605 module_t *h248_module;
1607 /* Register protocol */
1608 proto_h248 = proto_register_protocol(PNAME, PSNAME, PFNAME);
1609 register_dissector("h248", dissect_h248, proto_h248);
1610 register_dissector("h248.tpkt", dissect_h248_tpkt, proto_h248);
1612 /* Register fields and subtrees */
1613 proto_register_field_array(proto_h248, hf, array_length(hf));
1614 proto_register_subtree_array(ett, array_length(ett));
1615 expert_h248 = expert_register_protocol(proto_h248);
1616 expert_register_field_array(expert_h248, ei, array_length(ei));
1618 subdissector_table = register_dissector_table("h248.magic_num", "H248 Magic Num", FT_UINT32, BASE_HEX);
1620 h248_module = prefs_register_protocol(proto_h248, proto_reg_handoff_h248);
1621 prefs_register_bool_preference(h248_module, "ctx_info",
1622 "Track Context",
1623 "Mantain relationships between transactions and contexts and display an extra tree showing context data",
1624 &keep_persistent_data);
1625 prefs_register_uint_preference(h248_module, "udp_port",
1626 "UDP port",
1627 "Port to be decoded as h248",
1629 &global_udp_port);
1630 prefs_register_uint_preference(h248_module, "tcp_port",
1631 "TCP port",
1632 "Port to be decoded as h248",
1634 &global_tcp_port);
1635 prefs_register_bool_preference(h248_module, "desegment",
1636 "Desegment H.248 over TCP",
1637 "Desegment H.248 messages that span more TCP segments",
1638 &h248_desegment);
1640 msgs = wmem_tree_new_autoreset(wmem_epan_scope(), wmem_file_scope());
1641 trxs = wmem_tree_new_autoreset(wmem_epan_scope(), wmem_file_scope());
1642 ctxs_by_trx = wmem_tree_new_autoreset(wmem_epan_scope(), wmem_file_scope());
1643 ctxs = wmem_tree_new_autoreset(wmem_epan_scope(), wmem_file_scope());
1645 h248_tap = register_tap("h248");
1647 gcp_init();
1650 /*--- proto_reg_handoff_h248 -------------------------------------------*/
1651 void proto_reg_handoff_h248(void) {
1653 static gboolean initialized = FALSE;
1654 static guint32 udp_port;
1655 static guint32 tcp_port;
1657 if (!initialized) {
1658 h248_handle = find_dissector("h248");
1659 h248_tpkt_handle = find_dissector("h248.tpkt");
1660 dissector_add_uint("mtp3.service_indicator", MTP_SI_GCP, h248_handle);
1661 h248_term_handle = find_dissector("h248term");
1662 initialized = TRUE;
1663 } else {
1664 if (udp_port != 0)
1665 dissector_delete_uint("udp.port", udp_port, h248_handle);
1667 if (tcp_port != 0)
1668 dissector_delete_uint("tcp.port", tcp_port, h248_tpkt_handle);
1671 udp_port = global_udp_port;
1672 tcp_port = global_tcp_port;
1674 if (udp_port != 0) {
1675 dissector_add_uint("udp.port", udp_port, h248_handle);
1678 if (tcp_port != 0) {
1679 dissector_add_uint("tcp.port", tcp_port, h248_tpkt_handle);