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