Change in libosmocore[master]: gprs_ns2_vty: add optional argument signalling and data weights to `n...

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

lynxis lazus gerrit-no-reply at lists.osmocom.org
Fri Feb 19 10:41:51 UTC 2021


lynxis lazus has submitted this change. ( https://gerrit.osmocom.org/c/libosmocore/+/22900 )

Change subject: gprs_ns2_vty: add optional argument signalling and data weights to `nsvc udp`
......................................................................

gprs_ns2_vty: add optional argument signalling and data weights to `nsvc udp`

A static configured UDP NSVC can have signalling and data weights

Related: SYS#5354
Change-Id: Id363937c64e786c55e3136401ebdb44052415e0f
---
M src/gb/gprs_ns2_vty.c
M tests/gb/gprs_ns2_vty.vty
2 files changed, 74 insertions(+), 11 deletions(-)

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



diff --git a/src/gb/gprs_ns2_vty.c b/src/gb/gprs_ns2_vty.c
index 01409bb..4bd7cde 100644
--- a/src/gb/gprs_ns2_vty.c
+++ b/src/gb/gprs_ns2_vty.c
@@ -1038,14 +1038,8 @@
 	return CMD_SUCCESS;
 }
 
-DEFUN(cfg_ns_nse_nsvc_udp, cfg_ns_nse_nsvc_udp_cmd,
-      "nsvc udp BIND " VTY_IPV46_CMD " <1-65535>",
-      "NS Virtual Connection\n"
-      "NS over UDP\n"
-      "A unique bind identifier created by ns bind\n"
-      "Remote IPv4 Address\n" "Remote IPv6 Address\n"
-      "Remote UDP Port\n"
-      )
+static int ns_nse_nsvc_udp_cmds(struct vty *vty, const char *bind_name, const char *remote_char, uint16_t port,
+				uint16_t sig_weight, uint16_t data_weight)
 {
 	struct gprs_ns2_vc_bind *bind;
 	struct gprs_ns2_vc *nsvc;
@@ -1053,10 +1047,8 @@
 	bool dialect_modified = false;
 	bool ll_modified = false;
 
-	const char *bind_name = argv[0];
 	struct osmo_sockaddr_str remote_str;
 	struct osmo_sockaddr remote;
-	uint16_t port = atoi(argv[2]);
 
 	if (nse->ll == GPRS_NS2_LL_UNDEF) {
 		nse->ll = GPRS_NS2_LL_UDP;
@@ -1078,7 +1070,7 @@
 		goto err;
 	}
 
-	if (osmo_sockaddr_str_from_str(&remote_str, argv[1], port)) {
+	if (osmo_sockaddr_str_from_str(&remote_str, remote_char, port)) {
 		vty_out(vty, "Can not parse IPv4/IPv6 or port.%s", VTY_NEWLINE);
 		goto err;
 	}
@@ -1106,6 +1098,8 @@
 		vty_out(vty, "Can not create NS-VC.%s", VTY_NEWLINE);
 		goto err;
 	}
+	nsvc->sig_weight = sig_weight;
+	nsvc->data_weight = data_weight;
 	nsvc->persistent = true;
 
 	return CMD_SUCCESS;
@@ -1118,6 +1112,45 @@
 	return CMD_WARNING;
 }
 
+DEFUN(cfg_ns_nse_nsvc_udp, cfg_ns_nse_nsvc_udp_cmd,
+      "nsvc udp BIND " VTY_IPV46_CMD " <1-65535>",
+      "NS Virtual Connection\n"
+      "NS over UDP\n"
+      "A unique bind identifier created by ns bind\n"
+      "Remote IPv4 Address\n" "Remote IPv6 Address\n"
+      "Remote UDP Port\n")
+{
+	const char *bind_name = argv[0];
+	const char *remote = argv[1];
+	uint16_t port = atoi(argv[2]);
+	uint16_t sig_weight = 1;
+	uint16_t data_weight = 1;
+
+	return ns_nse_nsvc_udp_cmds(vty, bind_name, remote, port, sig_weight, data_weight);
+}
+
+DEFUN(cfg_ns_nse_nsvc_udp_weights, cfg_ns_nse_nsvc_udp_weights_cmd,
+      "nsvc udp BIND " VTY_IPV46_CMD " <1-65535> signalling-weight <0-254> data-weight <0-254>",
+      "NS Virtual Connection\n"
+      "NS over UDP\n"
+      "A unique bind identifier created by ns bind\n"
+      "Remote IPv4 Address\n" "Remote IPv6 Address\n"
+      "Remote UDP Port\n"
+      "Signalling weight of the NSVC (default = 1)\n"
+      "Signalling weight of the NSVC (default = 1)\n"
+      "Data weight of the NSVC (default = 1)\n"
+      "Data weight of the NSVC (default = 1)\n"
+      )
+{
+	const char *bind_name = argv[0];
+	const char *remote = argv[1];
+	uint16_t port = atoi(argv[2]);
+	uint16_t sig_weight = atoi(argv[3]);
+	uint16_t data_weight = atoi(argv[4]);
+
+	return ns_nse_nsvc_udp_cmds(vty, bind_name, remote, port, sig_weight, data_weight);
+}
+
 DEFUN(cfg_no_ns_nse_nsvc_udp, cfg_no_ns_nse_nsvc_udp_cmd,
       "no nsvc udp BIND " VTY_IPV46_CMD " <1-65535>",
       NO_STR
@@ -2033,6 +2066,7 @@
 	install_lib_element(L_NS_NSE_NODE, &cfg_no_ns_nse_nsvci_cmd);
 	install_lib_element(L_NS_NSE_NODE, &cfg_no_ns_nse_nsvc_fr_dlci_cmd);
 	install_lib_element(L_NS_NSE_NODE, &cfg_ns_nse_nsvc_udp_cmd);
+	install_lib_element(L_NS_NSE_NODE, &cfg_ns_nse_nsvc_udp_weights_cmd);
 	install_lib_element(L_NS_NSE_NODE, &cfg_no_ns_nse_nsvc_udp_cmd);
 	install_lib_element(L_NS_NSE_NODE, &cfg_ns_nse_nsvc_ipa_cmd);
 	install_lib_element(L_NS_NSE_NODE, &cfg_no_ns_nse_nsvc_ipa_cmd);
diff --git a/tests/gb/gprs_ns2_vty.vty b/tests/gb/gprs_ns2_vty.vty
index a748f13..a969881 100644
--- a/tests/gb/gprs_ns2_vty.vty
+++ b/tests/gb/gprs_ns2_vty.vty
@@ -32,3 +32,32 @@
 UDP bind: 127.0.0.14:42999 DSCP: 0
   IP-SNS signalling weight: 1 data weight: 1
   0 NS-VC: 
+OsmoNSdummy# configure terminal
+OsmoNSdummy(config)# ns
+OsmoNSdummy(config-ns)# nse 1234
+OsmoNSdummy(config-ns-nse)# nsvc udp abc 127.0.0.15 9496
+OsmoNSdummy(config-ns-nse)# end
+OsmoNSdummy# show ns
+NSEI 01234: UDP, DEAD
+ NSVCI none: RECOVERING PERSIST data_weight=1 sig_weight=1 udp)[127.0.0.14]:42999<>[127.0.0.15]:9496
+UDP bind: 127.0.0.14:42999 DSCP: 0
+  IP-SNS signalling weight: 1 data weight: 1
+  1 NS-VC: 
+    NSVCI 00000: udp)[127.0.0.14]:42999<>[127.0.0.15]:9496
+OsmoNSdummy# configure terminal
+OsmoNSdummy(config)# ns
+OsmoNSdummy(config-ns)# nse 1234
+OsmoNSdummy(config-ns-nse)# nsvc udp abc 127.0.0.16 9496 signalling-weight 0 data-weight 9
+OsmoNSdummy(config-ns-nse)# nsvc udp abc 127.0.0.17 9496 signalling-weight 0 data-weight 0
+OsmoNSdummy(config-ns-nse)# end
+OsmoNSdummy# show ns
+NSEI 01234: UDP, DEAD
+ NSVCI none: RECOVERING PERSIST data_weight=0 sig_weight=0 udp)[127.0.0.14]:42999<>[127.0.0.17]:9496
+ NSVCI none: RECOVERING PERSIST data_weight=9 sig_weight=0 udp)[127.0.0.14]:42999<>[127.0.0.16]:9496
+ NSVCI none: RECOVERING PERSIST data_weight=1 sig_weight=1 udp)[127.0.0.14]:42999<>[127.0.0.15]:9496
+UDP bind: 127.0.0.14:42999 DSCP: 0
+  IP-SNS signalling weight: 1 data weight: 1
+  3 NS-VC: 
+    NSVCI 00000: udp)[127.0.0.14]:42999<>[127.0.0.17]:9496
+    NSVCI 00000: udp)[127.0.0.14]:42999<>[127.0.0.16]:9496
+    NSVCI 00000: udp)[127.0.0.14]:42999<>[127.0.0.15]:9496

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

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: Id363937c64e786c55e3136401ebdb44052415e0f
Gerrit-Change-Number: 22900
Gerrit-PatchSet: 11
Gerrit-Owner: lynxis lazus <lynxis at fe80.eu>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: daniel <dwillmann at sysmocom.de>
Gerrit-Reviewer: laforge <laforge at osmocom.org>
Gerrit-Reviewer: lynxis lazus <lynxis at fe80.eu>
Gerrit-Reviewer: pespin <pespin at sysmocom.de>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20210219/8f71c69c/attachment.htm>


More information about the gerrit-log mailing list