aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexander Couzens <lynxis@fe80.eu>2021-02-12 04:04:13 +0100
committerlynxis lazus <lynxis@fe80.eu>2021-02-19 10:41:50 +0000
commitbf5d0dbdec94f58bdbedadd92db7111e51fa7053 (patch)
tree1a1c90717a0720b30735ea28eb2fec65589c1851
parent6b9d2324219d50f38f27cfaa5d546379f0aec74e (diff)
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
-rw-r--r--src/gb/gprs_ns2_vty.c56
-rw-r--r--tests/gb/gprs_ns2_vty.vty29
2 files changed, 74 insertions, 11 deletions
diff --git a/src/gb/gprs_ns2_vty.c b/src/gb/gprs_ns2_vty.c
index 01409bbf..4bd7cdef 100644
--- a/src/gb/gprs_ns2_vty.c
+++ b/src/gb/gprs_ns2_vty.c
@@ -1038,14 +1038,8 @@ DEFUN(cfg_no_ns_nse_nsvci, cfg_no_ns_nse_nsvci_cmd,
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 @@ DEFUN(cfg_ns_nse_nsvc_udp, cfg_ns_nse_nsvc_udp_cmd,
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 @@ DEFUN(cfg_ns_nse_nsvc_udp, cfg_ns_nse_nsvc_udp_cmd,
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 @@ DEFUN(cfg_ns_nse_nsvc_udp, cfg_ns_nse_nsvc_udp_cmd,
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 @@ err:
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 @@ int gprs_ns2_vty_init(struct gprs_ns2_inst *nsi)
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 a748f135..a9698813 100644
--- a/tests/gb/gprs_ns2_vty.vty
+++ b/tests/gb/gprs_ns2_vty.vty
@@ -32,3 +32,32 @@ OsmoNSdummy# show ns
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