Change in libosmocore[master]: ns2: permit multiple nsvci in one nse in VTY

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
Wed Nov 25 16:34:06 UTC 2020


laforge has submitted this change. ( https://gerrit.osmocom.org/c/libosmocore/+/21245 )

Change subject: ns2: permit multiple nsvci in one nse in VTY
......................................................................

ns2: permit multiple nsvci in one nse in VTY

Change-Id: I4ad454320d0a03e81b399f55e8bd0ee57402dad0
---
M src/gb/gprs_ns2_vty.c
1 file changed, 54 insertions(+), 44 deletions(-)

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



diff --git a/src/gb/gprs_ns2_vty.c b/src/gb/gprs_ns2_vty.c
index 4eb9d37..1759a12 100644
--- a/src/gb/gprs_ns2_vty.c
+++ b/src/gb/gprs_ns2_vty.c
@@ -126,12 +126,14 @@
 	1,
 };
 
-static struct ns2_vty_vc *vtyvc_alloc(uint16_t nsei) {
+static struct ns2_vty_vc *vtyvc_alloc(uint16_t nsei, uint16_t nsvci)
+{
 	struct ns2_vty_vc *vtyvc = talloc_zero(vty_nsi, struct ns2_vty_vc);
 	if (!vtyvc)
 		return vtyvc;
 
 	vtyvc->nsei = nsei;
+	vtyvc->nsvci = nsvci;
 
 	llist_add(&vtyvc->list, &priv.vtyvc);
 
@@ -146,18 +148,19 @@
 	talloc_free(vtyvc);
 }
 
-static struct ns2_vty_vc *vtyvc_by_nsei(uint16_t nsei, bool alloc_missing) {
+static struct ns2_vty_vc *vtyvc_by_nsei_nsvci(uint16_t nsei, uint16_t nsvci, bool alloc_missing)
+{
 	struct ns2_vty_vc *vtyvc;
 
 	llist_for_each_entry(vtyvc, &priv.vtyvc, list) {
-		if (vtyvc->nsei == nsei)
+		if (vtyvc->nsei == nsei && vtyvc->nsvci == nsvci)
 			return vtyvc;
 	}
 
 	if (!alloc_missing)
 		return NULL;
 
-	vtyvc = vtyvc_alloc(nsei);
+	vtyvc = vtyvc_alloc(nsei, nsvci);
 	if (!vtyvc)
 		return vtyvc;
 
@@ -206,36 +209,29 @@
 		vty_out(vty, " nse %u nsvci %u%s",
 			vtyvc->nsei, vtyvc->nsvci, VTY_NEWLINE);
 
-		vty_out(vty, " nse %u remote-role %s%s",
-			vtyvc->nsei, vtyvc->remote_end_is_sgsn ? "sgsn" : "bss",
-			VTY_NEWLINE);
+		vty_out(vty, " nse %u nsvci %u remote-role %s%s", vtyvc->nsei, vtyvc->nsvci,
+			vtyvc->remote_end_is_sgsn ? "sgsn" : "bss", VTY_NEWLINE);
 
 		switch (vtyvc->ll) {
 		case GPRS_NS_LL_UDP:
-			vty_out(vty, " nse %u encapsulation udp%s", vtyvc->nsei, VTY_NEWLINE);
-			vty_out(vty, " nse %u remote-ip %s%s",
-				vtyvc->nsei,
-				vtyvc->remote.ip,
+			vty_out(vty, " nse %u nsvci %u encapsulation udp%s", vtyvc->nsei, vtyvc->nsvci,
 				VTY_NEWLINE);
-			vty_out(vty, " nse %u remote-port %u%s",
-				vtyvc->nsei, vtyvc->remote.port,
-				VTY_NEWLINE);
+			vty_out(vty, " nse %u nsvci %u remote-ip %s%s", vtyvc->nsei, vtyvc->nsvci,
+				vtyvc->remote.ip, VTY_NEWLINE);
+			vty_out(vty, " nse %u nsvci %u remote-port %u%s", vtyvc->nsei, vtyvc->nsvci,
+				vtyvc->remote.port, VTY_NEWLINE);
 			break;
 		case GPRS_NS_LL_FR_GRE:
-			vty_out(vty, " nse %u encapsulation framerelay-gre%s",
-				vtyvc->nsei, VTY_NEWLINE);
-			vty_out(vty, " nse %u remote-ip %s%s",
-				vtyvc->nsei,
-				vtyvc->remote.ip,
-				VTY_NEWLINE);
-			vty_out(vty, " nse %u fr-dlci %u%s",
-				vtyvc->nsei, vtyvc->frdlci,
-				VTY_NEWLINE);
+			vty_out(vty, " nse %u nsvci %u encapsulation framerelay-gre%s", vtyvc->nsei,
+				vtyvc->nsvci, VTY_NEWLINE);
+			vty_out(vty, " nse %u nsvci %u remote-ip %s%s", vtyvc->nsei, vtyvc->nsvci,
+				vtyvc->remote.ip, VTY_NEWLINE);
+			vty_out(vty, " nse %u nsvci %u fr-dlci %u%s", vtyvc->nsei, vtyvc->nsvci,
+				vtyvc->frdlci, VTY_NEWLINE);
 			break;
 		case GPRS_NS_LL_FR:
-			vty_out(vty, " nse %u fr %s dlci %u%s",
-				vtyvc->nsei, vtyvc->netif, vtyvc->frdlci,
-				VTY_NEWLINE);
+			vty_out(vty, " nse %u nsvci %u fr %s dlci %u%s", vtyvc->nsei, vtyvc->nsvci,
+				vtyvc->netif, vtyvc->frdlci, VTY_NEWLINE);
 			break;
 		default:
 			break;
@@ -420,7 +416,7 @@
 	const char *name = argv[3];
 	uint16_t dlci = atoi(argv[4]);
 
-	vtyvc = vtyvc_by_nsei(nsei, true);
+	vtyvc = vtyvc_by_nsei_nsvci(nsei, nsvci, true);
 	if (!vtyvc) {
 		vty_out(vty, "Can not allocate space %s", VTY_NEWLINE);
 		return CMD_WARNING;
@@ -451,7 +447,7 @@
 	uint16_t nsei = atoi(argv[0]);
 	uint16_t nsvci = atoi(argv[1]);
 
-	vtyvc = vtyvc_by_nsei(nsei, true);
+	vtyvc = vtyvc_by_nsei_nsvci(nsei, nsvci, true);
 	if (!vtyvc) {
 		vty_out(vty, "Can not allocate space %s", VTY_NEWLINE);
 		return CMD_WARNING;
@@ -463,37 +459,43 @@
 }
 
 DEFUN(cfg_nse_remoteip, cfg_nse_remoteip_cmd,
-	"nse <0-65535> remote-ip " VTY_IPV46_CMD,
+	"nse <0-65535> nsvci <0-65535> remote-ip " VTY_IPV46_CMD,
 	NSE_CMD_STR
+	"NS Virtual Connection\n"
+	"NS Virtual Connection ID (NSVCI)\n"
 	"Remote IP Address\n"
 	"Remote IPv4 Address\n"
 	"Remote IPv6 Address\n")
 {
 	uint16_t nsei = atoi(argv[0]);
+	uint16_t nsvci = atoi(argv[1]);
 	struct ns2_vty_vc *vtyvc;
 
-	vtyvc = vtyvc_by_nsei(nsei, true);
+	vtyvc = vtyvc_by_nsei_nsvci(nsei, nsvci, true);
 	if (!vtyvc) {
 		vty_out(vty, "Can not allocate space %s", VTY_NEWLINE);
 		return CMD_WARNING;
 	}
 
-	osmo_sockaddr_str_from_str2(&vtyvc->remote, argv[1]);
+	osmo_sockaddr_str_from_str2(&vtyvc->remote, argv[2]);
 
 	return CMD_SUCCESS;
 }
 
 DEFUN(cfg_nse_remoteport, cfg_nse_remoteport_cmd,
-	"nse <0-65535> remote-port <0-65535>",
+	"nse <0-65535> nsvci <0-65535> remote-port <0-65535>",
 	NSE_CMD_STR
+	"NS Virtual Connection\n"
+	"NS Virtual Connection ID (NSVCI)\n"
 	"Remote UDP Port\n"
 	"Remote UDP Port Number\n")
 {
 	uint16_t nsei = atoi(argv[0]);
-	uint16_t port = atoi(argv[1]);
+	uint16_t nsvci = atoi(argv[1]);
+	uint16_t port = atoi(argv[2]);
 	struct ns2_vty_vc *vtyvc;
 
-	vtyvc = vtyvc_by_nsei(nsei, true);
+	vtyvc = vtyvc_by_nsei_nsvci(nsei, nsvci, true);
 	if (!vtyvc) {
 		vty_out(vty, "Can not allocate space %s", VTY_NEWLINE);
 		return CMD_WARNING;
@@ -507,6 +509,8 @@
 DEFUN(cfg_nse_fr_dlci, cfg_nse_fr_dlci_cmd,
 	"nse <0-65535> nsvci <0-65535> fr-dlci <16-1007>",
 	NSE_CMD_STR
+	"NS Virtual Connection\n"
+	"NS Virtual Connection ID (NSVCI)\n"
 	"Frame Relay DLCI\n"
 	"Frame Relay DLCI Number\n")
 {
@@ -515,7 +519,7 @@
 	uint16_t dlci = atoi(argv[2]);
 	struct ns2_vty_vc *vtyvc;
 
-	vtyvc = vtyvc_by_nsei(nsei, true);
+	vtyvc = vtyvc_by_nsei_nsvci(nsei, nsvci, true);
 	if (!vtyvc) {
 		vty_out(vty, "Can not allocate space %s", VTY_NEWLINE);
 		return CMD_WARNING;
@@ -527,27 +531,29 @@
 	}
 
 	vtyvc->frdlci = dlci;
-	vtyvc->nsvci = nsvci;
 
 	return CMD_SUCCESS;
 }
 
 DEFUN(cfg_nse_encaps, cfg_nse_encaps_cmd,
-	"nse <0-65535> encapsulation (udp|framerelay-gre)",
+	"nse <0-65535> nsvci <0-65535> encapsulation (udp|framerelay-gre)",
 	NSE_CMD_STR
+	"NS Virtual Connection\n"
+	"NS Virtual Connection ID (NSVCI)\n"
 	"Encapsulation for NS\n"
 	"UDP/IP Encapsulation\n" "Frame-Relay/GRE/IP Encapsulation\n")
 {
 	uint16_t nsei = atoi(argv[0]);
+	uint16_t nsvci = atoi(argv[1]);
 	struct ns2_vty_vc *vtyvc;
 
-	vtyvc = vtyvc_by_nsei(nsei, true);
+	vtyvc = vtyvc_by_nsei_nsvci(nsei, nsvci, true);
 	if (!vtyvc) {
 		vty_out(vty, "Can not allocate space %s", VTY_NEWLINE);
 		return CMD_WARNING;
 	}
 
-	if (!strcmp(argv[1], "udp"))
+	if (!strcmp(argv[2], "udp"))
 		vtyvc->ll = GPRS_NS_LL_UDP;
 	else
 		vtyvc->ll = GPRS_NS_LL_FR_GRE;
@@ -556,22 +562,25 @@
 }
 
 DEFUN(cfg_nse_remoterole, cfg_nse_remoterole_cmd,
-	"nse <0-65535> remote-role (sgsn|bss)",
+	"nse <0-65535> nsvci <0-65535> remote-role (sgsn|bss)",
 	NSE_CMD_STR
+	"NS Virtual Connection\n"
+	"NS Virtual Connection ID (NSVCI)\n"
 	"Remote NSE Role\n"
 	"Remote Peer is SGSN\n"
 	"Remote Peer is BSS\n")
 {
 	uint16_t nsei = atoi(argv[0]);
+	uint16_t nsvci = atoi(argv[1]);
 	struct ns2_vty_vc *vtyvc;
 
-	vtyvc = vtyvc_by_nsei(nsei, true);
+	vtyvc = vtyvc_by_nsei_nsvci(nsei, nsvci, true);
 	if (!vtyvc) {
 		vty_out(vty, "Can not allocate space %s", VTY_NEWLINE);
 		return CMD_WARNING;
 	}
 
-	if (!strcmp(argv[1], "sgsn"))
+	if (!strcmp(argv[2], "sgsn"))
 		vtyvc->remote_end_is_sgsn = 1;
 	else
 		vtyvc->remote_end_is_sgsn = 0;
@@ -580,14 +589,15 @@
 }
 
 DEFUN(cfg_no_nse, cfg_no_nse_cmd,
-	"no nse <0-65535>",
+	"no nse <0-65535> nsvci <0-65535>",
 	"Delete Persistent NS Entity\n"
 	"Delete " NSE_CMD_STR)
 {
 	uint16_t nsei = atoi(argv[0]);
+	uint16_t nsvci = atoi(argv[1]);
 	struct ns2_vty_vc *vtyvc;
 
-	vtyvc = vtyvc_by_nsei(nsei, false);
+	vtyvc = vtyvc_by_nsei_nsvci(nsei, nsvci, false);
 	if (!vtyvc) {
 		vty_out(vty, "The NSE %d does not exists.%s", nsei, VTY_NEWLINE);
 		return CMD_WARNING;

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

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: I4ad454320d0a03e81b399f55e8bd0ee57402dad0
Gerrit-Change-Number: 21245
Gerrit-PatchSet: 2
Gerrit-Owner: lynxis lazus <lynxis at fe80.eu>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge <laforge at osmocom.org>
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/20201125/4177785d/attachment.htm>


More information about the gerrit-log mailing list