blob: 82dc7d67933a9b684d0fb474ca33f14dda0c9f0f [file] [log] [blame]
Neels Hofmeyra1756f32016-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
67static int config_write_msc(struct vty *vty)
68{
69 struct gsm_network *gsmnet = gsmnet_from_vty(vty);
70
71 vty_out(vty, "msc%s", VTY_NEWLINE);
72 vty_out(vty, " %sassign-tmsi%s",
73 gsmnet->vlr->cfg.assign_tmsi? "" : "no ", VTY_NEWLINE);
74
75 mgcpgw_client_config_write(vty, " ");
76#ifdef BUILD_IU
77 iu_vty_config_write(vty, " ");
78#endif
79
80 return CMD_SUCCESS;
81}
82
83static int config_write_net(struct vty *vty)
84{
85 struct gsm_network *gsmnet = gsmnet_from_vty(vty);
86
87 vty_out(vty, "network%s", VTY_NEWLINE);
88 vty_out(vty, " network country code %u%s", gsmnet->country_code, VTY_NEWLINE);
89 vty_out(vty, " mobile network code %u%s", gsmnet->network_code, VTY_NEWLINE);
90 vty_out(vty, " short name %s%s", gsmnet->name_short, VTY_NEWLINE);
91 vty_out(vty, " long name %s%s", gsmnet->name_long, VTY_NEWLINE);
92 vty_out(vty, " auth policy %s%s", gsm_auth_policy_name(gsmnet->auth_policy), VTY_NEWLINE);
93 vty_out(vty, " location updating reject cause %u%s",
94 gsmnet->reject_cause, VTY_NEWLINE);
95 vty_out(vty, " encryption a5 %u%s", gsmnet->a5_encryption, VTY_NEWLINE);
96 vty_out(vty, " rrlp mode %s%s", rrlp_mode_name(gsmnet->rrlp.mode),
97 VTY_NEWLINE);
98 vty_out(vty, " mm info %u%s", gsmnet->send_mm_info, VTY_NEWLINE);
99 if (gsmnet->tz.override != 0) {
100 if (gsmnet->tz.dst)
101 vty_out(vty, " timezone %d %d %d%s",
102 gsmnet->tz.hr, gsmnet->tz.mn, gsmnet->tz.dst,
103 VTY_NEWLINE);
104 else
105 vty_out(vty, " timezone %d %d%s",
106 gsmnet->tz.hr, gsmnet->tz.mn, VTY_NEWLINE);
107 }
108 if (gsmnet->t3212 == 0)
109 vty_out(vty, " no periodic location update%s", VTY_NEWLINE);
110 else
111 vty_out(vty, " periodic location update %u%s",
112 gsmnet->t3212 * 6, VTY_NEWLINE);
113
114 return CMD_SUCCESS;
115}
116
117void msc_vty_init(struct gsm_network *msc_network)
118{
119 common_cs_vty_init(msc_network, config_write_net);
120
121 install_element(CONFIG_NODE, &cfg_msc_cmd);
122 install_node(&msc_node, config_write_msc);
123 vty_install_default(MSC_NODE);
124 install_element(MSC_NODE, &cfg_msc_assign_tmsi_cmd);
125 install_element(MSC_NODE, &cfg_msc_no_assign_tmsi_cmd);
126 mgcpgw_client_vty_init(MSC_NODE, &msc_network->mgcpgw.conf);
127#ifdef BUILD_IU
128 iu_vty_init(MSC_NODE, &msc_network->iu.rab_assign_addr_enc);
129#endif
130}