Holger Hans Peter Freyther | cacbc73 | 2010-06-30 14:59:23 +0800 | [diff] [blame] | 1 | /* Osmo BSC VTY Configuration */ |
Holger Hans Peter Freyther | 55ef5fb | 2011-04-07 23:23:27 +0200 | [diff] [blame] | 2 | /* (C) 2009-2011 by Holger Hans Peter Freyther |
Holger Hans Peter Freyther | e1880105 | 2011-04-23 23:31:31 +0200 | [diff] [blame] | 3 | * (C) 2009-2011 by On-Waves |
Holger Hans Peter Freyther | cacbc73 | 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 |
Harald Welte | 9af6ddf | 2011-01-01 15:25:50 +0100 | [diff] [blame] | 7 | * it under the terms of the GNU Affero General Public License as published by |
| 8 | * the Free Software Foundation; either version 3 of the License, or |
Holger Hans Peter Freyther | cacbc73 | 2010-06-30 14:59:23 +0800 | [diff] [blame] | 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 |
Harald Welte | 9af6ddf | 2011-01-01 15:25:50 +0100 | [diff] [blame] | 14 | * GNU Affero General Public License for more details. |
Holger Hans Peter Freyther | cacbc73 | 2010-06-30 14:59:23 +0800 | [diff] [blame] | 15 | * |
Harald Welte | 9af6ddf | 2011-01-01 15:25:50 +0100 | [diff] [blame] | 16 | * You should have received a copy of the GNU Affero General Public License |
| 17 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
Holger Hans Peter Freyther | cacbc73 | 2010-06-30 14:59:23 +0800 | [diff] [blame] | 18 | * |
| 19 | */ |
| 20 | |
Holger Hans Peter Freyther | 47b2601 | 2010-09-15 23:28:49 +0800 | [diff] [blame] | 21 | #include <openbsc/gsm_data.h> |
| 22 | #include <openbsc/osmo_msc_data.h> |
| 23 | #include <openbsc/vty.h> |
| 24 | |
Pablo Neira Ayuso | 136f453 | 2011-03-22 16:47:59 +0100 | [diff] [blame] | 25 | #include <osmocom/core/talloc.h> |
Holger Hans Peter Freyther | 47b2601 | 2010-09-15 23:28:49 +0800 | [diff] [blame] | 26 | |
Holger Hans Peter Freyther | fe16622 | 2010-11-03 13:32:48 +0100 | [diff] [blame] | 27 | |
| 28 | #define IPA_STR "IP.ACCESS specific\n" |
| 29 | |
Holger Hans Peter Freyther | 47b2601 | 2010-09-15 23:28:49 +0800 | [diff] [blame] | 30 | extern struct gsm_network *bsc_gsmnet; |
| 31 | |
Holger Hans Peter Freyther | 8ec4952 | 2011-08-15 15:53:00 +0200 | [diff] [blame] | 32 | static struct osmo_bsc_data *osmo_bsc_data(struct vty *vty) |
| 33 | { |
| 34 | return bsc_gsmnet->bsc_data; |
| 35 | } |
| 36 | |
Holger Hans Peter Freyther | 47b2601 | 2010-09-15 23:28:49 +0800 | [diff] [blame] | 37 | static struct osmo_msc_data *osmo_msc_data(struct vty *vty) |
| 38 | { |
Holger Hans Peter Freyther | 20fea24 | 2011-06-04 19:58:26 +0200 | [diff] [blame] | 39 | return osmo_msc_data_find(bsc_gsmnet, (int) vty->index); |
Holger Hans Peter Freyther | 47b2601 | 2010-09-15 23:28:49 +0800 | [diff] [blame] | 40 | } |
| 41 | |
Holger Hans Peter Freyther | 8b902d7 | 2011-06-04 20:22:49 +0200 | [diff] [blame] | 42 | static struct cmd_node bsc_node = { |
| 43 | BSC_NODE, |
| 44 | "%s(bsc)#", |
| 45 | 1, |
| 46 | }; |
| 47 | |
Holger Hans Peter Freyther | 47b2601 | 2010-09-15 23:28:49 +0800 | [diff] [blame] | 48 | static struct cmd_node msc_node = { |
| 49 | MSC_NODE, |
Harald Welte | 570ce24 | 2012-08-17 13:16:10 +0200 | [diff] [blame] | 50 | "%s(config-msc)# ", |
Holger Hans Peter Freyther | 47b2601 | 2010-09-15 23:28:49 +0800 | [diff] [blame] | 51 | 1, |
| 52 | }; |
| 53 | |
| 54 | DEFUN(cfg_net_msc, cfg_net_msc_cmd, |
Holger Hans Peter Freyther | 8b902d7 | 2011-06-04 20:22:49 +0200 | [diff] [blame] | 55 | "msc [<0-1000>]", "Configure MSC details\n" "MSC connection to configure\n") |
Holger Hans Peter Freyther | 47b2601 | 2010-09-15 23:28:49 +0800 | [diff] [blame] | 56 | { |
Holger Hans Peter Freyther | 8b902d7 | 2011-06-04 20:22:49 +0200 | [diff] [blame] | 57 | int index = argc == 1 ? atoi(argv[0]) : 0; |
Holger Hans Peter Freyther | 20fea24 | 2011-06-04 19:58:26 +0200 | [diff] [blame] | 58 | struct osmo_msc_data *msc; |
Holger Hans Peter Freyther | 47b2601 | 2010-09-15 23:28:49 +0800 | [diff] [blame] | 59 | |
Holger Hans Peter Freyther | 20fea24 | 2011-06-04 19:58:26 +0200 | [diff] [blame] | 60 | msc = osmo_msc_data_alloc(bsc_gsmnet, index); |
| 61 | if (!msc) { |
| 62 | vty_out(vty, "%%Failed to allocate MSC data.%s", VTY_NEWLINE); |
| 63 | return CMD_WARNING; |
| 64 | } |
| 65 | |
| 66 | vty->index = (void *) index; |
| 67 | vty->node = MSC_NODE; |
Holger Hans Peter Freyther | 47b2601 | 2010-09-15 23:28:49 +0800 | [diff] [blame] | 68 | return CMD_SUCCESS; |
| 69 | } |
| 70 | |
Holger Hans Peter Freyther | 8b902d7 | 2011-06-04 20:22:49 +0200 | [diff] [blame] | 71 | DEFUN(cfg_net_bsc, cfg_net_bsc_cmd, |
| 72 | "bsc", "Configure BSC\n") |
| 73 | { |
| 74 | vty->node = BSC_NODE; |
| 75 | return CMD_SUCCESS; |
| 76 | } |
| 77 | |
Holger Hans Peter Freyther | 20fea24 | 2011-06-04 19:58:26 +0200 | [diff] [blame] | 78 | static void write_msc(struct vty *vty, struct osmo_msc_data *msc) |
Holger Hans Peter Freyther | 47b2601 | 2010-09-15 23:28:49 +0800 | [diff] [blame] | 79 | { |
Holger Hans Peter Freyther | e1880105 | 2011-04-23 23:31:31 +0200 | [diff] [blame] | 80 | struct bsc_msc_dest *dest; |
Holger Hans Peter Freyther | 47b2601 | 2010-09-15 23:28:49 +0800 | [diff] [blame] | 81 | |
Holger Hans Peter Freyther | 8b902d7 | 2011-06-04 20:22:49 +0200 | [diff] [blame] | 82 | vty_out(vty, "msc %d%s", msc->nr, VTY_NEWLINE); |
Holger Hans Peter Freyther | 8ec4952 | 2011-08-15 15:53:00 +0200 | [diff] [blame] | 83 | if (msc->bsc_token) |
| 84 | vty_out(vty, " token %s%s", msc->bsc_token, VTY_NEWLINE); |
| 85 | if (msc->core_ncc != -1) |
Holger Hans Peter Freyther | 06f4fc7 | 2011-03-29 17:46:14 +0200 | [diff] [blame] | 86 | vty_out(vty, " core-mobile-network-code %d%s", |
Holger Hans Peter Freyther | 8ec4952 | 2011-08-15 15:53:00 +0200 | [diff] [blame] | 87 | msc->core_ncc, VTY_NEWLINE); |
| 88 | if (msc->core_mcc != -1) |
Holger Hans Peter Freyther | 06f4fc7 | 2011-03-29 17:46:14 +0200 | [diff] [blame] | 89 | vty_out(vty, " core-mobile-country-code %d%s", |
Holger Hans Peter Freyther | 8ec4952 | 2011-08-15 15:53:00 +0200 | [diff] [blame] | 90 | msc->core_mcc, VTY_NEWLINE); |
| 91 | vty_out(vty, " ip.access rtp-base %d%s", msc->rtp_base, VTY_NEWLINE); |
| 92 | vty_out(vty, " timeout-ping %d%s", msc->ping_timeout, VTY_NEWLINE); |
| 93 | vty_out(vty, " timeout-pong %d%s", msc->pong_timeout, VTY_NEWLINE); |
| 94 | if (msc->ussd_welcome_txt) |
| 95 | vty_out(vty, " bsc-welcome-text %s%s", msc->ussd_welcome_txt, VTY_NEWLINE); |
Holger Hans Peter Freyther | 47b2601 | 2010-09-15 23:28:49 +0800 | [diff] [blame] | 96 | |
Holger Hans Peter Freyther | 8ec4952 | 2011-08-15 15:53:00 +0200 | [diff] [blame] | 97 | if (msc->audio_length != 0) { |
Holger Hans Peter Freyther | 7bf66c5 | 2010-11-03 13:55:49 +0100 | [diff] [blame] | 98 | int i; |
| 99 | |
Holger Hans Peter Freyther | 06f4fc7 | 2011-03-29 17:46:14 +0200 | [diff] [blame] | 100 | vty_out(vty, " codec-list "); |
Holger Hans Peter Freyther | 8ec4952 | 2011-08-15 15:53:00 +0200 | [diff] [blame] | 101 | for (i = 0; i < msc->audio_length; ++i) { |
Holger Hans Peter Freyther | 7bf66c5 | 2010-11-03 13:55:49 +0100 | [diff] [blame] | 102 | if (i != 0) |
| 103 | vty_out(vty, ", "); |
| 104 | |
Holger Hans Peter Freyther | 8ec4952 | 2011-08-15 15:53:00 +0200 | [diff] [blame] | 105 | if (msc->audio_support[i]->hr) |
| 106 | vty_out(vty, "hr%.1u", msc->audio_support[i]->ver); |
Holger Hans Peter Freyther | 7bf66c5 | 2010-11-03 13:55:49 +0100 | [diff] [blame] | 107 | else |
Holger Hans Peter Freyther | 8ec4952 | 2011-08-15 15:53:00 +0200 | [diff] [blame] | 108 | vty_out(vty, "fr%.1u", msc->audio_support[i]->ver); |
Holger Hans Peter Freyther | 7bf66c5 | 2010-11-03 13:55:49 +0100 | [diff] [blame] | 109 | } |
| 110 | vty_out(vty, "%s", VTY_NEWLINE); |
| 111 | |
| 112 | } |
| 113 | |
Holger Hans Peter Freyther | 8ec4952 | 2011-08-15 15:53:00 +0200 | [diff] [blame] | 114 | llist_for_each_entry(dest, &msc->dests, list) |
Holger Hans Peter Freyther | e1880105 | 2011-04-23 23:31:31 +0200 | [diff] [blame] | 115 | vty_out(vty, " dest %s %d %d%s", dest->ip, dest->port, |
| 116 | dest->dscp, VTY_NEWLINE); |
Holger Hans Peter Freyther | 20fea24 | 2011-06-04 19:58:26 +0200 | [diff] [blame] | 117 | } |
| 118 | |
| 119 | static int config_write_msc(struct vty *vty) |
| 120 | { |
| 121 | struct osmo_msc_data *msc; |
| 122 | struct osmo_bsc_data *bsc = osmo_bsc_data(vty); |
| 123 | |
| 124 | llist_for_each_entry(msc, &bsc->mscs, entry) |
| 125 | write_msc(vty, msc); |
Holger Hans Peter Freyther | e1880105 | 2011-04-23 23:31:31 +0200 | [diff] [blame] | 126 | |
Holger Hans Peter Freyther | 8b902d7 | 2011-06-04 20:22:49 +0200 | [diff] [blame] | 127 | return CMD_SUCCESS; |
| 128 | } |
| 129 | |
| 130 | static int config_write_bsc(struct vty *vty) |
| 131 | { |
| 132 | struct osmo_bsc_data *bsc = osmo_bsc_data(vty); |
| 133 | |
| 134 | vty_out(vty, "bsc%s", VTY_NEWLINE); |
Holger Hans Peter Freyther | 8ec4952 | 2011-08-15 15:53:00 +0200 | [diff] [blame] | 135 | if (bsc->mid_call_txt) |
| 136 | vty_out(vty, " mid-call-text %s%s", bsc->mid_call_txt, VTY_NEWLINE); |
| 137 | vty_out(vty, " mid-call-timeout %d%s", bsc->mid_call_timeout, VTY_NEWLINE); |
| 138 | if (bsc->rf_ctrl_name) |
| 139 | vty_out(vty, " bsc-rf-socket %s%s", |
| 140 | bsc->rf_ctrl_name, VTY_NEWLINE); |
| 141 | |
Holger Hans Peter Freyther | 47b2601 | 2010-09-15 23:28:49 +0800 | [diff] [blame] | 142 | return CMD_SUCCESS; |
| 143 | } |
| 144 | |
Holger Hans Peter Freyther | 5b848f3 | 2010-11-03 13:11:14 +0100 | [diff] [blame] | 145 | DEFUN(cfg_net_bsc_token, |
Holger Hans Peter Freyther | 47b2601 | 2010-09-15 23:28:49 +0800 | [diff] [blame] | 146 | cfg_net_bsc_token_cmd, |
| 147 | "token TOKEN", |
| 148 | "A token for the BSC to be sent to the MSC") |
| 149 | { |
| 150 | struct osmo_msc_data *data = osmo_msc_data(vty); |
| 151 | |
Holger Hans Peter Freyther | 8ec4952 | 2011-08-15 15:53:00 +0200 | [diff] [blame] | 152 | bsc_replace_string(osmo_bsc_data(vty), &data->bsc_token, argv[0]); |
Holger Hans Peter Freyther | 47b2601 | 2010-09-15 23:28:49 +0800 | [diff] [blame] | 153 | return CMD_SUCCESS; |
| 154 | } |
| 155 | |
Holger Hans Peter Freyther | 4de1116 | 2010-11-03 13:12:18 +0100 | [diff] [blame] | 156 | DEFUN(cfg_net_bsc_ncc, |
| 157 | cfg_net_bsc_ncc_cmd, |
Holger Hans Peter Freyther | 6e1a676 | 2011-02-10 11:37:13 +0100 | [diff] [blame] | 158 | "core-mobile-network-code <1-999>", |
Holger Hans Peter Freyther | 4de1116 | 2010-11-03 13:12:18 +0100 | [diff] [blame] | 159 | "Use this network code for the backbone\n" "NCC value\n") |
| 160 | { |
| 161 | struct osmo_msc_data *data = osmo_msc_data(vty); |
| 162 | data->core_ncc = atoi(argv[0]); |
| 163 | return CMD_SUCCESS; |
| 164 | } |
| 165 | |
Holger Hans Peter Freyther | 2a8675e | 2010-11-05 19:43:07 +0100 | [diff] [blame] | 166 | DEFUN(cfg_net_bsc_mcc, |
| 167 | cfg_net_bsc_mcc_cmd, |
Holger Hans Peter Freyther | 6e1a676 | 2011-02-10 11:37:13 +0100 | [diff] [blame] | 168 | "core-mobile-country-code <1-999>", |
Holger Hans Peter Freyther | 2a8675e | 2010-11-05 19:43:07 +0100 | [diff] [blame] | 169 | "Use this country code for the backbone\n" "MCC value\n") |
| 170 | { |
| 171 | struct osmo_msc_data *data = osmo_msc_data(vty); |
| 172 | data->core_mcc = atoi(argv[0]); |
| 173 | return CMD_SUCCESS; |
| 174 | } |
| 175 | |
Holger Hans Peter Freyther | fe16622 | 2010-11-03 13:32:48 +0100 | [diff] [blame] | 176 | DEFUN(cfg_net_bsc_rtp_base, |
| 177 | cfg_net_bsc_rtp_base_cmd, |
| 178 | "ip.access rtp-base <1-65000>", |
| 179 | IPA_STR |
| 180 | "Set the rtp-base port for the RTP stream\n" |
| 181 | "Port number\n") |
| 182 | { |
| 183 | struct osmo_msc_data *data = osmo_msc_data(vty); |
| 184 | data->rtp_base = atoi(argv[0]); |
| 185 | return CMD_SUCCESS; |
| 186 | } |
| 187 | |
Holger Hans Peter Freyther | 7bf66c5 | 2010-11-03 13:55:49 +0100 | [diff] [blame] | 188 | DEFUN(cfg_net_bsc_codec_list, |
| 189 | cfg_net_bsc_codec_list_cmd, |
| 190 | "codec-list .LIST", |
| 191 | "Set the allowed audio codecs\n" |
| 192 | "List of audio codecs\n") |
| 193 | { |
| 194 | struct osmo_msc_data *data = osmo_msc_data(vty); |
| 195 | int saw_fr, saw_hr; |
| 196 | int i; |
| 197 | |
| 198 | saw_fr = saw_hr = 0; |
| 199 | |
| 200 | /* free the old list... if it exists */ |
| 201 | if (data->audio_support) { |
| 202 | talloc_free(data->audio_support); |
| 203 | data->audio_support = NULL; |
| 204 | data->audio_length = 0; |
| 205 | } |
| 206 | |
| 207 | /* create a new array */ |
| 208 | data->audio_support = |
Holger Hans Peter Freyther | 8ec4952 | 2011-08-15 15:53:00 +0200 | [diff] [blame] | 209 | talloc_zero_array(osmo_bsc_data(vty), struct gsm_audio_support *, argc); |
Holger Hans Peter Freyther | 7bf66c5 | 2010-11-03 13:55:49 +0100 | [diff] [blame] | 210 | data->audio_length = argc; |
| 211 | |
| 212 | for (i = 0; i < argc; ++i) { |
| 213 | /* check for hrX or frX */ |
| 214 | if (strlen(argv[i]) != 3 |
| 215 | || argv[i][1] != 'r' |
| 216 | || (argv[i][0] != 'h' && argv[i][0] != 'f') |
| 217 | || argv[i][2] < 0x30 |
| 218 | || argv[i][2] > 0x39) |
| 219 | goto error; |
| 220 | |
| 221 | data->audio_support[i] = talloc_zero(data->audio_support, |
| 222 | struct gsm_audio_support); |
| 223 | data->audio_support[i]->ver = atoi(argv[i] + 2); |
| 224 | |
| 225 | if (strncmp("hr", argv[i], 2) == 0) { |
| 226 | data->audio_support[i]->hr = 1; |
| 227 | saw_hr = 1; |
| 228 | } else if (strncmp("fr", argv[i], 2) == 0) { |
| 229 | data->audio_support[i]->hr = 0; |
| 230 | saw_fr = 1; |
| 231 | } |
| 232 | |
| 233 | if (saw_hr && saw_fr) { |
| 234 | vty_out(vty, "Can not have full-rate and half-rate codec.%s", |
| 235 | VTY_NEWLINE); |
| 236 | return CMD_ERR_INCOMPLETE; |
| 237 | } |
| 238 | } |
| 239 | |
| 240 | return CMD_SUCCESS; |
| 241 | |
| 242 | error: |
| 243 | vty_out(vty, "Codec name must be hrX or frX. Was '%s'%s", |
| 244 | argv[i], VTY_NEWLINE); |
| 245 | return CMD_ERR_INCOMPLETE; |
| 246 | } |
| 247 | |
Holger Hans Peter Freyther | e1880105 | 2011-04-23 23:31:31 +0200 | [diff] [blame] | 248 | DEFUN(cfg_net_msc_dest, |
| 249 | cfg_net_msc_dest_cmd, |
| 250 | "dest A.B.C.D <1-65000> <0-255>", |
| 251 | "Add a destination to a MUX/MSC\n" |
| 252 | "IP Address\n" "Port\n" "DSCP\n") |
Holger Hans Peter Freyther | 47b2601 | 2010-09-15 23:28:49 +0800 | [diff] [blame] | 253 | { |
Holger Hans Peter Freyther | e1880105 | 2011-04-23 23:31:31 +0200 | [diff] [blame] | 254 | struct bsc_msc_dest *dest; |
Holger Hans Peter Freyther | 47b2601 | 2010-09-15 23:28:49 +0800 | [diff] [blame] | 255 | struct osmo_msc_data *data = osmo_msc_data(vty); |
Holger Hans Peter Freyther | 47b2601 | 2010-09-15 23:28:49 +0800 | [diff] [blame] | 256 | |
Holger Hans Peter Freyther | 8ec4952 | 2011-08-15 15:53:00 +0200 | [diff] [blame] | 257 | dest = talloc_zero(osmo_bsc_data(vty), struct bsc_msc_dest); |
Holger Hans Peter Freyther | e1880105 | 2011-04-23 23:31:31 +0200 | [diff] [blame] | 258 | if (!dest) { |
| 259 | vty_out(vty, "%%Failed to create structure.%s", VTY_NEWLINE); |
| 260 | return CMD_WARNING; |
| 261 | } |
| 262 | |
Holger Hans Peter Freyther | 8ec4952 | 2011-08-15 15:53:00 +0200 | [diff] [blame] | 263 | dest->ip = talloc_strdup(dest, argv[0]); |
Holger Hans Peter Freyther | e1880105 | 2011-04-23 23:31:31 +0200 | [diff] [blame] | 264 | if (!dest->ip) { |
| 265 | vty_out(vty, "%%Failed to copy dest ip.%s", VTY_NEWLINE); |
| 266 | talloc_free(dest); |
| 267 | return CMD_WARNING; |
| 268 | } |
| 269 | |
| 270 | dest->port = atoi(argv[1]); |
| 271 | dest->dscp = atoi(argv[2]); |
| 272 | llist_add_tail(&dest->list, &data->dests); |
Holger Hans Peter Freyther | 47b2601 | 2010-09-15 23:28:49 +0800 | [diff] [blame] | 273 | return CMD_SUCCESS; |
| 274 | } |
| 275 | |
Holger Hans Peter Freyther | e1880105 | 2011-04-23 23:31:31 +0200 | [diff] [blame] | 276 | DEFUN(cfg_net_msc_no_dest, |
| 277 | cfg_net_msc_no_dest_cmd, |
| 278 | "no dest A.B.C.D <1-65000> <0-255>", |
| 279 | NO_STR "Remove a destination to a MUX/MSC\n" |
| 280 | "IP Address\n" "Port\n" "DSCP\n") |
Holger Hans Peter Freyther | 47b2601 | 2010-09-15 23:28:49 +0800 | [diff] [blame] | 281 | { |
Holger Hans Peter Freyther | e1880105 | 2011-04-23 23:31:31 +0200 | [diff] [blame] | 282 | struct bsc_msc_dest *dest, *tmp; |
Holger Hans Peter Freyther | 47b2601 | 2010-09-15 23:28:49 +0800 | [diff] [blame] | 283 | struct osmo_msc_data *data = osmo_msc_data(vty); |
Holger Hans Peter Freyther | 47b2601 | 2010-09-15 23:28:49 +0800 | [diff] [blame] | 284 | |
Holger Hans Peter Freyther | e1880105 | 2011-04-23 23:31:31 +0200 | [diff] [blame] | 285 | int port = atoi(argv[1]); |
| 286 | int dscp = atoi(argv[2]); |
Holger Hans Peter Freyther | 47b2601 | 2010-09-15 23:28:49 +0800 | [diff] [blame] | 287 | |
Holger Hans Peter Freyther | e1880105 | 2011-04-23 23:31:31 +0200 | [diff] [blame] | 288 | llist_for_each_entry_safe(dest, tmp, &data->dests, list) { |
| 289 | if (port != dest->port || dscp != dest->dscp |
| 290 | || strcmp(dest->ip, argv[0]) != 0) |
| 291 | continue; |
| 292 | |
| 293 | llist_del(&dest->list); |
| 294 | talloc_free(dest); |
| 295 | } |
| 296 | |
Holger Hans Peter Freyther | 47b2601 | 2010-09-15 23:28:49 +0800 | [diff] [blame] | 297 | return CMD_SUCCESS; |
| 298 | } |
| 299 | |
| 300 | DEFUN(cfg_net_msc_ping_time, |
| 301 | cfg_net_msc_ping_time_cmd, |
| 302 | "timeout-ping NR", |
| 303 | "Set the PING interval, negative for not sending PING") |
| 304 | { |
| 305 | struct osmo_msc_data *data = osmo_msc_data(vty); |
| 306 | data->ping_timeout = atoi(argv[0]); |
| 307 | return CMD_SUCCESS; |
| 308 | } |
| 309 | |
| 310 | DEFUN(cfg_net_msc_pong_time, |
| 311 | cfg_net_msc_pong_time_cmd, |
| 312 | "timeout-pong NR", |
| 313 | "Set the time to wait for a PONG.") |
| 314 | { |
| 315 | struct osmo_msc_data *data = osmo_msc_data(vty); |
| 316 | data->pong_timeout = atoi(argv[0]); |
| 317 | return CMD_SUCCESS; |
| 318 | } |
| 319 | |
Holger Hans Peter Freyther | 8b902d7 | 2011-06-04 20:22:49 +0200 | [diff] [blame] | 320 | DEFUN(cfg_net_msc_welcome_ussd, |
| 321 | cfg_net_msc_welcome_ussd_cmd, |
| 322 | "bsc-welcome-text .TEXT", |
| 323 | "Set the USSD notification to be sent.\n" "Text to be sent\n") |
| 324 | { |
| 325 | struct osmo_msc_data *data = osmo_msc_data(vty); |
| 326 | char *str = argv_concat(argv, argc, 0); |
| 327 | if (!str) |
| 328 | return CMD_WARNING; |
| 329 | |
| 330 | bsc_replace_string(osmo_bsc_data(vty), &data->ussd_welcome_txt, str); |
| 331 | talloc_free(str); |
| 332 | return CMD_SUCCESS; |
| 333 | } |
| 334 | |
| 335 | DEFUN(cfg_net_bsc_mid_call_text, |
| 336 | cfg_net_bsc_mid_call_text_cmd, |
Holger Hans Peter Freyther | bb62b3f | 2010-11-22 18:30:21 +0100 | [diff] [blame] | 337 | "mid-call-text .TEXT", |
Holger Hans Peter Freyther | 47b2601 | 2010-09-15 23:28:49 +0800 | [diff] [blame] | 338 | "Set the USSD notifcation to be send.\n" "Text to be sent\n") |
| 339 | { |
Holger Hans Peter Freyther | 8ec4952 | 2011-08-15 15:53:00 +0200 | [diff] [blame] | 340 | struct osmo_bsc_data *data = osmo_bsc_data(vty); |
Holger Hans Peter Freyther | 414bc4a | 2010-11-22 22:27:39 +0100 | [diff] [blame] | 341 | char *txt = argv_concat(argv, argc, 0); |
Holger Hans Peter Freyther | 47b2601 | 2010-09-15 23:28:49 +0800 | [diff] [blame] | 342 | if (!txt) |
| 343 | return CMD_WARNING; |
| 344 | |
Holger Hans Peter Freyther | bb62b3f | 2010-11-22 18:30:21 +0100 | [diff] [blame] | 345 | bsc_replace_string(data, &data->mid_call_txt, txt); |
Holger Hans Peter Freyther | 47b2601 | 2010-09-15 23:28:49 +0800 | [diff] [blame] | 346 | talloc_free(txt); |
| 347 | return CMD_SUCCESS; |
| 348 | } |
Holger Hans Peter Freyther | cacbc73 | 2010-06-30 14:59:23 +0800 | [diff] [blame] | 349 | |
Holger Hans Peter Freyther | 8b902d7 | 2011-06-04 20:22:49 +0200 | [diff] [blame] | 350 | DEFUN(cfg_net_bsc_mid_call_timeout, |
| 351 | cfg_net_bsc_mid_call_timeout_cmd, |
Holger Hans Peter Freyther | bb62b3f | 2010-11-22 18:30:21 +0100 | [diff] [blame] | 352 | "mid-call-timeout NR", |
Holger Hans Peter Freyther | 625b6e4 | 2010-11-22 18:25:02 +0100 | [diff] [blame] | 353 | "Switch from Grace to Off in NR seconds.\n" "Timeout in seconds\n") |
| 354 | { |
Holger Hans Peter Freyther | 8ec4952 | 2011-08-15 15:53:00 +0200 | [diff] [blame] | 355 | struct osmo_bsc_data *data = osmo_bsc_data(vty); |
Holger Hans Peter Freyther | bb62b3f | 2010-11-22 18:30:21 +0100 | [diff] [blame] | 356 | data->mid_call_timeout = atoi(argv[0]); |
Holger Hans Peter Freyther | 625b6e4 | 2010-11-22 18:25:02 +0100 | [diff] [blame] | 357 | return CMD_SUCCESS; |
| 358 | } |
| 359 | |
Holger Hans Peter Freyther | 55ef5fb | 2011-04-07 23:23:27 +0200 | [diff] [blame] | 360 | DEFUN(cfg_net_rf_socket, |
| 361 | cfg_net_rf_socket_cmd, |
| 362 | "bsc-rf-socket PATH", |
| 363 | "Set the filename for the RF control interface.\n" "RF Control path\n") |
| 364 | { |
Holger Hans Peter Freyther | 8ec4952 | 2011-08-15 15:53:00 +0200 | [diff] [blame] | 365 | struct osmo_bsc_data *data = osmo_bsc_data(vty); |
Holger Hans Peter Freyther | 55ef5fb | 2011-04-07 23:23:27 +0200 | [diff] [blame] | 366 | |
| 367 | bsc_replace_string(data, &data->rf_ctrl_name, argv[0]); |
| 368 | return CMD_SUCCESS; |
| 369 | } |
| 370 | |
Holger Hans Peter Freyther | 286ba0e | 2011-05-03 18:12:39 +0200 | [diff] [blame] | 371 | DEFUN(show_statistics, |
| 372 | show_statistics_cmd, |
| 373 | "show statistics", |
| 374 | SHOW_STR "Statistics about the BSC\n") |
| 375 | { |
| 376 | openbsc_vty_print_statistics(vty, bsc_gsmnet); |
| 377 | return CMD_SUCCESS; |
| 378 | } |
| 379 | |
Holger Hans Peter Freyther | c50e04a | 2011-10-20 11:06:31 +0200 | [diff] [blame] | 380 | DEFUN(show_mscs, |
| 381 | show_mscs_cmd, |
| 382 | "show mscs", |
| 383 | SHOW_STR "MSC Connections and State\n") |
| 384 | { |
| 385 | struct osmo_msc_data *msc; |
| 386 | llist_for_each_entry(msc, &bsc_gsmnet->bsc_data->mscs, entry) { |
| 387 | vty_out(vty, "MSC Nr: %d is connected: %d auth: %d.%s", |
| 388 | msc->nr, |
| 389 | msc->msc_con ? msc->msc_con->is_connected : -1, |
| 390 | msc->msc_con ? msc->msc_con->is_authenticated : -1, |
| 391 | VTY_NEWLINE); |
| 392 | } |
| 393 | |
| 394 | return CMD_SUCCESS; |
| 395 | } |
| 396 | |
Holger Hans Peter Freyther | cacbc73 | 2010-06-30 14:59:23 +0800 | [diff] [blame] | 397 | int bsc_vty_init_extra(void) |
| 398 | { |
Holger Hans Peter Freyther | 06f4fc7 | 2011-03-29 17:46:14 +0200 | [diff] [blame] | 399 | install_element(CONFIG_NODE, &cfg_net_msc_cmd); |
Holger Hans Peter Freyther | 8b902d7 | 2011-06-04 20:22:49 +0200 | [diff] [blame] | 400 | install_element(CONFIG_NODE, &cfg_net_bsc_cmd); |
| 401 | |
| 402 | install_node(&bsc_node, config_write_bsc); |
| 403 | install_default(BSC_NODE); |
| 404 | install_element(BSC_NODE, &cfg_net_bsc_mid_call_text_cmd); |
| 405 | install_element(BSC_NODE, &cfg_net_bsc_mid_call_timeout_cmd); |
| 406 | install_element(BSC_NODE, &cfg_net_rf_socket_cmd); |
| 407 | |
| 408 | |
| 409 | |
Holger Hans Peter Freyther | 47b2601 | 2010-09-15 23:28:49 +0800 | [diff] [blame] | 410 | install_node(&msc_node, config_write_msc); |
| 411 | install_default(MSC_NODE); |
| 412 | install_element(MSC_NODE, &cfg_net_bsc_token_cmd); |
Holger Hans Peter Freyther | 4de1116 | 2010-11-03 13:12:18 +0100 | [diff] [blame] | 413 | install_element(MSC_NODE, &cfg_net_bsc_ncc_cmd); |
Holger Hans Peter Freyther | 2a8675e | 2010-11-05 19:43:07 +0100 | [diff] [blame] | 414 | install_element(MSC_NODE, &cfg_net_bsc_mcc_cmd); |
Holger Hans Peter Freyther | fe16622 | 2010-11-03 13:32:48 +0100 | [diff] [blame] | 415 | install_element(MSC_NODE, &cfg_net_bsc_rtp_base_cmd); |
Holger Hans Peter Freyther | 7bf66c5 | 2010-11-03 13:55:49 +0100 | [diff] [blame] | 416 | install_element(MSC_NODE, &cfg_net_bsc_codec_list_cmd); |
Holger Hans Peter Freyther | e1880105 | 2011-04-23 23:31:31 +0200 | [diff] [blame] | 417 | install_element(MSC_NODE, &cfg_net_msc_dest_cmd); |
| 418 | install_element(MSC_NODE, &cfg_net_msc_no_dest_cmd); |
Holger Hans Peter Freyther | 47b2601 | 2010-09-15 23:28:49 +0800 | [diff] [blame] | 419 | install_element(MSC_NODE, &cfg_net_msc_ping_time_cmd); |
| 420 | install_element(MSC_NODE, &cfg_net_msc_pong_time_cmd); |
Holger Hans Peter Freyther | 8ec4952 | 2011-08-15 15:53:00 +0200 | [diff] [blame] | 421 | install_element(MSC_NODE, &cfg_net_msc_welcome_ussd_cmd); |
| 422 | |
Holger Hans Peter Freyther | 286ba0e | 2011-05-03 18:12:39 +0200 | [diff] [blame] | 423 | install_element_ve(&show_statistics_cmd); |
Holger Hans Peter Freyther | c50e04a | 2011-10-20 11:06:31 +0200 | [diff] [blame] | 424 | install_element_ve(&show_mscs_cmd); |
Holger Hans Peter Freyther | 286ba0e | 2011-05-03 18:12:39 +0200 | [diff] [blame] | 425 | |
Holger Hans Peter Freyther | cacbc73 | 2010-06-30 14:59:23 +0800 | [diff] [blame] | 426 | return 0; |
| 427 | } |