Holger Hans Peter Freyther | 58ef6e4 | 2010-06-30 14:59:23 +0800 | [diff] [blame] | 1 | /* Osmo BSC VTY Configuration */ |
| 2 | /* (C) 2009-2010 by Holger Hans Peter Freyther |
Holger Hans Peter Freyther | 5180844 | 2010-10-06 20:37:09 +0800 | [diff] [blame] | 3 | * (C) 2009-2010 by On-Waves |
Holger Hans Peter Freyther | 58ef6e4 | 2010-06-30 14:59:23 +0800 | [diff] [blame] | 4 | * 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 Freyther | 8c4dca2 | 2010-09-15 23:28:49 +0800 | [diff] [blame] | 22 | #include <openbsc/gsm_data.h> |
| 23 | #include <openbsc/osmo_msc_data.h> |
| 24 | #include <openbsc/vty.h> |
| 25 | |
| 26 | #include <osmocore/talloc.h> |
| 27 | |
Holger Hans Peter Freyther | 7dcd8e3 | 2010-11-03 13:32:48 +0100 | [diff] [blame^] | 28 | |
| 29 | #define IPA_STR "IP.ACCESS specific\n" |
| 30 | |
Holger Hans Peter Freyther | 8c4dca2 | 2010-09-15 23:28:49 +0800 | [diff] [blame] | 31 | extern struct gsm_network *bsc_gsmnet; |
| 32 | |
| 33 | static struct osmo_msc_data *osmo_msc_data(struct vty *vty) |
| 34 | { |
| 35 | return bsc_gsmnet->msc_data; |
| 36 | } |
| 37 | |
| 38 | static struct cmd_node msc_node = { |
| 39 | MSC_NODE, |
| 40 | "%s(msc)#", |
| 41 | 1, |
| 42 | }; |
| 43 | |
| 44 | DEFUN(cfg_net_msc, cfg_net_msc_cmd, |
| 45 | "msc", "Configure MSC details") |
| 46 | { |
| 47 | vty->index = bsc_gsmnet; |
| 48 | vty->node = MSC_NODE; |
| 49 | |
| 50 | return CMD_SUCCESS; |
| 51 | } |
| 52 | |
| 53 | static int config_write_msc(struct vty *vty) |
| 54 | { |
| 55 | struct osmo_msc_data *data = osmo_msc_data(vty); |
| 56 | |
| 57 | vty_out(vty, " msc%s", VTY_NEWLINE); |
| 58 | if (data->bsc_token) |
| 59 | vty_out(vty, " token %s%s", data->bsc_token, VTY_NEWLINE); |
Holger Hans Peter Freyther | 21a1cf3 | 2010-11-03 13:12:18 +0100 | [diff] [blame] | 60 | if (data->core_ncc != -1) |
| 61 | vty_out(vty, " core-mobile-network-code %d%s", |
| 62 | data->core_ncc, VTY_NEWLINE); |
Holger Hans Peter Freyther | f43e3db | 2010-11-03 13:21:02 +0100 | [diff] [blame] | 63 | vty_out(vty, " ip.access rtp-payload %d%s", |
| 64 | data->rtp_payload, VTY_NEWLINE); |
Holger Hans Peter Freyther | 7dcd8e3 | 2010-11-03 13:32:48 +0100 | [diff] [blame^] | 65 | vty_out(vty, " ip.access rtp-base %d%s", data->rtp_base, VTY_NEWLINE); |
Holger Hans Peter Freyther | 8c4dca2 | 2010-09-15 23:28:49 +0800 | [diff] [blame] | 66 | vty_out(vty, " ip %s%s", data->msc_ip, VTY_NEWLINE); |
| 67 | vty_out(vty, " port %d%s", data->msc_port, VTY_NEWLINE); |
| 68 | vty_out(vty, " ip-dscp %d%s", data->msc_ip_dscp, VTY_NEWLINE); |
| 69 | vty_out(vty, " timeout-ping %d%s", data->ping_timeout, VTY_NEWLINE); |
| 70 | vty_out(vty, " timeout-pong %d%s", data->pong_timeout, VTY_NEWLINE); |
| 71 | if (data->ussd_grace_txt) |
| 72 | vty_out(vty, "bsc-grace-text %s%s", data->ussd_grace_txt, VTY_NEWLINE); |
| 73 | |
| 74 | return CMD_SUCCESS; |
| 75 | } |
| 76 | |
Holger Hans Peter Freyther | f3ce67d | 2010-11-03 13:11:14 +0100 | [diff] [blame] | 77 | DEFUN(cfg_net_bsc_token, |
Holger Hans Peter Freyther | 8c4dca2 | 2010-09-15 23:28:49 +0800 | [diff] [blame] | 78 | cfg_net_bsc_token_cmd, |
| 79 | "token TOKEN", |
| 80 | "A token for the BSC to be sent to the MSC") |
| 81 | { |
| 82 | struct osmo_msc_data *data = osmo_msc_data(vty); |
| 83 | |
Holger Hans Peter Freyther | 7c831f6 | 2010-10-12 23:21:54 +0200 | [diff] [blame] | 84 | bsc_replace_string(data, &data->bsc_token, argv[0]); |
Holger Hans Peter Freyther | 8c4dca2 | 2010-09-15 23:28:49 +0800 | [diff] [blame] | 85 | return CMD_SUCCESS; |
| 86 | } |
| 87 | |
Holger Hans Peter Freyther | 21a1cf3 | 2010-11-03 13:12:18 +0100 | [diff] [blame] | 88 | DEFUN(cfg_net_bsc_ncc, |
| 89 | cfg_net_bsc_ncc_cmd, |
| 90 | "core-mobile-network-code <0-255>", |
| 91 | "Use this network code for the backbone\n" "NCC value\n") |
| 92 | { |
| 93 | struct osmo_msc_data *data = osmo_msc_data(vty); |
| 94 | data->core_ncc = atoi(argv[0]); |
| 95 | return CMD_SUCCESS; |
| 96 | } |
| 97 | |
Holger Hans Peter Freyther | f43e3db | 2010-11-03 13:21:02 +0100 | [diff] [blame] | 98 | DEFUN(cfg_net_bsc_rtp_payload, |
| 99 | cfg_net_bsc_rtp_payload_cmd, |
| 100 | "ip.access rtp-payload <0-255>", |
Holger Hans Peter Freyther | 7dcd8e3 | 2010-11-03 13:32:48 +0100 | [diff] [blame^] | 101 | IPA_STR |
Holger Hans Peter Freyther | f43e3db | 2010-11-03 13:21:02 +0100 | [diff] [blame] | 102 | "Set the rtp-payload for the RTP stream\n" |
| 103 | "RTP payload number\n") |
| 104 | { |
| 105 | struct osmo_msc_data *data = osmo_msc_data(vty); |
| 106 | data->rtp_payload = atoi(argv[0]); |
| 107 | return CMD_SUCCESS; |
| 108 | } |
| 109 | |
Holger Hans Peter Freyther | 7dcd8e3 | 2010-11-03 13:32:48 +0100 | [diff] [blame^] | 110 | DEFUN(cfg_net_bsc_rtp_base, |
| 111 | cfg_net_bsc_rtp_base_cmd, |
| 112 | "ip.access rtp-base <1-65000>", |
| 113 | IPA_STR |
| 114 | "Set the rtp-base port for the RTP stream\n" |
| 115 | "Port number\n") |
| 116 | { |
| 117 | struct osmo_msc_data *data = osmo_msc_data(vty); |
| 118 | data->rtp_base = atoi(argv[0]); |
| 119 | return CMD_SUCCESS; |
| 120 | } |
| 121 | |
Holger Hans Peter Freyther | 8c4dca2 | 2010-09-15 23:28:49 +0800 | [diff] [blame] | 122 | DEFUN(cfg_net_msc_ip, |
| 123 | cfg_net_msc_ip_cmd, |
| 124 | "ip A.B.C.D", "Set the MSC/MUX IP address.") |
| 125 | { |
| 126 | struct osmo_msc_data *data = osmo_msc_data(vty); |
Holger Hans Peter Freyther | 8c4dca2 | 2010-09-15 23:28:49 +0800 | [diff] [blame] | 127 | |
Holger Hans Peter Freyther | 7c831f6 | 2010-10-12 23:21:54 +0200 | [diff] [blame] | 128 | bsc_replace_string(data, &data->msc_ip, argv[0]); |
Holger Hans Peter Freyther | 8c4dca2 | 2010-09-15 23:28:49 +0800 | [diff] [blame] | 129 | return CMD_SUCCESS; |
| 130 | } |
| 131 | |
| 132 | DEFUN(cfg_net_msc_port, |
| 133 | cfg_net_msc_port_cmd, |
| 134 | "port <1-65000>", |
| 135 | "Set the MSC/MUX port.") |
| 136 | { |
| 137 | struct osmo_msc_data *data = osmo_msc_data(vty); |
| 138 | data->msc_port = atoi(argv[0]); |
| 139 | return CMD_SUCCESS; |
| 140 | } |
| 141 | |
| 142 | |
| 143 | DEFUN(cfg_net_msc_prio, |
| 144 | cfg_net_msc_prio_cmd, |
| 145 | "ip-dscp <0-255>", |
| 146 | "Set the IP_TOS socket attribite") |
| 147 | { |
| 148 | struct osmo_msc_data *data = osmo_msc_data(vty); |
| 149 | data->msc_ip_dscp = atoi(argv[0]); |
| 150 | return CMD_SUCCESS; |
| 151 | } |
| 152 | |
| 153 | DEFUN(cfg_net_msc_ping_time, |
| 154 | cfg_net_msc_ping_time_cmd, |
| 155 | "timeout-ping NR", |
| 156 | "Set the PING interval, negative for not sending PING") |
| 157 | { |
| 158 | struct osmo_msc_data *data = osmo_msc_data(vty); |
| 159 | data->ping_timeout = atoi(argv[0]); |
| 160 | return CMD_SUCCESS; |
| 161 | } |
| 162 | |
| 163 | DEFUN(cfg_net_msc_pong_time, |
| 164 | cfg_net_msc_pong_time_cmd, |
| 165 | "timeout-pong NR", |
| 166 | "Set the time to wait for a PONG.") |
| 167 | { |
| 168 | struct osmo_msc_data *data = osmo_msc_data(vty); |
| 169 | data->pong_timeout = atoi(argv[0]); |
| 170 | return CMD_SUCCESS; |
| 171 | } |
| 172 | |
| 173 | DEFUN(cfg_net_msc_grace_ussd, |
| 174 | cfg_net_msc_grace_ussd_cmd, |
| 175 | "bsc-grace-text .TEXT", |
| 176 | "Set the USSD notifcation to be send.\n" "Text to be sent\n") |
| 177 | { |
| 178 | struct osmo_msc_data *data = osmo_msc_data(vty); |
| 179 | char *txt = argv_concat(argv, argc, 1); |
| 180 | if (!txt) |
| 181 | return CMD_WARNING; |
| 182 | |
Holger Hans Peter Freyther | 7c831f6 | 2010-10-12 23:21:54 +0200 | [diff] [blame] | 183 | bsc_replace_string(data, &data->ussd_grace_txt, txt); |
Holger Hans Peter Freyther | 8c4dca2 | 2010-09-15 23:28:49 +0800 | [diff] [blame] | 184 | talloc_free(txt); |
| 185 | return CMD_SUCCESS; |
| 186 | } |
Holger Hans Peter Freyther | 58ef6e4 | 2010-06-30 14:59:23 +0800 | [diff] [blame] | 187 | |
| 188 | int bsc_vty_init_extra(void) |
| 189 | { |
Holger Hans Peter Freyther | 8c4dca2 | 2010-09-15 23:28:49 +0800 | [diff] [blame] | 190 | install_element(GSMNET_NODE, &cfg_net_msc_cmd); |
| 191 | install_node(&msc_node, config_write_msc); |
| 192 | install_default(MSC_NODE); |
| 193 | install_element(MSC_NODE, &cfg_net_bsc_token_cmd); |
Holger Hans Peter Freyther | 21a1cf3 | 2010-11-03 13:12:18 +0100 | [diff] [blame] | 194 | install_element(MSC_NODE, &cfg_net_bsc_ncc_cmd); |
Holger Hans Peter Freyther | f43e3db | 2010-11-03 13:21:02 +0100 | [diff] [blame] | 195 | install_element(MSC_NODE, &cfg_net_bsc_rtp_payload_cmd); |
Holger Hans Peter Freyther | 7dcd8e3 | 2010-11-03 13:32:48 +0100 | [diff] [blame^] | 196 | install_element(MSC_NODE, &cfg_net_bsc_rtp_base_cmd); |
Holger Hans Peter Freyther | 8c4dca2 | 2010-09-15 23:28:49 +0800 | [diff] [blame] | 197 | install_element(MSC_NODE, &cfg_net_msc_ip_cmd); |
| 198 | install_element(MSC_NODE, &cfg_net_msc_port_cmd); |
| 199 | install_element(MSC_NODE, &cfg_net_msc_prio_cmd); |
| 200 | install_element(MSC_NODE, &cfg_net_msc_ping_time_cmd); |
| 201 | install_element(MSC_NODE, &cfg_net_msc_pong_time_cmd); |
| 202 | install_element(MSC_NODE, &cfg_net_msc_grace_ussd_cmd); |
| 203 | |
Holger Hans Peter Freyther | 58ef6e4 | 2010-06-30 14:59:23 +0800 | [diff] [blame] | 204 | return 0; |
| 205 | } |