Change in gr-gsm[master]: gsm_trx_burst_if: allow to customize the bind address

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:19 UTC 2018


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

Change subject: gsm_trx_burst_if: allow to customize the bind address
......................................................................

gsm_trx_burst_if: allow to customize the bind address

Pleviously remote address for DATA interface was also used as the
bind address, what is definitely wrong. Let's change the API a bit
in order to allow one to specify a custom bind address.

Change-Id: I6e5f7b7119ac454217b8dd04f9ee0dd3b23972b6
---
M grc/trx/gsm_trx_burst_if.xml
M include/grgsm/misc_utils/udp_socket.h
M include/grgsm/trx/trx_burst_if.h
M lib/misc_utils/udp_socket.cc
M lib/trx/trx_burst_if_impl.cc
M lib/trx/trx_burst_if_impl.h
M python/trx/radio_if.py
7 files changed, 26 insertions(+), 11 deletions(-)

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



diff --git a/grc/trx/gsm_trx_burst_if.xml b/grc/trx/gsm_trx_burst_if.xml
index 99427b3..49979a3 100644
--- a/grc/trx/gsm_trx_burst_if.xml
+++ b/grc/trx/gsm_trx_burst_if.xml
@@ -3,7 +3,7 @@
   <name>TRX Burst Interface</name>
   <key>gsm_trx_burst_if</key>
   <import>import grgsm</import>
-  <make>grgsm.trx_burst_if($remote_addr, $base_port)</make>
+  <make>grgsm.trx_burst_if($bind_addr, $remote_addr, $base_port)</make>
 
   <param>
     <name>base_port</name>
@@ -13,6 +13,13 @@
   </param>
 
   <param>
+    <name>bind_addr</name>
+    <key>bind_addr</key>
+    <value>0.0.0.0</value>
+    <type>string</type>
+  </param>
+
+  <param>
     <name>remote_addr</name>
     <key>remote_addr</key>
     <value>127.0.0.1</value>
diff --git a/include/grgsm/misc_utils/udp_socket.h b/include/grgsm/misc_utils/udp_socket.h
index 15b2c66..d1ceb9f 100644
--- a/include/grgsm/misc_utils/udp_socket.h
+++ b/include/grgsm/misc_utils/udp_socket.h
@@ -53,8 +53,9 @@
 
     public:
       udp_socket(
-        const std::string &remote_addr,
+        const std::string &bind_addr,
         const std::string &src_port,
+        const std::string &remote_addr,
         const std::string &dst_port,
         size_t mtu);
       ~udp_socket();
diff --git a/include/grgsm/trx/trx_burst_if.h b/include/grgsm/trx/trx_burst_if.h
index 0e7a35a..9277dc5 100644
--- a/include/grgsm/trx/trx_burst_if.h
+++ b/include/grgsm/trx/trx_burst_if.h
@@ -48,6 +48,7 @@
        * creating new instances.
        */
       static sptr make(
+        const std::string &bind_addr,
         const std::string &remote_addr,
         const std::string &base_port);
     };
diff --git a/lib/misc_utils/udp_socket.cc b/lib/misc_utils/udp_socket.cc
index 73393a0..c43f183 100644
--- a/lib/misc_utils/udp_socket.cc
+++ b/lib/misc_utils/udp_socket.cc
@@ -38,8 +38,9 @@
   namespace gsm {
 
     udp_socket::udp_socket(
-      const std::string &remote_addr,
+      const std::string &bind_addr,
       const std::string &src_port,
+      const std::string &remote_addr,
       const std::string &dst_port,
       size_t mtu)
     {
@@ -50,7 +51,7 @@
       udp::resolver resolver(d_io_service);
 
       udp::resolver::query rx_query(
-        udp::v4(), remote_addr, src_port,
+        udp::v4(), bind_addr, src_port,
         boost::asio::ip::resolver_query_base::passive);
       udp::resolver::query tx_query(
         udp::v4(), remote_addr, dst_port,
diff --git a/lib/trx/trx_burst_if_impl.cc b/lib/trx/trx_burst_if_impl.cc
index e3fcc89..f72eecd 100644
--- a/lib/trx/trx_burst_if_impl.cc
+++ b/lib/trx/trx_burst_if_impl.cc
@@ -48,19 +48,22 @@
 
     trx_burst_if::sptr
     trx_burst_if::make(
+      const std::string &bind_addr,
       const std::string &remote_addr,
       const std::string &base_port)
     {
       int base_port_int = boost::lexical_cast<int> (base_port);
 
       return gnuradio::get_initial_sptr
-        (new trx_burst_if_impl(remote_addr, base_port_int));
+        (new trx_burst_if_impl(bind_addr, remote_addr,
+          base_port_int));
     }
 
     /*
      * The private constructor
      */
     trx_burst_if_impl::trx_burst_if_impl(
+      const std::string &bind_addr,
       const std::string &remote_addr,
       int base_port
     ) : gr::block("trx_burst_if",
@@ -79,8 +82,8 @@
         std::string data_dst_port = boost::lexical_cast<std::string> (base_port + 102);
 
         // Init DATA interface
-        d_data_sock = new udp_socket(remote_addr,
-          data_src_port, data_dst_port, DATA_IF_MTU);
+        d_data_sock = new udp_socket(bind_addr, data_src_port,
+          remote_addr, data_dst_port, DATA_IF_MTU);
 
         // Bind DATA interface handler
         d_data_sock->udp_rx_handler = boost::bind(
diff --git a/lib/trx/trx_burst_if_impl.h b/lib/trx/trx_burst_if_impl.h
index 27ec259..fdb49f2 100644
--- a/lib/trx/trx_burst_if_impl.h
+++ b/lib/trx/trx_burst_if_impl.h
@@ -40,7 +40,8 @@
       void burst_pack(pmt::pmt_t msg, uint8_t *buf);
 
      public:
-      trx_burst_if_impl(const std::string &remote_addr, int base_port);
+      trx_burst_if_impl(const std::string &bind_addr,
+        const std::string &remote_addr, int base_port);
       ~trx_burst_if_impl();
 
       void handle_dl_burst(pmt::pmt_t msg);
diff --git a/python/trx/radio_if.py b/python/trx/radio_if.py
index 2648cc9..25a35a5 100644
--- a/python/trx/radio_if.py
+++ b/python/trx/radio_if.py
@@ -81,7 +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_remote_addr, trx_base_port,
+			trx_bind_addr = "0.0.0.0"):
 
 		print("[i] Init Radio interface")
 
@@ -95,8 +96,8 @@
 
 		# TRX Burst Interface
 		self.trx_burst_if = grgsm.trx_burst_if(
-			trx_remote_addr, str(trx_base_port))
-
+			trx_bind_addr, trx_remote_addr,
+			str(trx_base_port))
 
 		# RX path definition
 		self.phy_src = uhd.usrp_source(phy_args,

-- 
To view, visit https://gerrit.osmocom.org/10424
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: I6e5f7b7119ac454217b8dd04f9ee0dd3b23972b6
Gerrit-Change-Number: 10424
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/40db26e4/attachment.htm>


More information about the gerrit-log mailing list