diff options
author | Neels Hofmeyr <nhofmeyr@sysmocom.de> | 2016-05-30 14:58:46 +0200 |
---|---|---|
committer | Neels Hofmeyr <nhofmeyr@sysmocom.de> | 2016-11-12 15:50:37 +0100 |
commit | 2ee77ab28a462aa4fc09897c1800c0b2938e2e4b (patch) | |
tree | c5fa973f0f5f719981d33c0152b72dadbdff3a76 | |
parent | 829c060b74f848d06e814c61b789c058f374026d (diff) |
add cscn vty, remove nitb vty
Change-Id: I8f8980d6cfbf26f1b0e0197939833e55dbe521fb
-rw-r--r-- | openbsc/include/openbsc/vty.h | 3 | ||||
-rw-r--r-- | openbsc/src/libcommon/common_vty.c | 1 | ||||
-rw-r--r-- | openbsc/src/libmsc/Makefile.am | 1 | ||||
-rw-r--r-- | openbsc/src/libmsc/cscn_vty.c | 174 | ||||
-rw-r--r-- | openbsc/src/libmsc/vty_interface_layer3.c | 104 |
5 files changed, 179 insertions, 104 deletions
diff --git a/openbsc/include/openbsc/vty.h b/openbsc/include/openbsc/vty.h index 315db0d11..cb543f23e 100644 --- a/openbsc/include/openbsc/vty.h +++ b/openbsc/include/openbsc/vty.h @@ -37,6 +37,7 @@ enum bsc_vty_node { SMPP_NODE, SMPP_ESME_NODE, GTPHUB_NODE, + CSCN_NODE, }; extern int bsc_vty_is_config_node(struct vty *vty, int node); @@ -46,6 +47,8 @@ struct log_info; int bsc_vty_init(const struct log_info *cat, struct gsm_network *network); int bsc_vty_init_extra(void); +void cscn_vty_init(struct gsm_network *cscn_network); + struct gsm_network *gsmnet_from_vty(struct vty *vty); #endif diff --git a/openbsc/src/libcommon/common_vty.c b/openbsc/src/libcommon/common_vty.c index a0674f0f1..ce2a815d8 100644 --- a/openbsc/src/libcommon/common_vty.c +++ b/openbsc/src/libcommon/common_vty.c @@ -107,6 +107,7 @@ int bsc_vty_go_parent(struct vty *vty) case MSC_NODE: case MNCC_INT_NODE: case NITB_NODE: + case CSCN_NODE: default: if (bsc_vty_is_config_node(vty, vty->node)) vty->node = CONFIG_NODE; diff --git a/openbsc/src/libmsc/Makefile.am b/openbsc/src/libmsc/Makefile.am index d9f7dc271..e8bcd9871 100644 --- a/openbsc/src/libmsc/Makefile.am +++ b/openbsc/src/libmsc/Makefile.am @@ -25,6 +25,7 @@ noinst_LIBRARIES = \ libmsc_a_SOURCES = \ a_iface.c \ auth.c \ + cscn_vty.c \ db.c \ gsm_04_08.c \ gsm_04_11.c \ diff --git a/openbsc/src/libmsc/cscn_vty.c b/openbsc/src/libmsc/cscn_vty.c new file mode 100644 index 000000000..adba37daa --- /dev/null +++ b/openbsc/src/libmsc/cscn_vty.c @@ -0,0 +1,174 @@ +/* MSC interface to quagga VTY */ +/* (C) 2016 by sysmocom s.m.f.c. GmbH <info@sysmocom.de> + * Based on OpenBSC interface to quagga VTY (libmsc/vty_interface_layer3.c) + * (C) 2009 by Harald Welte <laforge@gnumonks.org> + * (C) 2009-2011 by Holger Hans Peter Freyther + * All Rights Reserved + * + * 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/>. + * + */ + +/* NOTE: I would have liked to call this the MSC_NODE instead of the CSCN_NODE, + * but MSC_NODE already exists to configure a remote MSC for osmo-bsc. */ + +#include <inttypes.h> + +#include <osmocom/vty/command.h> +#include <openbsc/vty.h> + +#include <openbsc/gsm_data.h> +#include <openbsc/gsm_subscriber.h> + +static struct cmd_node cscn_node = { + CSCN_NODE, + "%s(config-cscn)# ", + 1, +}; + +DEFUN(cfg_cscn, cfg_cscn_cmd, + "cscn", "Configure CSCN options") +{ + vty->node = CSCN_NODE; + return CMD_SUCCESS; +} + +/* Note: limit on the parameter length is set by internal vty code limitations */ +DEFUN(cfg_cscn_subscr_random, cfg_cscn_subscr_random_cmd, + "subscriber-create-on-demand random <1-9999999999> <2-9999999999>", + "Set random parameters for a new record when a subscriber is first seen.\n" + "Set random parameters for a new record when a subscriber is first seen.\n" + "Minimum for subscriber extension\n""Maximum for subscriber extension\n") +{ + struct gsm_network *gsmnet = gsmnet_from_vty(vty); + uint64_t mi = atoi(argv[0]), ma = atoi(argv[1]); + gsmnet->auto_create_subscr = true; + gsmnet->auto_assign_exten = true; + if (mi >= ma) { + vty_out(vty, "Incorrect range: %s >= %s, expected MIN < MAX%s", + argv[0], argv[1], VTY_NEWLINE); + return CMD_WARNING; + } + gsmnet->ext_min = mi; + gsmnet->ext_max = ma; + return CMD_SUCCESS; +} + +DEFUN(cfg_cscn_subscr_create, cfg_cscn_subscr_create_cmd, + "subscriber-create-on-demand [no-extension]", + "Make a new record when a subscriber is first seen.\n" + "Do not automatically assign extension to created subscribers\n") +{ + struct gsm_network *gsmnet = gsmnet_from_vty(vty); + gsmnet->auto_create_subscr = true; + gsmnet->auto_assign_exten = argc ? false : true; + return CMD_SUCCESS; +} + +DEFUN(cfg_cscn_no_subscr_create, cfg_cscn_no_subscr_create_cmd, + "no subscriber-create-on-demand", + NO_STR "Make a new record when a subscriber is first seen.\n") +{ + struct gsm_network *gsmnet = gsmnet_from_vty(vty); + gsmnet->auto_create_subscr = false; + return CMD_SUCCESS; +} + +DEFUN(cfg_cscn_assign_tmsi, cfg_cscn_assign_tmsi_cmd, + "assign-tmsi", + "Assign TMSI during Location Updating.\n") +{ + struct gsm_network *gsmnet = gsmnet_from_vty(vty); + gsmnet->avoid_tmsi = 0; + return CMD_SUCCESS; +} + +DEFUN(cfg_cscn_no_assign_tmsi, cfg_cscn_no_assign_tmsi_cmd, + "no assign-tmsi", + NO_STR "Assign TMSI during Location Updating.\n") +{ + struct gsm_network *gsmnet = gsmnet_from_vty(vty); + gsmnet->avoid_tmsi = 1; + return CMD_SUCCESS; +} + +static int config_write_cscn(struct vty *vty) +{ + struct gsm_network *gsmnet = gsmnet_from_vty(vty); + + vty_out(vty, "cscn%s", VTY_NEWLINE); + if (!gsmnet->auto_create_subscr) + vty_out(vty, " no subscriber-create-on-demand%s", VTY_NEWLINE); + else + vty_out(vty, " subscriber-create-on-demand%s%s", + gsmnet->auto_assign_exten ? "" : " no-extension", + VTY_NEWLINE); + + if (gsmnet->ext_min != GSM_MIN_EXTEN || gsmnet->ext_max != GSM_MAX_EXTEN) + vty_out(vty, " subscriber-create-on-demand random %"PRIu64" %" + PRIu64"%s", gsmnet->ext_min, gsmnet->ext_max, + VTY_NEWLINE); + vty_out(vty, " %sassign-tmsi%s", + gsmnet->avoid_tmsi ? "no " : "", VTY_NEWLINE); + return CMD_SUCCESS; +} + +static int config_write_net(struct vty *vty) +{ + struct gsm_network *gsmnet = gsmnet_from_vty(vty); + + vty_out(vty, "network%s", VTY_NEWLINE); + vty_out(vty, " network country code %u%s", gsmnet->country_code, VTY_NEWLINE); + vty_out(vty, " mobile network code %u%s", gsmnet->network_code, VTY_NEWLINE); + vty_out(vty, " short name %s%s", gsmnet->name_short, VTY_NEWLINE); + vty_out(vty, " long name %s%s", gsmnet->name_long, VTY_NEWLINE); + vty_out(vty, " auth policy %s%s", gsm_auth_policy_name(gsmnet->auth_policy), VTY_NEWLINE); + vty_out(vty, " location updating reject cause %u%s", + gsmnet->reject_cause, VTY_NEWLINE); + vty_out(vty, " encryption a5 %u%s", gsmnet->a5_encryption, VTY_NEWLINE); + vty_out(vty, " rrlp mode %s%s", rrlp_mode_name(gsmnet->rrlp.mode), + VTY_NEWLINE); + vty_out(vty, " mm info %u%s", gsmnet->send_mm_info, VTY_NEWLINE); + vty_out(vty, " subscriber-keep-in-ram %d%s", + gsmnet->subscr_group->keep_subscr, VTY_NEWLINE); + if (gsmnet->tz.override != 0) { + if (gsmnet->tz.dst) + vty_out(vty, " timezone %d %d %d%s", + gsmnet->tz.hr, gsmnet->tz.mn, gsmnet->tz.dst, + VTY_NEWLINE); + else + vty_out(vty, " timezone %d %d%s", + gsmnet->tz.hr, gsmnet->tz.mn, VTY_NEWLINE); + } + if (gsmnet->t3212 == 0) + vty_out(vty, " no periodic location update%s", VTY_NEWLINE); + else + vty_out(vty, " periodic location update %u%s", + gsmnet->t3212 * 6, VTY_NEWLINE); + + return CMD_SUCCESS; +} + +void cscn_vty_init(struct gsm_network *cscn_network) +{ + xsc_vty_init(cscn_network, config_write_net); + + install_element(CONFIG_NODE, &cfg_cscn_cmd); + install_node(&cscn_node, config_write_cscn); + install_element(CSCN_NODE, &cfg_cscn_subscr_create_cmd); + install_element(CSCN_NODE, &cfg_cscn_subscr_random_cmd); + install_element(CSCN_NODE, &cfg_cscn_no_subscr_create_cmd); + install_element(CSCN_NODE, &cfg_cscn_assign_tmsi_cmd); + install_element(CSCN_NODE, &cfg_cscn_no_assign_tmsi_cmd); +} diff --git a/openbsc/src/libmsc/vty_interface_layer3.c b/openbsc/src/libmsc/vty_interface_layer3.c index 11aa97024..641a86ec9 100644 --- a/openbsc/src/libmsc/vty_interface_layer3.c +++ b/openbsc/src/libmsc/vty_interface_layer3.c @@ -21,8 +21,6 @@ #include <stdlib.h> #include <limits.h> #include <unistd.h> -#include <stdbool.h> -#include <inttypes.h> #include <time.h> #include <osmocom/vty/command.h> @@ -1039,99 +1037,6 @@ DEFUN(logging_fltr_imsi, return CMD_SUCCESS; } -static struct cmd_node nitb_node = { - NITB_NODE, - "%s(config-nitb)# ", - 1, -}; - -DEFUN(cfg_nitb, cfg_nitb_cmd, - "nitb", "Configure NITB options") -{ - vty->node = NITB_NODE; - return CMD_SUCCESS; -} - -/* Note: limit on the parameter length is set by internal vty code limitations */ -DEFUN(cfg_nitb_subscr_random, cfg_nitb_subscr_random_cmd, - "subscriber-create-on-demand random <1-9999999999> <2-9999999999>", - "Set random parameters for a new record when a subscriber is first seen.\n" - "Set random parameters for a new record when a subscriber is first seen.\n" - "Minimum for subscriber extension\n""Maximum for subscriber extension\n") -{ - struct gsm_network *gsmnet = gsmnet_from_vty(vty); - uint64_t mi = atoi(argv[0]), ma = atoi(argv[1]); - gsmnet->auto_create_subscr = true; - gsmnet->auto_assign_exten = true; - if (mi >= ma) { - vty_out(vty, "Incorrect range: %s >= %s, expected MIN < MAX%s", - argv[0], argv[1], VTY_NEWLINE); - return CMD_WARNING; - } - gsmnet->ext_min = mi; - gsmnet->ext_max = ma; - return CMD_SUCCESS; -} - -DEFUN(cfg_nitb_subscr_create, cfg_nitb_subscr_create_cmd, - "subscriber-create-on-demand [no-extension]", - "Make a new record when a subscriber is first seen.\n" - "Do not automatically assign extension to created subscribers\n") -{ - struct gsm_network *gsmnet = gsmnet_from_vty(vty); - gsmnet->auto_create_subscr = true; - gsmnet->auto_assign_exten = argc ? false : true; - return CMD_SUCCESS; -} - -DEFUN(cfg_nitb_no_subscr_create, cfg_nitb_no_subscr_create_cmd, - "no subscriber-create-on-demand", - NO_STR "Make a new record when a subscriber is first seen.\n") -{ - struct gsm_network *gsmnet = gsmnet_from_vty(vty); - gsmnet->auto_create_subscr = false; - return CMD_SUCCESS; -} - -DEFUN(cfg_nitb_assign_tmsi, cfg_nitb_assign_tmsi_cmd, - "assign-tmsi", - "Assign TMSI during Location Updating.\n") -{ - struct gsm_network *gsmnet = gsmnet_from_vty(vty); - gsmnet->avoid_tmsi = 0; - return CMD_SUCCESS; -} - -DEFUN(cfg_nitb_no_assign_tmsi, cfg_nitb_no_assign_tmsi_cmd, - "no assign-tmsi", - NO_STR "Assign TMSI during Location Updating.\n") -{ - struct gsm_network *gsmnet = gsmnet_from_vty(vty); - gsmnet->avoid_tmsi = 1; - return CMD_SUCCESS; -} - -static int config_write_nitb(struct vty *vty) -{ - struct gsm_network *gsmnet = gsmnet_from_vty(vty); - - vty_out(vty, "nitb%s", VTY_NEWLINE); - if (!gsmnet->auto_create_subscr) - vty_out(vty, " no subscriber-create-on-demand%s", VTY_NEWLINE); - else - vty_out(vty, " subscriber-create-on-demand%s%s", - gsmnet->auto_assign_exten ? "" : " no-extension", - VTY_NEWLINE); - - if (gsmnet->ext_min != GSM_MIN_EXTEN || gsmnet->ext_max != GSM_MAX_EXTEN) - vty_out(vty, " subscriber-create-on-demand random %"PRIu64" %" - PRIu64"%s", gsmnet->ext_min, gsmnet->ext_max, - VTY_NEWLINE); - vty_out(vty, " %sassign-tmsi%s", - gsmnet->avoid_tmsi ? "no " : "", VTY_NEWLINE); - return CMD_SUCCESS; -} - int bsc_vty_init_extra(void) { osmo_signal_register_handler(SS_SCALL, scall_cbfn, NULL); @@ -1177,14 +1082,5 @@ int bsc_vty_init_extra(void) install_element(CFG_LOG_NODE, &log_level_sms_cmd); install_element(CFG_LOG_NODE, &logging_fltr_imsi_cmd); - - install_element(CONFIG_NODE, &cfg_nitb_cmd); - install_node(&nitb_node, config_write_nitb); - install_element(NITB_NODE, &cfg_nitb_subscr_create_cmd); - install_element(NITB_NODE, &cfg_nitb_subscr_random_cmd); - install_element(NITB_NODE, &cfg_nitb_no_subscr_create_cmd); - install_element(NITB_NODE, &cfg_nitb_assign_tmsi_cmd); - install_element(NITB_NODE, &cfg_nitb_no_assign_tmsi_cmd); - return 0; } |