Change in gr-gsm[master]: apps/grgsm_trx: introduce bind address option

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

Piotr Krysik gerrit-no-reply at lists.osmocom.org
Fri Aug 10 09:46:20 UTC 2018


Piotr Krysik has submitted this change and it was merged. ( https://gerrit.osmocom.org/10425 )

Change subject: apps/grgsm_trx: introduce bind address option
......................................................................

apps/grgsm_trx: introduce bind address option

The new option (-b --bind-addr) allows one to specify the bind
address for both DATA and CTRL interfaces. By default, '0.0.0.0'
is used, so there are no restrictions for the L1 source address.

Change-Id: I3339f686b53db07cfd1bff9a516f4bdc28058cd9
---
M apps/grgsm_trx
M python/trx/ctrl_if_bb.py
M python/trx/radio_if.py
M python/trx/udp_link.py
4 files changed, 23 insertions(+), 15 deletions(-)

Approvals:
  Piotr Krysik: Looks good to me, approved; Verified



diff --git a/apps/grgsm_trx b/apps/grgsm_trx
index 668b0be..1c0581f 100755
--- a/apps/grgsm_trx
+++ b/apps/grgsm_trx
@@ -3,7 +3,7 @@
 
 # GR-GSM based transceiver
 #
-# (C) 2016-2017 by Vadim Yanitskiy <axilirator at gmail.com>
+# (C) 2016-2018 by Vadim Yanitskiy <axilirator at gmail.com>
 #
 # All Rights Reserved
 #
@@ -30,7 +30,7 @@
 from grgsm.trx import fake_pm
 
 COPYRIGHT = \
-	"Copyright (C) 2016-2017 by Vadim Yanitskiy <axilirator at gmail.com>\n" \
+	"Copyright (C) 2016-2018 by Vadim Yanitskiy <axilirator at gmail.com>\n" \
 	"Copyright (C) 2017 by Piotr Krysik <ptrkrysik at gmail.com>\n" \
 	"License GPLv2+: GNU GPL version 2 or later " \
 	"<http://gnu.org/licenses/gpl.html>\n" \
@@ -40,6 +40,7 @@
 class Application:
 	# Application variables
 	remote_addr = "127.0.0.1"
+	bind_addr = "0.0.0.0"
 	base_port = 6700
 
 	# PHY specific
@@ -63,7 +64,8 @@
 		self.radio = radio_if(self.phy_args, self.phy_sample_rate,
 			self.phy_rx_gain, self.phy_tx_gain, self.phy_ppm,
 			self.phy_rx_antenna, self.phy_tx_antenna,
-			self.remote_addr, self.base_port)
+			self.bind_addr, self.remote_addr,
+			self.base_port)
 
 		# Power measurement emulation
 		# Noise: -120 .. -105
@@ -71,8 +73,9 @@
 		self.pm = fake_pm(-120, -105, -75, -50)
 
 		# Init TRX CTRL interface
-		self.server = ctrl_if_bb(self.remote_addr,
-			self.base_port + 101, self.base_port + 1,
+		self.server = ctrl_if_bb(
+			self.remote_addr, self.base_port + 101,
+			self.bind_addr, self.base_port + 1,
 			self.radio, self.pm)
 
 		print("[i] Init complete")
@@ -96,6 +99,7 @@
 		# TRX specific
 		s += " TRX interface specific\n" \
 			 "  -i --remote-addr  Set remote address (default %s)\n" \
+			 "  -b --bind-addr    Set bind address (default %s)\n" \
 			 "  -p --base-port    Set base port number (default %d)\n\n"
 
 		# PHY specific
@@ -110,6 +114,7 @@
 
 		print(s % (
 			self.remote_addr,
+			self.bind_addr,
 			self.base_port,
 			self.phy_rx_gain,
 			self.phy_tx_gain,
@@ -120,10 +125,10 @@
 	def parse_argv(self):
 		try:
 			opts, args = getopt.getopt(sys.argv[1:],
-				"i:p:a:s:g:G:h",
-				["help", "remote-addr=", "base-port=", "device-args=",
-				"sample-rate=", "rx-gain=", "tx-gain=", "ppm=",
-				"rx-antenna=", "tx-antenna="])
+				"i:b:p:a:s:g:G:h",
+				["help", "remote-addr=", "bind-addr=", "base-port=",
+				"device-args=", "sample-rate=", "rx-gain=", "tx-gain=",
+				"ppm=", "rx-antenna=", "tx-antenna="])
 		except getopt.GetoptError as err:
 			# Print(help and exit)
 			self.print_help()
@@ -138,6 +143,8 @@
 			# TRX specific
 			elif o in ("-i", "--remote-addr"):
 				self.remote_addr = v
+			elif o in ("-b", "--bind-addr"):
+				self.bind_addr = v
 			elif o in ("-p", "--base-port"):
 				if int(v) >= 0 and int(v) <= 65535:
 					self.base_port = int(v)
diff --git a/python/trx/ctrl_if_bb.py b/python/trx/ctrl_if_bb.py
index 7886e23..f5a9fa3 100644
--- a/python/trx/ctrl_if_bb.py
+++ b/python/trx/ctrl_if_bb.py
@@ -26,9 +26,10 @@
 from ctrl_if import ctrl_if
 
 class ctrl_if_bb(ctrl_if):
-	def __init__(self, remote_addr, remote_port, bind_port, tb, pm):
+	def __init__(self, remote_addr, remote_port, bind_addr, bind_port, tb, pm):
 		print("[i] Init CTRL interface")
-		ctrl_if.__init__(self, remote_addr, remote_port, bind_port)
+		ctrl_if.__init__(self, remote_addr, remote_port,
+			bind_addr, bind_port)
 
 		# Set link to the follow graph (top block)
 		self.tb = tb
diff --git a/python/trx/radio_if.py b/python/trx/radio_if.py
index 25a35a5..1c7f003 100644
--- a/python/trx/radio_if.py
+++ b/python/trx/radio_if.py
@@ -81,8 +81,8 @@
 	def __init__(self, phy_args, phy_sample_rate,
 			phy_rx_gain, phy_tx_gain, phy_ppm,
 			phy_rx_antenna, phy_tx_antenna,
-			trx_remote_addr, trx_base_port,
-			trx_bind_addr = "0.0.0.0"):
+			trx_bind_addr, trx_remote_addr,
+			trx_base_port):
 
 		print("[i] Init Radio interface")
 
diff --git a/python/trx/udp_link.py b/python/trx/udp_link.py
index d96a6aa..efa701b 100644
--- a/python/trx/udp_link.py
+++ b/python/trx/udp_link.py
@@ -26,10 +26,10 @@
 import select
 
 class udp_link:
-	def __init__(self, remote_addr, remote_port, bind_port):
+	def __init__(self, remote_addr, remote_port, bind_addr = '0.0.0.0', bind_port = 0):
 		self.sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
 		self.sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
-		self.sock.bind((remote_addr, bind_port))
+		self.sock.bind((bind_addr, bind_port))
 		self.sock.setblocking(0)
 
 		# Save remote info

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

Gerrit-Project: gr-gsm
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: I3339f686b53db07cfd1bff9a516f4bdc28058cd9
Gerrit-Change-Number: 10425
Gerrit-PatchSet: 2
Gerrit-Owner: Vadim Yanitskiy <axilirator at gmail.com>
Gerrit-Reviewer: Piotr Krysik <ptrkrysik at gmail.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20180810/7a31c6d8/attachment.htm>


More information about the gerrit-log mailing list