2c1d36a0bb15f731ac358ec22de15da32e25030c
[obnox/wireshark/wip.git] / packet-cast.c
1 /* packet-cast.c
2  *
3  * Dissector for the CAST Client Control Protocol
4  *   (The "D-Channel"-Protocol for Cisco Systems' IP-Phones)
5  *
6  * $Id$
7  *
8  * This program is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU General Public License
10  * as published by the Free Software Foundation; either version 2
11  * of the License, or (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, write to the Free Software
20  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21  */
22
23 /* This implementation is based on a draft version of the 3.0
24  * specification
25  */
26
27 #ifdef HAVE_CONFIG_H
28 # include "config.h"
29 #endif
30
31 #include <string.h>
32
33 #include <epan/packet.h>
34 #include "prefs.h"
35
36 #include "packet-tcp.h"
37
38 #define TCP_PORT_CAST 4224
39
40
41 /* I will probably need this again when I change things
42  * to function pointers, but let me use the existing
43  * infrastructure for now
44  *
45  * typedef struct {
46  *   guint32    id;
47  *   char *     name;
48  * } message_id_t;
49  */
50
51 static const value_string  message_id[] = {
52
53   {0x0000, "KeepAliveMessage"},
54   {0x0001, "KeepAliveVersionMessage"},
55   {0x0002, "KeepAliveVersionACKMessage"},
56   {0x0003, "UpdateCapabilitiesMessage"},
57   {0x0004, "EmptyCapabilitiesMessage"},
58   {0x0005, "OpenMultiMediaReceiveChannelMessage"},
59   {0x0006, "OpenMultiMediaReceiveChannelACKMessage"},
60   {0x0007, "CloseMultiMediaReceiveChannelMessage"},
61   {0x0008, "StartMultiMediaTransmissionMessage"},
62   {0x0009, "StopMultiMediaTransmissionMessage"},
63   {0x000A, "MiscellaneousCommandMessage"},
64   {0x000B, "FlowControlCommandMessage"},
65   {0x000C, "ClearConferenceMessage"},
66   {0x000D, "CallStateMessage"},
67   {0x000E, "RequestCallStateMessage"},
68   {0x000F, "RequestAllCallStatesMessage"},
69   {0x0010, "CallInfoMessage"},
70   {0x0011, "RequestCallInfoMessage"},
71   {0x0012, "CallFocusMessage"},
72   {0x0013, "MakeCallMessage"},
73   {0x0014, "HangUpMessage"},
74   {0x0015, "AnswerMessage"},
75
76   {0x0040, "KeepAliveACKMessage"},
77   {0x0041, "StreamStartMessage"},
78   {0x0042, "StreamStopMessage"},
79   {0x0043, "MuteStartMessage"},
80   {0x0044, "MuteStopMessage"},
81   {0x0045, "SpeakerStartMessage"},
82   {0x0046, "SpeakerStopMessage"},
83   {0x0047, "StreamStartMessageWithCodec"},
84
85   {0x0050, "VIEODiscoveryprotocol"},
86   {0x0051, "VIEOControlprotocol"},
87
88   {0x0060, "T120protocol"},
89   {0x0061, "T121protocol"},
90   {0x0062, "T122protocol"},
91
92   {0x0070, "IMSessionDiscoveryprotocol"},
93   {0x0071, "IMSessionControlprotocol"},
94
95   {0x0074, "SlidesDiscoveryprotocol"},
96   {0x0075, "SlidesControlprotocol"},
97
98   {0x0080, "CastTunnelMessage"},
99
100   {0x0090, "RemoteRequestMessage"},
101   {0x0091, "RemoteResponseMessage"},
102
103   {0x00A0, "CollabDiscoveryprotocol"},
104   {0x00A1, "CollabControlprotocol"},
105
106   {0x00A4, "FECCDiscoveryprotocol"},
107   {0x00A5, "FECCControlprotocol"},
108
109   {0x00B0, "ClockSyncprotocol"},
110   {0x00B1, "StreamSyncprotocol"},
111
112   {0x00B4, "MediaDiscoveryprotocol"},
113   {0x00B5, "MediaControlprotocol"},
114
115   {0x00C0, "SessionDiscoveryprotocol"},
116   {0x00C1, "SessionControlprotocol"},
117
118   {0x00C4, "ConferenceDiscoveryprotocol"},
119   {0x00C5, "Conferenceprotocol"},
120
121   {0x00CC, "SCCPCallControlProxyprotocol"},
122
123   {0x00D0, "CallDiscoveryprotocol"},
124   {0x00D1, "CallControlprotocol"},
125
126   {0     , NULL}        /* terminator */
127 };
128
129 static const value_string  audioCodecTypes[] = {
130   {1  , "G711"},
131   {1  , "G729"},
132   {2  , "GSM"},
133   {3  , "G723"},
134   {4  , "G722"},
135   {5  , "WideBand"},
136   { 0    , NULL}
137 };
138
139 static const value_string orcStatus[] = {
140   {0   , "orcOk"},
141   {1   , "orcError"},
142   {0   , NULL}
143 };
144
145 static const value_string mediaPayloads[] = {
146   {1   , "Non-standard codec"},
147   {2   , "G.711 A-law 64k"},
148   {3   , "G.711 A-law 56k"},
149   {4   , "G.711 u-law 64k"},
150   {5   , "G.711 u-law 56k"},
151   {6   , "G.722 64k"},
152   {7   , "G.722 56k"},
153   {8   , "G.722 48k"},
154   {9   , "G.723.1"},
155   {10  , "G.728"},
156   {11  , "G.729"},
157   {12  , "G.729 Annex A"},
158   {13  , "IS11172 AudioCap"},   /* IS11172 is an ISO MPEG standard */
159   {14  , "IS13818 AudioCap"},   /* IS13818 is an ISO MPEG standard */
160   {15  , "G.729 Annex B"},
161   {16  , "G.729 Annex A+Annex B"},
162   {18  , "GSM Full Rate"},
163   {19  , "GSM Half Rate"},
164   {20  , "GSM Enhanced Full Rate"},
165   {25  , "Wideband 256k"},
166   {32  , "Data 64k"},
167   {33  , "Data 56k"},
168   {80  , "GSM"},
169   {81  , "ActiveVoice"},
170   {82  , "G.726 32K"},
171   {83  , "G.726 24K"},
172   {84  , "G.726 16K"},
173   {85  , "G.729B"},
174   {86  , "G.729B Low Complexity"},
175         {100 , "H261"},
176         {101 , "H263"},
177         {102 , "Vieo"},
178         {105 , "T120"},
179         {106 , "H224"},
180         {257 , "RFC2833_DynPayload"},
181   {0  , NULL}
182 };
183
184 static const value_string cast_Layouts[] = {
185   {0  , "NoLayout"},
186   {1  , "OneByOne"},
187   {2  , "OneByTwo"},
188   {3  , "TwoByTwo"},
189   {4  , "TwoByTwo3Alt1"},
190   {5  , "TwoByTwo3Alt2"},
191   {6  , "ThreeByThree"},
192   {7  , "ThreeByThree6Alt1"},
193   {8  , "ThreeByThree6Alt2"},
194   {9  , "ThreeByThree4Alt1"},
195   {10 , "ThreeByThree4Alt2"},
196   {0  , NULL}
197 };
198
199 static const value_string cast_transmitOrReceive[] = {
200   {1  , "Station_Receive_only"},
201   {2  , "Station_Transmit_only"},
202   {3  , "Station_Receive_Transmit"},
203   {0  , NULL}
204 };
205
206 static const value_string cast_formatTypes[] = {
207   {1  , "sqcif (128x96)"},
208   {2  , "qcif (176x144)"},
209   {3  , "cif (352x288)"},
210   {4  , "4cif (704x576)"},
211   {5  , "16cif (1408x1152)"},
212   {6  , "custom_base"},
213   {0  , NULL}
214 };
215
216 static const value_string cast_echoCancelTypes[] = {
217   {0    , "Media_EchoCancellation_Off"},
218   {1    , "Media_EchoCancellation_On"},
219   {0    , NULL}
220 };
221
222 static const value_string cast_g723BitRates[] = {
223   {1   , "Media_G723BRate_5_3"},
224   {2   , "Media_G723BRate_6_4"},
225   {0   , NULL}
226 };
227
228 static const value_string cast_miscCommandType[] = {
229   {0  , "videoFreezePicture"},
230   {1  , "videoFastUpdatePicture"},
231   {2  , "videoFastUpdateGOB"},
232   {3  , "videoFastUpdateMB"},
233   {4  , "lostPicture"},
234   {5  , "lostPartialPicture"},
235   {6  , "recoveryReferencePicture"},
236   {7  , "temporalSpatialTradeOff"},
237   {0  , NULL}
238 };
239
240 static const value_string cast_callStateTypes[] = {
241   {0  , "TsIdle"},
242   {1  , "TsOffHook"},
243   {2  , "TsOnHook"},
244   {3  , "TsRingOut"},
245   {4  , "TsRingIn"},
246   {5  , "TsConnected"},
247   {6  , "TsBusy"},
248   {7  , "TsCongestion"},
249   {8  , "TsHold"},
250   {9  , "TsCallWaiting"},
251   {10 , "TsCallTransfer"},
252   {11 , "TsCallPark"},
253   {12 , "TsProceed"},
254   {13 , "TsCallRemoteMultiline"},
255   {14 , "TsInvalidNumber"},
256   {15 , "TsMaxState"},
257   {0  , NULL}
258 };
259
260 /* Defined Call Type */
261 static const value_string cast_callTypes[] = {
262   {1   , "InBoundCall"},
263   {2   , "OutBoundCall"},
264   {3   , "ForwardCall"},
265   {0   , NULL}
266 };
267
268 static const value_string cast_callSecurityStatusTypes[] = {
269   {0   , "CallSecurityStatusUnknown"},
270   {1   , "CallSecurityStatusNotAuthenticated"},
271   {2   , "CallSecurityStatusAuthenticated"},
272   {0   , NULL}
273 };
274
275
276 #define MAX_CUSTOM_PICTURES                             6
277 #define MAX_SERVICE_TYPE                                4
278 #define MAX_LAYOUT_WITH_SAME_SERVICE    5
279 #define MAX_PICTURE_FORMAT                       5
280 #define MAX_REFERENCE_PICTURE            4
281 #define MAX_LEVEL_PREFERENCE             4
282 #define StationMaxVideoCapabilities     10
283 #define StationMaxDataCapabilities   5
284 #define StationMaxNameSize 40           /* max size of calling party's name  */
285 #define StationMaxDirnumSize 24         /* max size of calling or called party dirnum  */
286
287
288 static void dissect_cast(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
289
290 /* Initialize the protocol and registered fields */
291 static int proto_cast          = -1;
292 static int hf_cast_data_length = -1;
293 static int hf_cast_reserved    = -1;
294 static int hf_cast_messageid   = -1;
295 static int hf_cast_version   = -1;
296 static int hf_cast_ORCStatus = -1;
297 static int hf_cast_ipAddress = -1;
298 static int hf_cast_portNumber = -1;
299 static int hf_cast_passThruPartyID = -1;
300 static int hf_cast_callIdentifier = -1;
301 static int hf_cast_conferenceID = -1;
302 static int hf_cast_payloadType = -1;
303 static int hf_cast_lineInstance = -1;
304 static int hf_cast_payloadCapability = -1;
305 static int hf_cast_isConferenceCreator = -1;
306 static int hf_cast_payload_rfc_number = -1;
307 static int hf_cast_videoCapCount = -1;
308 static int hf_cast_dataCapCount = -1;
309 static int hf_cast_RTPPayloadFormat = -1;
310 static int hf_cast_customPictureFormatCount = -1;
311 static int hf_cast_pictureWidth = -1;
312 static int hf_cast_pictureHeight = -1;
313 static int hf_cast_pixelAspectRatio = -1;
314 static int hf_cast_clockConversionCode = -1;
315 static int hf_cast_clockDivisor = -1;
316 static int hf_cast_activeStreamsOnRegistration = -1;
317 static int hf_cast_maxBW = -1;
318 static int hf_cast_serviceResourceCount = -1;
319 static int hf_cast_layoutCount = -1;
320 static int hf_cast_layout = -1;
321 static int hf_cast_maxConferences = -1;
322 static int hf_cast_activeConferenceOnRegistration = -1;
323 static int hf_cast_transmitOrReceive = -1;
324 static int hf_cast_levelPreferenceCount = -1;
325 static int hf_cast_transmitPreference = -1;
326 static int hf_cast_format = -1;
327 static int hf_cast_maxBitRate = -1;
328 static int hf_cast_minBitRate = -1;
329 static int hf_cast_MPI = -1;
330 static int hf_cast_serviceNumber = -1;
331 static int hf_cast_temporalSpatialTradeOffCapability = -1;
332 static int hf_cast_stillImageTransmission = -1;
333 static int hf_cast_h263_capability_bitfield = -1;
334 static int hf_cast_annexNandWFutureUse = -1;
335 static int hf_cast_modelNumber = -1;
336 static int hf_cast_bandwidth = -1;
337 static int hf_cast_protocolDependentData = -1;
338 static int hf_cast_DSCPValue = -1;
339 static int hf_cast_serviceNum = -1;
340 static int hf_cast_precedenceValue = -1;
341 static int hf_cast_maxStreams = -1;
342 static int hf_cast_millisecondPacketSize = -1;
343 static int hf_cast_echoCancelType = -1;
344 static int hf_cast_g723BitRate = -1;
345 static int hf_cast_bitRate = -1;
346 static int hf_cast_pictureFormatCount = -1;
347 static int hf_cast_confServiceNum = -1;
348 static int hf_cast_miscCommandType = -1;
349 static int hf_cast_temporalSpatialTradeOff = -1;
350 static int hf_cast_firstGOB = -1;
351 static int hf_cast_numberOfGOBs = -1;
352 static int hf_cast_firstMB = -1;
353 static int hf_cast_numberOfMBs = -1;
354 static int hf_cast_pictureNumber = -1;
355 static int hf_cast_longTermPictureIndex = -1;
356 static int hf_cast_recoveryReferencePictureCount = -1;
357 static int hf_cast_calledParty = -1;
358 static int hf_cast_privacy = -1;
359 static int hf_cast_precedenceLv = -1;
360 static int hf_cast_precedenceDm = -1;
361 static int hf_cast_callState = -1;
362 static int hf_cast_callingPartyName = -1;
363 static int hf_cast_callingParty = -1;
364 static int hf_cast_calledPartyName = -1;
365 static int hf_cast_callType = -1;
366 static int hf_cast_originalCalledPartyName = -1;
367 static int hf_cast_originalCalledParty = -1;
368 static int hf_cast_lastRedirectingPartyName = -1;
369 static int hf_cast_lastRedirectingParty = -1;
370 static int hf_cast_cgpnVoiceMailbox = -1;
371 static int hf_cast_cdpnVoiceMailbox = -1;
372 static int hf_cast_originalCdpnVoiceMailbox = -1;
373 static int hf_cast_lastRedirectingVoiceMailbox = -1;
374 static int hf_cast_originalCdpnRedirectReason = -1;
375 static int hf_cast_lastRedirectingReason = -1;
376 static int hf_cast_callInstance = -1;
377 static int hf_cast_callSecurityStatus = -1;
378 static int hf_cast_directoryNumber = -1;
379 static int hf_cast_requestorIpAddress = -1;
380 static int hf_cast_stationIpAddress = -1;
381 static int hf_cast_stationFriendlyName = -1;
382 static int hf_cast_stationGUID = -1;
383 static int hf_cast_audio = -1;
384
385
386
387 /* Initialize the subtree pointers */
388 static gint ett_cast          = -1;
389 static gint ett_cast_tree     = -1;
390
391 /* desegmentation of SCCP */
392 static gboolean cast_desegment = TRUE;
393
394 static dissector_handle_t data_handle;
395
396 /* Dissect a single CAST PDU */
397 static void dissect_cast_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
398 {
399   int offset = 0;
400
401   /* Header fields */
402   guint32 hdr_data_length;
403   guint32 hdr_marker;
404   guint32 data_messageid;
405   gchar   *messageid_str;
406   /*  guint32 data_size; */
407
408   guint i = 0;
409   guint t = 0;
410   int count;
411   int val;
412
413   /* Set up structures we will need to add the protocol subtree and manage it */
414   proto_item *ti;
415   proto_tree *cast_tree = NULL;
416   proto_item *ti_sub;
417   proto_tree *cast_sub_tree;
418   proto_tree *cast_sub_tree_sav;
419   proto_tree *cast_sub_tree_sav_sav;
420
421   hdr_data_length = tvb_get_letohl(tvb, offset);
422   hdr_marker      = tvb_get_letohl(tvb, offset+4);
423   data_messageid  = tvb_get_letohl(tvb, offset+8);
424
425   /* In the interest of speed, if "tree" is NULL, don't do any work not
426    * necessary to generate protocol tree items. */
427   if (tree) {
428     ti = proto_tree_add_item(tree, proto_cast, tvb, offset, hdr_data_length+8, FALSE);
429     cast_tree = proto_item_add_subtree(ti, ett_cast);
430     proto_tree_add_uint(cast_tree, hf_cast_data_length, tvb, offset, 4, hdr_data_length);
431     proto_tree_add_uint(cast_tree, hf_cast_reserved, tvb, offset+4, 4, hdr_marker);
432   }
433
434   messageid_str = val_to_str(data_messageid, message_id, "0x%08X (Unknown)");
435
436   if (check_col(pinfo->cinfo, COL_INFO)) {
437     col_add_str(pinfo->cinfo, COL_INFO, messageid_str);
438   }
439
440   if (tree) {
441     proto_tree_add_uint(cast_tree, hf_cast_messageid, tvb,offset+8, 4, data_messageid );
442   }
443
444   if (tree) {
445     switch(data_messageid) {
446
447     case 0x0 :    /* keepAlive */
448       /* no data in message */
449       break;
450
451     case 0x1 :    /* KeepAliveVersion */
452       proto_tree_add_item(cast_tree, hf_cast_version, tvb, offset+12, 4, TRUE);
453       break;
454
455     case 0x2 :    /* KeepAliveVersionAck */
456       proto_tree_add_item(cast_tree, hf_cast_version, tvb, offset+12, 4, TRUE);
457       break;
458
459     case 0x3 :    /* UpdateCapabilities */
460       /* to do - this message is very large and will span multiple packets, it would be nice to someday */
461       /* find out a way to join the next packet and get the complete message to decode */
462       proto_tree_add_item(cast_tree, hf_cast_videoCapCount, tvb, offset+12, 4, TRUE);
463       proto_tree_add_item(cast_tree, hf_cast_dataCapCount, tvb, offset+16, 4, TRUE);
464       proto_tree_add_item(cast_tree, hf_cast_RTPPayloadFormat, tvb, offset+20, 4, TRUE);
465       proto_tree_add_item(cast_tree, hf_cast_customPictureFormatCount, tvb, offset+24, 4, TRUE);
466       count = offset+28;
467       /* total of 120 bytes */
468       for ( i = 0; i < MAX_CUSTOM_PICTURES; i++ ) {
469                     ti_sub = proto_tree_add_text(cast_tree, tvb, offset, 20, "customPictureFormat[%d]", i);
470                     cast_sub_tree = proto_item_add_subtree(ti_sub, ett_cast_tree);
471         proto_tree_add_item(cast_sub_tree, hf_cast_pictureWidth, tvb, count, 4, TRUE);
472         count+= 4;
473         proto_tree_add_item(cast_sub_tree, hf_cast_pictureHeight, tvb, count, 4, TRUE);
474         count+= 4;
475         proto_tree_add_item(cast_sub_tree, hf_cast_pixelAspectRatio, tvb, count, 4, TRUE);
476         count+= 4;
477         proto_tree_add_item(cast_sub_tree, hf_cast_clockConversionCode, tvb, count, 4, TRUE);
478         count+= 4;
479         proto_tree_add_item(cast_sub_tree, hf_cast_clockDivisor, tvb, count, 4, TRUE);
480         count+= 4;
481       }
482       ti_sub = proto_tree_add_text(cast_tree, tvb, offset, 8, "confResources");
483       cast_sub_tree = proto_item_add_subtree(ti_sub, ett_cast_tree);
484       proto_tree_add_item(cast_sub_tree, hf_cast_activeStreamsOnRegistration, tvb, count, 4, TRUE);
485       count+= 4;
486       proto_tree_add_item(cast_sub_tree, hf_cast_maxBW, tvb, count, 4, TRUE);
487       count+= 4;
488       proto_tree_add_item(cast_sub_tree, hf_cast_serviceResourceCount, tvb, count, 4, TRUE);
489       count+= 4;
490       cast_sub_tree_sav = cast_sub_tree;
491       /* total of 160 bytes */
492       for ( i = 0; i < MAX_SERVICE_TYPE; i++ ) {
493         ti_sub = proto_tree_add_text(cast_sub_tree_sav, tvb, offset, 20, "serviceResource[%d]", i);
494         cast_sub_tree = proto_item_add_subtree(ti_sub, ett_cast_tree);
495         proto_tree_add_item(cast_sub_tree, hf_cast_layoutCount, tvb, count, 4, TRUE);
496         count+= 4;
497         cast_sub_tree_sav_sav = cast_sub_tree_sav;
498         for ( t = 0; t < MAX_LAYOUT_WITH_SAME_SERVICE; t++ ) {
499                       ti_sub = proto_tree_add_text(cast_sub_tree_sav, tvb, offset, 20, "layouts[%d]", t);
500                       cast_sub_tree = proto_item_add_subtree(ti_sub, ett_cast_tree);
501           proto_tree_add_item(cast_sub_tree, hf_cast_layout, tvb, count, 4, TRUE);
502           count+= 4;
503         }
504         cast_sub_tree = cast_sub_tree_sav_sav;
505         proto_tree_add_item(cast_sub_tree, hf_cast_serviceNum, tvb, count, 4, TRUE);
506         count+= 4;
507         proto_tree_add_item(cast_sub_tree, hf_cast_maxStreams, tvb, count, 4, TRUE);
508         count+= 4;
509         proto_tree_add_item(cast_sub_tree, hf_cast_maxConferences, tvb, count, 4, TRUE);
510         count+= 4;
511         proto_tree_add_item(cast_sub_tree, hf_cast_activeConferenceOnRegistration, tvb, count, 4, TRUE);
512         count+= 4;
513       }
514       /* total of 176 bytes */
515       for ( i = 0; i < StationMaxVideoCapabilities; i++ ) {
516         ti_sub = proto_tree_add_text(cast_tree, tvb, offset, 20, "vidCaps[%d]", i);
517         cast_sub_tree = proto_item_add_subtree(ti_sub, ett_cast_tree);
518         proto_tree_add_item(cast_sub_tree, hf_cast_payloadCapability, tvb, count, 4, TRUE);
519         count+= 4;
520         proto_tree_add_item(cast_sub_tree, hf_cast_transmitOrReceive, tvb, count, 4, TRUE);
521         count+= 4;
522         proto_tree_add_item(cast_sub_tree, hf_cast_levelPreferenceCount, tvb, count, 4, TRUE);
523         count+= 4;
524         cast_sub_tree_sav = cast_sub_tree;
525         for ( t = 0; t < MAX_LEVEL_PREFERENCE; t++ ) {
526           ti_sub = proto_tree_add_text(cast_sub_tree_sav, tvb, offset, 20, "levelPreference[%d]", t);
527           cast_sub_tree = proto_item_add_subtree(ti_sub, ett_cast_tree);
528           proto_tree_add_item(cast_sub_tree, hf_cast_transmitPreference, tvb, count, 4, TRUE);
529           count+= 4;
530           proto_tree_add_item(cast_sub_tree, hf_cast_format, tvb, count, 4, TRUE);
531           count+= 4;
532           proto_tree_add_item(cast_sub_tree, hf_cast_maxBitRate, tvb, count, 4, TRUE);
533           count+= 4;
534           proto_tree_add_item(cast_sub_tree, hf_cast_minBitRate, tvb, count, 4, TRUE);
535           count+= 4;
536           proto_tree_add_item(cast_sub_tree, hf_cast_MPI, tvb, count, 4, TRUE);
537           count+= 4;
538           proto_tree_add_item(cast_sub_tree, hf_cast_serviceNumber, tvb, count, 4, TRUE);
539           count+= 4;
540         }
541
542         /* H.261 */
543         ti_sub = proto_tree_add_text(cast_sub_tree_sav, tvb, offset, 8, "h261VideoCapability");
544         cast_sub_tree = proto_item_add_subtree(ti_sub, ett_cast_tree);
545         proto_tree_add_item(cast_sub_tree, hf_cast_temporalSpatialTradeOffCapability, tvb, count, 4, TRUE);
546         proto_tree_add_item(cast_sub_tree, hf_cast_stillImageTransmission, tvb, count+4, 4, TRUE);
547
548         /* H.263 */
549         ti_sub = proto_tree_add_text(cast_sub_tree_sav, tvb, offset, 8, "h263VideoCapability");
550         cast_sub_tree = proto_item_add_subtree(ti_sub, ett_cast_tree);
551         proto_tree_add_item(cast_sub_tree, hf_cast_h263_capability_bitfield, tvb, count, 4, TRUE);
552         proto_tree_add_item(cast_sub_tree, hf_cast_annexNandWFutureUse, tvb, count+4, 4, TRUE);
553
554         /* Vieo */
555         ti_sub = proto_tree_add_text(cast_sub_tree_sav, tvb, offset, 8, "vieoVideoCapability");
556         cast_sub_tree = proto_item_add_subtree(ti_sub, ett_cast_tree);
557         proto_tree_add_item(cast_sub_tree, hf_cast_modelNumber, tvb, count, 4, TRUE);
558         count+= 4;
559         proto_tree_add_item(cast_sub_tree, hf_cast_bandwidth, tvb, count, 4, TRUE);
560         count+= 4;
561       }
562       /* total 80 bytes */
563       for ( i = 0; i < StationMaxDataCapabilities; i++ ) {
564         ti_sub = proto_tree_add_text(cast_tree, tvb, offset, 20, "dataCaps[%d]", i);
565         cast_sub_tree = proto_item_add_subtree(ti_sub, ett_cast_tree);
566         proto_tree_add_item(cast_sub_tree, hf_cast_payloadCapability, tvb, count, 4, TRUE);
567         count+= 4;
568         proto_tree_add_item(cast_sub_tree, hf_cast_transmitOrReceive, tvb, count, 4, TRUE);
569         count+= 4;
570         proto_tree_add_item(cast_sub_tree, hf_cast_protocolDependentData, tvb, count, 4, TRUE);
571         count+= 4;
572         proto_tree_add_item(cast_sub_tree, hf_cast_maxBitRate, tvb, count, 4, TRUE);
573         count+= 4;
574       }
575       break;
576
577     case 0x4 :    /*  */
578       break;
579
580     case 0x5 :    /* OpenMultiMediaReceiveChannel */
581       proto_tree_add_item(cast_tree, hf_cast_conferenceID, tvb, offset+12, 4, TRUE);
582       proto_tree_add_item(cast_tree, hf_cast_passThruPartyID, tvb, offset+16, 4, TRUE);
583       proto_tree_add_item(cast_tree, hf_cast_payloadCapability, tvb, offset+20, 4, TRUE);
584       proto_tree_add_item(cast_tree, hf_cast_lineInstance, tvb, offset+24, 4, TRUE);
585       proto_tree_add_item(cast_tree, hf_cast_callIdentifier, tvb, offset+28, 4, TRUE);
586       proto_tree_add_item(cast_tree, hf_cast_payload_rfc_number, tvb, offset+32, 4, TRUE);
587       proto_tree_add_item(cast_tree, hf_cast_payloadType, tvb, offset+36, 4, TRUE);
588       proto_tree_add_item(cast_tree, hf_cast_isConferenceCreator, tvb, offset+40, 4, TRUE);
589
590       /* add audio part of union */
591       ti_sub = proto_tree_add_text(cast_tree, tvb, offset, 12, "audioParameters");
592       cast_sub_tree = proto_item_add_subtree(ti_sub, ett_cast_tree);
593       proto_tree_add_item(cast_sub_tree, hf_cast_millisecondPacketSize, tvb, offset+44, 4, TRUE);
594       proto_tree_add_item(cast_sub_tree, hf_cast_echoCancelType, tvb, offset+48, 4, TRUE);
595       proto_tree_add_item(cast_sub_tree, hf_cast_g723BitRate, tvb, offset+52, 4, TRUE);
596
597       /* add video part of union */
598       ti_sub = proto_tree_add_text(cast_tree, tvb, offset, 30, "videoParameters");
599       cast_sub_tree = proto_item_add_subtree(ti_sub, ett_cast_tree);
600       proto_tree_add_item(cast_sub_tree, hf_cast_bitRate, tvb, offset+44, 4, TRUE);
601       proto_tree_add_item(cast_sub_tree, hf_cast_pictureFormatCount, tvb, offset+48, 4, TRUE);
602       cast_sub_tree_sav = cast_sub_tree;
603       count = offset+52;
604       for ( i = 0; i < MAX_PICTURE_FORMAT; i++ ) {
605         ti_sub = proto_tree_add_text(cast_sub_tree_sav, tvb, offset, 8 * MAX_PICTURE_FORMAT, "pictureFormat[%d]", i);
606         cast_sub_tree = proto_item_add_subtree(ti_sub, ett_cast_tree);
607         proto_tree_add_item(cast_sub_tree, hf_cast_format, tvb, count, 4, TRUE);
608         count += 4;
609         proto_tree_add_item(cast_sub_tree, hf_cast_MPI, tvb, count, 4, TRUE);
610         count += 4;
611       }
612       cast_sub_tree = cast_sub_tree_sav;
613       proto_tree_add_item(cast_sub_tree, hf_cast_confServiceNum, tvb, count, 4, TRUE);
614       count += 4;
615
616       /* add H261 part of union */
617       ti_sub = proto_tree_add_text(cast_sub_tree_sav, tvb, offset, 8, "h261VideoCapability");
618       cast_sub_tree = proto_item_add_subtree(ti_sub, ett_cast_tree);
619       proto_tree_add_item(cast_sub_tree, hf_cast_temporalSpatialTradeOffCapability, tvb, count, 4, TRUE);
620       proto_tree_add_item(cast_sub_tree, hf_cast_stillImageTransmission, tvb, count+4, 4, TRUE);
621
622       /* add H263 part of union */
623       ti_sub = proto_tree_add_text(cast_sub_tree_sav, tvb, offset, 8, "h263VideoCapability");
624       cast_sub_tree = proto_item_add_subtree(ti_sub, ett_cast_tree);
625       proto_tree_add_item(cast_sub_tree, hf_cast_h263_capability_bitfield, tvb, count, 4, TRUE);
626       proto_tree_add_item(cast_sub_tree, hf_cast_annexNandWFutureUse, tvb, count+4, 4, TRUE);
627
628       /* add Vieo part of union */
629       ti_sub = proto_tree_add_text(cast_sub_tree_sav, tvb, offset, 8, "vieoVideoCapability");
630       cast_sub_tree = proto_item_add_subtree(ti_sub, ett_cast_tree);
631       proto_tree_add_item(cast_sub_tree, hf_cast_modelNumber, tvb, count, 4, TRUE);
632       count += 4;
633       proto_tree_add_item(cast_sub_tree, hf_cast_bandwidth, tvb, count, 4, TRUE);
634
635       /* add data part of union */
636       ti_sub = proto_tree_add_text(cast_tree, tvb, offset, 8, "dataParameters");
637       cast_sub_tree = proto_item_add_subtree(ti_sub, ett_cast_tree);
638       proto_tree_add_item(cast_sub_tree, hf_cast_protocolDependentData, tvb, offset+44, 4, TRUE);
639       proto_tree_add_item(cast_sub_tree, hf_cast_maxBitRate, tvb, offset+48, 4, TRUE);
640       break;
641
642     case 0x6 :    /* OpenMultiMediaReceiveChannelACK */
643       proto_tree_add_item(cast_tree, hf_cast_ORCStatus, tvb, offset+12, 4, TRUE);
644       proto_tree_add_item(cast_tree, hf_cast_ipAddress, tvb, offset+16, 4, TRUE);
645       proto_tree_add_item(cast_tree, hf_cast_portNumber, tvb, offset+20, 4, TRUE);
646       proto_tree_add_item(cast_tree, hf_cast_passThruPartyID, tvb, offset+24, 4, TRUE);
647       proto_tree_add_item(cast_tree, hf_cast_callIdentifier, tvb, offset+28, 4, TRUE);
648       break;
649
650     case 0x7 :    /* CloseMultiMediaReceiveChannel */
651       proto_tree_add_item(cast_tree, hf_cast_conferenceID, tvb, offset+12, 4, TRUE);
652       proto_tree_add_item(cast_tree, hf_cast_passThruPartyID, tvb, offset+16, 4, TRUE);
653       proto_tree_add_item(cast_tree, hf_cast_callIdentifier, tvb, offset+20, 4, TRUE);
654       break;
655
656     case 0x8 :    /* StartMultiMediaTransmission */
657       proto_tree_add_item(cast_tree, hf_cast_conferenceID, tvb, offset+12, 4, TRUE);
658       proto_tree_add_item(cast_tree, hf_cast_passThruPartyID, tvb, offset+16, 4, TRUE);
659       proto_tree_add_item(cast_tree, hf_cast_payloadCapability, tvb, offset+20, 4, TRUE);
660       proto_tree_add_item(cast_tree, hf_cast_ipAddress, tvb, offset+24, 4, TRUE);
661       proto_tree_add_item(cast_tree, hf_cast_portNumber, tvb, offset+28, 4, TRUE);
662       proto_tree_add_item(cast_tree, hf_cast_callIdentifier, tvb, offset+32, 4, TRUE);
663       proto_tree_add_item(cast_tree, hf_cast_payload_rfc_number, tvb, offset+36, 4, TRUE);
664       proto_tree_add_item(cast_tree, hf_cast_payloadType, tvb, offset+40, 4, TRUE);
665       proto_tree_add_item(cast_tree, hf_cast_DSCPValue, tvb, offset+44, 4, TRUE);
666
667       /* add video part of union */
668                   ti_sub = proto_tree_add_text(cast_tree, tvb, offset, 30, "videoParameters");
669                   cast_sub_tree = proto_item_add_subtree(ti_sub, ett_cast_tree);
670       proto_tree_add_item(cast_sub_tree, hf_cast_bitRate, tvb, offset+48, 4, TRUE);
671       proto_tree_add_item(cast_sub_tree, hf_cast_pictureFormatCount, tvb, offset+52, 4, TRUE);
672       cast_sub_tree_sav = cast_sub_tree;
673       count = offset+56;
674       for ( i = 0; i < MAX_PICTURE_FORMAT; i++ ) {
675         ti_sub = proto_tree_add_text(cast_sub_tree_sav, tvb, offset, 8 * MAX_PICTURE_FORMAT, "pictureFormat[%d]", i);
676         cast_sub_tree = proto_item_add_subtree(ti_sub, ett_cast_tree);
677         proto_tree_add_item(cast_sub_tree, hf_cast_format, tvb, count, 4, TRUE);
678         count += 4;
679         proto_tree_add_item(cast_sub_tree, hf_cast_MPI, tvb, count, 4, TRUE);
680         count += 4;
681       }
682       cast_sub_tree = cast_sub_tree_sav;
683       proto_tree_add_item(cast_sub_tree, hf_cast_confServiceNum, tvb, count, 4, TRUE);
684       count += 4;
685
686       val = count;
687       /* add H261 part of union */
688       ti_sub = proto_tree_add_text(cast_sub_tree_sav, tvb, offset, 8, "h261VideoCapability");
689       cast_sub_tree = proto_item_add_subtree(ti_sub, ett_cast_tree);
690       proto_tree_add_item(cast_sub_tree, hf_cast_temporalSpatialTradeOffCapability, tvb, count, 4, TRUE);
691       count += 4;
692       proto_tree_add_item(cast_sub_tree, hf_cast_stillImageTransmission, tvb, count, 4, TRUE);
693
694       /* add H263 part of union */
695       count = val;
696       ti_sub = proto_tree_add_text(cast_sub_tree_sav, tvb, offset, 8, "h263VideoCapability");
697       cast_sub_tree = proto_item_add_subtree(ti_sub, ett_cast_tree);
698       proto_tree_add_item(cast_sub_tree, hf_cast_h263_capability_bitfield, tvb, count, 4, TRUE);
699       count += 4;
700       proto_tree_add_item(cast_sub_tree, hf_cast_annexNandWFutureUse, tvb, count, 4, TRUE);
701
702       /* add Vieo part of union */
703       count = val;
704       ti_sub = proto_tree_add_text(cast_sub_tree_sav, tvb, offset, 8, "vieoVideoCapability");
705       cast_sub_tree = proto_item_add_subtree(ti_sub, ett_cast_tree);
706       proto_tree_add_item(cast_sub_tree, hf_cast_modelNumber, tvb, count, 4, TRUE);
707       count += 4;
708       proto_tree_add_item(cast_sub_tree, hf_cast_bandwidth, tvb, count, 4, TRUE);
709
710       /* add data part of union */
711       ti_sub = proto_tree_add_text(cast_tree, tvb, offset, 8, "dataParameters");
712       cast_sub_tree = proto_item_add_subtree(ti_sub, ett_cast_tree);
713       proto_tree_add_item(cast_sub_tree, hf_cast_protocolDependentData, tvb, offset+48, 4, TRUE);
714       proto_tree_add_item(cast_sub_tree, hf_cast_maxBitRate, tvb, offset+52, 4, TRUE);
715       break;
716
717     case 0x9 :    /* StopMultiMediaTransmission */
718       proto_tree_add_item(cast_tree, hf_cast_conferenceID, tvb, offset+12, 4, TRUE);
719       proto_tree_add_item(cast_tree, hf_cast_passThruPartyID, tvb, offset+16, 4, TRUE);
720       proto_tree_add_item(cast_tree, hf_cast_callIdentifier, tvb, offset+20, 4, TRUE);
721       break;
722
723     case 0xA :    /* MiscellaneousCommand */
724       proto_tree_add_item(cast_tree, hf_cast_conferenceID, tvb, offset+12, 4, TRUE);
725       proto_tree_add_item(cast_tree, hf_cast_passThruPartyID, tvb, offset+16, 4, TRUE);
726       proto_tree_add_item(cast_tree, hf_cast_callIdentifier, tvb, offset+20, 4, TRUE);
727       proto_tree_add_item(cast_tree, hf_cast_miscCommandType, tvb, offset+24, 4, TRUE);
728
729       /* show videoFreezePicture */
730       /* not sure of format */
731
732       /* show videoFastUpdatePicture */
733       /* not sure of format */
734
735       /* show videoFastUpdateGOB */
736       ti_sub = proto_tree_add_text(cast_tree, tvb, offset, 8, "videoFastUpdateGOB");
737       cast_sub_tree = proto_item_add_subtree(ti_sub, ett_cast_tree);
738       proto_tree_add_item(cast_sub_tree, hf_cast_firstGOB, tvb, offset+28, 4, TRUE);
739       proto_tree_add_item(cast_sub_tree, hf_cast_numberOfGOBs, tvb, offset+32, 4, TRUE);
740
741       /* show videoFastUpdateMB */
742       ti_sub = proto_tree_add_text(cast_tree, tvb, offset, 8, "videoFastUpdateGOB");
743       cast_sub_tree = proto_item_add_subtree(ti_sub, ett_cast_tree);
744       proto_tree_add_item(cast_sub_tree, hf_cast_firstGOB, tvb, offset+28, 4, TRUE);
745       proto_tree_add_item(cast_sub_tree, hf_cast_firstMB, tvb, offset+32, 4, TRUE);
746       proto_tree_add_item(cast_sub_tree, hf_cast_numberOfMBs, tvb, offset+36, 4, TRUE);
747
748       /* show lostPicture */
749       ti_sub = proto_tree_add_text(cast_tree, tvb, offset, 8, "lostPicture");
750       cast_sub_tree = proto_item_add_subtree(ti_sub, ett_cast_tree);
751       proto_tree_add_item(cast_sub_tree, hf_cast_pictureNumber, tvb, offset+28, 4, TRUE);
752       proto_tree_add_item(cast_sub_tree, hf_cast_longTermPictureIndex, tvb, offset+32, 4, TRUE);
753
754       /* show lostPartialPicture */
755       ti_sub = proto_tree_add_text(cast_tree, tvb, offset, 8, "lostPartialPicture");
756       cast_sub_tree = proto_item_add_subtree(ti_sub, ett_cast_tree);
757       proto_tree_add_item(cast_sub_tree, hf_cast_pictureNumber, tvb, offset+28, 4, TRUE);
758       proto_tree_add_item(cast_sub_tree, hf_cast_longTermPictureIndex, tvb, offset+32, 4, TRUE);
759       proto_tree_add_item(cast_sub_tree, hf_cast_firstMB, tvb, offset+36, 4, TRUE);
760       proto_tree_add_item(cast_sub_tree, hf_cast_numberOfMBs, tvb, offset+40, 4, TRUE);
761
762       /* show recoveryReferencePicture */
763       ti_sub = proto_tree_add_text(cast_tree, tvb, offset, 8, "recoveryReferencePicture");
764       cast_sub_tree = proto_item_add_subtree(ti_sub, ett_cast_tree);
765       proto_tree_add_item(cast_sub_tree, hf_cast_recoveryReferencePictureCount, tvb, offset+28, 4, TRUE);
766       cast_sub_tree_sav = cast_sub_tree;
767       for ( i = 0; i < MAX_REFERENCE_PICTURE; i++ ) {
768         ti_sub = proto_tree_add_text(cast_sub_tree_sav, tvb, offset, 8, "recoveryReferencePicture[%d]", i);
769         cast_sub_tree = proto_item_add_subtree(ti_sub, ett_cast_tree);
770         proto_tree_add_item(cast_sub_tree, hf_cast_pictureNumber, tvb, offset+32+(i*8), 4, TRUE);
771         proto_tree_add_item(cast_sub_tree, hf_cast_longTermPictureIndex, tvb, offset+36+(i*8), 4, TRUE);
772       }
773
774       /* show temporalSpatialTradeOff */
775       ti_sub = proto_tree_add_text(cast_tree, tvb, offset, 4, "temporalSpatialTradeOff");
776       cast_sub_tree = proto_item_add_subtree(ti_sub, ett_cast_tree);
777       proto_tree_add_item(cast_sub_tree, hf_cast_temporalSpatialTradeOff, tvb, offset+28, 4, TRUE);
778       break;
779
780     case 0xB :    /* FlowControlCommand */
781       proto_tree_add_item(cast_tree, hf_cast_conferenceID, tvb, offset+12, 4, TRUE);
782       proto_tree_add_item(cast_tree, hf_cast_passThruPartyID, tvb, offset+16, 4, TRUE);
783       proto_tree_add_item(cast_tree, hf_cast_callIdentifier, tvb, offset+20, 4, TRUE);
784       proto_tree_add_item(cast_tree, hf_cast_maxBitRate, tvb, offset+24, 4, TRUE);
785       break;
786
787     case 0xC :    /* ClearConference */
788       proto_tree_add_item(cast_tree, hf_cast_conferenceID, tvb, offset+12, 4, TRUE);
789       proto_tree_add_item(cast_tree, hf_cast_serviceNum, tvb, offset+16, 4, TRUE);
790       break;
791
792     case 0xD :    /* CallState */
793       proto_tree_add_item(cast_tree, hf_cast_callState, tvb, offset+12, 4, TRUE);
794       proto_tree_add_item(cast_tree, hf_cast_lineInstance, tvb, offset+16, 4, TRUE);
795       proto_tree_add_item(cast_tree, hf_cast_callIdentifier, tvb, offset+20, 4, TRUE);
796       proto_tree_add_item(cast_tree, hf_cast_privacy, tvb, offset+24, 4, TRUE);
797       proto_tree_add_item(cast_tree, hf_cast_precedenceLv, tvb, offset+28, 4, TRUE);
798       proto_tree_add_item(cast_tree, hf_cast_precedenceDm, tvb, offset+32, 4, TRUE);
799       break;
800
801     case 0xE :    /* RequestCallState */
802       proto_tree_add_item(cast_tree, hf_cast_callIdentifier, tvb, offset+12, 4, TRUE);
803       break;
804
805     case 0xF :    /* RequestAllCallStates */
806       /* no data in message */
807       break;
808
809     case 0x10 :    /* CallInfo */
810       i = offset+12;
811       proto_tree_add_item(cast_tree, hf_cast_callingPartyName, tvb, i, StationMaxNameSize, TRUE);
812       i += StationMaxNameSize;
813       proto_tree_add_item(cast_tree, hf_cast_callingParty, tvb, i, StationMaxDirnumSize, TRUE);
814       i += StationMaxDirnumSize;
815       proto_tree_add_item(cast_tree, hf_cast_calledPartyName, tvb, i, StationMaxNameSize, TRUE);
816       i += StationMaxNameSize;
817       proto_tree_add_item(cast_tree, hf_cast_calledParty, tvb, i, StationMaxDirnumSize, TRUE);
818       i += StationMaxDirnumSize;
819       proto_tree_add_item(cast_tree, hf_cast_lineInstance, tvb, i, 4, TRUE);
820       i += 4;
821       proto_tree_add_item(cast_tree, hf_cast_callIdentifier, tvb, i, 4, TRUE);
822       i += 4;
823       proto_tree_add_item(cast_tree, hf_cast_callType, tvb, i, 4, TRUE);
824       i += 4;
825       proto_tree_add_item(cast_tree, hf_cast_originalCalledPartyName, tvb, i, StationMaxNameSize, TRUE);
826       i += StationMaxNameSize;
827       proto_tree_add_item(cast_tree, hf_cast_originalCalledParty, tvb, i, StationMaxDirnumSize, TRUE);
828       i += StationMaxDirnumSize;
829       proto_tree_add_item(cast_tree, hf_cast_lastRedirectingPartyName, tvb, i, StationMaxNameSize, TRUE);
830       i += StationMaxNameSize;
831       proto_tree_add_item(cast_tree, hf_cast_lastRedirectingParty, tvb, i, StationMaxDirnumSize, TRUE);
832       i += StationMaxDirnumSize;
833       proto_tree_add_item(cast_tree, hf_cast_originalCdpnRedirectReason, tvb, i, 4, TRUE);
834       i += 4;
835       proto_tree_add_item(cast_tree, hf_cast_lastRedirectingReason, tvb, i, 4, TRUE);
836       i += 4;
837       proto_tree_add_item(cast_tree, hf_cast_cgpnVoiceMailbox, tvb, i, StationMaxDirnumSize, TRUE);
838       i += StationMaxDirnumSize;
839       proto_tree_add_item(cast_tree, hf_cast_cdpnVoiceMailbox, tvb, i, StationMaxDirnumSize, TRUE);
840       i += StationMaxDirnumSize;
841       proto_tree_add_item(cast_tree, hf_cast_originalCdpnVoiceMailbox, tvb, i, StationMaxDirnumSize, TRUE);
842       i += StationMaxDirnumSize;
843       proto_tree_add_item(cast_tree, hf_cast_lastRedirectingVoiceMailbox, tvb, i, StationMaxDirnumSize, TRUE);
844       i += StationMaxDirnumSize;
845       proto_tree_add_item(cast_tree, hf_cast_callInstance, tvb, i, 4, TRUE);
846       i += 4;
847       proto_tree_add_item(cast_tree, hf_cast_callSecurityStatus, tvb, i, 4, TRUE);
848       i += 4;
849       val = tvb_get_letohl( tvb, i);
850       ti_sub = proto_tree_add_text(cast_tree, tvb, offset, 8, "partyPIRestrictionBits");
851       cast_sub_tree = proto_item_add_subtree(ti_sub, ett_cast_tree);
852       proto_tree_add_text(cast_sub_tree, tvb, i, 4,
853         decode_boolean_bitfield( val, 0x01, 4*8, "Does RestrictCallingPartyName", "Doesn't RestrictCallingPartyName"));
854       proto_tree_add_text(cast_sub_tree, tvb, i, 4,
855         decode_boolean_bitfield( val, 0x02, 4*8, "Does RestrictCallingPartyNumber", "Doesn't RestrictCallingPartyNumber"));
856       proto_tree_add_text(cast_sub_tree, tvb, i, 4,
857         decode_boolean_bitfield( val, 0x04, 4*8, "Does RestrictCalledPartyName", "Doesn't RestrictCalledPartyName"));
858       proto_tree_add_text(cast_sub_tree, tvb, i, 4,
859         decode_boolean_bitfield( val, 0x08, 4*8, "Does RestrictCalledPartyNumber", "Doesn't RestrictCalledPartyNumber"));
860       proto_tree_add_text(cast_sub_tree, tvb, i, 4,
861         decode_boolean_bitfield( val, 0x10, 4*8, "Does RestrictOriginalCalledPartyName", "Doesn't RestrictOriginalCalledPartyName"));
862       proto_tree_add_text(cast_sub_tree, tvb, i, 4,
863         decode_boolean_bitfield( val, 0x20, 4*8, "Does RestrictOriginalCalledPartyNumber", "Doesn't RestrictOriginalCalledPartyNumber"));
864       proto_tree_add_text(cast_sub_tree, tvb, i, 4,
865         decode_boolean_bitfield( val, 0x40, 4*8, "Does RestrictLastRedirectPartyName", "Doesn't RestrictLastRedirectPartyName"));
866       proto_tree_add_text(cast_sub_tree, tvb, i, 4,
867         decode_boolean_bitfield( val, 0x80, 4*8, "Does RestrictLastRedirectPartyNumber", "Doesn't RestrictLastRedirectPartyNumber"));
868       break;
869
870     case 0x11 :    /* RequestCallInfo */
871       proto_tree_add_item(cast_tree, hf_cast_lineInstance, tvb, offset+12, 4, TRUE);
872       break;
873
874     case 0x12 :    /* CallFocus */
875       proto_tree_add_item(cast_tree, hf_cast_lineInstance, tvb, offset+12, 4, TRUE);
876       proto_tree_add_item(cast_tree, hf_cast_callIdentifier, tvb, offset+16, 4, TRUE);
877       break;
878
879     case 0x13 :    /* MakeCall */
880       proto_tree_add_item(cast_tree, hf_cast_calledParty, tvb, offset+12, StationMaxDirnumSize, TRUE);
881       proto_tree_add_item(cast_tree, hf_cast_lineInstance, tvb, offset+16, 4, TRUE);
882       break;
883
884     case 0x14 :    /* HangUp */
885       proto_tree_add_item(cast_tree, hf_cast_lineInstance, tvb, offset+12, 4, TRUE);
886       break;
887
888     case 0x15 :    /* Answer */
889       proto_tree_add_item(cast_tree, hf_cast_lineInstance, tvb, offset+12, 4, TRUE);
890       break;
891
892     case 0x40 :    /* keepAliveAck */
893       /* no data in message */
894       break;
895
896     case 0x41 :    /* StreamStart */
897       /* no data in message */
898       break;
899
900     case 0x42 :    /* StreamStop */
901       /* no data in message */
902       break;
903
904     case 0x43 :    /* MuteStart */
905       /* no data in message */
906       break;
907
908     case 0x44 :    /* MuteStop */
909       /* no data in message */
910       break;
911
912     case 0x45 :    /* SpeakerStart */
913       /* no data in message */
914       break;
915
916     case 0x46 :    /* SpeakerStop */
917       /* no data in message */
918       break;
919
920     case 0x47 :    /* StreamStartMessageWithCodec */
921       proto_tree_add_item(cast_tree, hf_cast_audio, tvb, offset+12, 4, TRUE);
922       break;
923
924
925     case 0x50 :    /* VIEODiscoveryprotocol */
926       break;
927
928     case 0x51 :    /* VIEOControlprotocol */
929       break;
930
931
932     case 0x60 :    /* VeT120protocol */
933       break;
934
935     case 0x61 :    /* VeT121protocol */
936       break;
937
938     case 0x62 :    /* VeT122protocol */
939       break;
940
941
942     case 0x70 :    /* IMSessionDiscoveryprotocol */
943       break;
944
945     case 0x71 :    /* IMSessionControlprotocol */
946       break;
947
948
949     case 0x74 :    /* SlidesDiscoveryprotocol */
950       break;
951
952     case 0x75 :    /* SlidesControlprotocol */
953       break;
954
955
956     case 0x80 :    /* Tunnel */
957       break;
958
959     case 0x90 :    /* RemoteInfoRequest */
960       i = offset+12;
961       proto_tree_add_item(cast_tree, hf_cast_stationFriendlyName, tvb, i, StationMaxNameSize, TRUE);
962       i += StationMaxNameSize;
963       proto_tree_add_item(cast_tree, hf_cast_stationGUID, tvb, i, StationMaxNameSize, TRUE);
964       i += StationMaxNameSize;
965       proto_tree_add_item(cast_tree, hf_cast_requestorIpAddress, tvb, i, 4, TRUE);
966       break;
967
968     case 0x91 :    /* RemoteInfoResponse */
969       i = offset+12;
970       proto_tree_add_item(cast_tree, hf_cast_stationFriendlyName, tvb, i, StationMaxNameSize, TRUE);
971       i += StationMaxNameSize;
972       proto_tree_add_item(cast_tree, hf_cast_stationGUID, tvb, i, StationMaxNameSize, TRUE);
973       i += StationMaxNameSize;
974       proto_tree_add_item(cast_tree, hf_cast_stationIpAddress, tvb, i, 4, TRUE);
975       i += 4;
976       proto_tree_add_item(cast_tree, hf_cast_directoryNumber, tvb, i, StationMaxNameSize, TRUE);
977       break;
978
979
980     case 0xA0 :    /* CollabDiscoveryprotocol */
981       break;
982
983     case 0xA1 :    /* CollabControlprotocol */
984       break;
985
986
987     case 0xA4 :    /* FECCDiscoveryprotocol */
988       break;
989
990     case 0xA5 :    /* FECCControlprotocol */
991       break;
992
993
994     case 0xB0 :    /* ClockSyncprotocol */
995       break;
996
997     case 0xB1 :    /* StreamSyncprotocol */
998       break;
999
1000
1001     case 0xB4 :    /* MediaDiscoveryprotocol */
1002       break;
1003
1004     case 0xB5 :    /* MediaControlprotocol */
1005       break;
1006
1007
1008     case 0xC0 :    /* SessionDiscoveryprotocol */
1009       break;
1010
1011     case 0xC1 :    /* SessionControlprotocol */
1012       break;
1013
1014
1015     case 0xC4 :    /* ConferenceDiscoveryprotocol */
1016       break;
1017
1018     case 0xC5 :    /* Conferenceprotocol */
1019       break;
1020
1021
1022     case 0xCC :    /* SCCPCallControlProxyprotocol */
1023       break;
1024
1025
1026     case 0xD0 :    /* CallDiscoveryprotocol */
1027       break;
1028
1029     case 0xD1 :    /* CallControlprotocol */
1030       break;
1031
1032
1033     default:
1034       break;
1035     }
1036   }
1037 }
1038
1039 /* Get the length of a single CAST PDU */
1040 static guint get_cast_pdu_len(tvbuff_t *tvb, int offset)
1041 {
1042   guint32 hdr_data_length;
1043
1044   /*
1045    * Get the length of the CAST packet.
1046    */
1047   hdr_data_length = tvb_get_letohl(tvb, offset);
1048
1049   /*
1050    * That length doesn't include the length of the header itself;
1051    * add that in.
1052    */
1053   return hdr_data_length + 8;
1054 }
1055
1056 /* Code to actually dissect the packets */
1057 static void dissect_cast(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
1058 {
1059   /* The general structure of a packet: {IP-Header|TCP-Header|n*CAST}
1060    * CAST-Packet: {Header(Size, Reserved)|Data(MessageID, Message-Data)}
1061    */
1062   /* Header fields */
1063   volatile guint32 hdr_data_length;
1064   guint32 hdr_marker;
1065
1066   /* check, if this is really an SKINNY packet, they start with a length + 0 */
1067
1068   /* get relevant header information */
1069   hdr_data_length = tvb_get_letohl(tvb, 0);
1070   hdr_marker      = tvb_get_letohl(tvb, 4);
1071
1072   /*  data_size       = MIN(8+hdr_data_length, tvb_length(tvb)) - 0xC; */
1073
1074   if (hdr_data_length < 4 || hdr_marker != 0) {
1075     /* Not an CAST packet, just happened to use the same port */
1076     call_dissector(data_handle,tvb, pinfo, tree);
1077     return;
1078   }
1079
1080   /* Make entries in Protocol column and Info column on summary display */
1081   if (check_col(pinfo->cinfo, COL_PROTOCOL)) {
1082     col_set_str(pinfo->cinfo, COL_PROTOCOL, "CAST");
1083   }
1084
1085   if (check_col(pinfo->cinfo, COL_INFO)) {
1086     col_set_str(pinfo->cinfo, COL_INFO, "Cast Client Control Protocol");
1087   }
1088   tcp_dissect_pdus(tvb, pinfo, tree, cast_desegment, 4, get_cast_pdu_len, dissect_cast_pdu);
1089 }
1090
1091 /* Register the protocol with Ethereal */
1092 void
1093 proto_register_cast(void)
1094 {
1095   /* Setup list of header fields */
1096   static hf_register_info hf[] = {
1097     { &hf_cast_data_length,
1098       { "Data Length", "cast.data_length",
1099         FT_UINT32, BASE_DEC, NULL, 0x0,
1100         "Number of bytes in the data portion.",
1101         HFILL }
1102     },
1103
1104     { &hf_cast_reserved,
1105       { "Marker", "cast.marker",
1106         FT_UINT32, BASE_HEX, NULL, 0x0,
1107         "Marker value should ne zero.",
1108         HFILL }
1109     },
1110
1111     /* FIXME: Enable use of message name ???  */
1112     { &hf_cast_messageid,
1113       { "Message ID", "cast.messageid",
1114         FT_UINT32, BASE_HEX, VALS(message_id), 0x0,
1115         "The function requested/done with this message.",
1116         HFILL }
1117     },
1118
1119     { &hf_cast_version,
1120       { "Version", "cast.version",
1121         FT_UINT32, BASE_DEC, NULL, 0x0,
1122         "The version in the keepalive version messages.",
1123         HFILL }
1124     },
1125
1126     { &hf_cast_ORCStatus,
1127       { "ORCStatus", "cast.ORCStatus",
1128         FT_UINT32, BASE_DEC, VALS(orcStatus), 0x0,
1129         "The status of the opened receive channel.",
1130         HFILL }
1131     },
1132
1133     { &hf_cast_ipAddress,
1134       { "IP Address", "cast.ipAddress",
1135         FT_IPv4, BASE_NONE, NULL, 0x0,
1136         "An IP address",
1137         HFILL }
1138     },
1139
1140     { &hf_cast_portNumber,
1141       { "Port Number", "cast.portNumber",
1142         FT_UINT32, BASE_DEC, NULL, 0x0,
1143         "A port number",
1144         HFILL }
1145     },
1146
1147     { &hf_cast_passThruPartyID,
1148       { "PassThruPartyID", "cast.passThruPartyID",
1149         FT_UINT32, BASE_DEC, NULL, 0x0,
1150         "The pass thru party id",
1151         HFILL }
1152     },
1153
1154     { &hf_cast_callIdentifier,
1155       { "Call Identifier", "cast.callIdentifier",
1156         FT_UINT32, BASE_DEC, NULL, 0x0,
1157         "Call identifier for this call.",
1158         HFILL }
1159     },
1160
1161     { &hf_cast_conferenceID,
1162       { "Conference ID", "cast.conferenceID",
1163         FT_UINT32, BASE_DEC, NULL, 0x0,
1164         "The conference ID",
1165         HFILL }
1166     },
1167
1168     { &hf_cast_payloadType,
1169       { "PayloadType", "cast.payloadType",
1170         FT_UINT32, BASE_DEC, NULL, 0x0,
1171         "PayloadType.",
1172         HFILL }
1173     },
1174
1175     { &hf_cast_lineInstance,
1176       { "Line Instance", "cast.lineInstance",
1177         FT_UINT32, BASE_DEC, NULL, 0x0,
1178         "The display call plane associated with this call.",
1179         HFILL }
1180     },
1181
1182     { &hf_cast_payloadCapability,
1183       { "PayloadCapability", "cast.payloadCapability",
1184         FT_UINT32, BASE_DEC, VALS(mediaPayloads), 0x0,
1185         "The payload capability for this media capability structure.",
1186         HFILL }
1187     },
1188
1189     { &hf_cast_isConferenceCreator,
1190       { "IsConferenceCreator", "cast.isConferenceCreator",
1191         FT_UINT32, BASE_DEC, NULL, 0x0,
1192         "IsConferenceCreator.",
1193         HFILL }
1194     },
1195
1196     { &hf_cast_payload_rfc_number,
1197       { "Payload_rfc_number", "cast.payload_rfc_number",
1198         FT_UINT32, BASE_DEC, NULL, 0x0,
1199         "Payload_rfc_number.",
1200         HFILL }
1201     },
1202
1203     { &hf_cast_videoCapCount,
1204       { "VideoCapCount", "cast.videoCapCount",
1205         FT_UINT32, BASE_DEC, NULL, 0x0,
1206         "VideoCapCount.",
1207         HFILL }
1208     },
1209
1210     { &hf_cast_dataCapCount,
1211       { "DataCapCount", "cast.dataCapCount",
1212         FT_UINT32, BASE_DEC, NULL, 0x0,
1213         "DataCapCount.",
1214         HFILL }
1215     },
1216
1217     { &hf_cast_RTPPayloadFormat,
1218       { "RTPPayloadFormat", "cast.RTPPayloadFormat",
1219         FT_UINT32, BASE_DEC, NULL, 0x0,
1220         "RTPPayloadFormat.",
1221         HFILL }
1222     },
1223
1224     { &hf_cast_customPictureFormatCount,
1225       { "CustomPictureFormatCount", "cast.customPictureFormatCount",
1226         FT_UINT32, BASE_DEC, NULL, 0x0,
1227         "CustomPictureFormatCount.",
1228         HFILL }
1229     },
1230
1231     { &hf_cast_pictureWidth,
1232       { "PictureWidth", "cast.pictureWidth",
1233         FT_UINT32, BASE_DEC, NULL, 0x0,
1234         "PictureWidth.",
1235         HFILL }
1236     },
1237
1238     { &hf_cast_pictureHeight,
1239       { "PictureHeight", "cast.pictureHeight",
1240         FT_UINT32, BASE_DEC, NULL, 0x0,
1241         "PictureHeight.",
1242         HFILL }
1243     },
1244
1245     { &hf_cast_pixelAspectRatio,
1246       { "PixelAspectRatio", "cast.pixelAspectRatio",
1247         FT_UINT32, BASE_DEC, NULL, 0x0,
1248         "PixelAspectRatio.",
1249         HFILL }
1250     },
1251
1252     { &hf_cast_clockConversionCode,
1253       { "ClockConversionCode", "cast.clockConversionCode",
1254         FT_UINT32, BASE_DEC, NULL, 0x0,
1255         "ClockConversionCode.",
1256         HFILL }
1257     },
1258
1259     { &hf_cast_clockDivisor,
1260       { "ClockDivisor", "cast.clockDivisor",
1261         FT_UINT32, BASE_DEC, NULL, 0x0,
1262         "Clock Divisor.",
1263         HFILL }
1264     },
1265
1266     { &hf_cast_activeStreamsOnRegistration,
1267       { "ActiveStreamsOnRegistration", "cast.activeStreamsOnRegistration",
1268         FT_UINT32, BASE_DEC, NULL, 0x0,
1269         "ActiveStreamsOnRegistration.",
1270         HFILL }
1271     },
1272
1273     { &hf_cast_maxBW,
1274       { "MaxBW", "cast.maxBW",
1275         FT_UINT32, BASE_DEC, NULL, 0x0,
1276         "MaxBW.",
1277         HFILL }
1278     },
1279
1280     { &hf_cast_serviceResourceCount,
1281       { "ServiceResourceCount", "cast.serviceResourceCount",
1282         FT_UINT32, BASE_DEC, NULL, 0x0,
1283         "ServiceResourceCount.",
1284         HFILL }
1285     },
1286
1287     { &hf_cast_layoutCount,
1288       { "LayoutCount", "cast.layoutCount",
1289         FT_UINT32, BASE_DEC, NULL, 0x0,
1290         "LayoutCount.",
1291         HFILL }
1292     },
1293
1294     { &hf_cast_layout,
1295       { "Layout", "cast.layout",
1296         FT_UINT32, BASE_DEC, VALS(cast_Layouts), 0x0,
1297         "Layout",
1298         HFILL }
1299     },
1300
1301     { &hf_cast_maxConferences,
1302       { "MaxConferences", "cast.maxConferences",
1303         FT_UINT32, BASE_DEC, NULL, 0x0,
1304         "MaxConferences.",
1305         HFILL }
1306     },
1307
1308     { &hf_cast_activeConferenceOnRegistration,
1309       { "ActiveConferenceOnRegistration", "cast.activeConferenceOnRegistration",
1310         FT_UINT32, BASE_DEC, NULL, 0x0,
1311         "ActiveConferenceOnRegistration.",
1312         HFILL }
1313     },
1314
1315     { &hf_cast_transmitOrReceive,
1316       { "TransmitOrReceive", "cast.transmitOrReceive",
1317         FT_UINT32, BASE_DEC, VALS(cast_transmitOrReceive), 0x0,
1318         "TransmitOrReceive",
1319         HFILL }
1320     },
1321
1322     { &hf_cast_levelPreferenceCount,
1323       { "LevelPreferenceCount", "cast.levelPreferenceCount",
1324         FT_UINT32, BASE_DEC, NULL, 0x0,
1325         "LevelPreferenceCount.",
1326         HFILL }
1327     },
1328
1329     { &hf_cast_transmitPreference,
1330       { "TransmitPreference", "cast.transmitPreference",
1331         FT_UINT32, BASE_DEC, NULL, 0x0,
1332         "TransmitPreference.",
1333         HFILL }
1334     },
1335
1336     { &hf_cast_format,
1337       { "Format", "cast.format",
1338         FT_UINT32, BASE_DEC, VALS(cast_formatTypes), 0x0,
1339         "Format.",
1340         HFILL }
1341     },
1342
1343     { &hf_cast_maxBitRate,
1344       { "MaxBitRate", "cast.maxBitRate",
1345         FT_UINT32, BASE_DEC, NULL, 0x0,
1346         "MaxBitRate.",
1347         HFILL }
1348     },
1349
1350     { &hf_cast_minBitRate,
1351       { "MinBitRate", "cast.minBitRate",
1352         FT_UINT32, BASE_DEC, NULL, 0x0,
1353         "MinBitRate.",
1354         HFILL }
1355     },
1356
1357     { &hf_cast_MPI,
1358       { "MPI", "cast.MPI",
1359         FT_UINT32, BASE_DEC, NULL, 0x0,
1360         "MPI.",
1361         HFILL }
1362     },
1363
1364     { &hf_cast_serviceNumber,
1365       { "ServiceNumber", "cast.serviceNumber",
1366         FT_UINT32, BASE_DEC, NULL, 0x0,
1367         "ServiceNumber.",
1368         HFILL }
1369     },
1370
1371     { &hf_cast_temporalSpatialTradeOffCapability,
1372       { "TemporalSpatialTradeOffCapability", "cast.temporalSpatialTradeOffCapability",
1373         FT_UINT32, BASE_DEC, NULL, 0x0,
1374         "TemporalSpatialTradeOffCapability.",
1375         HFILL }
1376     },
1377
1378     { &hf_cast_stillImageTransmission,
1379       { "StillImageTransmission", "cast.stillImageTransmission",
1380         FT_UINT32, BASE_DEC, NULL, 0x0,
1381         "StillImageTransmission.",
1382         HFILL }
1383     },
1384
1385     { &hf_cast_h263_capability_bitfield,
1386       { "H263_capability_bitfield", "cast.h263_capability_bitfield",
1387         FT_UINT32, BASE_DEC, NULL, 0x0,
1388         "H263_capability_bitfield.",
1389         HFILL }
1390     },
1391
1392     { &hf_cast_annexNandWFutureUse,
1393       { "AnnexNandWFutureUse", "cast.annexNandWFutureUse",
1394         FT_UINT32, BASE_DEC, NULL, 0x0,
1395         "AnnexNandWFutureUse.",
1396         HFILL }
1397     },
1398
1399     { &hf_cast_modelNumber,
1400       { "ModelNumber", "cast.modelNumber",
1401         FT_UINT32, BASE_DEC, NULL, 0x0,
1402         "ModelNumber.",
1403         HFILL }
1404     },
1405
1406     { &hf_cast_bandwidth,
1407       { "Bandwidth", "cast.bandwidth",
1408         FT_UINT32, BASE_DEC, NULL, 0x0,
1409         "Bandwidth.",
1410         HFILL }
1411     },
1412
1413     { &hf_cast_protocolDependentData,
1414       { "ProtocolDependentData", "cast.protocolDependentData",
1415         FT_UINT32, BASE_DEC, NULL, 0x0,
1416         "ProtocolDependentData.",
1417         HFILL }
1418     },
1419
1420     { &hf_cast_DSCPValue,
1421       { "DSCPValue", "cast.DSCPValue",
1422         FT_UINT32, BASE_DEC, NULL, 0x0,
1423         "DSCPValue.",
1424         HFILL }
1425     },
1426
1427     { &hf_cast_serviceNum,
1428       { "ServiceNum", "cast.serviceNum",
1429         FT_UINT32, BASE_DEC, NULL, 0x0,
1430         "ServiceNum.",
1431         HFILL }
1432     },
1433
1434     { &hf_cast_precedenceValue,
1435       { "Precedence", "cast.precedenceValue",
1436         FT_UINT32, BASE_DEC, NULL, 0x0,
1437         "Precedence value",
1438         HFILL }
1439     },
1440
1441     { &hf_cast_maxStreams,
1442       { "MaxStreams", "cast.maxStreams",
1443         FT_UINT32, BASE_DEC, NULL, 0x0,
1444         "32 bit unsigned integer indicating the maximum number of simultansous RTP duplex streams that the client can handle.",
1445         HFILL }
1446     },
1447
1448     { &hf_cast_millisecondPacketSize,
1449       { "MS/Packet", "cast.millisecondPacketSize",
1450         FT_UINT32, BASE_DEC, NULL, 0x0,
1451         "The number of milliseconds of conversation in each packet",
1452         HFILL }
1453     },
1454
1455     { &hf_cast_echoCancelType,
1456       { "Echo Cancel Type", "cast.echoCancelType",
1457         FT_UINT32, BASE_DEC, VALS(cast_echoCancelTypes), 0x0,
1458         "Is echo cancelling enabled or not",
1459         HFILL }
1460     },
1461
1462     { &hf_cast_g723BitRate,
1463       { "G723 BitRate", "cast.g723BitRate",
1464         FT_UINT32, BASE_DEC, VALS(cast_g723BitRates), 0x0,
1465         "The G723 bit rate for this stream/JUNK if not g723 stream",
1466         HFILL }
1467     },
1468
1469     { &hf_cast_pictureFormatCount,
1470       { "PictureFormatCount", "cast.pictureFormatCount",
1471         FT_UINT32, BASE_DEC, NULL, 0x0,
1472         "PictureFormatCount.",
1473         HFILL }
1474     },
1475
1476     { &hf_cast_confServiceNum,
1477       { "ConfServiceNum", "cast.confServiceNum",
1478         FT_UINT32, BASE_DEC, NULL, 0x0,
1479         "ConfServiceNum.",
1480         HFILL }
1481     },
1482
1483     { &hf_cast_miscCommandType,
1484       { "MiscCommandType", "cast.miscCommandType",
1485         FT_UINT32, BASE_DEC, VALS(cast_miscCommandType), 0x0,
1486         "MiscCommandType",
1487         HFILL }
1488     },
1489
1490     { &hf_cast_temporalSpatialTradeOff,
1491       { "TemporalSpatialTradeOff", "cast.temporalSpatialTradeOff",
1492         FT_UINT32, BASE_DEC, NULL, 0x0,
1493         "TemporalSpatialTradeOff.",
1494         HFILL }
1495     },
1496
1497     { &hf_cast_firstGOB,
1498       { "FirstGOB", "cast.firstGOB",
1499         FT_UINT32, BASE_DEC, NULL, 0x0,
1500         "FirstGOB.",
1501         HFILL }
1502     },
1503
1504     { &hf_cast_numberOfGOBs,
1505       { "NumberOfGOBs", "cast.numberOfGOBs",
1506         FT_UINT32, BASE_DEC, NULL, 0x0,
1507         "NumberOfGOBs.",
1508         HFILL }
1509     },
1510
1511     { &hf_cast_firstMB,
1512       { "FirstMB", "cast.firstMB",
1513         FT_UINT32, BASE_DEC, NULL, 0x0,
1514         "FirstMB.",
1515         HFILL }
1516     },
1517
1518     { &hf_cast_numberOfMBs,
1519       { "NumberOfMBs", "cast.numberOfMBs",
1520         FT_UINT32, BASE_DEC, NULL, 0x0,
1521         "NumberOfMBs.",
1522         HFILL }
1523     },
1524
1525     { &hf_cast_pictureNumber,
1526       { "PictureNumber", "cast.pictureNumber",
1527         FT_UINT32, BASE_DEC, NULL, 0x0,
1528         "PictureNumber.",
1529         HFILL }
1530     },
1531
1532     { &hf_cast_longTermPictureIndex,
1533       { "LongTermPictureIndex", "cast.longTermPictureIndex",
1534         FT_UINT32, BASE_DEC, NULL, 0x0,
1535         "LongTermPictureIndex.",
1536         HFILL }
1537     },
1538
1539     { &hf_cast_recoveryReferencePictureCount,
1540       { "RecoveryReferencePictureCount", "cast.recoveryReferencePictureCount",
1541         FT_UINT32, BASE_DEC, NULL, 0x0,
1542         "RecoveryReferencePictureCount.",
1543         HFILL }
1544     },
1545
1546     { &hf_cast_calledParty,
1547       { "CalledParty", "cast.calledParty",
1548         FT_STRING, BASE_NONE, NULL, 0x0,
1549         "The number called.",
1550         HFILL }
1551     },
1552
1553     { &hf_cast_privacy,
1554       { "Privacy", "cast.privacy",
1555         FT_UINT32, BASE_DEC, NULL, 0x0,
1556         "Privacy.",
1557         HFILL }
1558     },
1559
1560     { &hf_cast_precedenceLv,
1561       { "PrecedenceLv", "cast.precedenceLv",
1562         FT_UINT32, BASE_DEC, NULL, 0x0,
1563         "Precedence Level.",
1564         HFILL }
1565     },
1566
1567     { &hf_cast_precedenceDm,
1568       { "PrecedenceDm", "cast.precedenceDm",
1569         FT_UINT32, BASE_DEC, NULL, 0x0,
1570         "Precedence Domain.",
1571         HFILL }
1572     },
1573
1574     { &hf_cast_callState,
1575       { "CallState", "cast.callState",
1576         FT_UINT32, BASE_DEC, VALS(cast_callStateTypes), 0x0,
1577         "CallState.",
1578         HFILL }
1579     },
1580
1581     { &hf_cast_callingPartyName,
1582       { "Calling Party Name", "cast.callingPartyName",
1583         FT_STRING, BASE_NONE, NULL, 0x0,
1584         "The passed name of the calling party.",
1585         HFILL }
1586     },
1587
1588     { &hf_cast_callingParty,
1589       { "Calling Party", "cast.callingPartyName",
1590         FT_STRING, BASE_NONE, NULL, 0x0,
1591         "The passed number of the calling party.",
1592         HFILL }
1593     },
1594
1595     { &hf_cast_calledPartyName,
1596       { "Called Party Name", "cast.calledPartyName",
1597         FT_STRING, BASE_NONE, NULL, 0x0,
1598         "The name of the party we are calling.",
1599         HFILL }
1600     },
1601
1602     { &hf_cast_callType,
1603       { "Call Type", "cast.callType",
1604         FT_UINT32, BASE_DEC, VALS(cast_callTypes), 0x0,
1605         "What type of call, in/out/etc",
1606         HFILL }
1607     },
1608
1609     { &hf_cast_originalCalledPartyName,
1610       { "Original Called Party Name", "cast.originalCalledPartyName",
1611         FT_STRING, BASE_NONE, NULL, 0x0,
1612         "name of the original person who placed the call.",
1613         HFILL }
1614     },
1615
1616     { &hf_cast_originalCalledParty,
1617       { "Original Called Party", "cast.originalCalledParty",
1618         FT_STRING, BASE_NONE, NULL, 0x0,
1619         "The number of the original calling party.",
1620         HFILL }
1621     },
1622
1623     { &hf_cast_lastRedirectingPartyName,
1624       { "LastRedirectingPartyName", "cast.lastRedirectingPartyName",
1625         FT_STRING, BASE_NONE, NULL, 0x0,
1626         "LastRedirectingPartyName.",
1627         HFILL }
1628     },
1629
1630     { &hf_cast_lastRedirectingParty,
1631       { "LastRedirectingParty", "cast.lastRedirectingParty",
1632         FT_STRING, BASE_NONE, NULL, 0x0,
1633         "LastRedirectingParty.",
1634         HFILL }
1635     },
1636
1637     { &hf_cast_cgpnVoiceMailbox,
1638       { "CgpnVoiceMailbox", "cast.cgpnVoiceMailbox",
1639         FT_STRING, BASE_NONE, NULL, 0x0,
1640         "CgpnVoiceMailbox.",
1641         HFILL }
1642     },
1643
1644     { &hf_cast_cdpnVoiceMailbox,
1645       { "CdpnVoiceMailbox", "cast.cdpnVoiceMailbox",
1646         FT_STRING, BASE_NONE, NULL, 0x0,
1647         "CdpnVoiceMailbox.",
1648         HFILL }
1649     },
1650
1651     { &hf_cast_originalCdpnVoiceMailbox,
1652       { "OriginalCdpnVoiceMailbox", "cast.originalCdpnVoiceMailbox",
1653         FT_STRING, BASE_NONE, NULL, 0x0,
1654         "OriginalCdpnVoiceMailbox.",
1655         HFILL }
1656     },
1657
1658     { &hf_cast_lastRedirectingVoiceMailbox,
1659       { "LastRedirectingVoiceMailbox", "cast.lastRedirectingVoiceMailbox",
1660         FT_STRING, BASE_NONE, NULL, 0x0,
1661         "LastRedirectingVoiceMailbox.",
1662         HFILL }
1663     },
1664
1665     { &hf_cast_originalCdpnRedirectReason,
1666       { "OriginalCdpnRedirectReason", "cast.originalCdpnRedirectReason",
1667         FT_UINT32, BASE_DEC, NULL, 0x0,
1668         "OriginalCdpnRedirectReason.",
1669         HFILL }
1670     },
1671
1672     { &hf_cast_lastRedirectingReason,
1673       { "LastRedirectingReason", "cast.lastRedirectingReason",
1674         FT_UINT32, BASE_DEC, NULL, 0x0,
1675         "LastRedirectingReason.",
1676         HFILL }
1677     },
1678
1679     { &hf_cast_callInstance,
1680       { "CallInstance", "cast.callInstance",
1681         FT_UINT32, BASE_DEC, NULL, 0x0,
1682         "CallInstance.",
1683         HFILL }
1684     },
1685
1686     { &hf_cast_callSecurityStatus,
1687       { "CallSecurityStatus", "cast.callSecurityStatus",
1688         FT_UINT32, BASE_DEC, VALS(cast_callSecurityStatusTypes), 0x0,
1689         "CallSecurityStatus.",
1690         HFILL }
1691     },
1692
1693     { &hf_cast_directoryNumber,
1694       { "Directory Number", "cast.directoryNumber",
1695         FT_STRING, BASE_NONE, NULL, 0x0,
1696         "The number we are reporting statistics for.",
1697         HFILL }
1698     },
1699
1700     { &hf_cast_requestorIpAddress,
1701       { "RequestorIpAddress", "cast.requestorIpAddress",
1702         FT_IPv4, BASE_NONE, NULL, 0x0,
1703         "RequestorIpAddress",
1704         HFILL }
1705     },
1706
1707     { &hf_cast_stationIpAddress,
1708       { "StationIpAddress", "cast.stationIpAddress",
1709         FT_IPv4, BASE_NONE, NULL, 0x0,
1710         "StationIpAddress",
1711         HFILL }
1712     },
1713
1714     { &hf_cast_stationFriendlyName,
1715       { "StationFriendlyName", "cast.stationFriendlyName",
1716         FT_STRING, BASE_NONE, NULL, 0x0,
1717         "StationFriendlyName.",
1718         HFILL }
1719     },
1720
1721     { &hf_cast_stationGUID,
1722       { "stationGUID", "cast.stationGUID",
1723         FT_STRING, BASE_NONE, NULL, 0x0,
1724         "stationGUID.",
1725         HFILL }
1726     },
1727
1728     { &hf_cast_audio,
1729       { "AudioCodec", "cast.audio",
1730         FT_UINT32, BASE_DEC, VALS(audioCodecTypes), 0x0,
1731         "The audio codec that is in use.",
1732         HFILL }
1733     },
1734
1735     { &hf_cast_bitRate,
1736       { "BitRate", "skinny.bitRate",
1737         FT_UINT32, BASE_DEC, NULL, 0x0,
1738         "BitRate.",
1739         HFILL }
1740     },
1741
1742   };
1743
1744   /* Setup protocol subtree array */
1745   static gint *ett[] = {
1746     &ett_cast,
1747     &ett_cast_tree,
1748   };
1749
1750   module_t *cast_module;
1751
1752   /* Register the protocol name and description */
1753   proto_cast = proto_register_protocol("Cast Client Control Protocol",
1754                                          "CAST", "cast");
1755
1756   /* Required function calls to register the header fields and subtrees used */
1757   proto_register_field_array(proto_cast, hf, array_length(hf));
1758   proto_register_subtree_array(ett, array_length(ett));
1759
1760   cast_module = prefs_register_protocol(proto_cast, NULL);
1761   prefs_register_bool_preference(cast_module, "reassembly", /*"desegment",*/
1762     "Desegment all CAST messages spanning multiple TCP segments",
1763     "Whether the CAST dissector should desegment all messages spanning multiple TCP segments",
1764     &cast_desegment);
1765 }
1766
1767 void
1768 proto_reg_handoff_cast(void)
1769 {
1770   dissector_handle_t cast_handle;
1771
1772   data_handle = find_dissector("data");
1773   cast_handle = create_dissector_handle(dissect_cast, proto_cast);
1774   dissector_add("tcp.port", TCP_PORT_CAST, cast_handle);
1775 }
1776