Skip to content

Commit

Permalink
Make extcap more modular
Browse files Browse the repository at this point in the history
This will allow creating wrapper extcaps that can change default values.
  • Loading branch information
oshaked1 committed Jul 17, 2024
1 parent 4edabfd commit 084adbc
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions extcap/tracee-capture.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@
os.makedirs(TMP_DIR, exist_ok=True)

EXTCAP_VERSION = 'VERSION_PLACEHOLDER'
EXTCAP_DISPLAY = 'Tracee'
INTERFACE_NAME = 'tracee'
INTERFACE_DISPLAY = 'Tracee capture'
DLT_USER0 = 147
TRACEE_OUTPUT_BUF_CAPACITY = 262144 # enough to hold the largest event encountered so far
DATA_PORT = 4000
Expand All @@ -53,6 +56,7 @@
DEFAULT_CONTAINER_NAME = 'traceeshark'
DEFAULT_LOGFILE = os.path.join(TMP_DIR, 'tracee_logs.log')
DEFAULT_OUTPUT_DIR = os.path.join(TMP_DIR, 'tracee_output')
DEFAULT_PRESET = 'Default'
DEFAULT_SNAPLEN = 'default'

# corresponds to "enum InterfaceControlCommand" from wireshark/ui/qt/interface_toolbar.cpp
Expand Down Expand Up @@ -88,8 +92,8 @@ def show_version():


def show_interfaces():
print("extcap {version=%s}{help=https://www.wireshark.org}{display=Tracee}" % EXTCAP_VERSION)
print("interface {value=tracee}{display=Tracee capture}")
print("extcap {version=%s}{help=https://www.wireshark.org}{display=%s}" % (EXTCAP_VERSION, EXTCAP_DISPLAY))
print("interface {value=%s}{display=%s}" % (INTERFACE_NAME, INTERFACE_DISPLAY))
print("control {number=%d}{type=button}{display=Stop}{tooltip=Stop the capture}" % CTRL_ARG_STOP)
print("control {number=%d}{type=boolean}{display=Copy output on stop}{default=true}{tooltip=Copy output folder when stopping the capture}" % CTRL_ARG_COPY_ON_STOP)
print("control {number=%d}{type=button}{display=Copy output}{tooltip=Copy output folder from remote}" % CTRL_ARG_COPY_OUTPUT)
Expand Down Expand Up @@ -400,7 +404,7 @@ def show_config(reload_option: Optional[str]):
if reload_option is None or reload_option == 'preset':
values.append(ConfigVal(arg=id_preset, value='none', display=f'No preset', default='false'))
for preset in presets:
values.append(ConfigVal(arg=id_preset, value=preset, display=preset, default='true' if preset == 'Default' else 'false'))
values.append(ConfigVal(arg=id_preset, value=preset, display=preset, default='true' if preset == DEFAULT_PRESET else 'false'))

if reload_option is None:
for arg in args:
Expand Down Expand Up @@ -1238,7 +1242,7 @@ def main():
sys.exit(0)


if __name__ == '__main__':
def main_wrapper():
#sys.stderr.write(f'{sys.argv}\n')
#sys.stderr.flush()

Expand All @@ -1253,3 +1257,7 @@ def main():
exception(ex)
finally:
sys.stderr.flush()


if __name__ == '__main__':
main_wrapper()

0 comments on commit 084adbc

Please sign in to comment.