blob: a4ec70d669c7a1ca37af16a45de422ae513efe3a [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 Freyther45f9e692010-11-03 13:21:02 +010060 vty_out(vty, " ip.access rtp-payload %d%s",
61 data->rtp_payload, VTY_NEWLINE);
Holger Hans Peter Freyther47b26012010-09-15 23:28:49 +080062 vty_out(vty, " ip %s%s", data->msc_ip, VTY_NEWLINE);
63 vty_out(vty, " port %d%s", data->msc_port, VTY_NEWLINE);
64 vty_out(vty, " ip-dscp %d%s", data->msc_ip_dscp, VTY_NEWLINE);
65 vty_out(vty, " timeout-ping %d%s", data->ping_timeout, VTY_NEWLINE);
66 vty_out(vty, " timeout-pong %d%s", data->pong_timeout, VTY_NEWLINE);
67 if (data->ussd_grace_txt)
68 vty_out(vty, "bsc-grace-text %s%s", data->ussd_grace_txt, VTY_NEWLINE);
69
70 return CMD_SUCCESS;
71}
72
Holger Hans Peter Freyther5b848f32010-11-03 13:11:14 +010073DEFUN(cfg_net_bsc_token,
Holger Hans Peter Freyther47b26012010-09-15 23:28:49 +080074 cfg_net_bsc_token_cmd,
75 "token TOKEN",
76 "A token for the BSC to be sent to the MSC")
77{
78 struct osmo_msc_data *data = osmo_msc_data(vty);
79
Holger Hans Peter Freyther3e9a7f82010-10-12 23:21:54 +020080 bsc_replace_string(data, &data->bsc_token, argv[0]);
Holger Hans Peter Freyther47b26012010-09-15 23:28:49 +080081 return CMD_SUCCESS;
82}
83
Holger Hans Peter Freyther4de11162010-11-03 13:12:18 +010084DEFUN(cfg_net_bsc_ncc,
85 cfg_net_bsc_ncc_cmd,
86 "core-mobile-network-code <0-255>",
87 "Use this network code for the backbone\n" "NCC value\n")
88{
89 struct osmo_msc_data *data = osmo_msc_data(vty);
90 data->core_ncc = atoi(argv[0]);
91 return CMD_SUCCESS;
92}
93
Holger Hans Peter Freyther45f9e692010-11-03 13:21:02 +010094DEFUN(cfg_net_bsc_rtp_payload,
95 cfg_net_bsc_rtp_payload_cmd,
96 "ip.access rtp-payload <0-255>",
97 "IP.ACCESS specific\n"
98 "Set the rtp-payload for the RTP stream\n"
99 "RTP payload number\n")
100{
101 struct osmo_msc_data *data = osmo_msc_data(vty);
102 data->rtp_payload = atoi(argv[0]);
103 return CMD_SUCCESS;
104}
105
Holger Hans Peter Freyther47b26012010-09-15 23:28:49 +0800106DEFUN(cfg_net_msc_ip,
107 cfg_net_msc_ip_cmd,
108 "ip A.B.C.D", "Set the MSC/MUX IP address.")
109{
110 struct osmo_msc_data *data = osmo_msc_data(vty);
Holger Hans Peter Freyther47b26012010-09-15 23:28:49 +0800111
Holger Hans Peter Freyther3e9a7f82010-10-12 23:21:54 +0200112 bsc_replace_string(data, &data->msc_ip, argv[0]);
Holger Hans Peter Freyther47b26012010-09-15 23:28:49 +0800113 return CMD_SUCCESS;
114}
115
116DEFUN(cfg_net_msc_port,
117 cfg_net_msc_port_cmd,
118 "port <1-65000>",
119 "Set the MSC/MUX port.")
120{
121 struct osmo_msc_data *data = osmo_msc_data(vty);
122 data->msc_port = atoi(argv[0]);
123 return CMD_SUCCESS;
124}
125
126
127DEFUN(cfg_net_msc_prio,
128 cfg_net_msc_prio_cmd,
129 "ip-dscp <0-255>",
130 "Set the IP_TOS socket attribite")
131{
132 struct osmo_msc_data *data = osmo_msc_data(vty);
133 data->msc_ip_dscp = atoi(argv[0]);
134 return CMD_SUCCESS;
135}
136
137DEFUN(cfg_net_msc_ping_time,
138 cfg_net_msc_ping_time_cmd,
139 "timeout-ping NR",
140 "Set the PING interval, negative for not sending PING")
141{
142 struct osmo_msc_data *data = osmo_msc_data(vty);
143 data->ping_timeout = atoi(argv[0]);
144 return CMD_SUCCESS;
145}
146
147DEFUN(cfg_net_msc_pong_time,
148 cfg_net_msc_pong_time_cmd,
149 "timeout-pong NR",
150 "Set the time to wait for a PONG.")
151{
152 struct osmo_msc_data *data = osmo_msc_data(vty);
153 data->pong_timeout = atoi(argv[0]);
154 return CMD_SUCCESS;
155}
156
157DEFUN(cfg_net_msc_grace_ussd,
158 cfg_net_msc_grace_ussd_cmd,
159 "bsc-grace-text .TEXT",
160 "Set the USSD notifcation to be send.\n" "Text to be sent\n")
161{
162 struct osmo_msc_data *data = osmo_msc_data(vty);
163 char *txt = argv_concat(argv, argc, 1);
164 if (!txt)
165 return CMD_WARNING;
166
Holger Hans Peter Freyther3e9a7f82010-10-12 23:21:54 +0200167 bsc_replace_string(data, &data->ussd_grace_txt, txt);
Holger Hans Peter Freyther47b26012010-09-15 23:28:49 +0800168 talloc_free(txt);
169 return CMD_SUCCESS;
170}
Holger Hans Peter Freythercacbc732010-06-30 14:59:23 +0800171
172int bsc_vty_init_extra(void)
173{
Holger Hans Peter Freyther47b26012010-09-15 23:28:49 +0800174 install_element(GSMNET_NODE, &cfg_net_msc_cmd);
175 install_node(&msc_node, config_write_msc);
176 install_default(MSC_NODE);
177 install_element(MSC_NODE, &cfg_net_bsc_token_cmd);
Holger Hans Peter Freyther4de11162010-11-03 13:12:18 +0100178 install_element(MSC_NODE, &cfg_net_bsc_ncc_cmd);
Holger Hans Peter Freyther45f9e692010-11-03 13:21:02 +0100179 install_element(MSC_NODE, &cfg_net_bsc_rtp_payload_cmd);
Holger Hans Peter Freyther47b26012010-09-15 23:28:49 +0800180 install_element(MSC_NODE, &cfg_net_msc_ip_cmd);
181 install_element(MSC_NODE, &cfg_net_msc_port_cmd);
182 install_element(MSC_NODE, &cfg_net_msc_prio_cmd);
183 install_element(MSC_NODE, &cfg_net_msc_ping_time_cmd);
184 install_element(MSC_NODE, &cfg_net_msc_pong_time_cmd);
185 install_element(MSC_NODE, &cfg_net_msc_grace_ussd_cmd);
186
Holger Hans Peter Freythercacbc732010-06-30 14:59:23 +0800187 return 0;
188}