/* MSC interface to quagga VTY */ /* (C) 2016 by sysmocom s.m.f.c. GmbH * Based on OpenBSC interface to quagga VTY (libmsc/vty_interface_layer3.c) * (C) 2009 by Harald Welte * (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 . * */ /* NOTE: I would have liked to call this the MSC_NODE instead of the MSC_NODE, * but MSC_NODE already exists to configure a remote MSC for osmo-bsc. */ #include #include #include #include #include #include #include #include #include static struct cmd_node msc_node = { MSC_NODE, "%s(config-msc)# ", 1, }; DEFUN(cfg_msc, cfg_msc_cmd, "msc", "Configure MSC options") { vty->node = MSC_NODE; return CMD_SUCCESS; } /* Note: limit on the parameter length is set by internal vty code limitations */ DEFUN(cfg_msc_subscr_random, cfg_msc_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_msc_subscr_create, cfg_msc_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_msc_no_subscr_create, cfg_msc_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_msc_assign_tmsi, cfg_msc_assign_tmsi_cmd, "assign-tmsi", "Assign TMSI during Location Updating.\n") { struct gsm_network *gsmnet = gsmnet_from_vty(vty); gsmnet->vlr->cfg.assign_tmsi = true; return CMD_SUCCESS; } DEFUN(cfg_msc_no_assign_tmsi, cfg_msc_no_assign_tmsi_cmd, "no assign-tmsi", NO_STR "Assign TMSI during Location Updating.\n") { struct gsm_network *gsmnet = gsmnet_from_vty(vty); gsmnet->vlr->cfg.assign_tmsi = false; return CMD_SUCCESS; } DEFUN(cfg_msc_register_bsc, cfg_msc_register_bsc_cmd, "bsc cs7-instance <0-15> calling-addr NAME called-addr NAME", "Register a new BSC connection to this MSC.\n" "Associated SS7 instance\n" "SS7 instance reference number\n" "Calling Address (local address of this MSC)\n" "SCCP address name\n" "Called Address (remote address of the BSC)\n" "SCCP address name\n") { struct gsm_network *gsmnet = gsmnet_from_vty(vty); struct osmo_sccp_addr *calling_addr; struct osmo_sccp_addr *called_addr; struct osmo_ss7_instance *inst; uint32_t inst_id = atoi(argv[0]); const char *calling_addr_name = argv[1]; const char *called_addr_name = argv[2]; inst = osmo_ss7_instance_find(inst_id); if (!inst) { vty_out(vty, "No SS7 instance %d found%s", inst_id, VTY_NEWLINE); return CMD_WARNING; } calling_addr = osmo_sccp_addr_by_name(calling_addr_name, inst); if (!calling_addr) { vty_out(vty, "No sccp address %s found%s", calling_addr_name, VTY_NEWLINE); return CMD_WARNING; } called_addr = osmo_sccp_addr_by_name(called_addr_name, inst); if (!called_addr) { vty_out(vty, "No sccp address %s found%s", called_addr_name, VTY_NEWLINE); return CMD_WARNING; } a_init(gsmnet, calling_addr, called_addr, inst); return CMD_SUCCESS; } DEFUN(cfg_msc_no_register_bsc, cfg_msc_no_register_bsc_cmd, "no bsc cs7-instance <0-15> calling-addr NAME called-addr NAME", NO_STR "Remove a BSC connection to this MSC.\n" "Associated SS7 instance\n" "SS7 instance reference number\n" "Calling Address (local address of this MSC)\n" "SCCP address name\n" "Called Address (remote address of the BSC)\n" "SCCP address name\n") { struct osmo_sccp_addr *calling_addr; struct osmo_sccp_addr *called_addr; struct osmo_ss7_instance *inst; uint32_t inst_id = atoi(argv[0]); const char *calling_addr_name = argv[1]; const char *called_addr_name = argv[2]; inst = osmo_ss7_instance_find(inst_id); if (!inst) { vty_out(vty, "No SS7 instance %d found%s", inst_id, VTY_NEWLINE); return CMD_WARNING; } calling_addr = osmo_sccp_addr_by_name(calling_addr_name, inst); if (!calling_addr) { vty_out(vty, "No sccp address %s found%s", calling_addr_name, VTY_NEWLINE); return CMD_WARNING; } called_addr = osmo_sccp_addr_by_name(called_addr_name, inst); if (!called_addr) { vty_out(vty, "No sccp address %s found%s", called_addr_name, VTY_NEWLINE); return CMD_WARNING; } a_drop(calling_addr, called_addr); return CMD_SUCCESS; } static int config_write_msc(struct vty *vty) { struct gsm_network *gsmnet = gsmnet_from_vty(vty); struct bsc_context *bsc_ctx; vty_out(vty, "msc%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->vlr->cfg.assign_tmsi? "" : "no ", VTY_NEWLINE); mgcpgw_client_config_write(vty, " "); iu_vty_config_write(vty, " "); /* write sccp connection configuration */ llist_for_each_entry(bsc_ctx, &gsmnet->a.bscs, list) { OSMO_ASSERT(bsc_ctx->ss7); vty_out(vty, " bsc cs7-instance %u calling-addr %s called-addr %s%s", bsc_ctx->ss7->cfg.id, osmo_sccp_name_by_addr(&bsc_ctx->calling_addr, bsc_ctx->ss7), osmo_sccp_name_by_addr(&bsc_ctx->called_addr, bsc_ctx->ss7), 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); 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 msc_vty_init(struct gsm_network *msc_network) { common_cs_vty_init(msc_network, config_write_net); install_element(CONFIG_NODE, &cfg_msc_cmd); install_node(&msc_node, config_write_msc); vty_install_default(MSC_NODE); install_element(MSC_NODE, &cfg_msc_subscr_create_cmd); install_element(MSC_NODE, &cfg_msc_subscr_random_cmd); install_element(MSC_NODE, &cfg_msc_no_subscr_create_cmd); install_element(MSC_NODE, &cfg_msc_assign_tmsi_cmd); install_element(MSC_NODE, &cfg_msc_no_assign_tmsi_cmd); install_element(MSC_NODE, &cfg_msc_register_bsc_cmd); install_element(MSC_NODE, &cfg_msc_no_register_bsc_cmd); mgcpgw_client_vty_init(MSC_NODE, &msc_network->mgcpgw.conf); iu_vty_init(MSC_NODE, &msc_network->iu.rab_assign_addr_enc); }