summaryrefslogtreecommitdiffstats
path: root/src/target
diff options
context:
space:
mode:
authorVadim Yanitskiy <axilirator@gmail.com>2019-07-24 04:00:15 +0700
committerVadim Yanitskiy <axilirator@gmail.com>2019-07-24 05:44:19 +0700
commit710503bc4c83b6b8562ffac0ba7ee6113167b586 (patch)
tree1dd80eff48ce93cf9872f583259e8a988112fcff /src/target
parente92c9cd923fe6d4cdce073ffe397ede2b09b30c3 (diff)
trx_toolkit/trx_sniff.py: support sniffing on multiple ports
Diffstat (limited to 'src/target')
-rwxr-xr-xsrc/target/trx_toolkit/trx_sniff.py13
1 files changed, 7 insertions, 6 deletions
diff --git a/src/target/trx_toolkit/trx_sniff.py b/src/target/trx_toolkit/trx_sniff.py
index 45a5cf4..7eea04c 100755
--- a/src/target/trx_toolkit/trx_sniff.py
+++ b/src/target/trx_toolkit/trx_sniff.py
@@ -57,14 +57,14 @@ class Application(ApplicationBase):
self.ddf = DATADumpFile(self.argv.output_file)
def run(self):
- # Compose a packet filter
- pkt_filter = "udp and (port %d or port %d)" \
- % (self.argv.base_port + 2, self.argv.base_port + 102)
+ # Compose a list of permitted UDP ports
+ rx_port_list = ["port %d" % (port + 102) for port in self.argv.base_ports]
+ tx_port_list = ["port %d" % (port + 2) for port in self.argv.base_ports]
# Arguments to be passed to scapy.all.sniff()
sniff_args = {
+ "filter" : "udp and (%s)" % " or ".join(rx_port_list + tx_port_list),
"prn" : self.pkt_handler,
- "filter" : pkt_filter,
"store" : 0,
}
@@ -208,8 +208,9 @@ class Application(ApplicationBase):
self.app_reg_logging_options(parser)
trx_group = parser.add_argument_group("TRX interface")
- trx_group.add_argument("-p", "--base-port",
- dest = "base_port", type = int, default = 6700,
+ trx_group.add_argument("-p", "--base-port", "--base-ports",
+ dest = "base_ports", type = int, metavar = "PORT",
+ default = [5700, 6700], nargs = "*",
help = "Set base port number (default %(default)s)")
trx_group.add_argument("-o", "--output-file", metavar = "FILE",
dest = "output_file", type = str,