1 /* packet-h245_asn1.c
2  * Routines for h245 packet dissection
3  * Copyright 2004, Anders Broman <anders.broman@ericsson.com>
4  *
5  * Wireshark - Network traffic analyzer
6  * By Gerald Combs <gerald@wireshark.org>
7  * Copyright 1998 Gerald Combs
8  *
9  * SPDX-License-Identifier: GPL-2.0-or-later
10  *
11  * To quote the author of the previous H245 dissector:
12  *   "This is a complete replacement of the previous limitied dissector
13  * that Ronnie was crazy enough to write by hand. It was a lot of time
14  * to hack it by hand, but it is incomplete and buggy and it is good when
15  * it will go away."
16  * Ronnie did a great job and all the VoIP users had made good use of it!
17  * Credit to Tomas Kukosa for developing the asn2wrs compiler.
18  *
19  */
20 
21 #include "config.h"
22 
23 #include <epan/packet.h>
24 #include <epan/exceptions.h>
25 #include <epan/strutil.h>
26 #include <epan/addr_resolv.h>
27 #include <epan/prefs.h>
28 #include <epan/t35.h>
29 #include <epan/oids.h>
30 #include <epan/asn1.h>
31 #include <epan/tap.h>
32 #include <wsutil/pint.h>
33 #include "packet-tpkt.h"
34 #include "packet-per.h"
35 #include "packet-h323.h"
36 #include "packet-h245.h"
37 #include "packet-rtp.h"
38 #include "packet-rtcp.h"
39 #include "packet-t38.h"
40 
41 #define PNAME  "MULTIMEDIA-SYSTEM-CONTROL"
42 #define PSNAME "H.245"
43 #define PFNAME "h245"
44 
45 void proto_register_h245(void);
46 void proto_reg_handoff_h245(void);
47 
48 static dissector_handle_t rtcp_handle=NULL;
49 static dissector_table_t nsp_object_dissector_table;
50 static dissector_table_t nsp_h221_dissector_table;
51 static dissector_table_t gef_name_dissector_table;
52 static dissector_table_t gef_content_dissector_table;
53 static dissector_handle_t h245_handle;
54 static dissector_handle_t nsp_handle;
55 static dissector_handle_t data_handle;
56 static dissector_handle_t MultimediaSystemControlMessage_handle;
57 static dissector_handle_t h263_handle = NULL;
58 static dissector_handle_t amr_handle = NULL;
59 
60 static void init_h245_packet_info(h245_packet_info *pi);
61 static int hf_h245_pdu_type = -1;
62 static int hf_h245Manufacturer = -1;
63 static int hf_h245_subMessageIdentifier_standard = -1;
64 static int h245_tap = -1;
65 static int h245dg_tap = -1;
66 static int hf_h245_debug_dissector_try_string = -1;
67 
68 h245_packet_info *h245_pi=NULL;
69 
70 static gboolean h245_reassembly = TRUE;
71 static gboolean h245_shorttypes = FALSE;
72 static gboolean info_col_fmt_prepend = FALSE;
73 
74 #include "packet-h245-val.h"
75 
76 static const value_string h245_RequestMessage_short_vals[] = {
77 	{ RequestMessage_nonStandard              ,	"NSM" },
78 	{ RequestMessage_masterSlaveDetermination ,	"MSD" },
79 	{ RequestMessage_terminalCapabilitySet    ,	"TCS" },
80 	{ RequestMessage_openLogicalChannel       ,	"OLC" },
81 	{ RequestMessage_closeLogicalChannel      ,	"CLC" },
82 	{ RequestMessage_requestChannelClose      ,	"RCC" },
83 	{ RequestMessage_multiplexEntrySend       ,	"MES" },
84 	{ RequestMessage_requestMultiplexEntry    ,	"RME" },
85 	{ RequestMessage_requestMode              ,	"RM"  },
86 	{ RequestMessage_roundTripDelayRequest    ,	"RTDR" },
87 	{ RequestMessage_maintenanceLoopRequest   ,	"MLR" },
88 	{ RequestMessage_communicationModeRequest ,	"CMR" },
89 	{ RequestMessage_conferenceRequest        ,	"CR"  },
90 	{ RequestMessage_multilinkRequest         ,	"MR"  },
91 	{ RequestMessage_logicalChannelRateRequest,	"LCRR" },
92 	{ RequestMessage_genericRequest           ,	"GR"  },
93 	{  0, NULL }
94 };
95 static const value_string h245_ResponseMessage_short_vals[] = {
96 	{ ResponseMessage_nonStandard                   ,	"NSM" },
97 	{ ResponseMessage_masterSlaveDeterminationAck   ,	"MSDAck" },
98 	{ ResponseMessage_masterSlaveDeterminationReject,	"MSDReject" },
99 	{ ResponseMessage_terminalCapabilitySetAck      ,	"TCSAck" },
100 	{ ResponseMessage_terminalCapabilitySetReject   ,	"TCSReject" },
101 	{ ResponseMessage_openLogicalChannelAck         ,	"OLCAck" },
102 	{ ResponseMessage_openLogicalChannelReject      ,	"OLCReject" },
103 	{ ResponseMessage_closeLogicalChannelAck        ,	"CLCAck" },
104 	{ ResponseMessage_requestChannelCloseAck        ,	"RCCAck" },
105 	{ ResponseMessage_requestChannelCloseReject     ,	"RCCReject" },
106 	{ ResponseMessage_multiplexEntrySendAck         ,	"MESAck" },
107 	{ ResponseMessage_multiplexEntrySendReject      ,	"MESReject" },
108 	{ ResponseMessage_requestMultiplexEntryAck      ,	"RMEAck" },
109 	{ ResponseMessage_requestMultiplexEntryReject   ,	"RMEReject" },
110 	{ ResponseMessage_requestModeAck                ,	"RMAck" },
111 	{ ResponseMessage_requestModeReject             ,	"RMReject" },
112 	{ ResponseMessage_roundTripDelayResponse        ,	"RTDResponse" },
113 	{ ResponseMessage_maintenanceLoopAck            ,	"MLAck" },
114 	{ ResponseMessage_maintenanceLoopReject         ,	"MLReject" },
115 	{ ResponseMessage_communicationModeResponse     ,	"CMResponse" },
116 	{ ResponseMessage_conferenceResponse            ,	"CResponse" },
117 	{ ResponseMessage_multilinkResponse             ,	"MResponse" },
118 	{ ResponseMessage_logicalChannelRateAcknowledge ,	"LCRAck" },
119 	{ ResponseMessage_logicalChannelRateReject      ,	"LCRReject" },
120 	{ ResponseMessage_genericResponse               ,	"GR" },
121 	{  0, NULL }
122 };
123 static const value_string h245_IndicationMessage_short_vals[] = {
124 	{ IndicationMessage_nonStandard                             ,	"NSM" },
125 	{ IndicationMessage_functionNotUnderstood                   ,	"FNU" },
126 	{ IndicationMessage_masterSlaveDeterminationRelease         ,	"MSDRelease" },
127 	{ IndicationMessage_terminalCapabilitySetRelease            ,	"TCSRelease" },
128 	{ IndicationMessage_openLogicalChannelConfirm               ,	"OLCConfirm" },
129 	{ IndicationMessage_requestChannelCloseRelease              ,	"RCCRelease" },
130 	{ IndicationMessage_multiplexEntrySendRelease               ,	"MESRelease" },
131 	{ IndicationMessage_requestMultiplexEntryRelease            ,	"RMERelease" },
132 	{ IndicationMessage_requestModeRelease                      ,	"RMRelease" },
133 	{ IndicationMessage_miscellaneousIndication                 ,	"MI" },
134 	{ IndicationMessage_jitterIndication                        ,	"JI" },
135 	{ IndicationMessage_h223SkewIndication                      ,	"H223SI" },
136 	{ IndicationMessage_newATMVCIndication                      ,	"NATMVCI" },
137 	{ IndicationMessage_userInput                               ,	"UII" },
138 	{ IndicationMessage_h2250MaximumSkewIndication              ,	"H2250MSI" },
139 	{ IndicationMessage_mcLocationIndication                    ,	"MCLI" },
140 	{ IndicationMessage_conferenceIndication                    ,	"CI" },
141 	{ IndicationMessage_vendorIdentification                    ,	"VI" },
142 	{ IndicationMessage_functionNotSupported                    ,	"FNS" },
143 	{ IndicationMessage_multilinkIndication                     ,	"MultilinkIndication" },
144 	{ IndicationMessage_logicalChannelRateRelease               ,	"LCRRelease" },
145 	{ IndicationMessage_flowControlIndication                   ,	"FCIndication" },
146 	{ IndicationMessage_mobileMultilinkReconfigurationIndication,	"MMRI" },
147 	{ IndicationMessage_genericIndication                       ,	"GI" },
148 	{  0, NULL }
149 };
150 static const value_string h245_CommandMessage_short_vals[] = {
151 	{ CommandMessage_nonStandard                          ,	"NSM" },
152 	{ CommandMessage_maintenanceLoopOffCommand            ,	"MLOC" },
153 	{ CommandMessage_sendTerminalCapabilitySet            ,	"STCS" },
154 	{ CommandMessage_encryptionCommand                    ,	"EC" },
155 	{ CommandMessage_flowControlCommand                   ,	"FCC" },
156 	{ CommandMessage_endSessionCommand                    ,	"ESC" },
157 	{ CommandMessage_miscellaneousCommand                 ,	"MC" },
158 	{ CommandMessage_communicationModeCommand             ,	"CMC" },
159 	{ CommandMessage_conferenceCommand                    ,	"CC" },
160 	{ CommandMessage_h223MultiplexReconfiguration         ,	"H223MR" },
161 	{ CommandMessage_newATMVCCommand                      ,	"NATMVCC" },
162 	{ CommandMessage_mobileMultilinkReconfigurationCommand,	"MMRC" },
163 	{ CommandMessage_genericCommand                       ,	"GC" },
164 	{  0, NULL }
165 };
166 
167 static const value_string h245_AudioCapability_short_vals[] = {
168   { AudioCapability_nonStandard           , "nonStd" },
169   { AudioCapability_g711Alaw64k           , "g711A" },
170   { AudioCapability_g711Alaw56k           , "g711A56k" },
171   { AudioCapability_g711Ulaw64k           , "g711U" },
172   { AudioCapability_g711Ulaw56k           , "g711U56k" },
173   { AudioCapability_g722_64k              , "g722-64k" },
174   { AudioCapability_g722_56k              , "g722-56k" },
175   { AudioCapability_g722_48k              , "g722-48k" },
176   { AudioCapability_g7231                 , "g7231" },
177   { AudioCapability_g728                  , "g728" },
178   { AudioCapability_g729                  , "g729" },
179   { AudioCapability_g729AnnexA            , "g729A" },
180   { AudioCapability_is11172AudioCapability, "is11172" },
181   { AudioCapability_is13818AudioCapability, "is13818" },
182   { AudioCapability_g729wAnnexB           , "g729B" },
183   { AudioCapability_g729AnnexAwAnnexB     , "g729AB" },
184   { AudioCapability_g7231AnnexCCapability , "g7231C" },
185   { AudioCapability_gsmFullRate           , "gsmFR" },
186   { AudioCapability_gsmHalfRate           , "gsmHR" },
187   { AudioCapability_gsmEnhancedFullRate   , "gsmEFR" },
188   { AudioCapability_genericAudioCapability, "generic" },
189   { AudioCapability_g729Extensions        , "g729Ext" },
190   { AudioCapability_vbd                   , "vbd" },
191   { AudioCapability_audioTelephonyEvent   , "audioTelEvent" },
192   { AudioCapability_audioTone             , "audioTone" },
193   {  0, NULL }
194 };
195 
196 /* To put the codec type only in COL_INFO when
197    an OLC is read */
198 const char* codec_type = NULL;
199 static guint32 rfc_number;
200 
201 typedef struct _unicast_addr_t {
202   address addr;
203   guint8 addr_buf[16];
204   guint32 port;
205 } unicast_addr_t;
206 
207 typedef struct _channel_info_t {
208   gchar data_type_str[32];
209   unicast_addr_t *upcoming_addr;
210   unicast_addr_t media_addr;
211   unicast_addr_t media_control_addr;
212   unsigned int rfc2198;
213   gboolean srtp_flag;
214   gboolean is_video;
215 } channel_info_t;
216 
217 typedef struct _olc_info_t {
218   guint16 fwd_lc_num;
219   channel_info_t fwd_lc;
220   channel_info_t rev_lc;
221 } olc_info_t;
222 
223 static wmem_map_t* h245_pending_olc_reqs = NULL;
224 static gboolean fast_start = FALSE;
225 static olc_info_t *upcoming_olc = NULL;
226 static channel_info_t *upcoming_channel = NULL;
227 
228 /* NonStandardParameter */
229 static const char *nsiOID;
230 static guint32 h221NonStandard;
231 static guint32 t35CountryCode;
232 static guint32 t35Extension;
233 static guint32 manufacturerCode;
234 
235 static const value_string h245_RFC_number_vals[] = {
236 	{  2190,	"RFC 2190 - H.263 Video Streams" },
237 	{  2198,	"RFC 2198 - RTP Payload for Redundant Audio Data" },
238 	{  2429,	"RFC 2429 - 1998 Version of ITU-T Rec. H.263 Video (H.263+)" },
239 	{  3016,	"RFC 3016 - RTP Payload Format for MPEG-4 Audio/Visual Streams" },
240 	{  3267,	"RFC 3267 - Adaptive Multi-Rate (AMR) and Adaptive Multi-Rate Wideband (AMR-WB)" },
241 	{  3984,	"RFC 3984 - RTP Payload Format for H.264 Video" },
242 	{  0, NULL }
243 };
244 
245 /* Table 7/H.239 subMessageIdentifier values */
246 static const value_string h245_h239subMessageIdentifier_vals[] = {
247   {   1, "flowControlReleaseRequest" },
248   {   2, "flowControlReleaseResponse" },
249   {   3, "presentationTokenRequest" },
250   {   4, "presentationTokenResponse" },
251   {   5, "presentationTokenRelease" },
252   {   6, "presentationTokenIndicateOwner" },
253   { 0, NULL }
254 };
255 
256 
257 /* h223 multiplex codes */
258 static h223_set_mc_handle_t h223_set_mc_handle = NULL;
259 h223_mux_element *h223_me=NULL;
260 guint8 h223_mc=0;
h245_set_h223_set_mc_handle(h223_set_mc_handle_t handle)261 void h245_set_h223_set_mc_handle( h223_set_mc_handle_t handle )
262 {
263 	h223_set_mc_handle = handle;
264 }
265 
266 /* h223 logical channels */
267 typedef struct {
268 	h223_lc_params *fw_channel_params;
269 	h223_lc_params *rev_channel_params;
270 } h223_pending_olc;
271 
272 static wmem_map_t*          h223_pending_olc_reqs[] = { NULL, NULL };
273 static dissector_handle_t   h245_lc_dissector;
274 static guint16              h245_lc_temp;
275 static guint16              h223_fw_lc_num;
276 static guint16              h223_rev_lc_num;
277 static h223_lc_params      *h223_lc_params_temp;
278 static h223_lc_params      *h223_fw_lc_params;
279 static h223_lc_params      *h223_rev_lc_params;
280 static h223_add_lc_handle_t h223_add_lc_handle = NULL;
281 
h223_lc_init(void)282 static void h223_lc_init( void )
283 {
284 	h223_lc_params_temp = NULL;
285 	h245_lc_dissector = NULL;
286 	h223_fw_lc_num = 0;
287 }
288 
h245_set_h223_add_lc_handle(h223_add_lc_handle_t handle)289 void h245_set_h223_add_lc_handle( h223_add_lc_handle_t handle )
290 {
291 	h223_add_lc_handle = handle;
292 }
293 
gen_olc_key(guint16 lc_num,address * dst_addr,address * src_addr,wmem_allocator_t * scope)294 static const gchar *gen_olc_key(guint16 lc_num, address *dst_addr, address *src_addr, wmem_allocator_t *scope)
295 {
296   return wmem_strdup_printf(scope, "%s/%s/%u",
297           address_to_str(scope, dst_addr),
298           address_to_str(scope, src_addr),
299           lc_num);
300 }
301 
update_unicast_addr(unicast_addr_t * req_addr,unicast_addr_t * ack_addr)302 static void update_unicast_addr(unicast_addr_t *req_addr, unicast_addr_t *ack_addr)
303 {
304   if (ack_addr->addr.type!=AT_NONE && ack_addr->port!=0) {
305     memcpy(req_addr->addr_buf, ack_addr->addr_buf, sizeof(req_addr->addr_buf));
306     set_address(&req_addr->addr, ack_addr->addr.type, ack_addr->addr.len, req_addr->addr_buf);
307     req_addr->port = ack_addr->port;
308   }
309 }
310 
h245_setup_channels(packet_info * pinfo,channel_info_t * upcoming_channel_lcl)311 static void h245_setup_channels(packet_info *pinfo, channel_info_t *upcoming_channel_lcl)
312 {
313 	rtp_dyn_payload_t *rtp_dyn_payload = NULL;
314 	struct srtp_info *dummy_srtp_info = NULL;
315 
316 	if (!upcoming_channel_lcl) return;
317 
318 	/* T.38 */
319 	if (!strcmp(upcoming_channel_lcl->data_type_str, "t38fax")) {
320 		if (upcoming_channel_lcl->media_addr.addr.type!=AT_NONE && upcoming_channel_lcl->media_addr.port!=0) {
321 			t38_add_address(pinfo, &upcoming_channel_lcl->media_addr.addr,
322 							upcoming_channel_lcl->media_addr.port, 0,
323 							"H245", pinfo->num);
324 		}
325 		return;
326 	}
327 
328 	/* (S)RTP, (S)RTCP */
329 	if (upcoming_channel_lcl->rfc2198 > 0) {
330 		rtp_dyn_payload = rtp_dyn_payload_new();
331 		rtp_dyn_payload_insert(rtp_dyn_payload, upcoming_channel_lcl->rfc2198, "red", 8000);
332 	}
333 
334 	if (upcoming_channel_lcl->srtp_flag) {
335 		dummy_srtp_info = wmem_new0(wmem_file_scope(), struct srtp_info);
336 	}
337 
338 	/* DEBUG 	ws_warning("h245_setup_channels media_addr.addr.type %u port %u",upcoming_channel_lcl->media_addr.addr.type, upcoming_channel_lcl->media_addr.port );
339 	*/
340 	if (upcoming_channel_lcl->media_addr.addr.type!=AT_NONE && upcoming_channel_lcl->media_addr.port!=0) {
341 		srtp_add_address(pinfo, PT_UDP, &upcoming_channel_lcl->media_addr.addr,
342 						upcoming_channel_lcl->media_addr.port, 0,
343 						"H245", pinfo->num, upcoming_channel_lcl->is_video , rtp_dyn_payload, dummy_srtp_info, NULL);
344 	}
345 	if (upcoming_channel_lcl->media_control_addr.addr.type!=AT_NONE && upcoming_channel_lcl->media_control_addr.port!=0 && rtcp_handle) {
346 		srtcp_add_address(pinfo, &upcoming_channel_lcl->media_control_addr.addr,
347 						upcoming_channel_lcl->media_control_addr.port, 0,
348 						"H245", pinfo->num, dummy_srtp_info);
349 	}
350 }
351 
352 /* Prints formated information column of h245 messages. Note that global variables
353  * "h245_shorttypes" and "info_col_fmt_prepend" are used to decide formating preferences */
print_info_column(column_info * cinfo,const gint32 * value,const value_string * msg_vals,const value_string * short_msg_vals)354 static void print_info_column(column_info *cinfo, const gint32 *value,
355     const value_string *msg_vals, const value_string *short_msg_vals)
356 {
357   const value_string *vals;
358 
359   if (h245_shorttypes == FALSE || short_msg_vals == NULL) {
360     vals = msg_vals;
361   } else {
362     vals = short_msg_vals;
363   }
364 
365   if (info_col_fmt_prepend == FALSE) {
366     col_append_fstr(cinfo, COL_INFO, "%s ", val_to_str(*value, vals, "<unknown>"));
367   } else {
368     col_prepend_fstr(cinfo, COL_INFO, "%s ", val_to_str(*value, vals, "<unknown>"));
369   }
370 }
371 
372 /* Initialize the protocol and registered fields */
373 static int proto_h245 = -1;
374 #include "packet-h245-hf.c"
375 
376 /* Initialize the subtree pointers */
377 static int ett_h245 = -1;
378 static int ett_h245_returnedFunction = -1;
379 #include "packet-h245-ett.c"
380 
381 /* Forward declarations */
382 static int dissect_h245_MultimediaSystemControlMessage(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_);
reset_h245_pi(void * dummy _U_)383 static void reset_h245_pi(void *dummy _U_)
384 {
385 	h245_pi = NULL; /* Make sure we don't leave pinfo->pool memory lying around */
386 }
387 
388 #include "packet-h245-fn.c"
389 
390 static int
dissect_h245(tvbuff_t * tvb,packet_info * pinfo,proto_tree * parent_tree,void * data _U_)391 dissect_h245(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, void* data _U_)
392 {
393 	/*
394 	 * MultimediaSystemControlMessage_handle is the handle for
395 	 * dissect_h245_h245, so we don't want to do any h245_pi or tap stuff here.
396 	 */
397 	dissect_tpkt_encap(tvb, pinfo, parent_tree, h245_reassembly, MultimediaSystemControlMessage_handle);
398 	return tvb_captured_length(tvb);
399 }
400 
401 
402 static int
dissect_h245_h245(tvbuff_t * tvb,packet_info * pinfo,proto_tree * parent_tree,void * data _U_)403 dissect_h245_h245(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, void* data _U_)
404 {
405 	proto_item *it;
406 	proto_tree *tr;
407 	guint32 offset=0;
408 	asn1_ctx_t asn1_ctx;
409 
410 	fast_start = FALSE;
411 	/* Clean up from any previous packet dissection */
412 	upcoming_olc = NULL;
413 	upcoming_channel = NULL;
414 	codec_type = NULL;
415 
416 	col_set_str(pinfo->cinfo, COL_PROTOCOL, PSNAME);
417 
418 	it=proto_tree_add_protocol_format(parent_tree, proto_h245, tvb, 0, -1, PSNAME);
419 	tr=proto_item_add_subtree(it, ett_h245);
420 
421 	/* assume that whilst there is more tvb data, there are more h245 commands */
422 	while ( tvb_reported_length_remaining( tvb, offset>>3 )>0 ){
423 		CLEANUP_PUSH(reset_h245_pi, NULL);
424 		h245_pi=wmem_new(pinfo->pool, h245_packet_info);
425 		init_h245_packet_info(h245_pi);
426 		asn1_ctx_init(&asn1_ctx, ASN1_ENC_PER, TRUE, pinfo);
427 		offset = dissect_h245_MultimediaSystemControlMessage(tvb, offset, &asn1_ctx, tr, hf_h245_pdu_type);
428 		tap_queue_packet(h245dg_tap, pinfo, h245_pi);
429 		offset = (offset+0x07) & 0xfffffff8;
430 		CLEANUP_CALL_AND_POP;
431 	}
432 	return tvb_captured_length(tvb);
433 }
434 
435 void
dissect_h245_FastStart_OLC(tvbuff_t * tvb,packet_info * pinfo _U_,proto_tree * tree,char * codec_str)436 dissect_h245_FastStart_OLC(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, char *codec_str) {
437 
438   fast_start = TRUE;
439   /* Clean up from any previous packet dissection */
440   upcoming_olc = NULL;
441   upcoming_channel = NULL;
442   codec_type = NULL;
443 
444   dissect_OpenLogicalChannel_PDU(tvb, pinfo, tree, NULL);
445 
446   if (h245_pi != NULL)
447 	  h245_pi->msg_type = H245_OpenLogChn;
448 
449   if (codec_str && codec_type){
450         (void) g_strlcpy(codec_str, codec_type, 50);
451   }
452 
453 }
454 
455 /*--- proto_register_h245 -------------------------------------------*/
proto_register_h245(void)456 void proto_register_h245(void) {
457 
458   /* List of fields */
459   static hf_register_info hf[] = {
460     { &hf_h245_pdu_type,
461  { "PDU Type", "h245.pdu_type", FT_UINT32, BASE_DEC,
462 		VALS(h245_MultimediaSystemControlMessage_vals), 0, "Type of H.245 PDU", HFILL }},
463 	{ &hf_h245Manufacturer,
464 		{ "H.245 Manufacturer", "h245.Manufacturer", FT_UINT32, BASE_HEX,
465 		VALS(H221ManufacturerCode_vals), 0, "h245.H.221 Manufacturer", HFILL }},
466     { &hf_h245_subMessageIdentifier_standard,
467       { "subMessageIdentifier", "h245.subMessageIdentifier.standard",
468         FT_UINT32, BASE_DEC, VALS(h245_h239subMessageIdentifier_vals), 0,
469         NULL, HFILL }},
470   	{ &hf_h245_debug_dissector_try_string,
471       { "*** DEBUG dissector_try_string", "h245.debug.dissector_try_string", FT_STRING, BASE_NONE,
472         NULL, 0, NULL, HFILL }},
473 
474 #include "packet-h245-hfarr.c"
475   };
476 
477   /* List of subtrees */
478   static gint *ett[] = {
479 	  &ett_h245,
480 	  &ett_h245_returnedFunction,
481 #include "packet-h245-ettarr.c"
482   };
483   module_t *h245_module;
484 
485   /* Register protocol */
486   proto_h245 = proto_register_protocol(PNAME, PSNAME, PFNAME);
487   h223_pending_olc_reqs[P2P_DIR_SENT] = wmem_map_new_autoreset(wmem_epan_scope(), wmem_file_scope(), g_direct_hash, g_direct_equal );
488   h223_pending_olc_reqs[P2P_DIR_RECV] = wmem_map_new_autoreset(wmem_epan_scope(), wmem_file_scope(), g_direct_hash, g_direct_equal );
489   h245_pending_olc_reqs = wmem_map_new_autoreset(wmem_epan_scope(), wmem_file_scope(), wmem_str_hash, g_str_equal);
490 
491   register_init_routine(h223_lc_init);
492   /* Register fields and subtrees */
493   proto_register_field_array(proto_h245, hf, array_length(hf));
494   proto_register_subtree_array(ett, array_length(ett));
495 
496   /* From Ronnie Sahlbergs original H245 dissector */
497 
498   h245_module = prefs_register_protocol(proto_h245, NULL);
499   prefs_register_bool_preference(h245_module, "reassembly",
500 		"Reassemble H.245 messages spanning multiple TCP segments",
501 		"Whether the H.245 dissector should reassemble messages spanning multiple TCP segments."
502 		" To use this option, you must also enable \"Allow subdissectors to reassemble TCP streams\" in the TCP protocol settings.",
503 		&h245_reassembly);
504   prefs_register_bool_preference(h245_module, "shorttypes",
505 		"Show short message types",
506 		"Whether the dissector should show short names or the long names from the standard",
507 		&h245_shorttypes);
508   prefs_register_bool_preference(h245_module, "prepand",
509     "Show h245 info in reversed order",
510     "Whether the dissector should print items of h245 Info column in reversed order",
511     &info_col_fmt_prepend);
512   MultimediaSystemControlMessage_handle = register_dissector("h245dg", dissect_h245_h245, proto_h245);
513   h245_handle = register_dissector("h245", dissect_h245, proto_h245);
514 
515   nsp_object_dissector_table = register_dissector_table("h245.nsp.object", "H.245 NonStandardParameter (object)", proto_h245, FT_STRING, BASE_NONE);
516   nsp_h221_dissector_table = register_dissector_table("h245.nsp.h221", "H.245 NonStandardParameter (h221)", proto_h245, FT_UINT32, BASE_HEX);
517   gef_name_dissector_table = register_dissector_table("h245.gef.name", "H.245 Generic Extensible Framework Name", proto_h245, FT_STRING, BASE_NONE);
518   gef_content_dissector_table = register_dissector_table("h245.gef.content", "H.245 Generic Extensible Framework Content", proto_h245, FT_STRING, BASE_NONE);
519 
520   h245_tap = register_tap("h245");
521   h245dg_tap = register_tap("h245dg");
522 
523   oid_add_from_string("h239ControlCapability","0.0.8.239.1.1");
524   oid_add_from_string("h239ExtendedVideoCapability","0.0.8.239.1.2");
525   oid_add_from_string("generic-message","0.0.8.239.2");
526   oid_add_from_string("h245 version 3","0.0.8.245.0.3");
527   oid_add_from_string("h245 version 4","0.0.8.245.0.4");
528   oid_add_from_string("h245 version 5","0.0.8.245.0.5");
529   oid_add_from_string("h245 version 6","0.0.8.245.0.6");
530   oid_add_from_string("h245 version 7","0.0.8.245.0.7");
531   oid_add_from_string("h245 version 8","0.0.8.245.0.8");
532   oid_add_from_string("h245 version 9","0.0.8.245.0.9");
533   oid_add_from_string("h245 version 10","0.0.8.245.0.10");
534   oid_add_from_string("h245 version 11","0.0.8.245.0.11");
535   oid_add_from_string("h245 version 12","0.0.8.245.0.12");
536   oid_add_from_string("h245 version 13","0.0.8.245.0.13");
537   /* This capability is defined in Annex E. */
538   oid_add_from_string("ISO/IEC 14496-2 MPEG-4 video","0.0.8.245.1.0.0");
539   /* This capability is defined in Annex H. */
540   oid_add_from_string("ISO/IEC 14496-3 MPEG-4 audio","0.0.8.245.1.1.0");
541   /* This capability is defined in Annex I. */
542   oid_add_from_string("AMR","0.0.8.245.1.1.1");
543   /* This capability is defined in Annex J. */
544   oid_add_from_string("acelp","0.0.8.245.1.1.2");
545   /* This capability is defined in Annex K. */
546   oid_add_from_string("us1","0.0.8.245.1.1.3");
547   /* This capability is defined in Annex L. */
548   oid_add_from_string("is127evrc","0.0.8.245.1.1.4");
549   /* This capability is defined in Annex M. */
550   oid_add_from_string("ISO/IEC 13818-7","0.0.8.245.1.1.5");
551   /* This capability is defined in Annex N. */
552   oid_add_from_string("rfc3389","0.0.8.245.1.1.6");
553   /* This capability is defined in Annex O. */
554   oid_add_from_string("L-16","0.0.8.245.1.1.7");
555   /* This capability is defined in Annex P. */
556   oid_add_from_string("bounded-audio-stream","0.0.8.245.1.1.8");
557   /* This capability is defined in Annex R. */
558   oid_add_from_string("AMR-NB","0.0.8.245.1.1.9");
559   /* This capability is defined in Annex R. */
560   oid_add_from_string("AMR-WB","0.0.8.245.1.1.10");
561   /* This capability is defined in Annex S. */
562   oid_add_from_string("ilbc","0.0.8.245.1.1.11");
563 
564   oid_add_from_string("ISO/IEC 14496-1","0.0.8.245.1.2.0");
565   oid_add_from_string("Nx64","0.0.8.245.1.2.1");
566   oid_add_from_string("logical-channel-bit-ratemanagement","0.0.8.245.1.3.0");
567 
568   oid_add_from_string("h264 generic-capabilities","0.0.8.241.0.0.1");
569   oid_add_from_string("iPpacketization_h241AnnexA(single NAL unit mode)","0.0.8.241.0.0.0.0");
570   oid_add_from_string("iPpacketization_RFC3984NonInterleaved","0.0.8.241.0.0.0.1");
571   oid_add_from_string("iPpacketization_RFC3984Interleaved","0.0.8.241.0.0.0.2");
572 }
573 
574 
575 /*--- proto_reg_handoff_h245 ---------------------------------------*/
proto_reg_handoff_h245(void)576 void proto_reg_handoff_h245(void) {
577 	rtcp_handle = find_dissector("rtcp");
578 	data_handle = find_dissector("data");
579 	h263_handle = find_dissector("h263data");
580 	amr_handle = find_dissector("amr_if2_nb");
581 
582 
583 	dissector_add_for_decode_as_with_preference("tcp.port", h245_handle);
584 	dissector_add_for_decode_as_with_preference("udp.port", MultimediaSystemControlMessage_handle);
585 }
586 
init_h245_packet_info(h245_packet_info * pi)587 static void init_h245_packet_info(h245_packet_info *pi)
588 {
589         if(pi == NULL) {
590                 return;
591         }
592 
593         pi->msg_type = H245_OTHER;
594 		pi->frame_label[0] = '\0';
595 		g_snprintf(pi->comment, sizeof(pi->comment), "H245 ");
596 }
597 
598