blob: 01e7e82956e8a4963542ec854817dea5fef12119 [file] [log] [blame]
Neels Hofmeyr2188a772016-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
26#include <inttypes.h>
27
28#include <osmocom/vty/command.h>
29
30#include <openbsc/vty.h>
31#include <openbsc/gsm_data.h>
32#include <openbsc/gsm_subscriber.h>
33#include <openbsc/vlr.h>
34#include <openbsc/iu.h>
35
36static struct cmd_node msc_node = {
37 MSC_NODE,
38 "%s(config-msc)# ",
39 1,
40};
41
42DEFUN(cfg_msc, cfg_msc_cmd,
43 "msc", "Configure MSC options")
44{
45 vty->node = MSC_NODE;
46 return CMD_SUCCESS;
47}
48
49DEFUN(cfg_msc_assign_tmsi, cfg_msc_assign_tmsi_cmd,
50 "assign-tmsi",
51 "Assign TMSI during Location Updating.\n")
52{
53 struct gsm_network *gsmnet = gsmnet_from_vty(vty);
54 gsmnet->vlr->cfg.assign_tmsi = true;
55 return CMD_SUCCESS;
56}
57
58DEFUN(cfg_msc_no_assign_tmsi, cfg_msc_no_assign_tmsi_cmd,
59 "no assign-tmsi",
60 NO_STR "Assign TMSI during Location Updating.\n")
61{
62 struct gsm_network *gsmnet = gsmnet_from_vty(vty);
63 gsmnet->vlr->cfg.assign_tmsi = false;
64 return CMD_SUCCESS;
65}
66
Philipp Maierefe85d32017-04-09 12:32:51 +020067DEFUN(cfg_msc_cs7_instance_a,
68 cfg_msc_cs7_instance_a_cmd,
69 "cs7-instance-a <0-15>",
70 "Set SS7 to be used by the A-Interface.\n" "SS7 instance reference number\n")
71{
72 struct gsm_network *gsmnet = gsmnet_from_vty(vty);
73 gsmnet->a.cs7_instance = atoi(argv[0]);
74 return CMD_SUCCESS;
75}
76
77DEFUN(cfg_msc_cs7_instance_iu,
78 cfg_msc_cs7_instance_iu_cmd,
79 "cs7-instance-iu <0-15>",
80 "Set SS7 to be used by the Iu-Interface.\n" "SS7 instance reference number\n")
81{
82 struct gsm_network *gsmnet = gsmnet_from_vty(vty);
83 gsmnet->iu.cs7_instance = atoi(argv[0]);
84 return CMD_SUCCESS;
85}
86
Neels Hofmeyr2188a772016-05-20 21:59:55 +020087static int config_write_msc(struct vty *vty)
88{
89 struct gsm_network *gsmnet = gsmnet_from_vty(vty);
90
91 vty_out(vty, "msc%s", VTY_NEWLINE);
92 vty_out(vty, " %sassign-tmsi%s",
93 gsmnet->vlr->cfg.assign_tmsi? "" : "no ", VTY_NEWLINE);
94
Philipp Maierefe85d32017-04-09 12:32:51 +020095 vty_out(vty, " cs7-instance-a %u%s", gsmnet->a.cs7_instance,
96 VTY_NEWLINE);
97 vty_out(vty, " cs7-instance-iu %u%s", gsmnet->iu.cs7_instance,
98 VTY_NEWLINE);
99
Neels Hofmeyr2188a772016-05-20 21:59:55 +0200100 mgcpgw_client_config_write(vty, " ");
101#ifdef BUILD_IU
102 iu_vty_config_write(vty, " ");
103#endif
104
105 return CMD_SUCCESS;
106}
107
108static int config_write_net(struct vty *vty)
109{
110 struct gsm_network *gsmnet = gsmnet_from_vty(vty);
111
112 vty_out(vty, "network%s", VTY_NEWLINE);
113 vty_out(vty, " network country code %u%s", gsmnet->country_code, VTY_NEWLINE);
114 vty_out(vty, " mobile network code %u%s", gsmnet->network_code, VTY_NEWLINE);
115 vty_out(vty, " short name %s%s", gsmnet->name_short, VTY_NEWLINE);
116 vty_out(vty, " long name %s%s", gsmnet->name_long, VTY_NEWLINE);
117 vty_out(vty, " auth policy %s%s", gsm_auth_policy_name(gsmnet->auth_policy), VTY_NEWLINE);
118 vty_out(vty, " location updating reject cause %u%s",
119 gsmnet->reject_cause, VTY_NEWLINE);
120 vty_out(vty, " encryption a5 %u%s", gsmnet->a5_encryption, VTY_NEWLINE);
121 vty_out(vty, " rrlp mode %s%s", rrlp_mode_name(gsmnet->rrlp.mode),
122 VTY_NEWLINE);
123 vty_out(vty, " mm info %u%s", gsmnet->send_mm_info, VTY_NEWLINE);
124 if (gsmnet->tz.override != 0) {
125 if (gsmnet->tz.dst)
126 vty_out(vty, " timezone %d %d %d%s",
127 gsmnet->tz.hr, gsmnet->tz.mn, gsmnet->tz.dst,
128 VTY_NEWLINE);
129 else
130 vty_out(vty, " timezone %d %d%s",
131 gsmnet->tz.hr, gsmnet->tz.mn, VTY_NEWLINE);
132 }
133 if (gsmnet->t3212 == 0)
134 vty_out(vty, " no periodic location update%s", VTY_NEWLINE);
135 else
136 vty_out(vty, " periodic location update %u%s",
137 gsmnet->t3212 * 6, VTY_NEWLINE);
138
139 return CMD_SUCCESS;
140}
141
142void msc_vty_init(struct gsm_network *msc_network)
143{
144 common_cs_vty_init(msc_network, config_write_net);
145
146 install_element(CONFIG_NODE, &cfg_msc_cmd);
147 install_node(&msc_node, config_write_msc);
148 vty_install_default(MSC_NODE);
149 install_element(MSC_NODE, &cfg_msc_assign_tmsi_cmd);
150 install_element(MSC_NODE, &cfg_msc_no_assign_tmsi_cmd);
Philipp Maierefe85d32017-04-09 12:32:51 +0200151 install_element(MSC_NODE, &cfg_msc_cs7_instance_a_cmd);
152 install_element(MSC_NODE, &cfg_msc_cs7_instance_iu_cmd);
153
Neels Hofmeyr2188a772016-05-20 21:59:55 +0200154 mgcpgw_client_vty_init(MSC_NODE, &msc_network->mgcpgw.conf);
155#ifdef BUILD_IU
156 iu_vty_init(MSC_NODE, &msc_network->iu.rab_assign_addr_enc);
157#endif
158}