diff --git a/openbsc/include/openbsc/osmo_msc_data.h b/openbsc/include/openbsc/osmo_msc_data.h index 4a84f7422..b8db686f1 100644 --- a/openbsc/include/openbsc/osmo_msc_data.h +++ b/openbsc/include/openbsc/osmo_msc_data.h @@ -27,7 +27,17 @@ #include "bsc_msc.h" struct osmo_msc_data { + /* Connection data */ + char *bsc_token; + int msc_port; + int msc_ip_dscp; + char *msc_ip; + int ping_timeout; + int pong_timeout; struct bsc_msc_connection *msc_con; + + /* rf ctl related bits */ + char *ussd_grace_txt; }; #endif diff --git a/openbsc/include/openbsc/vty.h b/openbsc/include/openbsc/vty.h index 8c75c5812..d62778840 100644 --- a/openbsc/include/openbsc/vty.h +++ b/openbsc/include/openbsc/vty.h @@ -31,6 +31,7 @@ enum bsc_vty_node { OML_NODE, NAT_NODE, NAT_BSC_NODE, + MSC_NODE, }; extern int bsc_vty_is_config_node(struct vty *vty, int node); diff --git a/openbsc/src/bsc/osmo_bsc_vty.c b/openbsc/src/bsc/osmo_bsc_vty.c index 67bc64cd7..ac1be6e75 100644 --- a/openbsc/src/bsc/osmo_bsc_vty.c +++ b/openbsc/src/bsc/osmo_bsc_vty.c @@ -19,9 +19,148 @@ * */ -#include +#include +#include +#include + +#include + +extern struct gsm_network *bsc_gsmnet; + +static struct osmo_msc_data *osmo_msc_data(struct vty *vty) +{ + return bsc_gsmnet->msc_data; +} + +static struct cmd_node msc_node = { + MSC_NODE, + "%s(msc)#", + 1, +}; + +DEFUN(cfg_net_msc, cfg_net_msc_cmd, + "msc", "Configure MSC details") +{ + vty->index = bsc_gsmnet; + vty->node = MSC_NODE; + + return CMD_SUCCESS; +} + +static int config_write_msc(struct vty *vty) +{ + struct osmo_msc_data *data = osmo_msc_data(vty); + + vty_out(vty, " msc%s", VTY_NEWLINE); + if (data->bsc_token) + vty_out(vty, " token %s%s", data->bsc_token, VTY_NEWLINE); + vty_out(vty, " ip %s%s", data->msc_ip, VTY_NEWLINE); + vty_out(vty, " port %d%s", data->msc_port, VTY_NEWLINE); + vty_out(vty, " ip-dscp %d%s", data->msc_ip_dscp, VTY_NEWLINE); + vty_out(vty, " timeout-ping %d%s", data->ping_timeout, VTY_NEWLINE); + vty_out(vty, " timeout-pong %d%s", data->pong_timeout, VTY_NEWLINE); + if (data->ussd_grace_txt) + vty_out(vty, "bsc-grace-text %s%s", data->ussd_grace_txt, VTY_NEWLINE); + + return CMD_SUCCESS; +} + +DEFUN(cfg_net_msc_token, + cfg_net_bsc_token_cmd, + "token TOKEN", + "A token for the BSC to be sent to the MSC") +{ + struct osmo_msc_data *data = osmo_msc_data(vty); + + if (data->bsc_token) + talloc_free(data->bsc_token); + data->bsc_token = talloc_strdup(data, argv[0]); + + return CMD_SUCCESS; +} + +DEFUN(cfg_net_msc_ip, + cfg_net_msc_ip_cmd, + "ip A.B.C.D", "Set the MSC/MUX IP address.") +{ + struct osmo_msc_data *data = osmo_msc_data(vty); + if (data->msc_ip) + talloc_free(data->msc_ip); + data->msc_ip = talloc_strdup(data, argv[0]); + + return CMD_SUCCESS; +} + +DEFUN(cfg_net_msc_port, + cfg_net_msc_port_cmd, + "port <1-65000>", + "Set the MSC/MUX port.") +{ + struct osmo_msc_data *data = osmo_msc_data(vty); + data->msc_port = atoi(argv[0]); + return CMD_SUCCESS; +} + + +DEFUN(cfg_net_msc_prio, + cfg_net_msc_prio_cmd, + "ip-dscp <0-255>", + "Set the IP_TOS socket attribite") +{ + struct osmo_msc_data *data = osmo_msc_data(vty); + data->msc_ip_dscp = atoi(argv[0]); + return CMD_SUCCESS; +} + +DEFUN(cfg_net_msc_ping_time, + cfg_net_msc_ping_time_cmd, + "timeout-ping NR", + "Set the PING interval, negative for not sending PING") +{ + struct osmo_msc_data *data = osmo_msc_data(vty); + data->ping_timeout = atoi(argv[0]); + return CMD_SUCCESS; +} + +DEFUN(cfg_net_msc_pong_time, + cfg_net_msc_pong_time_cmd, + "timeout-pong NR", + "Set the time to wait for a PONG.") +{ + struct osmo_msc_data *data = osmo_msc_data(vty); + data->pong_timeout = atoi(argv[0]); + return CMD_SUCCESS; +} + +DEFUN(cfg_net_msc_grace_ussd, + cfg_net_msc_grace_ussd_cmd, + "bsc-grace-text .TEXT", + "Set the USSD notifcation to be send.\n" "Text to be sent\n") +{ + struct osmo_msc_data *data = osmo_msc_data(vty); + char *txt = argv_concat(argv, argc, 1); + if (!txt) + return CMD_WARNING; + + if (data->ussd_grace_txt) + talloc_free(data->ussd_grace_txt); + data->ussd_grace_txt = talloc_strdup(data, txt); + talloc_free(txt); + return CMD_SUCCESS; +} int bsc_vty_init_extra(void) { + install_element(GSMNET_NODE, &cfg_net_msc_cmd); + install_node(&msc_node, config_write_msc); + install_default(MSC_NODE); + install_element(MSC_NODE, &cfg_net_bsc_token_cmd); + install_element(MSC_NODE, &cfg_net_msc_ip_cmd); + install_element(MSC_NODE, &cfg_net_msc_port_cmd); + install_element(MSC_NODE, &cfg_net_msc_prio_cmd); + install_element(MSC_NODE, &cfg_net_msc_ping_time_cmd); + install_element(MSC_NODE, &cfg_net_msc_pong_time_cmd); + install_element(MSC_NODE, &cfg_net_msc_grace_ussd_cmd); + return 0; } diff --git a/openbsc/src/common_vty.c b/openbsc/src/common_vty.c index b2a394fc3..72d5163d8 100644 --- a/openbsc/src/common_vty.c +++ b/openbsc/src/common_vty.c @@ -83,6 +83,9 @@ enum node_type bsc_vty_go_parent(struct vty *vty) vty->index = bsc_config->nat; } break; + case MSC_NODE: + vty->node = GSMNET_NODE; + break; default: vty->node = CONFIG_NODE; } @@ -147,6 +150,9 @@ gDEFUN(ournode_exit, talloc_free(vty->index); vty->index = NULL; break; + case MSC_NODE: + vty->node = GSMNET_NODE; + break; default: break; } @@ -174,6 +180,7 @@ gDEFUN(ournode_end, case VTY_NODE: case NAT_NODE: case NAT_BSC_NODE: + case MSC_NODE: vty_config_unlock(vty); vty->node = ENABLE_NODE; vty->index = NULL;