-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathwireshark_lua_api.lua
More file actions
4755 lines (3854 loc) · 156 KB
/
wireshark_lua_api.lua
File metadata and controls
4755 lines (3854 loc) · 156 KB
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
---@meta
--[[
Base Wireshark proto definitions.
Annotations are EmmyLua format, as used by the Sumneko VSCode extension.
]]
---@enum FtypesEnum
--NOTE[javi]: Not real values of enum
ftypes = {
BOOLEAN = 0,
CHAR = 0,
UINT8 = 0,
UINT16 = 0,
UINT24 = 0,
UINT32 = 0,
UINT64 = 0,
INT8 = 0,
INT16 = 0,
INT24 = 0,
INT32 = 0,
INT64 = 0,
FLOAT = 0,
DOUBLE = 0,
ABSOLUTE_TIME = 0,
RELATIVE_TIME = 0,
STRING = 0,
STRINGZ = 0,
UINT_STRING = 0,
ETHER = 0,
BYTES = 0,
UINT_BYTES = 0,
IPv4 = 0,
IPv6 = 0,
IPXNET = 0,
FRAMENUM = 0,
PCRE = 0,
GUID = 0,
OID = 0,
PROTOCOL = 0,
REL_OID = 0,
SYSTEM_ID = 0,
EUI64 = 0,
NONE = 0,
}
--NOTE[javi]: Not the actual values
MENU_PACKET_ANALYZE_UNSORTED = 0 -- Analyze
MENU_PACKET_STAT_UNSORTED = 0 -- Statistics
MENU_STAT_GENERIC = 0 -- Statistics, first section
MENU_STAT_CONVERSATION_LIST = 0 -- Statistics → Conversation List
MENU_STAT_ENDPOINT_LIST = 0 -- Statistics → Endpoint List
MENU_STAT_RESPONSE_TIME = 0 -- Statistics → Service Response Time
MENU_STAT_RSERPOOL = 0 --= Statistics → Reliable Server Pooling (RSerPool)
MENU_STAT_TELEPHONY = 0 -- Telephony
MENU_STAT_TELEPHONY_ANSI = 0 -- Telephony → ANSI
MENU_STAT_TELEPHONY_GSM = 0 -- Telephony → GSM
MENU_STAT_TELEPHONY_LTE = 0 -- Telephony → LTE
MENU_STAT_TELEPHONY_MTP3 = 0 -- Telephony → MTP3
MENU_STAT_TELEPHONY_SCTP = 0 -- Telephony → SCTP
MENU_ANALYZE = 0 -- Analyze
MENU_ANALYZE_CONVERSATION_FILTER = 0 -- Analyze → Conversation Filter
MENU_TOOLS_UNSORTED = 0 -- Tools
MENU_LOG_ANALYZE_UNSORTED = 0 -- Analyze
MENU_LOG_STAT_UNSORTED = 0 --= 16
---@deprecated
MENU_ANALYZE_UNSORTED = 0 -- superseded by MENU_PACKET_ANALYZE_UNSORTED
---@deprecated
MENU_ANALYZE_CONVERSATION = 0 -- superseded by MENU_ANALYZE_CONVERSATION_FILTER
---@deprecated
MENU_STAT_CONVERSATION = 0 -- superseded by MENU_STAT_CONVERSATION_LIST
---@deprecated
MENU_STAT_ENDPOINT = 0 -- superseded by MENU_STAT_ENDPOINT_LIST
---@deprecated
MENU_STAT_RESPONSE = 0 -- superseded by MENU_STAT_RESPONSE_TIME
---@deprecated
MENU_STAT_UNSORTED = 0 -- superseded by MENU_PACKET_STAT_UNSORTED
---@enum BaseEnum
--NOTE[javi]: Not real values of enum
base = {
NONE = 0,
DEC = 0,
HEX = 0,
OCT = 0,
DEC_HEX = 0,
HEX_DEC = 0,
UNIT_STRING = 0,
RANGE_STRING = 0,
LOCAL = 0,
UTC = 0,
DOY_UTC = 0,
ASCII = 0,
UNICODE = 0,
DOT = 0,
DASH = 0,
COLON = 0,
SPACE = 0,
}
expert = {
---@enum ExpertGroupEnum
--NOTE[javi]: Not real values of enum
group = {
CHECKSUM = 0,
SEQUENCE = 0,
RESPONSE_CODE = 0,
REQUEST_CODE = 0,
UNDECODED = 0,
REASSEMBLE = 0,
MALFORMED = 0,
DEBUG = 0,
PROTOCOL = 0,
SECURITY = 0,
COMMENTS_GROUP = 0,
DECRYPTION = 0,
ASSUMPTION = 0,
DEPRECATED = 0,
},
---@enum ExpertSeverityEnum
--NOTE[javi]: Not real values of enum
severity = {
COMMENT = 0,
CHAT = 0,
NOTE = 0,
WARN = 0,
ERROR = 0,
},
}
---@enum FrameEnum
--NOTE[javi]: Not real values of enum
frametype = {
NONE = 0,
REQUEST = 0,
RESPONSE = 0,
ACK = 0,
DUP_ACK = 0,
}
---@enum EncodingEnum
--NOTE[javi]: Not real values of enum
encoding = {
ENC_ASCII = 0,
ENC_UTF_8 = 0,
ENC_UTF_16 = 0,
ENC_UCS_2 = 0,
ENC_UCS_4 = 0,
ENC_WINDOWS_1250 = 0,
ENC_WINDOWS_1251 = 0,
ENC_WINDOWS_1252 = 0,
ENC_ISO_646_BASIC = 0,
ENC_ISO_8859_1 = 0,
ENC_ISO_8859_2 = 0,
ENC_ISO_8859_3 = 0,
ENC_ISO_8859_4 = 0,
ENC_ISO_8859_5 = 0,
ENC_ISO_8859_6 = 0,
ENC_ISO_8859_7 = 0,
ENC_ISO_8859_8 = 0,
ENC_ISO_8859_9 = 0,
ENC_ISO_8859_10 = 0,
ENC_ISO_8859_11 = 0,
ENC_ISO_8859_13 = 0,
ENC_ISO_8859_14 = 0,
ENC_ISO_8859_15 = 0,
ENC_ISO_8859_16 = 0,
ENC_3GPP_TS_23_038_7BITS = 0,
ENC_3GPP_TS_23_038_7BITS_UNPACKED = 0,
ENC_ETSI_TS_102_221_ANNEX_A = 0,
ENC_EBCDIC = 0,
ENC_EBCDIC_CP037 = 0,
ENC_EBCDIC_CP500 = 0,
ENC_MAC_ROMAN = 0,
ENC_CP437 = 0,
ENC_CP855 = 0,
ENC_CP866 = 0,
ENC_ASCII_7BITS = 0,
ENC_T61 = 0,
ENC_BCD_DIGITS_0_9 = 0,
ENC_KEYPAD_ABC_TBCD = 0,
ENC_KEYPAD_BC_TBCD = 0,
ENC_GB18030 = 0,
ENC_EUC_KR = 0,
ENC_DECT_STANDARD_8BITS = 0,
ENC_DECT_STANDARD_4BITS_TBCD = 0,
}
---@enum WtapEncapsEnum
wtap_encaps = {
["3MB_ETHERNET"] = 184,
APPLE_IP_OVER_IEEE1394 = 62,
ARCNET_LINUX = 9,
ARCNET = 8,
ASCEND = 16,
ATM_PDUS_UNTRUNCATED = 14,
ATM_PDUS = 13,
ATM_RFC1483 = 10,
ATSC_ALP = 220,
AUERSWALD_LOG = 219,
AUTOSAR_DLT = 218,
AX25_KISS = 147,
AX25 = 148,
BACNET_MS_TP_WITH_PHDR = 143,
BACNET_MS_TP = 63,
BER = 90,
BLUETOOTH_BREDR_BB = 160,
BLUETOOTH_H4_WITH_PHDR = 99,
BLUETOOTH_H4 = 41,
BLUETOOTH_HCI = 102,
BLUETOOTH_LE_LL_WITH_PHDR = 161,
BLUETOOTH_LE_LL = 154,
BLUETOOTH_LINUX_MONITOR = 159,
CAN20B = 109,
CATAPULT_DCT2000 = 89,
CHDLC_WITH_PHDR = 40,
CHDLC = 28,
CISCO_IOS = 29,
COSINE = 34,
DBUS = 146,
DECT_NR = 225,
DOCSIS = 33,
DOCSIS31_XRA31 = 199,
DPAUXMON = 200,
DPNSS = 117,
DVBCI = 132,
EBHSCR = 204,
EMS = 224,
ENC = 38,
EPON = 172,
ERF = 98,
ERI_ENB_LOG = 213,
ETHERNET_MPACKET = 198,
ETHERNET = 1,
ETW = 212,
FDDI_BITSWAPPED = 6,
FDDI = 5,
FIBRE_CHANNEL_FC2_WITH_FRAME_DELIMS = 122,
FIBRE_CHANNEL_FC2 = 121,
FIRA_UCI = 221,
FLEXRAY = 106,
FRELAY_WITH_PHDR = 27,
FRELAY = 26,
GCOM_SERIAL = 78,
GCOM_TIE1 = 77,
GFP_F = 179,
GFP_T = 178,
GPRS_LLC = 66,
GSM_UM = 116,
HHDLC = 32,
I2C_LINUX = 112,
IEEE_802_11_AVS = 24,
IEEE_802_11_NETMON = 126,
IEEE_802_11_PRISM = 21,
IEEE_802_11_RADIOTAP = 23,
IEEE_802_11_WITH_RADIO = 22,
IEEE_802_11 = 20,
IEEE802_15_4_NOFCS = 127,
IEEE802_15_4_NONASK_PHY = 113,
IEEE802_15_4_TAP = 206,
IEEE802_15_4 = 104,
IEEE802_16_MAC_CPS = 93,
INFINIBAND = 150,
IP_OVER_FC = 18,
IP_OVER_IB_PCAP = 180,
IP_OVER_IB_SNOOP = 137,
IPMB_KONTRON = 103,
IPMI_TRACE = 173,
IPNET = 124,
IRDA = 44,
ISDN = 17,
ISO14443 = 177,
IXVERIWAVE = 144,
JPEG_JFIF = 123,
JSON = 175,
JUNIPER_ATM1 = 67,
JUNIPER_ATM2 = 68,
JUNIPER_CHDLC = 86,
JUNIPER_ETHER = 83,
JUNIPER_FRELAY = 85,
JUNIPER_GGSN = 87,
JUNIPER_MLFR = 82,
JUNIPER_MLPPP = 81,
JUNIPER_PPP = 84,
JUNIPER_PPPOE = 76,
JUNIPER_ST = 197,
JUNIPER_SVCS = 151,
JUNIPER_VN = 181,
JUNIPER_VP = 91,
K12 = 80,
LAPB = 12,
LAPD = 131,
LAYER1_EVENT = 110,
LIN = 107,
LINUX_ATM_CLIP = 11,
LINUX_LAPD = 88,
LOCALTALK = 30,
LOG_3GPP = 207,
LOGCAT_BRIEF = 164,
LOGCAT_LONG = 170,
LOGCAT_PROCESS = 165,
LOGCAT_TAG = 166,
LOGCAT_THREAD = 167,
LOGCAT_THREADTIME = 169,
LOGCAT_TIME = 168,
LOGCAT = 163,
LOOP = 174,
LORATAP = 183,
MA_WFP_CAPTURE_2V4 = 193,
MA_WFP_CAPTURE_2V6 = 194,
MA_WFP_CAPTURE_AUTH_V4 = 195,
MA_WFP_CAPTURE_AUTH_V6 = 196,
MA_WFP_CAPTURE_V4 = 191,
MA_WFP_CAPTURE_V6 = 192,
MDB = 223,
MIME = 134,
MOST = 108,
MP4 = 209,
MPEG_2_TS = 138,
MPEG = 96,
MTP2_WITH_PHDR = 75,
MTP2 = 42,
MTP3 = 43,
MUX27010 = 133,
NETANALYZER_TRANSPARENT = 136,
NETANALYZER = 135,
NETLINK = 158,
NETMON_HEADER = 188,
NETMON_NET_FILTER = 189,
NETMON_NET_NETEVENT = 187,
NETMON_NETWORK_INFO_EX = 190,
NETTL_ETHERNET = 71,
NETTL_FDDI = 73,
NETTL_RAW_ICMP = 64,
NETTL_RAW_ICMPV6 = 65,
NETTL_RAW_IP = 70,
NETTL_RAW_TELNET = 94,
NETTL_TOKEN_RING = 72,
NETTL_UNKNOWN = 74,
NETTL_X25 = 79,
NFC_LLCP = 140,
NFLOG = 141,
NONE = -2,
NORDIC_BLE = 186,
NSTRACE_1_0 = 119,
NSTRACE_2_0 = 120,
NSTRACE_3_0 = 162,
NSTRACE_3_5 = 176,
NULL = 15,
OLD_PFLOG = 31,
PACKETLOGGER = 118,
PER_PACKET = -1,
PFLOG = 39,
PKTAP = 171,
PPI = 97,
PPP_ETHER = 139,
PPP_WITH_PHDR = 19,
PPP = 4,
RAW_IP = 7,
RAW_IP4 = 129,
RAW_IP6 = 130,
RAW_IPFIX = 128,
REDBACK = 69,
RFC7468 = 202,
RTAC_SERIAL = 153,
RUBY_MARSHAL = 201,
SCCP = 101,
SCTP = 149,
SDH = 145,
SDLC = 36,
SILABS_DEBUG_CHANNEL = 222,
SITA = 100,
SLIP = 3,
SLL = 25,
SLL2 = 210,
SOCKETCAN = 125,
STANAG_4607 = 156,
STANAG_5066_D_PDU = 157,
SYMANTEC = 61,
SYSTEMD_JOURNAL = 203,
TNEF = 114,
TOKEN_RING = 2,
TZSP = 37,
UNKNOWN = 0,
USB_2_0_FULL_SPEED = 216,
USB_2_0_HIGH_SPEED = 217,
USB_2_0_LOW_SPEED = 215,
USB_2_0 = 208,
USB_DARWIN = 182,
USB_FREEBSD = 92,
USB_LINUX_MMAPPED = 115,
USB_LINUX = 95,
USBPCAP = 152,
USER0 = 45,
USER1 = 46,
USER10 = 55,
USER11 = 56,
USER12 = 57,
USER13 = 58,
USER14 = 59,
USER15 = 60,
USER2 = 47,
USER3 = 48,
USER4 = 49,
USER5 = 50,
USER6 = 51,
USER7 = 52,
USER8 = 53,
USER9 = 54,
V5_EF = 142,
VPP = 205,
VSOCK = 185,
WFLEET_HDLC = 35,
WIRESHARK_UPPER_PDU = 155,
X2E_SERIAL = 111,
X2E_XORAYA = 105,
ZBNCP = 214,
ZWAVE_SERIAL = 211,
}
---@enum WtapTsprecEnum
wtap_file_tsprec = {
["10_MSEC"] = 2,
["10_NSEC"] = 8,
["10_USEC"] = 5,
["100_MSEC"] = 1,
["100_NSEC"] = 7,
["100_USEC"] = 4,
CSEC = 2,
DSEC = 1,
MSEC = 3,
NSEC = 9,
PER_PACKET = -1,
SEC = 0,
UNKNOWN = -2,
USEC = 6,
}
--[[------------------------------------------------------------------------
Utility functions section
]]
--[[
Gets the Wireshark version as a string
]]
---@return string version The version string, e.g. "3.2.5".
function get_version() end
--[[
Set a Lua table with meta-data about the plugin, such as version.
The passed-in Lua table entries need to be keyed/indexed by the following:
* "version" with a string value identifying the plugin version (required)
* "description" with a string value describing the plugin (optional)
* "author" with a string value of the author's name(s) (optional)
* "repository" with a string value of a URL to a repository (optional)
Not all of the above key entries need to be in the table. The 'version' entry is required, however. The others are not currently used for anything, but might be in the future and thus using them might be useful. Table entries keyed by other strings are ignored, and do not cause an error.
Example:
```lua
local my_info = {
version = "1.0.1",
author = "Jane Doe",
repository = "https://github.com/octocat/Spoon-Knife"
}
set_plugin_info(my_info)
```
]]
---@param table table The Lua table of information
function set_plugin_info(table) end
--[[
Formats a relative timestamp in a human readable time.
]]
---@param timestamp any A timestamp value to convert.
---@return string formatted_time A string with the formated time
function format_time(timestamp) end
--[[
Get a preference value. @since 3.5.0
]]
---@param preference string The name of the preference.
---@return any? preference_value The preference value, or nil if not found.
function get_preference(preference) end
--[[
Set a preference value. @since 3.5.0
]]
---@param preference string The name of the preference.
---@param value any The preference value to set.
---@return boolean? result true if changed, false if unchanged or nil if not found.
function set_preference(preference, value) end
--[[
Reset a preference to default value. @since 3.5.0
]]
---@param preference string The name of the preference.
---@return boolean result true if valid preference
function reset_preference(preference) end
--[[
Write preferences to file and apply changes. @since 3.5.0
]]
function apply_preferences() end
--[[
Reports a failure to the user.
]]
---@param text string Message text to report.
function report_failure(text) end
--[[
Loads a Lua file and compiles it into a Lua chunk, similar to the standard loadfile but searches additional directories. The search order is the current directory, followed by the user's personal configuration directory, and finally the global configuration directory.
Example:
```lua
-- Assume foo.lua contains definition for foo(a,b). Load the chunk
-- from the file and execute it to add foo(a,b) to the global table.
-- These two lines are effectively the same as dofile('foo.lua').
local loaded_chunk = assert(loadfile('foo.lua'))
loaded_chunk()
-- ok to call foo at this point
foo(1,2)
```
]]
---@param filename string Name of the file to be loaded. If the file does not exist in the current directory, the user and system directories are searched.
function loadfile(filename) end
--[[
Loads a Lua file and executes it as a Lua chunk, similar to the standard dofile but searches additional directories. The search order is the current directory, followed by the user's personal configuration directory, and finally the global configuration directory.
]]
---@param filename string Name of the file to be run. If the file does not exist in the current directory, the user and system directories are searched.
function dofile(filename) end
--[[
Register a function to handle a -z option
]]
---@param argument string The name of the option argument.
---@param action? fun() The function to be called when the command is invoked
function register_stat_cmd_arg(argument, action) end
--[[------------------------------------------------------------------------
GUI Support
]]
--[[
Creates and manages a modal progress bar. This is intended to be used with coroutines, where a main UI thread controls the progress bar dialog while a background coroutine (worker thread) yields to the main thread between steps. The main thread checks the status of the Cancel button and if it's not set, returns control to the coroutine.
The legacy (GTK+) user interface displayed this as a separate dialog, hence the “Dlg” suffix. The Qt user interface shows a progress bar inside the main status bar.
]]
---@class ProgDlg
ProgDlg = {}
--[[
Creates and displays a new ProgDlg progress bar with a Cancel button and optional title. It is highly recommended that you wrap code that uses a ProgDlg instance because it does not automatically close itself upon encountering an error. Requires a GUI.
Example:
```lua
if not gui_enabled() then return end
local p = ProgDlg.new("Constructing", "tacos")
-- We have to wrap the ProgDlg code in a pcall in case some unexpected
-- error occurs.
local ok, errmsg = pcall(function()
local co = coroutine.create(
function()
local limit = 100000
for i=1,limit do
print("co", i)
coroutine.yield(i/limit, "step "..i.." of "..limit)
end
end
)
-- Whenever coroutine yields, check the status of the cancel button to determine
-- when to break. Wait up to 20 sec for coroutine to finish.
local start_time = os.time()
while coroutine.status(co) ~= 'dead' do
local elapsed = os.time() - start_time
-- Quit if cancel button pressed or 20 seconds elapsed
if p:stopped() or elapsed > 20 then
break
end
local res, val, val2 = coroutine.resume(co)
if not res or res == false then
if val then
debug(val)
end
print('coroutine error')
break
end
-- show progress in progress dialog
p:update(val, val2)
end
end)
p:close()
if not ok and errmsg then
report_failure(errmsg)
end
```
]]
---@param title? string Title of the progress bar. Defaults to "Progress"
---@param task? string Optional task name, which will be appended to the title. Defaults to the empty string ("")
---@return ProgDlg progdlg The newly created ProgDlg object
function ProgDlg.new(title, task) end
--[[
Sets the progress dialog's progress bar position based on percentage done
Errors:
* GUI not available
* Cannot be called for something not a ProgDlg
* Progress value out of range (must be between 0.0 and 1.0)
]]
---@param progress number Progress value, e.g. 0.75. Value must be between 0.0 and 1.0 inclusive
---@param task? string Task name. Currently ignored. Defaults to empty string ("").
function ProgDlg:update(progress, task) end
--[[
Checks whether the user has pressed the Cancel button.
]]
---@return boolean stopped Boolean true if the user has asked to stop the operation, false otherwise
function ProgDlg:stopped() end
--[[
Hides the progress bar
Errors:
* GUI not available
]]
---@return string stopped A string specifying whether the Progress Dialog has stopped or not
function ProgDlg:close() end
--[[
Creates and manages a text window. The text can be read-only or editable, and buttons can be added below the text
]]
---@class TextWindow
TextWindow = {}
--[[
Creates a new TextWindow text window and displays it. Requires a GUI.
Example:
```lua
if not gui_enabled() then return end
-- create new text window and initialize its text
local win = TextWindow.new("Log")
win:set("Hello world!")
-- add buttons to clear text window and to enable editing
win:add_button("Clear", function() win:clear() end)
win:add_button("Enable edit", function() win:set_editable(true) end)
-- add button to change text to uppercase
win:add_button("Uppercase", function()
local text = win:get_text()
if text ~= "" then
win:set(string.upper(text))
end
end)
-- print "closing" to stdout when the user closes the text windw
win:set_atclose(function() print("closing") end)
```
]]
---@param title string Title of the new window. Optional. Defaults to "Untitled Window"
---@return TextWindow text_window The newly created TextWindow object
function TextWindow.new(title) end
--[[
Set the function that will be called when the text window closes.
Errors:
* GUI not available
]]
---@param action fun() A Lua function to be executed when the user closes the text window
---@return TextWindow text_window The TextWindow object
function TextWindow:set_at_close(action) end
--[[
Sets the text to be displayed.
Errors:
* GUI not available
]]
---@param text string The text to be displayed
---@return TextWindow text_window The TextWindow object
function TextWindow:set(text) end
--[[
Appends text to the current window contents.
Errors:
* GUI not available
]]
---@param text string The text to be appended
---@return TextWindow text_window The TextWindow object
function TextWindow:append(text) end
--[[
Prepends text to the current window contents.
Errors:
* GUI not available
]]
---@param text string The text to be prepended
---@return TextWindow text_window The TextWindow object
function TextWindow:prepend(text) end
--[[
Erases all of the text in the window.
Errors:
* GUI not available
]]
---@return TextWindow text_window The TextWindow object
function TextWindow:clear() end
--[[
Get the text of the window.
Errors:
* GUI not available
]]
---@return string text The TextWindow's text
function TextWindow:get_text() end
--[[
Close the window.
Errors:
* GUI not available
]]
function TextWindow:close() end
--[[
Make this text window editable.
Errors:
* GUI not available
]]
---@param editable boolean true to make the text editable, false otherwise. Defaults to true
---@return TextWindow text_window The TextWindow object
function TextWindow:set_editable(editable) end
--[[
Adds a button with an action handler to the text window.
Errors:
* GUI not available
]]
---@param label string The button label
---@param action fun() The Lua function to be called when the button is pressed
---@return TextWindow text_window The TextWindow object
function TextWindow:add_button(label, action) end
--[[
Checks if we're running inside a GUI (i.e. Wireshark) or not
]]
---@return boolean enabled Boolean true if a GUI is available, false if it isn't
function gui_enabled() end
--[[
Register a menu item in one of the main menus. Requires a GUI.
]]
---@param name string The name of the menu item. Use slashes to separate submenus. (e.g. Lua Scripts → My Fancy Statistics). (string)
---@param action fun(arg: unknown) The function to be called when the menu item is invoked. The function must take no arguments and return nothing.
---@param group integer Where to place the item in the menu hierarchy. If omitted, defaults to MENU_STAT_GENERIC.
---| `MENU_PACKET_ANALYZE_UNSORTED` -- Analyze
---| `MENU_PACKET_STAT_UNSORTED` -- Statistics
---| `MENU_STAT_GENERIC` -- Statistics, first section
---| `MENU_STAT_CONVERSATION_LIST` -- Statistics → Conversation List
---| `MENU_STAT_ENDPOINT_LIST` -- Statistics → Endpoint List
---| `MENU_STAT_RESPONSE_TIME` -- Statistics → Service Response Time
---| `MENU_STAT_RSERPOOL` --= Statistics → Reliable Server Pooling (RSerPool)
---| `MENU_STAT_TELEPHONY` -- Telephony
---| `MENU_STAT_TELEPHONY_ANSI` -- Telephony → ANSI
---| `MENU_STAT_TELEPHONY_GSM` -- Telephony → GSM
---| `MENU_STAT_TELEPHONY_LTE` -- Telephony → LTE
---| `MENU_STAT_TELEPHONY_MTP3` -- Telephony → MTP3
---| `MENU_STAT_TELEPHONY_SCTP` -- Telephony → SCTP
---| `MENU_ANALYZE` -- Analyze
---| `MENU_ANALYZE_CONVERSATION_FILTER` -- Analyze → Conversation Filter
---| `MENU_TOOLS_UNSORTED` -- Tools
---| `MENU_LOG_ANALYZE_UNSORTED` -- Analyze
---| `MENU_LOG_STAT_UNSORTED` --= 16
---| `MENU_ANALYZE_UNSORTED` -- superseded by MENU_PACKET_ANALYZE_UNSORTED
---| `MENU_ANALYZE_CONVERSATION` -- superseded by MENU_ANALYZE_CONVERSATION_FILTER
---| `MENU_STAT_CONVERSATION` -- superseded by MENU_STAT_CONVERSATION_LIST
---| `MENU_STAT_ENDPOINT` -- superseded by MENU_STAT_ENDPOINT_LIST
---| `MENU_STAT_RESPONSE` -- superseded by MENU_STAT_RESPONSE_TIME
---| `MENU_STAT_UNSORTED` -- superseded by MENU_PACKET_STAT_UNSORTED
--[[
Valid packet (Wireshark) items are:
* MENU_PACKET_ANALYZE_UNSORTED: Analyze
* MENU_PACKET_STAT_UNSORTED: Statistics
* MENU_STAT_GENERIC: Statistics, first section
* MENU_STAT_CONVERSATION_LIST: Statistics → Conversation List
* MENU_STAT_ENDPOINT_LIST: Statistics → Endpoint List
* MENU_STAT_RESPONSE_TIME: Statistics → Service Response Time
* MENU_STAT_RSERPOOL = Statistics → Reliable Server Pooling (RSerPool)
* MENU_STAT_TELEPHONY: Telephony
* MENU_STAT_TELEPHONY_ANSI: Telephony → ANSI
* MENU_STAT_TELEPHONY_GSM: Telephony → GSM
* MENU_STAT_TELEPHONY_LTE: Telephony → LTE
* MENU_STAT_TELEPHONY_MTP3: Telephony → MTP3
* MENU_STAT_TELEPHONY_SCTP: Telephony → SCTP
* MENU_ANALYZE: Analyze
* MENU_ANALYZE_CONVERSATION_FILTER: Analyze → Conversation Filter
* MENU_TOOLS_UNSORTED: Tools
Valid log (Logray) items are:
* MENU_LOG_ANALYZE_UNSORTED: Analyze
* MENU_LOG_STAT_UNSORTED = 16
The following are deprecated and shouldn’t be used in new code:
* MENU_ANALYZE_UNSORTED, superseded by MENU_PACKET_ANALYZE_UNSORTED
* MENU_ANALYZE_CONVERSATION, superseded by MENU_ANALYZE_CONVERSATION_FILTER
* MENU_STAT_CONVERSATION, superseded by MENU_STAT_CONVERSATION_LIST
* MENU_STAT_ENDPOINT, superseded by MENU_STAT_ENDPOINT_LIST
* MENU_STAT_RESPONSE, superseded by MENU_STAT_RESPONSE_TIME
* MENU_STAT_UNSORTED, superseded by MENU_PACKET_STAT_UNSORTED
]]
function register_menu(name, action, group) end
--[[
Register a menu item in the packet list
]]
---@param name string The name of the menu item. Use slashes to separate submenus. (e.g. level1/level2/name). (string)
---@param action fun(arg: unknown) The function to be called when the menu item is invoked. The function must take one argument and return nothing.
---@param required_fields? string A comma-separated list of packet fields (e.g., http.host,dns.qry.name) which all must be present for the menu to be displayed (default: always display)
function register_packet_menu(name, action, required_fields) end
--[[
Displays a dialog, prompting for input. The dialog includes an OK button and Cancel button. Requires a GUI
Errors:
* GUI not available
* At least one field required
Example:
```lua
if not gui_enabled() then return end
-- Prompt for IP and port and then print them to stdout
local label_ip = "IP address"
local label_port = "Port"
local function print_ip(ip, port)
print(label_ip, ip)
print(label_port, port)
end
new_dialog("Enter IP address", print_ip, label_ip, label_port)
-- Prompt for 4 numbers and then print their product to stdout
new_dialog(
"Enter 4 numbers",
function (a, b, c, d) print(a * b * c * d) end,
"a", "b", "c", "d"
)
```
]]
---@param title string The title of the dialog
---@param action fun() Action to be performed when the user presses OK.
---@param ... string|table Strings to be used as labels of the dialog's fields. Each string creates a new labeled field. The first field is required. Instead of a strings it is possible to provide tables with fields 'name' and 'value' of type string. Then the created dialog's field will labeld with the content of name and prefilled with the content of value.
function new_dialog(title, action, ...) end
--[[
Rescans all packets and runs each tap listener without reconstructing the display
]]
function retap_packets() end
--[[
Copy a string into the clipboard. Requires a GUI
]]
---@param text string The string to be copied into the clipboard
function copy_to_clipboard(text) end
--[[
Open and display a capture file. Requires a GUI
]]
---@param filename string The name of the file to be opened
---@param filter string The display filter to be applied once the file is opened
function open_capture_file(filename, filter) end
--[[
Get the main filter text
]]
---@return string
function get_filter() end
--[[
Set the main filter text
]]
---@param text string The filter's text
function set_filter(text) end
--[[
Gets the current packet coloring rule (by index) for the current session. Wireshark reserves 10 slots for these coloring rules. Requires a GUI
]]
---@param row integer The index (1-10) of the desired color filter value in the temporary coloring rules list
---@return unknown
function get_color_filter_slot(row) end
--[[
Sets a packet coloring rule (by index) for the current session. Wireshark reserves 10 slots for these coloring rules. Requires a GUI
]]
---@param row integer The index (1-10) of the desired color in the temporary coloring rules list. The default foreground is black and the default backgrounds are listed below.
--[[
The color list can be set from the command line using two unofficial preferences: gui.colorized_frame.bg and gui.colorized_frame.fg, which require 10 hex RGB codes (6 hex digits each), e.g.
```sh
wireshark -o gui.colorized_frame.bg:${RGB0},${RGB1},${RGB2},${RGB3},${RGB4},${RGB5},${RGB6},${RGB7},${RGB8},${RGB9}
```
For example, this command yields the same results as the table above (and with all foregrounds set to black):
```sh
wireshark -o gui.colorized_frame.bg:ffc0c0,ffc0ff,e0c0e0,c0c0ff,c0e0e0,c0ffff,c0ffc0,ffffc0,e0e0c0,e0e0e0 -o gui.colorized_frame.fg:000000,000000,000000,000000,000000,000000,000000,000000,000000,000000
```
]]
---@param text string The display filter for selecting packets to be colorized
function set_color_filter_slot(row, text) end
--[[
Apply the filter in the main filter box. Requires a GUI.
Warning
Avoid calling this from within a dissector function or else an infinite loop can occur if it causes the dissector to be called again. This function is best used in a button callback (from a dialog or text window) or menu callback.
]]
function apply_filter() end
--[[
Reload the current capture file. Deprecated. Use reload_packets() instead
]]
---@deprecated
function reload() end
--[[
Reload the current capture file. Requires a GUI.
Warning
Avoid calling this from within a dissector function or else an infinite loop can occur if it causes the dissector to be called again. This function is best used in a button callback (from a dialog or text window) or menu callback.
]]
function reload_packets() end
--[[
Redissect all packets in the current capture file. Requires a GUI.
Warning
Avoid calling this from within a dissector function or else an infinite loop can occur if it causes the dissector to be called again. This function is best used in a button callback (from a dialog or text window) or menu callback.
]]
function redissect_packets() end
--[[
Reload all Lua plugins
]]
function reload_lua_plugins() end
--[[
Opens an URL in a web browser. Requires a GUI.
Warning
Do not pass an untrusted URL to this function.
It will be passed to the system's URL handler, which might execute malicious code, switch on your Bluetooth-connected foghorn, or any of a number of unexpected or harmful things.
]]
---@return string url The url
function browser_open_url(url) end
--[[
Open a file located in the data directory (specified in the Wireshark preferences) in the web browser. If the file does not exist, the function silently ignores the request. Requires a GUI.
Warning
Do not pass an untrusted URL to this function.
It will be passed to the system's URL handler, which might execute malicious code, switch on your Bluetooth-connected foghorn, or any of a number of unexpected or harmful things.
]]
---@return string filename The file name
function browser_open_data_file(filename) end
--[[------------------------------------------------------------------------
Functions For New Protocols And Dissectors