jolly has uploaded this change for review. ( 
https://gerrit.osmocom.org/c/osmo-bsc/+/35571?usp=email )


Change subject: Add vty commands "no gprs nsvc ..."
......................................................................

Add vty commands "no gprs nsvc ..."

A switch (bool) is used to enable or disable NSVC 0 or 1. It is enabled
via any "gprs nsvc 0|1" command and disabled via "no gprs nsvc 0|1"
command. If it is disabled, it is treated as unconfigured, similar when
no remote IP or port has been defined.

Related: OS#6006
Change-Id: Ia112e86aa35f6a245d98ef1b3720c18835faeda6
---
M include/osmocom/bsc/bts_sm.h
M src/osmo-bsc/bts_vty.c
M src/osmo-bsc/nm_gprs_nsvc_fsm.c
3 files changed, 47 insertions(+), 0 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-bsc refs/changes/71/35571/1

diff --git a/include/osmocom/bsc/bts_sm.h b/include/osmocom/bsc/bts_sm.h
index e25b8da..13be3d9 100644
--- a/include/osmocom/bsc/bts_sm.h
+++ b/include/osmocom/bsc/bts_sm.h
@@ -40,6 +40,7 @@
        /* data read via VTY config file, to configure the BTS
         * via OML from BSC */
        int id;
+       bool enabled;
        uint16_t nsvci;
        uint16_t local_port;    /* on the BTS */
        struct osmo_sockaddr remote;
diff --git a/src/osmo-bsc/bts_vty.c b/src/osmo-bsc/bts_vty.c
index e38ec94..24224f6 100644
--- a/src/osmo-bsc/bts_vty.c
+++ b/src/osmo-bsc/bts_vty.c
@@ -1564,6 +1564,22 @@
 #define NSVC_TEXT "Network Service Virtual Connection (NS-VC)\n" \
                "NSVC Logical Number\n"

+DEFUN_USRATTR(cfg_no_bts_gprs_nsvc,
+             cfg_no_bts_gprs_nsvc_cmd,
+             X(BSC_VTY_ATTR_RESTART_ABIS_OML_LINK),
+             "no gprs nsvc <0-1>",
+             NO_STR GPRS_TEXT NSVC_TEXT)
+{
+       struct gsm_bts *bts = vty->index;
+       int idx = atoi(argv[0]);
+
+       GPRS_CHECK_ENABLED(bts);
+
+       bts->site_mgr->gprs.nsvc[idx].enabled = false;
+
+       return CMD_SUCCESS;
+}
+
 DEFUN_USRATTR(cfg_bts_gprs_nsvci,
              cfg_bts_gprs_nsvci_cmd,
              X(BSC_VTY_ATTR_RESTART_ABIS_OML_LINK),
@@ -1578,6 +1594,7 @@
        GPRS_CHECK_ENABLED(bts);

        bts->site_mgr->gprs.nsvc[idx].nsvci = atoi(argv[1]);
+       bts->site_mgr->gprs.nsvc[idx].enabled = true;

        return CMD_SUCCESS;
 }
@@ -1598,6 +1615,7 @@
        GPRS_CHECK_ENABLED(bts);

        bts->site_mgr->gprs.nsvc[idx].local_port = atoi(argv[1]);
+       bts->site_mgr->gprs.nsvc[idx].enabled = true;

        return CMD_SUCCESS;
 }
@@ -1619,6 +1637,7 @@

        /* sockaddr_in and sockaddr_in6 have the port at the same position */
        bts->site_mgr->gprs.nsvc[idx].remote.u.sin.sin_port = 
htons(atoi(argv[1]));
+       bts->site_mgr->gprs.nsvc[idx].enabled = true;

        return CMD_SUCCESS;
 }
@@ -1651,9 +1670,11 @@
        switch (remote.af) {
        case AF_INET:
                osmo_sockaddr_str_to_in_addr(&remote, 
&bts->site_mgr->gprs.nsvc[idx].remote.u.sin.sin_addr);
+               bts->site_mgr->gprs.nsvc[idx].enabled = true;
                break;
        case AF_INET6:
                osmo_sockaddr_str_to_in6_addr(&remote, 
&bts->site_mgr->gprs.nsvc[idx].remote.u.sin6.sin6_addr);
+               bts->site_mgr->gprs.nsvc[idx].enabled = true;
                break;
        }

@@ -4251,6 +4272,11 @@
                const struct gsm_gprs_nsvc *nsvc = &bts_sm->gprs.nsvc[i];
                struct osmo_sockaddr_str remote;

+               if (!nsvc->enabled) {
+                       vty_out(vty, "  no gprs nsvc %u%s", i, VTY_NEWLINE);
+                       continue;
+               }
+
                vty_out(vty, "  gprs nsvc %u nsvci %u%s", i,
                        nsvc->nsvci, VTY_NEWLINE);

@@ -4951,6 +4977,7 @@
        install_element(BTS_NODE, &cfg_bts_gprs_bvci_cmd);
        install_element(BTS_NODE, &cfg_bts_gprs_cell_timer_cmd);
        install_element(BTS_NODE, &cfg_bts_gprs_nsei_cmd);
+       install_element(BTS_NODE, &cfg_no_bts_gprs_nsvc_cmd);
        install_element(BTS_NODE, &cfg_bts_gprs_nsvci_cmd);
        install_element(BTS_NODE, &cfg_bts_gprs_nsvc_lport_cmd);
        install_element(BTS_NODE, &cfg_bts_gprs_nsvc_rport_cmd);
diff --git a/src/osmo-bsc/nm_gprs_nsvc_fsm.c b/src/osmo-bsc/nm_gprs_nsvc_fsm.c
index a3555aa..beedcdd 100644
--- a/src/osmo-bsc/nm_gprs_nsvc_fsm.c
+++ b/src/osmo-bsc/nm_gprs_nsvc_fsm.c
@@ -96,6 +96,10 @@

 static bool has_valid_nsvc(const struct gsm_gprs_nsvc *nsvc)
 {
+       /* If not configured (enabled) at all. */
+       if (!nsvc->enabled)
+               return false;
+
        /* remote address must be valid */
        if (osmo_sockaddr_is_any(&nsvc->remote))
                return false;

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

Gerrit-Project: osmo-bsc
Gerrit-Branch: master
Gerrit-Change-Id: Ia112e86aa35f6a245d98ef1b3720c18835faeda6
Gerrit-Change-Number: 35571
Gerrit-PatchSet: 1
Gerrit-Owner: jolly <andr...@eversberg.eu>
Gerrit-MessageType: newchange

Reply via email to