forked from hossimo/CITP-Dissector
-
Notifications
You must be signed in to change notification settings - Fork 0
/
citp.lua
1290 lines (1055 loc) · 42.1 KB
/
citp.lua
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
citp_proto = Proto("citp","CITP")
-- UDP and TCP Dissector Tables
udp_table = DissectorTable.get("udp.port")
tcp_table = DissectorTable.get("tcp.port")
-- Globals
dissector_version = "1.6.1"
dissector_date = "2017-01-31"
listeningport = 0
start = 0
count = 0
found_ports = {}
win = nil
-- Value Strings for Fields
local citp_base_contentTypes = {
-- CITP
--[[MSEX]] [0x4D534558] = "Media Server Extensions",
--[[PINF]] [0x50494E46] = "Peer Information layer",
--[[PNam]] [0x504E616D] = "Peer Name message",
--[[PLoc]] [0x504C6F63] = "Peer Location message",
-- MSEX
--[[CInf]] [0x43496E66] = "Client Information Message",
--[[SInf]] [0x53496E66] = "Server Information Message",
--[[Nack]] [0x4E61636B] = "Negative Acknowledge Message",
--[[LSta]] [0x4C537461] = "Layer Status Message",
--[[StFr]] [0x53744672] = "Stream Frame message",
--[[RqSt]] [0x52715374] = "Request Stream message",
--[[GEIn]] [0x4745496E] = "Get Element Information message",
--[[MEIn]] [0x4D45496E] = "Media Element Information message",
--[[GETh]] [0x47455468] = "Get Element Thumbnail message",
--[[EThn]] [0x4554686E] = "Element Thumbnail message",
--[[ELIn]] [0x454C496E] = "Element Library Information message",
--[[GELI]] [0x47454C49] = "Get Element Library Information message",
--[[GELT]] [0x47454C54] = "Get Element Library Thumbnail message",
--[[GVSr]] [0x47565372] = "GetVideoSources",
--[[VSrc]] [0x56537263] = "Video Sources",
-- Other
--[[CAEX]] [0x43414558] = "Capture Extensions"
}
local citp_caex_contentTypes = {
-- Live Views
[0x00000100] = "Get Live View Status",
[0x00000101] = "Live View Status",
[0x00000200] = "Get Live View Image",
[0x00000201] = "Live View Image",
-- Cue recording
[0x00010100] = "Set Cue Recording Capabilities",
[0x00010200] = "Record Cue",
[0x00010300] = "Set Recorder Clearing Capabilities",
[0x00010400] = "Clear Recorder",
-- Show Synchronization
[0x00020100] = "Enter Show",
[0x00020101] = "Leave Show",
[0x00020200] = "Fixture List Request",
[0x00020201] = "Fixture List",
[0x00020204] = "Fixture Identify",
[0x00020202] = "Fixture Modify",
[0x00020203] = "Fixture Remove",
[0x00020300] = "Fixture Selection",
[0x00020400] = "Fixture Console Status",
-- Laser Feeds
[0x00030100] = "Get Laser Feed List",
[0x00030101] = "Laser Feed List",
[0x00030102] = "Laser Feed Control",
[0x00030200] = "Laser Feed Frame",
}
local citp_pinf_contentTypes = {
--[[PNam]] [0x504e616d] = "Peer Name",
--[[PLoc]] [0x504c6f63] = "Peer Location",
}
-- CITP Base Fields
local citp_base_versionMajor_field = ProtoField.uint8( "citp.versionMajor", "Major Version", base.DEC)
local citp_base_versionMinor_field = ProtoField.uint8( "citp.versionMinor", "Minor Version", base.DEC)
local citp_base_reqRespID_field = ProtoField.uint16( "citp.reqRespID", "Request/Response ID", base.HEX)
local citp_base_msgPartCount_field = ProtoField.uint16( "citp.msgPartCount", "Message Part Count", base.HEX)
local citp_base_msgPart_field = ProtoField.uint16( "citp.msgPart", "Message Part", base.HEX)
local citp_base_contentType_field = ProtoField.uint32( "citp.contentType", "Content Type", base.HEX, citp_base_contentTypes)
-- CAEX Fields
local citp_caex_contentType_field = ProtoField.uint32( "citp.caex.contentType", "Content Type", base.HEX, citp_caex_contentTypes)
local citp_caex_laser_sourceKey_field = ProtoField.uint32( "citp.caex.laser.sourceKey", "Source Key", base.HEX)
local citp_caex_laser_feedIndex_field = ProtoField.uint8( "citp.caex.laser.feedIndex", "Feed Index", base.DEC)
local citp_caex_laser_numPts_field = ProtoField.uint16( "citp.caex.laser.numPts", "Number of Points", base.DEC)
-- PINF Fields
local citp_pinf_contentType_field = ProtoField.uint32( "citp.pinf.contentType", "Content Type", base.HEX, citp_pinf_contentTypes)
local citp_pinf_name_field = ProtoField.stringz( "citp.pinf.name", "Peer Name", base.ASCII)
local citp_pinf_type_field = ProtoField.stringz( "citp.pinf.type", "Peer Type", base.ASCII)
local citp_pinf_state_field = ProtoField.stringz( "citp.pinf.state", "Peer State", base.ASCII)
local citp_pinf_listPort_field = ProtoField.uint16( "citp.pinf.listeningPort", "Listening Port", base.DEC)
citp_proto.fields = {
citp_base_versionMajor_field,
citp_base_versionMinor_field,
citp_base_reqRespID_field,
citp_base_msgPartCount_field,
citp_base_msgPart_field,
citp_base_contentType_field,
citp_caex_contentType_field,
citp_caex_laser_sourceKey_field,
citp_caex_laser_feedIndex_field,
citp_caex_laser_numPts_field,
citp_pinf_contentType_field,
citp_pinf_name_field,
citp_pinf_type_field,
citp_pinf_state_field,
citp_pinf_listPort_field,
}
ct = {
-- CITP
MSEX = "Media Server Extensions",
PINF = "Peer Information layer",
PNam = "Peer Name message",
PLoc = "Peer Location message",
-- MSEX
CInf = "Client Information Message",
SInf = "Server Information Message",
Nack = "Negative Acknowledge Message",
LSta = "Layer Status Message",
StFr = "Stream Frame message",
RqSt = "Request Stream message",
GEIn = "Get Element Information message",
MEIn = "Media Element Information message",
GETh = "Get Element Thumbnail message",
EThn = "Element Thumbnail message",
ELIn = "Element Library Information message",
GELI = "Get Element Library Information message",
GELT = "Get Element Library Thumbnail message",
GVSr = "GetVideoSources",
VSrc = "Video Sources",
-- Other
CAEX = "Capture Extensions"
}
lt = {
"Media (Images & Video)",
"Effects",
"Cues",
"Crossfades",
"Masks",
"Blend presets",
"Effect presets",
"Image presets",
"3D meshes"
}
-- CAEX ------------------------------------------------------------------------
-- Capture CITP Extensions
--------------------------------------------------------------------------------
function caex_dissector(buffer, pinfo, subtree)
pinfo.cols.info:append ("CAEX >") -- info
caex_code = buffer(4,4):le_uint()
str = citp_caex_contentTypes[caex_code] or "(Unknown)"
pinfo.cols.info:append (str)
subtree:add_le(citp_caex_contentType_field, buffer(4,4))
if str == "Laser Feed List" then
subtree:add_le( citp_caex_laser_sourceKey, buffer(8,4))
nFeeds = buffer(12,1):le_uint()
subtree:add_le( buffer(12,1),"Feed Count: " .. buffer(12,1):le_uint())
feedNameStart = 13
for i=1,nFeeds do
str, l = ucs2ascii(feedNameStart, buffer)
subtree:add("Feed " .. (i) .. ": " .. str)
feedNameStart = feedNameStart + l
end
elseif str == "Laser Feed Frame" then
pinfo.cols.info:append (" >Feed " .. buffer(12,1):le_uint())
subtree:add_le( citp_caex_laser_sourceKey_field, buffer(8,4))
subtree:add( citp_caex_laser_feedIndex_field, buffer(12,1))
subtree:add( "Frame Seq Num: " .. buffer(13,4):le_uint())
subtree:add_le( citp_caex_laser_numPts_field, buffer(17,2))
elseif str == "Laser Feed Control" then
pinfo.cols.info:append (" >Feed " .. buffer(8,1):le_uint())
subtree:add( citp_caex_laser_feedIndex, buffer(8,1))
framerate = buffer(9,1):le_uint()
if framerate == 0 then
subtree:add( "Framerate: DISABLED")
else
subtree:add( "Framerate: " .. framerate)
end
end
end
-- PINF ------------------------------------------------------------------------
-- Peer Information layer
--------------------------------------------------------------------------------
function pinf_dissector(buffer, pinfo, subtree)
name=""
pinfo.cols.info:append ("PINF >") -- info
str = ct[buffer(4,4):string()] or "(Unknown)"
subtree:add(buffer(4,4), "Content Type: " .. buffer(4,4):string() .. " - " ..str)
subtree:add_le( citp_pinf_contentType_field, buffer(4,4))
-- PNam
if buffer(4,4):string() == "PNam" then
start = 8
name=buffer(start):string();
pinfo.cols.info:append ("PNam >") -- info
count = string.find(buffer(start):string(),"\0",1)
subtree:add(buffer(start, count),"Name: ".. buffer(start):string())
--PLoc
elseif buffer(4,4):string() == "PLoc" then
pinfo.cols.info:append ("PLoc >") -- info
listeningport = buffer(8,2):le_uint()
subtree:add(citp_pinf_listPort_field, buffer(8,2))
-- If we listening port is non zero then add to the dissector
if listeningport then
CITP_add_port(listeningport)
end
listeningport = 0
start = 10
name = buffer(start):string()
count = string.find(buffer(start):string(),"\0",1)
subtree:add(citp_pinf_type_field, buffer(start, count))
start = start+count
count = string.find(buffer(start):string(),"\0",1)
subtree:add(citp_pinf_name_field, buffer(start, count))
start = start+count
count = string.find(buffer(start):string(),"\0",1)
subtree:add(citp_pinf_state_field, buffer(start, count))
else
pinfo.cols.info:append ("Unknown format or content type")
end
pinfo.cols.info:append (name) -- info
end
function citp_proto.dissector(buffer,pinfo,tree)
listeningport = 0
start = 0
-- Check for buffer lengths less the CITP Header (20 Bytes)
if buffer:len() < 20 then -- We don't have enough to figure out message length
pinfo.desegment_len = 20 - buffer:len() -- get more data.
return
end
count = 4
cookie = buffer (start,count):string()
pinfo.cols.protocol = cookie
subtree = tree:add(citp_proto,buffer(), string.format("Controller Interface Transport Protocol, Length: %d Header: 22",buffer:len()))
start = start + count
count = 1
citp_version = string.format("%d.%d",buffer (start,count):le_uint(),buffer (start+1,count):le_uint())
-- subtree:add(buffer(start,count+1), "Version: " .. citp_version)
subtree:add(citp_base_versionMajor_field, buffer(4,1))
subtree:add(citp_base_versionMinor_field, buffer(5,1))
-- subtree:add(buffer(6,2), "Request/Response ID: " .. buffer(6,2):le_uint())
subtree:add(citp_base_reqRespID_field, buffer(6,2):le_uint())
message_size = buffer(8,4):le_uint()
subtree:add(buffer(8,4), "Message Size: " .. message_size)
subtree:add(buffer(12,2), "Message Part Count: " .. buffer(12,2):le_uint())
subtree:add(buffer(14,2), "Message Part: " .. buffer(14,2):le_uint())
subtree = subtree:add(citp_base_contentType_field, buffer(16,4))
contentType = buffer(16,4):string()
str = ct[contentType] or "(Unknown)"
-- subtree = subtree:add(buffer(16,4), string.format("Content Type: %s - %s, Length: %d",buffer(16,4):string(),
-- str,
-- string.len(buffer(20):string())))
pinfo.cols.info = string.format("CITP %s >",citp_version) -- info
-- Calculate message size and reassemble PDUs if needed.
if message_size > buffer:len() then
pinfo.desegment_len = message_size - buffer:len()
return
end
if contentType == "CAEX" then caex_dissector(buffer(16), pinfo, subtree)
elseif contentType == "PINF" then pinf_dissector(buffer(16), pinfo, subtree)
end
-- MSEX ------------------------------------------------------------------------
if buffer (16,4):string() == "MSEX" then
local str = ""
str = ct[buffer(22,4):string()] or "(Unknown)"
subtree:add(buffer(20), string.format("Length: %s",buffer:len()-20))
version = buffer (20,1):uint() .. "." .. buffer(21,1):uint()
subtree:add(buffer(20,2), "Version: " .. version)
subtree:add(buffer(22,4), "Content Type: " .. buffer(22,4):string().." - "..str)
pinfo.cols.info:append ("MSEX ".. version .." >") -- info
-- MSEX/CInf --------------------------------------------------------------------
-- Client Information message
if buffer(22,4):string() == "CInf" then
pinfo.cols.info:append ("CInf >") -- info
version_tree = subtree:add(buffer(26,1), "Supported Version Count: ".. buffer(26,1):uint())
start = 27
for i=1,buffer(26,1):uint() do
local supportVersion = buffer(start+1,1):uint() .. "." .. buffer(start,1):uint()
version_tree:add(buffer(start,2), "Supports: ".. supportVersion)
start = start+2
end
end
-- MSEX/SInf -------------------------------------------------------------------
-- Server Information message
if (buffer(22,4):string() == "SInf") then
pinfo.cols.info:append ("SInf >") -- info
start = 26
if version >= "1.2" then
count = 36
subtree:add(buffer(start,count), "UUID: ".. buffer(start,count):string())
start = start + count
end
-- Product Name (ASCII)
count = 0
str=""
while buffer(start+count,1):uint() ~= 0 do
str = str .. buffer(start+count,1):string()
count = count + 2
end
count = count + 2
subtree:add(buffer(start, count),"Product Name (ASCII): ".. str)
start = start + count
count = 2
local productVersion = buffer (start,1):uint() .. "." .. buffer(start+1,1):uint()
if version >= "1.2" then
count = 3
productVersion = productVersion .. "." .. buffer(start+2,1)
end
subtree:add(buffer(start,count), "Product Version: " .. productVersion)
start = start + count
if version >= "1.2" then
subtree:add(buffer(start,1), "Supported Version Count: ".. buffer(start,1):uint())
start = start + 1
for i=1,buffer(start-1,1):uint() do
local supportVersion = buffer(start+1,1):uint() .. "." .. buffer(start,1):uint()
subtree:add(buffer(start,2), "Supports: ".. supportVersion)
start = start+2
end
supported_types = buffer(start,2):le_uint()
if bit.band(supported_types,00000001) > 0 then
str = str .. lt[1] .. ", "
end
if bit.band(supported_types,00000002) > 0 then
str = str .. lt[2] .. ", "
end
if bit.band(supported_types,00000004) > 0 then
str = str .. lt[3] .. ", "
end
if bit.band(supported_types,00000008) > 0 then
str = str .. lt[4] .. ", "
end
if bit.band(supported_types,00000016) > 0 then
str = str .. lt[5] .. ", "
end
if bit.band(supported_types,00000032) > 0 then
str = str .. lt[6] .. ", "
end
if bit.band(supported_types,00000064) > 0 then
str = str .. lt[7] .. ", "
end
if bit.band(supported_types,00000128) > 0 then
str = str .. lt[8] .. ", "
end
if bit.band(supported_types,00000256) > 0 then
str = str .. lt[9] .. ", "
end
if supported_types == "00000000" then
str = "None, "
end
str = string.sub(str,1,-3)
subtree:add(buffer(start,2), "Supported Library Types: " .. str)
start = start + 2
count = buffer(start,1):uint()
subtree:add(buffer(start,1), "Thumbnail Format Count: ".. count)
start = start + 1
for i=0,count-1 do
subtree:add(buffer(start,4), "Thumbnail Format: ".. buffer(start,4):string())
start = start+4
end
count = buffer(start,1):uint()
subtree:add(buffer(start,1), "Stream Format Count: ".. count)
start = start + 1
for i=0,count-1 do
subtree:add(buffer(start,4), "Stream Format: ".. buffer(start,4):string())
start = start+4
end
end -- Version 1.2
count = 1
layercount = buffer(start, count):uint()
dmx = subtree:add(buffer(start,count), "Number of Layers: " .. layercount)
start = start + count
for i = 1, layercount do
count = string.find(buffer(start):string(),"\0",1)
dmx:add(buffer(start, count), "Layer ".. i .." DMX (proto/net/uni/chan.): " .. buffer(start):string())
start = start + count
end
pinfo.cols.info:append (string.format("Server: %s Layers: %d", str, layercount))
end
-- MSEX/Nack ------------------------------------------------------------------
-- Negative Acknowledge message
if buffer(22,4):string() == "Nack" then
pinfo.cols.info:append ("Nack >") -- info
subtree:add(buffer(22),"Received Content: " .. buffer(22):string())
end
-- MSEX/StFr ------------------------------------------------------------------
-- Stream Frame message
if buffer(22,4):string() == "StFr" then
pinfo.cols.info:append ("StFr >") -- info
start = 26
if version >= "1.2" then
subtree:add(buffer(start,36), "Media Server UUID: " .. buffer(start,36):string())
start = start + 36
end
-- Source ID
count = 2
sourceIdentifier = buffer(start,count):le_uint()
subtree:add(buffer(start,count),"SourceIdentifier: " .. sourceIdentifier)
start = start + count
-- Thumbs Format
count = 4
frameFormat = buffer(start,count):string()
subtree:add(buffer(start,count),"FrameFormat: " .. frameFormat)
start = start + count
-- Dimentions
dims, count = MSEX_Dims (buffer, start)
subtree:add(buffer(start,count), string.format("Dimensions: %s", dims))
start = start + count
-- Buffer Size
count = 2
subtree:add(buffer(start,count),"BufferSize: " .. buffer(start,count):uint())
bufferSize = buffer(start,count):le_uint()
start = start + count
pinfo.cols.info:append (string.format("SOURCE:%d %s %s",
sourceIdentifier,
frameFormat,
dims
))
end
-- MSEX/RqSt ------------------------------------------------------------------
-- Request Stream message
if buffer(22,4):string() == "RqSt" then
pinfo.cols.info:append ("RqSt >") -- info
start = 26
-- Source ID
count = 2
local sourceIdentifier = buffer(start,count):le_uint()
subtree:add(buffer(start,count),"SourceIdentifier: " .. sourceIdentifier)
start = start + count
-- Frame Format
count = 4
local frameFormat = buffer(start,count):string()
subtree:add(buffer(start,count),"FrameFormat: " .. frameFormat)
start = start + count
-- Dimentions
dims, count = MSEX_Dims (buffer, start)
subtree:add(buffer(start,count), string.format("Dimensions: %s", dims))
start = start + count
-- FPS
count = 1
local fps = buffer(start,count):le_uint()
subtree:add(buffer(start,count),"FPS: " .. fps)
start = start + count
-- Timeout
count = 1
local timeout = buffer(start,count):le_uint()
subtree:add(buffer(start,count),"Timeout: " .. timeout)
start = start + count
--info
pinfo.cols.info:append (string.format("SOURCE:%d %s %s@%d %dSec",
sourceIdentifier,
frameFormat,
dims,
fps,
timeout))
end
-- MSEX 1.0 - 1.2/EThn ------------------------------------------------------------------
-- Element Thumbnail message
if (buffer(22,4):string() == "EThn") and (version <= "1.1") then
start = 26
-- Library Type
str, count = MSEX_LibraryType (buffer, start)
subtree:add(buffer(start,count),string.format("Library Type: %s",str))
start = start + count
if version == "1.0" then
count = 1
libraryNumber = buffer(start,count):le_uint()
subtree:add(buffer(start,count),"LibraryNumber: " .. libraryNumber)
start = start + count
elseif version <= "1.2" then -- There is no definition for 1.2
-- LibraryID
libraryNumber, count = MSEX_LibraryID(buffer, start)
subtree:add(buffer(start,count),string.format("LibraryId: %s", libraryNumber))
start = start + count
end
-- Element
count = 1
element = buffer(start,count):uint()
subtree:add(buffer(start,count),string.format("Element: %d", element))
start = start + count
-- Thumbnail Format
count = 4
subtree:add(buffer(start,count),string.format("Thumbnail Format: %s", buffer(start,count):string()))
start = start + count
-- Dimentions
dims, count = MSEX_Dims (buffer, start)
subtree:add(buffer(start,count), string.format("Dimensions: %s", dims))
start = start + count
--Thumb Buffer
count = 2
subtree:add(buffer(start,count),string.format("Thumbs Buffer: %d", buffer(start,count):le_uint()))
start = start + count
-- Remainder of packet is frame data, or part of frame data
subtree:add(buffer(start),"Data")
--info
pinfo.cols.info:append (string.format("ETHn LibraryID:%s Element:%d",
libraryNumber,
element
)
)
end -- end EThn 1.0 - 1.2
-- MSEX/ELIn ------------------------------------------------------------------
-- Element Library Information message
if (buffer(22,4):string() == "ELIn") then
pinfo.cols.info:append ("ELIn >") -- info
start = 26
-- Library Type
str, count = MSEX_LibraryType (buffer, start)
subtree:add(buffer(start,count),string.format("Library Type: %s",str))
start = start + count
-- Element Count
-- Size of count in bytes
count = 1
if version >= "1.2" then
count = 2
end
library_count = buffer(start,count):le_uint()
element_tree = subtree:add(buffer(start,count),string.format("Library Count: %d", library_count))
start = start + count
for i = 1, library_count do
if version == "1.0" then
-- LibraryNumber
count = 1
lib_tree = element_tree:add(buffer(start,count),"LibraryNumber: " .. buffer(start,count):uint())
else
-- LibraryID
str, count = MSEX_LibraryID(buffer, start)
lib_tree = element_tree:add(buffer(start,count),string.format("LibraryId: %s", str))
end
start = start + count
if version >= "1.2" then
count = 4
lib_tree:add(buffer(start,count), "SerialNumber: " .. buffer(start,count):uint())
start = start + count
end
-- DMX Min
count = 1
lib_tree:add(buffer(start,count),string.format("DMX Min: %s", buffer(start,count):uint()))
start = start + count
-- DMX Max
count = 1
lib_tree:add(buffer(start,count),string.format("DMX Max: %s", buffer(start,count):uint()))
start = start + count
count = 0
str=""
while buffer(start + count,1):uint() ~= 0 do
str = str .. buffer(start+count,1):string()
count = count + 2
end
count = count + 2
lib_tree:add(buffer(start, count), string.format("Name: %s", str))
start = start + count
if version >= "1.1" then
count = 1
if version >= "1.2" then
count = 2
end
lib_tree:add(buffer(start,count),string.format("Sub Libraries %d", buffer(start,count):le_uint()))
start = start + count
end
count = 1
if version >= "1.2" then
count = 2
end
lib_tree:add(buffer(start,count),string.format("Element Count: %d", buffer(start,count):le_uint()))
start = start + count
end
pinfo.cols.info:append (string.format("Libraries: %d",library_count))
end
-- MSEX/LSta ------------------------------------------------------------------
-- Layer Status message
if buffer(22,4):string() == "LSta" then
pinfo.cols.info:append ("LSta >") -- info
start = 26
count = 1
layercount = buffer(start,count):uint()
subtree:add(buffer(start,count), "Layer Count: " .. layercount)
LSta = {}
LSta_status = {}
for i = 1, layercount do
start = start + count
count = 1
LSta[i] = subtree:add(buffer(start,count), "Layer Number:" .. buffer(start,count):uint() .." (".. buffer(start+2,1):uint().."/"..buffer(start+3,1):uint()..")")
start = start + count
count = 1
LSta[i]:add(buffer(start,count), "Physical Output: " .. buffer(start,count):uint())
start = start + count
count = 1
LSta[i]:add(buffer(start,count), "Media Library: " .. buffer(start,count):uint())
start = start + count
count = 1
LSta[i]:add(buffer(start,count), "Media Number: " .. buffer(start,count):uint())
start = start + count
count = 0
str=""
while buffer(start+count,1):uint() ~= 0 do
str = str .. buffer(start+count,1):string()
count = count + 2
end
count = count + 2
LSta[i]:add(buffer(start,count), "Media Name: " .. str)
start = start + count
count = 4
length = buffer(start,count):le_uint()
LSta[i]:add(buffer(start,count), "Media Position: " .. length)
start = start + count
count = 4
length = buffer(start,count):le_uint()
LSta[i]:add(buffer(start,count), "Media Length: " .. length)
start = start + count
count = 1
LSta[i]:add(buffer(start,count), "Media FPS: " .. buffer(start,count):uint())
start = start + count
count = 4
str = ""
current_stat = buffer(start+3,1) .. buffer(start+2,1).. buffer(start+1,1).. buffer(start,1)
if bit.band(current_stat,00000001) > 0 then
str = str .. "MediaPlaying, "
end
if bit.band(current_stat,00000002) > 0 then -- 1.2 Only
str = str .. "MediaPlaybackReverse, "
end
if bit.band(current_stat,00000004) > 0 then -- 1.2 Only
str = str .. "MediaPlaybackLooping, "
end
if bit.band(current_stat,00000008) > 0 then -- 1.2 Only
str = str .. "MediaPlaybackBouncing, "
end
if bit.band(current_stat,00000010) > 0 then -- 1.2 Only
str = str .. "MediaPlaybackRandom, "
end
if bit.band(current_stat,00000020) > 0 then -- 1.2 Only
str = str .. "MediaPaused, "
end
if current_stat == "00000000" then
str = "None, "
end
str = string.sub(str,1,-3)
LSta[i]:add(buffer(start,count), "Layer Status: ".."("..current_stat..") "..str)
end -- end for : Layer Count
--info
pinfo.cols.info:append (string.format("LAYER COUNT:%d",layercount))
end -- end if : MSEX/LSta
-- MSEX/MEIn ---------------------------------------------------------------------
-- Media Element Information message
if (buffer(22,4):string() == "MEIn") then
start = 26
if verison == "1.0" then
-- LibraryNumber
count = 1
libraryNumber = buffer(start,count):uint()
subtree:add(buffer(start,count),"LibraryNumber: " .. libraryNumber)
start = start + count
else
-- LibraryID
libraryId, count = MSEX_LibraryID(buffer, start)
subtree:add(buffer(start,count),string.format("LibraryId: %s", str))
start = start + count
end
count = 1
if version >= "1.2" then
count = 2
end
element_count = buffer(start,count):le_uint()
MEIn = subtree:add(buffer(start,count),string.format("Element Count: %d", element_count))
start = start + count
MEIn = {}
for i = 1, element_count do
count = 1
MEIn[i] = subtree:add(buffer(start,count),string.format("Number: %d", buffer(start,count):uint()))
start = start + count
if version >= "1.2" then
count = 4
MEIn[i]:add(buffer(start,count),string.format("SerialNumber: %d", buffer(start,count):uint()))
start = start + count
end
count = 1
MEIn[i]:add(buffer(start,count),string.format("DMX Start: %d", buffer(start,count):uint()))
start = start + count
count = 1
MEIn[i]:add(buffer(start,count),string.format("DMX End: %d", buffer(start,count):uint()))
start = start + count
count = 0
str=""
while buffer(start + count,1):uint() ~= 0 do --THIS IS BROKEN!?!?!
str = str .. buffer(start+count,1):string()
count = count + 2
end
count = count +2
MEIn[i]:add(buffer(start,count),string.format("Name: %s", str))
start = start + count --debug
-- This is a hack because le_uint64() returns the bigendian result
count = 8
epoch = 0
mult = 1
for j=0, count - 1 do
epoch = epoch + (buffer(start+j, 1):uint() * mult)
--debug
--MEIn[i]:add(buffer(start,count),string.format("%02d: %sx%d=%s", j, buffer(start+j, 1):uint(), mult, buffer(start+j, 1):uint()*mult))
mult = mult * 256
end
-- The time OSX displays and the epoch caluclation is off by a number of minues.
-- epoch and os.date seem to jive, but OSX time is wrong?
MEIn[i]:add(buffer(start,count),string.format("Time: %s (epoch:%d)", os.date("%c", epoch), epoch))
start = start + count
-- Dimentions
dims, count = MSEX_Dims (buffer, start)
subtree:add(buffer(start,count), string.format("Dimensions: %s", dims))
start = start + count
count = 4
MEIn[i]:add(buffer(start,count),string.format("Length (Frames): %d", buffer(start,count):le_uint()))
start = start + count
count = 1
MEIn[i]:add(buffer(start,count),string.format("FPS: %d", buffer(start,count):uint()))
start = start + count
end
-- info
if version == "1.0" then
pinfo.cols.info:append (string.format("MEIn LibraryNumber: %s Elements: %d",libraryNumber ,element_count))
else
pinfo.cols.info:append (string.format("MEIn LibraryID: %s Elements: %d",libraryId ,element_count))
end
end -- end if: MSEX/MEIn
-- MSEX/GEIn ---------------------------------------------------------------------
-- Get Element Information message
if (buffer(22,4):string() == "GEIn") then
start = 26
-- Library Type
str, count = MSEX_LibraryType (buffer, start)
subtree:add(buffer(start,count),string.format("Library Type: %s",str))
start = start + count
if version == "1.0" then
count = 1
libraryNumber = buffer(start,count):le_uint()
subtree:add(buffer(start,count),"LibraryNumber: " .. libraryNumber)
start = start + count
else
-- LibraryID
libraryId, count = MSEX_LibraryID(buffer, start)
subtree:add(buffer(start,count),string.format("LibraryId: %s", libraryId))
start = start + count
end
count = 1
if version >= "1.2" then
count = 2
end
elementCount = buffer(start,count):le_uint()
subtree:add(buffer(start,count),"ElementCount: " .. elementCount)
start = start + count
if (elementCount > 0) then
txt = ""
count = 1
for i = 1, elementCount do
elements:add(buffer(start,count),"Element Number: %d" .. buffer(start,count):le_uint())
start = start + count
end
else
txt = "All"
end
-- info
if version == "1.0" then
pinfo.cols.info:append (string.format("GEIn LibraryNumber: %s Count: %s (%d)", libraryNumber, txt, elementCount))
else
pinfo.cols.info:append (string.format("GEIn LibraryID: %s Count: %s (%d)", libraryId, txt, elementCount))
end
end -- end if: MSEX/GEIn
-- MSEX/GELI ---------------------------------------------------------------------
-- Get Element Library Information message
if (buffer(22,4):string() == "GELI") then
start = 26
-- Library Type
str, count = MSEX_LibraryType (buffer, start)
subtree:add(buffer(start,count),string.format("Library Type: %s",str))
start = start + count
if version >= "1.1" then
-- LibraryID
parentLibraryId, count = MSEX_LibraryID(buffer, start)
subtree:add(buffer(start,count),string.format("ParentLibraryId: %s", parentLibraryId))
start = start + count
end
count = 1
if version >= "1.2" then
count = 2
end
libraryCount = buffer(start,count):le_uint()
if libraryCount == 0 then
txt = "All"
else
txt = ""
end
elements = subtree:add(buffer(start,count),string.format("Library Count: (%d) %s", libraryCount, txt))
start = start + count
if (libraryCount > 0) then
count = 1
for i = 1, libraryCount do
elements:add(buffer(start,count),"Library Number: " .. buffer(start,count):le_uint())
start = start + count
end
end
-- info
pinfo.cols.info:append (string.format("GELI Count: %s (%d)", txt, libraryCount))
end -- end if: MSEX/GELI
-- MSEX/GELT ------------------------------------------------------------------
-- Get Element Library Thumbnail message
if (buffer(22,4):string() == "GELT") then
start = 26
-- Thumbnail Format
count = 4
thumbnailFormat = buffer(start,count):string()
subtree:add(buffer(start,count),string.format("Thumbnail Format: %s", thumbnailFormat))
start = start + count
-- Dimentions
dims, count = MSEX_Dims (buffer, start)
subtree:add(buffer(start,count), string.format("Dimensions: %s", dims))
start = start + count
-- Thumbnail Flags
count = 1
str = ""
current_stat = buffer(start,count):uint()
if bit.band(current_stat,00000001) > 0 then
str = str .. "Preserve aspect ratio, "
end
if current_stat == "00000000" then
str = "None, "
end
str = string.sub(str,1,-3) -- strip off the final ", "