arg {number=4}{call=--server}{display=IP address for log server}{type=string}{validation=\\b(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\b}
value {arg=3}{value=if1}{display=Remote1}{default=true}
value {arg=3}{value=if2}{display=Remote2}{default=false}
----
Now the user can click on the options and change them. They are sent to the
extcap when the capture is launched.
There are three kind of options available:
[horizontal]
Flag:: boolflag for instance expects the option to be present resulting in the corresponding entry set to true, false otherwise
Value:: are value based options and each expect a single value via the command-line call
Selection:: are selections and can be presented multiple times in the command line. Both expect subsequent "value" items in the config list, with the corresponding argument selected via arg
===== The capture process
Once the interfaces are listed and configuration is customized by the user the capture is started.
To run the capture, the extcap must implement the `--capture`, `--extcap-capture-filter`
and `--fifo` option.
They are automatically added by Wireshark that opens the fifo for reading. All
the other options are automatically added to run the capture. The extcap interface
is used like all other interfaces (meaning that capture on multiple interfaces, as
well as stopping and restarting the capture is supported).
[[ChCaptureExtcapWindowsShell]]
====== Execute a script-based extcap on Windows
To use scripts on Windows, please generate an <scriptname>.bat inside
the extcap folder, with the following content (in this case for a Python-based extcap utility):
[source,batch]
----
@echo off
<Path to python interpreter> <Path to script file> %*
----
Windows is not able to execute most scripts directly (Powershell being an exception), which also goes for all other script-based formats besides VBScript and PowerShell
==== Extcap Arguments
The extcap interface provides the possibility for generating a GUI dialog to
set and adapt settings for the extcap binary.
All options must provide a number, by which they are identified. No `NUMBER` may be
provided twice. Also all options must present the elements `CALL` and `DISPLAY`, where
call provides the arguments name on the command-line and display the name in the GUI.
Additionally `TOOLTIP` and PLACEHOLDER may be provided, which will give the user an
explanation within the GUI, about what to enter into this field.
These options do have types, for which the following types are being supported:
[horizontal]
INTEGER, UNSIGNED, LONG, DOUBLE:: This provides a field for entering a numeric value of the given data type. A DEFAULT value may be provided, as well as a RANGE
+
[source,python]
----
arg {number=0}{call=--delay}{display=Time delay}{tooltip=Time delay between packages}{type=integer}{range=1,15}{default=0}
----
STRING:: Let the user provide a string to the capture
+
[source,python]
----
arg {number=1}{call=--server}{display=IP Address}{tooltip=IP Address for log server}{type=string}{validation=\\b(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\b}
----
+
`validation` allows to provide a regular expression string, which is used to check the user input for validity beyond normal data type or range checks. Back-slashes must be escaped (as in \\b for \b)
PASSWORD:: Let the user provide a masked string to the capture. Password strings are not saved, when the extcap configuration is being saved
+
[source,python]
----
arg {number=0}{call=--password}{display=The user password}{tooltip=The password for the connection}{type=password}
----
BOOLEAN, BOOLFLAG:: This provides the possibility to set a true/false value. BOOLFLAG values will only appear in the command-line if set to true, otherwise they will not be added to the command-line call for the extcap interface
FILESELECT:: Let the user provide a filepath to the capture. If MUSTEXIST is being provided, the GUI checks if the file exists.
+
[source,python]
----
arg {number=3}{call=--logfile}{display=Logfile}{tooltip=A file for log messages}{type=fileselect}{mustexist=false}
----
SELECTOR, RADIO, MULTICHECK:: Optionfields, where the user may choose one or more options from. If PARENT is provided for the value items, the option fields for MULTICHECK and SELECTOR are being presented in a tree-like structure. SELECTOR and RADIO values must present a default value, which will be the value provided to the extcap binary for this argument
value {arg=3}{value=if1}{display=Remote1}{default=true}
value {arg=3}{value=if2}{display=Remote2}{default=false}
----
===== Reload a selector
A selector may be reloaded from the configuration dialog of the extcap application within Wireshark. With the reload argument (defaults to false), the entry can be marked as reloadable.
After this has been defined, the user will get a button displayed in the configuration dialog for this extcap application, with the text "Load interfaces..." in this case, and a generic "Reload" text if no text has been provided.
The extcap utility is then called again with all filled out arguments and the additional parameter `--extcap-reload-option <option_name>`. It is expected to return a value section for this option, as it would during normal configuration. The provided option list is then presented as the selection, a previous selected option will be reselected if applicable.
===== Validation of arguments
Arguments may be set with `{required=true}` which enforces a value being provided, before
a capture can be started using the extcap options dialog. This is not being checked, if
the extcap is started via a simple double-click. The necessary fields are marked for the
customer, to ensure a visibility for the end customer of the required argument.
Additionally text and number arguments may also be checked using a regular expression,
which is provided using the validation attribute (see example above). The syntax for
such a check is the same as for Qt RegExp classes. This feature is only active in the
Qt version of Wireshark.
==== Toolbar Controls
An extcap utility can provide configuration for controls to use in an interface toolbar.
These controls are bidirectional and can be used to control the extcap utility while
capturing.
This is useful in scenarios where configuration can be done based on findings in the
capture process, setting temporary values or give other inputs without restarting the
current capture.
.Example of interface definition with toolbar controls
The extcap utility can set a default value at startup, and can change (set) and receive value changes while capturing. When starting a capture the GUI will send the value if different from the default value.
+
The payload is one byte with binary value 0 or 1.
+
Valid Commands: Set value, Enable, Disable.
BUTTON:: This provides a button with different ROLEs:
CONTROL:::: This button will send a signal when pressed. This is the default if no role is configured. The button is only enabled when capturing.
+
The extcap utility can set the button text at startup, and can change (set) the button text and receive button press signals while capturing. The button is disabled and the button text is restored to the default text when not capturing.
+
The payload is either the button text or empty (signal).
+
Valid Commands: Set value, Enable, Disable.
LOGGER:::: This provides a logger mechanism where the extcap utility can send log entries to be presented in a log window. This communication is unidirectional.
+
The payload is the log entry, and should be ended with a newline. Maximum length is 65535 bytes.
+
Valid Commands: Set log entry, Add log entry.
+
The Set command will clear the log before adding the entry.
+
HELP:::: This button opens the help page, if configured. This role has no controls and will not be used in communication.
+
Valid Commands: NONE.
RESTORE:::: This button will restore all control values to default. This role has no controls and will not be used in communication. The button is only enabled when not capturing.
+
Valid Commands: NONE.
SELECTOR:: This provides a combo box with fixed values which can be selected.
+
The extcap utility can set default values at startup, and add and remove values and receive change in value selection while capturing. When starting a capture the GUI will send the value if different from the default value.
+
The payload is a string with the value, and optionally a string with a display value if this is different from the value. This two string values are separated by a null character.
If value is empty the Remove command will remove all entries.
STRING:: This provides a text edit line with the possibility to set a string or any value which can be represented in a string (integer, float, date, etc.).
+
The extcap utility can set a default string value at startup, and can change (set) and receive value changes while capturing. When starting a capture the GUI will send the value if different from the default value.
+
The payload is a string with the value. Maximum length is 32767 bytes.
+
Valid Commands for control: Set value, Enable, Disable.
+
The element VALIDATION allows to provide a regular expression string, which is used to check the user input for validity beyond normal data type or range checks. Back-slashes must be escaped (as in \\b for \b).
===== Messages
In addition to the controls it's possible to send a single message from the extcap
utility to the user. This message can be put in the status bar or displayed in a
information, warning or error dialog which must be accepted by the user. This message
does not use the NUMBER argument so this can have any value.
====== Control Protocol
The protocol used to communicate over the control pipes has a fixed size header of