Change in ...osmocom-bb[master]: trx_toolkit/trx_sniff.py: support sniffing on multiple ports

fixeria gerrit-no-reply at lists.osmocom.org
Tue Jul 23 21:12:14 UTC 2019


fixeria has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmocom-bb/+/14915


Change subject: trx_toolkit/trx_sniff.py: support sniffing on multiple ports
......................................................................

trx_toolkit/trx_sniff.py: support sniffing on multiple ports

Change-Id: I76b818c673b98c427b5621ddb852f947c74557d6
---
M src/target/trx_toolkit/trx_sniff.py
1 file changed, 7 insertions(+), 6 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/osmocom-bb refs/changes/15/14915/1

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 @@
 			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 @@
 		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,

-- 
To view, visit https://gerrit.osmocom.org/c/osmocom-bb/+/14915
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: osmocom-bb
Gerrit-Branch: master
Gerrit-Change-Id: I76b818c673b98c427b5621ddb852f947c74557d6
Gerrit-Change-Number: 14915
Gerrit-PatchSet: 1
Gerrit-Owner: fixeria <axilirator at gmail.com>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20190723/c19407f3/attachment.html>


More information about the gerrit-log mailing list