File: sampleif.py

package info (click to toggle)
wireshark 4.6.3-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 351,352 kB
  • sloc: ansic: 3,102,875; cpp: 129,717; xml: 100,972; python: 56,513; perl: 24,575; sh: 5,874; lex: 4,383; pascal: 4,304; makefile: 166; ruby: 113; objc: 91; tcl: 35
file content (59 lines) | stat: -rwxr-xr-x 1,847 bytes parent folder | download | duplicates (4)
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
#!/usr/bin/env python3
#
# Wireshark test dummy extcap
#
# Copyright (c) 2018-2019 Peter Wu <peter@lekensteyn.nl>
#
# SPDX-License-Identifier: GPL-2.0-or-later
#
import argparse, codecs, os, sys

parser = argparse.ArgumentParser()

# Actions
parser.add_argument('--extcap-interfaces', action='store_true')
parser.add_argument('--extcap-dlts', action='store_true')
parser.add_argument('--extcap-config', action='store_true')
parser.add_argument('--capture', action='store_true')
parser.add_argument('--extcap-version')

parser.add_argument('--extcap-interface', metavar='IFACE')

parser.add_argument('--extcap-capture-filter', metavar='CFILTER')
parser.add_argument('--fifo', metavar='FIFO')


def extcap_interfaces():
    print("extcap {version=1.0}")
    print("interface {value=sampleif}{display=Remote dumpcap}")


def extcap_dlts():
    # Required for the interface to show up in the interface list
    print("dlt {number=147}{name=USER0}{display=Remote capture dependent DLT}")


def extcap_config():
    print("arg {number=0}{call=--test1}{display=Remote SSH server address}{type=string}{tooltip=bla}{required=true}{group=Server}")
    print("arg {number=1}{call=--test2}{display=[7] UrzÄ…dzenie kompozytowe USB}{type=string}{tooltip=X}{group=Capture}")


def main():
    # In Python 3.6 and older, the encoding of stdout depends on the locale.
    # Do not rely on that and force a sane encoding instead. Python 3.7 has
    # improved, see https://www.python.org/dev/peps/pep-0540/
    sys.stdout = codecs.getwriter('utf-8')(sys.stdout.detach())

    args = parser.parse_args()
    if args.extcap_interfaces:
        return extcap_interfaces()

    if args.extcap_dlts:
        return extcap_dlts()
    elif args.extcap_config:
        return extcap_config()
    else:
        parser.error('Unsupported')
        return 1

sys.exit(main())