Use ENC_NA as proto_tree_add_item() encoding arg for FT_ETHER hf[] field type.
[obnox/wireshark/wip.git] / plugins / unistim / packet-unistim.c
1 /* packet-unistim.c
2   * Routines for unistim packet dissection
3   * Copyright 2007 Don Newton <dnewton@cypresscom.net>
4   *
5   * $Id$
6   *
7   * Wireshark - Network traffic analyzer
8   * By Gerald Combs <gerald@wireshark.org>
9   * Copyright 1998 Gerald Combs
10   *
11   * This program is free software; you can redistribute it and/or
12   * modify it under the terms of the GNU General Public License
13   * as published by the Free Software Foundation; either version 2
14   * of the License, or (at your option) any later version.
15   *
16   * This program is distributed in the hope that it will be useful,
17   * but WITHOUT ANY WARRANTY; without even the implied warranty of
18   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19   * GNU General Public License for more details.
20   *
21   * You should have received a copy of the GNU General Public License
22   * along with this program; if not, write to the Free Software
23   * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
24  */
25
26
27 #ifdef HAVE_CONFIG_H
28 # include "config.h"
29 #endif
30
31 #include <glib.h>
32 #include <epan/packet.h>
33 #include <epan/tap.h>
34 #include <epan/emem.h>
35 #include <epan/expert.h>
36 #include <epan/address.h>
37 #include <epan/prefs.h>
38 #include <epan/dissectors/packet-rtp.h>
39 #include <epan/dissectors/packet-rtcp.h>
40 #include <string.h>
41 #include "packet-unistim.h"
42 #include "defines.h"
43 #include "audio.h"
44 #include "basic.h"
45 #include "display.h"
46 #include "network.h"
47 #include "key.h"
48 #include "broadcast.h"
49 #include "uftp.h"
50 #include "expansion.h"
51
52 /* Don't set this to 5000 until this dissector is made a heuristic one!
53    It collides (at least) with tapa.
54    static guint global_unistim_port = 5000; */
55 static guint global_unistim_port = 0;
56
57 static unistim_info_t *uinfo;
58 static int unistim_tap = -1;
59
60 void proto_reg_handoff_unistim(void);
61 static void dissect_payload(proto_tree *unistim_tree,tvbuff_t *tvb,gint offset, packet_info *pinfo);
62 static int dissect_unistim(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
63
64 static gint dissect_broadcast_switch(proto_tree *msg_tree,
65                                      tvbuff_t *tvb,gint offset,guint msg_len);
66 static gint dissect_audio_switch(proto_tree *msg_tree,packet_info *pinfo,
67                                    tvbuff_t *tvb,gint offset,guint msg_len);
68 static gint dissect_expansion_switch(proto_tree *msg_tree,
69                                    tvbuff_t *tvb,gint offset,guint msg_len);
70 static gint dissect_display_switch(proto_tree *msg_tree,
71                                    tvbuff_t *tvb,gint offset,guint msg_len);
72 static gint dissect_key_indicator_switch(proto_tree *msg_tree,
73                                    tvbuff_t *tvb,gint offset,guint msg_len);
74 static gint dissect_basic_switch(proto_tree *msg_tree,
75                                    tvbuff_t *tvb,gint offset,guint msg_len);
76 static gint dissect_network_switch(proto_tree *msg_tree,
77                                    tvbuff_t *tvb,gint offset,guint msg_len);
78 static gint dissect_broadcast_phone(proto_tree *msg_tree,
79                                    tvbuff_t *tvb,gint offset,guint msg_len);
80 static gint dissect_audio_phone(proto_tree *msg_tree,
81                                    tvbuff_t *tvb,gint offset,guint msg_len);
82 static gint dissect_expansion_phone(proto_tree *msg_tree,
83                                    tvbuff_t *tvb,gint offset,guint msg_len);
84 static gint dissect_display_phone(proto_tree *msg_tree,
85                                    tvbuff_t *tvb,gint offset,guint msg_len);
86 static gint dissect_key_indicator_phone(proto_tree *msg_tree,
87                                    tvbuff_t *tvb,gint offset,guint msg_len);
88 static gint dissect_basic_phone(proto_tree *msg_tree,
89                                    tvbuff_t *tvb,gint offset,guint msg_len);
90 static gint dissect_network_phone(proto_tree *msg_tree,
91                                    tvbuff_t *tvb,gint offset,guint msg_len);
92 static gint dissect_unistim_message(proto_tree *unistim_tree, packet_info *pinfo,
93                                    tvbuff_t *tvb,gint offset);
94 static gint dissect_uftp_message(proto_tree *unistim_tree, packet_info *pinfo,
95                                    tvbuff_t *tvb,gint offset);
96
97
98 static void set_ascii_item(proto_tree *unistim_tree, tvbuff_t *tvb,
99                            gint offset,guint msg_len);
100
101
102 static int proto_unistim = -1;
103 static int hf_unistim_seq_nu = -1;
104 static int hf_unistim_packet_type = -1;
105 static int hf_unistim_payload = -1;
106 static int hf_unistim_cmd_add = -1;
107 static int hf_unistim_len =-1;
108 static int hf_terminal_id=-1;
109 static int hf_basic_bit_field=-1;
110 static const true_false_string basic_bit_yn={
111    "For Following Byte",
112    "For Following Byte"
113 };
114
115 static int hf_basic_switch_cmd=-1;
116 static int hf_basic_phone_cmd=-1;
117 static int hf_broadcast_switch_cmd=-1;
118 static int hf_broadcast_phone_cmd=-1;
119 static int hf_audio_switch_cmd=-1;
120 static int hf_audio_phone_cmd=-1;
121 static int hf_display_switch_cmd=-1;
122 static int hf_display_phone_cmd=-1;
123 static int hf_key_switch_cmd=-1;
124 static int hf_key_phone_cmd=-1;
125 static int hf_network_switch_cmd=-1;
126 static int hf_network_phone_cmd=-1;
127 static int hf_expansion_switch_cmd=-1;
128 static int hf_expansion_phone_cmd=-1;
129
130 static int hf_generic_data=-1;
131 static int hf_generic_string=-1;
132
133 static gint ett_unistim = -1;
134
135 static const value_string packet_names[]={
136    {0,"NAK"},
137    {1,"ACK"},
138    {2,"Payload"},
139    {0,NULL}
140 };
141
142 static const value_string payload_names[]={
143    {0x00,"NULL Protocol"},
144    {0x01,"Aggregate Unistim"},
145    {0x02,"Aggregate Unistim with Terminal ID"},
146    {0x03,"UFTP"},
147    {0xff,"Free Form Protocol"},
148    {0,NULL}
149 };
150
151 static const range_string sequence_numbers[]={
152    {0x00,0xFFFFFFFE,"Normal Sequence Number"},
153    {0xFFFFFFFF,0xFFFFFFFF, "RESET Sequence Number"},
154    {0,0,NULL}
155 };
156
157 static const value_string command_address[]={
158    {0x09,"Expansion Module-1 Manager Switch"},
159    {0x0A,"Expansion Module-2 Manager Switch"},
160    {0x0B,"Expansion Module-3 Manager Switch"},
161    {0x0C,"Expansion Module-4 Manager Switch"},
162    {0x0D,"Expansion Module-5 Manager Switch"},
163    {0x0E,"Expansion Module-6 Manager Switch"},
164    {0x10,"Expansion Module Manager Phone"},
165    {0x11,"Broadcast Manager Switch"},
166    {0x16,"Audio Manager Switch"},
167    {0x17,"Display Manager Switch"},
168    {0x19,"Key/Indicator Manager Switch"},
169    {0x1a,"Basic Manager Switch"},
170    {0x1e,"Network Manager Switch"},
171    {0x89,"Expansion Module-1 Manager Phone"},
172    {0x8A,"Expansion Module-2 Manager Phone"},
173    {0x8B,"Expansion Module-3 Manager Phone"},
174    {0x8C,"Expansion Module-4 Manager Phone"},
175    {0x8D,"Expansion Module-5 Manager Phone"},
176    {0x8E,"Expansion Module-6 Manager Phone"},
177    {0x91,"Broadcast Manager Phone"},
178    {0x96,"Audio Manager Phone"},
179    {0x97,"Display Manager Phone"},
180    {0x99,"Key/Indicator Manager Phone"},
181    {0x9a,"Basic Manager Phone"},
182    {0x9e,"Network Manager Phone"},
183    {0,NULL}
184 };
185
186 static int
187 dissect_unistim(tvbuff_t *tvb,packet_info *pinfo,proto_tree *tree){
188    gint offset=0;
189    proto_item *ti= NULL;
190    proto_item *ti1= NULL;
191    proto_tree *overall_unistim_tree = NULL;
192    proto_tree *rudpm_tree=NULL;
193    gint size;
194
195    /* heuristic*/
196    switch(tvb_get_guint8(tvb,offset+4)) {/*rudp packet type 0,1,2 only */
197       case 0x0:/*NAK*/
198       case 0x1:/*ACK*/
199          break;
200       case 0x2:/*PAYLOAD*/
201          switch(tvb_get_guint8(tvb,offset+5)){/*payload type 0,1,2,3,ff only */
202             case 0x0: /*NULL*/
203             case 0x1: /*UNISTIM*/
204             case 0x2: /*UNISTIM WITH TERM ID*/
205             case 0x3: /*UFTP*/
206             case 0xff:/*UNKNOWN BUT VALID*/
207                break;
208             default:
209                return 0;
210          }
211          break;
212       default:
213          return 0;
214    }
215
216
217    size=tvb_length_remaining(tvb, offset);
218    col_set_str(pinfo->cinfo, COL_PROTOCOL, "UNISTIM");
219    /* Clear out stuff in the info column */
220    col_clear(pinfo->cinfo, COL_INFO);
221    ti = proto_tree_add_item(tree,proto_unistim,tvb,offset,-1,FALSE);
222    overall_unistim_tree = proto_item_add_subtree(ti,ett_unistim);
223    ti1=proto_tree_add_text(overall_unistim_tree,tvb,offset,5,"Reliable UDP");
224    rudpm_tree=proto_item_add_subtree(ti1,ett_unistim);
225
226    proto_tree_add_item(rudpm_tree,hf_unistim_seq_nu,tvb,offset,4,ENC_BIG_ENDIAN);
227
228    /* Allocate new mem for queueing */
229    uinfo = (unistim_info_t *)se_alloc(sizeof(unistim_info_t));
230
231    /* Clear tap struct */
232    uinfo->rudp_type = 0;
233    uinfo->payload_type = 0;
234    uinfo->sequence = tvb_get_ntohl(tvb,offset);
235    uinfo->termid = 0;
236    uinfo->key_val = -1;
237    uinfo->key_state = -1;
238    uinfo->hook_state = -1;
239    uinfo->stream_connect = -1;
240    uinfo->trans_connect = -1;
241    uinfo->set_termid = -1;
242    uinfo->string_data = NULL;
243    uinfo->key_buffer = NULL;
244    SET_ADDRESS(&uinfo->it_ip, AT_NONE, 0, NULL);
245    SET_ADDRESS(&uinfo->ni_ip, AT_NONE, 0, NULL);
246    uinfo->it_port = 0;
247
248    offset+=4;
249    proto_tree_add_item(rudpm_tree,hf_unistim_packet_type,tvb,offset,1,ENC_BIG_ENDIAN);
250    uinfo->rudp_type = tvb_get_guint8(tvb,offset);
251
252    switch(tvb_get_guint8(tvb,offset)) {
253       case 0x00:
254          /*NAK*/
255          col_add_fstr(pinfo->cinfo, COL_INFO, "NAK for seq -   0x%X",
256                       tvb_get_ntohl(tvb, offset-4));
257          break;
258       case 0x01:
259          /*ACK*/
260          col_add_fstr(pinfo->cinfo, COL_INFO, "ACK for seq -   0x%X",
261                       tvb_get_ntohl(tvb, offset-4));
262          break;
263       case 0x02:
264          col_add_fstr(pinfo->cinfo, COL_INFO, "Payload seq -   0x%X",
265                       tvb_get_ntohl(tvb, offset-4));
266          offset+=1;
267          dissect_payload(overall_unistim_tree,tvb,offset,pinfo);
268          break;
269       default:
270          return 0;
271          break;
272    }
273
274    /* Queue packet for tap */
275    tap_queue_packet(unistim_tap, pinfo, uinfo);
276    return size;
277 }
278
279 static void
280 dissect_payload(proto_tree *overall_unistim_tree,tvbuff_t *tvb, gint offset, packet_info *pinfo){
281    proto_item *ti;
282    proto_tree *unistim_tree;
283    guint payload_proto=tvb_get_guint8(tvb,offset);
284
285    /* Payload type for tap */
286    uinfo->payload_type = payload_proto;
287
288    ti=proto_tree_add_item(overall_unistim_tree,hf_unistim_payload,
289                           tvb,offset,1,ENC_BIG_ENDIAN);
290    offset+=1;
291    unistim_tree=proto_item_add_subtree(ti,ett_unistim);
292
293    switch(payload_proto){
294       case 0x00:
295    /*NULL PROTO - NOTHING LEFT TO DO*/
296          return;
297       case 0x01:
298    /*UNISTIM only so no term id but further payload work*/
299          /* Collect info for tap */
300          /* If no term id then packet sourced from NI */
301          COPY_ADDRESS(&(uinfo->ni_ip), &(pinfo->src));
302          COPY_ADDRESS(&(uinfo->it_ip), &(pinfo->dst));
303          uinfo->it_port = pinfo->destport;
304          break;
305       case 0x02:
306    /*UNISTIM with term id*/
307          /* Termid packs are always sourced from the it, so collect relevant infos */
308          COPY_ADDRESS(&(uinfo->ni_ip),&(pinfo->dst));
309          COPY_ADDRESS(&(uinfo->it_ip),&(pinfo->src));
310          uinfo->it_port = pinfo->srcport;
311          uinfo->termid = tvb_get_ntohl(tvb,offset);
312
313          proto_tree_add_item(unistim_tree,hf_terminal_id,tvb,offset,4,ENC_BIG_ENDIAN);
314          offset+=4;
315          break;
316       case 0x03:
317    /* UFTP */
318          offset = dissect_uftp_message(unistim_tree,pinfo,tvb,offset);
319          break;
320       case 0xff:
321    /*TODO flesh this out probably only for init*/
322          break;
323    }
324
325    /* Handle UFTP seperately because it is significantly different
326       than standard UNISTIM */
327    while (tvb_length_remaining(tvb, offset) > 0)
328       offset = dissect_unistim_message(unistim_tree,pinfo,tvb,offset);
329
330 }
331
332 static gint
333 dissect_uftp_message(proto_tree *unistim_tree,packet_info *pinfo _U_,tvbuff_t *tvb,gint offset){
334
335    guint command;
336    guint str_len;
337    guint dat_len;
338    proto_item *ti;
339    proto_tree *msg_tree;
340
341    ti = proto_tree_add_text(unistim_tree,tvb,offset,-1,"UFTP CMD");
342
343    msg_tree = proto_item_add_subtree(ti,ett_unistim);
344
345    command=tvb_get_guint8(tvb,offset);
346
347    proto_tree_add_item(msg_tree,hf_uftp_command,tvb,offset,1,ENC_BIG_ENDIAN);
348
349    offset += 1;
350
351    switch(command)
352    {
353       case 0x80:
354          /* Connection request */
355          /* Nothing to do */
356          break;
357
358       case 0x81:
359          /* Connection Details */
360          /* Get datablock size */
361          proto_tree_add_item(msg_tree,hf_uftp_datablock_size,tvb,offset,2,ENC_BIG_ENDIAN);
362          offset+=2;
363          /* Get datablock limit b4 flow control */
364          proto_tree_add_item(msg_tree,hf_uftp_datablock_limit,tvb,offset,1,ENC_BIG_ENDIAN);
365          offset+=1;
366          /* Get filename */
367          str_len = tvb_length_remaining(tvb, offset);
368          proto_tree_add_item(msg_tree,hf_uftp_filename,tvb,offset,str_len,ENC_ASCII|ENC_NA);
369          offset += str_len;
370          break;
371
372       case 0x82:
373          /* Flow Control off */
374          /* Nothing to do */
375          break;
376
377       case 0x00:
378          /* Connection Granted */
379          /* Nothing to do */
380          break;
381
382       case 0x01:
383          /* Connection Denied */
384          /* Nothing to do */
385          break;
386
387       case 0x02:
388          /* File Data Block */
389          /* Raw Data.. */
390          dat_len = tvb_length_remaining(tvb, offset);
391          proto_tree_add_item(msg_tree,hf_uftp_datablock,tvb,offset,dat_len,ENC_NA);
392          offset += dat_len;
393          break;
394    }
395
396    return offset;
397
398 }
399
400
401 static gint
402 dissect_unistim_message(proto_tree *unistim_tree,packet_info *pinfo,tvbuff_t *tvb,gint offset){
403    guint addr;
404    guint msg_len;
405    proto_item *ti;
406    proto_tree *msg_tree;
407
408    ti = proto_tree_add_text(unistim_tree,tvb,offset,-1,"Unistim CMD");
409
410    msg_tree = proto_item_add_subtree(ti,ett_unistim);
411
412    addr=tvb_get_guint8(tvb,offset);
413
414    proto_tree_add_item(msg_tree,hf_unistim_cmd_add,tvb,offset,1,ENC_BIG_ENDIAN);
415
416    offset+=1;
417    msg_len=tvb_get_guint8(tvb,offset);
418
419    if (msg_len<=2)
420    {
421       ti=proto_tree_add_item(msg_tree,hf_unistim_len,tvb,offset,1,ENC_BIG_ENDIAN);
422       expert_add_info_format(pinfo,ti,PI_MALFORMED,PI_ERROR,"Length too short");
423       return tvb_length(tvb);
424    } else {
425       proto_item_set_len(ti,msg_len);
426       proto_tree_add_item(msg_tree,hf_unistim_len,tvb,offset,1,ENC_BIG_ENDIAN);
427    }
428
429    offset+=1;
430    /*from switch*/
431    switch(addr){
432       case 0x00:
433    /*Nothing*/
434          break;
435    /*Expansion Manager Switch*/
436       case 0x09:
437       case 0x0A:
438       case 0x0B:
439       case 0x0C:
440       case 0x0D:
441       case 0x0E:
442          offset = dissect_expansion_switch(msg_tree,tvb,offset,msg_len-2);
443          break;
444
445       case 0x11:
446    /*Broadcast Manager Switch*/
447          offset = dissect_broadcast_switch(msg_tree,tvb,offset,msg_len-2);
448          break;
449       case 0x16:
450    /*Audio Manager Switch*/
451          offset = dissect_audio_switch(msg_tree,pinfo,tvb,offset,msg_len-2);
452          break;
453       case 0x17:
454    /*Display Manager Switch*/
455          offset = dissect_display_switch(msg_tree,tvb,offset,msg_len-2);
456          break;
457       case 0x19:
458    /*Key Indicator Manager Switch*/
459          offset = dissect_key_indicator_switch(msg_tree,tvb,offset,msg_len-2);
460          break;
461       case 0x1a:
462    /*Basic Manager Switch*/
463          offset = dissect_basic_switch(msg_tree,tvb,offset,msg_len-2);
464          break;
465       case 0x1e:
466    /*Network Manager Switch*/
467          offset = dissect_network_switch(msg_tree,tvb,offset,msg_len-2);
468          break;
469       case 0x89:
470       case 0x8A:
471       case 0x8B:
472       case 0x8C:
473       case 0x8D:
474       case 0x8E:
475    /*Expansion Manager Phone*/
476          offset = dissect_expansion_phone(msg_tree,tvb,offset,msg_len-2);
477          break;
478
479       case 0x91:
480    /*Broadcast Manager phone*/
481          offset = dissect_broadcast_phone(msg_tree,tvb,offset,msg_len-2);
482          break;
483       case 0x96:
484    /*Audio Manager phone*/
485          offset = dissect_audio_phone(msg_tree,tvb,offset,msg_len-2);
486          break;
487       case 0x97:
488    /*Display Manager phone*/
489          offset = dissect_display_phone(msg_tree,tvb,offset,msg_len-2);
490          break;
491       case 0x99:
492    /*Key/Indicator Manager phone*/
493          offset = dissect_key_indicator_phone(msg_tree,tvb,offset,msg_len-2);
494          break;
495       case 0x9a:
496    /*Basic Manager phone*/
497          offset = dissect_basic_phone(msg_tree,tvb,offset,msg_len-2);
498          break;
499       case 0x9e:
500    /*Network Manager Switch*/
501          offset = dissect_network_phone(msg_tree,tvb,offset,msg_len-2);
502          break;
503       default:
504    /*See some undocumented messages.  Don't want to miss the ones we understand*/
505          proto_tree_add_item(msg_tree,hf_generic_data,tvb,offset,msg_len-2,ENC_NA);
506
507          offset+=(msg_len-2);
508    }
509
510    return offset;
511 }
512
513
514    /*DONE*/
515 static gint
516 dissect_basic_phone(proto_tree *msg_tree,
517                     tvbuff_t *tvb,gint offset, guint msg_len){
518    guint basic_cmd;
519
520    basic_cmd=tvb_get_guint8(tvb,offset);
521
522    proto_tree_add_item(msg_tree,hf_basic_phone_cmd,tvb,offset,1,ENC_BIG_ENDIAN);
523
524    offset+=1;msg_len-=1;
525    switch(basic_cmd){
526
527       case 0x00:
528    /*Basic Manager Attributes Info*/
529          proto_tree_add_item(msg_tree,hf_basic_phone_eeprom_stat_cksum,
530                              tvb,offset,1,ENC_BIG_ENDIAN);
531          offset+=1;
532          proto_tree_add_item(msg_tree,hf_basic_phone_eeprom_dynam,
533                              tvb,offset,1,ENC_BIG_ENDIAN);
534          offset+=1;
535          proto_tree_add_item(msg_tree,hf_basic_phone_eeprom_net_config_cksum,
536                              tvb,offset,1,ENC_BIG_ENDIAN);
537          offset+=1;
538          break;
539       case 0x01:
540    /*Basic Manager Options Report*/
541          proto_tree_add_item(msg_tree,hf_basic_switch_options_secure,
542                              tvb,offset,1,ENC_BIG_ENDIAN);
543          offset+=1;
544          break;
545       case 0x02:
546    /*Firmware Version*/
547          proto_tree_add_item(msg_tree,hf_basic_phone_fw_ver,
548                              tvb,offset,msg_len,ENC_ASCII|ENC_NA);
549          offset+=msg_len;
550          break;
551       case 0x03:
552    /*IT Type*/
553          proto_tree_add_item(msg_tree,hf_basic_it_type,tvb,offset,1,ENC_BIG_ENDIAN);
554          offset+=1;
555          break;
556       case 0x07:
557    /*Hardware ID*/
558          proto_tree_add_item(msg_tree,hf_basic_phone_hw_id,
559                              tvb,offset,msg_len,ENC_NA);
560          offset+=msg_len;
561          break;
562       case 0x08:
563    /*Product Engineering Code*/
564          proto_tree_add_item(msg_tree,hf_basic_prod_eng_code,
565                              tvb,offset,msg_len,ENC_ASCII|ENC_NA);
566          offset+=msg_len;
567          break;
568       case 0x09:
569    /*Grey Market Info*/
570          proto_tree_add_item(msg_tree,hf_generic_data,tvb,offset,msg_len,ENC_NA);
571          offset+=msg_len;
572          break;
573       case 0x0a:
574    /*Encapsulate Command*/
575          proto_tree_add_item(msg_tree,hf_generic_data,tvb,offset,msg_len,ENC_NA);
576          offset+=msg_len;
577          break;
578       case 0x11:
579    /*Phone Ethernet address*/
580          proto_tree_add_item(msg_tree,hf_basic_ether_address,
581                              tvb,offset,msg_len,ENC_NA);
582          offset+=msg_len;
583          break;
584       case 0x0b:
585    /*not in pdf but get them*/
586          set_ascii_item(msg_tree,tvb,offset,msg_len);
587          offset+=msg_len;
588          break;
589       case 0xff:
590    /*Reserved*/
591          break;
592       default:
593          proto_tree_add_item(msg_tree,hf_generic_data,tvb,offset,msg_len,ENC_NA);
594          offset+=msg_len;
595    }
596
597    return offset;
598 }
599    /*DONE*/
600 static gint
601 dissect_basic_switch(proto_tree *msg_tree,
602                      tvbuff_t *tvb,gint offset,guint msg_len){
603    guint basic_cmd;
604    basic_cmd=tvb_get_guint8(tvb,offset);
605    proto_tree_add_item(msg_tree,hf_basic_switch_cmd,tvb,offset,1,ENC_BIG_ENDIAN);
606    offset+=1;msg_len-=1;
607    switch(basic_cmd){
608       case 0x01:
609    /*Query Basic Manager*/
610          proto_tree_add_item(msg_tree,hf_basic_bit_field,tvb,offset,1,ENC_BIG_ENDIAN);
611          proto_tree_add_item(msg_tree,hf_basic_switch_query_attr,
612                              tvb,offset,1,ENC_BIG_ENDIAN);
613          proto_tree_add_item(msg_tree,hf_basic_switch_query_opts,
614                              tvb,offset,1,ENC_BIG_ENDIAN);
615          proto_tree_add_item(msg_tree,hf_basic_switch_query_fw,
616                              tvb,offset,1,ENC_BIG_ENDIAN);
617          proto_tree_add_item(msg_tree,hf_basic_switch_query_hw_id,
618                              tvb,offset,1,ENC_BIG_ENDIAN);
619          proto_tree_add_item(msg_tree,hf_basic_switch_query_it_type,
620                              tvb,offset,1,ENC_BIG_ENDIAN);
621          proto_tree_add_item(msg_tree,hf_basic_switch_query_prod_eng_code,
622                              tvb,offset,1,ENC_BIG_ENDIAN);
623          proto_tree_add_item(msg_tree,hf_basic_switch_query_gray_mkt_info,
624                              tvb,offset,1,ENC_BIG_ENDIAN);
625          offset+=1;
626          break;
627       case 0x02:
628    /*Basic Manager Options*/
629          proto_tree_add_item(msg_tree,hf_basic_switch_options_secure,
630                              tvb,offset,1,ENC_BIG_ENDIAN);
631          offset+=1;
632          break;
633       case 0x06:
634    /*EEprom Write*/
635          proto_tree_add_item(msg_tree,hf_basic_switch_element_id,
636                              tvb,offset,1,ENC_BIG_ENDIAN);
637          offset+=1;
638          proto_tree_add_item(msg_tree,hf_basic_switch_eeprom_data,
639                              tvb,offset,msg_len,ENC_NA);
640          offset+=1;
641          break;
642       case 0x07:
643    /*Assign Terminal ID*/
644          /* Set tap info */
645          uinfo->set_termid = 1;
646
647          proto_tree_add_item(msg_tree,hf_basic_switch_terminal_id,
648                              tvb,offset,msg_len,ENC_BIG_ENDIAN);
649          offset+=msg_len;
650          break;
651       case 0x08:
652    /*Encapsulate Command*/
653          proto_tree_add_item(msg_tree,hf_generic_data,tvb,offset,msg_len,ENC_NA);
654          offset+=msg_len;
655          break;
656       case 0x0f:
657    /*showing up in captures but not in pdf*/
658          proto_tree_add_item(msg_tree,hf_generic_data,tvb,offset,msg_len,ENC_NA);
659          offset+=msg_len;
660       case 0xff:
661    /*Reserved*/
662          break;
663       default:
664          proto_tree_add_item(msg_tree,hf_generic_data,tvb,offset,msg_len,ENC_NA);
665          offset+=msg_len;
666
667    }
668
669    return offset;
670 }
671
672
673    /*DONE*/
674 static gint
675 dissect_broadcast_switch(proto_tree *msg_tree,
676                          tvbuff_t *tvb,gint offset, guint msg_len){
677    guint bcast_cmd;
678    guint year,month,day,hour,minute,second;
679    proto_item *date_label;
680    proto_item *time_label;
681    proto_tree *date_tree;
682    proto_tree *time_tree;
683    bcast_cmd=tvb_get_guint8(tvb,offset);
684    proto_tree_add_item(msg_tree,hf_broadcast_switch_cmd,tvb,offset,1,ENC_BIG_ENDIAN);
685    offset+=1;msg_len-=1;
686    switch(bcast_cmd){
687       case 0x00:
688    /*Accessory Sync Update   -   len=3 */
689          break;
690       case 0x01:
691    /*Logical Icon Update*/
692          proto_tree_add_item(msg_tree,hf_basic_bit_field,
693                              tvb,offset,1,ENC_BIG_ENDIAN);
694          proto_tree_add_item(msg_tree,hf_broadcast_icon_state,
695                              tvb,offset,1,ENC_BIG_ENDIAN);
696          proto_tree_add_item(msg_tree,hf_broadcast_icon_cadence,
697                              tvb,offset,1,ENC_BIG_ENDIAN);
698          offset+=1;
699          break;
700       case 0x02:
701    /*Time and Date Download*/
702          year=tvb_get_guint8(tvb,offset);
703          month=tvb_get_guint8(tvb,offset+1);
704          day=tvb_get_guint8(tvb,offset+2);
705          hour=tvb_get_guint8(tvb,offset+3);
706          minute=tvb_get_guint8(tvb,offset+4);
707          second=tvb_get_guint8(tvb,offset+5);
708          date_label=proto_tree_add_text(msg_tree,tvb,offset,3,
709                                         "Date %i/%i/%i",month,day,year%100);
710          date_tree=proto_item_add_subtree(date_label,ett_unistim);
711          proto_tree_add_item(date_tree,hf_broadcast_year,tvb,offset,1,ENC_BIG_ENDIAN);
712          offset+=1;
713          proto_tree_add_item(date_tree,hf_broadcast_month,tvb,offset,1,ENC_BIG_ENDIAN);
714          offset+=1;
715          proto_tree_add_item(date_tree,hf_broadcast_day,tvb,offset,1,ENC_BIG_ENDIAN);
716          offset+=1;
717
718          time_label=proto_tree_add_text(msg_tree,tvb,offset,3,
719                                         "Time %i:%i:%i",hour,minute,second);
720          time_tree=proto_item_add_subtree(time_label,ett_unistim);
721          proto_tree_add_item(time_tree,hf_broadcast_hour,tvb,offset,1,ENC_BIG_ENDIAN);
722          offset+=1;
723          proto_tree_add_item(time_tree,hf_broadcast_minute,tvb,offset,1,ENC_BIG_ENDIAN);
724          offset+=1;
725          proto_tree_add_item(time_tree,hf_broadcast_second,tvb,offset,1,ENC_BIG_ENDIAN);
726          offset+=1;
727          break;
728       case 0x03:
729    /*Set Default Character Table Config */
730          /* UGLY may work may not*/
731          proto_tree_add_item(msg_tree,hf_generic_data,tvb,offset,msg_len,ENC_NA);
732          offset+=msg_len;
733          break;
734       case 0xff:
735    /*Reserved*/
736          break;
737       default:
738          proto_tree_add_item(msg_tree,hf_generic_data,tvb,offset,msg_len,ENC_NA);
739          offset+=msg_len;
740    }
741
742    return offset;
743 }
744    /*DONE Haven't seen any phone broadcasts, wouldn't expect to*/
745 static gint
746 dissect_broadcast_phone(proto_tree *msg_tree,
747                         tvbuff_t *tvb, gint offset,guint msg_len){
748
749    proto_tree_add_item(msg_tree,hf_generic_data, tvb,offset,msg_len,ENC_NA);
750    offset+=msg_len;
751
752    return offset;
753 }
754
755    /*DONE*/
756 static gint
757 dissect_display_switch(proto_tree *msg_tree,
758                        tvbuff_t *tvb, gint offset,guint msg_len){
759    guint clear_mask;
760    guint highlight_cmd;
761    guint time_date_mask;
762    guint display_cmd;
763    guint address_byte;
764    guint movement_byte;
765    proto_tree *address_tree;
766    proto_item *tmp_ti;
767    display_cmd=tvb_get_guint8(tvb,offset);
768    proto_tree_add_item(msg_tree,hf_display_switch_cmd,tvb,offset,1,ENC_BIG_ENDIAN);
769    offset+=1;msg_len-=1;
770
771    switch(display_cmd){
772       case 0x01:
773    /*Restore Default Character Table Configuration length = 3*/
774          break;
775       case 0x04:
776    /*Arrow*/
777          proto_tree_add_item(msg_tree,hf_display_arrow,tvb,offset,1,ENC_BIG_ENDIAN);
778          offset+=1;
779          break;
780       case 0x05:
781    /*Query Status Bar Icon*/
782          proto_tree_add_item(msg_tree,hf_generic_data,tvb,offset,msg_len,ENC_NA);
783          offset+=msg_len;
784          break;
785       case 0x06:
786    /*Highlight Off length = 3*/
787          break;
788       case 0x07:
789    /*Highlight On length = 3*/
790          break;
791       case 0x09:
792    /*Restore Time and Date length  = 3*/
793          break;
794       case 0x0a:
795    /*Clear Time and Date length  = 3*/
796          break;
797       case 0x0b:
798    /*Call Duration Timer*/
799          proto_tree_add_item(msg_tree,hf_basic_bit_field,tvb,offset,1,ENC_BIG_ENDIAN);
800          proto_tree_add_item(msg_tree,hf_display_call_timer_mode,tvb,offset,
801                              1,ENC_BIG_ENDIAN);
802          proto_tree_add_item(msg_tree,hf_display_call_timer_reset,tvb,offset,
803                              1,ENC_BIG_ENDIAN);
804          proto_tree_add_item(msg_tree,hf_display_call_timer_display,tvb,offset,
805                              1,ENC_BIG_ENDIAN);
806          proto_tree_add_item(msg_tree,hf_display_call_timer_delay,tvb,offset,
807                              1,ENC_BIG_ENDIAN);
808          offset+=1;msg_len-=1;
809          proto_tree_add_item(msg_tree,hf_display_call_timer_id,tvb,offset,
810                              1,ENC_BIG_ENDIAN);
811          offset+=1;msg_len-=1;
812          break;
813       case 0x0c:
814    /*Query Display Manager*/
815          proto_tree_add_item(msg_tree,hf_generic_data,tvb,offset,msg_len,ENC_NA);
816          offset+=msg_len;
817          break;
818       case 0x0d:
819    /*Download Call Duration Timer Delay*/
820          proto_tree_add_item(msg_tree,hf_generic_data,tvb,offset,msg_len,ENC_NA);
821          offset+=msg_len;
822          break;
823       case 0x0e:
824    /*Disable Display Field*/
825          proto_tree_add_item(msg_tree,hf_generic_data,tvb,offset,msg_len,ENC_NA);
826          offset+=msg_len;
827          break;
828       case 0x0f:
829    /*Clear Field*/
830          clear_mask=tvb_get_guint8(tvb,offset);
831    /*need to know which paths to take*/
832          proto_tree_add_item(msg_tree,hf_basic_bit_field,tvb,offset,1,ENC_BIG_ENDIAN);
833          proto_tree_add_item(msg_tree,hf_display_clear_numeric,
834                              tvb,offset,1,ENC_BIG_ENDIAN);
835          proto_tree_add_item(msg_tree,hf_display_clear_context,
836                              tvb,offset,1,ENC_BIG_ENDIAN);
837          proto_tree_add_item(msg_tree,hf_display_clear_date,
838                              tvb,offset,1,ENC_BIG_ENDIAN);
839
840          proto_tree_add_item(msg_tree,hf_display_clear_time,
841                              tvb,offset,1,ENC_BIG_ENDIAN);
842          proto_tree_add_item(msg_tree,hf_display_clear_line,
843                              tvb,offset,1,ENC_BIG_ENDIAN);
844          proto_tree_add_item(msg_tree,hf_display_clear_status_bar_icon,
845                              tvb,offset,1,ENC_BIG_ENDIAN);
846          proto_tree_add_item(msg_tree,hf_display_clear_softkey,
847                              tvb,offset,1,ENC_BIG_ENDIAN);
848          proto_tree_add_item(msg_tree,hf_display_clear_softkey_label,
849                              tvb,offset,1,ENC_BIG_ENDIAN);
850          offset+=1;msg_len-=1;
851          if((clear_mask&DISPLAY_CLEAR_LINE)==DISPLAY_CLEAR_LINE){
852             proto_tree_add_item(msg_tree,hf_basic_bit_field,tvb,offset,1,ENC_BIG_ENDIAN);
853             proto_tree_add_item(msg_tree,hf_display_clear_line_1,
854                                 tvb,offset,1,ENC_BIG_ENDIAN);
855             proto_tree_add_item(msg_tree,hf_display_clear_line_2,
856                                 tvb,offset,1,ENC_BIG_ENDIAN);
857             proto_tree_add_item(msg_tree,hf_display_clear_line_3,
858                                 tvb,offset,1,ENC_BIG_ENDIAN);
859             proto_tree_add_item(msg_tree,hf_display_clear_line_4,
860                                 tvb,offset,1,ENC_BIG_ENDIAN);
861             proto_tree_add_item(msg_tree,hf_display_clear_line_5,
862                                 tvb,offset,1,ENC_BIG_ENDIAN);
863             proto_tree_add_item(msg_tree,hf_display_clear_line_6,
864                                 tvb,offset,1,ENC_BIG_ENDIAN);
865             proto_tree_add_item(msg_tree,hf_display_clear_line_7,
866                                 tvb,offset,1,ENC_BIG_ENDIAN);
867             proto_tree_add_item(msg_tree,hf_display_clear_line_8,
868                                 tvb,offset,1,ENC_BIG_ENDIAN);
869             offset+=1;msg_len-=1;
870          }
871          if((clear_mask&DISPLAY_CLEAR_STATUS_BAR_ICON)==
872                         DISPLAY_CLEAR_STATUS_BAR_ICON){
873             proto_tree_add_item(msg_tree,hf_basic_bit_field,tvb,offset,1,ENC_BIG_ENDIAN);
874             proto_tree_add_item(msg_tree,hf_display_clear_status_bar_icon_1,
875                                 tvb,offset,1,ENC_BIG_ENDIAN);
876             proto_tree_add_item(msg_tree,hf_display_clear_status_bar_icon_2,
877                                 tvb,offset,1,ENC_BIG_ENDIAN);
878             proto_tree_add_item(msg_tree,hf_display_clear_status_bar_icon_3,
879                                 tvb,offset,1,ENC_BIG_ENDIAN);
880             proto_tree_add_item(msg_tree,hf_display_clear_status_bar_icon_4,
881                                 tvb,offset,1,ENC_BIG_ENDIAN);
882             proto_tree_add_item(msg_tree,hf_display_clear_status_bar_icon_5,
883                                 tvb,offset,1,ENC_BIG_ENDIAN);
884             proto_tree_add_item(msg_tree,hf_display_clear_status_bar_icon_6,
885                                 tvb,offset,1,ENC_BIG_ENDIAN);
886             proto_tree_add_item(msg_tree,hf_display_clear_status_bar_icon_7,
887                                 tvb,offset,1,ENC_BIG_ENDIAN);
888             proto_tree_add_item(msg_tree,hf_display_clear_status_bar_icon_8,
889                                 tvb,offset,1,ENC_BIG_ENDIAN);
890             offset+=1;msg_len-=1;
891          }
892          if((clear_mask&DISPLAY_CLEAR_SOFTKEY)==DISPLAY_CLEAR_SOFTKEY){
893             proto_tree_add_item(msg_tree,hf_basic_bit_field,tvb,offset,1,ENC_BIG_ENDIAN);
894             proto_tree_add_item(msg_tree,hf_display_clear_soft_key_1,
895                                 tvb,offset,1,ENC_BIG_ENDIAN);
896             proto_tree_add_item(msg_tree,hf_display_clear_soft_key_2,
897                                 tvb,offset,1,ENC_BIG_ENDIAN);
898             proto_tree_add_item(msg_tree,hf_display_clear_soft_key_3,
899                                 tvb,offset,1,ENC_BIG_ENDIAN);
900             proto_tree_add_item(msg_tree,hf_display_clear_soft_key_4,
901                                 tvb,offset,1,ENC_BIG_ENDIAN);
902             proto_tree_add_item(msg_tree,hf_display_clear_soft_key_5,
903                                 tvb,offset,1,ENC_BIG_ENDIAN);
904             proto_tree_add_item(msg_tree,hf_display_clear_soft_key_6,
905                                 tvb,offset,1,ENC_BIG_ENDIAN);
906             proto_tree_add_item(msg_tree,hf_display_clear_soft_key_7,
907                                 tvb,offset,1,ENC_BIG_ENDIAN);
908             proto_tree_add_item(msg_tree,hf_display_clear_soft_key_8,
909                                 tvb,offset,1,ENC_BIG_ENDIAN);
910             offset+=1;msg_len-=1;
911          }
912          if((clear_mask&DISPLAY_CLEAR_SOFTKEY_LABEL)==DISPLAY_CLEAR_SOFTKEY_LABEL){
913             proto_tree_add_item(msg_tree,hf_basic_bit_field,tvb,offset,1,ENC_BIG_ENDIAN);
914             proto_tree_add_item(msg_tree,hf_display_clear_sk_label_key_id,tvb,offset,1,ENC_BIG_ENDIAN);
915             proto_tree_add_item(msg_tree,hf_display_clear_all_slks,tvb,offset,1,ENC_BIG_ENDIAN);
916             offset+=1;msg_len-=1;
917          }
918          break;
919       case 0x10:
920    /*Cursor Control*/
921          movement_byte=tvb_get_guint8(tvb,offset);
922          proto_tree_add_item(msg_tree,hf_basic_bit_field,tvb,offset,1,ENC_BIG_ENDIAN);
923          proto_tree_add_item(msg_tree,hf_display_cursor_move_cmd,tvb,offset,1,ENC_BIG_ENDIAN);
924          proto_tree_add_item(msg_tree,hf_display_cursor_blink,tvb,offset,1,ENC_BIG_ENDIAN);
925          offset+=1;msg_len-=1;
926          if(msg_len==0){
927    /*turn cursor off*/
928             break;
929          }
930          if((movement_byte&0x01)==0x01){
931             address_byte=tvb_get_guint8(tvb,offset);
932             proto_tree_add_item(msg_tree,hf_basic_bit_field,tvb,offset,1,ENC_BIG_ENDIAN);
933             proto_tree_add_item(msg_tree,hf_display_write_address_numeric,
934                                 tvb,offset,1,ENC_BIG_ENDIAN);
935             proto_tree_add_item(msg_tree,hf_display_write_address_context,
936                                 tvb,offset,1,ENC_BIG_ENDIAN);
937             proto_tree_add_item(msg_tree,hf_display_write_address_line,
938                                 tvb,offset,1,ENC_BIG_ENDIAN);
939             proto_tree_add_item(msg_tree,hf_display_write_address_soft_key,
940                                 tvb,offset,1,ENC_BIG_ENDIAN);
941             if((address_byte&DISPLAY_WRITE_ADDRESS_SOFT_KEY_FLAG)==
942                              DISPLAY_WRITE_ADDRESS_SOFT_KEY_FLAG)
943                proto_tree_add_item(msg_tree,
944                                    hf_display_write_address_softkey_id,
945                                    tvb,offset,1,ENC_BIG_ENDIAN);
946             offset+=1;msg_len-=1;
947             if(msg_len==0){
948    /*turn cursor off*/
949                break;
950             }
951          }
952          proto_tree_add_item(msg_tree,hf_basic_bit_field,tvb,offset,1,ENC_BIG_ENDIAN);
953          proto_tree_add_item(msg_tree,hf_display_write_address_char_pos,
954                              tvb,offset,1,ENC_BIG_ENDIAN);
955          proto_tree_add_item(msg_tree,hf_display_write_address_line_number,
956                              tvb,offset,1,ENC_BIG_ENDIAN);
957          offset+=1;msg_len-=1;
958          break;
959       case 0x12:
960    /*Display Scroll with Data (before)*/
961          set_ascii_item(msg_tree,tvb,offset,msg_len);
962          offset+=msg_len;
963          break;
964       case 0x13:
965    /*Display Scroll with Data (after)*/
966          set_ascii_item(msg_tree,tvb,offset,msg_len);
967          offset+=msg_len;
968          break;
969       case 0x14:
970    /*Status Bar Icon Update*/
971          proto_tree_add_item(msg_tree,hf_basic_bit_field, tvb,offset,1,ENC_BIG_ENDIAN);
972          proto_tree_add_item(msg_tree,hf_icon_id,tvb,offset,1,ENC_BIG_ENDIAN);
973          offset+=1;
974          proto_tree_add_item(msg_tree,hf_basic_bit_field, tvb,offset,1,ENC_BIG_ENDIAN);
975          proto_tree_add_item(msg_tree,hf_broadcast_icon_state,
976                              tvb,offset,1,ENC_BIG_ENDIAN);
977          proto_tree_add_item(msg_tree,hf_broadcast_icon_cadence,
978                              tvb,offset,1,ENC_BIG_ENDIAN);
979          offset+=1;
980          break;
981       case 0x15:
982    /*Month Labels Download*/
983          set_ascii_item(msg_tree,tvb,offset,msg_len);
984          offset+=msg_len;
985          break;
986       case 0x16:
987    /*Call Duration Timer Label Download*/
988          set_ascii_item(msg_tree,tvb,offset,msg_len);
989          offset+=1;msg_len-=1;
990          break;
991       case 0x17:
992    /*Time and Date Format*/
993          time_date_mask=tvb_get_guint8(tvb,offset);
994          if((time_date_mask&DISPLAY_USE_TIME_FORMAT)==DISPLAY_USE_TIME_FORMAT){
995             proto_tree_add_item(msg_tree,hf_display_time_format,tvb,offset,1,ENC_BIG_ENDIAN);
996          }
997          if((time_date_mask&DISPLAY_USE_DATE_FORMAT)==DISPLAY_USE_DATE_FORMAT){
998             proto_tree_add_item(msg_tree,hf_display_date_format,tvb,offset,1,ENC_BIG_ENDIAN);
999          }
1000          proto_tree_add_item(msg_tree,hf_display_use_time_format,tvb,offset,1,ENC_BIG_ENDIAN);
1001          proto_tree_add_item(msg_tree,hf_display_use_date_format,tvb,offset,1,ENC_BIG_ENDIAN);
1002          offset+=1;msg_len-=1;
1003          break;
1004       case 0x18:
1005    /*address|no control|no tag|no*/
1006          set_ascii_item(msg_tree,tvb,offset,msg_len);
1007          offset+=msg_len;
1008          break;
1009       case 0x19:
1010    /*address|yes control|no tag|no*/
1011          tmp_ti=proto_tree_add_text(msg_tree,tvb,offset,0,"Address");
1012
1013          address_tree=proto_item_add_subtree(tmp_ti,ett_unistim);
1014          address_byte=tvb_get_guint8(tvb,offset);
1015          proto_tree_add_item(address_tree,hf_basic_bit_field,
1016                              tvb,offset,1,ENC_BIG_ENDIAN);
1017          proto_tree_add_item(address_tree,hf_display_write_address_numeric,
1018                              tvb,offset,1,ENC_BIG_ENDIAN);
1019          proto_tree_add_item(address_tree,hf_display_write_address_context,
1020                              tvb,offset,1,ENC_BIG_ENDIAN);
1021          proto_tree_add_item(address_tree,hf_display_write_address_line,
1022                              tvb,offset,1,ENC_BIG_ENDIAN);
1023          proto_tree_add_item(address_tree,hf_display_write_address_soft_key,
1024                              tvb,offset,1,ENC_BIG_ENDIAN);
1025          proto_tree_add_item(address_tree,hf_display_write_address_soft_label,
1026                              tvb,offset,1,ENC_BIG_ENDIAN);
1027
1028          if((address_byte&DISPLAY_WRITE_ADDRESS_SOFT_KEY_FLAG)==
1029                           DISPLAY_WRITE_ADDRESS_SOFT_KEY_FLAG){
1030             proto_tree_add_item(address_tree,
1031                                 hf_display_write_address_softkey_id,
1032                                 tvb,offset,1,ENC_BIG_ENDIAN);
1033          }
1034          offset+=1;msg_len-=1;
1035          if((address_byte&DISPLAY_WRITE_ADDRESS_SOFT_LABEL_FLAG)==
1036              DISPLAY_WRITE_ADDRESS_SOFT_LABEL_FLAG){
1037             proto_tree_add_item(address_tree,hf_basic_bit_field,tvb,offset,1,ENC_BIG_ENDIAN);
1038             proto_tree_add_item(address_tree,
1039                                 hf_display_write_address_char_pos,
1040                                 tvb,offset,1,ENC_BIG_ENDIAN);
1041             if((address_byte&DISPLAY_WRITE_ADDRESS_LINE_FLAG)!=
1042                              DISPLAY_WRITE_ADDRESS_LINE_FLAG){
1043                offset+=1;msg_len-=1;
1044             }
1045          }
1046          if((address_byte&DISPLAY_WRITE_ADDRESS_LINE_FLAG)==
1047              DISPLAY_WRITE_ADDRESS_LINE_FLAG){
1048             proto_tree_add_item(address_tree,
1049                                 hf_display_write_address_line_number,
1050                                 tvb,offset,1,ENC_BIG_ENDIAN);
1051             offset+=1;msg_len-=1;
1052          }
1053          if(msg_len>0){
1054             /* I'm guessing this will work flakily at best */
1055             uinfo->string_data = tvb_get_string(tvb,offset,msg_len);
1056             set_ascii_item(msg_tree,tvb,offset,msg_len);
1057          }
1058
1059          offset+=msg_len;
1060          break;
1061       case 0x1a:
1062    /*address|no control|yes tag|no*/
1063          proto_tree_add_item(msg_tree,hf_basic_bit_field,tvb,offset,1,ENC_BIG_ENDIAN);
1064          proto_tree_add_item(msg_tree,hf_display_write_cursor_move,
1065                              tvb,offset,1,ENC_BIG_ENDIAN);
1066          proto_tree_add_item(msg_tree,hf_display_write_clear_left,
1067                              tvb,offset,1,ENC_BIG_ENDIAN);
1068          proto_tree_add_item(msg_tree,hf_display_write_clear_right,
1069                              tvb,offset,1,ENC_BIG_ENDIAN);
1070          proto_tree_add_item(msg_tree,hf_display_write_shift_left,
1071                              tvb,offset,1,ENC_BIG_ENDIAN);
1072          proto_tree_add_item(msg_tree,hf_display_write_shift_right,
1073                              tvb,offset,1,ENC_BIG_ENDIAN);
1074          proto_tree_add_item(msg_tree,hf_display_write_highlight,
1075                              tvb,offset,1,ENC_BIG_ENDIAN);
1076          offset+=1;msg_len-=1;
1077          set_ascii_item(msg_tree,tvb,offset,msg_len);
1078          offset+=msg_len;
1079          proto_tree_add_item(msg_tree,hf_generic_string,
1080                              tvb,offset,msg_len,ENC_ASCII|ENC_NA);
1081          offset+=msg_len;
1082          break;
1083       case 0x1b:
1084    /*address|yes control|yes tag|no*/
1085          tmp_ti=proto_tree_add_text(msg_tree,tvb,offset,0,"Address Data");
1086          address_tree=proto_item_add_subtree(tmp_ti,ett_unistim);
1087          address_byte=tvb_get_guint8(tvb,offset);
1088          proto_tree_add_item(address_tree,hf_basic_bit_field,tvb,offset,1,ENC_BIG_ENDIAN);
1089          proto_tree_add_item(address_tree,
1090                              hf_display_write_address_numeric,
1091                              tvb,offset,1,ENC_BIG_ENDIAN);
1092          proto_tree_add_item(address_tree,
1093                              hf_display_write_address_context,
1094                              tvb,offset,1,ENC_BIG_ENDIAN);
1095          proto_tree_add_item(address_tree,
1096                              hf_display_write_address_line,
1097                              tvb,offset,1,ENC_BIG_ENDIAN);
1098          proto_tree_add_item(address_tree,
1099                              hf_display_write_address_soft_key,
1100                              tvb,offset,1,ENC_BIG_ENDIAN);
1101          proto_tree_add_item(address_tree,
1102                              hf_display_write_address_soft_label,
1103                              tvb,offset,1,ENC_BIG_ENDIAN);
1104          if((address_byte&DISPLAY_WRITE_ADDRESS_SOFT_KEY_FLAG)==
1105                           DISPLAY_WRITE_ADDRESS_SOFT_KEY_FLAG){
1106             proto_tree_add_item(address_tree,hf_display_write_address_softkey_id,
1107                                 tvb,offset,1,ENC_BIG_ENDIAN);
1108             offset+=1; msg_len-=1;
1109          }
1110          if((address_byte&DISPLAY_WRITE_ADDRESS_SOFT_LABEL_FLAG)==
1111                           DISPLAY_WRITE_ADDRESS_SOFT_LABEL_FLAG){
1112             proto_tree_add_item(address_tree,
1113                                 hf_display_write_address_char_pos,
1114                                 tvb,offset,1,ENC_BIG_ENDIAN);
1115             if((address_byte&DISPLAY_WRITE_ADDRESS_LINE_FLAG)!=
1116                              DISPLAY_WRITE_ADDRESS_LINE_FLAG)
1117                offset+=1;msg_len-=1;
1118          }
1119          if((address_byte&DISPLAY_WRITE_ADDRESS_LINE_FLAG)==
1120                           DISPLAY_WRITE_ADDRESS_LINE_FLAG){
1121             proto_tree_add_item(address_tree,
1122                                 hf_display_write_address_line_number,
1123                                 tvb,offset,1,ENC_BIG_ENDIAN);
1124             offset+=1;msg_len-=1;
1125          }
1126          proto_tree_add_item(msg_tree,hf_basic_bit_field,tvb,offset,1,ENC_BIG_ENDIAN);
1127          proto_tree_add_item(msg_tree,hf_display_write_cursor_move,
1128                              tvb,offset,1,ENC_BIG_ENDIAN);
1129          proto_tree_add_item(msg_tree,hf_display_write_clear_left,
1130                              tvb,offset,1,ENC_BIG_ENDIAN);
1131          proto_tree_add_item(msg_tree,hf_display_write_clear_right,
1132                              tvb,offset,1,ENC_BIG_ENDIAN);
1133          proto_tree_add_item(msg_tree,hf_display_write_shift_left,
1134                              tvb,offset,1,ENC_BIG_ENDIAN);
1135          proto_tree_add_item(msg_tree,hf_display_write_shift_right,
1136                              tvb,offset,1,ENC_BIG_ENDIAN);
1137          proto_tree_add_item(msg_tree,hf_display_write_highlight,
1138                              tvb,offset,1,ENC_BIG_ENDIAN);
1139          offset+=1;msg_len-=1;
1140          set_ascii_item(msg_tree,tvb,offset,msg_len);
1141          offset+=msg_len;
1142          break;
1143       case 0x1c:
1144    /*address|no control|no tag|yes*/
1145          proto_tree_add_item(msg_tree,hf_display_write_tag,tvb,offset,1,ENC_BIG_ENDIAN);
1146          offset+=1;msg_len-=1;
1147          set_ascii_item(msg_tree,tvb,offset,msg_len);
1148          offset+=msg_len;
1149          break;
1150       case 0x1d:
1151    /*address|yes control|no tag|yes*/
1152          tmp_ti=proto_tree_add_text(msg_tree,tvb,offset,0,"Address Data");
1153          address_tree=proto_item_add_subtree(tmp_ti,ett_unistim);
1154          address_byte=tvb_get_guint8(tvb,offset);
1155          proto_tree_add_item(address_tree,hf_basic_bit_field,tvb,offset,1,ENC_BIG_ENDIAN);
1156          proto_tree_add_item(address_tree,hf_display_write_address_numeric,tvb,
1157                              offset,1,ENC_BIG_ENDIAN);
1158          proto_tree_add_item(address_tree,hf_display_write_address_context,
1159                              tvb,offset,1,ENC_BIG_ENDIAN);
1160          proto_tree_add_item(address_tree,hf_display_write_address_line,
1161                              tvb,offset,1,ENC_BIG_ENDIAN);
1162          proto_tree_add_item(address_tree,hf_display_write_address_soft_key,
1163                              tvb,offset,1,ENC_BIG_ENDIAN);
1164          proto_tree_add_item(address_tree,hf_display_write_address_soft_label,
1165                              tvb,offset,1,ENC_BIG_ENDIAN);
1166          if((address_byte&DISPLAY_WRITE_ADDRESS_SOFT_KEY_FLAG)==
1167              DISPLAY_WRITE_ADDRESS_SOFT_KEY_FLAG)
1168             proto_tree_add_item(address_tree,
1169                                 hf_display_write_address_softkey_id,
1170                                 tvb,offset,1,ENC_BIG_ENDIAN);
1171          offset+=1; msg_len-=1;
1172          if((address_byte&DISPLAY_WRITE_ADDRESS_SOFT_LABEL_FLAG)==
1173              DISPLAY_WRITE_ADDRESS_SOFT_LABEL_FLAG){
1174             proto_tree_add_item(address_tree,
1175                                 hf_display_write_address_char_pos,
1176                                 tvb,offset,1,ENC_BIG_ENDIAN);
1177             if((address_byte&DISPLAY_WRITE_ADDRESS_LINE_FLAG)!=
1178                 DISPLAY_WRITE_ADDRESS_LINE_FLAG)
1179                offset+=1;msg_len-=1;
1180          }
1181          if((address_byte&DISPLAY_WRITE_ADDRESS_LINE_FLAG)==
1182              DISPLAY_WRITE_ADDRESS_LINE_FLAG){
1183             proto_tree_add_item(address_tree,hf_display_write_address_line_number,
1184                                 tvb,offset,1,ENC_BIG_ENDIAN);
1185             offset+=1;msg_len-=1;
1186          }
1187          set_ascii_item(msg_tree,tvb,offset,msg_len);
1188          offset+=msg_len;
1189          break;
1190       case 0x1e:
1191    /*address|no control|yes tag|yes*/
1192          proto_tree_add_item(msg_tree,hf_basic_bit_field,tvb,offset,1,ENC_BIG_ENDIAN);
1193          proto_tree_add_item(msg_tree,hf_display_write_cursor_move,
1194                              tvb,offset,1,ENC_BIG_ENDIAN);
1195          proto_tree_add_item(msg_tree,hf_display_write_clear_left,
1196                              tvb,offset,1,ENC_BIG_ENDIAN);
1197          proto_tree_add_item(msg_tree,hf_display_write_clear_right,
1198                              tvb,offset,1,ENC_BIG_ENDIAN);
1199          proto_tree_add_item(msg_tree,hf_display_write_shift_left,
1200                              tvb,offset,1,ENC_BIG_ENDIAN);
1201          proto_tree_add_item(msg_tree,hf_display_write_shift_right,
1202                              tvb,offset,1,ENC_BIG_ENDIAN);
1203          proto_tree_add_item(msg_tree,hf_display_write_highlight,
1204                              tvb,offset,1,ENC_BIG_ENDIAN);
1205          offset+=1;msg_len-=1;
1206
1207          proto_tree_add_item(msg_tree,hf_generic_data,tvb,offset,msg_len,ENC_NA);
1208          offset+=msg_len;
1209          proto_tree_add_item(msg_tree,hf_display_write_tag,tvb,offset,1,ENC_BIG_ENDIAN);
1210          offset+=1;msg_len-=1;
1211          set_ascii_item(msg_tree,tvb,offset,msg_len);
1212          offset+=msg_len;
1213          break;
1214       case 0x1f:
1215    /*address|yes control|yes tag|yes*/
1216          tmp_ti=proto_tree_add_text(msg_tree,tvb,offset,0,"Address");
1217          address_tree=proto_item_add_subtree(tmp_ti,ett_unistim);
1218          address_byte=tvb_get_guint8(tvb,offset);
1219          proto_tree_add_item(address_tree,hf_basic_bit_field,tvb,offset,1,ENC_BIG_ENDIAN);
1220          proto_tree_add_item(address_tree,hf_display_write_address_numeric,
1221                              tvb,offset,1,ENC_BIG_ENDIAN);
1222          proto_tree_add_item(address_tree,hf_display_write_address_context,
1223                              tvb,offset,1,ENC_BIG_ENDIAN);
1224          proto_tree_add_item(address_tree,hf_display_write_address_line,
1225                              tvb,offset,1,ENC_BIG_ENDIAN);
1226          proto_tree_add_item(address_tree,hf_display_write_address_soft_key,
1227                              tvb,offset,1,ENC_BIG_ENDIAN);
1228          proto_tree_add_item(address_tree,hf_display_write_address_soft_label,
1229                              tvb,offset,1,ENC_BIG_ENDIAN);
1230          if((address_byte&DISPLAY_WRITE_ADDRESS_SOFT_KEY_FLAG)==
1231                           DISPLAY_WRITE_ADDRESS_SOFT_KEY_FLAG)
1232             proto_tree_add_item(address_tree,hf_display_write_address_softkey_id,
1233                                 tvb,offset,1,ENC_BIG_ENDIAN);
1234          offset+=1; msg_len-=1;
1235          proto_tree_add_item(msg_tree,hf_generic_string,
1236                              tvb,offset,msg_len,ENC_ASCII|ENC_NA);
1237          offset+=msg_len;
1238          if((address_byte&DISPLAY_WRITE_ADDRESS_SOFT_LABEL_FLAG)==
1239                           DISPLAY_WRITE_ADDRESS_SOFT_LABEL_FLAG){
1240             proto_tree_add_item(address_tree,hf_display_write_address_char_pos,
1241                                 tvb,offset,1,ENC_BIG_ENDIAN);
1242             if((address_byte&DISPLAY_WRITE_ADDRESS_SOFT_LABEL_FLAG)!=
1243                              DISPLAY_WRITE_ADDRESS_SOFT_LABEL_FLAG)
1244                offset+=1;msg_len-=1;
1245          }
1246          if((address_byte&DISPLAY_WRITE_ADDRESS_LINE_FLAG)==
1247                           DISPLAY_WRITE_ADDRESS_LINE_FLAG){
1248             proto_tree_add_item(address_tree,
1249                                 hf_display_write_address_line_number,
1250                                 tvb,offset,1,ENC_BIG_ENDIAN);
1251             offset+=1;msg_len-=1;
1252          }
1253          proto_tree_add_item(msg_tree,hf_basic_bit_field,tvb,offset,1,ENC_BIG_ENDIAN);
1254          proto_tree_add_item(msg_tree,hf_display_write_cursor_move,
1255                              tvb,offset,1,ENC_BIG_ENDIAN);
1256          proto_tree_add_item(msg_tree,hf_display_write_clear_left,
1257                              tvb,offset,1,ENC_BIG_ENDIAN);
1258          proto_tree_add_item(msg_tree,hf_display_write_clear_right,
1259                              tvb,offset,1,ENC_BIG_ENDIAN);
1260          proto_tree_add_item(msg_tree,hf_display_write_shift_left,
1261                              tvb,offset,1,ENC_BIG_ENDIAN);
1262          proto_tree_add_item(msg_tree,hf_display_write_shift_right,
1263                              tvb,offset,1,ENC_BIG_ENDIAN);
1264          proto_tree_add_item(msg_tree,hf_display_write_highlight,
1265                              tvb,offset,1,ENC_BIG_ENDIAN);
1266          offset+=1;msg_len-=1;
1267          proto_tree_add_item(msg_tree,hf_display_write_tag,
1268                              tvb,offset,1,ENC_BIG_ENDIAN);
1269          offset+=1;msg_len-=1;
1270          set_ascii_item(msg_tree,tvb,offset,msg_len);
1271          offset+=msg_len;
1272          break;
1273       case 0x20:
1274    /*Context Info Bar Format*/
1275          while(msg_len>0){
1276             proto_tree_add_item(msg_tree,hf_display_context_format,tvb,offset,1,ENC_BIG_ENDIAN);
1277             proto_tree_add_item(msg_tree,hf_display_context_field,tvb,offset,1,ENC_BIG_ENDIAN);
1278             offset+=1;msg_len-=1;
1279          }
1280          break;
1281       case 0x21:
1282    /*Set Default Character Table Configuration VERY UGLY*/
1283          proto_tree_add_item(msg_tree,hf_generic_data,tvb,offset,msg_len,ENC_NA);
1284          offset+=msg_len;
1285          break;
1286       case 0x22:
1287    /*Special Character Download*/
1288          proto_tree_add_item(msg_tree,hf_display_char_address,tvb,offset,1,ENC_BIG_ENDIAN);
1289          offset+=1;msg_len-=1;
1290          proto_tree_add_item(msg_tree,hf_generic_data,tvb,offset,msg_len,ENC_NA);
1291          offset+=msg_len;
1292          break;
1293       case 0x23:
1294    /*Highlighted Field Definition*/
1295          highlight_cmd=tvb_get_guint8(tvb,offset);
1296          proto_tree_add_item(msg_tree,hf_display_cursor_numeric,tvb,offset,1,ENC_BIG_ENDIAN);
1297          proto_tree_add_item(msg_tree,hf_display_cursor_context ,tvb,offset,1,ENC_BIG_ENDIAN);
1298          proto_tree_add_item(msg_tree,hf_display_cursor_line,tvb,offset,1,ENC_BIG_ENDIAN);
1299          proto_tree_add_item(msg_tree,hf_display_cursor_softkey,tvb,offset,1,ENC_BIG_ENDIAN);
1300          proto_tree_add_item(msg_tree,hf_display_cursor_softkey_id,tvb,offset,1,ENC_BIG_ENDIAN);
1301          offset+=1;msg_len-=1;proto_tree_add_item(msg_tree,hf_display_hlight_start,tvb,offset,1,ENC_BIG_ENDIAN);
1302          offset+=1;msg_len-=1;
1303          proto_tree_add_item(msg_tree,hf_display_hlight_end,tvb,offset,1,ENC_BIG_ENDIAN);
1304          offset+=1;msg_len-=1;
1305          if(msg_len==0)
1306              break;
1307          if((highlight_cmd&DISPLAY_CURSOR_LINE)==DISPLAY_CURSOR_LINE){
1308            proto_tree_add_item(msg_tree,hf_display_cursor_char_pos,tvb,offset,1,ENC_BIG_ENDIAN);
1309            proto_tree_add_item(msg_tree,hf_display_cursor_line_number,tvb,offset,1,ENC_BIG_ENDIAN);
1310            offset+=1;msg_len-=1;
1311          }
1312          proto_tree_add_item(msg_tree,hf_generic_data,tvb,offset,msg_len,ENC_NA);
1313          offset+=msg_len;
1314          break;
1315       case 0x24:
1316    /*Contrast*/
1317          proto_tree_add_item(msg_tree,hf_display_contrast,tvb,offset,1,ENC_BIG_ENDIAN);
1318          offset+=1;msg_len-=1;
1319          break;
1320       case 0x25:
1321    /*Caller Log Download*/
1322          proto_tree_add_item(msg_tree,hf_broadcast_hour,tvb,offset,msg_len,ENC_BIG_ENDIAN);
1323          offset+=1;msg_len-=1;
1324          proto_tree_add_item(msg_tree,hf_broadcast_minute,tvb,offset,msg_len,ENC_BIG_ENDIAN);
1325          offset+=1;msg_len-=1;
1326          proto_tree_add_item(msg_tree,hf_generic_data,tvb,offset,msg_len,ENC_NA);
1327          offset+=msg_len;
1328          break;
1329       case 0x30:
1330    /*Layered Softkey Text Download*/
1331          proto_tree_add_item(msg_tree,hf_display_layer_skey_id,tvb,offset,1,ENC_BIG_ENDIAN);
1332          offset+=1;msg_len-=1;
1333          proto_tree_add_item(msg_tree,hf_display_layer_number,tvb,offset,1,ENC_BIG_ENDIAN);
1334          offset+=1;msg_len-=1;
1335          set_ascii_item(msg_tree,tvb,offset,msg_len);
1336          offset+=msg_len;
1337          break;
1338       case 0x31:
1339    /*Layered Softkey Clear*/
1340          proto_tree_add_item(msg_tree,hf_display_layer_skey_id,tvb,offset,1,ENC_BIG_ENDIAN);
1341          proto_tree_add_item(msg_tree,hf_display_layer_all_skeys,tvb,offset,msg_len,ENC_BIG_ENDIAN);
1342          offset+=1;msg_len-=1;
1343          proto_tree_add_item(msg_tree,hf_display_layer_number,tvb,offset,1,ENC_BIG_ENDIAN);
1344          offset+=1;msg_len-=1;
1345          break;
1346       case 0x32:
1347    /*Set Visible Softkey Layer*/
1348          proto_tree_add_item(msg_tree,hf_display_layer_skey_id,tvb,offset,1,ENC_BIG_ENDIAN);
1349          proto_tree_add_item(msg_tree,hf_display_layer_all_skeys,tvb,offset,msg_len,ENC_BIG_ENDIAN);
1350          offset+=1;msg_len-=1;
1351          proto_tree_add_item(msg_tree,hf_display_layer_number,tvb,offset,1,ENC_BIG_ENDIAN);
1352          offset+=1;msg_len-=1;
1353          break;
1354       case 0x33:
1355    /*Layered Softkey Cadence Download*/
1356          proto_tree_add_item(msg_tree,hf_display_layer_skey_id,tvb,offset,1,ENC_BIG_ENDIAN);
1357          proto_tree_add_item(msg_tree,hf_display_once_or_cyclic,tvb,offset,msg_len,ENC_BIG_ENDIAN);
1358          offset+=1;msg_len-=1;
1359          while(msg_len>0){
1360             proto_tree_add_item(msg_tree,hf_display_layer_number,tvb,offset,1,ENC_BIG_ENDIAN);
1361             offset+=1;msg_len-=1;
1362             proto_tree_add_item(msg_tree,hf_display_layer_duration,tvb,offset,1,ENC_BIG_ENDIAN);
1363             offset+=1;msg_len-=1;
1364          }
1365          break;
1366       case 0x34:
1367    /*Layered Softkey Cadencing On*/
1368         proto_tree_add_item(msg_tree,hf_display_layer_skey_id,tvb,offset,1,ENC_BIG_ENDIAN);
1369         offset+=1;msg_len-=1;
1370         break;
1371       case 0x35:
1372    /*Layered Softkey Cadencing Off*/
1373          proto_tree_add_item(msg_tree,hf_display_layer_skey_id,tvb,offset,1,ENC_BIG_ENDIAN);
1374          offset+=1;msg_len-=1;
1375          break;
1376       case 0xff:
1377    /*Reserved*/
1378          break;
1379       default:
1380          proto_tree_add_item(msg_tree,hf_generic_data,
1381                              tvb,offset,msg_len,ENC_NA);
1382          offset+=msg_len;
1383    }
1384
1385    return offset;
1386 }
1387    /*DONE*/
1388 static gint
1389 dissect_display_phone(proto_tree *msg_tree,
1390                       tvbuff_t *tvb,gint offset,guint msg_len){
1391    guint display_cmd;
1392    guint highlight_cmd;
1393    display_cmd=tvb_get_guint8(tvb,offset);
1394    proto_tree_add_item(msg_tree,hf_display_phone_cmd,tvb,offset,1,ENC_BIG_ENDIAN);
1395    offset+=1;msg_len-=1;
1396    switch(display_cmd){
1397       case 0x00:
1398    /*Display Manager Attributes Info*/
1399          proto_tree_add_item(msg_tree,hf_display_line_width,tvb,offset,1,ENC_BIG_ENDIAN);
1400          proto_tree_add_item(msg_tree,hf_display_lines,tvb,offset,1,ENC_BIG_ENDIAN);
1401          offset+=1;msg_len-=1;
1402          proto_tree_add_item(msg_tree,hf_display_softkey_width,tvb,offset,1,ENC_BIG_ENDIAN);
1403          proto_tree_add_item(msg_tree,hf_display_softkeys,tvb,offset,1,ENC_BIG_ENDIAN);
1404          proto_tree_add_item(msg_tree,hf_display_icon,tvb,offset,1,ENC_BIG_ENDIAN);
1405          offset+=1;msg_len-=1;
1406          proto_tree_add_item(msg_tree,hf_display_softlabel_key_width,tvb,offset,1,ENC_BIG_ENDIAN);
1407          proto_tree_add_item(msg_tree,hf_display_context_width,tvb,offset,1,ENC_BIG_ENDIAN);
1408          offset+=1;msg_len-=1;
1409          proto_tree_add_item(msg_tree,hf_display_numeric_width,tvb,offset,1,ENC_BIG_ENDIAN);
1410          proto_tree_add_item(msg_tree,hf_display_time_width,tvb,offset,1,ENC_BIG_ENDIAN);
1411          proto_tree_add_item(msg_tree,hf_display_date_width,tvb,offset,1,ENC_BIG_ENDIAN);
1412          offset+=1;msg_len-=1;
1413          proto_tree_add_item(msg_tree,hf_display_char_dload,tvb,offset,1,ENC_BIG_ENDIAN);
1414          proto_tree_add_item(msg_tree,hf_display_freeform_icon_dload,tvb,offset,1,ENC_BIG_ENDIAN);
1415          proto_tree_add_item(msg_tree,hf_display_icon_type,tvb,offset,1,ENC_BIG_ENDIAN);
1416          offset+=1;msg_len-=1;
1417          proto_tree_add_item(msg_tree,hf_display_charsets,tvb,offset,1,ENC_BIG_ENDIAN);
1418          offset+=1;msg_len-=1;
1419
1420          break;
1421       case 0x01:
1422    /*Contrast Level Report*/
1423          proto_tree_add_item(msg_tree,hf_display_contrast,tvb,offset,1,ENC_BIG_ENDIAN);
1424          offset+=1;msg_len-=1;
1425          break;
1426       case 0x02:
1427    /*Cursor Location Report*/
1428          proto_tree_add_item(msg_tree,hf_display_cursor_numeric,tvb,offset,1,ENC_BIG_ENDIAN);
1429          proto_tree_add_item(msg_tree,hf_display_cursor_context ,tvb,offset,1,ENC_BIG_ENDIAN);
1430          proto_tree_add_item(msg_tree,hf_display_cursor_line,tvb,offset,1,ENC_BIG_ENDIAN);
1431          proto_tree_add_item(msg_tree,hf_display_cursor_softkey,tvb,offset,1,ENC_BIG_ENDIAN);
1432          proto_tree_add_item(msg_tree,hf_display_cursor_softkey_id,tvb,offset,1,ENC_BIG_ENDIAN);
1433          offset+=1;msg_len-=1;
1434          proto_tree_add_item(msg_tree,hf_display_cursor_char_pos,tvb,offset,1,ENC_BIG_ENDIAN);
1435          proto_tree_add_item(msg_tree,hf_display_cursor_line_number,tvb,offset,1,ENC_BIG_ENDIAN);
1436          offset+=1;msg_len-=1;
1437          break;
1438       case 0x03:
1439    /*Highlight Status On*/
1440          highlight_cmd=tvb_get_guint8(tvb,offset);
1441          proto_tree_add_item(msg_tree,hf_display_cursor_numeric,tvb,offset,1,ENC_BIG_ENDIAN);
1442          proto_tree_add_item(msg_tree,hf_display_cursor_context ,tvb,offset,1,ENC_BIG_ENDIAN);
1443          proto_tree_add_item(msg_tree,hf_display_cursor_line,tvb,offset,1,ENC_BIG_ENDIAN);
1444          proto_tree_add_item(msg_tree,hf_display_cursor_softkey,tvb,offset,1,ENC_BIG_ENDIAN);
1445          proto_tree_add_item(msg_tree,hf_display_cursor_softkey_id,tvb,offset,1,ENC_BIG_ENDIAN);
1446          offset+=1;msg_len-=1;proto_tree_add_item(msg_tree,hf_display_hlight_start,tvb,offset,1,ENC_BIG_ENDIAN);
1447          offset+=1;msg_len-=1;
1448          proto_tree_add_item(msg_tree,hf_display_hlight_end,tvb,offset,1,ENC_BIG_ENDIAN);
1449          offset+=1;msg_len-=1;
1450          if((highlight_cmd&DISPLAY_CURSOR_LINE)==DISPLAY_CURSOR_LINE){
1451            proto_tree_add_item(msg_tree,hf_display_cursor_char_pos,tvb,offset,1,ENC_BIG_ENDIAN);
1452            proto_tree_add_item(msg_tree,hf_display_cursor_line_number,tvb,offset,1,ENC_BIG_ENDIAN);
1453            offset+=1;msg_len-=1;
1454          }
1455          break;
1456       case 0x04:
1457    /*Current Character Table Configuration Status   VERY UGLY*/
1458          proto_tree_add_item(msg_tree,hf_generic_data,tvb,offset,msg_len,ENC_NA);
1459          offset+=msg_len;
1460          break;
1461       case 0x05:
1462    /*Default Character Table Configuration Status   VERY UGLY*/
1463          proto_tree_add_item(msg_tree,hf_generic_data,tvb,offset,msg_len,ENC_NA);
1464          offset+=msg_len;
1465          break;
1466       case 0x06:
1467    /*Timer And Date Format Report*/
1468          proto_tree_add_item(msg_tree,hf_display_time_format,tvb,offset,1,ENC_BIG_ENDIAN);
1469          proto_tree_add_item(msg_tree,hf_display_date_format,tvb,offset,1,ENC_BIG_ENDIAN);
1470          offset+=1;msg_len-=1;
1471          break;
1472       case 0x07:
1473    /*Status Bar Icon State Report*/
1474          proto_tree_add_item(msg_tree,hf_icon_id,tvb,offset,msg_len,ENC_BIG_ENDIAN);
1475          offset+=1;msg_len-=1;
1476          proto_tree_add_item(msg_tree,hf_broadcast_icon_state,tvb,offset,msg_len,ENC_BIG_ENDIAN);
1477          proto_tree_add_item(msg_tree,hf_broadcast_icon_cadence,tvb,offset,msg_len,ENC_BIG_ENDIAN);
1478          offset+=1;msg_len-=1;
1479          break;
1480       case 0x0a:
1481    /*Highlight Status Off length = 3*/
1482          break;
1483       case 0xff:
1484    /*Reserved*/
1485          break;
1486       default:
1487          proto_tree_add_item(msg_tree,hf_generic_data,tvb,offset,msg_len,ENC_NA);
1488          offset+=msg_len;
1489    }
1490
1491    return offset;
1492 }
1493
1494
1495 static gint
1496 dissect_key_indicator_switch(proto_tree *msg_tree,
1497                              tvbuff_t *tvb, gint offset,guint msg_len){
1498    guint key_cmd;
1499    key_cmd=tvb_get_guint8(tvb,offset);
1500    proto_tree_add_item(msg_tree,hf_key_switch_cmd,tvb,offset,1,ENC_BIG_ENDIAN);
1501    offset+=1;msg_len-=1;
1502    switch(key_cmd){
1503       case 0x00:
1504    /*LED Update*/
1505          proto_tree_add_item(msg_tree,hf_basic_bit_field,tvb,offset,1,ENC_BIG_ENDIAN);
1506          proto_tree_add_item(msg_tree,hf_key_led_cadence,tvb,offset,1,ENC_BIG_ENDIAN);
1507          proto_tree_add_item(msg_tree,hf_key_led_id,tvb,offset,1,ENC_BIG_ENDIAN);
1508          offset+=1;msg_len-=1;
1509          break;
1510       case 0x01:
1511    /*Query Hookswitch length = 3 */
1512          break;
1513       case 0x02:
1514    /*User Activity Timer Stop length = 3*/
1515          break;
1516       case 0x03:
1517    /*User Activity Timer Start length = 3*/
1518          break;
1519       case 0x04:
1520    /*Downloadable Free Form Icon Access (Hardcoded) length of 3*/
1521          break;
1522       case 0x05:
1523    /*Downloadable Free Form Icon Access (Downloadable) length of 3*/
1524          break;
1525       case 0x06:
1526    /*Query Key/Indicator Manager*/
1527          proto_tree_add_item(msg_tree,hf_generic_data,tvb,offset,msg_len,ENC_NA);
1528          offset+=msg_len;
1529          break;
1530       case 0x07:
1531    /*Key/Indicator Manager Options*/
1532          proto_tree_add_item(msg_tree,hf_keys_send_key_rel,tvb,offset,1,ENC_BIG_ENDIAN);
1533          proto_tree_add_item(msg_tree,hf_keys_enable_vol,tvb,offset,1,ENC_BIG_ENDIAN);
1534          proto_tree_add_item(msg_tree,hf_keys_conspic_prog_key,tvb,offset,1,ENC_BIG_ENDIAN);
1535          proto_tree_add_item(msg_tree,hf_keys_acd_super_control,tvb,offset,1,ENC_BIG_ENDIAN);
1536          proto_tree_add_item(msg_tree,hf_keys_local_dial_feedback,tvb,offset,1,ENC_BIG_ENDIAN);
1537          offset+=1;msg_len-=1;
1538          break;
1539       case 0x08:
1540    /*Logical Icon Mapping*/
1541          proto_tree_add_item(msg_tree,hf_key_icon_id,tvb,offset,1,ENC_BIG_ENDIAN);
1542          proto_tree_add_item(msg_tree,hf_keys_admin_command,tvb,offset,1,ENC_BIG_ENDIAN);
1543          offset+=1;msg_len-=1;
1544          proto_tree_add_item(msg_tree,hf_keys_logical_icon_id,tvb,offset,2,ENC_BIG_ENDIAN);
1545          offset+=2;msg_len-=2;
1546          break;
1547       case 0x09:
1548    /*Key Repeat Timer Download*/
1549          proto_tree_add_item(msg_tree,hf_keys_repeat_timer_one,tvb,offset,1,ENC_BIG_ENDIAN);
1550          offset+=1;msg_len-=1;
1551          proto_tree_add_item(msg_tree,hf_keys_repeat_timer_two,tvb,offset,1,ENC_BIG_ENDIAN);
1552          offset+=1;msg_len-=1;
1553          break;
1554       case 0x0a:
1555    /*Query LED State*/
1556          proto_tree_add_item(msg_tree,hf_keys_led_id,tvb,offset,1,ENC_BIG_ENDIAN);
1557          offset+=1;msg_len-=1;
1558          break;
1559       case 0x0b:
1560    /*Query Phone Icon State*/
1561          proto_tree_add_item(msg_tree,hf_keys_phone_icon_id,tvb,offset,1,ENC_BIG_ENDIAN);
1562          offset+=1;msg_len-=1;
1563          break;
1564       case 0x0c:
1565    /*Indicator Cadence Download*/
1566          while(msg_len>0){
1567             proto_tree_add_item(msg_tree,hf_keys_cadence_on_time,tvb,offset,1,ENC_BIG_ENDIAN);
1568             offset+=1;msg_len-=1;
1569             proto_tree_add_item(msg_tree,hf_keys_cadence_off_time,tvb,offset,1,ENC_BIG_ENDIAN);
1570             offset+=1;msg_len-=1;
1571          }
1572          break;
1573       case 0x0d:
1574    /*User Activity Timer Download*/
1575          proto_tree_add_item(msg_tree,hf_keys_user_activity_timeout,tvb,offset,1,ENC_BIG_ENDIAN);
1576          offset+=1;msg_len-=1;
1577          break;
1578       case 0x0e:
1579    /*Free Form Icon Download*/
1580          proto_tree_add_item(msg_tree,hf_key_icon_id,tvb,offset,1,ENC_BIG_ENDIAN);
1581          offset+=1;msg_len-=1;
1582          proto_tree_add_item(msg_tree,hf_generic_data,tvb,offset,msg_len,ENC_NA);
1583          offset+=msg_len;
1584          break;
1585       case 0x0f:
1586    /*Phone Icon Update*/
1587          proto_tree_add_item(msg_tree,hf_key_icon_id,tvb,offset,1,ENC_BIG_ENDIAN);
1588          offset+=1;msg_len-=1;
1589          proto_tree_add_item(msg_tree,hf_basic_bit_field,tvb,offset,1,ENC_BIG_ENDIAN);
1590          proto_tree_add_item(msg_tree,hf_broadcast_icon_state,tvb,offset,1,ENC_BIG_ENDIAN);
1591          proto_tree_add_item(msg_tree,hf_broadcast_icon_cadence,tvb,offset,1,ENC_BIG_ENDIAN);
1592          offset+=1;msg_len-=1;
1593          break;
1594       case 0xff:
1595    /*Reserved*/
1596          proto_tree_add_item(msg_tree,hf_generic_data,tvb,offset,msg_len,ENC_NA);
1597          offset+=msg_len;
1598          break;
1599       default:
1600          proto_tree_add_item(msg_tree,hf_generic_data,tvb,offset,msg_len,ENC_NA);
1601          offset+=msg_len;
1602    }
1603
1604    return offset;
1605 }
1606
1607 /*DONE*/
1608 static gint
1609 dissect_key_indicator_phone(proto_tree *msg_tree,
1610                             tvbuff_t *tvb,gint offset, guint msg_len){
1611    guint key_cmd;
1612    key_cmd=tvb_get_guint8(tvb,offset);
1613    proto_tree_add_item(msg_tree,hf_key_phone_cmd,tvb,offset,1,ENC_BIG_ENDIAN);
1614    offset+=1;msg_len-=1;
1615    switch(key_cmd){
1616       case 0x00:
1617    /*Key Event*/
1618          /* Set the tap info */
1619          uinfo->key_state = tvb_get_guint8(tvb,offset);
1620          uinfo->key_state >>= 6;
1621          /* Extract the key code */
1622          uinfo->key_val = (tvb_get_guint8(tvb,offset) & 0x3F);
1623
1624          proto_tree_add_item(msg_tree,hf_basic_bit_field,tvb,offset,1,ENC_BIG_ENDIAN);
1625          proto_tree_add_item(msg_tree,hf_key_code,tvb,offset,1,ENC_BIG_ENDIAN);
1626          proto_tree_add_item(msg_tree,hf_key_command,tvb,offset,1,ENC_BIG_ENDIAN);
1627          offset+=1;
1628          break;
1629       case 0x01:
1630    /*LED Status Report*/
1631          proto_tree_add_item(msg_tree,hf_generic_data,tvb,offset,msg_len,ENC_NA);
1632          offset+=msg_len;
1633          break;
1634       case 0x03:
1635    /*On Hook length = 3*/
1636          /* Set tap info.. */
1637          uinfo->hook_state = 0;
1638
1639          break;
1640       case 0x04:
1641    /*Off Hook length = 3*/
1642          /* Set tap info.. */
1643          uinfo->hook_state = 1;
1644
1645          break;
1646       case 0x05:
1647    /*User Activity Timer Expired length = 3*/
1648          break;
1649       case 0x06:
1650    /*Hookswitch State (on hook) length = 3*/
1651          break;
1652       case 0x07:
1653    /*Hookswitch State (off hook) length = 3*/
1654          break;
1655       case 0x08:
1656    /*Key/Indicator Manager Attributes Info*/
1657          proto_tree_add_item(msg_tree,hf_key_programmable_keys,tvb,offset,1,ENC_BIG_ENDIAN);
1658          proto_tree_add_item(msg_tree,hf_keys_soft_keys,tvb,offset,1,ENC_BIG_ENDIAN);
1659          offset+=1;msg_len-=1;
1660          proto_tree_add_item(msg_tree,hf_keys_hd_key,tvb,offset,1,ENC_BIG_ENDIAN);
1661          proto_tree_add_item(msg_tree,hf_keys_mute_key,tvb,offset,1,ENC_BIG_ENDIAN);
1662          proto_tree_add_item(msg_tree,hf_keys_quit_key,tvb,offset,1,ENC_BIG_ENDIAN);
1663          proto_tree_add_item(msg_tree,hf_keys_copy_key,tvb,offset,1,ENC_BIG_ENDIAN);
1664          proto_tree_add_item(msg_tree,hf_keys_mwi_key,tvb,offset,1,ENC_BIG_ENDIAN);
1665          offset+=1;msg_len-=1;
1666          proto_tree_add_item(msg_tree,hf_keys_num_nav_keys,tvb,offset,1,ENC_BIG_ENDIAN);
1667          proto_tree_add_item(msg_tree,hf_keys_num_conspic_keys,tvb,offset,1,ENC_BIG_ENDIAN);
1668          offset+=1;msg_len-=1;
1669
1670          break;
1671       case 0x09:
1672    /*Key/Indicator Manager Options Report*/
1673          proto_tree_add_item(msg_tree,hf_keys_send_key_rel,tvb,offset,1,ENC_BIG_ENDIAN);
1674          proto_tree_add_item(msg_tree,hf_keys_enable_vol,tvb,offset,1,ENC_BIG_ENDIAN);
1675          proto_tree_add_item(msg_tree,hf_keys_conspic_prog_key,tvb,offset,1,ENC_BIG_ENDIAN);
1676          proto_tree_add_item(msg_tree,hf_keys_acd_super_control,tvb,offset,1,ENC_BIG_ENDIAN);
1677          proto_tree_add_item(msg_tree,hf_keys_local_dial_feedback,tvb,offset,1,ENC_BIG_ENDIAN);
1678          offset+=1;msg_len-=1;
1679          break;
1680       case 0x0a:
1681    /*Phone Icon Status Report*/
1682          proto_tree_add_item(msg_tree,hf_generic_data,tvb,offset,msg_len,ENC_NA);
1683          offset+=msg_len;
1684          break;
1685       case 0xff:
1686    /*Reserved*/
1687          break;
1688       default:
1689          proto_tree_add_item(msg_tree,hf_generic_data,tvb,offset,msg_len,ENC_NA);
1690          offset+=msg_len;
1691    }
1692
1693    return offset;
1694 }
1695
1696
1697 /*Done*/
1698 static gint
1699 dissect_network_switch(proto_tree *msg_tree,
1700                        tvbuff_t *tvb,gint offset, guint msg_len){
1701    guint network_cmd;
1702    guint string_len;
1703
1704    network_cmd=tvb_get_guint8(tvb,offset);
1705    proto_tree_add_item(msg_tree,hf_network_switch_cmd,tvb,offset,1,ENC_BIG_ENDIAN);
1706    offset+=1;msg_len-=1;
1707    switch(network_cmd){
1708       case 0x02:
1709    /*Soft Reset done*/
1710          break;
1711       case 0x03:
1712    /*Hard Reset done*/
1713          break;
1714       case 0x04:
1715    /*Query Network Manager*/
1716          proto_tree_add_item(msg_tree,hf_basic_bit_field,tvb,offset,1,ENC_BIG_ENDIAN);
1717          proto_tree_add_item(msg_tree,hf_net_diag_flag,tvb,offset,1,ENC_BIG_ENDIAN);
1718          proto_tree_add_item(msg_tree,hf_net_managers_flag,tvb,offset,1,ENC_BIG_ENDIAN);
1719          proto_tree_add_item(msg_tree,hf_net_attributes_flag,tvb,offset,1,ENC_BIG_ENDIAN);
1720          proto_tree_add_item(msg_tree,hf_net_serv_info_flag,tvb,offset,1,ENC_BIG_ENDIAN);
1721          proto_tree_add_item(msg_tree,hf_net_options_flag,tvb,offset,1,ENC_BIG_ENDIAN);
1722          proto_tree_add_item(msg_tree,hf_net_sanity_flag,tvb,offset,1,ENC_BIG_ENDIAN);
1723          offset+=1;
1724          break;
1725       case 0x05:
1726    /*Network Manager Options*/
1727          proto_tree_add_item(msg_tree,hf_basic_bit_field,tvb,offset,1,ENC_BIG_ENDIAN);
1728          proto_tree_add_item(msg_tree,hf_net_enable_diag,tvb,offset,1,ENC_BIG_ENDIAN);
1729          proto_tree_add_item(msg_tree,hf_net_enable_rudp,tvb,offset,1,ENC_BIG_ENDIAN);
1730          offset+=1;
1731          break;
1732       case 0x06:
1733    /*QoS Configuration*/
1734          proto_tree_add_item(msg_tree,hf_generic_data,tvb,offset,msg_len,ENC_NA);
1735          offset+=msg_len;
1736          break;
1737       case 0x09:
1738    /*Set RTCP Source Description Item*/
1739          proto_tree_add_item(msg_tree,hf_generic_data,tvb,offset,msg_len,ENC_NA);
1740          offset+=msg_len;
1741          break;
1742       case 0x0b:
1743    /*Download Server Information*/
1744          proto_tree_add_item(msg_tree,hf_net_server_id,tvb,offset,1,ENC_BIG_ENDIAN);
1745          offset+=1;
1746          proto_tree_add_item(msg_tree,hf_net_server_port,tvb,offset,2,ENC_BIG_ENDIAN);
1747          offset+=2;
1748          proto_tree_add_item(msg_tree,hf_net_server_action,tvb,offset,1,ENC_BIG_ENDIAN);
1749          offset+=1;
1750          proto_tree_add_item(msg_tree,hf_net_server_retry_count,tvb,offset,1,ENC_BIG_ENDIAN);
1751          offset+=1;
1752          proto_tree_add_item(msg_tree,hf_net_server_failover_id,tvb,offset,1,ENC_BIG_ENDIAN);
1753          offset+=1;
1754          proto_tree_add_item(msg_tree,hf_net_server_ip_address,tvb,offset,4,ENC_BIG_ENDIAN);
1755          offset+=4;
1756          break;
1757       case 0x0c:
1758    /*Server Switch*/
1759          proto_tree_add_item(msg_tree,hf_net_server_id,tvb,offset,1,ENC_BIG_ENDIAN);
1760          offset+=1;
1761          break;
1762       case 0x0d:
1763    /*Query Network Configuration Element*/
1764          proto_tree_add_item(msg_tree,hf_net_server_config_element,
1765                              tvb,offset-1,1,ENC_BIG_ENDIAN);
1766          offset+=1;
1767          break;
1768       case 0x0e:
1769    /*Download Software Upgrade*/
1770          proto_tree_add_item(msg_tree,hf_net_file_xfer_mode,tvb,offset,1,ENC_BIG_ENDIAN);
1771          proto_tree_add_item(msg_tree,hf_net_force_download,tvb,offset,1,ENC_BIG_ENDIAN);
1772          proto_tree_add_item(msg_tree,hf_net_use_file_server_port,tvb,offset,1,ENC_BIG_ENDIAN);
1773          proto_tree_add_item(msg_tree,hf_net_use_local_port,tvb,offset,1,ENC_BIG_ENDIAN);
1774          offset+=1;msg_len-=1;
1775          proto_tree_add_item(msg_tree,hf_generic_data,tvb,offset,1,ENC_NA);
1776          offset+=1;msg_len-=1;
1777          string_len=tvb_strsize(tvb,offset);
1778          proto_tree_add_item(msg_tree,hf_net_full_pathname,tvb,offset,string_len,ENC_ASCII|ENC_NA);
1779          offset+=string_len;msg_len-=string_len;
1780          string_len=tvb_strsize(tvb,offset);
1781          proto_tree_add_item(msg_tree,hf_net_file_identifier,tvb,offset,string_len,ENC_ASCII|ENC_NA);
1782          offset+=string_len;msg_len-=string_len;
1783          proto_tree_add_item(msg_tree,hf_net_file_server_port,tvb,offset,2,ENC_BIG_ENDIAN);
1784          offset+=2;msg_len-=2;
1785          proto_tree_add_item(msg_tree,hf_net_local_port,tvb,offset,2,ENC_BIG_ENDIAN);
1786          offset+=2;msg_len-=2;
1787          proto_tree_add_item(msg_tree,hf_net_file_server_address,tvb,offset,4,ENC_BIG_ENDIAN);
1788          offset+=4;msg_len-=4;
1789          break;
1790       case 0x0f:
1791    /*Set RTCP Report Interval*/
1792          proto_tree_add_item(msg_tree,hf_generic_data,tvb,offset,msg_len,ENC_NA);
1793          offset+=msg_len;
1794          break;
1795       case 0x10:
1796    /*Set Primary Server*/
1797          proto_tree_add_item(msg_tree,hf_net_server_id,tvb,offset,1,ENC_BIG_ENDIAN);
1798          offset+=1;
1799          break;
1800       case 0x12:
1801    /*Reset Watchdog*/
1802          proto_tree_add_item(msg_tree,hf_net_server_time_out,
1803                              tvb,offset,2,ENC_BIG_ENDIAN);
1804          offset+=2;
1805          break;
1806       case 0x13:
1807    /*Set Recovery Procedure Time Interval*/
1808          proto_tree_add_item(msg_tree,hf_net_server_recovery_time_low,
1809                              tvb,offset,2,ENC_BIG_ENDIAN);
1810          offset+=2;
1811          proto_tree_add_item(msg_tree,hf_net_server_recovery_time_high,
1812                              tvb,offset,2,ENC_BIG_ENDIAN);
1813          offset+=2;
1814          break;
1815       case 0x14:
1816    /*Transport Reliability Layer Parameters Download*/
1817          proto_tree_add_item(msg_tree,hf_generic_data,
1818                              tvb,offset,msg_len,ENC_NA);
1819          offset+=msg_len;
1820          break;
1821       case 0xff:
1822    /*Reserved*/
1823          proto_tree_add_item(msg_tree,hf_generic_data,tvb,offset,msg_len,ENC_NA);
1824          offset+=msg_len;
1825          break;
1826       default:
1827          proto_tree_add_item(msg_tree,hf_generic_data,tvb,offset,msg_len,ENC_NA);
1828          offset+=msg_len;
1829
1830    }
1831
1832    return offset;
1833 }
1834
1835 /*DONE*/
1836 static gint
1837 dissect_expansion_switch(proto_tree *msg_tree,
1838                       tvbuff_t *tvb,gint offset, guint msg_len){
1839    guint expansion_cmd;
1840
1841
1842    expansion_cmd=tvb_get_guint8(tvb,offset);
1843    proto_tree_add_item(msg_tree,hf_expansion_switch_cmd,tvb,offset,1,ENC_BIG_ENDIAN);
1844    offset+=1; msg_len-=1;
1845    switch(expansion_cmd){
1846       case 0x17:
1847          break;
1848       case 0x57:
1849         /*skip a byte for now, not sure what it means*/
1850         offset+=1;
1851         msg_len-=1;
1852
1853
1854          proto_tree_add_item(msg_tree,hf_expansion_softlabel_number,tvb,
1855                           offset,1,ENC_BIG_ENDIAN);
1856          offset+=1;
1857          msg_len-=1;
1858
1859          set_ascii_item(msg_tree,tvb,offset,msg_len);
1860          break;
1861       case 0x59:
1862          /*skip a byte for now, not sure what it means*/
1863          offset+=1;
1864          msg_len-=1;
1865          proto_tree_add_item(msg_tree,hf_expansion_softlabel_number,tvb,
1866                           offset,1,ENC_BIG_ENDIAN);
1867          offset+=1;
1868          msg_len-=1;
1869          proto_tree_add_item(msg_tree,hf_basic_bit_field,
1870                              tvb,offset,1,ENC_BIG_ENDIAN);
1871          proto_tree_add_item(msg_tree,hf_broadcast_icon_state,
1872                              tvb,offset,1,ENC_BIG_ENDIAN);
1873          proto_tree_add_item(msg_tree,hf_broadcast_icon_cadence,
1874                              tvb,offset,1,ENC_BIG_ENDIAN);
1875          offset+=1;
1876          msg_len-=1;
1877          break;
1878    }
1879    offset+=msg_len;
1880    return offset;
1881 }
1882
1883 static gint
1884 dissect_expansion_phone(proto_tree *msg_tree,
1885                       tvbuff_t *tvb,gint offset, guint msg_len){
1886    guint expansion_cmd;
1887    guint key_number;
1888
1889    expansion_cmd=tvb_get_guint8(tvb,offset);
1890    proto_tree_add_item(msg_tree,hf_expansion_phone_cmd,tvb,offset,1,ENC_BIG_ENDIAN);
1891    offset+=1; msg_len-=1;
1892    key_number=(tvb_get_guint8(tvb,offset))-64;
1893
1894    switch(expansion_cmd){
1895       case 0x59:
1896          proto_tree_add_text(msg_tree,tvb,offset,msg_len,"Module Key Number: %i",key_number);
1897          offset+=1;
1898          msg_len-=1;
1899          break;
1900    }
1901    offset+=msg_len;
1902    return offset;
1903 }
1904
1905 static gint
1906 dissect_network_phone(proto_tree *msg_tree,
1907                       tvbuff_t *tvb,gint offset, guint msg_len){
1908    guint network_cmd;
1909    proto_tree *server_tree;
1910    proto_item *server;
1911    guint i;
1912    network_cmd=tvb_get_guint8(tvb,offset);
1913    proto_tree_add_item(msg_tree,hf_network_phone_cmd,tvb,offset,1,ENC_BIG_ENDIAN);
1914    offset+=1;msg_len-=1;
1915    switch(network_cmd){
1916       case 0x00:
1917    /*Soft Reset Ack done length = 3*/
1918          break;
1919       case 0x01:
1920    /*Sanity OK done length = 3*/
1921          break;
1922       case 0x02:
1923    /*Network Manager Attributes Info*/
1924          proto_tree_add_item(msg_tree,hf_generic_data,tvb,offset,msg_len,ENC_NA);
1925          offset+=msg_len;
1926          break;
1927       case 0x03:
1928    /*Network Manager Diagnostic Info*/
1929          proto_tree_add_item(msg_tree,hf_basic_bit_field,tvb,offset,1,ENC_BIG_ENDIAN);
1930          proto_tree_add_item(msg_tree,hf_net_phone_rx_ovr_flag,
1931                              tvb,offset,1,ENC_BIG_ENDIAN);
1932          proto_tree_add_item(msg_tree,hf_net_phone_tx_ovr_flag,
1933                              tvb,offset,1,ENC_BIG_ENDIAN);
1934          proto_tree_add_item(msg_tree,hf_net_phone_rx_empty_flag,
1935                              tvb,offset,1,ENC_BIG_ENDIAN);
1936          proto_tree_add_item(msg_tree,hf_net_phone_invalid_msg_flag,
1937                              tvb,offset,1,ENC_BIG_ENDIAN);
1938          proto_tree_add_item(msg_tree,hf_net_phone_eeprom_insane_flag,
1939                              tvb,offset,1,ENC_BIG_ENDIAN);
1940          proto_tree_add_item(msg_tree,hf_net_phone_eeprom_unsafe_flag,
1941                              tvb,offset,1,ENC_BIG_ENDIAN);
1942          offset+=1;
1943          break;
1944       case 0x04:
1945    /*Manager IDs*/
1946          proto_tree_add_item(msg_tree,hf_generic_data,tvb,offset,msg_len,ENC_NA);
1947          offset+=msg_len;
1948          break;
1949       case 0x05:
1950    /*Network Manager Options Report*/
1951          proto_tree_add_boolean(msg_tree,hf_net_phone_diag,tvb,offset,1,FALSE);
1952          proto_tree_add_item(msg_tree,hf_net_phone_rudp,tvb,offset,1,ENC_BIG_ENDIAN);
1953          offset+=1;
1954          break;
1955       case 0x08:
1956    /*Resume Connection with Server done*/
1957          break;
1958       case 0x09:
1959    /*Suspend Connection with Server done*/
1960          break;
1961       case 0x0b:
1962    /*Network Configuration Element Report*/
1963          proto_tree_add_item(msg_tree,hf_generic_data,tvb,offset,msg_len,ENC_NA);
1964          offset+=msg_len;
1965          break;
1966       case 0x0c:
1967    /*Server Information Report*/
1968          proto_tree_add_item(msg_tree,hf_net_phone_primary_server_id,
1969                              tvb,offset,1,ENC_BIG_ENDIAN);
1970          offset+=1;msg_len-=1;
1971          for (i=1; msg_len>8; i++){
1972    /*if less than 9 not full report so punt*/
1973 /*          guint16 port_num;
1974             port_num=tvb_get_ntohs(tvb,offset);
1975             if(port_num<1064)
1976                break;
1977 */
1978             server=proto_tree_add_text(msg_tree,tvb,offset,9,
1979                                        "Server (S%d) Server ID: %X",i,i-1);
1980             server_tree=proto_item_add_subtree(server,ett_unistim);
1981             proto_tree_add_item(server_tree,
1982                                 hf_net_phone_server_port,
1983                                 tvb,offset,2,ENC_BIG_ENDIAN);
1984             offset+=2;msg_len-=2;
1985             proto_tree_add_item(server_tree,
1986                                 hf_net_phone_server_action,
1987                                 tvb,offset,1,ENC_BIG_ENDIAN);
1988             offset+=1;msg_len-=1;
1989             proto_tree_add_item(server_tree,
1990                                 hf_net_phone_server_retry_count,
1991                                 tvb,offset,1,ENC_BIG_ENDIAN);
1992             offset+=1;msg_len-=1;
1993             proto_tree_add_item(server_tree,
1994                                 hf_net_phone_server_failover_id,
1995                                 tvb,offset,1,ENC_BIG_ENDIAN);
1996             offset+=1;msg_len-=1;
1997             proto_tree_add_item(server_tree,hf_net_phone_server_ip,
1998                                 tvb,offset,4,ENC_BIG_ENDIAN);
1999             offset+=4;msg_len-=4;
2000          }
2001          break;
2002       case 0xff:
2003    /*Reserved*/
2004          break;
2005       default:
2006          proto_tree_add_item(msg_tree,hf_generic_data,tvb,offset,msg_len,ENC_NA);
2007          offset+=msg_len;
2008    }
2009
2010    return offset;
2011 }
2012 /*DONE*/
2013 static gint
2014 dissect_audio_switch(proto_tree *msg_tree,packet_info *pinfo,
2015                                     tvbuff_t *tvb,gint offset,guint msg_len){
2016    proto_tree *param_tree;
2017    proto_item *param;
2018    guint audio_cmd;
2019    guint apb_op_code;
2020    guint apb_data_len;
2021    guint vocoder_param;
2022    audio_cmd=tvb_get_guint8(tvb,offset);
2023    proto_tree_add_item(msg_tree,hf_audio_switch_cmd,tvb,offset,1,ENC_BIG_ENDIAN);
2024    offset+=1;msg_len-=1;
2025    switch(audio_cmd){
2026    case 0x00:
2027    /*Query Audio Manager*/
2028       proto_tree_add_item(msg_tree,hf_basic_bit_field,tvb,offset,1,ENC_BIG_ENDIAN);
2029       proto_tree_add_item(msg_tree,hf_audio_mgr_attr,tvb,offset,1,ENC_BIG_ENDIAN);
2030       proto_tree_add_item(msg_tree,hf_audio_mgr_opts,tvb,offset,1,ENC_BIG_ENDIAN);
2031       proto_tree_add_item(msg_tree,hf_audio_mgr_alert,tvb,offset,1,ENC_BIG_ENDIAN);
2032       proto_tree_add_item(msg_tree,hf_audio_mgr_adj_rx_vol,tvb,offset,1,ENC_BIG_ENDIAN);
2033       proto_tree_add_item(msg_tree,hf_audio_mgr_def_rx_vol,tvb,offset,1,ENC_BIG_ENDIAN);
2034       proto_tree_add_item(msg_tree,hf_audio_mgr_handset,tvb,offset,1,ENC_BIG_ENDIAN);
2035       proto_tree_add_item(msg_tree,hf_audio_mgr_headset,tvb,offset,1,ENC_BIG_ENDIAN);
2036       offset+=1;
2037       proto_tree_add_item(msg_tree,hf_audio_default_rx_vol_id,
2038                           tvb,offset,1,ENC_BIG_ENDIAN);
2039       offset+=1;
2040       break;
2041    case 0x01:
2042    /*Query Supervisor Headset Status*/
2043       /*done*/
2044       break;
2045    case 0x02:
2046    /*Audio Manager Options*/
2047       proto_tree_add_item(msg_tree,hf_basic_bit_field,tvb,offset,1,ENC_BIG_ENDIAN);
2048       proto_tree_add_item(msg_tree,hf_audio_mgr_opt_max_vol,
2049                           tvb,offset,1,ENC_BIG_ENDIAN);
2050       proto_tree_add_item(msg_tree,hf_audio_mgr_opt_adj_vol,
2051                           tvb,offset,1,ENC_BIG_ENDIAN);
2052       proto_tree_add_item(msg_tree,hf_audio_mgr_opt_aa_rx_vol_rpt,
2053                           tvb,offset,1,ENC_BIG_ENDIAN);
2054       proto_tree_add_item(msg_tree,hf_audio_mgr_opt_hs_on_air,
2055                           tvb,offset,1,ENC_BIG_ENDIAN);
2056       proto_tree_add_item(msg_tree,hf_audio_mgr_opt_hd_on_air,
2057                           tvb,offset,1,ENC_BIG_ENDIAN);
2058       proto_tree_add_item(msg_tree,hf_audio_mgr_opt_noise_squelch,
2059                           tvb,offset,1,ENC_BIG_ENDIAN);
2060       offset+=1;
2061          break;
2062       case 0x04:
2063    /*Mute/Unmute*/
2064          while(msg_len>0){
2065             proto_tree_add_item(msg_tree,hf_basic_bit_field,tvb,offset,1,ENC_BIG_ENDIAN);
2066             proto_tree_add_item(msg_tree,hf_audio_mgr_mute,tvb,offset,1,ENC_BIG_ENDIAN);
2067             proto_tree_add_item(msg_tree,hf_audio_mgr_tx_rx,tvb,offset,1,ENC_BIG_ENDIAN);
2068             offset+=1;msg_len-=1;
2069             proto_tree_add_item(msg_tree,hf_audio_mgr_stream_id,
2070                                 tvb,offset,1,ENC_BIG_ENDIAN);
2071             offset+=1;msg_len-=1;
2072          }
2073          break;
2074       case 0x10:
2075    /*Transducer Based Tone On*/
2076          proto_tree_add_item(msg_tree,
2077                              hf_audio_mgr_transducer_based_tone_id,
2078                              tvb,offset,1,ENC_BIG_ENDIAN);
2079          proto_tree_add_item(msg_tree,hf_audio_mgr_attenuated,
2080                              tvb,offset,1,ENC_BIG_ENDIAN);
2081          offset+=1;
2082          break;
2083       case 0x11:
2084    /*Transducer Based Tone Off*/
2085          proto_tree_add_item(msg_tree,hf_audio_mgr_transducer_based_tone_id,
2086                              tvb,offset,1,ENC_BIG_ENDIAN);
2087          offset+=1;
2088          break;
2089       case 0x12:
2090    /*Alerting Tone Configuration*/
2091          proto_tree_add_item(msg_tree,hf_basic_bit_field,tvb,offset,1,ENC_BIG_ENDIAN);
2092          proto_tree_add_item(msg_tree,hf_audio_mgr_warbler_select,
2093                              tvb,offset,1,ENC_BIG_ENDIAN);
2094          proto_tree_add_item(msg_tree,hf_audio_mgr_transducer_routing,
2095                              tvb,offset,1,ENC_BIG_ENDIAN);
2096          offset+=1;
2097          proto_tree_add_item(msg_tree,hf_basic_bit_field,tvb,offset,1,ENC_BIG_ENDIAN);
2098          proto_tree_add_item(msg_tree,hf_audio_mgr_tone_vol_range,
2099                              tvb,offset,1,ENC_BIG_ENDIAN);
2100          proto_tree_add_item(msg_tree,hf_audio_mgr_cadence_select,
2101                              tvb,offset,1,ENC_BIG_ENDIAN);
2102          offset+=1;
2103          break;
2104       case 0x13:
2105    /*Special Tone Configuration*/
2106          proto_tree_add_item(msg_tree,hf_audio_mgr_transducer_routing,
2107                              tvb,offset,1,ENC_BIG_ENDIAN);
2108          offset+=1;
2109          proto_tree_add_item(msg_tree,hf_audio_mgr_tone_vol_range,
2110                              tvb,offset,1,ENC_BIG_ENDIAN);
2111          offset+=1;
2112          proto_tree_add_item(msg_tree,hf_audio_special_tone,tvb,offset,1,ENC_BIG_ENDIAN);
2113          offset+=1;
2114          break;
2115       case 0x14:
2116    /*Paging Tone Configuration*/
2117          proto_tree_add_item(msg_tree,hf_audio_mgr_transducer_routing,
2118                              tvb,offset,1,ENC_BIG_ENDIAN);
2119          offset+=1;
2120          proto_tree_add_item(msg_tree,hf_audio_mgr_tone_vol_range,
2121                              tvb,offset,1,ENC_BIG_ENDIAN);
2122          proto_tree_add_item(msg_tree,hf_audio_mgr_cadence_select,
2123                              tvb,offset,1,ENC_BIG_ENDIAN);
2124          offset+=1;
2125          break;
2126       case 0x15:
2127    /*Alerting Tone Cadence Download*/
2128          proto_tree_add_item(msg_tree,hf_generic_data,tvb,offset,msg_len,ENC_NA);
2129          offset+=msg_len;
2130          break;
2131    /*TODO UGLY*/
2132       case 0x17:
2133    /*Paging Tone Cadence Download*/
2134          proto_tree_add_item(msg_tree,hf_generic_data,tvb,offset,msg_len,ENC_NA);
2135          offset+=msg_len;
2136          break;
2137    /*TODO UGLY*/
2138       case 0x18:
2139    /*Transducer Based Tone Volume Level*/
2140          proto_tree_add_item(msg_tree,hf_basic_bit_field,
2141                              tvb,offset,1,ENC_BIG_ENDIAN);
2142          proto_tree_add_item(msg_tree,
2143                              hf_audio_mgr_transducer_based_tone_id,
2144                              tvb,offset,1,ENC_BIG_ENDIAN);
2145          proto_tree_add_item(msg_tree,hf_audio_tone_level,tvb,offset,1,ENC_BIG_ENDIAN);
2146          offset+=1;
2147          break;
2148       case 0x1a:
2149    /*Visual Transducer Based Tone Enable*/
2150          proto_tree_add_item(msg_tree,hf_audio_visual_tones,
2151                              tvb,offset,1,ENC_BIG_ENDIAN);
2152          offset+=1;
2153          break;
2154       case 0x1b:
2155    /*Stream Based Tone On*/
2156          proto_tree_add_item(msg_tree,hf_basic_bit_field,tvb,offset,1,ENC_BIG_ENDIAN);
2157          proto_tree_add_item(msg_tree,hf_audio_stream_based_tone_id,
2158                              tvb,offset,1,ENC_BIG_ENDIAN);
2159          proto_tree_add_item(msg_tree,hf_audio_stream_based_tone_rx_tx,
2160                              tvb,offset,1,ENC_BIG_ENDIAN);
2161          proto_tree_add_item(msg_tree,hf_audio_stream_based_tone_mute,
2162                              tvb,offset,1,ENC_BIG_ENDIAN);
2163          offset+=1;
2164          proto_tree_add_item(msg_tree,hf_audio_stream_id,tvb,offset,1,ENC_BIG_ENDIAN);
2165          offset+=1;
2166          proto_tree_add_item(msg_tree,hf_audio_stream_based_volume,tvb,offset,1,ENC_BIG_ENDIAN);
2167          offset+=1;
2168          break;
2169       case 0x1c:
2170    /*Stream Based Tone Off*/
2171          proto_tree_add_item(msg_tree,hf_basic_bit_field,tvb,offset,1,ENC_BIG_ENDIAN);
2172          proto_tree_add_item(msg_tree,hf_audio_stream_based_tone_id,
2173                              tvb,offset,1,ENC_BIG_ENDIAN);
2174          proto_tree_add_item(msg_tree,hf_audio_stream_based_tone_rx_tx,
2175                              tvb,offset,1,ENC_BIG_ENDIAN);
2176          offset+=1;
2177          proto_tree_add_item(msg_tree,hf_audio_stream_id,tvb,offset,1,ENC_BIG_ENDIAN);
2178          offset+=1;
2179          break;
2180       case 0x1d:
2181    /*Stream Based Tone Frequency Component List Download*/
2182          proto_tree_add_item(msg_tree,hf_generic_data,tvb,offset,msg_len,ENC_NA);
2183          offset+=msg_len;
2184          break;
2185       case 0x1e:
2186    /*Stream Based Tone Cadence Download*/
2187          proto_tree_add_item(msg_tree,hf_generic_data,tvb,offset,msg_len,ENC_NA);
2188          offset+=msg_len;
2189          break;
2190       case 0x20:
2191    /*Select Adjustable Rx Volume*/
2192          proto_tree_add_item(msg_tree,hf_audio_default_rx_vol_id,
2193                              tvb,offset,1,ENC_BIG_ENDIAN);
2194          break;
2195       case 0x21:
2196    /*Set APB's Rx Volume Level*/
2197          proto_tree_add_item(msg_tree,hf_generic_data,tvb,offset,msg_len,ENC_NA);
2198          offset+=msg_len;
2199          break;
2200       case 0x22:
2201    /*Change Adjustable Rx Volume (quieter) DONE*/
2202          proto_tree_add_item(msg_tree,hf_generic_data,
2203                              tvb,offset,msg_len,ENC_NA);
2204          offset+=msg_len;
2205          break;
2206       case 0x23:
2207    /*Change Adjustable Rx Volume (louder) DONE*/
2208          proto_tree_add_item(msg_tree,hf_generic_data,
2209                              tvb,offset,msg_len,ENC_NA);
2210          offset+=msg_len;
2211          break;
2212       case 0x24:
2213    /*Adjust Default Rx Volume(quieter)*/
2214          proto_tree_add_item(msg_tree,hf_audio_default_rx_vol_id,
2215                              tvb,offset,1,ENC_BIG_ENDIAN);
2216          break;
2217       case 0x25:
2218    /*Adjust Default Rx Volume(louder)*/
2219          proto_tree_add_item(msg_tree,hf_audio_default_rx_vol_id,
2220                              tvb,offset,1,ENC_BIG_ENDIAN);
2221          break;
2222       case 0x28:
2223    /*APB Download*/
2224          proto_tree_add_item(msg_tree,hf_audio_apb_number,tvb,offset,1,ENC_BIG_ENDIAN);
2225          offset+=1;msg_len-=1;
2226          while(msg_len>0){
2227             apb_op_code=tvb_get_guint8(tvb,offset);
2228             proto_tree_add_item(msg_tree,hf_audio_apb_op_code,tvb,
2229                                 offset,1,ENC_BIG_ENDIAN);
2230             offset+=1;msg_len-=1;
2231             if(apb_op_code>0x39){
2232    /*should have a len + data*/
2233                apb_data_len=tvb_get_guint8(tvb,offset);
2234                proto_tree_add_item(msg_tree,hf_audio_apb_param_len,tvb,
2235                                    offset,1,ENC_BIG_ENDIAN);
2236                offset+=1;msg_len-=1;
2237                proto_tree_add_item(msg_tree,hf_audio_apb_data,tvb,
2238                                    offset,apb_data_len,ENC_NA);
2239                offset+=apb_data_len;msg_len-=apb_data_len;
2240             }
2241          }
2242          break;
2243       case 0x30:
2244    /*Open Audio Stream*/
2245          /* Set the tap info */
2246          uinfo->stream_connect = 1;
2247
2248          proto_tree_add_item(msg_tree,hf_audio_rx_stream_id,tvb,offset,1,ENC_BIG_ENDIAN);
2249          offset+=1;msg_len-=1;
2250          proto_tree_add_item(msg_tree,hf_audio_tx_stream_id,tvb,offset,1,ENC_BIG_ENDIAN);
2251          offset+=1;msg_len-=1;
2252          proto_tree_add_item(msg_tree,hf_rx_vocoder_type,tvb,offset,1,ENC_BIG_ENDIAN);
2253          offset+=1;msg_len-=1;
2254          proto_tree_add_item(msg_tree,hf_tx_vocoder_type,tvb,offset,1,ENC_BIG_ENDIAN);
2255          offset+=1;msg_len-=1;
2256          proto_tree_add_item(msg_tree,hf_frames_per_packet,tvb,offset,1,ENC_BIG_ENDIAN);
2257          offset+=1;msg_len-=1;
2258          proto_tree_add_item(msg_tree,hf_audio_tos,tvb,offset,1,ENC_BIG_ENDIAN);
2259          proto_tree_add_item(msg_tree,hf_audio_precedence,tvb,offset,1,ENC_BIG_ENDIAN);
2260          proto_tree_add_item(msg_tree,hf_audio_frf_11,tvb,offset,1,ENC_BIG_ENDIAN);
2261          offset+=1;msg_len-=1;
2262          proto_tree_add_item(msg_tree,hf_rtcp_bucket_id,
2263                              tvb,offset,1,ENC_BIG_ENDIAN);
2264          offset+=1;msg_len-=1;
2265          proto_tree_add_item(msg_tree,hf_generic_data,
2266                              tvb,offset,4,ENC_NA);
2267          offset+=4;msg_len-=4;
2268          proto_tree_add_item(msg_tree,hf_audio_lcl_rtp_port,
2269                              tvb,offset,2,ENC_BIG_ENDIAN);
2270          offset+=2;msg_len-=2;
2271          proto_tree_add_item(msg_tree,hf_audio_lcl_rtcp_port,
2272                              tvb,offset,2,ENC_BIG_ENDIAN);
2273          offset+=2;msg_len-=2;
2274
2275          proto_tree_add_item(msg_tree,hf_audio_far_rtp_port,
2276                              tvb,offset,2,ENC_BIG_ENDIAN);
2277          offset+=2;msg_len-=2;
2278          proto_tree_add_item(msg_tree,hf_audio_far_rtcp_port,
2279                              tvb,offset,2,ENC_BIG_ENDIAN);
2280          offset+=2;msg_len-=2;
2281
2282          /* Sometimes the open stream does not specify an endpoint */
2283          /* In this circumstance the packet is truncated at the far end */
2284          /* rtp port */
2285          if(msg_len > 0){
2286             proto_tree_add_item(msg_tree,hf_audio_far_ip_add,tvb,offset,4,ENC_BIG_ENDIAN);
2287             offset+=4;msg_len-=4;
2288             {
2289                guint32 far_ip_addr;
2290                address far_addr;
2291                guint16 far_port;
2292
2293                far_ip_addr = tvb_get_ipv4(tvb, offset-4);
2294                SET_ADDRESS(&far_addr, AT_IPv4, 4, &far_ip_addr);
2295
2296                far_port = tvb_get_ntohs(tvb, offset-8);
2297                rtp_add_address(pinfo, &far_addr, far_port, 0, "UNISTIM", pinfo->fd->num, FALSE, NULL);
2298
2299                far_port = tvb_get_ntohs(tvb, offset-6);
2300                rtcp_add_address(pinfo, &far_addr, far_port, 0, "UNISTIM", pinfo->fd->num);
2301             }
2302          }
2303          break;
2304       case 0x31:
2305    /*Close Audio Stream*/
2306          /* Set the tap info */
2307          uinfo->stream_connect = 0;
2308
2309          proto_tree_add_item(msg_tree,hf_audio_rx_stream_id,tvb,offset,1,ENC_BIG_ENDIAN);
2310          offset+=1;msg_len-=1;
2311          proto_tree_add_item(msg_tree,hf_audio_tx_stream_id,tvb,offset,1,ENC_BIG_ENDIAN);
2312          offset+=1;msg_len-=1;
2313          break;
2314       case 0x32:
2315    /*Connect Transducer*/
2316          /* Tap info again */
2317          uinfo->trans_connect = 1;
2318
2319          proto_tree_add_item(msg_tree,hf_basic_bit_field, tvb,offset,1,ENC_BIG_ENDIAN);
2320          proto_tree_add_item(msg_tree,hf_audio_transducer_pair,tvb,offset,1,ENC_BIG_ENDIAN);
2321          proto_tree_add_item(msg_tree,hf_audio_rx_enable,tvb,offset,1,ENC_BIG_ENDIAN);
2322          proto_tree_add_item(msg_tree,hf_audio_tx_enable,tvb,offset,1,ENC_BIG_ENDIAN);
2323          offset+=1;msg_len-=1;
2324          proto_tree_add_item(msg_tree,hf_basic_bit_field, tvb,offset,1,ENC_BIG_ENDIAN);
2325          proto_tree_add_item(msg_tree,hf_audio_apb_number,tvb,offset,1,ENC_BIG_ENDIAN);
2326          proto_tree_add_item(msg_tree,hf_audio_sidetone_disable,tvb,offset,1,ENC_BIG_ENDIAN);
2327          proto_tree_add_item(msg_tree,hf_audio_destruct_additive,tvb,offset,1,ENC_BIG_ENDIAN);
2328          proto_tree_add_item(msg_tree,hf_audio_dont_force_active,tvb,offset,1,ENC_BIG_ENDIAN);
2329          offset+=1;msg_len-=1;
2330          while(msg_len>0){
2331             proto_tree_add_item(msg_tree,hf_audio_mgr_stream_id,tvb,offset,1,ENC_LITTLE_ENDIAN);
2332             offset+=1;msg_len-=1;
2333          }
2334          break;
2335       case 0x34:
2336    /*Filter Block Download*/
2337          proto_tree_add_item(msg_tree,hf_generic_data,tvb,offset,msg_len,ENC_NA);
2338          offset+=msg_len;
2339          break;
2340       case 0x37:
2341    /*Query RTCP Statistics*/
2342          proto_tree_add_item(msg_tree,hf_audio_rtcp_bucket_id,tvb,offset,1,ENC_BIG_ENDIAN);
2343          proto_tree_add_item(msg_tree,hf_audio_clear_bucket,tvb,offset,1,ENC_BIG_ENDIAN);
2344
2345          offset+=1;msg_len-=1;
2346          break;
2347       case 0x38:
2348    /*Configure Vocoder Parameters*/
2349          proto_tree_add_item(msg_tree,hf_audio_mgr_stream_id,tvb,offset,1,ENC_LITTLE_ENDIAN);
2350          offset+=1;msg_len-=1;
2351          proto_tree_add_item(msg_tree,hf_audio_vocoder_id,tvb,offset,1,FALSE),
2352          offset+=1;msg_len-=1;
2353          while(msg_len>0){
2354             param=proto_tree_add_text(msg_tree,tvb,offset,0,"Param");
2355             param_tree=proto_item_add_subtree(param,ett_unistim);
2356             vocoder_param=tvb_get_guint8(tvb,offset);
2357             proto_tree_add_item(param_tree,hf_basic_bit_field,
2358                                 tvb,offset,1,ENC_BIG_ENDIAN);
2359             proto_tree_add_item(param_tree,hf_audio_vocoder_param,
2360                                 tvb,offset,1,ENC_BIG_ENDIAN);
2361             proto_tree_add_item(param_tree,hf_audio_vocoder_entity,
2362                                 tvb,offset,1,ENC_BIG_ENDIAN);
2363             offset+=1;msg_len-=1;
2364             if((vocoder_param&0x0a)==0x0a){
2365                proto_tree_add_item(param_tree,hf_audio_vocoder_annexa,
2366                                    tvb,offset,1,ENC_BIG_ENDIAN);
2367                proto_tree_add_item(param_tree,hf_audio_vocoder_annexb,
2368                                    tvb,offset,1,ENC_BIG_ENDIAN);
2369                offset+=1;msg_len-=1;
2370             }
2371             else if((vocoder_param&0x0b)==0x0b){
2372                proto_tree_add_item(param_tree,hf_audio_sample_rate,
2373                                    tvb,offset,1,ENC_BIG_ENDIAN);
2374                offset+=1;msg_len-=1;
2375             }
2376             else if((vocoder_param&0x0c)==0x0c){
2377                proto_tree_add_item(param_tree,hf_audio_rtp_type,
2378                                    tvb,offset,1,ENC_BIG_ENDIAN);
2379                offset+=1;msg_len-=1;
2380             }
2381             else if((vocoder_param&0x20)==0x20){
2382                proto_tree_add_item(param_tree,hf_audio_bytes_per_frame,
2383                                    tvb,offset,2,ENC_BIG_ENDIAN);
2384                offset+=2;msg_len-=2;
2385             }
2386          }
2387          break;
2388       case 0x39:
2389    /*Query RTCP Bucket's SDES Information*/
2390          proto_tree_add_item(msg_tree,hf_audio_source_descr,tvb,offset,msg_len,ENC_BIG_ENDIAN);
2391          proto_tree_add_item(msg_tree,hf_audio_sdes_rtcp_bucket,tvb,offset,msg_len,ENC_BIG_ENDIAN);
2392          offset+=1;msg_len-=1;
2393          break;
2394       case 0x3a:
2395    /*Jitter Buffer Parameters Configuration*/
2396          proto_tree_add_item(msg_tree,hf_audio_rx_stream_id,tvb,offset,1,ENC_BIG_ENDIAN);
2397          offset+=1;msg_len-=1;
2398          proto_tree_add_item(msg_tree,hf_audio_desired_jitter,tvb,offset,1,ENC_BIG_ENDIAN);
2399          offset+=1;msg_len-=1;
2400          proto_tree_add_item(msg_tree,hf_audio_high_water_mark,tvb,offset,1,ENC_BIG_ENDIAN);
2401          offset+=1;msg_len-=1;
2402          proto_tree_add_item(msg_tree,hf_audio_early_packet_resync_thresh,tvb,
2403                              offset,4,ENC_BIG_ENDIAN);
2404          offset+=4;msg_len-=4;
2405          proto_tree_add_item(msg_tree,hf_audio_late_packet_resync_thresh,tvb,
2406                              offset,4,ENC_BIG_ENDIAN);
2407          offset+=4;msg_len-=4;
2408          break;
2409       case 0x3b:
2410    /*Resolve Port Mapping*/
2411          proto_tree_add_item(msg_tree,hf_audio_resolve_phone_port,tvb,offset,2,ENC_BIG_ENDIAN);
2412          offset+=2;msg_len-=2;
2413          proto_tree_add_item(msg_tree,hf_audio_far_end_echo_port,tvb,offset,2,ENC_BIG_ENDIAN);
2414          offset+=2;msg_len-=2;
2415          proto_tree_add_item(msg_tree,hf_audio_far_end_ip_address,tvb,offset,4,ENC_BIG_ENDIAN);
2416          offset+=4;msg_len-=4;
2417          break;
2418       case 0x3c:
2419    /*Port Mapping Discovery Ack*/
2420          proto_tree_add_item(msg_tree,hf_audio_nat_port,tvb,offset,2,ENC_BIG_ENDIAN);
2421          offset+=2;msg_len-=2;
2422          proto_tree_add_item(msg_tree,hf_audio_nat_ip_address,tvb,offset,4,ENC_BIG_ENDIAN);
2423          offset+=4;msg_len-=4;
2424          break;
2425       case 0x3d:
2426    /*Query Audio Stream Status*/
2427          proto_tree_add_item(msg_tree,hf_audio_direction_code,tvb,offset,1,ENC_BIG_ENDIAN);
2428          offset+=1;msg_len-=1;
2429          proto_tree_add_item(msg_tree,hf_audio_mgr_stream_id,tvb,offset,1,ENC_BIG_ENDIAN);
2430          offset+=1;msg_len-=1;
2431          break;
2432       case 0xff:
2433    /*Reserved*/
2434       default:
2435          proto_tree_add_item(msg_tree,hf_generic_data,tvb,offset,msg_len,ENC_NA);
2436          offset+=msg_len;
2437    }
2438
2439    return offset;
2440 }
2441
2442 /*DONE*/
2443 static gint
2444 dissect_audio_phone(proto_tree *msg_tree,
2445                                  tvbuff_t *tvb,gint offset,guint msg_len){
2446    guint audio_cmd;
2447    guint apb_op_code;
2448    guint apb_data_len;
2449    guint stream_dir;
2450    guint stream_state;
2451    audio_cmd=tvb_get_guint8(tvb,offset);
2452    proto_tree_add_item(msg_tree,hf_audio_phone_cmd,tvb,offset,1,ENC_BIG_ENDIAN);
2453    offset+=1;msg_len-=1;
2454    switch(audio_cmd){
2455       case 0x00:
2456    /*Handset Connected length =3*/
2457          /* Set the tap info */
2458          uinfo->hook_state = 1;
2459          break;
2460       case 0x01:
2461    /*Handset Disconnected length =3*/
2462          /* Set the tap info */
2463          uinfo->hook_state = 0;
2464          break;
2465       case 0x02:
2466    /*Headset Connected length =3*/
2467          /* Set the tap info */
2468          uinfo->hook_state = 1;
2469          break;
2470       case 0x03:
2471    /*Headset Disconnected length =3*/
2472          /* Set the tap info */
2473          uinfo->hook_state = 0;
2474          break;
2475       case 0x04:
2476    /*Supervisor Headset Connected length =3*/
2477          /* Set the tap info */
2478          uinfo->hook_state = 1;
2479          break;
2480       case 0x05:
2481    /*Supervisor Headset Disconnected length =3*/
2482          /* Set the tap info */
2483          uinfo->hook_state = 0;
2484          break;
2485       case 0x07:
2486    /*Audio Manager Attributes Info*/
2487          proto_tree_add_item(msg_tree,hf_audio_hf_support,tvb,offset,1,ENC_BIG_ENDIAN);
2488          offset+=1;msg_len-=1;
2489          while(msg_len>0){
2490           proto_tree_add_item(msg_tree,hf_rx_vocoder_type,tvb,offset,1,ENC_BIG_ENDIAN);
2491           offset+=1;msg_len-=1;
2492          }
2493          break;
2494       case 0x08:
2495    /*Audio Manager Options Report*/
2496          proto_tree_add_item(msg_tree,hf_basic_bit_field,tvb,offset,1,ENC_BIG_ENDIAN);
2497          proto_tree_add_item(msg_tree,hf_audio_opt_rpt_max,tvb,offset,1,ENC_BIG_ENDIAN);
2498          proto_tree_add_item(msg_tree,hf_audio_opt_rpt_adj_vol,tvb,offset,1,ENC_BIG_ENDIAN);
2499          proto_tree_add_item(msg_tree,hf_audio_opt_rpt_auto_adj_vol,tvb,offset,1,ENC_BIG_ENDIAN);
2500          proto_tree_add_item(msg_tree,hf_audio_opt_rpt_hs_on_air,tvb,offset,1,ENC_BIG_ENDIAN);
2501          proto_tree_add_item(msg_tree,hf_audio_opt_rpt_hd_on_air,tvb,offset,1,ENC_BIG_ENDIAN);
2502          proto_tree_add_item(msg_tree,hf_audio_opt_rpt_noise_squelch,tvb,offset,1,ENC_BIG_ENDIAN);
2503          offset+=1;msg_len-=1;
2504          break;
2505       case 0x09:
2506    /*Adjustable Rx Volume Report*/
2507          proto_tree_add_item(msg_tree,hf_basic_bit_field,tvb,offset,1,ENC_BIG_ENDIAN);
2508          proto_tree_add_item(msg_tree,hf_audio_rx_vol_apb_rpt,tvb,offset,1,ENC_BIG_ENDIAN);
2509          proto_tree_add_item(msg_tree,hf_audio_rx_vol_vol_up,tvb,offset,1,ENC_BIG_ENDIAN);
2510          proto_tree_add_item(msg_tree,hf_audio_rx_vol_vol_floor,tvb,offset,1,ENC_BIG_ENDIAN);
2511          proto_tree_add_item(msg_tree,hf_audio_rx_vol_vol_ceiling,tvb,offset,1,ENC_BIG_ENDIAN);
2512          offset+=1;msg_len-=1;
2513          break;
2514       case 0x0a:
2515    /*Adjustable Rx Volume Information*/
2516          proto_tree_add_item(msg_tree,hf_audio_current_adj_vol_id,tvb,offset,1,ENC_BIG_ENDIAN);
2517          proto_tree_add_item(msg_tree,hf_audio_rx_vol_apb_rpt,tvb,offset,1,ENC_BIG_ENDIAN);
2518          proto_tree_add_item(msg_tree,hf_audio_rx_vol_vol_up,tvb,offset,1,ENC_BIG_ENDIAN);
2519          proto_tree_add_item(msg_tree,hf_audio_rx_vol_vol_floor,tvb,offset,1,ENC_BIG_ENDIAN);
2520          proto_tree_add_item(msg_tree,hf_audio_rx_vol_vol_ceiling,tvb,offset,1,ENC_BIG_ENDIAN);
2521          offset+=1;msg_len-=1;
2522          proto_tree_add_item(msg_tree,hf_audio_current_rx_level,tvb,offset,1,ENC_BIG_ENDIAN);
2523          offset+=1;msg_len-=1;
2524          proto_tree_add_item(msg_tree,hf_audio_current_rx_range,tvb,offset,1,ENC_BIG_ENDIAN);
2525          offset+=1;msg_len-=1;
2526          break;
2527       case 0x0b:
2528    /*APB's Default Rx Volume Value*/
2529          proto_tree_add_item(msg_tree,hf_audio_current_adj_vol_id,tvb,offset,1,ENC_BIG_ENDIAN);
2530          proto_tree_add_item(msg_tree,hf_audio_rx_vol_apb_rpt,tvb,offset,1,ENC_BIG_ENDIAN);
2531          proto_tree_add_item(msg_tree,hf_audio_rx_vol_vol_up,tvb,offset,1,ENC_BIG_ENDIAN);
2532          proto_tree_add_item(msg_tree,hf_audio_rx_vol_vol_floor,tvb,offset,1,ENC_BIG_ENDIAN);
2533          proto_tree_add_item(msg_tree,hf_audio_rx_vol_vol_ceiling,tvb,offset,1,ENC_BIG_ENDIAN);
2534          offset+=1;msg_len-=1;
2535          proto_tree_add_item(msg_tree,hf_audio_current_rx_level,tvb,offset,1,ENC_BIG_ENDIAN);
2536          offset+=1;msg_len-=1;
2537          proto_tree_add_item(msg_tree,hf_audio_current_rx_range,tvb,offset,1,ENC_BIG_ENDIAN);
2538          offset+=1;msg_len-=1;
2539          break;
2540       case 0x0c:
2541    /*Alerting Tone Select*/
2542          proto_tree_add_item(msg_tree,hf_audio_cadence_select,tvb,offset,1,ENC_BIG_ENDIAN);
2543          proto_tree_add_item(msg_tree,hf_audio_warbler_select,tvb,offset,1,ENC_BIG_ENDIAN);
2544          offset+=1;msg_len-=1;
2545          break;
2546       case 0x0e:
2547    /*RTCP Statistics Report UGLY*/
2548          proto_tree_add_item(msg_tree,hf_generic_data,tvb,offset,msg_len,ENC_NA);
2549          offset+=msg_len;
2550          break;
2551       case 0x0f:
2552    /*Open Audio Stream Report*/
2553          proto_tree_add_item(msg_tree,hf_audio_open_stream_rpt,tvb,offset,1,ENC_BIG_ENDIAN);
2554          offset+=1;msg_len-=1;
2555          break;
2556       case 0x10:
2557    /*RTCP Bucket SDES Information Report*/
2558          proto_tree_add_item(msg_tree,hf_audio_sdes_rpt_source_desc,tvb,offset,1,ENC_BIG_ENDIAN);
2559          proto_tree_add_item(msg_tree,hf_audio_sdes_rpt_buk_id,tvb,offset,1,ENC_BIG_ENDIAN);
2560          offset+=1;msg_len-=1;
2561          set_ascii_item(msg_tree,tvb,offset,msg_len);
2562          offset+=msg_len;
2563          break;
2564       case 0x11:
2565    /*Port Mapping Discovery*/
2566          proto_tree_add_item(msg_tree,hf_audio_phone_port,tvb,offset,2,ENC_BIG_ENDIAN);
2567          offset+=2;msg_len-=2;
2568          proto_tree_add_item(msg_tree,hf_audio_phone_ip,tvb,offset,4,ENC_BIG_ENDIAN);
2569          offset+=4;msg_len-=4;
2570          break;
2571       case 0x12:
2572    /*Resolve Port Mapping*/
2573          proto_tree_add_item(msg_tree,hf_audio_nat_listen_port,tvb,offset,2,ENC_BIG_ENDIAN);
2574          offset+=2;msg_len-=2;
2575          proto_tree_add_item(msg_tree,hf_audio_nat_ip,tvb,offset,4,ENC_BIG_ENDIAN);
2576          offset+=4;msg_len-=4;
2577          proto_tree_add_item(msg_tree,hf_audio_nat_add_len,tvb,offset,1,ENC_BIG_ENDIAN);
2578          offset+=1;msg_len-=1;
2579          proto_tree_add_item(msg_tree,hf_audio_phone_port,tvb,offset,2,ENC_BIG_ENDIAN);
2580          offset+=2;msg_len-=2;
2581          proto_tree_add_item(msg_tree,hf_audio_phone_ip,tvb,offset,4,ENC_BIG_ENDIAN);
2582          offset+=4;msg_len-=4;
2583          proto_tree_add_item(msg_tree,hf_audio_phone_add_len,tvb,offset,1,ENC_BIG_ENDIAN);
2584          offset+=1;msg_len-=1;
2585          break;
2586       case 0x13:
2587    /*Audio Stream Status Report*/
2588          stream_dir=tvb_get_guint8(tvb,offset);
2589          proto_tree_add_item(msg_tree,hf_audio_stream_direction_code,tvb,offset,1,ENC_BIG_ENDIAN);
2590          offset+=1;msg_len-=1;
2591          proto_tree_add_item(msg_tree,hf_audio_mgr_stream_id,tvb,offset,1,ENC_BIG_ENDIAN);
2592          offset+=1;msg_len-=1;
2593          stream_state=tvb_get_guint8(tvb,offset);
2594          proto_tree_add_item(msg_tree,hf_audio_stream_state,tvb,offset,1,ENC_BIG_ENDIAN);
2595          offset+=1;msg_len-=1;
2596          if((AUDIO_STREAM_STATE&stream_state)!=AUDIO_STREAM_STATE)
2597            break;
2598          if((AUDIO_STREAM_DIRECTION_RX&stream_dir)==AUDIO_STREAM_DIRECTION_RX)
2599             proto_tree_add_item(msg_tree,hf_rx_vocoder_type,tvb,offset,1,ENC_BIG_ENDIAN);
2600          else if((AUDIO_STREAM_DIRECTION_TX&stream_dir)==AUDIO_STREAM_DIRECTION_TX)
2601             proto_tree_add_item(msg_tree,hf_tx_vocoder_type,tvb,offset,1,ENC_BIG_ENDIAN);
2602          else
2603             proto_tree_add_item(msg_tree,hf_generic_data,tvb,offset,1,ENC_NA);
2604          offset+=1;msg_len-=1;
2605          proto_tree_add_item(msg_tree,hf_frames_per_packet,tvb,offset,1,ENC_BIG_ENDIAN);
2606          offset+=1;msg_len-=1;
2607          proto_tree_add_item(msg_tree,hf_audio_tos,tvb,offset,1,ENC_BIG_ENDIAN);
2608          proto_tree_add_item(msg_tree,hf_audio_precedence,tvb,offset,1,ENC_BIG_ENDIAN);
2609          proto_tree_add_item(msg_tree,hf_audio_frf_11,tvb,offset,1,ENC_BIG_ENDIAN);
2610          offset+=1;msg_len-=1;
2611          proto_tree_add_item(msg_tree,hf_rtcp_bucket_id,tvb,offset,1,ENC_BIG_ENDIAN);
2612          offset+=1;msg_len-=1;
2613          proto_tree_add_item(msg_tree,hf_audio_lcl_rtp_port,tvb,offset,2,ENC_BIG_ENDIAN);
2614          offset+=2;msg_len-=2;
2615          proto_tree_add_item(msg_tree,hf_audio_lcl_rtcp_port,tvb,offset,2,ENC_BIG_ENDIAN);
2616          offset+=2;msg_len-=2;
2617          proto_tree_add_item(msg_tree,hf_audio_far_rtp_port,tvb,offset,2,ENC_BIG_ENDIAN);
2618          offset+=2;msg_len-=2;
2619          proto_tree_add_item(msg_tree,hf_audio_far_rtcp_port,tvb,offset,2,ENC_BIG_ENDIAN);
2620          offset+=2;msg_len-=2;
2621          proto_tree_add_item(msg_tree,hf_audio_far_ip_add,tvb,offset,4,ENC_BIG_ENDIAN);
2622          offset+=4;msg_len-=4;
2623          proto_tree_add_item(msg_tree,hf_audio_transducer_list_length,tvb,offset,1,ENC_BIG_ENDIAN);
2624          offset+=1;msg_len-=1;
2625          while(msg_len>0){
2626             proto_tree_add_item(msg_tree,hf_audio_transducer_pair,tvb,offset,1,ENC_BIG_ENDIAN);
2627             offset+=1;msg_len-=1;
2628          }
2629       case 0x14:
2630    /*Query APB Response*/
2631          proto_tree_add_item(msg_tree,hf_audio_apb_number,tvb,offset,1,ENC_BIG_ENDIAN);
2632          offset+=1;msg_len-=1;
2633          while(msg_len>0){
2634             apb_op_code=tvb_get_guint8(tvb,offset);
2635             proto_tree_add_item(msg_tree,hf_audio_apb_op_code,tvb,
2636                                 offset,1,ENC_BIG_ENDIAN);
2637             offset+=1;msg_len-=1;
2638             if(apb_op_code>0x39){
2639                /*should have a len + data*/
2640                apb_data_len=tvb_get_guint8(tvb,offset);
2641                proto_tree_add_item(msg_tree,hf_audio_apb_param_len,tvb,
2642                                    offset,1,ENC_BIG_ENDIAN);
2643                offset+=1;msg_len-=1;
2644                proto_tree_add_item(msg_tree,hf_audio_apb_data,tvb,
2645                                    offset,apb_data_len,ENC_NA);
2646                offset+=apb_data_len;msg_len-=apb_data_len;
2647             }
2648          }
2649          break;
2650       case 0xff:
2651    /*Reserved*/
2652          break;
2653       default:
2654          proto_tree_add_item(msg_tree,hf_generic_data,tvb,offset,msg_len,ENC_NA);
2655          offset+=msg_len;
2656    }
2657
2658    return offset;
2659 }
2660
2661 static void
2662 set_ascii_item(proto_tree *msg_tree,tvbuff_t *tvb, gint offset,guint msg_len){
2663    proto_tree_add_text(msg_tree,tvb,offset,msg_len,"DATA: %s",
2664                        tvb_format_text(tvb,offset,msg_len));
2665 }
2666
2667 void
2668 proto_register_unistim(void){
2669
2670    module_t* unistim_module;
2671
2672    static hf_register_info hf[] = {
2673          { &hf_unistim_seq_nu,
2674             { "RUDP Seq Num","unistim.num",FT_UINT32,
2675                BASE_HEX|BASE_RANGE_STRING, RVALS(sequence_numbers), 0x0, NULL, HFILL}
2676          },
2677          { &hf_unistim_cmd_add,
2678             { "UNISTIM CMD Address","unistim.add",FT_UINT8,
2679                BASE_HEX,VALS(command_address),0x0,NULL,HFILL}
2680          },
2681          { &hf_uftp_command,
2682             { "UFTP CMD","uftp.cmd",FT_UINT8,
2683                BASE_HEX,VALS(uftp_commands),0x0,NULL,HFILL}
2684          },
2685          { &hf_uftp_datablock_size,
2686             { "UFTP Datablock Size","uftp.blocksize",FT_UINT32,
2687                BASE_DEC,NULL,0x0,NULL,HFILL}
2688          },
2689          { &hf_uftp_datablock_limit,
2690             { "UFTP Datablock Limit","uftp.limit",FT_UINT8,
2691                BASE_DEC,NULL,0x0,NULL,HFILL}
2692          },
2693          { &hf_uftp_filename,
2694             { "UFTP Filename","uftp.filename",FT_STRINGZ,
2695                BASE_NONE,NULL,0x0,NULL,HFILL}
2696          },
2697          { &hf_uftp_datablock,
2698             { "UFTP Data Block","uftp.datablock",FT_BYTES,
2699                BASE_NONE,NULL,0x0,NULL,HFILL}
2700          },
2701          { &hf_unistim_packet_type,
2702             { "RUDP Pkt type","unistim.type",FT_UINT8,
2703                BASE_DEC, VALS(packet_names),0x0,NULL,HFILL}
2704          },
2705          { &hf_unistim_payload,
2706             { "UNISTIM Payload","unistim.pay",FT_UINT8,
2707                BASE_HEX, VALS(payload_names),0x0,NULL,HFILL}
2708          },
2709          { &hf_unistim_len ,
2710             { "UNISTIM CMD Length","unistim.len",FT_UINT8,
2711                BASE_DEC,NULL,0x0,NULL,HFILL}
2712          },
2713          { &hf_basic_bit_field,
2714             {"FLAGS","unistim.bit.fields",FT_BOOLEAN,
2715                8,TFS(&basic_bit_yn),0xff,NULL,HFILL}
2716          },
2717          { &hf_basic_switch_cmd ,
2718             {"Basic Cmd (switch)","unistim.basic.switch",FT_UINT8,
2719                BASE_HEX,VALS(basic_switch_msgs),0x0,NULL,HFILL}
2720          },
2721          { &hf_basic_phone_cmd ,
2722             {"Basic Cmd (phone)","unistim.basic.phone",FT_UINT8,
2723                BASE_HEX,VALS(basic_phone_msgs),0x0,NULL,HFILL}
2724          },
2725          { &hf_broadcast_switch_cmd ,
2726             {"Broadcast Cmd (switch)","unistim.broadcast.switch",FT_UINT8,
2727                BASE_HEX,VALS(broadcast_switch_msgs),0x0,NULL,HFILL}
2728          },
2729          { &hf_broadcast_phone_cmd ,
2730             {"Broadcast Cmd (phone)","unistim.broadcast.phone",FT_UINT8,
2731                BASE_HEX,VALS(broadcast_phone_msgs),0x0,NULL,HFILL}
2732          },
2733          { &hf_audio_switch_cmd ,
2734             {"Audio Cmd (switch)","unistim.audio.switch",FT_UINT8,
2735                BASE_HEX,VALS(audio_switch_msgs),0x0,NULL,HFILL}
2736          },
2737          { &hf_audio_phone_cmd ,
2738             {"Audio Cmd (phone)","unistim.audio.phone",FT_UINT8,
2739                BASE_HEX,VALS(audio_phone_msgs),0x0,NULL,HFILL}
2740          },
2741          { &hf_display_switch_cmd ,
2742             {"Display Cmd (switch)","unistim.display.switch",FT_UINT8,
2743                BASE_HEX,VALS(display_switch_msgs),0x0,NULL,HFILL}
2744          },
2745          { &hf_display_phone_cmd ,
2746             {"Display Cmd (phone)","unistim.display.phone",FT_UINT8,
2747                BASE_HEX,VALS(display_phone_msgs),0x0,NULL,HFILL}
2748          },
2749          { &hf_key_switch_cmd ,
2750             {"Key Cmd (switch)","unistim.key.switch",FT_UINT8,
2751                BASE_HEX,VALS(key_switch_msgs),0x0,NULL,HFILL}
2752          },
2753          { &hf_key_phone_cmd ,
2754             {"Key Cmd (phone)","unistim.key.phone",FT_UINT8,
2755                BASE_HEX,VALS(key_phone_msgs),0x0,NULL,HFILL}
2756          },
2757          { &hf_network_switch_cmd ,
2758             {"Network Cmd (switch)","unistim.network.switch",FT_UINT8,
2759                BASE_HEX,VALS(network_switch_msgs),0x0,NULL,HFILL}
2760          },
2761          { &hf_network_phone_cmd ,
2762             {"Network Cmd (phone)","unistim.network.phone",FT_UINT8,
2763                BASE_HEX,VALS(network_phone_msgs),0x0,NULL,HFILL}
2764          },
2765          { &hf_terminal_id,
2766             {"Terminal ID","unistim.terminal.id",FT_IPv4,
2767                BASE_NONE,NULL,0x0,NULL,HFILL}
2768          },
2769          { &hf_broadcast_year,
2770             {"Year","unistim.broadcast.year",FT_UINT8,
2771                BASE_DEC,NULL,0x7f,NULL,HFILL}
2772          },
2773          { &hf_broadcast_month,
2774             {"Month","unistim.broadcast.month",FT_UINT8,
2775                BASE_DEC,NULL,0x0,NULL,HFILL}
2776          },
2777          { &hf_broadcast_day,
2778             {"Day","unistim.broadcast.day",FT_UINT8,
2779                BASE_DEC,NULL,0x0,NULL,HFILL}
2780          },
2781          { &hf_broadcast_hour,
2782             {"Hour","unistim.broadcast.hour",FT_UINT8,
2783                BASE_DEC,NULL,0x0,NULL,HFILL}
2784          },
2785          { &hf_broadcast_minute,
2786             {"Minute","unistim.broadcast.minute",FT_UINT8,
2787                BASE_DEC,NULL,0x0,NULL,HFILL}
2788          },
2789          { &hf_broadcast_second,
2790             {"Second","unistim.broadcast.second",FT_UINT8,
2791                BASE_DEC,NULL,0x0,NULL,HFILL}
2792          },
2793          { &hf_net_diag_flag,
2794             {"Query Network Manager Diagnostic","unistim.query.diagnostic",
2795                FT_BOOLEAN,8, NULL,
2796                QUERY_NETWORK_MANAGER_DIAGNOSTIC, NULL,HFILL}
2797          },
2798          { &hf_net_managers_flag,
2799             {"Query Network Manager Managers","unistim.query.managers",
2800                FT_BOOLEAN,8, NULL,
2801                QUERY_NETWORK_MANAGER_MANAGERS, NULL,HFILL}
2802          },
2803          { &hf_net_attributes_flag,
2804             {"Query Network Manager Attributes","unistim.query.attributes",
2805                FT_BOOLEAN, 8,NULL,
2806                QUERY_NETWORK_MANAGER_ATTRIBUTES,NULL,HFILL}
2807          },
2808          { &hf_net_serv_info_flag,
2809             {"Query Network Manager Server Info","unistim.query.serverInfo",
2810                FT_BOOLEAN, 8,NULL,
2811                QUERY_NETWORK_MANAGER_SERVER_INFO,NULL,HFILL}
2812          },
2813          { &hf_net_options_flag,
2814             {"Query Network Manager Options","unistim.query.options",
2815                FT_BOOLEAN, 8,NULL,
2816                QUERY_NETWORK_MANAGER_OPTIONS,NULL,HFILL}
2817          },
2818          { &hf_net_sanity_flag,
2819             {"Query Network Manager Sanity","unistim.query.sanity",
2820                FT_BOOLEAN, 8,NULL,
2821                QUERY_NETWORK_MANAGER_SANITY,NULL,HFILL}
2822          },
2823          { &hf_net_enable_diag,
2824             {"Network Manager Enable DIAG","unistim.enable.diag",
2825                FT_BOOLEAN, 8,NULL,
2826                NETWORK_MANAGER_ENABLE_DIAG,NULL,HFILL}
2827          },
2828          { &hf_net_enable_rudp,
2829             {"Network Manager Enable RUDP","unistim.enable.network.rel.udp",
2830                FT_BOOLEAN, 8,NULL,
2831                NETWORK_MANAGER_ENABLE_RUDP,NULL,HFILL}
2832          },
2833          { &hf_net_server_id,
2834             {"Download Server ID","unistim.download.id",FT_UINT8,
2835                BASE_HEX, VALS(network_server_id),0x00,NULL,HFILL}
2836          },
2837          { &hf_net_server_port,
2838             {"Download Server Port","unistim.download.port",FT_UINT16,
2839                BASE_DEC, NULL,0x00,NULL,HFILL}
2840          },
2841          { &hf_net_server_action,
2842             {"Download Server Action","unistim.download.action",FT_UINT8,
2843                BASE_HEX, VALS(server_action),0x00,NULL,HFILL}
2844          },
2845          { &hf_net_server_retry_count,
2846             {"Download Retry Count","unistim.download.retry",FT_UINT8,
2847                BASE_DEC, NULL,0x00,NULL,HFILL}
2848          },
2849          { &hf_net_server_failover_id,
2850             {"Download Failover Server ID","unistim.download.failover",FT_UINT8,
2851                BASE_HEX, VALS(network_server_id),0x00,NULL,HFILL}
2852          },
2853          { &hf_net_server_ip_address,
2854             {"Download Server Address","unistim.download.address",FT_UINT32,
2855                BASE_HEX, NULL,0x00,NULL,HFILL}
2856          },
2857          { &hf_net_server_time_out,
2858             {"Watchdog Timeout","unistim.watchdog.timeout",FT_UINT16,
2859                BASE_DEC, NULL,0x00,NULL,HFILL}
2860          },
2861          { &hf_net_server_config_element,
2862             {"Configure Network Element","unistim.config.element",FT_UINT8,
2863                BASE_HEX, VALS(network_elements),0x00,NULL,HFILL}
2864          },
2865          { &hf_net_server_recovery_time_low,
2866             {"Recovery Procedure Idle Low Boundary","unistim.recovery.low",FT_UINT16,
2867                BASE_DEC, NULL,0x00,NULL,HFILL}
2868          },
2869          { &hf_net_server_recovery_time_high,
2870             {"Recovery Procedure Idle High Boundary","unistim.recovery.high",FT_UINT16,
2871                BASE_DEC, NULL,0x00,NULL,HFILL}
2872          },
2873          { &hf_net_phone_rx_ovr_flag,
2874             {"Receive Buffer Overflow","unistim.receive.overflow",
2875                FT_BOOLEAN, 8,NULL,
2876                RX_BUFFER_OVERFLOW,NULL,HFILL}
2877          },
2878          { &hf_net_phone_tx_ovr_flag,
2879             {"Transmit Buffer Overflow","unistim.trans.overflow",
2880                FT_BOOLEAN, 8,NULL,
2881                TX_BUFFER_OVERFLOW,NULL,HFILL}
2882          },
2883          { &hf_net_phone_rx_empty_flag,
2884             {"Receive Buffer Unexpectedly Empty","unistim.receive.empty",
2885                FT_BOOLEAN, 8,NULL,
2886                RX_UNEXPECT_EMPTY,NULL,HFILL}
2887          },
2888          { &hf_net_phone_invalid_msg_flag,
2889             {"Received Invalid MSG","unistim.invalid.msg",
2890                FT_BOOLEAN, 8,NULL,
2891                INVALID_MSG,NULL,HFILL}
2892          },
2893          { &hf_net_phone_eeprom_insane_flag,
2894             {"EEProm Insane","unistim.eeprom.insane",
2895                FT_BOOLEAN, 8,NULL,
2896                EEPROM_INSANE,NULL,HFILL}
2897          },
2898          { &hf_net_phone_eeprom_unsafe_flag,
2899             {"EEProm Unsafe","unistim.eeprom.unsafe",
2900                FT_BOOLEAN, 8,NULL,
2901                EEPROM_UNSAFE,NULL,HFILL}
2902          },
2903          { &hf_net_phone_diag,
2904             {"Diagnostic Command Enabled","unistim.diag.enabled",FT_BOOLEAN,
2905               8,NULL,NETWORK_MGR_REPORT_DIAG,NULL,HFILL}
2906          },
2907          { &hf_net_phone_rudp,
2908             {"Reliable UDP Active","unistim.rudp.active",FT_BOOLEAN,
2909               8,NULL,NETWORK_MGR_REPORT_RUDP,NULL,HFILL}
2910          },
2911          { &hf_basic_switch_query_flags,
2912             {"Query Basic Manager","unistim.basic.query",FT_UINT8,
2913                BASE_HEX, NULL,0x00,"INITIAL PHONE QUERY",HFILL}
2914          },
2915          { &hf_basic_switch_query_attr,
2916             {"Query Basic Manager Attributes","unistim.basic.attrs",FT_BOOLEAN,
2917               8,NULL,BASIC_QUERY_ATTRIBUTES,"Basic Query Attributes",HFILL}
2918          },
2919          { &hf_basic_switch_query_opts,
2920             {"Query Basic Manager Options","unistim.basic.opts",FT_BOOLEAN,
2921               8,NULL,BASIC_QUERY_OPTIONS,"Basic Query Options",HFILL}
2922          },
2923          { &hf_basic_switch_query_fw,
2924             {"Query Basic Switch Firmware","unistim.basic.fw",FT_BOOLEAN,
2925                8,NULL,BASIC_QUERY_FW,"Basic Query Firmware",HFILL}
2926          },
2927          { &hf_basic_switch_query_hw_id,
2928             {"Query Basic Manager Hardware ID","unistim.basic.hwid",FT_BOOLEAN,
2929               8,NULL,BASIC_QUERY_HW_ID,"Basic Query Hardware ID",HFILL}
2930          },
2931          { &hf_basic_switch_query_it_type,
2932             {"Query Basic Manager Phone Type","unistim.basic.type",FT_BOOLEAN,
2933               8,NULL,BASIC_QUERY_IT_TYPE,"Basic Query Phone Type",HFILL}
2934          },
2935          { &hf_basic_switch_query_prod_eng_code,
2936             {"Query Basic Manager Prod Eng Code","unistim.basic.code",FT_BOOLEAN,
2937               8,NULL,BASIC_QUERY_PROD_ENG_CODE,"Basic Query Production Engineering Code",HFILL}
2938          },
2939          { &hf_basic_switch_query_gray_mkt_info,
2940             {"Query Basic Manager Gray Mkt Info","unistim.basic.gray",FT_BOOLEAN,
2941               8,NULL,BASIC_QUERY_GRAY_MKT_INFO,"Basic Query Gray Market Info",HFILL}
2942          },
2943          { &hf_basic_switch_options_secure,
2944             {"Basic Switch Options Secure Code","unistim.basic.secure",FT_BOOLEAN,
2945               8,NULL,BASIC_OPTION_SECURE,NULL,HFILL}
2946          },
2947          { &hf_basic_switch_element_id,
2948             {"Basic Element ID","unistim.basic.element.id",FT_UINT8,
2949                BASE_HEX,NULL,0x00,NULL,HFILL}
2950          },
2951          { &hf_basic_switch_eeprom_data,
2952             {"EEProm Data","unistim.basic.eeprom.data",FT_BYTES,
2953                BASE_NONE,NULL,0x00,NULL,HFILL}
2954          },
2955          { &hf_basic_phone_eeprom_stat_cksum,
2956             {"Basic Phone EEProm Static Checksum","unistim.static.cksum",FT_UINT8,
2957                BASE_HEX,NULL,0x0,NULL,HFILL}
2958          },
2959          { &hf_basic_phone_eeprom_dynam,
2960             {"Basic Phone EEProm Dynamic Checksum","unistim.dynam.cksum",FT_UINT8,
2961                BASE_HEX,NULL,0x00,NULL,HFILL}
2962          },
2963          { &hf_basic_phone_eeprom_net_config_cksum,
2964             {"Basic Phone EEProm Net Config Checksum","unistim.netconfig.cksum",FT_UINT8,
2965                BASE_HEX,NULL,0x00,NULL,HFILL}
2966          },
2967          { &hf_basic_phone_hw_id,
2968             {"Basic Phone Hardware ID","unistim.basic.hw.id",FT_BYTES,
2969                BASE_NONE,NULL,0x00,NULL,HFILL}
2970          },
2971          { &hf_basic_phone_fw_ver,
2972             {"Basic Phone Firmware Version","unistim.basic.fw.ver",FT_STRING,
2973                BASE_NONE,NULL,0x00,NULL,HFILL}
2974          },
2975          { &hf_key_code,
2976             {"Key Name","unistim.key.name",FT_UINT8,
2977                BASE_HEX,VALS(key_names),0x3f,NULL,HFILL}
2978          },
2979          { &hf_key_command,
2980             {"Key Action","unistim.key.action",FT_UINT8,
2981                BASE_HEX,VALS(key_cmds),0xc0,NULL,HFILL}
2982          },
2983          { &hf_icon_id,
2984             {"Icon ID","unistim.icon.id",FT_UINT8,
2985                BASE_HEX,NULL, DISPLAY_ICON_ID,NULL,HFILL}
2986          },
2987          { &hf_broadcast_icon_state,
2988             {"Icon State","unistim.icon.state",FT_UINT8,
2989                BASE_HEX,VALS(bcast_icon_states),0x1f,NULL,HFILL}
2990          },
2991          { &hf_broadcast_icon_cadence,
2992             {"Icon Cadence","unistim.icon.cadence",FT_UINT8,
2993                BASE_HEX,VALS(bcast_icon_cadence),0xe0,NULL,HFILL}
2994          },
2995          { &hf_audio_mgr_attr,
2996             {"Query Audio Manager Attributes","unistim.audio.attr",FT_BOOLEAN,
2997                8,NULL,QUERY_AUDIO_MGR_ATTRIBUTES,NULL,HFILL}
2998          },
2999          { &hf_audio_mgr_opts,
3000             {"Query Audio Manager Options","unistim.audio.options",FT_BOOLEAN,
3001                8,NULL,QUERY_AUDIO_MGR_OPTIONS,NULL,HFILL}
3002          },
3003          { &hf_audio_mgr_alert,
3004             {"Query Audio Manager Alerting","unistim.audio.alerting",FT_BOOLEAN,
3005                8,NULL,QUERY_AUDIO_MGR_ALERTING ,NULL,HFILL}
3006          },
3007          { &hf_audio_mgr_adj_rx_vol,
3008             {"Query Audio Manager Adjustable Receive Volume","unistim.audio.adj.volume",FT_BOOLEAN,
3009                8,NULL,QUERY_AUDIO_MGR_ADJ_RX_VOL,NULL,HFILL}
3010          },
3011          { &hf_audio_mgr_def_rx_vol,
3012             {"Query Audio Manager Default Receive Volume","unistim.audio.def.volume",FT_BOOLEAN,
3013                8,NULL,QUERY_AUDIO_MGR_DEF_RX_VOL,NULL,HFILL}
3014          },
3015          { &hf_audio_mgr_handset,
3016             {"Query Audio Manager Handset","unistim.audio.handset",FT_BOOLEAN,
3017                8,NULL,QUERY_AUDIO_MGR_HANDSET,NULL,HFILL}
3018          },
3019          { &hf_audio_mgr_headset,
3020             {"Query Audio Manager Headset","unistim.audio.headset",FT_BOOLEAN,
3021                8,NULL,QUERY_AUDIO_MGR_HEADSET,NULL,HFILL}
3022          },
3023          { &hf_audio_default_rx_vol_id,
3024             {"Audio Manager Default Receive Volume ID","unistim.audio.volume.id",FT_UINT8,
3025                BASE_HEX,VALS(default_rx_vol_id),0x00,NULL,HFILL}
3026          },
3027          { &hf_audio_mgr_opt_max_vol,
3028             {"Audio Manager Enable Max Tone Volume","unistim.audio.max.tone",FT_BOOLEAN,
3029                8,TFS(&audio_opts_enable_max_tone_vol),AUDIO_MGR_OPTS_MAX_VOL,NULL,HFILL}
3030          },
3031          { &hf_audio_mgr_opt_adj_vol,
3032             {"Audio Manager Adjust Volume","unistim.audio.opts.adj.vol",FT_BOOLEAN,
3033                8,TFS(&audio_opts_adjust_volume),AUDIO_MGR_ADJ_VOL,NULL,HFILL}
3034          },
3035          { &hf_audio_mgr_opt_aa_rx_vol_rpt,
3036             {"Audio Manager Auto Adjust Volume RPT","unistim.audio.aa.vol.rpt",FT_BOOLEAN,
3037                8,TFS(&audio_opts_automatic_adjustable),AUDIO_MGR_AUTO_RX_VOL_RPT,NULL,HFILL}
3038          },
3039          { &hf_audio_mgr_opt_hs_on_air,
3040             {"Audio Manager Handset","unistim.audio.handset",FT_BOOLEAN,
3041                8,TFS(&audio_opts_hs_on_air_feature),AUDIO_MGR_HS_ON_AIR,NULL,HFILL}
3042          },
3043          { &hf_audio_mgr_opt_hd_on_air,
3044             {"Audio Manager Headset","unistim.audio.headset",FT_BOOLEAN,
3045                8,TFS(&audio_opts_hd_on_air_feature),AUDIO_MGR_HD_ON_AIR,NULL,HFILL}
3046          },
3047          { &hf_audio_mgr_opt_noise_squelch,
3048             {"Audio Manager Noise Squelch","unistim.audio.squelch",FT_BOOLEAN,
3049                8,TFS(&noise_sqlch_disable), AUDIO_MGR_NOISE_SQUELCH,NULL,HFILL}
3050          },
3051          { &hf_audio_mgr_mute,
3052             {"Audio Manager Mute","unistim.audio.mute",FT_BOOLEAN,
3053                8,TFS(&audio_mgr_mute_val),AUDIO_MGR_MUTE,NULL,HFILL}
3054          },
3055          { &hf_audio_mgr_tx_rx,
3056             {"Audio Manager RX or TX","unistim.audio.rx.tx",FT_BOOLEAN,
3057                8,TFS(&audio_mgr_tx_rx_val),AUDIO_MGR_TX_RX,NULL,HFILL}
3058          },
3059          { &hf_audio_mgr_stream_id,
3060             {"Audio Manager Stream ID","unistim.audio.stream.id",FT_UINT8,
3061                BASE_DEC,NULL,0x00,NULL,HFILL}
3062          },
3063          { &hf_audio_mgr_transducer_based_tone_id,
3064             {"Audio Manager Transducer Based Tone On","unistim.audio.transducer.on",FT_UINT8,
3065                BASE_HEX,VALS(trans_base_tone_ids),0x07,NULL,HFILL}
3066          },
3067          { &hf_audio_mgr_attenuated,
3068             {"Audio Manager Transducer Tone Attenuated","unistim.audio.attenuated.on",FT_BOOLEAN,
3069                8,NULL,AUDIO_MGR_ATTENUATED,NULL,HFILL}
3070          },
3071          { &hf_audio_mgr_warbler_select,
3072             {"Warbler Select","unistim.warbler.select",FT_UINT8,
3073                BASE_HEX,NULL,0x07,NULL,HFILL}
3074          },
3075          { &hf_audio_mgr_transducer_routing,
3076             {"Transducer Routing","unistim.transducer.routing",FT_UINT8,
3077                BASE_HEX,VALS(transducer_routing_vals),0xf8,NULL,HFILL}
3078          },
3079          { &hf_audio_mgr_tone_vol_range,
3080             {"Tone Volume Range in Steps","unistim.tone.volume.range",FT_UINT8,
3081                BASE_HEX,NULL,0x0f,NULL,HFILL}
3082          },
3083          { &hf_audio_mgr_cadence_select,
3084             {"Cadence Select","unistim.cadence.select",FT_UINT8,
3085                BASE_HEX,VALS(cadence_select_vals),0xf0,NULL,HFILL}
3086          },
3087          { &hf_audio_special_tone,
3088             {"Special Tone Select","unistim.special.tone.select",FT_UINT8,
3089                BASE_HEX,VALS(special_tones_vals),0x00,NULL,HFILL}
3090          },
3091          { &hf_audio_tone_level,
3092             {"Tone Level","unistim.audio.tone.level",FT_UINT8,
3093                BASE_DEC,NULL,0xf0,NULL,HFILL}
3094          },
3095          { &hf_audio_visual_tones,
3096             {"Enable Visual Tones","unistim.visual.tones",FT_BOOLEAN,
3097                8,NULL,AUDIO_MGR_VISUAL_TONE,NULL,HFILL}
3098          },
3099          { &hf_audio_stream_based_tone_id,
3100             {"Stream Based Tone ID","unistim.stream.tone.id",FT_UINT8,
3101                BASE_HEX,VALS(stream_based_tone_vals),0x1f,NULL,HFILL}
3102          },
3103          { &hf_audio_stream_based_tone_rx_tx,
3104             {"Stream Based Tone RX or TX","unistim.stream.based.tone.rx.tx",FT_BOOLEAN,
3105                8,TFS(&stream_based_tone_rx_tx_yn),AUDIO_STREAM_BASED_TONE_RX_TX,NULL,HFILL}
3106          },
3107          { &hf_audio_stream_based_tone_mute,
3108             {"Stream Based Tone Mute","unistim.stream.tone.mute",FT_BOOLEAN,
3109                8,TFS(&stream_based_tone_mute_yn),AUDIO_STREAM_BASED_TONE_MUTE,NULL,HFILL}
3110          },
3111          { &hf_audio_stream_id,
3112             {"Stream ID","unistim.audio.stream.id",FT_UINT8,
3113                BASE_HEX,NULL,0x00,NULL,HFILL}
3114          },
3115          { &hf_audio_stream_based_volume,
3116             {"Stream Based Volume ID","unistim.stream.volume.id",FT_UINT8,
3117                BASE_HEX,VALS(stream_base_vol_level),0x00,NULL,HFILL}
3118  &