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 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.
Creates and displays a new ProgDlg progress bar with a 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.
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
The newly created ProgDlg object.
Sets the progress dialog’s progress bar position based on percentage done.
Creates and manages a text window. The text can be read-only or editable, and buttons can be added below the text.
Creates a new TextWindow text window and displays it.
Requires a GUI.
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)
The newly created TextWindow object.
Set the function that will be called when the text window closes.
The TextWindow object.
Sets the text to be displayed.
The TextWindow object.
Appends text to the current window contents.
The TextWindow object.
Prepends text to the current window contents.
The TextWindow object.
Checks if we’re running inside a GUI (i.e. Wireshark) or not.
Boolean true if a GUI is available, false if it isn’t.
Register a menu item in one of the main menus. Requires a GUI.
Where to place the item in the menu hierarchy. If omitted, defaults to MENU_STAT_GENERIC. One of:
Displays a dialog, prompting for input. The dialog includes an button and button. Requires a GUI.
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"
)
Rescans all packets and runs each tap listener without reconstructing the display.
Copy a string into the clipboard. Requires a GUI.
Open and display a capture file. Requires a GUI.
Gets the current packet coloring rule (by index) for the current session. Wireshark reserves 10 slots for these coloring rules. Requires a GUI.
Table 11.1. Default background colors
| Index | RGB (hex) | Color |
|---|---|---|
1 | ffc0c0 | pink 1 |
2 | ffc0ff | pink 2 |
3 | e0c0e0 | purple 1 |
4 | c0c0ff | purple 2 |
5 | c0e0e0 | green 1 |
6 | c0ffff | green 2 |
7 | c0ffc0 | green 3 |
8 | ffffc0 | yellow 1 |
9 | e0e0c0 | yellow 2 |
10 | e0e0e0 | gray |
Sets a packet coloring rule (by index) for the current session. Wireshark reserves 10 slots for these coloring rules. Requires a GUI.
Table 11.2. Default background colors
| Index | RGB (hex) | Color |
|---|---|---|
1 | ffc0c0 | pink 1 |
2 | ffc0ff | pink 2 |
3 | e0c0e0 | purple 1 |
4 | c0c0ff | purple 2 |
5 | c0e0e0 | green 1 |
6 | c0ffff | green 2 |
7 | c0ffc0 | green 3 |
8 | ffffc0 | yellow 1 |
9 | e0e0c0 | yellow 2 |
10 | e0e0e0 | gray |
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.
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):
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
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. |
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. |
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. |
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. |