/
packet-unistim.c
3866 lines (3721 loc) · 154 KB
/
packet-unistim.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/* packet-unistim.c
* Routines for unistim packet dissection
* Copyright 2007 Don Newton <dnewton@cypresscom.net>
*
* Wireshark - Network traffic analyzer
* By Gerald Combs <gerald@wireshark.org>
* Copyright 1998 Gerald Combs
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "config.h"
#include <string.h>
#include <epan/packet.h>
#include <epan/tap.h>
#include <epan/expert.h>
#include <epan/dissectors/packet-rtp.h>
#include <epan/dissectors/packet-rtcp.h>
#include "packet-unistim.h"
#include "defines.h"
#include "audio.h"
#include "basic.h"
#include "display.h"
#include "network.h"
#include "key.h"
#include "broadcast.h"
#include "uftp.h"
#include "expansion.h"
void proto_register_unistim(void);
static dissector_handle_t unistim_handle;
static unistim_info_t *uinfo;
static int unistim_tap;
void proto_reg_handoff_unistim(void);
static void dissect_payload(proto_tree *unistim_tree,tvbuff_t *tvb,gint offset, packet_info *pinfo);
static gint dissect_broadcast_switch(proto_tree *msg_tree,
tvbuff_t *tvb,gint offset,guint msg_len);
static gint dissect_audio_switch(proto_tree *msg_tree,packet_info *pinfo,
tvbuff_t *tvb,gint offset,guint msg_len);
static gint dissect_expansion_switch(proto_tree *msg_tree,
tvbuff_t *tvb,gint offset,guint msg_len);
static gint dissect_display_switch(proto_tree *msg_tree, packet_info *pinfo,
tvbuff_t *tvb,gint offset,guint msg_len);
static gint dissect_key_indicator_switch(proto_tree *msg_tree,
tvbuff_t *tvb,gint offset,guint msg_len);
static gint dissect_basic_switch(proto_tree *msg_tree,
tvbuff_t *tvb,gint offset,guint msg_len);
static gint dissect_network_switch(proto_tree *msg_tree,
tvbuff_t *tvb,gint offset,guint msg_len);
static gint dissect_broadcast_phone(proto_tree *msg_tree,
tvbuff_t *tvb,gint offset,guint msg_len);
static gint dissect_audio_phone(proto_tree *msg_tree,
tvbuff_t *tvb,gint offset,guint msg_len);
static gint dissect_expansion_phone(proto_tree *msg_tree,
tvbuff_t *tvb,gint offset,guint msg_len);
static gint dissect_display_phone(proto_tree *msg_tree,
tvbuff_t *tvb,gint offset,guint msg_len);
static gint dissect_key_indicator_phone(proto_tree *msg_tree,
tvbuff_t *tvb,gint offset,guint msg_len);
static gint dissect_basic_phone(proto_tree *msg_tree,
tvbuff_t *tvb,gint offset,guint msg_len);
static gint dissect_network_phone(proto_tree *msg_tree,
tvbuff_t *tvb,gint offset,guint msg_len);
static gint dissect_unistim_message(proto_tree *unistim_tree, packet_info *pinfo,
tvbuff_t *tvb,gint offset);
static gint dissect_uftp_message(proto_tree *unistim_tree, packet_info *pinfo,
tvbuff_t *tvb,gint offset);
static int proto_unistim;
static int hf_unistim_seq_nu;
static int hf_unistim_packet_type;
static int hf_unistim_payload;
static int hf_unistim_cmd_add;
static int hf_unistim_len;
static int hf_terminal_id;
static int hf_basic_bit_field;
static int hf_basic_switch_cmd;
static int hf_basic_phone_cmd;
static int hf_broadcast_switch_cmd;
/* static int hf_broadcast_phone_cmd; */
static int hf_audio_switch_cmd;
static int hf_audio_phone_cmd;
static int hf_display_switch_cmd;
static int hf_display_phone_cmd;
static int hf_key_switch_cmd;
static int hf_key_phone_cmd;
static int hf_network_switch_cmd;
static int hf_network_phone_cmd;
static int hf_expansion_switch_cmd;
static int hf_expansion_phone_cmd;
static int hf_module_key_number;
static int hf_generic_data;
static int hf_generic_string;
static gint ett_unistim;
static expert_field ei_unistim_len;
static const value_string packet_names[]={
{0,"NAK"},
{1,"ACK"},
{2,"Payload"},
{0,NULL}
};
static const value_string payload_names[]={
{0x00,"NULL Protocol"},
{0x01,"Aggregate Unistim"},
{0x02,"Aggregate Unistim with Terminal ID"},
{0x03,"UFTP"},
{0xff,"Free Form Protocol"},
{0,NULL}
};
static const range_string sequence_numbers[]={
{0x00,0xFFFFFFFE,"Normal Sequence Number"},
{0xFFFFFFFF,0xFFFFFFFF, "RESET Sequence Number"},
{0,0,NULL}
};
static const value_string command_address[]={
{0x09,"Expansion Module-1 Manager Switch"},
{0x0A,"Expansion Module-2 Manager Switch"},
{0x0B,"Expansion Module-3 Manager Switch"},
{0x0C,"Expansion Module-4 Manager Switch"},
{0x0D,"Expansion Module-5 Manager Switch"},
{0x0E,"Expansion Module-6 Manager Switch"},
{0x10,"Expansion Module Manager Phone"},
{0x11,"Broadcast Manager Switch"},
{0x16,"Audio Manager Switch"},
{0x17,"Display Manager Switch"},
{0x19,"Key/Indicator Manager Switch"},
{0x1a,"Basic Manager Switch"},
{0x1e,"Network Manager Switch"},
{0x89,"Expansion Module-1 Manager Phone"},
{0x8A,"Expansion Module-2 Manager Phone"},
{0x8B,"Expansion Module-3 Manager Phone"},
{0x8C,"Expansion Module-4 Manager Phone"},
{0x8D,"Expansion Module-5 Manager Phone"},
{0x8E,"Expansion Module-6 Manager Phone"},
{0x91,"Broadcast Manager Phone"},
{0x96,"Audio Manager Phone"},
{0x97,"Display Manager Phone"},
{0x99,"Key/Indicator Manager Phone"},
{0x9a,"Basic Manager Phone"},
{0x9e,"Network Manager Phone"},
{0,NULL}
};
static int
dissect_unistim(tvbuff_t *tvb,packet_info *pinfo,proto_tree *tree,void *data _U_){
gint offset=0;
proto_item *ti= NULL;
proto_tree *overall_unistim_tree = NULL;
proto_tree *rudpm_tree=NULL;
/* heuristic*/
switch(tvb_get_guint8(tvb,offset+4)) {/*rudp packet type 0,1,2 only */
case 0x0:/*NAK*/
case 0x1:/*ACK*/
break;
case 0x2:/*PAYLOAD*/
switch(tvb_get_guint8(tvb,offset+5)){/*payload type 0,1,2,3,ff only */
case 0x0: /*NULL*/
case 0x1: /*UNISTIM*/
case 0x2: /*UNISTIM WITH TERM ID*/
case 0x3: /*UFTP*/
case 0xff:/*UNKNOWN BUT VALID*/
break;
default:
return 0;
}
break;
default:
return 0;
}
col_set_str(pinfo->cinfo, COL_PROTOCOL, "UNISTIM");
/* Clear out stuff in the info column */
col_clear(pinfo->cinfo, COL_INFO);
ti = proto_tree_add_item(tree,proto_unistim,tvb,offset,-1,ENC_NA);
overall_unistim_tree = proto_item_add_subtree(ti,ett_unistim);
rudpm_tree=proto_tree_add_subtree(overall_unistim_tree,tvb,offset,5,ett_unistim,NULL,"Reliable UDP");
proto_tree_add_item(rudpm_tree,hf_unistim_seq_nu,tvb,offset,4,ENC_BIG_ENDIAN);
/* Allocate new mem for queueing */
uinfo = wmem_new(pinfo->pool, unistim_info_t);
/* Clear tap struct */
uinfo->rudp_type = 0;
uinfo->payload_type = 0;
uinfo->sequence = tvb_get_ntohl(tvb,offset);
uinfo->termid = 0;
uinfo->key_val = -1;
uinfo->key_state = -1;
uinfo->hook_state = -1;
uinfo->stream_connect = -1;
uinfo->trans_connect = -1;
uinfo->set_termid = -1;
uinfo->string_data = NULL;
uinfo->key_buffer = NULL;
clear_address(&uinfo->it_ip);
clear_address(&uinfo->ni_ip);
uinfo->it_port = 0;
offset+=4;
proto_tree_add_item(rudpm_tree,hf_unistim_packet_type,tvb,offset,1,ENC_BIG_ENDIAN);
uinfo->rudp_type = tvb_get_guint8(tvb,offset);
switch(tvb_get_guint8(tvb,offset)) {
case 0x00:
/*NAK*/
col_add_fstr(pinfo->cinfo, COL_INFO, "NAK for seq - 0x%X",
tvb_get_ntohl(tvb, offset-4));
break;
case 0x01:
/*ACK*/
col_add_fstr(pinfo->cinfo, COL_INFO, "ACK for seq - 0x%X",
tvb_get_ntohl(tvb, offset-4));
break;
case 0x02:
col_add_fstr(pinfo->cinfo, COL_INFO, "Payload seq - 0x%X",
tvb_get_ntohl(tvb, offset-4));
offset+=1;
dissect_payload(overall_unistim_tree,tvb,offset,pinfo);
break;
default:
return 0;
break;
}
/* Queue packet for tap */
tap_queue_packet(unistim_tap, pinfo, uinfo);
return tvb_captured_length(tvb);
}
static void
dissect_payload(proto_tree *overall_unistim_tree,tvbuff_t *tvb, gint offset, packet_info *pinfo){
proto_item *ti;
proto_tree *unistim_tree;
guint payload_proto=tvb_get_guint8(tvb,offset);
/* Payload type for tap */
uinfo->payload_type = payload_proto;
ti=proto_tree_add_item(overall_unistim_tree,hf_unistim_payload,
tvb,offset,1,ENC_BIG_ENDIAN);
offset+=1;
unistim_tree=proto_item_add_subtree(ti,ett_unistim);
switch(payload_proto){
case 0x00:
/*NULL PROTO - NOTHING LEFT TO DO*/
return;
case 0x01:
/*UNISTIM only so no term id but further payload work*/
/* Collect info for tap */
/* If no term id then packet sourced from NI */
copy_address(&(uinfo->ni_ip), &(pinfo->src));
copy_address(&(uinfo->it_ip), &(pinfo->dst));
uinfo->it_port = pinfo->destport;
break;
case 0x02:
/*UNISTIM with term id*/
/* Termid packs are always sourced from the it, so collect relevant infos */
copy_address(&(uinfo->ni_ip),&(pinfo->dst));
copy_address(&(uinfo->it_ip),&(pinfo->src));
uinfo->it_port = pinfo->srcport;
uinfo->termid = tvb_get_ntohl(tvb,offset);
proto_tree_add_item(unistim_tree,hf_terminal_id,tvb,offset,4,ENC_BIG_ENDIAN);
offset+=4;
break;
case 0x03:
/* UFTP */
offset = dissect_uftp_message(unistim_tree,pinfo,tvb,offset);
break;
case 0xff:
/*TODO flesh this out probably only for init*/
break;
}
/* Handle UFTP separately because it is significantly different
than standard UNISTIM */
while (tvb_reported_length_remaining(tvb, offset) > 0)
offset = dissect_unistim_message(unistim_tree,pinfo,tvb,offset);
}
static gint
dissect_uftp_message(proto_tree *unistim_tree,packet_info *pinfo _U_,tvbuff_t *tvb,gint offset){
guint command;
guint str_len;
guint dat_len;
proto_tree *msg_tree;
msg_tree = proto_tree_add_subtree(unistim_tree,tvb,offset,-1,ett_unistim,NULL,"UFTP CMD");
command=tvb_get_guint8(tvb,offset);
proto_tree_add_item(msg_tree,hf_uftp_command,tvb,offset,1,ENC_BIG_ENDIAN);
offset += 1;
switch(command)
{
case 0x80:
/* Connection request */
/* Nothing to do */
break;
case 0x81:
/* Connection Details */
/* Get datablock size */
proto_tree_add_item(msg_tree,hf_uftp_datablock_size,tvb,offset,2,ENC_BIG_ENDIAN);
offset+=2;
/* Get datablock limit b4 flow control */
proto_tree_add_item(msg_tree,hf_uftp_datablock_limit,tvb,offset,1,ENC_BIG_ENDIAN);
offset+=1;
/* Get filename */
str_len = tvb_reported_length_remaining(tvb, offset);
proto_tree_add_item(msg_tree,hf_uftp_filename,tvb,offset,str_len,ENC_ASCII|ENC_NA);
offset += str_len;
break;
case 0x82:
/* Flow Control off */
/* Nothing to do */
break;
case 0x00:
/* Connection Granted */
/* Nothing to do */
break;
case 0x01:
/* Connection Denied */
/* Nothing to do */
break;
case 0x02:
/* File Data Block */
/* Raw Data.. */
dat_len = tvb_reported_length_remaining(tvb, offset);
proto_tree_add_item(msg_tree,hf_uftp_datablock,tvb,offset,dat_len,ENC_NA);
offset += dat_len;
break;
}
return offset;
}
static gint
dissect_unistim_message(proto_tree *unistim_tree,packet_info *pinfo,tvbuff_t *tvb,gint offset){
guint addr;
guint msg_len;
proto_item *ti;
proto_tree *msg_tree;
msg_tree = proto_tree_add_subtree(unistim_tree,tvb,offset,-1,ett_unistim,&ti,"Unistim CMD");
addr=tvb_get_guint8(tvb,offset);
proto_tree_add_item(msg_tree,hf_unistim_cmd_add,tvb,offset,1,ENC_BIG_ENDIAN);
offset+=1;
msg_len=tvb_get_guint8(tvb,offset);
if (msg_len<=2)
{
ti=proto_tree_add_item(msg_tree,hf_unistim_len,tvb,offset,1,ENC_BIG_ENDIAN);
expert_add_info(pinfo,ti,&ei_unistim_len);
return tvb_reported_length(tvb);
} else {
proto_item_set_len(ti,msg_len);
proto_tree_add_item(msg_tree,hf_unistim_len,tvb,offset,1,ENC_BIG_ENDIAN);
}
offset+=1;
/*from switch*/
switch(addr){
case 0x00:
/*Nothing*/
break;
/*Expansion Manager Switch*/
case 0x09:
case 0x0A:
case 0x0B:
case 0x0C:
case 0x0D:
case 0x0E:
offset = dissect_expansion_switch(msg_tree,tvb,offset,msg_len-2);
break;
case 0x11:
/*Broadcast Manager Switch*/
offset = dissect_broadcast_switch(msg_tree,tvb,offset,msg_len-2);
break;
case 0x16:
/*Audio Manager Switch*/
offset = dissect_audio_switch(msg_tree,pinfo,tvb,offset,msg_len-2);
break;
case 0x17:
/*Display Manager Switch*/
offset = dissect_display_switch(msg_tree,pinfo,tvb,offset,msg_len-2);
break;
case 0x19:
/*Key Indicator Manager Switch*/
offset = dissect_key_indicator_switch(msg_tree,tvb,offset,msg_len-2);
break;
case 0x1a:
/*Basic Manager Switch*/
offset = dissect_basic_switch(msg_tree,tvb,offset,msg_len-2);
break;
case 0x1e:
/*Network Manager Switch*/
offset = dissect_network_switch(msg_tree,tvb,offset,msg_len-2);
break;
case 0x89:
case 0x8A:
case 0x8B:
case 0x8C:
case 0x8D:
case 0x8E:
/*Expansion Manager Phone*/
offset = dissect_expansion_phone(msg_tree,tvb,offset,msg_len-2);
break;
case 0x91:
/*Broadcast Manager phone*/
offset = dissect_broadcast_phone(msg_tree,tvb,offset,msg_len-2);
break;
case 0x96:
/*Audio Manager phone*/
offset = dissect_audio_phone(msg_tree,tvb,offset,msg_len-2);
break;
case 0x97:
/*Display Manager phone*/
offset = dissect_display_phone(msg_tree,tvb,offset,msg_len-2);
break;
case 0x99:
/*Key/Indicator Manager phone*/
offset = dissect_key_indicator_phone(msg_tree,tvb,offset,msg_len-2);
break;
case 0x9a:
/*Basic Manager phone*/
offset = dissect_basic_phone(msg_tree,tvb,offset,msg_len-2);
break;
case 0x9e:
/*Network Manager Switch*/
offset = dissect_network_phone(msg_tree,tvb,offset,msg_len-2);
break;
default:
/*See some undocumented messages. Don't want to miss the ones we understand*/
proto_tree_add_item(msg_tree,hf_generic_data,tvb,offset,msg_len-2,ENC_NA);
offset+=(msg_len-2);
}
if(msg_len){
/* TODO: add Expert info to indicate there is unknown data !
For the moment, this code only remove Clang Warnings about not used msg_len... */
}
return offset;
}
/*DONE*/
static gint
dissect_basic_phone(proto_tree *msg_tree,
tvbuff_t *tvb,gint offset, guint msg_len){
guint basic_cmd;
basic_cmd=tvb_get_guint8(tvb,offset);
proto_tree_add_item(msg_tree,hf_basic_phone_cmd,tvb,offset,1,ENC_BIG_ENDIAN);
offset+=1;msg_len-=1;
switch(basic_cmd){
case 0x00:
/*Basic Manager Attributes Info*/
proto_tree_add_item(msg_tree,hf_basic_phone_eeprom_stat_cksum,
tvb,offset,1,ENC_BIG_ENDIAN);
offset+=1;
proto_tree_add_item(msg_tree,hf_basic_phone_eeprom_dynam,
tvb,offset,1,ENC_BIG_ENDIAN);
offset+=1;
proto_tree_add_item(msg_tree,hf_basic_phone_eeprom_net_config_cksum,
tvb,offset,1,ENC_BIG_ENDIAN);
offset+=1;
break;
case 0x01:
/*Basic Manager Options Report*/
proto_tree_add_item(msg_tree,hf_basic_switch_options_secure,
tvb,offset,1,ENC_BIG_ENDIAN);
offset+=1;
break;
case 0x02:
/*Firmware Version*/
proto_tree_add_item(msg_tree,hf_basic_phone_fw_ver,
tvb,offset,msg_len,ENC_ASCII|ENC_NA);
offset+=msg_len;
break;
case 0x03:
/*IT Type*/
proto_tree_add_item(msg_tree,hf_basic_it_type,tvb,offset,1,ENC_BIG_ENDIAN);
offset+=1;
break;
case 0x07:
/*Hardware ID*/
proto_tree_add_item(msg_tree,hf_basic_phone_hw_id,
tvb,offset,msg_len,ENC_NA);
offset+=msg_len;
break;
case 0x08:
/*Product Engineering Code*/
proto_tree_add_item(msg_tree,hf_basic_prod_eng_code,
tvb,offset,msg_len,ENC_ASCII|ENC_NA);
offset+=msg_len;
break;
case 0x09:
/*Grey Market Info*/
proto_tree_add_item(msg_tree,hf_generic_data,tvb,offset,msg_len,ENC_NA);
offset+=msg_len;
break;
case 0x0a:
/*Encapsulate Command*/
proto_tree_add_item(msg_tree,hf_generic_data,tvb,offset,msg_len,ENC_NA);
offset+=msg_len;
break;
case 0x11:
/*Phone Ethernet address*/
proto_tree_add_item(msg_tree,hf_basic_ether_address,
tvb,offset,msg_len,ENC_NA);
offset+=msg_len;
break;
case 0x0b:
/*not in pdf but get them*/
proto_tree_add_item(msg_tree,hf_generic_string,tvb,offset,msg_len,ENC_ASCII|ENC_NA);
offset+=msg_len;
break;
case 0xff:
/*Reserved*/
break;
default:
proto_tree_add_item(msg_tree,hf_generic_data,tvb,offset,msg_len,ENC_NA);
offset+=msg_len;
}
if(msg_len){
/* TODO: add Expert info to indicate there is unknown data !
For the moment, this code only remove Clang Warnings about not used msg_len... */
}
return offset;
}
/*DONE*/
static gint
dissect_basic_switch(proto_tree *msg_tree,
tvbuff_t *tvb,gint offset,guint msg_len){
guint basic_cmd;
basic_cmd=tvb_get_guint8(tvb,offset);
proto_tree_add_item(msg_tree,hf_basic_switch_cmd,tvb,offset,1,ENC_BIG_ENDIAN);
offset+=1;msg_len-=1;
switch(basic_cmd){
case 0x01:
/*Query Basic Manager*/
proto_tree_add_item(msg_tree,hf_basic_bit_field,tvb,offset,1,ENC_BIG_ENDIAN);
proto_tree_add_item(msg_tree,hf_basic_switch_query_attr,
tvb,offset,1,ENC_BIG_ENDIAN);
proto_tree_add_item(msg_tree,hf_basic_switch_query_opts,
tvb,offset,1,ENC_BIG_ENDIAN);
proto_tree_add_item(msg_tree,hf_basic_switch_query_fw,
tvb,offset,1,ENC_BIG_ENDIAN);
proto_tree_add_item(msg_tree,hf_basic_switch_query_hw_id,
tvb,offset,1,ENC_BIG_ENDIAN);
proto_tree_add_item(msg_tree,hf_basic_switch_query_it_type,
tvb,offset,1,ENC_BIG_ENDIAN);
proto_tree_add_item(msg_tree,hf_basic_switch_query_prod_eng_code,
tvb,offset,1,ENC_BIG_ENDIAN);
proto_tree_add_item(msg_tree,hf_basic_switch_query_gray_mkt_info,
tvb,offset,1,ENC_BIG_ENDIAN);
offset+=1;
break;
case 0x02:
/*Basic Manager Options*/
proto_tree_add_item(msg_tree,hf_basic_switch_options_secure,
tvb,offset,1,ENC_BIG_ENDIAN);
offset+=1;
break;
case 0x06:
/*EEprom Write*/
proto_tree_add_item(msg_tree,hf_basic_switch_element_id,
tvb,offset,1,ENC_BIG_ENDIAN);
offset+=1;
proto_tree_add_item(msg_tree,hf_basic_switch_eeprom_data,
tvb,offset,msg_len,ENC_NA);
offset+=1;
break;
case 0x07:
/*Assign Terminal ID*/
/* Set tap info */
uinfo->set_termid = 1;
proto_tree_add_item(msg_tree,hf_basic_switch_terminal_id,
tvb,offset,msg_len,ENC_BIG_ENDIAN);
offset+=msg_len;
break;
case 0x08:
/*Encapsulate Command*/
proto_tree_add_item(msg_tree,hf_generic_data,tvb,offset,msg_len,ENC_NA);
offset+=msg_len;
break;
case 0x0f:
/*showing up in captures but not in pdf*/
proto_tree_add_item(msg_tree,hf_generic_data,tvb,offset,msg_len,ENC_NA);
offset+=msg_len;
case 0xff:
/*Reserved*/
break;
default:
proto_tree_add_item(msg_tree,hf_generic_data,tvb,offset,msg_len,ENC_NA);
offset+=msg_len;
}
if(msg_len){
/* TODO: add Expert info to indicate there is unknown data !
For the moment, this code only remove Clang Warnings about not used msg_len... */
}
return offset;
}
/*DONE*/
static gint
dissect_broadcast_switch(proto_tree *msg_tree,
tvbuff_t *tvb,gint offset, guint msg_len){
guint bcast_cmd;
guint year,month,day,hour,minute,second;
proto_tree *date_tree;
proto_tree *time_tree;
bcast_cmd=tvb_get_guint8(tvb,offset);
proto_tree_add_item(msg_tree,hf_broadcast_switch_cmd,tvb,offset,1,ENC_BIG_ENDIAN);
offset+=1;msg_len-=1;
switch(bcast_cmd){
case 0x00:
/*Accessory Sync Update - len=3 */
break;
case 0x01:
/*Logical Icon Update*/
proto_tree_add_item(msg_tree,hf_basic_bit_field,
tvb,offset,1,ENC_BIG_ENDIAN);
proto_tree_add_item(msg_tree,hf_broadcast_icon_state,
tvb,offset,1,ENC_BIG_ENDIAN);
proto_tree_add_item(msg_tree,hf_broadcast_icon_cadence,
tvb,offset,1,ENC_BIG_ENDIAN);
offset+=1;
break;
case 0x02:
/*Time and Date Download*/
year=tvb_get_guint8(tvb,offset);
month=tvb_get_guint8(tvb,offset+1);
day=tvb_get_guint8(tvb,offset+2);
hour=tvb_get_guint8(tvb,offset+3);
minute=tvb_get_guint8(tvb,offset+4);
second=tvb_get_guint8(tvb,offset+5);
date_tree=proto_tree_add_subtree_format(msg_tree,tvb,offset,3,ett_unistim,NULL,
"Date %i/%i/%i",month,day,year%100);
proto_tree_add_item(date_tree,hf_broadcast_year,tvb,offset,1,ENC_BIG_ENDIAN);
offset+=1;
proto_tree_add_item(date_tree,hf_broadcast_month,tvb,offset,1,ENC_BIG_ENDIAN);
offset+=1;
proto_tree_add_item(date_tree,hf_broadcast_day,tvb,offset,1,ENC_BIG_ENDIAN);
offset+=1;
time_tree=proto_tree_add_subtree_format(msg_tree,tvb,offset,3,ett_unistim,NULL,
"Time %i:%i:%i",hour,minute,second);
proto_tree_add_item(time_tree,hf_broadcast_hour,tvb,offset,1,ENC_BIG_ENDIAN);
offset+=1;
proto_tree_add_item(time_tree,hf_broadcast_minute,tvb,offset,1,ENC_BIG_ENDIAN);
offset+=1;
proto_tree_add_item(time_tree,hf_broadcast_second,tvb,offset,1,ENC_BIG_ENDIAN);
offset+=1;
break;
case 0x03:
/*Set Default Character Table Config */
/* UGLY may work may not*/
proto_tree_add_item(msg_tree,hf_generic_data,tvb,offset,msg_len,ENC_NA);
offset+=msg_len;
break;
case 0xff:
/*Reserved*/
break;
default:
proto_tree_add_item(msg_tree,hf_generic_data,tvb,offset,msg_len,ENC_NA);
offset+=msg_len;
}
if(msg_len){
/* TODO: add Expert info to indicate there is unknown data !
For the moment, this code only remove Clang Warnings about not used msg_len... */
}
return offset;
}
/*DONE Haven't seen any phone broadcasts, wouldn't expect to*/
static gint
dissect_broadcast_phone(proto_tree *msg_tree,
tvbuff_t *tvb, gint offset,guint msg_len){
proto_tree_add_item(msg_tree,hf_generic_data, tvb,offset,msg_len,ENC_NA);
offset+=msg_len;
return offset;
}
/*DONE*/
static gint
dissect_display_switch(proto_tree *msg_tree, packet_info *pinfo,
tvbuff_t *tvb, gint offset,guint msg_len){
guint clear_mask;
guint highlight_cmd;
guint time_date_mask;
guint display_cmd;
guint address_byte;
guint movement_byte;
proto_tree *address_tree;
display_cmd=tvb_get_guint8(tvb,offset);
proto_tree_add_item(msg_tree,hf_display_switch_cmd,tvb,offset,1,ENC_BIG_ENDIAN);
offset+=1;msg_len-=1;
switch(display_cmd){
case 0x01:
/*Restore Default Character Table Configuration length = 3*/
break;
case 0x04:
/*Arrow*/
proto_tree_add_item(msg_tree,hf_display_arrow,tvb,offset,1,ENC_BIG_ENDIAN);
offset+=1;
break;
case 0x05:
/*Query Status Bar Icon*/
proto_tree_add_item(msg_tree,hf_generic_data,tvb,offset,msg_len,ENC_NA);
offset+=msg_len;
break;
case 0x06:
/*Highlight Off length = 3*/
break;
case 0x07:
/*Highlight On length = 3*/
break;
case 0x09:
/*Restore Time and Date length = 3*/
break;
case 0x0a:
/*Clear Time and Date length = 3*/
break;
case 0x0b:
/*Call Duration Timer*/
proto_tree_add_item(msg_tree,hf_basic_bit_field,tvb,offset,1,ENC_BIG_ENDIAN);
proto_tree_add_item(msg_tree,hf_display_call_timer_mode,tvb,offset,
1,ENC_BIG_ENDIAN);
proto_tree_add_item(msg_tree,hf_display_call_timer_reset,tvb,offset,
1,ENC_BIG_ENDIAN);
proto_tree_add_item(msg_tree,hf_display_call_timer_display,tvb,offset,
1,ENC_BIG_ENDIAN);
proto_tree_add_item(msg_tree,hf_display_call_timer_delay,tvb,offset,
1,ENC_BIG_ENDIAN);
offset+=1;msg_len-=1;
proto_tree_add_item(msg_tree,hf_display_call_timer_id,tvb,offset,
1,ENC_BIG_ENDIAN);
offset+=1;msg_len-=1;
break;
case 0x0c:
/*Query Display Manager*/
proto_tree_add_item(msg_tree,hf_generic_data,tvb,offset,msg_len,ENC_NA);
offset+=msg_len;
break;
case 0x0d:
/*Download Call Duration Timer Delay*/
proto_tree_add_item(msg_tree,hf_generic_data,tvb,offset,msg_len,ENC_NA);
offset+=msg_len;
break;
case 0x0e:
/*Disable Display Field*/
proto_tree_add_item(msg_tree,hf_generic_data,tvb,offset,msg_len,ENC_NA);
offset+=msg_len;
break;
case 0x0f:
/*Clear Field*/
clear_mask=tvb_get_guint8(tvb,offset);
/*need to know which paths to take*/
proto_tree_add_item(msg_tree,hf_basic_bit_field,tvb,offset,1,ENC_BIG_ENDIAN);
proto_tree_add_item(msg_tree,hf_display_clear_numeric,
tvb,offset,1,ENC_BIG_ENDIAN);
proto_tree_add_item(msg_tree,hf_display_clear_context,
tvb,offset,1,ENC_BIG_ENDIAN);
proto_tree_add_item(msg_tree,hf_display_clear_date,
tvb,offset,1,ENC_BIG_ENDIAN);
proto_tree_add_item(msg_tree,hf_display_clear_time,
tvb,offset,1,ENC_BIG_ENDIAN);
proto_tree_add_item(msg_tree,hf_display_clear_line,
tvb,offset,1,ENC_BIG_ENDIAN);
proto_tree_add_item(msg_tree,hf_display_clear_status_bar_icon,
tvb,offset,1,ENC_BIG_ENDIAN);
proto_tree_add_item(msg_tree,hf_display_clear_softkey,
tvb,offset,1,ENC_BIG_ENDIAN);
proto_tree_add_item(msg_tree,hf_display_clear_softkey_label,
tvb,offset,1,ENC_BIG_ENDIAN);
offset+=1;msg_len-=1;
if((clear_mask&DISPLAY_CLEAR_LINE)==DISPLAY_CLEAR_LINE){
proto_tree_add_item(msg_tree,hf_basic_bit_field,tvb,offset,1,ENC_BIG_ENDIAN);
proto_tree_add_item(msg_tree,hf_display_clear_line_1,
tvb,offset,1,ENC_BIG_ENDIAN);
proto_tree_add_item(msg_tree,hf_display_clear_line_2,
tvb,offset,1,ENC_BIG_ENDIAN);
proto_tree_add_item(msg_tree,hf_display_clear_line_3,
tvb,offset,1,ENC_BIG_ENDIAN);
proto_tree_add_item(msg_tree,hf_display_clear_line_4,
tvb,offset,1,ENC_BIG_ENDIAN);
proto_tree_add_item(msg_tree,hf_display_clear_line_5,
tvb,offset,1,ENC_BIG_ENDIAN);
proto_tree_add_item(msg_tree,hf_display_clear_line_6,
tvb,offset,1,ENC_BIG_ENDIAN);
proto_tree_add_item(msg_tree,hf_display_clear_line_7,
tvb,offset,1,ENC_BIG_ENDIAN);
proto_tree_add_item(msg_tree,hf_display_clear_line_8,
tvb,offset,1,ENC_BIG_ENDIAN);
offset+=1;msg_len-=1;
}
if((clear_mask&DISPLAY_CLEAR_STATUS_BAR_ICON)==
DISPLAY_CLEAR_STATUS_BAR_ICON){
proto_tree_add_item(msg_tree,hf_basic_bit_field,tvb,offset,1,ENC_BIG_ENDIAN);
proto_tree_add_item(msg_tree,hf_display_clear_status_bar_icon_1,
tvb,offset,1,ENC_BIG_ENDIAN);
proto_tree_add_item(msg_tree,hf_display_clear_status_bar_icon_2,
tvb,offset,1,ENC_BIG_ENDIAN);
proto_tree_add_item(msg_tree,hf_display_clear_status_bar_icon_3,
tvb,offset,1,ENC_BIG_ENDIAN);
proto_tree_add_item(msg_tree,hf_display_clear_status_bar_icon_4,
tvb,offset,1,ENC_BIG_ENDIAN);
proto_tree_add_item(msg_tree,hf_display_clear_status_bar_icon_5,
tvb,offset,1,ENC_BIG_ENDIAN);
proto_tree_add_item(msg_tree,hf_display_clear_status_bar_icon_6,
tvb,offset,1,ENC_BIG_ENDIAN);
proto_tree_add_item(msg_tree,hf_display_clear_status_bar_icon_7,
tvb,offset,1,ENC_BIG_ENDIAN);
proto_tree_add_item(msg_tree,hf_display_clear_status_bar_icon_8,
tvb,offset,1,ENC_BIG_ENDIAN);
offset+=1;msg_len-=1;
}
if((clear_mask&DISPLAY_CLEAR_SOFTKEY)==DISPLAY_CLEAR_SOFTKEY){
proto_tree_add_item(msg_tree,hf_basic_bit_field,tvb,offset,1,ENC_BIG_ENDIAN);
proto_tree_add_item(msg_tree,hf_display_clear_soft_key_1,
tvb,offset,1,ENC_BIG_ENDIAN);
proto_tree_add_item(msg_tree,hf_display_clear_soft_key_2,
tvb,offset,1,ENC_BIG_ENDIAN);
proto_tree_add_item(msg_tree,hf_display_clear_soft_key_3,
tvb,offset,1,ENC_BIG_ENDIAN);
proto_tree_add_item(msg_tree,hf_display_clear_soft_key_4,
tvb,offset,1,ENC_BIG_ENDIAN);
proto_tree_add_item(msg_tree,hf_display_clear_soft_key_5,
tvb,offset,1,ENC_BIG_ENDIAN);
proto_tree_add_item(msg_tree,hf_display_clear_soft_key_6,
tvb,offset,1,ENC_BIG_ENDIAN);
proto_tree_add_item(msg_tree,hf_display_clear_soft_key_7,
tvb,offset,1,ENC_BIG_ENDIAN);
proto_tree_add_item(msg_tree,hf_display_clear_soft_key_8,
tvb,offset,1,ENC_BIG_ENDIAN);
offset+=1;msg_len-=1;
}
if((clear_mask&DISPLAY_CLEAR_SOFTKEY_LABEL)==DISPLAY_CLEAR_SOFTKEY_LABEL){
proto_tree_add_item(msg_tree,hf_basic_bit_field,tvb,offset,1,ENC_BIG_ENDIAN);
proto_tree_add_item(msg_tree,hf_display_clear_sk_label_key_id,tvb,offset,1,ENC_BIG_ENDIAN);
proto_tree_add_item(msg_tree,hf_display_clear_all_slks,tvb,offset,1,ENC_BIG_ENDIAN);
offset+=1;msg_len-=1;
}
break;
case 0x10:
/*Cursor Control*/
movement_byte=tvb_get_guint8(tvb,offset);
proto_tree_add_item(msg_tree,hf_basic_bit_field,tvb,offset,1,ENC_BIG_ENDIAN);
proto_tree_add_item(msg_tree,hf_display_cursor_move_cmd,tvb,offset,1,ENC_BIG_ENDIAN);
proto_tree_add_item(msg_tree,hf_display_cursor_blink,tvb,offset,1,ENC_BIG_ENDIAN);
offset+=1;msg_len-=1;
if(msg_len==0){
/*turn cursor off*/
break;
}
if((movement_byte&0x01)==0x01){
address_byte=tvb_get_guint8(tvb,offset);
proto_tree_add_item(msg_tree,hf_basic_bit_field,tvb,offset,1,ENC_BIG_ENDIAN);
proto_tree_add_item(msg_tree,hf_display_write_address_numeric,
tvb,offset,1,ENC_BIG_ENDIAN);
proto_tree_add_item(msg_tree,hf_display_write_address_context,
tvb,offset,1,ENC_BIG_ENDIAN);
proto_tree_add_item(msg_tree,hf_display_write_address_line,
tvb,offset,1,ENC_BIG_ENDIAN);
proto_tree_add_item(msg_tree,hf_display_write_address_soft_key,
tvb,offset,1,ENC_BIG_ENDIAN);
if((address_byte&DISPLAY_WRITE_ADDRESS_SOFT_KEY_FLAG)==
DISPLAY_WRITE_ADDRESS_SOFT_KEY_FLAG)
proto_tree_add_item(msg_tree,
hf_display_write_address_softkey_id,
tvb,offset,1,ENC_BIG_ENDIAN);
offset+=1;msg_len-=1;
if(msg_len==0){
/*turn cursor off*/
break;
}
}
proto_tree_add_item(msg_tree,hf_basic_bit_field,tvb,offset,1,ENC_BIG_ENDIAN);
proto_tree_add_item(msg_tree,hf_display_write_address_char_pos,
tvb,offset,1,ENC_BIG_ENDIAN);
proto_tree_add_item(msg_tree,hf_display_write_address_line_number,
tvb,offset,1,ENC_BIG_ENDIAN);
offset+=1;msg_len-=1;
break;
case 0x12:
/*Display Scroll with Data (before)*/
proto_tree_add_item(msg_tree,hf_generic_string,tvb,offset,msg_len,ENC_ASCII|ENC_NA);
offset+=msg_len;
break;
case 0x13:
/*Display Scroll with Data (after)*/
proto_tree_add_item(msg_tree,hf_generic_string,tvb,offset,msg_len,ENC_ASCII|ENC_NA);
offset+=msg_len;
break;
case 0x14:
/*Status Bar Icon Update*/
proto_tree_add_item(msg_tree,hf_basic_bit_field, tvb,offset,1,ENC_BIG_ENDIAN);
proto_tree_add_item(msg_tree,hf_icon_id,tvb,offset,1,ENC_BIG_ENDIAN);
offset+=1;
proto_tree_add_item(msg_tree,hf_basic_bit_field, tvb,offset,1,ENC_BIG_ENDIAN);
proto_tree_add_item(msg_tree,hf_broadcast_icon_state,
tvb,offset,1,ENC_BIG_ENDIAN);
proto_tree_add_item(msg_tree,hf_broadcast_icon_cadence,
tvb,offset,1,ENC_BIG_ENDIAN);
offset+=1;
break;
case 0x15:
/*Month Labels Download*/
proto_tree_add_item(msg_tree,hf_generic_string,tvb,offset,msg_len,ENC_ASCII|ENC_NA);
offset+=msg_len;
break;
case 0x16:
/*Call Duration Timer Label Download*/
proto_tree_add_item(msg_tree,hf_generic_string,tvb,offset,msg_len,ENC_ASCII|ENC_NA);
offset+=1;msg_len-=1;
break;
case 0x17:
/*Time and Date Format*/
time_date_mask=tvb_get_guint8(tvb,offset);
if((time_date_mask&DISPLAY_USE_TIME_FORMAT)==DISPLAY_USE_TIME_FORMAT){
proto_tree_add_item(msg_tree,hf_display_time_format,tvb,offset,1,ENC_BIG_ENDIAN);
}
if((time_date_mask&DISPLAY_USE_DATE_FORMAT)==DISPLAY_USE_DATE_FORMAT){
proto_tree_add_item(msg_tree,hf_display_date_format,tvb,offset,1,ENC_BIG_ENDIAN);
}
proto_tree_add_item(msg_tree,hf_display_use_time_format,tvb,offset,1,ENC_BIG_ENDIAN);
proto_tree_add_item(msg_tree,hf_display_use_date_format,tvb,offset,1,ENC_BIG_ENDIAN);
offset+=1;msg_len-=1;
break;
/*Address, control, tag: treat as bitmask to reduce code duplication*/
case 0x18: /*address|no control|no tag|no*/
case 0x19: /*address|yes control|no tag|no*/
case 0x1A: /*address|no control|yes tag|no*/
case 0x1B: /*address|yes control|yes tag|no*/
case 0x1C: /*address|no control|no tag|yes*/
case 0x1D: /*address|yes control|no tag|yes*/
case 0x1E: /*address|no control|yes tag|yes*/
case 0x1F: /*address|yes control|yes tag|yes*/
#define F_ADDR 1
#define F_CTRL 2
#define F_TAG 4
if((display_cmd&F_ADDR)==F_ADDR){
address_tree=proto_tree_add_subtree(msg_tree,tvb,offset,0,ett_unistim,NULL,"Address Data");
address_byte=tvb_get_guint8(tvb,offset);
proto_tree_add_item(address_tree,hf_basic_bit_field,
tvb,offset,1,ENC_BIG_ENDIAN);
proto_tree_add_item(address_tree,hf_display_write_address_numeric,
tvb,offset,1,ENC_BIG_ENDIAN);