blob: c19666f3b7ce94deda4d36f558ceb6543a960b31 [file] [log] [blame]
Neels Hofmeyr84da6b12016-05-20 21:59:55 +02001/* 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 Hofmeyr00e82d62017-07-05 15:19:52 +020026#include "../../bscconfig.h"
27
Neels Hofmeyr84da6b12016-05-20 21:59:55 +020028#include <inttypes.h>
29
30#include <osmocom/vty/command.h>
Neels Hofmeyr00e82d62017-07-05 15:19:52 +020031#ifdef BUILD_IU
32#include <osmocom/ranap/iu_client.h>
33#endif
Neels Hofmeyr84da6b12016-05-20 21:59:55 +020034
Neels Hofmeyr90843962017-09-04 15:04:35 +020035#include <osmocom/msc/vty.h>
36#include <osmocom/msc/gsm_data.h>
37#include <osmocom/msc/gsm_subscriber.h>
38#include <osmocom/msc/vlr.h>
Neels Hofmeyr84da6b12016-05-20 21:59:55 +020039
40static struct cmd_node msc_node = {
41 MSC_NODE,
42 "%s(config-msc)# ",
43 1,
44};
45
46DEFUN(cfg_msc, cfg_msc_cmd,
47 "msc", "Configure MSC options")
48{
49 vty->node = MSC_NODE;
50 return CMD_SUCCESS;
51}
52
53DEFUN(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
62DEFUN(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 Maierfbf66102017-04-09 12:32:51 +020071DEFUN(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
81DEFUN(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 Hofmeyr97ce0152017-10-29 02:10:38 +010091DEFUN(cfg_msc_auth_tuple_max_reuse_count, cfg_msc_auth_tuple_max_reuse_count_cmd,
92 "auth-tuple-max-reuse-count <-1-2147483647>",
93 "Configure authentication tuple re-use\n"
94 "0 to use each auth tuple at most once (default), >0 to limit re-use, -1 to re-use infinitely (vulnerable!).\n")
95{
96 struct gsm_network *gsmnet = gsmnet_from_vty(vty);
97 gsmnet->vlr->cfg.auth_tuple_max_reuse_count = atoi(argv[0]);
98 return CMD_SUCCESS;
99}
100
101DEFUN(cfg_msc_auth_tuple_reuse_on_error, cfg_msc_auth_tuple_reuse_on_error_cmd,
102 "auth-tuple-reuse-on-error (0|1)",
103 "Configure authentication tuple re-use when HLR is not responsive\n"
104 "0 = never re-use auth tuples beyond auth-tuple-max-reuse-count (default)\n"
105 "1 = if the HLR does not deliver new tuples, do re-use already available old ones.\n")
106{
107 struct gsm_network *gsmnet = gsmnet_from_vty(vty);
108 gsmnet->vlr->cfg.auth_reuse_old_sets_on_error = atoi(argv[0]) ? true : false;
109 return CMD_SUCCESS;
110}
111
Neels Hofmeyr84da6b12016-05-20 21:59:55 +0200112static int config_write_msc(struct vty *vty)
113{
114 struct gsm_network *gsmnet = gsmnet_from_vty(vty);
115
116 vty_out(vty, "msc%s", VTY_NEWLINE);
117 vty_out(vty, " %sassign-tmsi%s",
118 gsmnet->vlr->cfg.assign_tmsi? "" : "no ", VTY_NEWLINE);
119
Philipp Maierfbf66102017-04-09 12:32:51 +0200120 vty_out(vty, " cs7-instance-a %u%s", gsmnet->a.cs7_instance,
121 VTY_NEWLINE);
122 vty_out(vty, " cs7-instance-iu %u%s", gsmnet->iu.cs7_instance,
123 VTY_NEWLINE);
124
Neels Hofmeyr97ce0152017-10-29 02:10:38 +0100125 if (gsmnet->vlr->cfg.auth_tuple_max_reuse_count)
126 vty_out(vty, " auth-tuple-max-reuse-count %d%s",
127 OSMO_MAX(-1, gsmnet->vlr->cfg.auth_tuple_max_reuse_count),
128 VTY_NEWLINE);
129 if (gsmnet->vlr->cfg.auth_reuse_old_sets_on_error)
130 vty_out(vty, " auth-tuple-reuse-on-error 1%s",
131 VTY_NEWLINE);
132
Neels Hofmeyr6c8afe12017-09-04 01:03:58 +0200133 mgcp_client_config_write(vty, " ");
Neels Hofmeyr84da6b12016-05-20 21:59:55 +0200134#ifdef BUILD_IU
Neels Hofmeyr00e82d62017-07-05 15:19:52 +0200135 ranap_iu_vty_config_write(vty, " ");
Neels Hofmeyr84da6b12016-05-20 21:59:55 +0200136#endif
137
138 return CMD_SUCCESS;
139}
140
141static int config_write_net(struct vty *vty)
142{
143 struct gsm_network *gsmnet = gsmnet_from_vty(vty);
144
145 vty_out(vty, "network%s", VTY_NEWLINE);
146 vty_out(vty, " network country code %u%s", gsmnet->country_code, VTY_NEWLINE);
147 vty_out(vty, " mobile network code %u%s", gsmnet->network_code, VTY_NEWLINE);
148 vty_out(vty, " short name %s%s", gsmnet->name_short, VTY_NEWLINE);
149 vty_out(vty, " long name %s%s", gsmnet->name_long, VTY_NEWLINE);
150 vty_out(vty, " auth policy %s%s", gsm_auth_policy_name(gsmnet->auth_policy), VTY_NEWLINE);
151 vty_out(vty, " location updating reject cause %u%s",
152 gsmnet->reject_cause, VTY_NEWLINE);
153 vty_out(vty, " encryption a5 %u%s", gsmnet->a5_encryption, VTY_NEWLINE);
154 vty_out(vty, " rrlp mode %s%s", rrlp_mode_name(gsmnet->rrlp.mode),
155 VTY_NEWLINE);
156 vty_out(vty, " mm info %u%s", gsmnet->send_mm_info, VTY_NEWLINE);
157 if (gsmnet->tz.override != 0) {
158 if (gsmnet->tz.dst)
159 vty_out(vty, " timezone %d %d %d%s",
160 gsmnet->tz.hr, gsmnet->tz.mn, gsmnet->tz.dst,
161 VTY_NEWLINE);
162 else
163 vty_out(vty, " timezone %d %d%s",
164 gsmnet->tz.hr, gsmnet->tz.mn, VTY_NEWLINE);
165 }
166 if (gsmnet->t3212 == 0)
167 vty_out(vty, " no periodic location update%s", VTY_NEWLINE);
168 else
169 vty_out(vty, " periodic location update %u%s",
170 gsmnet->t3212 * 6, VTY_NEWLINE);
171
172 return CMD_SUCCESS;
173}
174
175void msc_vty_init(struct gsm_network *msc_network)
176{
177 common_cs_vty_init(msc_network, config_write_net);
178
179 install_element(CONFIG_NODE, &cfg_msc_cmd);
180 install_node(&msc_node, config_write_msc);
181 vty_install_default(MSC_NODE);
182 install_element(MSC_NODE, &cfg_msc_assign_tmsi_cmd);
183 install_element(MSC_NODE, &cfg_msc_no_assign_tmsi_cmd);
Neels Hofmeyr97ce0152017-10-29 02:10:38 +0100184 install_element(MSC_NODE, &cfg_msc_auth_tuple_max_reuse_count_cmd);
185 install_element(MSC_NODE, &cfg_msc_auth_tuple_reuse_on_error_cmd);
Philipp Maierfbf66102017-04-09 12:32:51 +0200186 install_element(MSC_NODE, &cfg_msc_cs7_instance_a_cmd);
187 install_element(MSC_NODE, &cfg_msc_cs7_instance_iu_cmd);
188
Neels Hofmeyr6c8afe12017-09-04 01:03:58 +0200189 mgcp_client_vty_init(msc_network, MSC_NODE, &msc_network->mgw.conf);
Neels Hofmeyr84da6b12016-05-20 21:59:55 +0200190#ifdef BUILD_IU
Neels Hofmeyr00e82d62017-07-05 15:19:52 +0200191 ranap_iu_vty_init(MSC_NODE, &msc_network->iu.rab_assign_addr_enc);
Neels Hofmeyr84da6b12016-05-20 21:59:55 +0200192#endif
193}