blob: edd17fcee8669383e5cec51144fd013c1d9b33b8 [file] [log] [blame]
Holger Hans Peter Freythercacbc732010-06-30 14:59:23 +08001/* Osmo BSC VTY Configuration */
2/* (C) 2009-2010 by Holger Hans Peter Freyther
Holger Hans Peter Freyther85531cc2010-10-06 20:37:09 +08003 * (C) 2009-2010 by On-Waves
Holger Hans Peter Freythercacbc732010-06-30 14:59:23 +08004 * All Rights Reserved
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License along
17 * with this program; if not, write to the Free Software Foundation, Inc.,
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19 *
20 */
21
Holger Hans Peter Freyther47b26012010-09-15 23:28:49 +080022#include <openbsc/gsm_data.h>
23#include <openbsc/osmo_msc_data.h>
24#include <openbsc/vty.h>
25
26#include <osmocore/talloc.h>
27
28extern struct gsm_network *bsc_gsmnet;
29
30static struct osmo_msc_data *osmo_msc_data(struct vty *vty)
31{
32 return bsc_gsmnet->msc_data;
33}
34
35static struct cmd_node msc_node = {
36 MSC_NODE,
37 "%s(msc)#",
38 1,
39};
40
41DEFUN(cfg_net_msc, cfg_net_msc_cmd,
42 "msc", "Configure MSC details")
43{
44 vty->index = bsc_gsmnet;
45 vty->node = MSC_NODE;
46
47 return CMD_SUCCESS;
48}
49
50static int config_write_msc(struct vty *vty)
51{
52 struct osmo_msc_data *data = osmo_msc_data(vty);
53
54 vty_out(vty, " msc%s", VTY_NEWLINE);
55 if (data->bsc_token)
56 vty_out(vty, " token %s%s", data->bsc_token, VTY_NEWLINE);
Holger Hans Peter Freyther4de11162010-11-03 13:12:18 +010057 if (data->core_ncc != -1)
58 vty_out(vty, " core-mobile-network-code %d%s",
59 data->core_ncc, VTY_NEWLINE);
Holger Hans Peter Freyther47b26012010-09-15 23:28:49 +080060 vty_out(vty, " ip %s%s", data->msc_ip, VTY_NEWLINE);
61 vty_out(vty, " port %d%s", data->msc_port, VTY_NEWLINE);
62 vty_out(vty, " ip-dscp %d%s", data->msc_ip_dscp, VTY_NEWLINE);
63 vty_out(vty, " timeout-ping %d%s", data->ping_timeout, VTY_NEWLINE);
64 vty_out(vty, " timeout-pong %d%s", data->pong_timeout, VTY_NEWLINE);
65 if (data->ussd_grace_txt)
66 vty_out(vty, "bsc-grace-text %s%s", data->ussd_grace_txt, VTY_NEWLINE);
67
68 return CMD_SUCCESS;
69}
70
Holger Hans Peter Freyther5b848f32010-11-03 13:11:14 +010071DEFUN(cfg_net_bsc_token,
Holger Hans Peter Freyther47b26012010-09-15 23:28:49 +080072 cfg_net_bsc_token_cmd,
73 "token TOKEN",
74 "A token for the BSC to be sent to the MSC")
75{
76 struct osmo_msc_data *data = osmo_msc_data(vty);
77
Holger Hans Peter Freyther3e9a7f82010-10-12 23:21:54 +020078 bsc_replace_string(data, &data->bsc_token, argv[0]);
Holger Hans Peter Freyther47b26012010-09-15 23:28:49 +080079 return CMD_SUCCESS;
80}
81
Holger Hans Peter Freyther4de11162010-11-03 13:12:18 +010082DEFUN(cfg_net_bsc_ncc,
83 cfg_net_bsc_ncc_cmd,
84 "core-mobile-network-code <0-255>",
85 "Use this network code for the backbone\n" "NCC value\n")
86{
87 struct osmo_msc_data *data = osmo_msc_data(vty);
88 data->core_ncc = atoi(argv[0]);
89 return CMD_SUCCESS;
90}
91
Holger Hans Peter Freyther47b26012010-09-15 23:28:49 +080092DEFUN(cfg_net_msc_ip,
93 cfg_net_msc_ip_cmd,
94 "ip A.B.C.D", "Set the MSC/MUX IP address.")
95{
96 struct osmo_msc_data *data = osmo_msc_data(vty);
Holger Hans Peter Freyther47b26012010-09-15 23:28:49 +080097
Holger Hans Peter Freyther3e9a7f82010-10-12 23:21:54 +020098 bsc_replace_string(data, &data->msc_ip, argv[0]);
Holger Hans Peter Freyther47b26012010-09-15 23:28:49 +080099 return CMD_SUCCESS;
100}
101
102DEFUN(cfg_net_msc_port,
103 cfg_net_msc_port_cmd,
104 "port <1-65000>",
105 "Set the MSC/MUX port.")
106{
107 struct osmo_msc_data *data = osmo_msc_data(vty);
108 data->msc_port = atoi(argv[0]);
109 return CMD_SUCCESS;
110}
111
112
113DEFUN(cfg_net_msc_prio,
114 cfg_net_msc_prio_cmd,
115 "ip-dscp <0-255>",
116 "Set the IP_TOS socket attribite")
117{
118 struct osmo_msc_data *data = osmo_msc_data(vty);
119 data->msc_ip_dscp = atoi(argv[0]);
120 return CMD_SUCCESS;
121}
122
123DEFUN(cfg_net_msc_ping_time,
124 cfg_net_msc_ping_time_cmd,
125 "timeout-ping NR",
126 "Set the PING interval, negative for not sending PING")
127{
128 struct osmo_msc_data *data = osmo_msc_data(vty);
129 data->ping_timeout = atoi(argv[0]);
130 return CMD_SUCCESS;
131}
132
133DEFUN(cfg_net_msc_pong_time,
134 cfg_net_msc_pong_time_cmd,
135 "timeout-pong NR",
136 "Set the time to wait for a PONG.")
137{
138 struct osmo_msc_data *data = osmo_msc_data(vty);
139 data->pong_timeout = atoi(argv[0]);
140 return CMD_SUCCESS;
141}
142
143DEFUN(cfg_net_msc_grace_ussd,
144 cfg_net_msc_grace_ussd_cmd,
145 "bsc-grace-text .TEXT",
146 "Set the USSD notifcation to be send.\n" "Text to be sent\n")
147{
148 struct osmo_msc_data *data = osmo_msc_data(vty);
149 char *txt = argv_concat(argv, argc, 1);
150 if (!txt)
151 return CMD_WARNING;
152
Holger Hans Peter Freyther3e9a7f82010-10-12 23:21:54 +0200153 bsc_replace_string(data, &data->ussd_grace_txt, txt);
Holger Hans Peter Freyther47b26012010-09-15 23:28:49 +0800154 talloc_free(txt);
155 return CMD_SUCCESS;
156}
Holger Hans Peter Freythercacbc732010-06-30 14:59:23 +0800157
158int bsc_vty_init_extra(void)
159{
Holger Hans Peter Freyther47b26012010-09-15 23:28:49 +0800160 install_element(GSMNET_NODE, &cfg_net_msc_cmd);
161 install_node(&msc_node, config_write_msc);
162 install_default(MSC_NODE);
163 install_element(MSC_NODE, &cfg_net_bsc_token_cmd);
Holger Hans Peter Freyther4de11162010-11-03 13:12:18 +0100164 install_element(MSC_NODE, &cfg_net_bsc_ncc_cmd);
Holger Hans Peter Freyther47b26012010-09-15 23:28:49 +0800165 install_element(MSC_NODE, &cfg_net_msc_ip_cmd);
166 install_element(MSC_NODE, &cfg_net_msc_port_cmd);
167 install_element(MSC_NODE, &cfg_net_msc_prio_cmd);
168 install_element(MSC_NODE, &cfg_net_msc_ping_time_cmd);
169 install_element(MSC_NODE, &cfg_net_msc_pong_time_cmd);
170 install_element(MSC_NODE, &cfg_net_msc_grace_ussd_cmd);
171
Holger Hans Peter Freythercacbc732010-06-30 14:59:23 +0800172 return 0;
173}