-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathwireshark_lua_api.lua
4507 lines (3559 loc) · 151 KB
/
wireshark_lua_api.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
---@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,
}
--[[------------------------------------------------------------------------
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 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
]]
--[[
A refererence to a dissector, used to call a dissector against a packet or a part of it.
]]
---@class Dissector
---@operator call():nil
Dissector = {}
--[[
Obtains a dissector reference by name.
]]
---@param name string The name of the dissector
---@return Dissector? dissector The Dissector reference if found, otherwise nil.
function Dissector.get(name) end
--[[
Gets a Lua array table of all registered Dissector names.
Note: This is an expensive operation, and should only be used for troubleshooting.
Since: 1.11.3
]]
---@return string[] dissector_names The array table of registered dissector names.
function Dissector.list() end
--[[
Calls a dissector against a given packet (or part of it).
]]
---@param tvb Tvb The buffer to dissect.
---@param pinfo PInfo The packet info.
---@param tree TreeItem The tree on which to add the protocol items.
---@return integer bytes_dissected Number of bytes dissected. Note that some dissectors always return number of bytes in incoming buffer, so be aware.
function Dissector:call(tvb, pinfo, tree) end
--[[
Calls a dissector against a given packet (or part of it).
]]
---@param tvb Tvb The buffer to dissect.
---@param pinfo PInfo The packet info.
---@param tree TreeItem The tree on which to add the protocol items.
function Dissector:__call(tvb, pinfo, tree) end
--[[
Gets the Dissector's description.
]]
---@return string description A string of the Dissector's description.
function Dissector:__tostring() end
--[[
A table of subdissectors of a particular protocol (e.g. TCP subdissectors like http, smtp, sip are added to table "tcp.port").
Useful to add more dissectors to a table so that they appear in the “Decode As…” dialog.
]]
---@class DissectorTable
DissectorTable = {}
--[[
Creates a new DissectorTable for your dissector's use.
]]
---@param tablename string The short name of the table. Use lower-case alphanumeric, dot, and/or underscores (e.g., "ansi_map.tele_id" or "udp.port").
---@param uiname? string The name of the table in the user interface. Defaults to the name given in tablename, but can be any string
---@param type? FtypesEnum One of ftypes.UINT8, ftypes.UINT16, ftypes.UINT24, ftypes.UINT32, or ftypes.STRING. Defaults to ftypes.UINT32
---@param base? BaseEnum One of base.NONE, base.DEC, base.HEX, base.OCT, base.DEC_HEX or base.HEX_DEC. Defaults to base.DEC
---@param proto? Proto The Proto object that uses this dissector table
---@return DissectorTable dissector_table The newly created DissectorTable
function DissectorTable.new(tablename, uiname, type, base, proto) end
--[[
Gets a Lua array table of all DissectorTable names - i.e., the string names you can use for the first argument to DissectorTable.get().
Note: This is an expensive operation, and should only be used for troubleshooting.
Since: 1.11.3
]]
---@return string[] dissector_table_names The array table of registered DissectorTable names
function DissectorTable.list() end
--[[
Gets a Lua array table of all heuristic list names - i.e., the string names you can use for the first argument in Proto:register_heuristic().
Note: This is an expensive operation, and should only be used for troubleshooting.
Since: 1.11.3
]]
---@return string[] heuristic_names The array table of registered heuristic list names
function DissectorTable.heuristic_list() end
--[[
Try all the dissectors in a given heuristic dissector table.
]]
---@param listname string The name of the heuristic dissector
---@param tvb Tvb The buffer to dissect.
---@param pinfo PInfo The packet info.
---@param tree TreeItem The tree on which to add the protocol items.
---@return boolean recognized True if the packet was recognized by the sub-dissector (stop dissection here).
function DissectorTable.try_heuristics(listname, tvb, pinfo, tree) end
--[[
Obtain a reference to an existing dissector table.
]]
---@param tablename string The short name of the table
---@return DissectorTable? dissector_table The DissectorTable reference if found, otherwise nil.
function DissectorTable.get(tablename) end
--[[
Add a Proto with a dissector function or a Dissector object to the dissector table
]]
---@param pattern integer|string The pattern to match (either an integer, a integer range or a string depending on the table's type).
---@param dissector Proto|Dissector The dissector to add (either a Proto or a Dissector)
function DissectorTable:add(pattern, dissector) end
--[[
Clear all existing dissectors from a table and add a new dissector or a range of new dissectors.
Since: 1.11.3
]]
---@param pattern integer|string The pattern to match (either an integer, a integer range or a string depending on the table's type).
---@param dissector Proto|Dissector The dissector to add (either a Proto or a Dissector)
function DissectorTable:set(pattern, dissector) end
--[[
Remove a dissector or a range of dissectors from a table.
]]
---@param pattern integer|string The pattern to match (either an integer, a integer range or a string depending on the table's type).
---@param dissector Proto|Dissector The dissector to remove (either a Proto or a Dissector).
function DissectorTable:remove(pattern, dissector) end
--[[
Remove all dissectors from a table.
Since: 1.11.3
]]
---@param dissector Proto|Dissector The dissector to remove (either a Proto or a Dissector).
function DissectorTable:remove_all(dissector) end
--[[
Try to call a dissector from a table.
]]
---@param pattern integer|string The pattern to be matched (either an integer or a string depending on the table's type).
---@param tvb Tvb The Tvb to dissect
---@param pinfo PInfo The packet's Pinfo.
---@param tree TreeItem The TreeItem on which to add the protocol items.
---@return integer bytes_dissected Number of bytes dissected. Note that some dissectors always return number of bytes in incoming buffer, so be aware
function DissectorTable:try(pattern, tvb, pinfo, tree) end
--[[
Try to obtain a dissector from a table.
]]
---@param pattern integer|string The pattern to be matched (either an integer or a string depending on the table's type).
---@return Dissector? dissector The Dissector handle if found, otherwise nil
function DissectorTable:get_dissector(pattern) end
--[[
Add the given Proto to the “Decode as…” list for this DissectorTable. The passed-in Proto object's dissector() function is used for dissecting.
Since: 1.99.1
]]
---@param proto Proto The Proto to add
function DissectorTable:add_for_decode_as(proto) end
--[[
Gets some debug information about the DissectorTable.
]]
---@return string information A string of debug information about the DissectorTable.
function DissectorTable:__tostring() end
--[[
A preference of a Proto.
]]
---@class Pref
Pref = {}
--[[
Creates a boolean preference to be added to a Proto.prefs Lua table.
Example:
```lua
-- create a Boolean preference named "bar" for Foo Protocol
-- (assuming Foo doesn't already have a preference named "bar")
proto_foo.prefs.bar = Pref.bool( "Bar", true, "Baz and all the rest" )
```
]]
---@param label string The Label (text in the right side of the preference input) for this preference.
---@param default boolean The default value for this preference.
---@param descr string A description of this preference
function Pref.bool(label, default, descr) end
--[[
Creates an (unsigned) integer preference to be added to a Proto.prefs Lua table
]]
---@param label string The Label (text in the right side of the preference input) for this preference.
---@param default integer The default value for this preference.
---@param descr string A description of what this preference is.
function Pref.uint(label, default, descr) end
--[[
Creates a string preference to be added to a Proto.prefs Lua table.
]]
---@param label string The Label (text in the right side of the preference input) for this preference.
---@param default string The default value for this preference.
---@param descr string A description of what this preference is.
function Pref.string(label, default, descr) end
--[[
Creates an enum preference to be added to a Proto.prefs Lua table.
Example:
```lua
local OUTPUT_OFF = 0
local OUTPUT_DEBUG = 1
local OUTPUT_INFO = 2
local OUTPUT_WARN = 3
local OUTPUT_ERROR = 4
local output_tab = {
{ 1, "Off" , OUTPUT_OFF },
{ 2, "Debug" , OUTPUT_DEBUG },
{ 3, "Information" , OUTPUT_INFO },
{ 4, "Warning" , OUTPUT_WARN },
{ 5, "Error" , OUTPUT_ERROR },
}
-- Create enum preference that shows as Combo Box under
-- Foo Protocol's preferences
proto_foo.prefs.outputlevel = Pref.enum(
"Output Level", -- label
OUTPUT_INFO, -- default value
"Verbosity of log output", -- description
output_tab, -- enum table
false -- show as combo box
)
-- Then, we can query the value of the selected preference.
-- This line prints "Output Level: 3" assuming the selected
-- output level is _INFO.
debug( "Output Level: " .. proto_foo.prefs.outputlevel )
```
]]
---@param label string The Label (text in the right side of the preference input) for this preference.
---@param default integer The default value for this preference.
---@param descr string A description of what this preference is.
---@param enum table An enum Lua table
---@param radio boolean Radio button (true) or Combobox (false).
function Pref.enum(label, default, descr, enum, radio) end
--[[
Creates a range (numeric text entry) preference to be added to a Proto.prefs Lua table.
]]
---@param label string The Label (text in the right side of the preference input) for this preference.
---@param default string The default value for this preference, e.g., "53", "10-30", or "10-30,53,55,100-120".
---@param descr string A description of what this preference is.
---@param max unknown The maximum value.
function Pref.range(label, default, descr, max) end
--[[
Creates a static text string to be added to a Proto.prefs Lua table
]]
---@param label string The static text.
---@param descr string The static text description.
function Pref.statictext(label, descr) end
--[[
The table of preferences of a protocol.
]]
---@class Prefs
Prefs = {}
--[[
Creates a new preference.
Errors:
* Unknown Pref type
]]
---@param name string The abbreviation of this preference
---@param pref Pref A valid but still unassigned Pref object
function Prefs:__newindex(name, pref) end
--[[
Get the value of a preference setting.
Example:
```lua