Neels Hofmeyr | a1756f3 | 2016-05-20 21:59:55 +0200 | [diff] [blame] | 1 | /* MSC interface to quagga VTY */ |
| 2 | /* (C) 2016 by sysmocom s.m.f.c. GmbH <info@sysmocom.de> |
| 3 | * Based on OpenBSC interface to quagga VTY (libmsc/vty_interface_layer3.c) |
| 4 | * (C) 2009 by Harald Welte <laforge@gnumonks.org> |
| 5 | * (C) 2009-2011 by Holger Hans Peter Freyther |
| 6 | * All Rights Reserved |
| 7 | * |
| 8 | * This program is free software; you can redistribute it and/or modify |
| 9 | * it under the terms of the GNU Affero General Public License as published by |
| 10 | * the Free Software Foundation; either version 3 of the License, or |
| 11 | * (at your option) any later version. |
| 12 | * |
| 13 | * This program is distributed in the hope that it will be useful, |
| 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 16 | * GNU Affero General Public License for more details. |
| 17 | * |
| 18 | * You should have received a copy of the GNU Affero General Public License |
| 19 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 20 | * |
| 21 | */ |
| 22 | |
| 23 | /* NOTE: I would have liked to call this the MSC_NODE instead of the MSC_NODE, |
| 24 | * but MSC_NODE already exists to configure a remote MSC for osmo-bsc. */ |
| 25 | |
Neels Hofmeyr | 28295b9 | 2017-07-05 15:19:52 +0200 | [diff] [blame^] | 26 | #include "../../bscconfig.h" |
| 27 | |
Neels Hofmeyr | a1756f3 | 2016-05-20 21:59:55 +0200 | [diff] [blame] | 28 | #include <inttypes.h> |
| 29 | |
| 30 | #include <osmocom/vty/command.h> |
Neels Hofmeyr | 28295b9 | 2017-07-05 15:19:52 +0200 | [diff] [blame^] | 31 | #ifdef BUILD_IU |
| 32 | #include <osmocom/ranap/iu_client.h> |
| 33 | #endif |
Neels Hofmeyr | a1756f3 | 2016-05-20 21:59:55 +0200 | [diff] [blame] | 34 | |
| 35 | #include <openbsc/vty.h> |
| 36 | #include <openbsc/gsm_data.h> |
| 37 | #include <openbsc/gsm_subscriber.h> |
| 38 | #include <openbsc/vlr.h> |
Neels Hofmeyr | a1756f3 | 2016-05-20 21:59:55 +0200 | [diff] [blame] | 39 | |
| 40 | static struct cmd_node msc_node = { |
| 41 | MSC_NODE, |
| 42 | "%s(config-msc)# ", |
| 43 | 1, |
| 44 | }; |
| 45 | |
| 46 | DEFUN(cfg_msc, cfg_msc_cmd, |
| 47 | "msc", "Configure MSC options") |
| 48 | { |
| 49 | vty->node = MSC_NODE; |
| 50 | return CMD_SUCCESS; |
| 51 | } |
| 52 | |
| 53 | DEFUN(cfg_msc_assign_tmsi, cfg_msc_assign_tmsi_cmd, |
| 54 | "assign-tmsi", |
| 55 | "Assign TMSI during Location Updating.\n") |
| 56 | { |
| 57 | struct gsm_network *gsmnet = gsmnet_from_vty(vty); |
| 58 | gsmnet->vlr->cfg.assign_tmsi = true; |
| 59 | return CMD_SUCCESS; |
| 60 | } |
| 61 | |
| 62 | DEFUN(cfg_msc_no_assign_tmsi, cfg_msc_no_assign_tmsi_cmd, |
| 63 | "no assign-tmsi", |
| 64 | NO_STR "Assign TMSI during Location Updating.\n") |
| 65 | { |
| 66 | struct gsm_network *gsmnet = gsmnet_from_vty(vty); |
| 67 | gsmnet->vlr->cfg.assign_tmsi = false; |
| 68 | return CMD_SUCCESS; |
| 69 | } |
| 70 | |
Philipp Maier | 4b60d07 | 2017-04-09 12:32:51 +0200 | [diff] [blame] | 71 | DEFUN(cfg_msc_cs7_instance_a, |
| 72 | cfg_msc_cs7_instance_a_cmd, |
| 73 | "cs7-instance-a <0-15>", |
| 74 | "Set SS7 to be used by the A-Interface.\n" "SS7 instance reference number\n") |
| 75 | { |
| 76 | struct gsm_network *gsmnet = gsmnet_from_vty(vty); |
| 77 | gsmnet->a.cs7_instance = atoi(argv[0]); |
| 78 | return CMD_SUCCESS; |
| 79 | } |
| 80 | |
| 81 | DEFUN(cfg_msc_cs7_instance_iu, |
| 82 | cfg_msc_cs7_instance_iu_cmd, |
| 83 | "cs7-instance-iu <0-15>", |
| 84 | "Set SS7 to be used by the Iu-Interface.\n" "SS7 instance reference number\n") |
| 85 | { |
| 86 | struct gsm_network *gsmnet = gsmnet_from_vty(vty); |
| 87 | gsmnet->iu.cs7_instance = atoi(argv[0]); |
| 88 | return CMD_SUCCESS; |
| 89 | } |
| 90 | |
Neels Hofmeyr | a1756f3 | 2016-05-20 21:59:55 +0200 | [diff] [blame] | 91 | static int config_write_msc(struct vty *vty) |
| 92 | { |
| 93 | struct gsm_network *gsmnet = gsmnet_from_vty(vty); |
| 94 | |
| 95 | vty_out(vty, "msc%s", VTY_NEWLINE); |
| 96 | vty_out(vty, " %sassign-tmsi%s", |
| 97 | gsmnet->vlr->cfg.assign_tmsi? "" : "no ", VTY_NEWLINE); |
| 98 | |
Philipp Maier | 4b60d07 | 2017-04-09 12:32:51 +0200 | [diff] [blame] | 99 | vty_out(vty, " cs7-instance-a %u%s", gsmnet->a.cs7_instance, |
| 100 | VTY_NEWLINE); |
| 101 | vty_out(vty, " cs7-instance-iu %u%s", gsmnet->iu.cs7_instance, |
| 102 | VTY_NEWLINE); |
| 103 | |
Neels Hofmeyr | a1756f3 | 2016-05-20 21:59:55 +0200 | [diff] [blame] | 104 | mgcpgw_client_config_write(vty, " "); |
| 105 | #ifdef BUILD_IU |
Neels Hofmeyr | 28295b9 | 2017-07-05 15:19:52 +0200 | [diff] [blame^] | 106 | ranap_iu_vty_config_write(vty, " "); |
Neels Hofmeyr | a1756f3 | 2016-05-20 21:59:55 +0200 | [diff] [blame] | 107 | #endif |
| 108 | |
| 109 | return CMD_SUCCESS; |
| 110 | } |
| 111 | |
| 112 | static int config_write_net(struct vty *vty) |
| 113 | { |
| 114 | struct gsm_network *gsmnet = gsmnet_from_vty(vty); |
| 115 | |
| 116 | vty_out(vty, "network%s", VTY_NEWLINE); |
| 117 | vty_out(vty, " network country code %u%s", gsmnet->country_code, VTY_NEWLINE); |
| 118 | vty_out(vty, " mobile network code %u%s", gsmnet->network_code, VTY_NEWLINE); |
| 119 | vty_out(vty, " short name %s%s", gsmnet->name_short, VTY_NEWLINE); |
| 120 | vty_out(vty, " long name %s%s", gsmnet->name_long, VTY_NEWLINE); |
| 121 | vty_out(vty, " auth policy %s%s", gsm_auth_policy_name(gsmnet->auth_policy), VTY_NEWLINE); |
| 122 | vty_out(vty, " location updating reject cause %u%s", |
| 123 | gsmnet->reject_cause, VTY_NEWLINE); |
| 124 | vty_out(vty, " encryption a5 %u%s", gsmnet->a5_encryption, VTY_NEWLINE); |
| 125 | vty_out(vty, " rrlp mode %s%s", rrlp_mode_name(gsmnet->rrlp.mode), |
| 126 | VTY_NEWLINE); |
| 127 | vty_out(vty, " mm info %u%s", gsmnet->send_mm_info, VTY_NEWLINE); |
| 128 | if (gsmnet->tz.override != 0) { |
| 129 | if (gsmnet->tz.dst) |
| 130 | vty_out(vty, " timezone %d %d %d%s", |
| 131 | gsmnet->tz.hr, gsmnet->tz.mn, gsmnet->tz.dst, |
| 132 | VTY_NEWLINE); |
| 133 | else |
| 134 | vty_out(vty, " timezone %d %d%s", |
| 135 | gsmnet->tz.hr, gsmnet->tz.mn, VTY_NEWLINE); |
| 136 | } |
| 137 | if (gsmnet->t3212 == 0) |
| 138 | vty_out(vty, " no periodic location update%s", VTY_NEWLINE); |
| 139 | else |
| 140 | vty_out(vty, " periodic location update %u%s", |
| 141 | gsmnet->t3212 * 6, VTY_NEWLINE); |
| 142 | |
| 143 | return CMD_SUCCESS; |
| 144 | } |
| 145 | |
| 146 | void msc_vty_init(struct gsm_network *msc_network) |
| 147 | { |
| 148 | common_cs_vty_init(msc_network, config_write_net); |
| 149 | |
| 150 | install_element(CONFIG_NODE, &cfg_msc_cmd); |
| 151 | install_node(&msc_node, config_write_msc); |
| 152 | vty_install_default(MSC_NODE); |
| 153 | install_element(MSC_NODE, &cfg_msc_assign_tmsi_cmd); |
| 154 | install_element(MSC_NODE, &cfg_msc_no_assign_tmsi_cmd); |
Philipp Maier | 4b60d07 | 2017-04-09 12:32:51 +0200 | [diff] [blame] | 155 | install_element(MSC_NODE, &cfg_msc_cs7_instance_a_cmd); |
| 156 | install_element(MSC_NODE, &cfg_msc_cs7_instance_iu_cmd); |
| 157 | |
Neels Hofmeyr | a1756f3 | 2016-05-20 21:59:55 +0200 | [diff] [blame] | 158 | mgcpgw_client_vty_init(MSC_NODE, &msc_network->mgcpgw.conf); |
| 159 | #ifdef BUILD_IU |
Neels Hofmeyr | 28295b9 | 2017-07-05 15:19:52 +0200 | [diff] [blame^] | 160 | ranap_iu_vty_init(MSC_NODE, &msc_network->iu.rab_assign_addr_enc); |
Neels Hofmeyr | a1756f3 | 2016-05-20 21:59:55 +0200 | [diff] [blame] | 161 | #endif |
| 162 | } |