Change in osmo-bsc[master]: CBSP: add local bind to client mode

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/.

laforge gerrit-no-reply at lists.osmocom.org
Sat Aug 29 07:57:59 UTC 2020


laforge has submitted this change. ( https://gerrit.osmocom.org/c/osmo-bsc/+/19865 )

Change subject: CBSP: add local bind to client mode
......................................................................

CBSP: add local bind to client mode

Add the ability to set a local bind address for the CBSP client mode.

Change-Id: I56a420d204a9a487b27dd460f4cc52e0b4093d69
---
M include/osmocom/bsc/smscb.h
M src/osmo-bsc/bsc_init.c
M src/osmo-bsc/cbsp_link.c
M tests/cbc.vty
4 files changed, 113 insertions(+), 2 deletions(-)

Approvals:
  laforge: Looks good to me, but someone else must approve
  fixeria: Looks good to me, approved
  Jenkins Builder: Verified



diff --git a/include/osmocom/bsc/smscb.h b/include/osmocom/bsc/smscb.h
index c7002f6..f48c1a1 100644
--- a/include/osmocom/bsc/smscb.h
+++ b/include/osmocom/bsc/smscb.h
@@ -55,6 +55,7 @@
 	/* for handling outbound TCP connections */
 	struct {
 		struct osmo_sockaddr_str remote_addr;
+		struct osmo_sockaddr_str local_addr;
 		struct osmo_stream_cli *cli;
 		char *sock_name;
 		struct msgb *msg;
diff --git a/src/osmo-bsc/bsc_init.c b/src/osmo-bsc/bsc_init.c
index e722199..1460af4 100644
--- a/src/osmo-bsc/bsc_init.c
+++ b/src/osmo-bsc/bsc_init.c
@@ -134,6 +134,7 @@
 	/* For CBSP client mode: default remote CBSP server port is CBSP_TCP_PORT == 48049. Leave the IP address unset.
 	 * Also leave the local bind for the CBSP client disabled (unconfigured). */
 	net->cbc->client.remote_addr = (struct osmo_sockaddr_str){ .port = CBSP_TCP_PORT, };
+	net->cbc->client.local_addr = (struct osmo_sockaddr_str){};
 
 	return net;
 
diff --git a/src/osmo-bsc/cbsp_link.c b/src/osmo-bsc/cbsp_link.c
index d587675..e5e72de 100644
--- a/src/osmo-bsc/cbsp_link.c
+++ b/src/osmo-bsc/cbsp_link.c
@@ -250,6 +250,11 @@
 		/* CBC side */
 		osmo_stream_cli_set_addr(cbc->client.cli, cbc->client.remote_addr.ip);
 		osmo_stream_cli_set_port(cbc->client.cli, cbc->client.remote_addr.port);
+		/* local side */
+		if (osmo_sockaddr_str_is_set(&cbc->client.local_addr)) {
+			osmo_stream_cli_set_local_addr(cbc->client.cli, cbc->client.local_addr.ip);
+			osmo_stream_cli_set_local_port(cbc->client.cli, cbc->client.local_addr.port);
+		}
 		/* Close/Reconnect? */
 		if (osmo_stream_cli_open(cbc->client.cli) < 0) {
 			LOGP(DCBS, LOGL_ERROR, "Cannot open CBSP client link to " OSMO_SOCKADDR_STR_FMT "\n",
@@ -400,6 +405,44 @@
 	return CMD_SUCCESS;
 }
 
+DEFUN(cfg_cbc_client_local_ip, cfg_cbc_client_local_ip_cmd,
+	"local-ip " VTY_IPV46_CMD,
+	"Set local bind address for the outbound CBSP link to the Cell Broadcast Centre\n"
+	"IPv4 address\n" "IPv6 address\n")
+{
+	struct bsc_cbc_link *cbc = vty_cbc_data(vty);
+	osmo_sockaddr_str_from_str(&cbc->client.local_addr, argv[0], cbc->client.local_addr.port);
+	return CMD_SUCCESS;
+}
+
+DEFUN(cfg_cbc_client_local_port, cfg_cbc_client_local_port_cmd,
+	"local-port <1-65535>",
+	"Set local bind port for the outbound CBSP link to the Cell Broadcast Centre\n"
+	"port number\n")
+{
+	struct bsc_cbc_link *cbc = vty_cbc_data(vty);
+	cbc->client.local_addr.port = atoi(argv[0]);
+	return CMD_SUCCESS;
+}
+
+DEFUN(cfg_cbc_client_no_local_ip, cfg_cbc_client_no_local_ip_cmd,
+	"no local-ip",
+	NO_STR "Remove local IP address bind config for the CBSP client mode\n")
+{
+	struct bsc_cbc_link *cbc = vty_cbc_data(vty);
+	cbc->client.local_addr = (struct osmo_sockaddr_str){ .port = cbc->client.local_addr.port };
+	return CMD_SUCCESS;
+}
+
+DEFUN(cfg_cbc_client_no_local_port, cfg_cbc_client_no_local_port_cmd,
+	"no local-port",
+	NO_STR "Remove local TCP port bind config for the CBSP client mode\n")
+{
+	struct bsc_cbc_link *cbc = vty_cbc_data(vty);
+	cbc->client.local_addr.port = 0;
+	return CMD_SUCCESS;
+}
+
 static struct cmd_node cbc_node = {
 	CBC_NODE,
 	"%s(config-cbc)# ",
@@ -424,15 +467,17 @@
 
 	bool default_server_local;
 	bool default_client_remote;
+	bool default_client_local;
 
 	default_server_local = !osmo_sockaddr_str_cmp(&cbc->server.local_addr,
 						      &bsc_cbc_default_server_local_addr);
 	default_client_remote = !osmo_sockaddr_str_is_set(&cbc->client.remote_addr);
+	default_client_local = !osmo_sockaddr_str_is_set(&cbc->client.local_addr);
 
 	/* If all reflects default values, skip the 'cbc' section */
 	if (cbc->mode == BSC_CBC_LINK_MODE_DISABLED
 	    && default_server_local
-	    && default_client_remote)
+	    && default_client_remote && default_client_local)
 		return 0;
 
 	vty_out(vty, "cbc%s", VTY_NEWLINE);
@@ -447,7 +492,7 @@
 			vty_out(vty, "  local-port %u%s", cbc->server.local_addr.port, VTY_NEWLINE);
 	}
 
-	if (!default_client_remote) {
+	if (!(default_client_remote && default_client_local)) {
 		vty_out(vty, " client%s", VTY_NEWLINE);
 
 		if (osmo_sockaddr_str_is_set(&cbc->client.remote_addr)) {
@@ -455,6 +500,11 @@
 			if (cbc->client.remote_addr.port != CBSP_TCP_PORT)
 				vty_out(vty, "  remote-port %u%s", cbc->client.remote_addr.port, VTY_NEWLINE);
 		}
+
+		if (cbc->client.local_addr.ip[0])
+			vty_out(vty, "  local-ip %s%s", cbc->client.local_addr.ip, VTY_NEWLINE);
+		if (cbc->client.local_addr.port)
+			vty_out(vty, "  local-port %u%s", cbc->client.local_addr.port, VTY_NEWLINE);
 	}
 
 	return 0;
@@ -505,4 +555,8 @@
 	install_node(&cbc_client_node, NULL);
 	install_element(CBC_CLIENT_NODE, &cfg_cbc_client_remote_ip_cmd);
 	install_element(CBC_CLIENT_NODE, &cfg_cbc_client_remote_port_cmd);
+	install_element(CBC_CLIENT_NODE, &cfg_cbc_client_local_ip_cmd);
+	install_element(CBC_CLIENT_NODE, &cfg_cbc_client_local_port_cmd);
+	install_element(CBC_CLIENT_NODE, &cfg_cbc_client_no_local_ip_cmd);
+	install_element(CBC_CLIENT_NODE, &cfg_cbc_client_no_local_port_cmd);
 }
diff --git a/tests/cbc.vty b/tests/cbc.vty
index 2cad609..7a4031f 100644
--- a/tests/cbc.vty
+++ b/tests/cbc.vty
@@ -94,11 +94,18 @@
 ...
   remote-ip (A.B.C.D|X:X::X:X)
   remote-port <1-65535>
+  local-ip (A.B.C.D|X:X::X:X)
+  local-port <1-65535>
+  no local-ip
+  no local-port
 
 OsmoBSC(config-cbc-client)# ?
 ...
   remote-ip    Set IP Address of the Cell Broadcast Centre, to establish CBSP link to
   remote-port  Set TCP port of the Cell Broadcast Centre, to establish CBSP link to
+  local-ip     Set local bind address for the outbound CBSP link to the Cell Broadcast Centre
+  local-port   Set local bind port for the outbound CBSP link to the Cell Broadcast Centre
+  no           Negate a command or set its defaults
 
 OsmoBSC(config-cbc-client)# remote-ip ?
   A.B.C.D   IPv4 address
@@ -106,6 +113,10 @@
 OsmoBSC(config-cbc-client)# remote-port ?
   <1-65535>  CBSP port number (Default: 48049)
 
+OsmoBSC(config-cbc-client)# no ?
+  local-ip    Remove local IP address bind config for the CBSP client mode
+  local-port  Remove local TCP port bind config for the CBSP client mode
+
 OsmoBSC(config-cbc-client)# remote-ip 1.2.3.4
 OsmoBSC(config-cbc-client)# remote-port 12345
 OsmoBSC(config-cbc-client)# show running-config
@@ -136,6 +147,50 @@
   remote-ip 1:2:3:4::5
 ...
 
+OsmoBSC(config-cbc-client)# local-ip 1.2.3.4
+
+OsmoBSC(config-cbc-client)# show running-config
+...
+cbc
+...
+ client
+  remote-ip 1:2:3:4::5
+  local-ip 1.2.3.4
+... !local-port
+
+OsmoBSC(config-cbc-client)# local-port 12345
+
+OsmoBSC(config-cbc-client)# show running-config
+...
+cbc
+...
+ client
+  remote-ip 1:2:3:4::5
+  local-ip 1.2.3.4
+  local-port 12345
+...
+
+OsmoBSC(config-cbc-client)# no local-ip
+
+OsmoBSC(config-cbc-client)# show running-config
+...
+cbc
+...
+ client
+  remote-ip 1:2:3:4::5
+  local-port 12345
+... !local
+
+OsmoBSC(config-cbc-client)# no local-port
+
+OsmoBSC(config-cbc-client)# show running-config
+...
+cbc
+...
+ client
+  remote-ip 1:2:3:4::5
+... !local
+
 OsmoBSC(config-cbc-client)# do show cbc
 CBSP link is disabled
 

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

Gerrit-Project: osmo-bsc
Gerrit-Branch: master
Gerrit-Change-Id: I56a420d204a9a487b27dd460f4cc52e0b4093d69
Gerrit-Change-Number: 19865
Gerrit-PatchSet: 3
Gerrit-Owner: neels <nhofmeyr at sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria <vyanitskiy at sysmocom.de>
Gerrit-Reviewer: laforge <laforge at osmocom.org>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20200829/6242e765/attachment.htm>


More information about the gerrit-log mailing list