HACK: 2nd try to match RowsetProperties
[wireshark-wip.git] / epan / dissectors / packet-ismacryp.c
blob157273faf1f9f28e572a5ecc8611043883c95457
1 /* packet-ismacryp.c
2 * ISMACryp 1.1 & 2.0 protocol as defined in ISMA Encryption and Authentication see http://www.isma.tv
4 * David Castleford, Orange Labs / France Telecom R&D
5 * March 2009
7 * $Id$
9 * Wireshark - Network traffic analyzer
10 * By Gerald Combs <gerald@wireshark.org>
11 * Copyright 1998 Gerald Combs
13 * This program is free software; you can redistribute it and/or
14 * modify it under the terms of the GNU General Public License
15 * as published by the Free Software Foundation; either version 2
16 * of the License, or (at your option) any later version.
18 * This program is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
23 * You should have received a copy of the GNU General Public License
24 * along with this program; if not, write to the Free Software
25 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
28 /* TODO: get ISMACryp parameters automatically from SDP info,
29 * if present (typically sent via SAP/SDP),
30 * rather than having manual insertion via preferences
31 * TODO: perhaps better check coherence of certain information?
33 #include "config.h"
35 #include <glib.h>
36 #include <epan/packet.h>
37 #include <epan/prefs.h>
39 /* keeps track of current position in buffer in terms of bit and byte offset */
40 typedef struct Toffset_struct
42 gint offset_bytes;
43 guint8 offset_bits;
45 } offset_struct;
47 static void dissect_ismacryp_common(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint ismacryp_version);
48 static offset_struct* dissect_auheader( tvbuff_t *tvb, offset_struct *poffset, packet_info *pinfo, proto_tree *tree, guint set_version );
49 void proto_reg_handoff_ismacryp(void);
50 static void add_bits(offset_struct* poffset, gint len_bits);
52 #define PROTO_TAG_ISMACRYP "ISMACRYP"
53 #define PROTO_TAG_ISMACRYP_11 "ISMACryp_11"
54 #define PROTO_TAG_ISMACRYP_20 "ISMACryp_20"
55 #define V11 11
56 #define V20 20
57 #define AAC_HBR_MODE 0
58 #define MPEG4_VIDEO_MODE 1
59 #define AVC_VIDEO_MODE 2
60 /* #define USERMODE 3 */
61 #define DEFAULT_SELECTIVE_ENCRYPTION TRUE
62 #define DEFAULT_SLICE_INDICATION FALSE
63 #define DEFAULT_PADDING_INDICATION FALSE
64 #define DEFAULT_IV_LENGTH 4
65 #define DEFAULT_DELTA_IV_LENGTH 0
66 #define DEFAULT_KEY_INDICATOR_LENGTH 0
67 #define DEFAULT_KEY_INDICATOR_PER_AU FALSE
68 #define AU_HEADERS_LENGTH_SIZE 2 /* size in bytes */
69 #define DEFAULT_AU_SIZE_LENGTH 0
70 #define DEFAULT_AU_INDEX_LENGTH 0
71 #define DEFAULT_AU_INDEX_DELTA_LENGTH 0
72 #define DEFAULT_CTS_DELTA_LENGTH 0
73 #define DEFAULT_DTS_DELTA_LENGTH 0
74 #define DEFAULT_RANDOM_ACCESS_INDICATION FALSE
75 #define DEFAULT_STREAM_STATE_INDICATION 0
77 /* Wireshark ID of the ISMACRYP protocol */
78 static int proto_ismacryp = -1;
80 /* parameters set in preferences */
81 static guint pref_dynamic_payload_type = 0; /* RTP dynamic payload type */
82 static guint pref_au_size_length = DEFAULT_AU_SIZE_LENGTH; /* default Au size length */
83 static guint pref_au_index_length = DEFAULT_AU_INDEX_LENGTH; /* default Au index length */
84 static guint pref_au_index_delta_length = DEFAULT_AU_INDEX_DELTA_LENGTH; /* default Au index delta length */
85 static guint pref_cts_delta_length = DEFAULT_CTS_DELTA_LENGTH; /* default CTS delta length */
86 static guint pref_dts_delta_length = DEFAULT_DTS_DELTA_LENGTH; /* default DTS delta length */
87 static gboolean pref_random_access_indication = DEFAULT_RANDOM_ACCESS_INDICATION; /* default random access indication */
88 static guint pref_stream_state_indication = DEFAULT_STREAM_STATE_INDICATION; /* default stream state indication */
89 static guint version_type = V11; /* default to ISMACryp 1.1 */
90 static guint mode = AVC_VIDEO_MODE; /* default codec mode */
91 static gboolean selective_encryption = DEFAULT_SELECTIVE_ENCRYPTION; /* default selective encryption flag */
92 static gboolean slice_indication = DEFAULT_SLICE_INDICATION; /* default slice indication */
93 static gboolean padding_indication = DEFAULT_PADDING_INDICATION; /* default padding indication */
94 static guint key_indicator_length = DEFAULT_KEY_INDICATOR_LENGTH; /* default key indicator length */
95 static gboolean key_indicator_per_au_flag = DEFAULT_KEY_INDICATOR_PER_AU; /* default key indicator per au */
96 static guint iv_length = DEFAULT_IV_LENGTH; /* default IV length */
97 static guint delta_iv_length = DEFAULT_DELTA_IV_LENGTH; /* default delta IV length */
98 static gboolean pref_user_mode = FALSE; /* preference user mode instead of RFC3640 mode? */
99 static gboolean override_flag = FALSE; /* override use of RTP payload type to deduce ISMACryp version */
101 /* */
103 static guint au_size_length = DEFAULT_AU_SIZE_LENGTH; /* default Au size length */
104 static guint au_index_length = DEFAULT_AU_INDEX_LENGTH; /* default Au index length */
105 static guint au_index_delta_length = DEFAULT_AU_INDEX_DELTA_LENGTH; /* default Au index delta length */
106 static guint cts_delta_length = DEFAULT_CTS_DELTA_LENGTH; /* default CTS delta length */
107 static guint dts_delta_length = DEFAULT_DTS_DELTA_LENGTH; /* default DTS delta length */
108 static gboolean random_access_indication = DEFAULT_RANDOM_ACCESS_INDICATION; /* default random access indication */
109 static guint stream_state_indication = DEFAULT_STREAM_STATE_INDICATION; /* default stream state indication */
110 static gboolean user_mode = FALSE; /* selected user mode instead of RFC3640 mode? */
112 /*static const value_string messagetypenames[] = {}; */
114 /* ismacryp Parameter Types */
115 /*static const value_string parametertypenames[] = {}; */
116 static const value_string modetypenames[] = {
117 { AAC_HBR_MODE, "aac-hbr" },
118 { MPEG4_VIDEO_MODE, "mpeg4-video" },
119 { AVC_VIDEO_MODE, "avc-video" },
120 { 0, NULL}
122 /* The following hf_* variables are used to hold the Wireshark IDs of
123 * our header fields; they are filled out when we call
124 * proto_register_field_array() in proto_register_ismacryp()
126 /** Kts attempt at defining the protocol */
127 /* static gint hf_ismacryp = -1; */
128 static gint hf_ismacryp_header = -1;
129 static gint hf_ismacryp_au_headers_length = -1;
130 /* static gint hf_ismacryp_header_length = -1; */
131 static gint hf_ismacryp_header_byte = -1;
132 /* static gint hf_ismacryp_version = -1; */
133 /* static gint hf_ismacryp_length = -1; */
134 /* static gint hf_ismacryp_message_type = -1; */
135 /* static gint hf_ismacryp_message_length = -1; */
136 static gint hf_ismacryp_message = -1;
137 /* static gint hf_ismacryp_parameter = -1; */
138 /* static gint hf_ismacryp_parameter_type = -1; */
139 /* static gint hf_ismacryp_parameter_length = -1; */
140 /* static gint hf_ismacryp_parameter_value = -1; */
141 static gint hf_ismacryp_iv = -1;
142 static gint hf_ismacryp_delta_iv = -1;
143 static gint hf_ismacryp_key_indicator = -1;
144 /* static gint hf_ismacryp_delta_iv_length = -1; */
145 static gint hf_ismacryp_au_size = -1;
146 static gint hf_ismacryp_au_index = -1;
147 static gint hf_ismacryp_au_index_delta = -1;
148 static gint hf_ismacryp_cts_delta = -1;
149 static gint hf_ismacryp_cts_flag = -1;
150 static gint hf_ismacryp_dts_flag = -1;
151 static gint hf_ismacryp_dts_delta = -1;
152 static gint hf_ismacryp_rap_flag = -1;
153 static gint hf_ismacryp_au_is_encrypted = -1;
154 static gint hf_ismacryp_slice_start = -1;
155 static gint hf_ismacryp_slice_end = -1;
156 static gint hf_ismacryp_padding_bitcount = -1;
157 static gint hf_ismacryp_padding = -1;
158 static gint hf_ismacryp_reserved_bits = -1;
159 static gint hf_ismacryp_unused_bits = -1;
160 static gint hf_ismacryp_stream_state = -1;
162 /* These are the ids of the subtrees that we may be creating */
163 static gint ett_ismacryp = -1;
164 static gint ett_ismacryp_header = -1;
165 static gint ett_ismacryp_header_byte = -1;
166 static gint ett_ismacryp_message = -1;
168 /* Informative tree structure is shown here:
169 * TREE -
170 * AU Headers Length (2 bytes) - total length of AU header(s)
171 * - HEADER1
172 * HEADER BYTE (if present - 1 byte)
173 * -AU_is_encrypted (1 bit)
174 * -Slice_start (1 bit)
175 * -Slice_end (1 bit)
176 * -Padding_bitcount (3 bits)
177 * -Reserved (2 bits)
178 * IV (variable length)
179 * Key Indicator (variable length)
180 * AU size (if present - variable length)
181 * AU index (if present - variable length)
182 * CTS delta (if present - variable length)
183 * DTS delta (if present - variable length)
184 * RAP flag (if present - 1 bit)
185 * Stream State Indication (if present - variable length)
186 * - HEADER2 if 2nd header present (depends on AU headers length)
187 * Header Byte (if present - 1 byte)
188 * -AU_is_encrypted (1 bit)
189 * -Slice_start (1 bit)
190 * -Slice_end (1 bit)
191 * -Padding_bitcount (3 bits)
192 * -Reserved (2 bits)
193 * IV (variable length)
194 * Key Indicator (variable length)
195 * AU size (if present - variable length)
196 * AU index delta(if present - variable length)
197 * CTS delta (if present - variable length)
198 * DTS delta (if present - variable length)
199 * RAP flag (if present - 1 bit)
200 * Stream State Indication (if present - variable length)
201 * - more HEADERS if present
202 * - MESSAGE
203 * encrypted AU
204 * End informative tree structure
207 /* Note that check coherence of total AU headers length and that calculated from size of parameters defined by default or preferences.
208 * These are found in SDP and vary e.g. between audio and video and depend on ISMACryp encoding parameters
209 * hence if these values are incorrect displayed values will be strange and can see errors
210 * this could be improved of course
213 /* dissect_ismacryp_v11 gets called if rtp_dyn_payload_type = "enc-mpeg4-generic" i.e. is set via SDP */
214 static void dissect_ismacryp_v11(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
216 /* display ISMACryp version */
217 col_set_str(pinfo->cinfo, COL_PROTOCOL, PROTO_TAG_ISMACRYP_11);
219 /* display RTP payload type */
220 col_set_str(pinfo->cinfo, COL_INFO, "(PT=enc-mpeg4-generic)");
222 dissect_ismacryp_common( tvb, pinfo, tree, V11);
225 /* dissect_ismacryp_v20 gets called if rtp_dyn_payload_type = "enc-isoff-generic" i.e. is set via SDP */
226 static void dissect_ismacryp_v20(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
228 /* display ISMACryp version */
229 col_set_str(pinfo->cinfo, COL_PROTOCOL, PROTO_TAG_ISMACRYP_20);
231 /* display RTP payload type */
232 col_set_str(pinfo->cinfo, COL_INFO, "(PT=enc-isoff-generic)");
234 dissect_ismacryp_common( tvb, pinfo, tree, V20);
237 static void dissect_ismacryp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
239 col_set_str(pinfo->cinfo, COL_INFO, "Manual version");
240 dissect_ismacryp_common( tvb, pinfo, tree, version_type); /* Unknown version type: Use preference */
243 static void dissect_ismacryp_common(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint ismacryp_version)
245 guint set_version; /* ISMACryp version used during dissection */
246 proto_item *ismacryp_item;
247 proto_tree *ismacryp_tree;
248 proto_tree *ismacryp_message_tree;
250 /* select and display ISMACryp version */
251 if ((ismacryp_version!=version_type) && override_flag){
252 /* override -> use manual preference setting */
253 col_append_str(pinfo->cinfo, COL_INFO, " Manual version");
254 set_version = version_type; /* set to preference value */
256 else {
257 set_version = ismacryp_version;
260 if (set_version == V11){
261 col_set_str(pinfo->cinfo, COL_PROTOCOL, PROTO_TAG_ISMACRYP_11);
262 /* display mode */
263 if (pref_user_mode == FALSE){
264 col_append_fstr(pinfo->cinfo, COL_INFO, ", %s",val_to_str_const(mode, modetypenames, "user mode"));
265 } else {
266 col_append_str(pinfo->cinfo, COL_INFO, ", user mode");
268 user_mode = pref_user_mode;
270 if (set_version == V20){
271 col_set_str(pinfo->cinfo, COL_PROTOCOL, PROTO_TAG_ISMACRYP_20);
272 user_mode = TRUE;
273 /* display mode */
274 col_append_str(pinfo->cinfo, COL_INFO, ", user mode");
276 /* select correct AU values depending on version & selected mode in preferences menu if not in user_mode */
277 if (user_mode == TRUE){ /* use values set in preference menu */
278 au_size_length = pref_au_size_length;
279 au_index_length = pref_au_index_length;
280 au_index_delta_length = pref_au_index_delta_length;
281 cts_delta_length = pref_cts_delta_length;
282 dts_delta_length = pref_dts_delta_length;
283 random_access_indication = pref_random_access_indication;
284 stream_state_indication = pref_stream_state_indication;
285 } /* end if user_mode == TRUE */
286 if (user_mode == FALSE){
287 switch (mode){
288 case AAC_HBR_MODE:
289 au_size_length = 13;
290 au_index_length = 3;
291 au_index_delta_length = 3;
292 cts_delta_length = 0;
293 dts_delta_length = 0;
294 random_access_indication = FALSE;
295 stream_state_indication = 0;
296 break;
297 case MPEG4_VIDEO_MODE:
298 au_size_length = 0;
299 au_index_length = 0;
300 au_index_delta_length = 0;
301 cts_delta_length = 0;
302 dts_delta_length = 22;
303 random_access_indication = TRUE;
304 stream_state_indication = 0;
305 break;
306 case AVC_VIDEO_MODE:
307 au_size_length = 0;
308 au_index_length = 0;
309 au_index_delta_length = 0;
310 cts_delta_length = 0;
311 dts_delta_length = 22;
312 random_access_indication = TRUE;
313 stream_state_indication = 0;
314 break;
315 default:
316 DISSECTOR_ASSERT_NOT_REACHED();
317 break;
318 } /* end switch */
319 } /* end if user_mode == FALSE */
321 /* navigate through buffer */
322 if (tree)
324 /* we are being asked for details */
326 guint16 au_headers_length = 0; /* total length of AU headers */
327 guint16 totalbits =0; /* keeps track of total number of AU header bits treated (used to determine end of AU headers) */
328 int deltabits = -1; /* keeps track of extra bits per AU header treated (used to determine end of AU heafers ) */
329 guint16 totalbit_offset = 0; /* total offset in bits*/
330 int nbpadding_bits = 0; /* number of padding bits*/
331 offset_struct s_offset;
332 offset_struct* poffset;
333 guint16 nbmessage_bytes = 0; /*nb of message data bytes */
334 s_offset.offset_bytes = 0; /* initialise byte offset */
335 s_offset.offset_bits = 0; /* initialise bit offset */
336 poffset = &s_offset;
338 ismacryp_item = proto_tree_add_item(tree, proto_ismacryp, tvb, 0, -1, ENC_NA);
339 ismacryp_tree = proto_item_add_subtree(ismacryp_item, ett_ismacryp);
340 proto_item_append_text(tree, ", %s", "ismacryp packet"); /* add text to tree */
342 /* ismacryp_tree analysis */
343 /* we are being asked for details */
344 /* get total length of AU headers (first 2 bytes) */
345 ismacryp_item = proto_tree_add_item(ismacryp_tree, hf_ismacryp_au_headers_length,
346 tvb, poffset->offset_bytes, AU_HEADERS_LENGTH_SIZE, ENC_BIG_ENDIAN );
347 proto_item_append_text(ismacryp_item, " (bits)"); /* add text to AU Header tree indicating length */
348 au_headers_length=tvb_get_ntohs(tvb,poffset->offset_bytes); /* 2 byte au headers length */
349 poffset->offset_bytes+=AU_HEADERS_LENGTH_SIZE;
350 /* ADD HEADER(S) BRANCH */
352 /* AU Header loop */
353 totalbits=(poffset->offset_bytes*8)+poffset->offset_bits;
354 while( ((totalbits-8*AU_HEADERS_LENGTH_SIZE)<au_headers_length) && deltabits!=0 ) /* subtract AU headers length bits*/
356 poffset=dissect_auheader( tvb, poffset, pinfo, ismacryp_tree, set_version);
357 deltabits=(poffset->offset_bytes*8)+poffset->offset_bits - totalbits; /* if zero this means no actual AU header so exit while loop */
358 totalbits+=deltabits;
360 /* reached end of AU Header(s) */
361 /* sanity check if actual total AU headers length in bits i.e. totalbits is */
362 /* the same as expected AU headers length from 2 bytes at start of buffer */
363 if ( (totalbits-8*AU_HEADERS_LENGTH_SIZE) != au_headers_length) /* something wrong */
365 proto_item_append_text(ismacryp_item,
366 " Error - expected total AU headers size (%d bits) "
367 "does not match calculated size (%d bits) - check parameters!",
368 au_headers_length,(totalbits-8*AU_HEADERS_LENGTH_SIZE));
370 /* add padding if need to byte align */
371 if (poffset->offset_bits!=0)
373 totalbit_offset = (poffset->offset_bytes)*8+poffset->offset_bits; /* offset in bits */
374 nbpadding_bits = (8-poffset->offset_bits); /* number of padding bits for byte alignment */
375 ismacryp_item = proto_tree_add_bits_item(ismacryp_tree, hf_ismacryp_padding,
376 tvb, totalbit_offset, nbpadding_bits , ENC_BIG_ENDIAN); /* padding bits */
377 proto_item_append_text(ismacryp_item, ": Length=%d bits",nbpadding_bits); /* add padding info */
378 add_bits(poffset, nbpadding_bits);
380 /* ADD MESSAGE BRANCH */
381 ismacryp_item = proto_tree_add_item( ismacryp_tree, hf_ismacryp_message,
382 tvb, poffset->offset_bytes, -1, ENC_NA );
383 ismacryp_message_tree = proto_item_add_subtree(ismacryp_item, ett_ismacryp_message);
384 proto_item_append_text(ismacryp_item, ", %s", "Encrypted data"); /* add text to Message tree */
385 nbmessage_bytes = tvb_reported_length_remaining(tvb, poffset->offset_bytes);
386 proto_item_append_text(ismacryp_item, ", Length= %d bytes", nbmessage_bytes ); /* add length of message */
388 /* ismacryp message tree analysis (encrypted AUs) */
389 if (ismacryp_message_tree)
390 { /* we are being asked for details */
391 poffset->offset_bytes+= nbmessage_bytes; /* */
392 } /* end message details */
393 /* end ismacryp tree details */
394 } /* end if tree */
396 /* AU Header dissection */
397 static offset_struct* dissect_auheader( tvbuff_t *tvb, offset_struct *poffset, packet_info *pinfo, proto_tree *ismacryp_tree, guint set_version )
399 proto_item *ismacryp_item;
400 proto_tree *ismacryp_header_tree;
401 proto_tree *ismacryp_header_byte_tree;
403 guint16 header_len_bytes = 0; /* total length of non-first AU header in bytes (rounded up) */
404 gint header_len = 0; /* length of AU headers in bits */
405 gint cts_flag =0;
406 gint dts_flag =0;
407 gboolean first_au_flag=FALSE;
408 gint bit_offset = 0;
410 /*first determine total AU header length */
411 /* calculate each AU header length in bits first */
412 switch (set_version) {
413 case V11:
414 if (selective_encryption)
415 header_len+=8; /* add one byte to header length */
416 break;
417 case V20:
418 if (selective_encryption || slice_indication || padding_indication)
419 header_len+=8; /* add one byte to header length */
420 break;
421 default:
422 DISSECTOR_ASSERT_NOT_REACHED();
423 break;
424 } /* end switch */
425 header_len+=au_size_length; /* add au size length */
427 if (poffset->offset_bytes==AU_HEADERS_LENGTH_SIZE){ /*first AU */
428 header_len+=8*(iv_length); /* add IV length */
429 header_len+=8*key_indicator_length; /* add key indicator length */
430 header_len+=au_index_length; /* add AU index length */
431 first_au_flag = TRUE;
433 else { /* not the first AU */
434 if (key_indicator_per_au_flag == TRUE)
435 header_len+=8*key_indicator_length; /* add key indicator length */
436 header_len+=8*(delta_iv_length); /* add delta IV length */
437 header_len+=au_index_delta_length; /* add AU delta index length */
439 /* CTS flag is present? */
440 if (cts_delta_length != 0){ /* need to test whether cts_delta_flag is TRUE or FALSE */
441 cts_flag=tvb_get_bits8(tvb, AU_HEADERS_LENGTH_SIZE*8+header_len, 1); /*fetch 1 bit CTS flag */
442 header_len+=1; /* add CTS flag bit */
443 if (cts_flag==1)
444 header_len+=cts_delta_length; /* add CTS delta length bits if CTS flag SET */
446 /* DTS flag is present? */
447 if (dts_delta_length != 0){ /* need to test whether dts_delta_flag is TRUE or FALSE */
448 dts_flag=tvb_get_bits8(tvb, AU_HEADERS_LENGTH_SIZE*8+header_len, 1); /*fetch 1 bit DTS flag */
449 header_len+=1; /* add DTS flag bit */
450 if (dts_flag==1)
451 header_len+=dts_delta_length; /* add DTS delta length bits if DTS flag SET */
453 /* RAP flag present? */
454 if (random_access_indication != FALSE)
455 header_len+=1; /* add 1 bit RAP flag */
457 /* stream state indication present */
458 if (stream_state_indication !=0)
459 header_len+=stream_state_indication; /* add stream state indication bits */
461 /* convert header_len to bytes (rounded up) */
462 if (header_len% 8!=0)
464 header_len_bytes=((header_len)/8)+1; /*add 1 */
466 else
467 header_len_bytes=((header_len)/8);
469 /* add AU header tree */
470 ismacryp_item = proto_tree_add_item(ismacryp_tree, hf_ismacryp_header, tvb, poffset->offset_bytes, header_len_bytes, ENC_NA );
471 proto_item_append_text(ismacryp_item, ": Length=%d bits", header_len); /* add text to Header tree indicating length */
472 /* sanity check if actual AU header length is zero bits, which indicates an error */
473 if ( header_len == 0) /* something wrong */
475 proto_item_append_text(ismacryp_item, " Error - zero bit AU header size - check parameters!");
477 ismacryp_header_tree = proto_item_add_subtree(ismacryp_item, ett_ismacryp_header);
479 /* ismacryp header analysis */
480 /* we are being asked for details */
482 /* Extra 1 Byte Header? */
484 if ((set_version==V20 && (selective_encryption || slice_indication || padding_indication))
485 || (set_version==V11 && selective_encryption)){
487 /* add header byte tree */
488 ismacryp_item = proto_tree_add_item(ismacryp_header_tree, hf_ismacryp_header_byte,
489 tvb, poffset->offset_bytes, 1, ENC_NA );
490 proto_item_append_text(ismacryp_item, ": Length=8 bits"); /* add text to Header byte tree indicating length */
491 ismacryp_header_byte_tree = proto_item_add_subtree(ismacryp_item, ett_ismacryp_header_byte);
493 /*ismacryp_header_byte_tree */
494 /* we are being asked for details */
495 /* tvb is network order, so get MSB bits first, so shift 8 bits and work "backwards" */
496 add_bits(poffset,7); /*shift 7 bits to get correct bit */
497 /* AU_is_encrypted bit */
498 bit_offset = (poffset->offset_bytes)*8+poffset->offset_bits; /* offset in bits */
499 if (selective_encryption){ /* bit used */
500 proto_tree_add_bits_item(ismacryp_header_byte_tree, hf_ismacryp_au_is_encrypted,
501 tvb, bit_offset, 1, ENC_BIG_ENDIAN); /*fetch 1 bit AU_is_encrypted */
503 else { /* bit unused */
504 proto_tree_add_bits_item(ismacryp_header_byte_tree, hf_ismacryp_unused_bits,
505 tvb, bit_offset, 1, ENC_BIG_ENDIAN); /*fetch 1 bit unused */
507 switch (set_version){ /* ISMACryp version? */
508 case V11:
509 /* Reserved bits */
510 add_bits(poffset, -7); /* move back 7 bits for reserved bits */
511 bit_offset = (poffset->offset_bytes)*8+poffset->offset_bits; /* offset in bits */
512 proto_tree_add_bits_item(ismacryp_header_byte_tree, hf_ismacryp_reserved_bits,
513 tvb, bit_offset, 7, ENC_BIG_ENDIAN); /*fetch 7 bits reserved */
514 add_bits(poffset,8); /* offset to next byte */
515 break;
516 case V20:
517 /* Slice_start bit */
518 add_bits(poffset, -1); /* move back 1 bit for slice_start */
519 bit_offset = (poffset->offset_bytes)*8+poffset->offset_bits; /* offset in bits */
520 if (slice_indication){
521 proto_tree_add_bits_item(ismacryp_header_byte_tree, hf_ismacryp_slice_start,
522 tvb, bit_offset, 1, ENC_BIG_ENDIAN); /*fetch 1 bit slice_start */
524 else { /* bit unused */
525 proto_tree_add_bits_item(ismacryp_header_byte_tree, hf_ismacryp_unused_bits,
526 tvb, bit_offset, 1, ENC_BIG_ENDIAN); /*fetch 1 bit unused */
528 add_bits(poffset, -1); /* move back 1 bit for slice_end */
530 /* Slice_end bit */
531 bit_offset = (poffset->offset_bytes)*8+poffset->offset_bits; /* offset in bits */
532 if (slice_indication){
533 proto_tree_add_bits_item(ismacryp_header_byte_tree, hf_ismacryp_slice_end,
534 tvb, bit_offset, 1, ENC_BIG_ENDIAN); /*fetch 1 bit Slice_end */
536 else { /* bit unused */
537 proto_tree_add_bits_item(ismacryp_header_byte_tree, hf_ismacryp_unused_bits,
538 tvb, bit_offset, 1, ENC_BIG_ENDIAN); /*fetch 1 bit unused */
540 add_bits(poffset, -3); /* move back 3 bits for padding_bitcount */
542 /* Padding_bitcount bits */
543 bit_offset = (poffset->offset_bytes)*8+poffset->offset_bits; /* offset in bits */
544 if (padding_indication){
545 proto_tree_add_bits_item(ismacryp_header_byte_tree, hf_ismacryp_padding_bitcount,
546 tvb, bit_offset, 3, ENC_BIG_ENDIAN); /*fetch 3 bits padding_bitcount */
548 else { /* bits unused */
549 proto_tree_add_bits_item(ismacryp_header_byte_tree, hf_ismacryp_unused_bits,
550 tvb, bit_offset, 3, ENC_BIG_ENDIAN); /*fetch 3 bits unused */
552 add_bits(poffset, -2); /* move back 2 bits for reserved bits */
554 /* Reserved bits */
555 bit_offset = (poffset->offset_bytes)*8+poffset->offset_bits; /* offset in bits */
556 proto_tree_add_bits_item(ismacryp_header_byte_tree, hf_ismacryp_reserved_bits,
557 tvb, bit_offset, 2, ENC_BIG_ENDIAN); /*fetch 2 bits reserved */
558 add_bits(poffset,8); /* offset to next byte */
559 break;
560 default:
561 DISSECTOR_ASSERT_NOT_REACHED();
562 break;
563 } /* end switch set_version */
564 } /* end selective encryption */
565 /* IV */
566 if (first_au_flag == TRUE && iv_length != 0)
568 ismacryp_item = proto_tree_add_item(ismacryp_header_tree, hf_ismacryp_iv, tvb, poffset->offset_bytes, iv_length, ENC_NA);
569 proto_item_append_text(ismacryp_item, ": Length=%d bytes",iv_length); /* add IV info */
570 col_append_fstr( pinfo->cinfo, COL_INFO,
571 ", IV=0x%s", tvb_bytes_to_str_punct(tvb, poffset->offset_bytes, iv_length,' '));
573 poffset->offset_bytes+=iv_length; /* add IV length to offset_bytes */
575 /*Delta IV */
576 if (first_au_flag == FALSE && delta_iv_length != 0)
578 ismacryp_item = proto_tree_add_item(ismacryp_header_tree, hf_ismacryp_delta_iv,
579 tvb, poffset->offset_bytes, delta_iv_length, ENC_NA);
580 proto_item_append_text(ismacryp_item, ": Length=%d bytes",delta_iv_length); /* add delta IV info */
581 col_append_fstr( pinfo->cinfo, COL_INFO,
582 ", Delta IV=0x%s", tvb_bytes_to_str_punct(tvb, poffset->offset_bytes, delta_iv_length,' '));
583 poffset->offset_bytes+=iv_length; /* add IV length to offset_bytes */
585 /* Key Indicator */
586 if ( key_indicator_length != 0 && ( first_au_flag == TRUE || key_indicator_per_au_flag == TRUE) )
588 /* (first AU or KI for each AU) and non-zero KeyIndicator size */
589 ismacryp_item = proto_tree_add_item(ismacryp_header_tree, hf_ismacryp_key_indicator,
590 tvb, poffset->offset_bytes, key_indicator_length, ENC_NA);
591 proto_item_append_text(ismacryp_item,": Length=%d bytes",key_indicator_length); /* add KI info */
592 col_append_fstr( pinfo->cinfo, COL_INFO,
593 ", KI=0x%s", tvb_bytes_to_str_punct(tvb, poffset->offset_bytes, key_indicator_length,' '));
594 poffset->offset_bytes+=key_indicator_length; /* add KI length to offset_bytes */
596 /* AU size */
597 if (au_size_length != 0) /* in bits */
599 bit_offset = (poffset->offset_bytes)*8+poffset->offset_bits; /* offset in bits */
600 ismacryp_item = proto_tree_add_bits_item(ismacryp_header_tree,hf_ismacryp_au_size,
601 tvb, bit_offset, au_size_length, ENC_BIG_ENDIAN);
602 proto_item_append_text(ismacryp_item, " bytes: Length=%d bits",au_size_length); /* add AU size info */
603 /*bit_offset+=au_size_length;*/
604 add_bits(poffset, au_size_length);
606 /* AU Index */
607 if (first_au_flag == TRUE && au_index_length != 0) /* first AU and non-zero AU size */
609 bit_offset = (poffset->offset_bytes)*8+poffset->offset_bits; /* offset in bits */
610 ismacryp_item = proto_tree_add_bits_item(ismacryp_header_tree,hf_ismacryp_au_index,
611 tvb, bit_offset, au_index_length, ENC_BIG_ENDIAN);
612 proto_item_append_text(ismacryp_item, " bits: Length=%d bits",au_index_length); /* add AU index info */
613 /*bit_offset+=au_index_length;*/
614 add_bits(poffset, au_index_length);
616 /* AU index delta */
617 if (first_au_flag == FALSE && au_index_delta_length != 0) /* not first AU and non-zero AU delta size */
619 bit_offset = (poffset->offset_bytes)*8+poffset->offset_bits; /* offset in bits */
620 ismacryp_item = proto_tree_add_bits_item(ismacryp_header_tree,hf_ismacryp_au_index_delta,
621 tvb, bit_offset, au_index_delta_length, ENC_BIG_ENDIAN);
622 proto_item_append_text(ismacryp_item, ": Length=%d bits", au_index_delta_length); /* add AU index info */
623 /*bit_offset+=au_index_delta_length;*/
624 add_bits(poffset, au_index_delta_length);
626 /* CTS delta value */
627 if (cts_delta_length != 0)
629 bit_offset = (poffset->offset_bytes)*8+poffset->offset_bits; /* offset in bits */
630 proto_tree_add_bits_item(ismacryp_header_tree, hf_ismacryp_cts_flag,
631 tvb, bit_offset, 1, ENC_BIG_ENDIAN); /* read CTS flag */
632 add_bits(poffset, 1);
633 if (cts_flag==1)
635 /* now fetch CTS delta value (remember offset 1 bit due to CTS flag) */
636 bit_offset = (poffset->offset_bytes)*8+poffset->offset_bits; /* offset in bits */
637 ismacryp_item = proto_tree_add_bits_item(ismacryp_header_tree, hf_ismacryp_cts_delta,
638 tvb, bit_offset, cts_delta_length, ENC_BIG_ENDIAN); /* read CTS delta value */
639 proto_item_append_text(ismacryp_item, ": Length=%d bits",cts_delta_length); /* add CTS delta info */
640 add_bits(poffset, cts_delta_length);
643 /* DTS delta value */
644 if (dts_delta_length != 0)
646 bit_offset = (poffset->offset_bytes)*8+poffset->offset_bits; /* offset in bits */
647 proto_tree_add_bits_item(ismacryp_header_tree, hf_ismacryp_dts_flag,
648 tvb, bit_offset, 1, ENC_BIG_ENDIAN); /* read DTS flag */
649 add_bits(poffset, 1);
651 /* now fetch DTS delta value (remember offset x bits due to DTS flag) */
652 if (dts_flag ==1)
654 bit_offset = (poffset->offset_bytes)*8+poffset->offset_bits; /* offset in bits */
655 ismacryp_item = proto_tree_add_bits_item(ismacryp_header_tree, hf_ismacryp_dts_delta,
656 tvb, bit_offset, dts_delta_length, ENC_BIG_ENDIAN); /* read DTS delta value */
657 proto_item_append_text(ismacryp_item, ": Length=%d bits",dts_delta_length); /* add DTS delta info */
658 add_bits(poffset, dts_delta_length);
661 /* RAP */
662 if (random_access_indication != FALSE)
664 bit_offset = (poffset->offset_bytes)*8+poffset->offset_bits; /* offset in bits */
665 proto_tree_add_bits_item(ismacryp_header_tree, hf_ismacryp_rap_flag,
666 tvb, bit_offset, 1, ENC_BIG_ENDIAN); /* read RAP flag */
667 add_bits(poffset, 1);
669 /*STREAM STATE */
670 if (stream_state_indication != 0)
672 bit_offset = (poffset->offset_bytes)*8+poffset->offset_bits; /* offset in bits */
673 proto_tree_add_bits_item(ismacryp_header_tree, hf_ismacryp_stream_state,
674 tvb, bit_offset, stream_state_indication, ENC_BIG_ENDIAN); /* read stream state */
675 add_bits(poffset, stream_state_indication);
677 /* end header details */
678 return poffset;
681 /* add len_bits to offset bits and bytes, handling bits overflow */
682 static void add_bits(offset_struct* poffset, gint len_bits)
684 gint nbbitstotal=0;
685 nbbitstotal=poffset->offset_bytes*8+(poffset->offset_bits)+len_bits; /* total offset in bits */
686 /* now calculate bytes and bit offsets */
687 poffset->offset_bytes=(nbbitstotal / 8); /* add integer no. of bytes */
688 poffset->offset_bits=(nbbitstotal % 8); /* add remaining bits */
691 void proto_register_ismacryp (void)
693 /* A header field is something you can search/filter on.
695 * We create a structure to register our fields. It consists of an
696 * array of hf_register_info structures, each of which are of the format
697 * {&(field id), {name, abbrev, type, display, strings, bitmask, blurb, HFILL}}.
699 static hf_register_info hf[] = {
700 #if 0
701 { &hf_ismacryp,
702 { "Data", "ismacryp.data", FT_NONE, BASE_NONE, NULL, 0x0,
703 NULL, HFILL }},
704 #endif
706 #if 0
707 { &hf_ismacryp_length,
708 { "Total Length", "ismacryp.len", FT_UINT16, BASE_DEC, NULL, 0x0, /* length 2 bytes, print as decimal value */
709 NULL, HFILL }},
710 #endif
712 { &hf_ismacryp_header,
713 { "AU Header", "ismacryp.header", FT_NONE, BASE_NONE, NULL, 0x0,
714 NULL, HFILL }},
716 #if 0
717 { &hf_ismacryp_header_length,
718 { "Header Length", "ismacryp.header.length", FT_UINT16, BASE_DEC, NULL, 0x0,
719 NULL, HFILL }},
720 #endif
722 { &hf_ismacryp_au_headers_length,
723 { "AU Headers Length", "ismacryp.au_headers.length", FT_UINT16, BASE_DEC, NULL, 0x0,
724 NULL, HFILL }},
726 { &hf_ismacryp_header_byte,
727 { "Header Byte", "ismacryp.header.byte", FT_NONE, BASE_NONE, NULL, 0x0, /* 1 byte */
728 NULL, HFILL }},
730 #if 0
731 { &hf_ismacryp_version,
732 { "Version", "ismacryp.version", FT_UINT8, BASE_HEX, NULL, 0x0, /* version 1 byte */
733 NULL, HFILL }},
734 #endif
736 { &hf_ismacryp_message,
737 { "Message", "ismacryp.message", FT_NONE, BASE_NONE, NULL, 0x0,
738 NULL, HFILL }},
740 #if 0
741 { &hf_ismacryp_message_length,
742 { "Message Length", "ismacryp.message.len", FT_UINT16, BASE_DEC, NULL, 0x0, /* length 2 bytes, print as decimal value */
743 NULL, HFILL }},
744 #endif
746 #if 0
747 { &hf_ismacryp_parameter,
748 { "Parameter", "ismacryp.parameter", FT_NONE, BASE_NONE, NULL, 0x0,
749 NULL, HFILL }},
750 #endif
752 #if 0
753 { &hf_ismacryp_parameter_length,
754 { "Parameter Length", "ismacryp.parameter.len", FT_UINT16, BASE_DEC, NULL, 0x0, /* length 2 bytes, print as decimal value */
755 NULL, HFILL }},
756 #endif
758 { &hf_ismacryp_iv,
759 { "IV", "ismacryp.iv", FT_BYTES, BASE_NONE, NULL, 0x0, /* variable length */
760 NULL, HFILL }},
762 { &hf_ismacryp_delta_iv,
763 { "Delta IV", "ismacryp.delta_iv", FT_BYTES, BASE_NONE, NULL, 0x0, /* variable length */
764 NULL, HFILL }},
766 { &hf_ismacryp_key_indicator,
767 { "Key Indicator", "ismacryp.key_indicator", FT_BYTES, BASE_NONE, NULL, 0x0, /* variable length */
768 NULL, HFILL }},
770 #if 0
771 { &hf_ismacryp_parameter_value,
772 { "Parameter Value", "ismacryp.parameter.value", FT_NONE, BASE_NONE, NULL, 0x0,
773 NULL, HFILL }},
774 #endif
776 { &hf_ismacryp_au_size,
777 { "AU size", "ismacryp.au.size", FT_UINT64, BASE_DEC, NULL, 0x0,
778 NULL, HFILL }},
780 { &hf_ismacryp_au_index,
781 { "AU index", "ismacryp.au.index", FT_UINT64, BASE_DEC, NULL, 0x0,
782 NULL, HFILL }},
784 { &hf_ismacryp_au_index_delta,
785 { "AU index delta", "ismacryp.au.index_delta", FT_UINT64, BASE_DEC, NULL, 0x0,
786 NULL, HFILL }},
788 { &hf_ismacryp_cts_delta,
789 { "CTS delta", "ismacryp.cts_delta", FT_BOOLEAN, BASE_NONE, NULL, 0x0,
790 NULL, HFILL }},
792 { &hf_ismacryp_cts_flag,
793 { "CTS flag", "ismacryp.cts_flag", FT_BOOLEAN, BASE_NONE, NULL, 0x0,
794 NULL, HFILL }},
796 { &hf_ismacryp_dts_delta,
797 { "DTS delta", "ismacryp.dts_delta", FT_BOOLEAN, BASE_NONE, NULL, 0x0,
798 NULL, HFILL }},
800 { &hf_ismacryp_dts_flag,
801 { "DTS flag", "ismacryp.dts_flag", FT_BOOLEAN, BASE_NONE, NULL, 0x0,
802 NULL, HFILL }},
804 { &hf_ismacryp_rap_flag,
805 { "RAP flag", "ismacryp.rap_flag", FT_BOOLEAN, BASE_NONE, NULL, 0x0,
806 NULL, HFILL }},
808 { &hf_ismacryp_stream_state,
809 { "Stream state", "ismacryp.stream_state", FT_BOOLEAN, BASE_NONE, NULL, 0x0,
810 NULL, HFILL }},
812 { &hf_ismacryp_au_is_encrypted,
813 { "AU_is_encrypted flag", "ismacryp.au_is_encrypted", FT_BOOLEAN, BASE_NONE, NULL, 0x0,
814 NULL, HFILL }},
816 { &hf_ismacryp_slice_start,
817 { "Slice_start flag", "ismacryp.slice_start", FT_BOOLEAN, BASE_NONE, NULL, 0x0,
818 NULL, HFILL }},
820 { &hf_ismacryp_slice_end,
821 { "Slice_end flag", "ismacryp.slice_end", FT_BOOLEAN, BASE_NONE, NULL, 0x0,
822 NULL, HFILL }},
824 { &hf_ismacryp_padding_bitcount,
825 { "Padding_bitcount bits", "ismacryp.padding_bitcount", FT_BOOLEAN, BASE_NONE, NULL, 0x0,
826 NULL, HFILL }},
828 { &hf_ismacryp_padding,
829 { "Padding bits", "ismacryp.padding", FT_BOOLEAN, BASE_NONE, NULL, 0x0,
830 NULL, HFILL }},
832 { &hf_ismacryp_reserved_bits,
833 { "Reserved bits", "ismacryp.reserved", FT_BOOLEAN, BASE_NONE, NULL, 0x0,
834 NULL, HFILL }},
836 { &hf_ismacryp_unused_bits,
837 { "Unused bits", "ismacryp.unused", FT_BOOLEAN, BASE_NONE, NULL, 0x0,
838 NULL, HFILL }}
841 static gint *ett[] =
843 &ett_ismacryp,
844 &ett_ismacryp_header,
845 &ett_ismacryp_header_byte,
846 &ett_ismacryp_message
849 static const enum_val_t version_types[] = {
850 {PROTO_TAG_ISMACRYP_11, "ISMACryp v1.1", V11},
851 {PROTO_TAG_ISMACRYP_20, "ISMACryp v2.0", V20},
852 {NULL, NULL, -1}
855 static const enum_val_t mode_types[] = {
856 {"aac-hbr", "aac-hbr", AAC_HBR_MODE},
857 {"mpeg4-video", "mpeg4-video", MPEG4_VIDEO_MODE},
858 {"avc-video", "avc-video", AVC_VIDEO_MODE},
859 {NULL, NULL, -1}
862 module_t *ismacryp_module;
864 proto_ismacryp = proto_register_protocol ("ISMACryp Protocol", "ISMACRYP", "ismacryp");
865 proto_register_field_array (proto_ismacryp, hf, array_length (hf));
866 proto_register_subtree_array (ett, array_length (ett));
868 /* Register our configuration options for ismacryp */
869 /* this registers our preferences, function proto_reg_handoff_ismacryp is called when preferences are applied */
870 ismacryp_module = prefs_register_protocol(proto_ismacryp, proto_reg_handoff_ismacryp);
872 prefs_register_uint_preference(ismacryp_module, "dynamic.payload.type",
873 "ISMACryp dynamic payload type",
874 "The dynamic payload type which will be interpreted as ISMACryp",
876 &pref_dynamic_payload_type);
878 prefs_register_enum_preference(ismacryp_module, "version",
879 "ISMACryp version",
880 "ISMACryp version",
881 &version_type, version_types, TRUE);
883 prefs_register_static_text_preference(ismacryp_module, "text_override",
884 "The following option allows the version to be set manually"
885 " and to override the version if detected from RTP payload type:",
886 "The following option allows the version to be set manually"
887 " and to override the version if detected from RTP payload type:");
889 prefs_register_bool_preference(ismacryp_module,
890 "override_rtp_pt","Override RTP payload type for version",
891 "Indicates whether or not the ISMACryp version deduced"
892 " from RTP payload type, if present, is used or whether the"
893 " version above is used",
894 &override_flag);
896 /* ISMACryp v11 parameters */
897 prefs_register_static_text_preference(ismacryp_module,
898 "v11_parameters",
899 "ISMACryp v1.1 parameters:",
900 "ISMACryp v1.1 parameters declared in SDP");
902 prefs_register_uint_preference(ismacryp_module,
903 "iv_length","ISMACrypIVLength (bytes)",
904 "Set the length of the IV in the ISMACryp AU Header in bytes",
905 10, &iv_length);
907 prefs_register_uint_preference(ismacryp_module,
908 "delta_iv_length","ISMACrypDeltaIVLength (bytes)",
909 "Set the length of the Delta IV in the ISMACryp AU Header in bytes",
910 10, &delta_iv_length);
912 prefs_register_uint_preference(ismacryp_module,
913 "key_indicator_length","ISMACrypKeyIndicatorLength (bytes)",
914 "Set the length of the Key Indicator in the ISMACryp AU Header in bytes",
915 10, &key_indicator_length);
917 prefs_register_bool_preference(ismacryp_module,
918 "key_indicator_per_au_flag","ISMACrypKeyIndicatorPerAU (T/F)",
919 "Indicates whether or not the Key Indicator is present in all AU Headers (T/F)",
920 &key_indicator_per_au_flag);
922 prefs_register_bool_preference(ismacryp_module,
923 "selective_encryption","ISMACrypSelectiveEncryption (T/F)",
924 "Indicates whether or not selective encryption is enabled (T/F)",
925 &selective_encryption);
927 /* ISMACryp v20 parameters */
928 prefs_register_static_text_preference(ismacryp_module,
929 "v20_parameters",
930 "ISMACryp v2.0 parameters:",
931 "ISMACryp v2.0 parameters declared in SDP");
933 prefs_register_bool_preference(ismacryp_module,
934 "slice_indication","ISMACrypSliceIndication (T/F)",
935 "Indicates whether or not slice start / end is present (T/F)",
936 &slice_indication);
938 prefs_register_bool_preference(ismacryp_module,
939 "padding_indication","ISMACrypPaddingIndication (T/F)",
940 "Indicates whether or not padding information is present (T/F)",
941 &padding_indication);
943 /* RFC3640 mode - ISMACryp v11 */
944 prefs_register_static_text_preference(ismacryp_module,
945 "codec_modes",
946 "Codec mode selection (RFC3640 for ISMACryp v1.1 only):",
947 "AU parameters set according to RFC3640 mode or user defined");
949 prefs_register_enum_preference(ismacryp_module,
950 "rfc3640_mode",
951 "RFC3640 mode",
952 "RFC3640 mode",
953 &mode, mode_types, TRUE);
955 /* User defined mode */
956 prefs_register_bool_preference(ismacryp_module,
957 "user_mode","User mode (T/F)",
958 "Indicates use of user mode instead of RFC3640 modes (T/F)",
959 &pref_user_mode);
961 /* following preference values only used if user mode is selected above */
962 prefs_register_static_text_preference(ismacryp_module,
963 "user_defined_modes",
964 "Following parameters only valid and used for user mode:",
965 "AU parameters defined by the user");
967 /* ideally would grey this out or disable this if in user mode */
968 prefs_register_uint_preference(ismacryp_module,
969 "au_size_length","User mode: SizeLength (bits)",
970 "Set the length of the AU size in the AU Header in bits",
971 10, &pref_au_size_length);
973 prefs_register_uint_preference(ismacryp_module,
974 "au_index_length","User mode: IndexLength (bits)",
975 "Set the length of the AU index in the AU Header in bits",
976 10, &pref_au_index_length);
978 prefs_register_uint_preference(ismacryp_module,
979 "au_index_delta_length","User mode: IndexDeltaLength (bits)",
980 "Set the length of the AU delta index in the AU Header in bits",
981 10, &pref_au_index_delta_length);
983 prefs_register_uint_preference(ismacryp_module,
984 "cts_delta_length","User mode: CTSDeltaLength (bits)",
985 "Set the length of the CTS delta field in the AU Header in bits",
986 10, &pref_cts_delta_length);
988 prefs_register_uint_preference(ismacryp_module,
989 "dts_delta_length","User mode: DTSDeltaLength (bits)",
990 "Set the length of the DTS delta field in the AU Header in bits",
991 10, &pref_dts_delta_length);
993 prefs_register_bool_preference(ismacryp_module,
994 "random_access_indication","User mode: RandomAccessIndication (T/F)",
995 "Indicates whether or not the RAP field is present in the AU Header (T/F)",
996 &pref_random_access_indication);
998 prefs_register_uint_preference(ismacryp_module,
999 "stream_state_indication","User mode: StreamStateIndication (number of bits)",
1000 "Indicates the number of bits on which the stream state field is encoded"
1001 " in the AU Header (bits)",
1002 10, &pref_stream_state_indication);
1006 void proto_reg_handoff_ismacryp(void)
1008 static gboolean ismacryp_prefs_initialized=FALSE;
1009 static dissector_handle_t ismacryp_handle;
1010 static guint dynamic_payload_type;
1012 if (!ismacryp_prefs_initialized) {
1013 dissector_handle_t ismacryp_v11_handle;
1014 dissector_handle_t ismacryp_v20_handle;
1015 ismacryp_handle = create_dissector_handle(dissect_ismacryp, proto_ismacryp);
1016 ismacryp_v11_handle = create_dissector_handle(dissect_ismacryp_v11, proto_ismacryp);
1017 ismacryp_v20_handle = create_dissector_handle(dissect_ismacryp_v20, proto_ismacryp);
1018 ismacryp_prefs_initialized = TRUE;
1019 dissector_add_string("rtp_dyn_payload_type", "ISMACRYP", ismacryp_handle);
1020 dissector_add_string("rtp_dyn_payload_type", "enc-mpeg4-generic", ismacryp_v11_handle);
1021 dissector_add_string("rtp_dyn_payload_type", "enc-isoff-generic", ismacryp_v20_handle);
1023 else { /* ismacryp_prefs_initialized = TRUE */
1024 /* delete existing association of ismacryp with payload_type */
1025 if ( dynamic_payload_type > 95 ){
1026 dissector_delete_uint("rtp.pt", dynamic_payload_type, ismacryp_handle);
1029 /* always do the following */
1030 dynamic_payload_type = pref_dynamic_payload_type; /*update payload_type to new value */
1031 if ( dynamic_payload_type > 95 ){
1032 dissector_add_uint("rtp.pt", dynamic_payload_type, ismacryp_handle);