aboutsummaryrefslogtreecommitdiffstats
path: root/src/libbsc/handover_vty.c
diff options
context:
space:
mode:
authorNeels Hofmeyr <neels@hofmeyr.de>2017-11-27 21:29:33 +0100
committerNeels Hofmeyr <neels@hofmeyr.de>2018-01-19 16:03:16 +0100
commite25018b8c1b24f049ec38c6085a8c4ba2d983185 (patch)
treec78780f7f1feab6ed917c056592b9ebcc9a32ce8 /src/libbsc/handover_vty.c
parentbe1131df42b3e0a7b4113ecc0c159977ecc8fae7 (diff)
HO prep: introduce per-BTS handover config, with defaults on net node
It is desirable to allow configuring handover for each individual network cell. At the same time, it is desirable to set global defaults. Treat the 'network' node handover parameters as global defaults, add another set of parameters for each individual BTS. This raises questions on how the 'network' node should affect the individual BTS. The simplistic solution would have been: on creating a BTS in the config, just copy the current defaults; with serious drawbacks: - tweaking any parameter in the telnet VTY on network node will never affect any running BTS. - network node defaults *must* be issued before the bts sections in the config file. - when writing a config back to file, we would copy all net node defaults to each BTS node, making the network node configs pointless. Instead, add a handover_cfg API that tracks whether a given node has a value set or not. A bts node ho_cfg gets a pointer to the network node config and returns those values if locally unset. If no value is set on any node, use the "factory" defaults, which are hardcoded in the API. Only write back exactly those config items that were actually issued in a config file / on the telnet VTY. (ho_cfg API wise, we could trivially add another ho_cfg level per TRX if we so desire in the future.) Implement ho parameters as an opaque config struct with getters and setters to ensure the tracking is always heeded. Opaqueness dictates allocating instead of direct embedding in gsm_network and gsm_bts structs, ctx is gsm_net / bts. This is 100% backwards compatible to old configs. - No VTY command syntax changes (only the online help). - If a 'bts' sets nothing, it will use the 'network' defaults. - The 'show network' output only changes in presence of individual BTS configs. On 'show network', say "Handover: On|Off" as before, iff all BTS reflect identical behavior. Otherwise, output BTS counts of handover being enabled or not. Use the same set of VTY commands (same VTY cmd syntax as before) on network and BTS nodes, i.e. don't duplicate VTY code. From the current vty->node, figure out which ho_cfg to modify. For linking, add handover_cfg.c (the value API) in libcommon, while the handover_vty.c is in libbsc. This is mainly because some utility programs use gsm_network and hence suck in the ho stuff, but don't need the VTY commands. Review the VTY online help strings. Add VTY transcript test for handover options, testing config propagation from network to bts nodes, 'show network' output and VTY online help strings. (Needs recent addition of '... !' wildcard to osmo_interact_common.py.) I considered leaving parts of this more readable, but in the end decided for heavy use of macros to define and declare the API, because more values will be added in upcoming patches and I want to prevent myself from messing them up. Inspired-by: jolly/new_handover branch, which moves the config to 'bts' level Depends: I7c1ebb2e7f059047903a53de26a0ec1ce7fa9b98 (osmo-python-tests) Change-Id: I79d35f6d3c0fbee67904378ad7f216df34fde79a
Diffstat (limited to 'src/libbsc/handover_vty.c')
-rw-r--r--src/libbsc/handover_vty.c101
1 files changed, 101 insertions, 0 deletions
diff --git a/src/libbsc/handover_vty.c b/src/libbsc/handover_vty.c
new file mode 100644
index 000000000..225e9a909
--- /dev/null
+++ b/src/libbsc/handover_vty.c
@@ -0,0 +1,101 @@
+/* OsmoBSC interface to quagga VTY for handover parameters */
+/* (C) 2017 by sysmocom - s.f.m.c. GmbH <info@sysmocom.de>
+ * (C) 2009-2010 by Harald Welte <laforge@gnumonks.org>
+ * All Rights Reserved
+ *
+ * Author: Neels Hofmeyr <nhofmeyr@sysmocom.de>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include <osmocom/bsc/gsm_data.h>
+#include <osmocom/bsc/vty.h>
+#include <osmocom/bsc/handover_cfg.h>
+
+static struct handover_cfg *ho_cfg_from_vty(struct vty *vty)
+{
+ switch (vty->node) {
+ case GSMNET_NODE:
+ return gsmnet_from_vty(vty)->ho;
+ case BTS_NODE:
+ OSMO_ASSERT(vty->index);
+ return ((struct gsm_bts *)vty->index)->ho;
+ default:
+ OSMO_ASSERT(false);
+ }
+}
+
+
+#define HO_CFG_ONE_MEMBER(TYPE, NAME, DEFAULT_VAL, \
+ VTY_CMD, VTY_CMD_ARG, VTY_ARG_EVAL, \
+ VTY_WRITE_FMT, VTY_WRITE_CONV, \
+ VTY_DOC) \
+DEFUN(cfg_ho_##NAME, cfg_ho_##NAME##_cmd, \
+ VTY_CMD " (" VTY_CMD_ARG "|default)", \
+ VTY_DOC \
+ "Use default (" #DEFAULT_VAL "), remove explicit setting on this node\n") \
+{ \
+ struct handover_cfg *ho = ho_cfg_from_vty(vty); \
+ const char *val = argv[0]; \
+ if (!strcmp(val, "default")) { \
+ const char *msg; \
+ if (ho_isset_##NAME(ho)) {\
+ ho_clear_##NAME(ho); \
+ msg = "setting removed, now is"; \
+ } else \
+ msg = "already was unset, still is"; \
+ vty_out(vty, "%% '" VTY_CMD "' %s " VTY_WRITE_FMT "%s%s", \
+ msg, VTY_WRITE_CONV( ho_get_##NAME(ho) ), \
+ ho_isset_on_parent_##NAME(ho)? " (set on higher level node)" : "", \
+ VTY_NEWLINE); \
+ } \
+ else \
+ ho_set_##NAME(ho, VTY_ARG_EVAL(val)); \
+ return CMD_SUCCESS; \
+}
+
+HO_CFG_ALL_MEMBERS
+#undef HO_CFG_ONE_MEMBER
+
+
+void ho_vty_write(struct vty *vty, const char *indent, struct handover_cfg *ho)
+{
+#define HO_CFG_ONE_MEMBER(TYPE, NAME, DEFAULT_VAL, \
+ VTY_CMD, VTY_CMD_ARG, VTY_ARG_EVAL, \
+ VTY_WRITE_FMT, VTY_WRITE_CONV, \
+ VTY_DOC) \
+ if (ho_isset_##NAME(ho)) \
+ vty_out(vty, "%s" VTY_CMD " " VTY_WRITE_FMT "%s", indent, \
+ VTY_WRITE_CONV( ho_get_##NAME(ho) ), VTY_NEWLINE);
+
+ HO_CFG_ALL_MEMBERS
+#undef HO_CFG_ONE_MEMBER
+}
+
+static void ho_vty_init_cmds(int parent_node)
+{
+#define HO_CFG_ONE_MEMBER(TYPE, NAME, DEFAULT_VAL, VTY1, VTY2, VTY3, VTY4, VTY5, VTY6) \
+ install_element(parent_node, &cfg_ho_##NAME##_cmd);
+
+ HO_CFG_ALL_MEMBERS
+#undef HO_CFG_ONE_MEMBER
+}
+
+void ho_vty_init()
+{
+ ho_vty_init_cmds(GSMNET_NODE);
+ ho_vty_init_cmds(BTS_NODE);
+}
+