Harald Welte | 59b0468 | 2009-06-10 05:40:52 +0800 | [diff] [blame] | 1 | /* OpenBSC interface to quagga VTY */ |
| 2 | /* (C) 2009 by Harald Welte <laforge@gnumonks.org> |
| 3 | * All Rights Reserved |
| 4 | * |
| 5 | * This program is free software; you can redistribute it and/or modify |
| 6 | * it under the terms of the GNU General Public License as published by |
| 7 | * the Free Software Foundation; either version 2 of the License, or |
| 8 | * (at your option) any later version. |
| 9 | * |
| 10 | * This program is distributed in the hope that it will be useful, |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | * GNU General Public License for more details. |
| 14 | * |
| 15 | * You should have received a copy of the GNU General Public License along |
| 16 | * with this program; if not, write to the Free Software Foundation, Inc., |
| 17 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
| 18 | * |
| 19 | */ |
| 20 | |
| 21 | #include <stdlib.h> |
| 22 | #include <unistd.h> |
| 23 | #include <sys/types.h> |
| 24 | |
| 25 | #include <vty/command.h> |
| 26 | #include <vty/vty.h> |
| 27 | |
| 28 | #include <arpa/inet.h> |
| 29 | |
| 30 | #include <openbsc/linuxlist.h> |
| 31 | #include <openbsc/gsm_data.h> |
| 32 | #include <openbsc/gsm_subscriber.h> |
| 33 | #include <openbsc/e1_input.h> |
| 34 | #include <openbsc/abis_nm.h> |
| 35 | #include <openbsc/db.h> |
| 36 | |
| 37 | static struct gsm_network *gsmnet; |
| 38 | |
| 39 | struct cmd_node bts_node = { |
| 40 | BTS_NODE, |
| 41 | "%s(bts)#", |
| 42 | 1, |
| 43 | }; |
| 44 | |
| 45 | struct cmd_node trx_node = { |
| 46 | TRX_NODE, |
| 47 | "%s(trx)#", |
| 48 | 1, |
| 49 | }; |
| 50 | |
| 51 | struct cmd_node ts_node = { |
| 52 | TS_NODE, |
| 53 | "%s(ts)#", |
| 54 | 1, |
| 55 | }; |
| 56 | |
| 57 | struct cmd_node subscr_node = { |
| 58 | SUBSCR_NODE, |
| 59 | "%s(subscriber)#", |
| 60 | 1, |
| 61 | }; |
| 62 | |
| 63 | static int dummy_config_write(struct vty *v) |
| 64 | { |
| 65 | return CMD_SUCCESS; |
| 66 | } |
| 67 | |
| 68 | static void net_dump_nmstate(struct vty *vty, struct gsm_nm_state *nms) |
| 69 | { |
| 70 | vty_out(vty,"Oper '%s', Admin %u, Avail '%s'%s", |
| 71 | nm_opstate_name(nms->operational), nms->administrative, |
| 72 | nm_avail_name(nms->availability), VTY_NEWLINE); |
| 73 | } |
| 74 | |
| 75 | static void net_dump_vty(struct vty *vty, struct gsm_network *net) |
| 76 | { |
| 77 | vty_out(vty, "BSC is on Country Code %u, Network Code %u " |
| 78 | "and has %u BTS%s", net->country_code, net->network_code, |
| 79 | net->num_bts, VTY_NEWLINE); |
| 80 | vty_out(vty, " Long network name: '%s'%s", |
| 81 | net->name_long, VTY_NEWLINE); |
| 82 | vty_out(vty, " Short network name: '%s'%s", |
| 83 | net->name_short, VTY_NEWLINE); |
| 84 | } |
| 85 | |
| 86 | DEFUN(show_net, show_net_cmd, "show network", |
| 87 | SHOW_STR "Display information about a GSM NETWORK\n") |
| 88 | { |
| 89 | struct gsm_network *net = gsmnet; |
| 90 | net_dump_vty(vty, net); |
| 91 | |
| 92 | return CMD_SUCCESS; |
| 93 | } |
| 94 | |
| 95 | static void e1isl_dump_vty(struct vty *vty, struct e1inp_sign_link *e1l) |
| 96 | { |
| 97 | struct e1inp_line *line; |
| 98 | |
| 99 | if (!e1l) { |
| 100 | vty_out(vty, " None%s", VTY_NEWLINE); |
| 101 | return; |
| 102 | } |
| 103 | |
| 104 | line = e1l->ts->line; |
| 105 | |
| 106 | vty_out(vty, " E1 Line %u, Type %s: Timeslot %u, Mode %s%s", |
| 107 | line->num, line->driver->name, e1l->ts->num, |
| 108 | e1inp_signtype_name(e1l->type), VTY_NEWLINE); |
| 109 | vty_out(vty, " E1 TEI %u, SAPI %u%s", |
| 110 | e1l->tei, e1l->sapi, VTY_NEWLINE); |
| 111 | } |
| 112 | |
| 113 | static void bts_dump_vty(struct vty *vty, struct gsm_bts *bts) |
| 114 | { |
Harald Welte | 91afe4c | 2009-06-20 18:15:19 +0200 | [diff] [blame] | 115 | vty_out(vty, "BTS %u is of %s type in band %s, has LAC %u, " |
| 116 | "BSIC %u, TSC %u and %u TRX%s", |
| 117 | bts->nr, btstype2str(bts->type), gsm_band_name(bts->band), |
| 118 | bts->location_area_code, bts->bsic, bts->tsc, |
| 119 | bts->num_trx, VTY_NEWLINE); |
Harald Welte | 59b0468 | 2009-06-10 05:40:52 +0800 | [diff] [blame] | 120 | if (is_ipaccess_bts(bts)) |
| 121 | vty_out(vty, " Unit ID: %u/%u/0%s", |
| 122 | bts->ip_access.site_id, bts->ip_access.bts_id, |
| 123 | VTY_NEWLINE); |
| 124 | vty_out(vty, " NM State: "); |
| 125 | net_dump_nmstate(vty, &bts->nm_state); |
| 126 | vty_out(vty, " Site Mgr NM State: "); |
| 127 | net_dump_nmstate(vty, &bts->site_mgr.nm_state); |
| 128 | vty_out(vty, " Paging: FIXME pending requests, %u free slots%s", |
| 129 | bts->paging.available_slots, VTY_NEWLINE); |
| 130 | vty_out(vty, " E1 Signalling Link:%s", VTY_NEWLINE); |
| 131 | e1isl_dump_vty(vty, bts->oml_link); |
| 132 | /* FIXME: oml_link, chan_desc */ |
| 133 | } |
| 134 | |
| 135 | DEFUN(show_bts, show_bts_cmd, "show bts [number]", |
| 136 | SHOW_STR "Display information about a BTS\n" |
| 137 | "BTS number") |
| 138 | { |
| 139 | struct gsm_network *net = gsmnet; |
| 140 | int bts_nr; |
| 141 | |
| 142 | if (argc != 0) { |
| 143 | /* use the BTS number that the user has specified */ |
| 144 | bts_nr = atoi(argv[0]); |
| 145 | if (bts_nr > net->num_bts) { |
| 146 | vty_out(vty, "%% can't find BTS '%s'%s", argv[0], |
| 147 | VTY_NEWLINE); |
| 148 | return CMD_WARNING; |
| 149 | } |
Harald Welte | e712a5f | 2009-06-21 16:17:15 +0200 | [diff] [blame] | 150 | bts_dump_vty(vty, gsm_bts_num(net, bts_nr)); |
Harald Welte | 59b0468 | 2009-06-10 05:40:52 +0800 | [diff] [blame] | 151 | return CMD_SUCCESS; |
| 152 | } |
| 153 | /* print all BTS's */ |
| 154 | for (bts_nr = 0; bts_nr < net->num_bts; bts_nr++) |
Harald Welte | e712a5f | 2009-06-21 16:17:15 +0200 | [diff] [blame] | 155 | bts_dump_vty(vty, gsm_bts_num(net, bts_nr)); |
Harald Welte | 59b0468 | 2009-06-10 05:40:52 +0800 | [diff] [blame] | 156 | |
| 157 | return CMD_SUCCESS; |
| 158 | } |
| 159 | |
Harald Welte | 97ceef9 | 2009-08-06 19:06:46 +0200 | [diff] [blame^] | 160 | static void config_write_ts_single(struct vty *vty, struct gsm_bts_trx_ts *ts) |
| 161 | { |
| 162 | vty_out(vty, "\t\tts %u%s", ts->nr, VTY_NEWLINE); |
| 163 | vty_out(vty, "\t\t\tphys_chan_config %s%s", gsm_pchan_name(ts->pchan), |
| 164 | VTY_NEWLINE); |
| 165 | vty_out(vty, "\t\t\te1_subslot %u %u %u%s", ts->e1_link.e1_nr, |
| 166 | ts->e1_link.e1_ts, ts->e1_link.e1_ts_ss, VTY_NEWLINE); |
| 167 | } |
| 168 | |
| 169 | static void config_write_trx_single(struct vty *vty, struct gsm_bts_trx *trx) |
| 170 | { |
| 171 | int i; |
| 172 | |
| 173 | vty_out(vty, "\ttrx %u%s", trx->nr, VTY_NEWLINE); |
| 174 | vty_out(vty, "\t\tarfcn %u%s", trx->arfcn, VTY_NEWLINE); |
| 175 | vty_out(vty, "\t\tmax_power_red %u%s", trx->max_power_red, VTY_NEWLINE); |
| 176 | |
| 177 | for (i = 0; i < TRX_NR_TS; i++) |
| 178 | config_write_ts_single(vty, &trx->ts[i]); |
| 179 | } |
| 180 | |
| 181 | static void config_write_bts_single(struct vty *vty, struct gsm_bts *bts) |
| 182 | { |
| 183 | struct gsm_bts_trx *trx; |
| 184 | |
| 185 | vty_out(vty, "bts %u%s", bts->nr, VTY_NEWLINE); |
| 186 | vty_out(vty, "\ttype %s%s", btstype2str(bts->type), VTY_NEWLINE); |
| 187 | vty_out(vty, "\tband %s%s", gsm_band_name(bts->band), VTY_NEWLINE); |
| 188 | vty_out(vty, "\tlocation_area_code %u%s", bts->location_area_code, |
| 189 | VTY_NEWLINE); |
| 190 | vty_out(vty, "\ttraining_sequence_code %u%s", bts->tsc, VTY_NEWLINE); |
| 191 | vty_out(vty, "\tbase_station_id_code %u%s", bts->bsic, VTY_NEWLINE); |
| 192 | vty_out(vty, "\tunit_id %u %u%s", |
| 193 | bts->ip_access.site_id, bts->ip_access.bts_id, VTY_NEWLINE); |
| 194 | |
| 195 | llist_for_each_entry(trx, &bts->trx_list, list) |
| 196 | config_write_trx_single(vty, trx); |
| 197 | } |
| 198 | |
| 199 | static int config_write_bts(struct vty *v) |
| 200 | { |
| 201 | struct gsm_bts *bts; |
| 202 | |
| 203 | llist_for_each_entry(bts, &gsmnet->bts_list, list) |
| 204 | config_write_bts_single(v, bts); |
| 205 | |
| 206 | return CMD_SUCCESS; |
| 207 | } |
| 208 | |
| 209 | |
Harald Welte | 59b0468 | 2009-06-10 05:40:52 +0800 | [diff] [blame] | 210 | static void trx_dump_vty(struct vty *vty, struct gsm_bts_trx *trx) |
| 211 | { |
| 212 | vty_out(vty, "TRX %u of BTS %u is on ARFCN %u%s", |
| 213 | trx->nr, trx->bts->nr, trx->arfcn, VTY_NEWLINE); |
Harald Welte | 91afe4c | 2009-06-20 18:15:19 +0200 | [diff] [blame] | 214 | vty_out(vty, " RF Nominal Power: %d dBm, reduced by %u dB, " |
| 215 | "resulting BS power: %d dBm\n", |
| 216 | trx->nominal_power, trx->max_power_red, |
| 217 | trx->nominal_power - trx->max_power_red); |
Harald Welte | 59b0468 | 2009-06-10 05:40:52 +0800 | [diff] [blame] | 218 | vty_out(vty, " NM State: "); |
| 219 | net_dump_nmstate(vty, &trx->nm_state); |
| 220 | vty_out(vty, " Baseband Transceiver NM State: "); |
| 221 | net_dump_nmstate(vty, &trx->bb_transc.nm_state); |
| 222 | vty_out(vty, " E1 Signalling Link:%s", VTY_NEWLINE); |
| 223 | e1isl_dump_vty(vty, trx->rsl_link); |
| 224 | } |
| 225 | |
| 226 | DEFUN(show_trx, |
| 227 | show_trx_cmd, |
| 228 | "show trx [bts_nr] [trx_nr]", |
| 229 | SHOW_STR "Display information about a TRX\n") |
| 230 | { |
| 231 | struct gsm_network *net = gsmnet; |
| 232 | struct gsm_bts *bts = NULL; |
| 233 | struct gsm_bts_trx *trx; |
| 234 | int bts_nr, trx_nr; |
| 235 | |
| 236 | if (argc >= 1) { |
| 237 | /* use the BTS number that the user has specified */ |
| 238 | bts_nr = atoi(argv[0]); |
| 239 | if (bts_nr >= net->num_bts) { |
| 240 | vty_out(vty, "%% can't find BTS '%s'%s", argv[0], |
| 241 | VTY_NEWLINE); |
| 242 | return CMD_WARNING; |
| 243 | } |
Harald Welte | e712a5f | 2009-06-21 16:17:15 +0200 | [diff] [blame] | 244 | bts = gsm_bts_num(net, bts_nr); |
Harald Welte | 59b0468 | 2009-06-10 05:40:52 +0800 | [diff] [blame] | 245 | } |
| 246 | if (argc >= 2) { |
| 247 | trx_nr = atoi(argv[1]); |
| 248 | if (trx_nr >= bts->num_trx) { |
| 249 | vty_out(vty, "%% can't find TRX '%s'%s", argv[1], |
| 250 | VTY_NEWLINE); |
| 251 | return CMD_WARNING; |
| 252 | } |
Harald Welte | e712a5f | 2009-06-21 16:17:15 +0200 | [diff] [blame] | 253 | trx = gsm_bts_trx_num(bts, trx_nr); |
Harald Welte | 59b0468 | 2009-06-10 05:40:52 +0800 | [diff] [blame] | 254 | trx_dump_vty(vty, trx); |
| 255 | return CMD_SUCCESS; |
| 256 | } |
| 257 | if (bts) { |
| 258 | /* print all TRX in this BTS */ |
| 259 | for (trx_nr = 0; trx_nr < bts->num_trx; trx_nr++) { |
Harald Welte | e712a5f | 2009-06-21 16:17:15 +0200 | [diff] [blame] | 260 | trx = gsm_bts_trx_num(bts, trx_nr); |
Harald Welte | 59b0468 | 2009-06-10 05:40:52 +0800 | [diff] [blame] | 261 | trx_dump_vty(vty, trx); |
| 262 | } |
| 263 | return CMD_SUCCESS; |
| 264 | } |
| 265 | |
| 266 | for (bts_nr = 0; bts_nr < net->num_bts; bts_nr++) { |
Harald Welte | e712a5f | 2009-06-21 16:17:15 +0200 | [diff] [blame] | 267 | bts = gsm_bts_num(net, bts_nr); |
Harald Welte | 59b0468 | 2009-06-10 05:40:52 +0800 | [diff] [blame] | 268 | for (trx_nr = 0; trx_nr < bts->num_trx; trx_nr++) { |
Harald Welte | e712a5f | 2009-06-21 16:17:15 +0200 | [diff] [blame] | 269 | trx = gsm_bts_trx_num(bts, trx_nr); |
Harald Welte | 59b0468 | 2009-06-10 05:40:52 +0800 | [diff] [blame] | 270 | trx_dump_vty(vty, trx); |
| 271 | } |
| 272 | } |
| 273 | |
| 274 | return CMD_SUCCESS; |
| 275 | } |
| 276 | |
Harald Welte | 97ceef9 | 2009-08-06 19:06:46 +0200 | [diff] [blame^] | 277 | |
Harald Welte | 59b0468 | 2009-06-10 05:40:52 +0800 | [diff] [blame] | 278 | static void ts_dump_vty(struct vty *vty, struct gsm_bts_trx_ts *ts) |
| 279 | { |
| 280 | struct in_addr ia; |
| 281 | |
| 282 | vty_out(vty, "Timeslot %u of TRX %u in BTS %u, phys cfg %s%s", |
| 283 | ts->nr, ts->trx->nr, ts->trx->bts->nr, |
| 284 | gsm_pchan_name(ts->pchan), VTY_NEWLINE); |
| 285 | vty_out(vty, " NM State: "); |
| 286 | net_dump_nmstate(vty, &ts->nm_state); |
| 287 | if (is_ipaccess_bts(ts->trx->bts)) { |
| 288 | ia.s_addr = ts->abis_ip.bound_ip; |
Harald Welte | 8cdeaad | 2009-07-12 09:50:35 +0200 | [diff] [blame] | 289 | vty_out(vty, " Bound IP: %s Port %u RTP_TYPE2=%u CONN_ID=%u%s", |
Harald Welte | 59b0468 | 2009-06-10 05:40:52 +0800 | [diff] [blame] | 290 | inet_ntoa(ia), ts->abis_ip.bound_port, |
Harald Welte | 8cdeaad | 2009-07-12 09:50:35 +0200 | [diff] [blame] | 291 | ts->abis_ip.rtp_payload2, ts->abis_ip.conn_id, |
Harald Welte | 59b0468 | 2009-06-10 05:40:52 +0800 | [diff] [blame] | 292 | VTY_NEWLINE); |
| 293 | } else { |
| 294 | vty_out(vty, " E1 Line %u, Timeslot %u, Subslot %u%s", |
| 295 | ts->e1_link.e1_nr, ts->e1_link.e1_ts, |
| 296 | ts->e1_link.e1_ts_ss, VTY_NEWLINE); |
| 297 | } |
| 298 | } |
| 299 | |
| 300 | DEFUN(show_ts, |
| 301 | show_ts_cmd, |
| 302 | "show timeslot [bts_nr] [trx_nr] [ts_nr]", |
| 303 | SHOW_STR "Display information about a TS\n") |
| 304 | { |
| 305 | struct gsm_network *net = gsmnet; |
| 306 | struct gsm_bts *bts; |
| 307 | struct gsm_bts_trx *trx; |
| 308 | struct gsm_bts_trx_ts *ts; |
| 309 | int bts_nr, trx_nr, ts_nr; |
| 310 | |
| 311 | if (argc >= 1) { |
| 312 | /* use the BTS number that the user has specified */ |
| 313 | bts_nr = atoi(argv[0]); |
| 314 | if (bts_nr >= net->num_bts) { |
| 315 | vty_out(vty, "%% can't find BTS '%s'%s", argv[0], |
| 316 | VTY_NEWLINE); |
| 317 | return CMD_WARNING; |
| 318 | } |
Harald Welte | e712a5f | 2009-06-21 16:17:15 +0200 | [diff] [blame] | 319 | bts = gsm_bts_num(net, bts_nr); |
Harald Welte | 59b0468 | 2009-06-10 05:40:52 +0800 | [diff] [blame] | 320 | } |
| 321 | if (argc >= 2) { |
| 322 | trx_nr = atoi(argv[1]); |
| 323 | if (trx_nr >= bts->num_trx) { |
| 324 | vty_out(vty, "%% can't find TRX '%s'%s", argv[1], |
| 325 | VTY_NEWLINE); |
| 326 | return CMD_WARNING; |
| 327 | } |
Harald Welte | e712a5f | 2009-06-21 16:17:15 +0200 | [diff] [blame] | 328 | trx = gsm_bts_trx_num(bts, trx_nr); |
Harald Welte | 59b0468 | 2009-06-10 05:40:52 +0800 | [diff] [blame] | 329 | } |
| 330 | if (argc >= 3) { |
| 331 | ts_nr = atoi(argv[2]); |
| 332 | if (ts_nr >= TRX_NR_TS) { |
| 333 | vty_out(vty, "%% can't find TS '%s'%s", argv[2], |
| 334 | VTY_NEWLINE); |
| 335 | return CMD_WARNING; |
| 336 | } |
| 337 | ts = &trx->ts[ts_nr]; |
| 338 | ts_dump_vty(vty, ts); |
| 339 | return CMD_SUCCESS; |
| 340 | } |
| 341 | for (bts_nr = 0; bts_nr < net->num_bts; bts_nr++) { |
Harald Welte | e712a5f | 2009-06-21 16:17:15 +0200 | [diff] [blame] | 342 | bts = gsm_bts_num(net, bts_nr); |
Harald Welte | 59b0468 | 2009-06-10 05:40:52 +0800 | [diff] [blame] | 343 | for (trx_nr = 0; trx_nr < bts->num_trx; trx_nr++) { |
Harald Welte | e712a5f | 2009-06-21 16:17:15 +0200 | [diff] [blame] | 344 | trx = gsm_bts_trx_num(bts, trx_nr); |
Harald Welte | 59b0468 | 2009-06-10 05:40:52 +0800 | [diff] [blame] | 345 | for (ts_nr = 0; ts_nr < TRX_NR_TS; ts_nr++) { |
| 346 | ts = &trx->ts[ts_nr]; |
| 347 | ts_dump_vty(vty, ts); |
| 348 | } |
| 349 | } |
| 350 | } |
| 351 | |
| 352 | return CMD_SUCCESS; |
| 353 | } |
| 354 | |
| 355 | static void subscr_dump_vty(struct vty *vty, struct gsm_subscriber *subscr) |
| 356 | { |
Harald Welte | 91afe4c | 2009-06-20 18:15:19 +0200 | [diff] [blame] | 357 | vty_out(vty, " ID: %llu, Authorized: %d%s", subscr->id, |
Harald Welte | 59b0468 | 2009-06-10 05:40:52 +0800 | [diff] [blame] | 358 | subscr->authorized, VTY_NEWLINE); |
| 359 | if (subscr->name) |
| 360 | vty_out(vty, " Name: '%s'%s", subscr->name, VTY_NEWLINE); |
| 361 | if (subscr->extension) |
| 362 | vty_out(vty, " Extension: %s%s", subscr->extension, |
| 363 | VTY_NEWLINE); |
| 364 | if (subscr->imsi) |
| 365 | vty_out(vty, " IMSI: %s%s", subscr->imsi, VTY_NEWLINE); |
| 366 | if (subscr->tmsi) |
| 367 | vty_out(vty, " TMSI: %s%s", subscr->tmsi, VTY_NEWLINE); |
| 368 | } |
| 369 | |
| 370 | static void lchan_dump_vty(struct vty *vty, struct gsm_lchan *lchan) |
| 371 | { |
| 372 | vty_out(vty, "Lchan %u in Timeslot %u of TRX %u in BTS %u, Type %s%s", |
| 373 | lchan->nr, lchan->ts->nr, lchan->ts->trx->nr, |
| 374 | lchan->ts->trx->bts->nr, gsm_lchan_name(lchan->type), |
| 375 | VTY_NEWLINE); |
| 376 | vty_out(vty, " Use Count: %u%s", lchan->use_count, VTY_NEWLINE); |
| 377 | vty_out(vty, " BS Power %u, MS Power %u%s", lchan->bs_power, |
| 378 | lchan->ms_power, VTY_NEWLINE); |
| 379 | if (lchan->subscr) { |
| 380 | vty_out(vty, " Subscriber:%s", VTY_NEWLINE); |
| 381 | subscr_dump_vty(vty, lchan->subscr); |
| 382 | } else |
| 383 | vty_out(vty, " No Subscriber%s", VTY_NEWLINE); |
| 384 | } |
| 385 | |
Harald Welte | 0374084 | 2009-06-10 23:11:52 +0800 | [diff] [blame] | 386 | #if 0 |
| 387 | TODO: callref and remote callref of call must be resolved to get gsm_trans object |
Harald Welte | 59b0468 | 2009-06-10 05:40:52 +0800 | [diff] [blame] | 388 | static void call_dump_vty(struct vty *vty, struct gsm_call *call) |
| 389 | { |
| 390 | vty_out(vty, "Call Type %u, State %u, Transaction ID %u%s", |
| 391 | call->type, call->state, call->transaction_id, VTY_NEWLINE); |
| 392 | |
| 393 | if (call->local_lchan) { |
| 394 | vty_out(vty, "Call Local Channel:%s", VTY_NEWLINE); |
| 395 | lchan_dump_vty(vty, call->local_lchan); |
| 396 | } else |
| 397 | vty_out(vty, "Call has no Local Channel%s", VTY_NEWLINE); |
| 398 | |
| 399 | if (call->remote_lchan) { |
| 400 | vty_out(vty, "Call Remote Channel:%s", VTY_NEWLINE); |
| 401 | lchan_dump_vty(vty, call->remote_lchan); |
| 402 | } else |
| 403 | vty_out(vty, "Call has no Remote Channel%s", VTY_NEWLINE); |
| 404 | |
| 405 | if (call->called_subscr) { |
| 406 | vty_out(vty, "Called Subscriber:%s", VTY_NEWLINE); |
| 407 | subscr_dump_vty(vty, call->called_subscr); |
| 408 | } else |
| 409 | vty_out(vty, "Call has no Called Subscriber%s", VTY_NEWLINE); |
| 410 | } |
Harald Welte | 0374084 | 2009-06-10 23:11:52 +0800 | [diff] [blame] | 411 | #endif |
Harald Welte | 59b0468 | 2009-06-10 05:40:52 +0800 | [diff] [blame] | 412 | |
| 413 | DEFUN(show_lchan, |
| 414 | show_lchan_cmd, |
| 415 | "show lchan [bts_nr] [trx_nr] [ts_nr] [lchan_nr]", |
| 416 | SHOW_STR "Display information about a logical channel\n") |
| 417 | { |
| 418 | struct gsm_network *net = gsmnet; |
| 419 | struct gsm_bts *bts; |
| 420 | struct gsm_bts_trx *trx; |
| 421 | struct gsm_bts_trx_ts *ts; |
| 422 | struct gsm_lchan *lchan; |
| 423 | int bts_nr, trx_nr, ts_nr, lchan_nr; |
| 424 | |
| 425 | if (argc >= 1) { |
| 426 | /* use the BTS number that the user has specified */ |
| 427 | bts_nr = atoi(argv[0]); |
| 428 | if (bts_nr >= net->num_bts) { |
| 429 | vty_out(vty, "%% can't find BTS %s%s", argv[0], |
| 430 | VTY_NEWLINE); |
| 431 | return CMD_WARNING; |
| 432 | } |
Harald Welte | e712a5f | 2009-06-21 16:17:15 +0200 | [diff] [blame] | 433 | bts = gsm_bts_num(net, bts_nr); |
Harald Welte | 59b0468 | 2009-06-10 05:40:52 +0800 | [diff] [blame] | 434 | } |
| 435 | if (argc >= 2) { |
| 436 | trx_nr = atoi(argv[1]); |
| 437 | if (trx_nr >= bts->num_trx) { |
| 438 | vty_out(vty, "%% can't find TRX %s%s", argv[1], |
| 439 | VTY_NEWLINE); |
| 440 | return CMD_WARNING; |
| 441 | } |
Harald Welte | e712a5f | 2009-06-21 16:17:15 +0200 | [diff] [blame] | 442 | trx = gsm_bts_trx_num(bts, trx_nr); |
Harald Welte | 59b0468 | 2009-06-10 05:40:52 +0800 | [diff] [blame] | 443 | } |
| 444 | if (argc >= 3) { |
| 445 | ts_nr = atoi(argv[2]); |
| 446 | if (ts_nr >= TRX_NR_TS) { |
| 447 | vty_out(vty, "%% can't find TS %s%s", argv[2], |
| 448 | VTY_NEWLINE); |
| 449 | return CMD_WARNING; |
| 450 | } |
| 451 | ts = &trx->ts[ts_nr]; |
| 452 | } |
| 453 | if (argc >= 4) { |
| 454 | lchan_nr = atoi(argv[3]); |
| 455 | if (lchan_nr >= TS_MAX_LCHAN) { |
| 456 | vty_out(vty, "%% can't find LCHAN %s%s", argv[3], |
| 457 | VTY_NEWLINE); |
| 458 | return CMD_WARNING; |
| 459 | } |
| 460 | lchan = &ts->lchan[lchan_nr]; |
| 461 | lchan_dump_vty(vty, lchan); |
| 462 | return CMD_SUCCESS; |
| 463 | } |
| 464 | for (bts_nr = 0; bts_nr < net->num_bts; bts_nr++) { |
Harald Welte | e712a5f | 2009-06-21 16:17:15 +0200 | [diff] [blame] | 465 | bts = gsm_bts_num(net, bts_nr); |
Harald Welte | 59b0468 | 2009-06-10 05:40:52 +0800 | [diff] [blame] | 466 | for (trx_nr = 0; trx_nr < bts->num_trx; trx_nr++) { |
Harald Welte | e712a5f | 2009-06-21 16:17:15 +0200 | [diff] [blame] | 467 | trx = gsm_bts_trx_num(bts, trx_nr); |
Harald Welte | 59b0468 | 2009-06-10 05:40:52 +0800 | [diff] [blame] | 468 | for (ts_nr = 0; ts_nr < TRX_NR_TS; ts_nr++) { |
| 469 | ts = &trx->ts[ts_nr]; |
| 470 | for (lchan_nr = 0; lchan_nr < TS_MAX_LCHAN; |
| 471 | lchan_nr++) { |
| 472 | lchan = &ts->lchan[lchan_nr]; |
| 473 | if (lchan->type == GSM_LCHAN_NONE) |
| 474 | continue; |
| 475 | lchan_dump_vty(vty, lchan); |
| 476 | } |
| 477 | } |
| 478 | } |
| 479 | } |
| 480 | |
| 481 | return CMD_SUCCESS; |
| 482 | } |
| 483 | |
| 484 | static void e1drv_dump_vty(struct vty *vty, struct e1inp_driver *drv) |
| 485 | { |
| 486 | vty_out(vty, "E1 Input Driver %s%s", drv->name, VTY_NEWLINE); |
| 487 | } |
| 488 | |
| 489 | DEFUN(show_e1drv, |
| 490 | show_e1drv_cmd, |
| 491 | "show e1_driver", |
| 492 | SHOW_STR "Display information about available E1 drivers\n") |
| 493 | { |
| 494 | struct e1inp_driver *drv; |
| 495 | |
| 496 | llist_for_each_entry(drv, &e1inp_driver_list, list) |
| 497 | e1drv_dump_vty(vty, drv); |
| 498 | |
| 499 | return CMD_SUCCESS; |
| 500 | } |
| 501 | |
| 502 | static void e1line_dump_vty(struct vty *vty, struct e1inp_line *line) |
| 503 | { |
| 504 | vty_out(vty, "E1 Line Number %u, Name %s, Driver %s%s", |
| 505 | line->num, line->name ? line->name : "", |
| 506 | line->driver->name, VTY_NEWLINE); |
| 507 | } |
| 508 | |
| 509 | DEFUN(show_e1line, |
| 510 | show_e1line_cmd, |
| 511 | "show e1_line [line_nr]", |
| 512 | SHOW_STR "Display information about a E1 line\n") |
| 513 | { |
| 514 | struct e1inp_line *line; |
| 515 | |
| 516 | if (argc >= 1) { |
| 517 | int num = atoi(argv[0]); |
| 518 | llist_for_each_entry(line, &e1inp_line_list, list) { |
| 519 | if (line->num == num) { |
| 520 | e1line_dump_vty(vty, line); |
| 521 | return CMD_SUCCESS; |
| 522 | } |
| 523 | } |
| 524 | return CMD_WARNING; |
| 525 | } |
| 526 | |
| 527 | llist_for_each_entry(line, &e1inp_line_list, list) |
| 528 | e1line_dump_vty(vty, line); |
| 529 | |
| 530 | return CMD_SUCCESS; |
| 531 | } |
| 532 | |
| 533 | static void e1ts_dump_vty(struct vty *vty, struct e1inp_ts *ts) |
| 534 | { |
| 535 | vty_out(vty, "E1 Timeslot %2u of Line %u is Type %s%s", |
| 536 | ts->num, ts->line->num, e1inp_tstype_name(ts->type), |
| 537 | VTY_NEWLINE); |
| 538 | } |
| 539 | |
| 540 | DEFUN(show_e1ts, |
| 541 | show_e1ts_cmd, |
| 542 | "show e1_timeslot [line_nr] [ts_nr]", |
| 543 | SHOW_STR "Display information about a E1 timeslot\n") |
| 544 | { |
| 545 | struct e1inp_line *line; |
| 546 | struct e1inp_ts *ts; |
| 547 | int ts_nr; |
| 548 | |
| 549 | if (argc == 0) { |
| 550 | llist_for_each_entry(line, &e1inp_line_list, list) { |
| 551 | for (ts_nr = 0; ts_nr < NUM_E1_TS; ts_nr++) { |
| 552 | ts = &line->ts[ts_nr]; |
| 553 | e1ts_dump_vty(vty, ts); |
| 554 | } |
| 555 | } |
| 556 | return CMD_SUCCESS; |
| 557 | } |
| 558 | if (argc >= 1) { |
| 559 | int num = atoi(argv[0]); |
| 560 | llist_for_each_entry(line, &e1inp_line_list, list) { |
| 561 | if (line->num == num) |
| 562 | break; |
| 563 | } |
| 564 | if (!line || line->num != num) { |
| 565 | vty_out(vty, "E1 line %s is invalid%s", |
| 566 | argv[0], VTY_NEWLINE); |
| 567 | return CMD_WARNING; |
| 568 | } |
| 569 | } |
| 570 | if (argc >= 2) { |
| 571 | ts_nr = atoi(argv[1]); |
| 572 | if (ts_nr > NUM_E1_TS) { |
| 573 | vty_out(vty, "E1 timeslot %s is invalid%s", |
| 574 | argv[1], VTY_NEWLINE); |
| 575 | return CMD_WARNING; |
| 576 | } |
| 577 | ts = &line->ts[ts_nr]; |
| 578 | e1ts_dump_vty(vty, ts); |
| 579 | return CMD_SUCCESS; |
| 580 | } else { |
| 581 | for (ts_nr = 0; ts_nr < NUM_E1_TS; ts_nr++) { |
| 582 | ts = &line->ts[ts_nr]; |
| 583 | e1ts_dump_vty(vty, ts); |
| 584 | } |
| 585 | return CMD_SUCCESS; |
| 586 | } |
| 587 | return CMD_SUCCESS; |
| 588 | } |
| 589 | |
| 590 | static void paging_dump_vty(struct vty *vty, struct gsm_paging_request *pag) |
| 591 | { |
| 592 | vty_out(vty, "Paging on BTS %u%s", pag->bts->nr, VTY_NEWLINE); |
| 593 | subscr_dump_vty(vty, pag->subscr); |
| 594 | } |
| 595 | |
| 596 | static void bts_paging_dump_vty(struct vty *vty, struct gsm_bts *bts) |
| 597 | { |
| 598 | struct gsm_paging_request *pag; |
| 599 | |
| 600 | llist_for_each_entry(pag, &bts->paging.pending_requests, entry) |
| 601 | paging_dump_vty(vty, pag); |
| 602 | } |
| 603 | |
| 604 | DEFUN(show_paging, |
| 605 | show_paging_cmd, |
| 606 | "show paging [bts_nr]", |
| 607 | SHOW_STR "Display information about paging reuqests of a BTS\n") |
| 608 | { |
| 609 | struct gsm_network *net = gsmnet; |
| 610 | struct gsm_bts *bts; |
| 611 | int bts_nr; |
| 612 | |
| 613 | if (argc >= 1) { |
| 614 | /* use the BTS number that the user has specified */ |
| 615 | bts_nr = atoi(argv[0]); |
| 616 | if (bts_nr >= net->num_bts) { |
| 617 | vty_out(vty, "%% can't find BTS %s%s", argv[0], |
| 618 | VTY_NEWLINE); |
| 619 | return CMD_WARNING; |
| 620 | } |
Harald Welte | e712a5f | 2009-06-21 16:17:15 +0200 | [diff] [blame] | 621 | bts = gsm_bts_num(net, bts_nr); |
Harald Welte | 59b0468 | 2009-06-10 05:40:52 +0800 | [diff] [blame] | 622 | bts_paging_dump_vty(vty, bts); |
| 623 | |
| 624 | return CMD_SUCCESS; |
| 625 | } |
| 626 | for (bts_nr = 0; bts_nr < net->num_bts; bts_nr++) { |
Harald Welte | e712a5f | 2009-06-21 16:17:15 +0200 | [diff] [blame] | 627 | bts = gsm_bts_num(net, bts_nr); |
Harald Welte | 59b0468 | 2009-06-10 05:40:52 +0800 | [diff] [blame] | 628 | bts_paging_dump_vty(vty, bts); |
| 629 | } |
| 630 | |
| 631 | return CMD_SUCCESS; |
| 632 | } |
| 633 | |
| 634 | /* per-subscriber configuration */ |
| 635 | DEFUN(cfg_subscr, |
| 636 | cfg_subscr_cmd, |
| 637 | "subscriber IMSI", |
| 638 | "Select a Subscriber to configure\n") |
| 639 | { |
| 640 | const char *imsi = argv[0]; |
| 641 | struct gsm_subscriber *subscr; |
| 642 | |
Harald Welte | aae7a52 | 2009-07-23 19:21:02 +0200 | [diff] [blame] | 643 | subscr = subscr_get_by_imsi(gsmnet, imsi); |
Harald Welte | 59b0468 | 2009-06-10 05:40:52 +0800 | [diff] [blame] | 644 | if (!subscr) { |
| 645 | vty_out(vty, "%% No subscriber for IMSI %s%s", |
| 646 | imsi, VTY_NEWLINE); |
| 647 | return CMD_WARNING; |
| 648 | } |
| 649 | |
| 650 | vty->index = subscr; |
| 651 | vty->node = SUBSCR_NODE; |
| 652 | |
| 653 | return CMD_SUCCESS; |
| 654 | } |
| 655 | |
| 656 | |
| 657 | /* per-BTS configuration */ |
| 658 | DEFUN(cfg_bts, |
| 659 | cfg_bts_cmd, |
| 660 | "bts BTS_NR", |
| 661 | "Select a BTS to configure\n") |
| 662 | { |
| 663 | int bts_nr = atoi(argv[0]); |
| 664 | struct gsm_bts *bts; |
| 665 | |
Harald Welte | e712a5f | 2009-06-21 16:17:15 +0200 | [diff] [blame] | 666 | if (bts_nr > gsmnet->num_bts) { |
| 667 | vty_out(vty, "%% The next unused BTS number is %u%s", |
| 668 | gsmnet->num_bts, VTY_NEWLINE); |
Harald Welte | 59b0468 | 2009-06-10 05:40:52 +0800 | [diff] [blame] | 669 | return CMD_WARNING; |
Harald Welte | e712a5f | 2009-06-21 16:17:15 +0200 | [diff] [blame] | 670 | } else if (bts_nr == gsmnet->num_bts) { |
| 671 | /* allocate a new one */ |
| 672 | bts = gsm_bts_alloc(gsmnet, GSM_BTS_TYPE_UNKNOWN, |
| 673 | HARDCODED_TSC, HARDCODED_BSIC); |
| 674 | } else |
| 675 | bts = gsm_bts_num(gsmnet, bts_nr); |
| 676 | |
| 677 | if (!bts) |
| 678 | return CMD_WARNING; |
Harald Welte | 59b0468 | 2009-06-10 05:40:52 +0800 | [diff] [blame] | 679 | |
| 680 | vty->index = bts; |
| 681 | vty->node = BTS_NODE; |
| 682 | |
| 683 | return CMD_SUCCESS; |
| 684 | } |
| 685 | |
| 686 | DEFUN(cfg_bts_type, |
| 687 | cfg_bts_type_cmd, |
| 688 | "type TYPE", |
| 689 | "Set the BTS type\n") |
| 690 | { |
| 691 | struct gsm_bts *bts = vty->index; |
| 692 | |
Harald Welte | 91afe4c | 2009-06-20 18:15:19 +0200 | [diff] [blame] | 693 | /* FIXME: implementation */ |
Harald Welte | 59b0468 | 2009-06-10 05:40:52 +0800 | [diff] [blame] | 694 | //bts->type = |
| 695 | return CMD_SUCCESS; |
| 696 | } |
| 697 | |
Harald Welte | 91afe4c | 2009-06-20 18:15:19 +0200 | [diff] [blame] | 698 | DEFUN(cfg_bts_band, |
| 699 | cfg_bts_band_cmd, |
| 700 | "band BAND", |
| 701 | "Set the frequency band of this BTS\n") |
| 702 | { |
| 703 | struct gsm_bts *bts = vty->index; |
| 704 | int band = gsm_band_parse(atoi(argv[0])); |
| 705 | |
| 706 | if (band < 0) { |
| 707 | vty_out(vty, "%% BAND %d is not a valid GSM band%s", |
| 708 | band, VTY_NEWLINE); |
| 709 | return CMD_WARNING; |
| 710 | } |
| 711 | |
| 712 | bts->band = band; |
| 713 | |
| 714 | return CMD_SUCCESS; |
| 715 | } |
| 716 | |
Harald Welte | 59b0468 | 2009-06-10 05:40:52 +0800 | [diff] [blame] | 717 | DEFUN(cfg_bts_lac, |
| 718 | cfg_bts_lac_cmd, |
| 719 | "location_area_code <0-255>", |
| 720 | "Set the Location Area Code (LAC) of this BTS\n") |
| 721 | { |
| 722 | struct gsm_bts *bts = vty->index; |
| 723 | int lac = atoi(argv[0]); |
| 724 | |
| 725 | if (lac < 0 || lac > 0xff) { |
| 726 | vty_out(vty, "%% LAC %d is not in the valid range (0-255)%s", |
| 727 | lac, VTY_NEWLINE); |
| 728 | return CMD_WARNING; |
| 729 | } |
| 730 | bts->location_area_code = lac; |
| 731 | |
| 732 | return CMD_SUCCESS; |
| 733 | } |
| 734 | |
| 735 | DEFUN(cfg_bts_tsc, |
| 736 | cfg_bts_tsc_cmd, |
| 737 | "training_sequence_code <0-255>", |
| 738 | "Set the Training Sequence Code (TSC) of this BTS\n") |
| 739 | { |
| 740 | struct gsm_bts *bts = vty->index; |
| 741 | int tsc = atoi(argv[0]); |
| 742 | |
| 743 | if (tsc < 0 || tsc > 0xff) { |
| 744 | vty_out(vty, "%% TSC %d is not in the valid range (0-255)%s", |
| 745 | tsc, VTY_NEWLINE); |
| 746 | return CMD_WARNING; |
| 747 | } |
| 748 | bts->tsc = tsc; |
| 749 | |
| 750 | return CMD_SUCCESS; |
| 751 | } |
| 752 | |
| 753 | DEFUN(cfg_bts_bsic, |
| 754 | cfg_bts_bsic_cmd, |
| 755 | "base_station_id_code <0-63>", |
| 756 | "Set the Base Station Identity Code (BSIC) of this BTS\n") |
| 757 | { |
| 758 | struct gsm_bts *bts = vty->index; |
| 759 | int bsic = atoi(argv[0]); |
| 760 | |
| 761 | if (bsic < 0 || bsic > 0x3f) { |
| 762 | vty_out(vty, "%% TSC %d is not in the valid range (0-255)%s", |
| 763 | bsic, VTY_NEWLINE); |
| 764 | return CMD_WARNING; |
| 765 | } |
| 766 | bts->bsic = bsic; |
| 767 | |
| 768 | return CMD_SUCCESS; |
| 769 | } |
| 770 | |
| 771 | |
| 772 | DEFUN(cfg_bts_unit_id, |
| 773 | cfg_bts_unit_id_cmd, |
| 774 | "unit_id <0-65534> <0-255>", |
| 775 | "Set the BTS Unit ID of this BTS\n") |
| 776 | { |
| 777 | struct gsm_bts *bts = vty->index; |
| 778 | int site_id = atoi(argv[0]); |
| 779 | int bts_id = atoi(argv[1]); |
| 780 | |
| 781 | if (site_id < 0 || site_id > 65534) { |
| 782 | vty_out(vty, "%% Site ID %d is not in the valid range%s", |
| 783 | site_id, VTY_NEWLINE); |
| 784 | return CMD_WARNING; |
| 785 | } |
| 786 | if (site_id < 0 || site_id > 255) { |
| 787 | vty_out(vty, "%% BTS ID %d is not in the valid range%s", |
| 788 | bts_id, VTY_NEWLINE); |
| 789 | return CMD_WARNING; |
| 790 | } |
| 791 | bts->ip_access.site_id = site_id; |
| 792 | bts->ip_access.bts_id = bts_id; |
| 793 | |
| 794 | return CMD_SUCCESS; |
| 795 | } |
| 796 | |
| 797 | /* per TRX configuration */ |
| 798 | DEFUN(cfg_trx, |
| 799 | cfg_trx_cmd, |
| 800 | "trx TRX_NR", |
| 801 | "Select a TRX to configure") |
| 802 | { |
| 803 | int trx_nr = atoi(argv[0]); |
| 804 | struct gsm_bts *bts = vty->index; |
| 805 | struct gsm_bts_trx *trx; |
| 806 | |
Harald Welte | e712a5f | 2009-06-21 16:17:15 +0200 | [diff] [blame] | 807 | if (trx_nr > bts->num_trx) { |
| 808 | vty_out(vty, "%% The next unused TRX number in this BTS is %u%s", |
| 809 | bts->num_trx, VTY_NEWLINE); |
Harald Welte | 59b0468 | 2009-06-10 05:40:52 +0800 | [diff] [blame] | 810 | return CMD_WARNING; |
Harald Welte | e712a5f | 2009-06-21 16:17:15 +0200 | [diff] [blame] | 811 | } else if (trx_nr == bts->num_trx) { |
| 812 | /* we need to allocate a new one */ |
| 813 | trx = gsm_bts_trx_alloc(bts); |
| 814 | } else |
| 815 | trx = gsm_bts_trx_num(bts, trx_nr); |
| 816 | |
| 817 | if (!trx) |
| 818 | return CMD_WARNING; |
Harald Welte | 59b0468 | 2009-06-10 05:40:52 +0800 | [diff] [blame] | 819 | |
| 820 | vty->index = trx; |
| 821 | vty->node = TRX_NODE; |
| 822 | |
| 823 | return CMD_SUCCESS; |
| 824 | } |
| 825 | |
| 826 | DEFUN(cfg_trx_arfcn, |
| 827 | cfg_trx_arfcn_cmd, |
| 828 | "arfcn <1-1024>", |
| 829 | "Set the ARFCN for this TRX\n") |
| 830 | { |
| 831 | int arfcn = atoi(argv[0]); |
| 832 | struct gsm_bts_trx *trx = vty->index; |
| 833 | |
| 834 | /* FIXME: check if this ARFCN is supported by this TRX */ |
| 835 | |
| 836 | trx->arfcn = arfcn; |
| 837 | |
| 838 | /* FIXME: patch ARFCN into SYSTEM INFORMATION */ |
| 839 | /* FIXME: use OML layer to update the ARFCN */ |
| 840 | /* FIXME: use RSL layer to update SYSTEM INFORMATION */ |
| 841 | |
| 842 | return CMD_SUCCESS; |
| 843 | } |
| 844 | |
Harald Welte | 91afe4c | 2009-06-20 18:15:19 +0200 | [diff] [blame] | 845 | DEFUN(cfg_trx_max_power_red, |
| 846 | cfg_trx_max_power_red_cmd, |
| 847 | "max_power_red <0-100>", |
| 848 | "Reduction of maximum BS RF Power in dB\n") |
| 849 | { |
| 850 | int maxpwr_r = atoi(argv[0]); |
| 851 | struct gsm_bts_trx *trx = vty->index; |
| 852 | int upper_limit = 12; /* default 12.21 max power red. */ |
| 853 | |
| 854 | /* FIXME: check if our BTS type supports more than 12 */ |
| 855 | if (maxpwr_r < 0 || maxpwr_r > upper_limit) { |
| 856 | vty_out(vty, "%% Power %d dB is not in the valid range%s", |
| 857 | maxpwr_r, VTY_NEWLINE); |
| 858 | return CMD_WARNING; |
| 859 | } |
| 860 | if (maxpwr_r & 1) { |
| 861 | vty_out(vty, "%% Power %d dB is not an even value%s", |
| 862 | maxpwr_r, VTY_NEWLINE); |
| 863 | return CMD_WARNING; |
| 864 | } |
| 865 | |
| 866 | trx->max_power_red = maxpwr_r; |
| 867 | |
| 868 | /* FIXME: make sure we update this using OML */ |
| 869 | |
| 870 | return CMD_SUCCESS; |
| 871 | } |
| 872 | |
Harald Welte | 59b0468 | 2009-06-10 05:40:52 +0800 | [diff] [blame] | 873 | /* per TS configuration */ |
| 874 | DEFUN(cfg_ts, |
| 875 | cfg_ts_cmd, |
| 876 | "timeslot TS_NR", |
| 877 | "Select a Timeslot to configure") |
| 878 | { |
| 879 | int ts_nr = atoi(argv[0]); |
| 880 | struct gsm_bts_trx *trx = vty->index; |
| 881 | struct gsm_bts_trx_ts *ts; |
| 882 | |
| 883 | if (ts_nr >= TRX_NR_TS) { |
| 884 | vty_out(vty, "%% A GSM TRX only has %u Timeslots per TRX%s", |
| 885 | TRX_NR_TS, VTY_NEWLINE); |
| 886 | return CMD_WARNING; |
| 887 | } |
| 888 | |
| 889 | ts = &trx->ts[ts_nr]; |
| 890 | |
| 891 | vty->index = ts; |
| 892 | vty->node = TS_NODE; |
| 893 | |
| 894 | return CMD_SUCCESS; |
| 895 | } |
| 896 | |
| 897 | |
| 898 | /* Subscriber */ |
| 899 | DEFUN(show_subscr, |
| 900 | show_subscr_cmd, |
| 901 | "show subscriber [IMSI]", |
| 902 | SHOW_STR "Display information about a subscriber\n") |
| 903 | { |
| 904 | const char *imsi; |
| 905 | struct gsm_subscriber *subscr; |
| 906 | |
| 907 | if (argc >= 1) { |
| 908 | imsi = argv[0]; |
Harald Welte | aae7a52 | 2009-07-23 19:21:02 +0200 | [diff] [blame] | 909 | subscr = subscr_get_by_imsi(gsmnet, imsi); |
Harald Welte | 59b0468 | 2009-06-10 05:40:52 +0800 | [diff] [blame] | 910 | if (!subscr) { |
| 911 | vty_out(vty, "%% unknown subscriber%s", |
| 912 | VTY_NEWLINE); |
| 913 | return CMD_WARNING; |
| 914 | } |
| 915 | subscr_dump_vty(vty, subscr); |
| 916 | |
| 917 | return CMD_SUCCESS; |
| 918 | } |
| 919 | |
| 920 | /* FIXME: iterate over all subscribers ? */ |
| 921 | return CMD_WARNING; |
| 922 | |
| 923 | return CMD_SUCCESS; |
| 924 | } |
| 925 | |
| 926 | DEFUN(cfg_subscr_name, |
| 927 | cfg_subscr_name_cmd, |
| 928 | "name NAME", |
| 929 | "Set the name of the subscriber") |
| 930 | { |
| 931 | const char *name = argv[0]; |
| 932 | struct gsm_subscriber *subscr = vty->index; |
| 933 | |
| 934 | strncpy(subscr->name, name, sizeof(subscr->name)); |
| 935 | |
| 936 | db_sync_subscriber(subscr); |
| 937 | |
| 938 | return CMD_SUCCESS; |
| 939 | } |
| 940 | |
| 941 | DEFUN(cfg_subscr_extension, |
| 942 | cfg_subscr_extension_cmd, |
| 943 | "extension EXTENSION", |
| 944 | "Set the extension of the subscriber") |
| 945 | { |
| 946 | const char *name = argv[0]; |
| 947 | struct gsm_subscriber *subscr = vty->index; |
| 948 | |
| 949 | strncpy(subscr->extension, name, sizeof(subscr->extension)); |
| 950 | |
| 951 | db_sync_subscriber(subscr); |
| 952 | |
| 953 | return CMD_SUCCESS; |
| 954 | } |
| 955 | |
| 956 | DEFUN(cfg_subscr_authorized, |
| 957 | cfg_subscr_authorized_cmd, |
| 958 | "auth <0-1>", |
| 959 | "Set the authorization status of the subscriber") |
| 960 | { |
| 961 | int auth = atoi(argv[0]); |
| 962 | struct gsm_subscriber *subscr = vty->index; |
| 963 | |
| 964 | if (auth) |
| 965 | subscr->authorized = 1; |
| 966 | else |
| 967 | subscr->authorized = 0; |
| 968 | |
| 969 | db_sync_subscriber(subscr); |
| 970 | |
| 971 | return CMD_SUCCESS; |
| 972 | } |
| 973 | |
| 974 | int bsc_vty_init(struct gsm_network *net) |
| 975 | { |
| 976 | gsmnet = net; |
| 977 | |
| 978 | cmd_init(1); |
| 979 | vty_init(); |
| 980 | |
| 981 | install_element(VIEW_NODE, &show_net_cmd); |
| 982 | install_element(VIEW_NODE, &show_bts_cmd); |
| 983 | install_element(VIEW_NODE, &show_trx_cmd); |
| 984 | install_element(VIEW_NODE, &show_ts_cmd); |
| 985 | install_element(VIEW_NODE, &show_lchan_cmd); |
| 986 | |
| 987 | install_element(VIEW_NODE, &show_e1drv_cmd); |
| 988 | install_element(VIEW_NODE, &show_e1line_cmd); |
| 989 | install_element(VIEW_NODE, &show_e1ts_cmd); |
| 990 | |
| 991 | install_element(VIEW_NODE, &show_paging_cmd); |
| 992 | |
| 993 | install_element(VIEW_NODE, &show_subscr_cmd); |
| 994 | |
| 995 | install_element(CONFIG_NODE, &cfg_bts_cmd); |
Harald Welte | 97ceef9 | 2009-08-06 19:06:46 +0200 | [diff] [blame^] | 996 | install_node(&bts_node, config_write_bts); |
Harald Welte | 59b0468 | 2009-06-10 05:40:52 +0800 | [diff] [blame] | 997 | install_default(BTS_NODE); |
| 998 | install_element(BTS_NODE, &cfg_bts_type_cmd); |
Harald Welte | 91afe4c | 2009-06-20 18:15:19 +0200 | [diff] [blame] | 999 | install_element(BTS_NODE, &cfg_bts_band_cmd); |
Harald Welte | 59b0468 | 2009-06-10 05:40:52 +0800 | [diff] [blame] | 1000 | install_element(BTS_NODE, &cfg_bts_lac_cmd); |
| 1001 | install_element(BTS_NODE, &cfg_bts_tsc_cmd); |
| 1002 | install_element(BTS_NODE, &cfg_bts_unit_id_cmd); |
| 1003 | |
| 1004 | install_element(BTS_NODE, &cfg_trx_cmd); |
| 1005 | install_node(&trx_node, dummy_config_write); |
| 1006 | install_default(TRX_NODE); |
| 1007 | install_element(TRX_NODE, &cfg_trx_arfcn_cmd); |
Harald Welte | 7f597bc | 2009-06-20 22:36:12 +0200 | [diff] [blame] | 1008 | install_element(TRX_NODE, &cfg_trx_max_power_red_cmd); |
Harald Welte | 59b0468 | 2009-06-10 05:40:52 +0800 | [diff] [blame] | 1009 | |
| 1010 | install_element(TRX_NODE, &cfg_ts_cmd); |
| 1011 | install_node(&ts_node, dummy_config_write); |
| 1012 | install_default(TS_NODE); |
| 1013 | |
| 1014 | install_element(CONFIG_NODE, &cfg_subscr_cmd); |
| 1015 | install_node(&subscr_node, dummy_config_write); |
| 1016 | install_default(SUBSCR_NODE); |
| 1017 | install_element(SUBSCR_NODE, &cfg_subscr_name_cmd); |
| 1018 | install_element(SUBSCR_NODE, &cfg_subscr_extension_cmd); |
| 1019 | install_element(SUBSCR_NODE, &cfg_subscr_authorized_cmd); |
| 1020 | |
| 1021 | return 0; |
| 1022 | } |