aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Makefile.am3
-rw-r--r--contrib/screenrc-sysmobts2
-rw-r--r--contrib/sysmobts-mgr.service2
-rw-r--r--doc/examples/sysmobts-mgr.cfg24
-rw-r--r--src/osmo-bts-sysmo/Makefile.am5
-rw-r--r--src/osmo-bts-sysmo/misc/sysmobts_mgr.c21
-rw-r--r--src/osmo-bts-sysmo/misc/sysmobts_mgr.h13
-rw-r--r--src/osmo-bts-sysmo/misc/sysmobts_mgr_vty.c133
8 files changed, 197 insertions, 6 deletions
diff --git a/Makefile.am b/Makefile.am
index 733e80f6..afb4d273 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -11,4 +11,5 @@ EXTRA_DIST = \
contrib/sysmobts-calib/sysmobts-calib.c \
contrib/sysmobts-calib/sysmobts-layer1.c \
contrib/sysmobts-calib/sysmobts-layer1.h \
- doc/examples/osmo-bts.cfg
+ doc/examples/osmo-bts.cfg \
+ doc/examples/sysmobts-mgr.cfg
diff --git a/contrib/screenrc-sysmobts b/contrib/screenrc-sysmobts
index 1bd510ce..80e78cc5 100644
--- a/contrib/screenrc-sysmobts
+++ b/contrib/screenrc-sysmobts
@@ -1,5 +1,5 @@
chdir /tmp
screen -t BTS 0 /etc/osmocom/respawn.sh /usr/bin/sysmobts -c /etc/osmocom/osmo-bts.cfg -r 1 -M
screen -t PCU 1 /etc/osmocom/respawn-only.sh /usr/bin/osmo-pcu -c /etc/osmocom/osmo-pcu.cfg -e
-screen -t MGR 2 /etc/osmocom/respawn-only.sh /usr/bin/sysmobts-mgr -n
+screen -t MGR 2 /etc/osmocom/respawn-only.sh /usr/bin/sysmobts-mgr -n -c /etc/osmocom/sysmobts-mgr.cfg
detach
diff --git a/contrib/sysmobts-mgr.service b/contrib/sysmobts-mgr.service
index 20adba0b..4a15bd8d 100644
--- a/contrib/sysmobts-mgr.service
+++ b/contrib/sysmobts-mgr.service
@@ -3,7 +3,7 @@ Description=sysmocom sysmoBTS manager
[Service]
Type=simple
-ExecStart=/usr/bin/sysmobts-mgr -ns
+ExecStart=/usr/bin/sysmobts-mgr -ns -c /etc/osmocom/sysmobts-mgr.cfg
Restart=always
RestartSec=2
diff --git a/doc/examples/sysmobts-mgr.cfg b/doc/examples/sysmobts-mgr.cfg
new file mode 100644
index 00000000..3b28d785
--- /dev/null
+++ b/doc/examples/sysmobts-mgr.cfg
@@ -0,0 +1,24 @@
+!
+! SysmoMgr (0.3.0.141-33e5) configuration saved from vty
+!!
+!
+log stderr
+ logging filter all 1
+ logging color 1
+ logging timestamp 0
+ logging level all everything
+ logging level temp info
+ logging level fw info
+ logging level find info
+ logging level lglobal notice
+ logging level llapd notice
+ logging level linp notice
+ logging level lmux notice
+ logging level lmi notice
+ logging level lmib notice
+ logging level lsms notice
+!
+line vty
+ no login
+!
+sysmobts-mgr
diff --git a/src/osmo-bts-sysmo/Makefile.am b/src/osmo-bts-sysmo/Makefile.am
index a213759e..0071e136 100644
--- a/src/osmo-bts-sysmo/Makefile.am
+++ b/src/osmo-bts-sysmo/Makefile.am
@@ -22,8 +22,9 @@ l1fwd_proxy_LDADD = $(top_builddir)/src/common/libbts.a $(COMMON_LDADD)
sysmobts_mgr_SOURCES = \
misc/sysmobts_mgr.c misc/sysmobts_misc.c \
- misc/sysmobts_par.c misc/sysmobts_nl.c
-sysmobts_mgr_LDADD = $(LIBOSMOCORE_LIBS)
+ misc/sysmobts_par.c misc/sysmobts_nl.c \
+ misc/sysmobts_mgr_vty.c
+sysmobts_mgr_LDADD = $(LIBOSMOCORE_LIBS) $(LIBOSMOVTY_LIBS)
sysmobts_util_SOURCES = misc/sysmobts_util.c misc/sysmobts_par.c
sysmobts_util_LDADD = $(LIBOSMOCORE_LIBS)
diff --git a/src/osmo-bts-sysmo/misc/sysmobts_mgr.c b/src/osmo-bts-sysmo/misc/sysmobts_mgr.c
index 41ee8143..ba3aa2ef 100644
--- a/src/osmo-bts-sysmo/misc/sysmobts_mgr.c
+++ b/src/osmo-bts-sysmo/misc/sysmobts_mgr.c
@@ -47,6 +47,7 @@
static int no_eeprom_write = 0;
static int daemonize = 0;
+static const char *cfgfile = "sysmobts-mgr.cfg";
void *tall_mgr_ctx;
/* every 6 hours means 365*4 = 1460 EEprom writes per year (max) */
@@ -130,13 +131,14 @@ static void print_help(void)
printf(" -s Disable color\n");
printf(" -d CAT enable debugging\n");
printf(" -D daemonize\n");
+ printf(" -c Specify the filename of the config file\n");
}
static int parse_options(int argc, char **argv)
{
int opt;
- while ((opt = getopt(argc, argv, "nhsd:")) != -1) {
+ while ((opt = getopt(argc, argv, "nhsd:c:")) != -1) {
switch (opt) {
case 'n':
no_eeprom_write = 1;
@@ -153,6 +155,9 @@ static int parse_options(int argc, char **argv)
case 'D':
daemonize = 1;
break;
+ case 'c':
+ cfgfile = optarg;
+ break;
default:
return -1;
}
@@ -386,6 +391,20 @@ int main(int argc, char **argv)
if (rc < 0)
exit(2);
+ sysmobts_mgr_vty_init();
+ logging_vty_add_cmds(&mgr_log_info);
+ rc = sysmobts_mgr_parse_config(cfgfile);
+ if (rc < 0) {
+ LOGP(DFIND, LOGL_FATAL, "Cannot parse config file\n");
+ exit(1);
+ }
+
+ rc = telnet_init(tall_msgb_ctx, NULL, 4252);
+ if (rc < 0) {
+ fprintf(stderr, "Error initializing telnet\n");
+ exit(1);
+ }
+
/* start temperature check timer */
temp_timer.cb = check_temp_timer_cb;
check_temp_timer_cb(NULL);
diff --git a/src/osmo-bts-sysmo/misc/sysmobts_mgr.h b/src/osmo-bts-sysmo/misc/sysmobts_mgr.h
index ddb6774a..aaa43736 100644
--- a/src/osmo-bts-sysmo/misc/sysmobts_mgr.h
+++ b/src/osmo-bts-sysmo/misc/sysmobts_mgr.h
@@ -1,10 +1,23 @@
#ifndef _SYSMOBTS_MGR_H
#define _SYSMOBTS_MGR_H
+#include <osmocom/vty/vty.h>
+#include <osmocom/vty/command.h>
+
enum {
DTEMP,
DFW,
DFIND,
};
+enum mgr_vty_node {
+ MGR_NODE = _LAST_OSMOVTY_NODE + 1,
+};
+
+int sysmobts_mgr_vty_init(void);
+int sysmobts_mgr_parse_config(const char *config_file);
+
+struct sysmobts_mgr_instance {
+ const char *config_file;
+};
#endif
diff --git a/src/osmo-bts-sysmo/misc/sysmobts_mgr_vty.c b/src/osmo-bts-sysmo/misc/sysmobts_mgr_vty.c
new file mode 100644
index 00000000..50d8e152
--- /dev/null
+++ b/src/osmo-bts-sysmo/misc/sysmobts_mgr_vty.c
@@ -0,0 +1,133 @@
+/* (C) 2014 by sysmocom - s.f.m.c. GmbH
+ *
+ * All Rights Reserved
+ *
+ * Author: Alvaro Neira Ayuso <anayuso@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 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 <stdlib.h>
+#include <unistd.h>
+#include <errno.h>
+#include <stdint.h>
+#include <ctype.h>
+#include <string.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <arpa/inet.h>
+
+#include <osmocom/vty/vty.h>
+#include <osmocom/vty/command.h>
+#include <osmocom/vty/misc.h>
+
+#include <osmo-bts/logging.h>
+
+#include "sysmobts_misc.h"
+#include "sysmobts_mgr.h"
+#include "btsconfig.h"
+
+static const char copyright[] =
+ "(C) 2012 by Harald Welte <laforge@gnumonks.org>\r\n"
+ "(C) 2014 by Holger Hans Peter Freyther\r\n"
+ "License AGPLv3+: GNU AGPL version 2 or later <http://gnu.org/licenses/agpl-3.0.html>\r\n"
+ "This is free software: you are free to change and redistribute it.\r\n"
+ "There is NO WARRANTY, to the extent permitted by law.\r\n";
+
+static enum node_type go_to_parent(struct vty *vty)
+{
+ switch (vty->node) {
+ case MGR_NODE:
+ vty->node = CONFIG_NODE;
+ break;
+ default:
+ vty->node = CONFIG_NODE;
+ }
+ return vty->node;
+}
+
+static int is_config_node(struct vty *vty, int node)
+{
+ switch (node) {
+ case MGR_NODE:
+ return 1;
+ default:
+ return 0;
+ }
+}
+
+static struct vty_app_info vty_info = {
+ .name = "sysmobts-mgr",
+ .version = PACKAGE_VERSION,
+ .go_parent_cb = go_to_parent,
+ .is_config_node = is_config_node,
+ .copyright = copyright,
+};
+
+
+#define MGR_STR "Configure sysmobts-mgr\n"
+
+static struct cmd_node mgr_node = {
+ MGR_NODE,
+ "%s(sysmobts-mgr)# ",
+ 1,
+};
+
+DEFUN(cfg_mgr, cfg_mgr_cmd,
+ "sysmobts-mgr",
+ MGR_STR)
+{
+ vty->node = MGR_NODE;
+ return CMD_SUCCESS;
+}
+
+DEFUN(show_mgr, show_mgr_cmd, "show manager",
+ SHOW_STR "Display information about the manager")
+{
+ return CMD_SUCCESS;
+}
+
+static int config_write_mgr(struct vty *vty)
+{
+ vty_out(vty, "sysmobts-mgr%s", VTY_NEWLINE);
+ return CMD_SUCCESS;
+}
+
+int sysmobts_mgr_vty_init(void)
+{
+ vty_init(&vty_info);
+
+ install_element_ve(&show_mgr_cmd);
+
+ install_node(&mgr_node, config_write_mgr);
+ install_element(CONFIG_NODE, &cfg_mgr_cmd);
+ vty_install_default(MGR_NODE);
+
+ return 0;
+}
+
+int sysmobts_mgr_parse_config(const char *config_file)
+{
+ int rc;
+
+ rc = vty_read_config_file(config_file, NULL);
+ if (rc < 0) {
+ fprintf(stderr, "Failed to parse the config file: '%s'\n",
+ config_file);
+ return rc;
+ }
+
+ return 0;
+}