aboutsummaryrefslogtreecommitdiffstats
path: root/openbsc/src/bsc/osmo_bsc_vty.c
blob: d5c018b7abab5363d0e56110954ece3dfdfa03b2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
/* Osmo BSC VTY Configuration */
/* (C) 2009-2010 by Holger Hans Peter Freyther
 * (C) 2009-2010 by On-Waves
 * All Rights Reserved
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License along
 * with this program; if not, write to the Free Software Foundation, Inc.,
 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 *
 */

#include <openbsc/gsm_data.h>
#include <openbsc/osmo_msc_data.h>
#include <openbsc/vty.h>

#include <osmocore/talloc.h>

extern struct gsm_network *bsc_gsmnet;

static struct osmo_msc_data *osmo_msc_data(struct vty *vty)
{
	return bsc_gsmnet->msc_data;
}

static struct cmd_node msc_node = {
	MSC_NODE,
	"%s(msc)#",
	1,
};

DEFUN(cfg_net_msc, cfg_net_msc_cmd,
      "msc", "Configure MSC details")
{
	vty->index = bsc_gsmnet;
	vty->node = MSC_NODE;

	return CMD_SUCCESS;
}

static int config_write_msc(struct vty *vty)
{
	struct osmo_msc_data *data = osmo_msc_data(vty);

	vty_out(vty, " msc%s", VTY_NEWLINE);
	if (data->bsc_token)
		vty_out(vty, "  token %s%s", data->bsc_token, VTY_NEWLINE);
	vty_out(vty, "  ip %s%s", data->msc_ip, VTY_NEWLINE);
	vty_out(vty, "  port %d%s", data->msc_port, VTY_NEWLINE);
	vty_out(vty, "  ip-dscp %d%s", data->msc_ip_dscp, VTY_NEWLINE);
	vty_out(vty, "  timeout-ping %d%s", data->ping_timeout, VTY_NEWLINE);
	vty_out(vty, "  timeout-pong %d%s", data->pong_timeout, VTY_NEWLINE);
	if (data->ussd_grace_txt)
		vty_out(vty, "bsc-grace-text %s%s", data->ussd_grace_txt, VTY_NEWLINE);

	return CMD_SUCCESS;
}

DEFUN(cfg_net_msc_token,
      cfg_net_bsc_token_cmd,
      "token TOKEN",
      "A token for the BSC to be sent to the MSC")
{
	struct osmo_msc_data *data = osmo_msc_data(vty);

	bsc_replace_string(data, &data->bsc_token, argv[0]);
	return CMD_SUCCESS;
}

DEFUN(cfg_net_msc_ip,
      cfg_net_msc_ip_cmd,
      "ip A.B.C.D", "Set the MSC/MUX IP address.")
{
	struct osmo_msc_data *data = osmo_msc_data(vty);

	bsc_replace_string(data, &data->msc_ip, argv[0]);
	return CMD_SUCCESS;
}

DEFUN(cfg_net_msc_port,
      cfg_net_msc_port_cmd,
      "port <1-65000>",
      "Set the MSC/MUX port.")
{
	struct osmo_msc_data *data = osmo_msc_data(vty);
	data->msc_port = atoi(argv[0]);
	return CMD_SUCCESS;
}


DEFUN(cfg_net_msc_prio,
      cfg_net_msc_prio_cmd,
      "ip-dscp <0-255>",
      "Set the IP_TOS socket attribite")
{
	struct osmo_msc_data *data = osmo_msc_data(vty);
	data->msc_ip_dscp = atoi(argv[0]);
	return CMD_SUCCESS;
}

DEFUN(cfg_net_msc_ping_time,
      cfg_net_msc_ping_time_cmd,
      "timeout-ping NR",
      "Set the PING interval, negative for not sending PING")
{
	struct osmo_msc_data *data = osmo_msc_data(vty);
	data->ping_timeout = atoi(argv[0]);
	return CMD_SUCCESS;
}

DEFUN(cfg_net_msc_pong_time,
      cfg_net_msc_pong_time_cmd,
      "timeout-pong NR",
      "Set the time to wait for a PONG.")
{
	struct osmo_msc_data *data = osmo_msc_data(vty);
	data->pong_timeout = atoi(argv[0]);
	return CMD_SUCCESS;
}

DEFUN(cfg_net_msc_grace_ussd,
      cfg_net_msc_grace_ussd_cmd,
      "bsc-grace-text .TEXT",
      "Set the USSD notifcation to be send.\n" "Text to be sent\n")
{
	struct osmo_msc_data *data = osmo_msc_data(vty);
	char *txt = argv_concat(argv, argc, 1);
	if (!txt)
		return CMD_WARNING;

	bsc_replace_string(data, &data->ussd_grace_txt, txt);
	talloc_free(txt);
	return CMD_SUCCESS;
}

int bsc_vty_init_extra(void)
{
	install_element(GSMNET_NODE, &cfg_net_msc_cmd);
	install_node(&msc_node, config_write_msc);
	install_default(MSC_NODE);
	install_element(MSC_NODE, &cfg_net_bsc_token_cmd);
	install_element(MSC_NODE, &cfg_net_msc_ip_cmd);
	install_element(MSC_NODE, &cfg_net_msc_port_cmd);
	install_element(MSC_NODE, &cfg_net_msc_prio_cmd);
	install_element(MSC_NODE, &cfg_net_msc_ping_time_cmd);
	install_element(MSC_NODE, &cfg_net_msc_pong_time_cmd);
	install_element(MSC_NODE, &cfg_net_msc_grace_ussd_cmd);

	return 0;
}