2017-01-30 22:30:26 +00:00
|
|
|
/* OsmoHLR VTY implementation */
|
|
|
|
|
|
|
|
/* (C) 2016 sysmocom s.f.m.c. GmbH <info@sysmocom.de>
|
|
|
|
* 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/>.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2017-05-31 11:19:22 +00:00
|
|
|
#include <osmocom/core/talloc.h>
|
2017-01-30 22:30:26 +00:00
|
|
|
#include <osmocom/vty/vty.h>
|
|
|
|
#include <osmocom/vty/command.h>
|
|
|
|
#include <osmocom/vty/logging.h>
|
2018-02-13 23:52:05 +00:00
|
|
|
#include <osmocom/vty/misc.h>
|
2017-01-30 22:30:26 +00:00
|
|
|
|
|
|
|
#include "hlr_vty.h"
|
2017-10-06 00:59:54 +00:00
|
|
|
#include "hlr_vty_subscr.h"
|
2017-01-30 22:30:26 +00:00
|
|
|
|
2017-05-31 11:19:22 +00:00
|
|
|
static struct hlr *g_hlr = NULL;
|
|
|
|
|
|
|
|
struct cmd_node hlr_node = {
|
|
|
|
HLR_NODE,
|
|
|
|
"%s(config-hlr)# ",
|
|
|
|
1,
|
|
|
|
};
|
|
|
|
|
|
|
|
DEFUN(cfg_hlr,
|
|
|
|
cfg_hlr_cmd,
|
|
|
|
"hlr",
|
|
|
|
"Configure the HLR")
|
|
|
|
{
|
|
|
|
vty->node = HLR_NODE;
|
|
|
|
return CMD_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
struct cmd_node gsup_node = {
|
|
|
|
GSUP_NODE,
|
|
|
|
"%s(config-hlr-gsup)# ",
|
|
|
|
1,
|
|
|
|
};
|
|
|
|
|
|
|
|
DEFUN(cfg_gsup,
|
|
|
|
cfg_gsup_cmd,
|
|
|
|
"gsup",
|
|
|
|
"Configure GSUP options")
|
|
|
|
{
|
|
|
|
vty->node = GSUP_NODE;
|
|
|
|
return CMD_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int config_write_hlr(struct vty *vty)
|
|
|
|
{
|
|
|
|
vty_out(vty, "hlr%s", VTY_NEWLINE);
|
|
|
|
return CMD_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int config_write_hlr_gsup(struct vty *vty)
|
|
|
|
{
|
|
|
|
vty_out(vty, " gsup%s", VTY_NEWLINE);
|
|
|
|
if (g_hlr->gsup_bind_addr)
|
|
|
|
vty_out(vty, " bind ip %s%s", g_hlr->gsup_bind_addr, VTY_NEWLINE);
|
|
|
|
return CMD_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
DEFUN(cfg_hlr_gsup_bind_ip,
|
|
|
|
cfg_hlr_gsup_bind_ip_cmd,
|
|
|
|
"bind ip A.B.C.D",
|
|
|
|
"Listen/Bind related socket option\n"
|
|
|
|
IP_STR
|
|
|
|
"IPv4 Address to bind the GSUP interface to\n")
|
|
|
|
{
|
|
|
|
if(g_hlr->gsup_bind_addr)
|
|
|
|
talloc_free(g_hlr->gsup_bind_addr);
|
|
|
|
g_hlr->gsup_bind_addr = talloc_strdup(g_hlr, argv[0]);
|
|
|
|
|
|
|
|
return CMD_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
int hlr_vty_go_parent(struct vty *vty)
|
|
|
|
{
|
|
|
|
switch (vty->node) {
|
|
|
|
case GSUP_NODE:
|
|
|
|
vty->node = HLR_NODE;
|
|
|
|
vty->index = NULL;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
case HLR_NODE:
|
|
|
|
vty->node = CONFIG_NODE;
|
|
|
|
vty->index = NULL;
|
|
|
|
break;
|
|
|
|
case CONFIG_NODE:
|
|
|
|
vty->node = ENABLE_NODE;
|
|
|
|
vty->index = NULL;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return vty->node;
|
|
|
|
}
|
|
|
|
|
2017-01-30 22:30:26 +00:00
|
|
|
int hlr_vty_is_config_node(struct vty *vty, int node)
|
|
|
|
{
|
|
|
|
switch (node) {
|
|
|
|
/* add items that are not config */
|
|
|
|
case CONFIG_NODE:
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
default:
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-05-31 11:19:22 +00:00
|
|
|
void hlr_vty_init(struct hlr *hlr, const struct log_info *cat)
|
2017-01-30 22:30:26 +00:00
|
|
|
{
|
2017-05-31 11:19:22 +00:00
|
|
|
g_hlr = hlr;
|
|
|
|
|
2017-01-30 22:30:26 +00:00
|
|
|
logging_vty_add_cmds(cat);
|
2018-02-13 23:52:05 +00:00
|
|
|
osmo_talloc_vty_add_cmds();
|
2017-05-31 11:19:22 +00:00
|
|
|
|
|
|
|
install_element(CONFIG_NODE, &cfg_hlr_cmd);
|
|
|
|
install_node(&hlr_node, config_write_hlr);
|
|
|
|
|
|
|
|
install_element(HLR_NODE, &cfg_gsup_cmd);
|
|
|
|
install_node(&gsup_node, config_write_hlr_gsup);
|
|
|
|
|
|
|
|
install_element(GSUP_NODE, &cfg_hlr_gsup_bind_ip_cmd);
|
2017-10-06 00:59:54 +00:00
|
|
|
|
|
|
|
hlr_vty_subscriber_init(hlr);
|
2017-01-30 22:30:26 +00:00
|
|
|
}
|