blob: ac366abb91e7f4ff0f777bb331f50a2b7276ba49 [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);
57 vty_out(vty, " ip %s%s", data->msc_ip, VTY_NEWLINE);
58 vty_out(vty, " port %d%s", data->msc_port, VTY_NEWLINE);
59 vty_out(vty, " ip-dscp %d%s", data->msc_ip_dscp, VTY_NEWLINE);
60 vty_out(vty, " timeout-ping %d%s", data->ping_timeout, VTY_NEWLINE);
61 vty_out(vty, " timeout-pong %d%s", data->pong_timeout, VTY_NEWLINE);
62 if (data->ussd_grace_txt)
63 vty_out(vty, "bsc-grace-text %s%s", data->ussd_grace_txt, VTY_NEWLINE);
64
65 return CMD_SUCCESS;
66}
67
68DEFUN(cfg_net_msc_token,
69 cfg_net_bsc_token_cmd,
70 "token TOKEN",
71 "A token for the BSC to be sent to the MSC")
72{
73 struct osmo_msc_data *data = osmo_msc_data(vty);
74
75 if (data->bsc_token)
76 talloc_free(data->bsc_token);
77 data->bsc_token = talloc_strdup(data, argv[0]);
78
79 return CMD_SUCCESS;
80}
81
82DEFUN(cfg_net_msc_ip,
83 cfg_net_msc_ip_cmd,
84 "ip A.B.C.D", "Set the MSC/MUX IP address.")
85{
86 struct osmo_msc_data *data = osmo_msc_data(vty);
87 if (data->msc_ip)
88 talloc_free(data->msc_ip);
89 data->msc_ip = talloc_strdup(data, argv[0]);
90
91 return CMD_SUCCESS;
92}
93
94DEFUN(cfg_net_msc_port,
95 cfg_net_msc_port_cmd,
96 "port <1-65000>",
97 "Set the MSC/MUX port.")
98{
99 struct osmo_msc_data *data = osmo_msc_data(vty);
100 data->msc_port = atoi(argv[0]);
101 return CMD_SUCCESS;
102}
103
104
105DEFUN(cfg_net_msc_prio,
106 cfg_net_msc_prio_cmd,
107 "ip-dscp <0-255>",
108 "Set the IP_TOS socket attribite")
109{
110 struct osmo_msc_data *data = osmo_msc_data(vty);
111 data->msc_ip_dscp = atoi(argv[0]);
112 return CMD_SUCCESS;
113}
114
115DEFUN(cfg_net_msc_ping_time,
116 cfg_net_msc_ping_time_cmd,
117 "timeout-ping NR",
118 "Set the PING interval, negative for not sending PING")
119{
120 struct osmo_msc_data *data = osmo_msc_data(vty);
121 data->ping_timeout = atoi(argv[0]);
122 return CMD_SUCCESS;
123}
124
125DEFUN(cfg_net_msc_pong_time,
126 cfg_net_msc_pong_time_cmd,
127 "timeout-pong NR",
128 "Set the time to wait for a PONG.")
129{
130 struct osmo_msc_data *data = osmo_msc_data(vty);
131 data->pong_timeout = atoi(argv[0]);
132 return CMD_SUCCESS;
133}
134
135DEFUN(cfg_net_msc_grace_ussd,
136 cfg_net_msc_grace_ussd_cmd,
137 "bsc-grace-text .TEXT",
138 "Set the USSD notifcation to be send.\n" "Text to be sent\n")
139{
140 struct osmo_msc_data *data = osmo_msc_data(vty);
141 char *txt = argv_concat(argv, argc, 1);
142 if (!txt)
143 return CMD_WARNING;
144
145 if (data->ussd_grace_txt)
146 talloc_free(data->ussd_grace_txt);
147 data->ussd_grace_txt = talloc_strdup(data, txt);
148 talloc_free(txt);
149 return CMD_SUCCESS;
150}
Holger Hans Peter Freythercacbc732010-06-30 14:59:23 +0800151
152int bsc_vty_init_extra(void)
153{
Holger Hans Peter Freyther47b26012010-09-15 23:28:49 +0800154 install_element(GSMNET_NODE, &cfg_net_msc_cmd);
155 install_node(&msc_node, config_write_msc);
156 install_default(MSC_NODE);
157 install_element(MSC_NODE, &cfg_net_bsc_token_cmd);
158 install_element(MSC_NODE, &cfg_net_msc_ip_cmd);
159 install_element(MSC_NODE, &cfg_net_msc_port_cmd);
160 install_element(MSC_NODE, &cfg_net_msc_prio_cmd);
161 install_element(MSC_NODE, &cfg_net_msc_ping_time_cmd);
162 install_element(MSC_NODE, &cfg_net_msc_pong_time_cmd);
163 install_element(MSC_NODE, &cfg_net_msc_grace_ussd_cmd);
164
Holger Hans Peter Freythercacbc732010-06-30 14:59:23 +0800165 return 0;
166}