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> |
Harald Welte | f9daefd | 2009-08-09 15:13:54 +0200 | [diff] [blame] | 26 | #include <vty/buffer.h> |
Harald Welte | 68628e8 | 2009-03-10 12:17:57 +0000 | [diff] [blame] | 27 | #include <vty/vty.h> |
| 28 | |
| 29 | #include <arpa/inet.h> |
| 30 | |
Harald Welte | 1bc7735 | 2009-03-10 19:47:51 +0000 | [diff] [blame] | 31 | #include <openbsc/linuxlist.h> |
Harald Welte | 68628e8 | 2009-03-10 12:17:57 +0000 | [diff] [blame] | 32 | #include <openbsc/gsm_data.h> |
Harald Welte | 68628e8 | 2009-03-10 12:17:57 +0000 | [diff] [blame] | 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 | f9daefd | 2009-08-09 15:13:54 +0200 | [diff] [blame] | 35 | #include <openbsc/gsm_utils.h> |
Harald Welte | b908cb7 | 2009-12-22 13:09:29 +0100 | [diff] [blame] | 36 | #include <openbsc/chan_alloc.h> |
Harald Welte | 40f8289 | 2009-05-23 17:31:39 +0000 | [diff] [blame] | 37 | #include <openbsc/db.h> |
Harald Welte | 5013b2a | 2009-08-07 13:29:14 +0200 | [diff] [blame] | 38 | #include <openbsc/talloc.h> |
Harald Welte | 68628e8 | 2009-03-10 12:17:57 +0000 | [diff] [blame] | 39 | |
| 40 | static struct gsm_network *gsmnet; |
| 41 | |
Harald Welte | 5013b2a | 2009-08-07 13:29:14 +0200 | [diff] [blame] | 42 | struct cmd_node net_node = { |
| 43 | GSMNET_NODE, |
| 44 | "%s(network)#", |
| 45 | 1, |
| 46 | }; |
| 47 | |
Harald Welte | 68628e8 | 2009-03-10 12:17:57 +0000 | [diff] [blame] | 48 | struct cmd_node bts_node = { |
| 49 | BTS_NODE, |
| 50 | "%s(bts)#", |
| 51 | 1, |
| 52 | }; |
| 53 | |
| 54 | struct cmd_node trx_node = { |
| 55 | TRX_NODE, |
| 56 | "%s(trx)#", |
| 57 | 1, |
| 58 | }; |
| 59 | |
| 60 | struct cmd_node ts_node = { |
| 61 | TS_NODE, |
| 62 | "%s(ts)#", |
| 63 | 1, |
| 64 | }; |
| 65 | |
| 66 | static int dummy_config_write(struct vty *v) |
| 67 | { |
| 68 | return CMD_SUCCESS; |
| 69 | } |
| 70 | |
| 71 | static void net_dump_nmstate(struct vty *vty, struct gsm_nm_state *nms) |
| 72 | { |
Harald Welte | 1bc7735 | 2009-03-10 19:47:51 +0000 | [diff] [blame] | 73 | vty_out(vty,"Oper '%s', Admin %u, Avail '%s'%s", |
| 74 | nm_opstate_name(nms->operational), nms->administrative, |
| 75 | nm_avail_name(nms->availability), VTY_NEWLINE); |
Harald Welte | 68628e8 | 2009-03-10 12:17:57 +0000 | [diff] [blame] | 76 | } |
| 77 | |
Harald Welte | b908cb7 | 2009-12-22 13:09:29 +0100 | [diff] [blame] | 78 | static void dump_pchan_load_vty(struct vty *vty, char *prefix, |
| 79 | const struct pchan_load *pl) |
| 80 | { |
| 81 | int i; |
| 82 | |
| 83 | for (i = 0; i < ARRAY_SIZE(pl->pchan); i++) { |
| 84 | const struct load_counter *lc = &pl->pchan[i]; |
| 85 | unsigned int percent; |
| 86 | |
| 87 | if (lc->total == 0) |
| 88 | continue; |
| 89 | |
| 90 | percent = (lc->used * 100) / lc->total; |
| 91 | |
| 92 | vty_out(vty, "%s%20s: %3u%% (%u/%u)%s", prefix, |
| 93 | gsm_pchan_name(i), percent, lc->used, lc->total, |
| 94 | VTY_NEWLINE); |
| 95 | } |
| 96 | } |
| 97 | |
Harald Welte | 68628e8 | 2009-03-10 12:17:57 +0000 | [diff] [blame] | 98 | static void net_dump_vty(struct vty *vty, struct gsm_network *net) |
| 99 | { |
Harald Welte | b908cb7 | 2009-12-22 13:09:29 +0100 | [diff] [blame] | 100 | struct pchan_load pl; |
| 101 | |
Harald Welte | ef235b5 | 2009-03-10 12:34:02 +0000 | [diff] [blame] | 102 | vty_out(vty, "BSC is on Country Code %u, Network Code %u " |
| 103 | "and has %u BTS%s", net->country_code, net->network_code, |
| 104 | net->num_bts, VTY_NEWLINE); |
Harald Welte | 1bc7735 | 2009-03-10 19:47:51 +0000 | [diff] [blame] | 105 | vty_out(vty, " Long network name: '%s'%s", |
Harald Welte | 68628e8 | 2009-03-10 12:17:57 +0000 | [diff] [blame] | 106 | net->name_long, VTY_NEWLINE); |
Harald Welte | 1bc7735 | 2009-03-10 19:47:51 +0000 | [diff] [blame] | 107 | vty_out(vty, " Short network name: '%s'%s", |
Harald Welte | 68628e8 | 2009-03-10 12:17:57 +0000 | [diff] [blame] | 108 | net->name_short, VTY_NEWLINE); |
Harald Welte (local) | 69de397 | 2009-08-12 14:42:23 +0200 | [diff] [blame] | 109 | vty_out(vty, " Authentication policy: %s%s", |
| 110 | gsm_auth_policy_name(net->auth_policy), VTY_NEWLINE); |
Harald Welte | 1085c09 | 2009-11-18 20:33:19 +0100 | [diff] [blame] | 111 | vty_out(vty, " Location updating reject cause: %u%s", |
| 112 | net->reject_cause, VTY_NEWLINE); |
Harald Welte | 4381cfe | 2009-08-30 15:47:06 +0900 | [diff] [blame] | 113 | vty_out(vty, " Encryption: A5/%u%s", net->a5_encryption, |
| 114 | VTY_NEWLINE); |
Holger Hans Peter Freyther | f7d752f | 2009-11-16 17:12:38 +0100 | [diff] [blame] | 115 | vty_out(vty, " NECI (TCH/H): %u%s", net->neci, |
| 116 | VTY_NEWLINE); |
Harald Welte | eab84a1 | 2009-12-13 10:53:12 +0100 | [diff] [blame] | 117 | vty_out(vty, " RRLP Mode: %s%s", rrlp_mode_name(net->rrlp.mode), |
| 118 | VTY_NEWLINE); |
Harald Welte | 648b6ce | 2009-12-14 09:00:24 +0100 | [diff] [blame] | 119 | vty_out(vty, " MM Info: %s%s", net->send_mm_info ? "On" : "Off", |
| 120 | VTY_NEWLINE); |
Harald Welte | bc81450 | 2009-12-19 21:41:52 +0100 | [diff] [blame] | 121 | vty_out(vty, " Handover: %s%s", net->handover.active ? "On" : "Off", |
| 122 | VTY_NEWLINE); |
Harald Welte | b908cb7 | 2009-12-22 13:09:29 +0100 | [diff] [blame] | 123 | network_chan_load(&pl, net); |
| 124 | vty_out(vty, " Current Channel Load:%s", VTY_NEWLINE); |
| 125 | dump_pchan_load_vty(vty, " ", &pl); |
Harald Welte | 68628e8 | 2009-03-10 12:17:57 +0000 | [diff] [blame] | 126 | } |
| 127 | |
| 128 | DEFUN(show_net, show_net_cmd, "show network", |
| 129 | SHOW_STR "Display information about a GSM NETWORK\n") |
| 130 | { |
| 131 | struct gsm_network *net = gsmnet; |
| 132 | net_dump_vty(vty, net); |
| 133 | |
| 134 | return CMD_SUCCESS; |
| 135 | } |
| 136 | |
| 137 | static void e1isl_dump_vty(struct vty *vty, struct e1inp_sign_link *e1l) |
| 138 | { |
Harald Welte | edb3778 | 2009-05-01 14:59:07 +0000 | [diff] [blame] | 139 | struct e1inp_line *line; |
| 140 | |
| 141 | if (!e1l) { |
| 142 | vty_out(vty, " None%s", VTY_NEWLINE); |
| 143 | return; |
| 144 | } |
| 145 | |
| 146 | line = e1l->ts->line; |
| 147 | |
| 148 | vty_out(vty, " E1 Line %u, Type %s: Timeslot %u, Mode %s%s", |
| 149 | line->num, line->driver->name, e1l->ts->num, |
Harald Welte | 1bc7735 | 2009-03-10 19:47:51 +0000 | [diff] [blame] | 150 | e1inp_signtype_name(e1l->type), VTY_NEWLINE); |
Harald Welte | edb3778 | 2009-05-01 14:59:07 +0000 | [diff] [blame] | 151 | vty_out(vty, " E1 TEI %u, SAPI %u%s", |
Harald Welte | 68628e8 | 2009-03-10 12:17:57 +0000 | [diff] [blame] | 152 | e1l->tei, e1l->sapi, VTY_NEWLINE); |
| 153 | } |
| 154 | |
| 155 | static void bts_dump_vty(struct vty *vty, struct gsm_bts *bts) |
| 156 | { |
Harald Welte | b908cb7 | 2009-12-22 13:09:29 +0100 | [diff] [blame] | 157 | struct pchan_load pl; |
| 158 | |
Holger Hans Peter Freyther | c4a49e3 | 2009-08-21 14:44:12 +0200 | [diff] [blame] | 159 | vty_out(vty, "BTS %u is of %s type in band %s, has CI %u LAC %u, " |
Harald Welte | fcd2445 | 2009-06-20 18:15:19 +0200 | [diff] [blame] | 160 | "BSIC %u, TSC %u and %u TRX%s", |
| 161 | bts->nr, btstype2str(bts->type), gsm_band_name(bts->band), |
Holger Hans Peter Freyther | c4a49e3 | 2009-08-21 14:44:12 +0200 | [diff] [blame] | 162 | bts->cell_identity, |
Harald Welte | fcd2445 | 2009-06-20 18:15:19 +0200 | [diff] [blame] | 163 | bts->location_area_code, bts->bsic, bts->tsc, |
| 164 | bts->num_trx, VTY_NEWLINE); |
Harald Welte | 1d8dbc4 | 2009-12-12 15:38:16 +0100 | [diff] [blame] | 165 | vty_out(vty, "MS Max power: %u dBm%s", bts->ms_max_power, VTY_NEWLINE); |
Harald Welte | 7322528 | 2009-12-12 18:17:25 +0100 | [diff] [blame] | 166 | vty_out(vty, "Minimum Rx Level for Access: %i dBm%s", |
Harald Welte | 1d8dbc4 | 2009-12-12 15:38:16 +0100 | [diff] [blame] | 167 | rxlev2dbm(bts->si_common.cell_sel_par.rxlev_acc_min), |
| 168 | VTY_NEWLINE); |
| 169 | vty_out(vty, "Cell Reselection Hysteresis: %u dBm%s", |
Harald Welte | 7322528 | 2009-12-12 18:17:25 +0100 | [diff] [blame] | 170 | bts->si_common.cell_sel_par.cell_resel_hyst*2, VTY_NEWLINE); |
Sylvain Munaut | 4010f1e | 2009-12-22 13:43:26 +0100 | [diff] [blame] | 171 | vty_out(vty, "RACH TX-Integer: %u%s", bts->si_common.rach_control.tx_integer, |
| 172 | VTY_NEWLINE); |
| 173 | vty_out(vty, "RACH Max transmissions: %u%s", |
| 174 | rach_max_trans_raw2val(bts->si_common.rach_control.max_trans), |
| 175 | VTY_NEWLINE); |
Harald Welte | 7135501 | 2009-12-21 23:08:18 +0100 | [diff] [blame] | 176 | if (bts->si_common.rach_control.cell_bar) |
Harald Welte (local) | 5dececf | 2009-08-12 13:28:23 +0200 | [diff] [blame] | 177 | vty_out(vty, " CELL IS BARRED%s", VTY_NEWLINE); |
Harald Welte | 4cc3422 | 2009-05-01 15:12:31 +0000 | [diff] [blame] | 178 | if (is_ipaccess_bts(bts)) |
Harald Welte | 8175e95 | 2009-10-20 00:22:00 +0200 | [diff] [blame] | 179 | vty_out(vty, " Unit ID: %u/%u/0, OML Stream ID 0x%02x%s", |
Harald Welte | 4cc3422 | 2009-05-01 15:12:31 +0000 | [diff] [blame] | 180 | bts->ip_access.site_id, bts->ip_access.bts_id, |
Harald Welte | 8175e95 | 2009-10-20 00:22:00 +0200 | [diff] [blame] | 181 | bts->oml_tei, VTY_NEWLINE); |
Harald Welte | 68628e8 | 2009-03-10 12:17:57 +0000 | [diff] [blame] | 182 | vty_out(vty, " NM State: "); |
| 183 | net_dump_nmstate(vty, &bts->nm_state); |
| 184 | vty_out(vty, " Site Mgr NM State: "); |
| 185 | net_dump_nmstate(vty, &bts->site_mgr.nm_state); |
| 186 | vty_out(vty, " Paging: FIXME pending requests, %u free slots%s", |
| 187 | bts->paging.available_slots, VTY_NEWLINE); |
Harald Welte | 8175e95 | 2009-10-20 00:22:00 +0200 | [diff] [blame] | 188 | if (!is_ipaccess_bts(bts)) { |
| 189 | vty_out(vty, " E1 Signalling Link:%s", VTY_NEWLINE); |
| 190 | e1isl_dump_vty(vty, bts->oml_link); |
| 191 | } |
Harald Welte | 68628e8 | 2009-03-10 12:17:57 +0000 | [diff] [blame] | 192 | /* FIXME: oml_link, chan_desc */ |
Harald Welte | b908cb7 | 2009-12-22 13:09:29 +0100 | [diff] [blame] | 193 | memset(&pl, 0, sizeof(pl)); |
| 194 | bts_chan_load(&pl, bts); |
| 195 | vty_out(vty, " Current Channel Load:%s", VTY_NEWLINE); |
| 196 | dump_pchan_load_vty(vty, " ", &pl); |
Harald Welte | 68628e8 | 2009-03-10 12:17:57 +0000 | [diff] [blame] | 197 | } |
| 198 | |
| 199 | DEFUN(show_bts, show_bts_cmd, "show bts [number]", |
| 200 | SHOW_STR "Display information about a BTS\n" |
| 201 | "BTS number") |
| 202 | { |
| 203 | struct gsm_network *net = gsmnet; |
| 204 | int bts_nr; |
| 205 | |
| 206 | if (argc != 0) { |
| 207 | /* use the BTS number that the user has specified */ |
| 208 | bts_nr = atoi(argv[0]); |
| 209 | if (bts_nr > net->num_bts) { |
Harald Welte | 1bc7735 | 2009-03-10 19:47:51 +0000 | [diff] [blame] | 210 | vty_out(vty, "%% can't find BTS '%s'%s", argv[0], |
Harald Welte | 68628e8 | 2009-03-10 12:17:57 +0000 | [diff] [blame] | 211 | VTY_NEWLINE); |
| 212 | return CMD_WARNING; |
| 213 | } |
Harald Welte | e441d9c | 2009-06-21 16:17:15 +0200 | [diff] [blame] | 214 | bts_dump_vty(vty, gsm_bts_num(net, bts_nr)); |
Harald Welte | 68628e8 | 2009-03-10 12:17:57 +0000 | [diff] [blame] | 215 | return CMD_SUCCESS; |
| 216 | } |
| 217 | /* print all BTS's */ |
| 218 | for (bts_nr = 0; bts_nr < net->num_bts; bts_nr++) |
Harald Welte | e441d9c | 2009-06-21 16:17:15 +0200 | [diff] [blame] | 219 | bts_dump_vty(vty, gsm_bts_num(net, bts_nr)); |
Harald Welte | 68628e8 | 2009-03-10 12:17:57 +0000 | [diff] [blame] | 220 | |
| 221 | return CMD_SUCCESS; |
| 222 | } |
| 223 | |
Harald Welte | 4258182 | 2009-08-08 16:12:58 +0200 | [diff] [blame] | 224 | /* utility functions */ |
| 225 | static void parse_e1_link(struct gsm_e1_subslot *e1_link, const char *line, |
| 226 | const char *ts, const char *ss) |
| 227 | { |
| 228 | e1_link->e1_nr = atoi(line); |
| 229 | e1_link->e1_ts = atoi(ts); |
| 230 | if (!strcmp(ss, "full")) |
| 231 | e1_link->e1_ts_ss = 255; |
| 232 | else |
| 233 | e1_link->e1_ts_ss = atoi(ss); |
| 234 | } |
| 235 | |
| 236 | static void config_write_e1_link(struct vty *vty, struct gsm_e1_subslot *e1_link, |
| 237 | const char *prefix) |
| 238 | { |
| 239 | if (!e1_link->e1_ts) |
| 240 | return; |
| 241 | |
| 242 | if (e1_link->e1_ts_ss == 255) |
| 243 | vty_out(vty, "%se1 line %u timeslot %u sub-slot full%s", |
| 244 | prefix, e1_link->e1_nr, e1_link->e1_ts, VTY_NEWLINE); |
| 245 | else |
| 246 | vty_out(vty, "%se1 line %u timeslot %u sub-slot %u%s", |
| 247 | prefix, e1_link->e1_nr, e1_link->e1_ts, |
| 248 | e1_link->e1_ts_ss, VTY_NEWLINE); |
| 249 | } |
| 250 | |
| 251 | |
Harald Welte | 67ce073 | 2009-08-06 19:06:46 +0200 | [diff] [blame] | 252 | static void config_write_ts_single(struct vty *vty, struct gsm_bts_trx_ts *ts) |
| 253 | { |
Harald Welte | 4258182 | 2009-08-08 16:12:58 +0200 | [diff] [blame] | 254 | vty_out(vty, " timeslot %u%s", ts->nr, VTY_NEWLINE); |
| 255 | if (ts->pchan != GSM_PCHAN_NONE) |
| 256 | vty_out(vty, " phys_chan_config %s%s", |
| 257 | gsm_pchan_name(ts->pchan), VTY_NEWLINE); |
| 258 | config_write_e1_link(vty, &ts->e1_link, " "); |
Harald Welte | 67ce073 | 2009-08-06 19:06:46 +0200 | [diff] [blame] | 259 | } |
| 260 | |
| 261 | static void config_write_trx_single(struct vty *vty, struct gsm_bts_trx *trx) |
| 262 | { |
| 263 | int i; |
| 264 | |
Harald Welte | 5013b2a | 2009-08-07 13:29:14 +0200 | [diff] [blame] | 265 | vty_out(vty, " trx %u%s", trx->nr, VTY_NEWLINE); |
| 266 | vty_out(vty, " arfcn %u%s", trx->arfcn, VTY_NEWLINE); |
| 267 | vty_out(vty, " max_power_red %u%s", trx->max_power_red, VTY_NEWLINE); |
Harald Welte | 4258182 | 2009-08-08 16:12:58 +0200 | [diff] [blame] | 268 | config_write_e1_link(vty, &trx->rsl_e1_link, " rsl "); |
| 269 | vty_out(vty, " rsl e1 tei %u%s", trx->rsl_tei, VTY_NEWLINE); |
Harald Welte | 67ce073 | 2009-08-06 19:06:46 +0200 | [diff] [blame] | 270 | |
| 271 | for (i = 0; i < TRX_NR_TS; i++) |
| 272 | config_write_ts_single(vty, &trx->ts[i]); |
| 273 | } |
| 274 | |
| 275 | static void config_write_bts_single(struct vty *vty, struct gsm_bts *bts) |
| 276 | { |
| 277 | struct gsm_bts_trx *trx; |
| 278 | |
Harald Welte | 5013b2a | 2009-08-07 13:29:14 +0200 | [diff] [blame] | 279 | vty_out(vty, " bts %u%s", bts->nr, VTY_NEWLINE); |
| 280 | vty_out(vty, " type %s%s", btstype2str(bts->type), VTY_NEWLINE); |
| 281 | vty_out(vty, " band %s%s", gsm_band_name(bts->band), VTY_NEWLINE); |
Holger Hans Peter Freyther | f926ed6 | 2009-11-19 16:38:49 +0100 | [diff] [blame] | 282 | vty_out(vty, " cell_identity %u%s", bts->cell_identity, VTY_NEWLINE); |
Harald Welte | 5013b2a | 2009-08-07 13:29:14 +0200 | [diff] [blame] | 283 | vty_out(vty, " location_area_code %u%s", bts->location_area_code, |
Harald Welte | 67ce073 | 2009-08-06 19:06:46 +0200 | [diff] [blame] | 284 | VTY_NEWLINE); |
Harald Welte | 5013b2a | 2009-08-07 13:29:14 +0200 | [diff] [blame] | 285 | vty_out(vty, " training_sequence_code %u%s", bts->tsc, VTY_NEWLINE); |
| 286 | vty_out(vty, " base_station_id_code %u%s", bts->bsic, VTY_NEWLINE); |
Harald Welte (local) | 0e451d0 | 2009-08-13 10:14:26 +0200 | [diff] [blame] | 287 | vty_out(vty, " ms max power %u%s", bts->ms_max_power, VTY_NEWLINE); |
Harald Welte | 7322528 | 2009-12-12 18:17:25 +0100 | [diff] [blame] | 288 | vty_out(vty, " cell reselection hysteresis %u%s", |
| 289 | bts->si_common.cell_sel_par.cell_resel_hyst*2, VTY_NEWLINE); |
| 290 | vty_out(vty, " rxlev access min %u%s", |
| 291 | bts->si_common.cell_sel_par.rxlev_acc_min, VTY_NEWLINE); |
Harald Welte | a43f789 | 2009-12-01 18:04:30 +0530 | [diff] [blame] | 292 | if (bts->si_common.chan_desc.t3212) |
Harald Welte (local) | efc9231 | 2009-08-14 23:09:25 +0200 | [diff] [blame] | 293 | vty_out(vty, " periodic location update %u%s", |
Harald Welte | a43f789 | 2009-12-01 18:04:30 +0530 | [diff] [blame] | 294 | bts->si_common.chan_desc.t3212 * 10, VTY_NEWLINE); |
Harald Welte | 7a8fa41 | 2009-08-10 13:48:16 +0200 | [diff] [blame] | 295 | vty_out(vty, " channel allocator %s%s", |
| 296 | bts->chan_alloc_reverse ? "descending" : "ascending", |
| 297 | VTY_NEWLINE); |
Sylvain Munaut | 4010f1e | 2009-12-22 13:43:26 +0100 | [diff] [blame] | 298 | vty_out(vty, " rach tx integer %u%s", |
| 299 | bts->si_common.rach_control.tx_integer, VTY_NEWLINE); |
| 300 | vty_out(vty, " rach max transmission %u%s", |
| 301 | rach_max_trans_raw2val(bts->si_common.rach_control.max_trans), |
| 302 | VTY_NEWLINE); |
Harald Welte | 7135501 | 2009-12-21 23:08:18 +0100 | [diff] [blame] | 303 | if (bts->si_common.rach_control.cell_bar) |
Harald Welte (local) | 5dececf | 2009-08-12 13:28:23 +0200 | [diff] [blame] | 304 | vty_out(vty, " cell barred 1%s", VTY_NEWLINE); |
Harald Welte | 8175e95 | 2009-10-20 00:22:00 +0200 | [diff] [blame] | 305 | if (is_ipaccess_bts(bts)) { |
Harald Welte | 5013b2a | 2009-08-07 13:29:14 +0200 | [diff] [blame] | 306 | vty_out(vty, " ip.access unit_id %u %u%s", |
Harald Welte | a6fd58e | 2009-08-07 00:25:23 +0200 | [diff] [blame] | 307 | bts->ip_access.site_id, bts->ip_access.bts_id, VTY_NEWLINE); |
Harald Welte | 8175e95 | 2009-10-20 00:22:00 +0200 | [diff] [blame] | 308 | vty_out(vty, " oml ip.access stream_id %u%s", bts->oml_tei, VTY_NEWLINE); |
| 309 | } else { |
Harald Welte | 4258182 | 2009-08-08 16:12:58 +0200 | [diff] [blame] | 310 | config_write_e1_link(vty, &bts->oml_e1_link, " oml "); |
| 311 | vty_out(vty, " oml e1 tei %u%s", bts->oml_tei, VTY_NEWLINE); |
| 312 | } |
Harald Welte | 67ce073 | 2009-08-06 19:06:46 +0200 | [diff] [blame] | 313 | |
| 314 | llist_for_each_entry(trx, &bts->trx_list, list) |
| 315 | config_write_trx_single(vty, trx); |
| 316 | } |
| 317 | |
| 318 | static int config_write_bts(struct vty *v) |
| 319 | { |
| 320 | struct gsm_bts *bts; |
| 321 | |
| 322 | llist_for_each_entry(bts, &gsmnet->bts_list, list) |
| 323 | config_write_bts_single(v, bts); |
| 324 | |
| 325 | return CMD_SUCCESS; |
| 326 | } |
| 327 | |
Harald Welte | 5013b2a | 2009-08-07 13:29:14 +0200 | [diff] [blame] | 328 | static int config_write_net(struct vty *vty) |
| 329 | { |
| 330 | vty_out(vty, "network%s", VTY_NEWLINE); |
Harald Welte | 4258182 | 2009-08-08 16:12:58 +0200 | [diff] [blame] | 331 | vty_out(vty, " network country code %u%s", gsmnet->country_code, VTY_NEWLINE); |
Harald Welte | 5013b2a | 2009-08-07 13:29:14 +0200 | [diff] [blame] | 332 | vty_out(vty, " mobile network code %u%s", gsmnet->network_code, VTY_NEWLINE); |
Harald Welte | 4258182 | 2009-08-08 16:12:58 +0200 | [diff] [blame] | 333 | vty_out(vty, " short name %s%s", gsmnet->name_short, VTY_NEWLINE); |
| 334 | vty_out(vty, " long name %s%s", gsmnet->name_long, VTY_NEWLINE); |
Harald Welte (local) | 69de397 | 2009-08-12 14:42:23 +0200 | [diff] [blame] | 335 | vty_out(vty, " auth policy %s%s", gsm_auth_policy_name(gsmnet->auth_policy), VTY_NEWLINE); |
Harald Welte | 1085c09 | 2009-11-18 20:33:19 +0100 | [diff] [blame] | 336 | vty_out(vty, " location updating reject cause %u%s", |
| 337 | gsmnet->reject_cause, VTY_NEWLINE); |
Harald Welte | 4381cfe | 2009-08-30 15:47:06 +0900 | [diff] [blame] | 338 | vty_out(vty, " encryption a5 %u%s", gsmnet->a5_encryption, VTY_NEWLINE); |
Holger Hans Peter Freyther | d54c337 | 2009-11-19 16:37:48 +0100 | [diff] [blame] | 339 | vty_out(vty, " neci %u%s", gsmnet->neci, VTY_NEWLINE); |
Harald Welte | eab84a1 | 2009-12-13 10:53:12 +0100 | [diff] [blame] | 340 | vty_out(vty, " rrlp mode %s%s", rrlp_mode_name(gsmnet->rrlp.mode), |
| 341 | VTY_NEWLINE); |
Harald Welte | 648b6ce | 2009-12-14 09:00:24 +0100 | [diff] [blame] | 342 | vty_out(vty, " mm info %u%s", gsmnet->send_mm_info, VTY_NEWLINE); |
Harald Welte | bc81450 | 2009-12-19 21:41:52 +0100 | [diff] [blame] | 343 | vty_out(vty, " handover %u%s", gsmnet->handover.active, VTY_NEWLINE); |
Harald Welte | b720bd3 | 2009-12-21 16:51:50 +0100 | [diff] [blame] | 344 | vty_out(vty, " handover window rxlev averaging %u%s", |
| 345 | gsmnet->handover.win_rxlev_avg, VTY_NEWLINE); |
| 346 | vty_out(vty, " handover window rxqual averaging %u%s", |
| 347 | gsmnet->handover.win_rxqual_avg, VTY_NEWLINE); |
| 348 | vty_out(vty, " handover window rxlev neighbor averaging %u%s", |
| 349 | gsmnet->handover.win_rxlev_avg_neigh, VTY_NEWLINE); |
| 350 | vty_out(vty, " handover power budget interval %u%s", |
| 351 | gsmnet->handover.pwr_interval, VTY_NEWLINE); |
| 352 | vty_out(vty, " handover power budget hysteresis %u%s", |
| 353 | gsmnet->handover.pwr_hysteresis, VTY_NEWLINE); |
| 354 | vty_out(vty, " handover maximum distance %u%s", |
| 355 | gsmnet->handover.max_distance, VTY_NEWLINE); |
Holger Hans Peter Freyther | c4d88ad | 2009-11-21 21:18:38 +0100 | [diff] [blame] | 356 | vty_out(vty, " timer t3101 %u%s", gsmnet->T3101, VTY_NEWLINE); |
Holger Hans Peter Freyther | 23975e7 | 2009-11-21 21:42:26 +0100 | [diff] [blame] | 357 | vty_out(vty, " timer t3103 %u%s", gsmnet->T3103, VTY_NEWLINE); |
| 358 | vty_out(vty, " timer t3105 %u%s", gsmnet->T3105, VTY_NEWLINE); |
| 359 | vty_out(vty, " timer t3107 %u%s", gsmnet->T3107, VTY_NEWLINE); |
| 360 | vty_out(vty, " timer t3109 %u%s", gsmnet->T3109, VTY_NEWLINE); |
| 361 | vty_out(vty, " timer t3111 %u%s", gsmnet->T3111, VTY_NEWLINE); |
| 362 | vty_out(vty, " timer t3113 %u%s", gsmnet->T3113, VTY_NEWLINE); |
| 363 | vty_out(vty, " timer t3115 %u%s", gsmnet->T3115, VTY_NEWLINE); |
| 364 | vty_out(vty, " timer t3117 %u%s", gsmnet->T3117, VTY_NEWLINE); |
| 365 | vty_out(vty, " timer t3119 %u%s", gsmnet->T3119, VTY_NEWLINE); |
| 366 | vty_out(vty, " timer t3141 %u%s", gsmnet->T3141, VTY_NEWLINE); |
Harald Welte | 5013b2a | 2009-08-07 13:29:14 +0200 | [diff] [blame] | 367 | |
| 368 | return CMD_SUCCESS; |
| 369 | } |
Harald Welte | 67ce073 | 2009-08-06 19:06:46 +0200 | [diff] [blame] | 370 | |
Harald Welte | 68628e8 | 2009-03-10 12:17:57 +0000 | [diff] [blame] | 371 | static void trx_dump_vty(struct vty *vty, struct gsm_bts_trx *trx) |
| 372 | { |
| 373 | vty_out(vty, "TRX %u of BTS %u is on ARFCN %u%s", |
| 374 | trx->nr, trx->bts->nr, trx->arfcn, VTY_NEWLINE); |
Harald Welte | fcd2445 | 2009-06-20 18:15:19 +0200 | [diff] [blame] | 375 | vty_out(vty, " RF Nominal Power: %d dBm, reduced by %u dB, " |
Harald Welte | 4258182 | 2009-08-08 16:12:58 +0200 | [diff] [blame] | 376 | "resulting BS power: %d dBm%s", |
Harald Welte | fcd2445 | 2009-06-20 18:15:19 +0200 | [diff] [blame] | 377 | trx->nominal_power, trx->max_power_red, |
Harald Welte | 4258182 | 2009-08-08 16:12:58 +0200 | [diff] [blame] | 378 | trx->nominal_power - trx->max_power_red, VTY_NEWLINE); |
Harald Welte | 68628e8 | 2009-03-10 12:17:57 +0000 | [diff] [blame] | 379 | vty_out(vty, " NM State: "); |
| 380 | net_dump_nmstate(vty, &trx->nm_state); |
| 381 | vty_out(vty, " Baseband Transceiver NM State: "); |
| 382 | net_dump_nmstate(vty, &trx->bb_transc.nm_state); |
Harald Welte | 8175e95 | 2009-10-20 00:22:00 +0200 | [diff] [blame] | 383 | if (is_ipaccess_bts(trx->bts)) { |
| 384 | vty_out(vty, " ip.access stream ID: 0x%02x%s", |
| 385 | trx->rsl_tei, VTY_NEWLINE); |
| 386 | } else { |
| 387 | vty_out(vty, " E1 Signalling Link:%s", VTY_NEWLINE); |
| 388 | e1isl_dump_vty(vty, trx->rsl_link); |
| 389 | } |
Harald Welte | 68628e8 | 2009-03-10 12:17:57 +0000 | [diff] [blame] | 390 | } |
| 391 | |
| 392 | DEFUN(show_trx, |
| 393 | show_trx_cmd, |
| 394 | "show trx [bts_nr] [trx_nr]", |
| 395 | SHOW_STR "Display information about a TRX\n") |
| 396 | { |
| 397 | struct gsm_network *net = gsmnet; |
| 398 | struct gsm_bts *bts = NULL; |
| 399 | struct gsm_bts_trx *trx; |
| 400 | int bts_nr, trx_nr; |
| 401 | |
| 402 | if (argc >= 1) { |
| 403 | /* use the BTS number that the user has specified */ |
| 404 | bts_nr = atoi(argv[0]); |
| 405 | if (bts_nr >= net->num_bts) { |
Harald Welte | 1bc7735 | 2009-03-10 19:47:51 +0000 | [diff] [blame] | 406 | vty_out(vty, "%% can't find BTS '%s'%s", argv[0], |
Harald Welte | 68628e8 | 2009-03-10 12:17:57 +0000 | [diff] [blame] | 407 | VTY_NEWLINE); |
| 408 | return CMD_WARNING; |
| 409 | } |
Harald Welte | e441d9c | 2009-06-21 16:17:15 +0200 | [diff] [blame] | 410 | bts = gsm_bts_num(net, bts_nr); |
Harald Welte | 68628e8 | 2009-03-10 12:17:57 +0000 | [diff] [blame] | 411 | } |
| 412 | if (argc >= 2) { |
| 413 | trx_nr = atoi(argv[1]); |
| 414 | if (trx_nr >= bts->num_trx) { |
Harald Welte | 1bc7735 | 2009-03-10 19:47:51 +0000 | [diff] [blame] | 415 | vty_out(vty, "%% can't find TRX '%s'%s", argv[1], |
Harald Welte | 68628e8 | 2009-03-10 12:17:57 +0000 | [diff] [blame] | 416 | VTY_NEWLINE); |
| 417 | return CMD_WARNING; |
| 418 | } |
Harald Welte | e441d9c | 2009-06-21 16:17:15 +0200 | [diff] [blame] | 419 | trx = gsm_bts_trx_num(bts, trx_nr); |
Harald Welte | 68628e8 | 2009-03-10 12:17:57 +0000 | [diff] [blame] | 420 | trx_dump_vty(vty, trx); |
| 421 | return CMD_SUCCESS; |
| 422 | } |
| 423 | if (bts) { |
| 424 | /* print all TRX in this BTS */ |
| 425 | for (trx_nr = 0; trx_nr < bts->num_trx; trx_nr++) { |
Harald Welte | e441d9c | 2009-06-21 16:17:15 +0200 | [diff] [blame] | 426 | trx = gsm_bts_trx_num(bts, trx_nr); |
Harald Welte | 68628e8 | 2009-03-10 12:17:57 +0000 | [diff] [blame] | 427 | trx_dump_vty(vty, trx); |
| 428 | } |
| 429 | return CMD_SUCCESS; |
| 430 | } |
| 431 | |
| 432 | for (bts_nr = 0; bts_nr < net->num_bts; bts_nr++) { |
Harald Welte | e441d9c | 2009-06-21 16:17:15 +0200 | [diff] [blame] | 433 | bts = gsm_bts_num(net, bts_nr); |
Harald Welte | 68628e8 | 2009-03-10 12:17:57 +0000 | [diff] [blame] | 434 | for (trx_nr = 0; trx_nr < bts->num_trx; trx_nr++) { |
Harald Welte | e441d9c | 2009-06-21 16:17:15 +0200 | [diff] [blame] | 435 | trx = gsm_bts_trx_num(bts, trx_nr); |
Harald Welte | 68628e8 | 2009-03-10 12:17:57 +0000 | [diff] [blame] | 436 | trx_dump_vty(vty, trx); |
| 437 | } |
| 438 | } |
| 439 | |
| 440 | return CMD_SUCCESS; |
| 441 | } |
| 442 | |
Harald Welte | 67ce073 | 2009-08-06 19:06:46 +0200 | [diff] [blame] | 443 | |
Harald Welte | 68628e8 | 2009-03-10 12:17:57 +0000 | [diff] [blame] | 444 | static void ts_dump_vty(struct vty *vty, struct gsm_bts_trx_ts *ts) |
| 445 | { |
Harald Welte | 68628e8 | 2009-03-10 12:17:57 +0000 | [diff] [blame] | 446 | vty_out(vty, "Timeslot %u of TRX %u in BTS %u, phys cfg %s%s", |
| 447 | ts->nr, ts->trx->nr, ts->trx->bts->nr, |
| 448 | gsm_pchan_name(ts->pchan), VTY_NEWLINE); |
| 449 | vty_out(vty, " NM State: "); |
| 450 | net_dump_nmstate(vty, &ts->nm_state); |
Harald Welte | 2c82899 | 2009-12-02 01:56:49 +0530 | [diff] [blame] | 451 | if (!is_ipaccess_bts(ts->trx->bts)) |
Harald Welte | ef235b5 | 2009-03-10 12:34:02 +0000 | [diff] [blame] | 452 | vty_out(vty, " E1 Line %u, Timeslot %u, Subslot %u%s", |
| 453 | ts->e1_link.e1_nr, ts->e1_link.e1_ts, |
| 454 | ts->e1_link.e1_ts_ss, VTY_NEWLINE); |
Harald Welte | 68628e8 | 2009-03-10 12:17:57 +0000 | [diff] [blame] | 455 | } |
| 456 | |
| 457 | DEFUN(show_ts, |
| 458 | show_ts_cmd, |
Harald Welte | 1bc7735 | 2009-03-10 19:47:51 +0000 | [diff] [blame] | 459 | "show timeslot [bts_nr] [trx_nr] [ts_nr]", |
Harald Welte | 68628e8 | 2009-03-10 12:17:57 +0000 | [diff] [blame] | 460 | SHOW_STR "Display information about a TS\n") |
| 461 | { |
| 462 | struct gsm_network *net = gsmnet; |
| 463 | struct gsm_bts *bts; |
| 464 | struct gsm_bts_trx *trx; |
| 465 | struct gsm_bts_trx_ts *ts; |
| 466 | int bts_nr, trx_nr, ts_nr; |
| 467 | |
| 468 | if (argc >= 1) { |
| 469 | /* use the BTS number that the user has specified */ |
| 470 | bts_nr = atoi(argv[0]); |
| 471 | if (bts_nr >= net->num_bts) { |
Harald Welte | 1bc7735 | 2009-03-10 19:47:51 +0000 | [diff] [blame] | 472 | vty_out(vty, "%% can't find BTS '%s'%s", argv[0], |
Harald Welte | 68628e8 | 2009-03-10 12:17:57 +0000 | [diff] [blame] | 473 | VTY_NEWLINE); |
| 474 | return CMD_WARNING; |
| 475 | } |
Harald Welte | e441d9c | 2009-06-21 16:17:15 +0200 | [diff] [blame] | 476 | bts = gsm_bts_num(net, bts_nr); |
Harald Welte | 68628e8 | 2009-03-10 12:17:57 +0000 | [diff] [blame] | 477 | } |
| 478 | if (argc >= 2) { |
| 479 | trx_nr = atoi(argv[1]); |
| 480 | if (trx_nr >= bts->num_trx) { |
Harald Welte | 1bc7735 | 2009-03-10 19:47:51 +0000 | [diff] [blame] | 481 | vty_out(vty, "%% can't find TRX '%s'%s", argv[1], |
Harald Welte | 68628e8 | 2009-03-10 12:17:57 +0000 | [diff] [blame] | 482 | VTY_NEWLINE); |
| 483 | return CMD_WARNING; |
| 484 | } |
Harald Welte | e441d9c | 2009-06-21 16:17:15 +0200 | [diff] [blame] | 485 | trx = gsm_bts_trx_num(bts, trx_nr); |
Harald Welte | 68628e8 | 2009-03-10 12:17:57 +0000 | [diff] [blame] | 486 | } |
| 487 | if (argc >= 3) { |
| 488 | ts_nr = atoi(argv[2]); |
| 489 | if (ts_nr >= TRX_NR_TS) { |
Harald Welte | 1bc7735 | 2009-03-10 19:47:51 +0000 | [diff] [blame] | 490 | vty_out(vty, "%% can't find TS '%s'%s", argv[2], |
Harald Welte | 68628e8 | 2009-03-10 12:17:57 +0000 | [diff] [blame] | 491 | VTY_NEWLINE); |
| 492 | return CMD_WARNING; |
| 493 | } |
| 494 | ts = &trx->ts[ts_nr]; |
| 495 | ts_dump_vty(vty, ts); |
| 496 | return CMD_SUCCESS; |
| 497 | } |
| 498 | for (bts_nr = 0; bts_nr < net->num_bts; bts_nr++) { |
Harald Welte | e441d9c | 2009-06-21 16:17:15 +0200 | [diff] [blame] | 499 | bts = gsm_bts_num(net, bts_nr); |
Harald Welte | 68628e8 | 2009-03-10 12:17:57 +0000 | [diff] [blame] | 500 | for (trx_nr = 0; trx_nr < bts->num_trx; trx_nr++) { |
Harald Welte | e441d9c | 2009-06-21 16:17:15 +0200 | [diff] [blame] | 501 | trx = gsm_bts_trx_num(bts, trx_nr); |
Harald Welte | 68628e8 | 2009-03-10 12:17:57 +0000 | [diff] [blame] | 502 | for (ts_nr = 0; ts_nr < TRX_NR_TS; ts_nr++) { |
| 503 | ts = &trx->ts[ts_nr]; |
| 504 | ts_dump_vty(vty, ts); |
| 505 | } |
| 506 | } |
| 507 | } |
| 508 | |
| 509 | return CMD_SUCCESS; |
| 510 | } |
| 511 | |
Holger Hans Peter Freyther | cfa90d4 | 2009-08-10 10:17:50 +0200 | [diff] [blame] | 512 | void subscr_dump_vty(struct vty *vty, struct gsm_subscriber *subscr) |
Harald Welte | 68628e8 | 2009-03-10 12:17:57 +0000 | [diff] [blame] | 513 | { |
Harald Welte | fcd2445 | 2009-06-20 18:15:19 +0200 | [diff] [blame] | 514 | vty_out(vty, " ID: %llu, Authorized: %d%s", subscr->id, |
Harald Welte | 40f8289 | 2009-05-23 17:31:39 +0000 | [diff] [blame] | 515 | subscr->authorized, VTY_NEWLINE); |
Harald Welte | 68628e8 | 2009-03-10 12:17:57 +0000 | [diff] [blame] | 516 | if (subscr->name) |
Harald Welte | 1bc7735 | 2009-03-10 19:47:51 +0000 | [diff] [blame] | 517 | vty_out(vty, " Name: '%s'%s", subscr->name, VTY_NEWLINE); |
Harald Welte | 68628e8 | 2009-03-10 12:17:57 +0000 | [diff] [blame] | 518 | if (subscr->extension) |
| 519 | vty_out(vty, " Extension: %s%s", subscr->extension, |
| 520 | VTY_NEWLINE); |
| 521 | if (subscr->imsi) |
| 522 | vty_out(vty, " IMSI: %s%s", subscr->imsi, VTY_NEWLINE); |
Holger Hans Peter Freyther | 2223025 | 2009-08-19 12:53:57 +0200 | [diff] [blame] | 523 | if (subscr->tmsi != GSM_RESERVED_TMSI) |
| 524 | vty_out(vty, " TMSI: %08X%s", subscr->tmsi, |
Harald Welte | 731fd91 | 2009-08-15 03:24:51 +0200 | [diff] [blame] | 525 | VTY_NEWLINE); |
Harald Welte (local) | 15920de | 2009-08-14 20:27:16 +0200 | [diff] [blame] | 526 | vty_out(vty, " Use count: %u%s", subscr->use_count, VTY_NEWLINE); |
Harald Welte | 68628e8 | 2009-03-10 12:17:57 +0000 | [diff] [blame] | 527 | } |
| 528 | |
| 529 | static void lchan_dump_vty(struct vty *vty, struct gsm_lchan *lchan) |
| 530 | { |
| 531 | vty_out(vty, "Lchan %u in Timeslot %u of TRX %u in BTS %u, Type %s%s", |
| 532 | lchan->nr, lchan->ts->nr, lchan->ts->trx->nr, |
| 533 | lchan->ts->trx->bts->nr, gsm_lchan_name(lchan->type), |
| 534 | VTY_NEWLINE); |
| 535 | vty_out(vty, " Use Count: %u%s", lchan->use_count, VTY_NEWLINE); |
Harald Welte | 7322528 | 2009-12-12 18:17:25 +0100 | [diff] [blame] | 536 | vty_out(vty, " BS Power: %u dBm, MS Power: %u dBm%s", |
| 537 | lchan->ts->trx->nominal_power - lchan->ts->trx->max_power_red |
| 538 | - lchan->bs_power*2, |
| 539 | ms_pwr_dbm(lchan->ts->trx->bts->band, lchan->ms_power), |
| 540 | VTY_NEWLINE); |
Harald Welte | 68628e8 | 2009-03-10 12:17:57 +0000 | [diff] [blame] | 541 | if (lchan->subscr) { |
| 542 | vty_out(vty, " Subscriber:%s", VTY_NEWLINE); |
| 543 | subscr_dump_vty(vty, lchan->subscr); |
| 544 | } else |
| 545 | vty_out(vty, " No Subscriber%s", VTY_NEWLINE); |
Harald Welte | 2c82899 | 2009-12-02 01:56:49 +0530 | [diff] [blame] | 546 | if (is_ipaccess_bts(lchan->ts->trx->bts)) { |
| 547 | struct in_addr ia; |
| 548 | ia.s_addr = lchan->abis_ip.bound_ip; |
| 549 | vty_out(vty, " Bound IP: %s Port %u RTP_TYPE2=%u CONN_ID=%u%s", |
| 550 | inet_ntoa(ia), lchan->abis_ip.bound_port, |
| 551 | lchan->abis_ip.rtp_payload2, lchan->abis_ip.conn_id, |
| 552 | VTY_NEWLINE); |
| 553 | } |
Harald Welte | 68628e8 | 2009-03-10 12:17:57 +0000 | [diff] [blame] | 554 | } |
| 555 | |
Harald Welte | 4bfdfe7 | 2009-06-10 23:11:52 +0800 | [diff] [blame] | 556 | #if 0 |
| 557 | 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] | 558 | static void call_dump_vty(struct vty *vty, struct gsm_call *call) |
| 559 | { |
| 560 | vty_out(vty, "Call Type %u, State %u, Transaction ID %u%s", |
| 561 | call->type, call->state, call->transaction_id, VTY_NEWLINE); |
| 562 | |
| 563 | if (call->local_lchan) { |
| 564 | vty_out(vty, "Call Local Channel:%s", VTY_NEWLINE); |
| 565 | lchan_dump_vty(vty, call->local_lchan); |
| 566 | } else |
| 567 | vty_out(vty, "Call has no Local Channel%s", VTY_NEWLINE); |
| 568 | |
| 569 | if (call->remote_lchan) { |
| 570 | vty_out(vty, "Call Remote Channel:%s", VTY_NEWLINE); |
| 571 | lchan_dump_vty(vty, call->remote_lchan); |
| 572 | } else |
| 573 | vty_out(vty, "Call has no Remote Channel%s", VTY_NEWLINE); |
| 574 | |
| 575 | if (call->called_subscr) { |
| 576 | vty_out(vty, "Called Subscriber:%s", VTY_NEWLINE); |
| 577 | subscr_dump_vty(vty, call->called_subscr); |
| 578 | } else |
| 579 | vty_out(vty, "Call has no Called Subscriber%s", VTY_NEWLINE); |
| 580 | } |
Harald Welte | 4bfdfe7 | 2009-06-10 23:11:52 +0800 | [diff] [blame] | 581 | #endif |
Harald Welte | 68628e8 | 2009-03-10 12:17:57 +0000 | [diff] [blame] | 582 | |
| 583 | DEFUN(show_lchan, |
| 584 | show_lchan_cmd, |
| 585 | "show lchan [bts_nr] [trx_nr] [ts_nr] [lchan_nr]", |
| 586 | SHOW_STR "Display information about a logical channel\n") |
| 587 | { |
| 588 | struct gsm_network *net = gsmnet; |
| 589 | struct gsm_bts *bts; |
| 590 | struct gsm_bts_trx *trx; |
| 591 | struct gsm_bts_trx_ts *ts; |
| 592 | struct gsm_lchan *lchan; |
| 593 | int bts_nr, trx_nr, ts_nr, lchan_nr; |
| 594 | |
| 595 | if (argc >= 1) { |
| 596 | /* use the BTS number that the user has specified */ |
| 597 | bts_nr = atoi(argv[0]); |
| 598 | if (bts_nr >= net->num_bts) { |
| 599 | vty_out(vty, "%% can't find BTS %s%s", argv[0], |
| 600 | VTY_NEWLINE); |
| 601 | return CMD_WARNING; |
| 602 | } |
Harald Welte | e441d9c | 2009-06-21 16:17:15 +0200 | [diff] [blame] | 603 | bts = gsm_bts_num(net, bts_nr); |
Harald Welte | 68628e8 | 2009-03-10 12:17:57 +0000 | [diff] [blame] | 604 | } |
| 605 | if (argc >= 2) { |
| 606 | trx_nr = atoi(argv[1]); |
| 607 | if (trx_nr >= bts->num_trx) { |
| 608 | vty_out(vty, "%% can't find TRX %s%s", argv[1], |
| 609 | VTY_NEWLINE); |
| 610 | return CMD_WARNING; |
| 611 | } |
Harald Welte | e441d9c | 2009-06-21 16:17:15 +0200 | [diff] [blame] | 612 | trx = gsm_bts_trx_num(bts, trx_nr); |
Harald Welte | 68628e8 | 2009-03-10 12:17:57 +0000 | [diff] [blame] | 613 | } |
| 614 | if (argc >= 3) { |
| 615 | ts_nr = atoi(argv[2]); |
| 616 | if (ts_nr >= TRX_NR_TS) { |
| 617 | vty_out(vty, "%% can't find TS %s%s", argv[2], |
| 618 | VTY_NEWLINE); |
| 619 | return CMD_WARNING; |
| 620 | } |
| 621 | ts = &trx->ts[ts_nr]; |
| 622 | } |
| 623 | if (argc >= 4) { |
| 624 | lchan_nr = atoi(argv[3]); |
| 625 | if (lchan_nr >= TS_MAX_LCHAN) { |
| 626 | vty_out(vty, "%% can't find LCHAN %s%s", argv[3], |
| 627 | VTY_NEWLINE); |
| 628 | return CMD_WARNING; |
| 629 | } |
| 630 | lchan = &ts->lchan[lchan_nr]; |
| 631 | lchan_dump_vty(vty, lchan); |
| 632 | return CMD_SUCCESS; |
| 633 | } |
| 634 | for (bts_nr = 0; bts_nr < net->num_bts; bts_nr++) { |
Harald Welte | e441d9c | 2009-06-21 16:17:15 +0200 | [diff] [blame] | 635 | bts = gsm_bts_num(net, bts_nr); |
Harald Welte | 68628e8 | 2009-03-10 12:17:57 +0000 | [diff] [blame] | 636 | for (trx_nr = 0; trx_nr < bts->num_trx; trx_nr++) { |
Harald Welte | e441d9c | 2009-06-21 16:17:15 +0200 | [diff] [blame] | 637 | trx = gsm_bts_trx_num(bts, trx_nr); |
Harald Welte | 68628e8 | 2009-03-10 12:17:57 +0000 | [diff] [blame] | 638 | for (ts_nr = 0; ts_nr < TRX_NR_TS; ts_nr++) { |
| 639 | ts = &trx->ts[ts_nr]; |
| 640 | for (lchan_nr = 0; lchan_nr < TS_MAX_LCHAN; |
| 641 | lchan_nr++) { |
| 642 | lchan = &ts->lchan[lchan_nr]; |
Harald Welte | ef235b5 | 2009-03-10 12:34:02 +0000 | [diff] [blame] | 643 | if (lchan->type == GSM_LCHAN_NONE) |
| 644 | continue; |
Harald Welte | 68628e8 | 2009-03-10 12:17:57 +0000 | [diff] [blame] | 645 | lchan_dump_vty(vty, lchan); |
| 646 | } |
| 647 | } |
| 648 | } |
| 649 | } |
| 650 | |
| 651 | return CMD_SUCCESS; |
| 652 | } |
| 653 | |
Harald Welte | 1bc7735 | 2009-03-10 19:47:51 +0000 | [diff] [blame] | 654 | static void e1drv_dump_vty(struct vty *vty, struct e1inp_driver *drv) |
| 655 | { |
| 656 | vty_out(vty, "E1 Input Driver %s%s", drv->name, VTY_NEWLINE); |
| 657 | } |
| 658 | |
| 659 | DEFUN(show_e1drv, |
| 660 | show_e1drv_cmd, |
| 661 | "show e1_driver", |
| 662 | SHOW_STR "Display information about available E1 drivers\n") |
| 663 | { |
| 664 | struct e1inp_driver *drv; |
| 665 | |
| 666 | llist_for_each_entry(drv, &e1inp_driver_list, list) |
| 667 | e1drv_dump_vty(vty, drv); |
| 668 | |
| 669 | return CMD_SUCCESS; |
| 670 | } |
| 671 | |
Harald Welte | 68628e8 | 2009-03-10 12:17:57 +0000 | [diff] [blame] | 672 | static void e1line_dump_vty(struct vty *vty, struct e1inp_line *line) |
| 673 | { |
| 674 | vty_out(vty, "E1 Line Number %u, Name %s, Driver %s%s", |
| 675 | line->num, line->name ? line->name : "", |
| 676 | line->driver->name, VTY_NEWLINE); |
| 677 | } |
| 678 | |
| 679 | DEFUN(show_e1line, |
| 680 | show_e1line_cmd, |
| 681 | "show e1_line [line_nr]", |
| 682 | SHOW_STR "Display information about a E1 line\n") |
| 683 | { |
Harald Welte | 1bc7735 | 2009-03-10 19:47:51 +0000 | [diff] [blame] | 684 | struct e1inp_line *line; |
| 685 | |
| 686 | if (argc >= 1) { |
| 687 | int num = atoi(argv[0]); |
| 688 | llist_for_each_entry(line, &e1inp_line_list, list) { |
| 689 | if (line->num == num) { |
| 690 | e1line_dump_vty(vty, line); |
| 691 | return CMD_SUCCESS; |
| 692 | } |
| 693 | } |
| 694 | return CMD_WARNING; |
| 695 | } |
| 696 | |
| 697 | llist_for_each_entry(line, &e1inp_line_list, list) |
| 698 | e1line_dump_vty(vty, line); |
| 699 | |
| 700 | return CMD_SUCCESS; |
Harald Welte | 68628e8 | 2009-03-10 12:17:57 +0000 | [diff] [blame] | 701 | } |
| 702 | |
| 703 | static void e1ts_dump_vty(struct vty *vty, struct e1inp_ts *ts) |
| 704 | { |
Harald Welte | 4258182 | 2009-08-08 16:12:58 +0200 | [diff] [blame] | 705 | if (ts->type == E1INP_TS_TYPE_NONE) |
| 706 | return; |
Harald Welte | 1bc7735 | 2009-03-10 19:47:51 +0000 | [diff] [blame] | 707 | vty_out(vty, "E1 Timeslot %2u of Line %u is Type %s%s", |
| 708 | ts->num, ts->line->num, e1inp_tstype_name(ts->type), |
| 709 | VTY_NEWLINE); |
Harald Welte | 68628e8 | 2009-03-10 12:17:57 +0000 | [diff] [blame] | 710 | } |
| 711 | |
| 712 | DEFUN(show_e1ts, |
| 713 | show_e1ts_cmd, |
| 714 | "show e1_timeslot [line_nr] [ts_nr]", |
| 715 | SHOW_STR "Display information about a E1 timeslot\n") |
| 716 | { |
Harald Welte | 986c3d7 | 2009-11-17 06:12:16 +0100 | [diff] [blame] | 717 | struct e1inp_line *line = NULL; |
Harald Welte | 1bc7735 | 2009-03-10 19:47:51 +0000 | [diff] [blame] | 718 | struct e1inp_ts *ts; |
| 719 | int ts_nr; |
Harald Welte | 68628e8 | 2009-03-10 12:17:57 +0000 | [diff] [blame] | 720 | |
Harald Welte | 1bc7735 | 2009-03-10 19:47:51 +0000 | [diff] [blame] | 721 | if (argc == 0) { |
| 722 | llist_for_each_entry(line, &e1inp_line_list, list) { |
| 723 | for (ts_nr = 0; ts_nr < NUM_E1_TS; ts_nr++) { |
| 724 | ts = &line->ts[ts_nr]; |
| 725 | e1ts_dump_vty(vty, ts); |
| 726 | } |
| 727 | } |
| 728 | return CMD_SUCCESS; |
| 729 | } |
| 730 | if (argc >= 1) { |
| 731 | int num = atoi(argv[0]); |
| 732 | llist_for_each_entry(line, &e1inp_line_list, list) { |
| 733 | if (line->num == num) |
| 734 | break; |
| 735 | } |
| 736 | if (!line || line->num != num) { |
| 737 | vty_out(vty, "E1 line %s is invalid%s", |
| 738 | argv[0], VTY_NEWLINE); |
| 739 | return CMD_WARNING; |
| 740 | } |
| 741 | } |
| 742 | if (argc >= 2) { |
| 743 | ts_nr = atoi(argv[1]); |
| 744 | if (ts_nr > NUM_E1_TS) { |
| 745 | vty_out(vty, "E1 timeslot %s is invalid%s", |
| 746 | argv[1], VTY_NEWLINE); |
| 747 | return CMD_WARNING; |
| 748 | } |
| 749 | ts = &line->ts[ts_nr]; |
| 750 | e1ts_dump_vty(vty, ts); |
| 751 | return CMD_SUCCESS; |
| 752 | } else { |
| 753 | for (ts_nr = 0; ts_nr < NUM_E1_TS; ts_nr++) { |
| 754 | ts = &line->ts[ts_nr]; |
| 755 | e1ts_dump_vty(vty, ts); |
| 756 | } |
| 757 | return CMD_SUCCESS; |
| 758 | } |
| 759 | return CMD_SUCCESS; |
Harald Welte | 68628e8 | 2009-03-10 12:17:57 +0000 | [diff] [blame] | 760 | } |
| 761 | |
Harald Welte | be4b730 | 2009-05-23 16:59:33 +0000 | [diff] [blame] | 762 | 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] | 763 | { |
| 764 | vty_out(vty, "Paging on BTS %u%s", pag->bts->nr, VTY_NEWLINE); |
| 765 | subscr_dump_vty(vty, pag->subscr); |
| 766 | } |
| 767 | |
Harald Welte | be4b730 | 2009-05-23 16:59:33 +0000 | [diff] [blame] | 768 | 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] | 769 | { |
| 770 | struct gsm_paging_request *pag; |
| 771 | |
| 772 | llist_for_each_entry(pag, &bts->paging.pending_requests, entry) |
| 773 | paging_dump_vty(vty, pag); |
| 774 | } |
| 775 | |
| 776 | DEFUN(show_paging, |
| 777 | show_paging_cmd, |
| 778 | "show paging [bts_nr]", |
Harald Welte | be4b730 | 2009-05-23 16:59:33 +0000 | [diff] [blame] | 779 | SHOW_STR "Display information about paging reuqests of a BTS\n") |
Harald Welte | f5025b6 | 2009-03-28 16:55:11 +0000 | [diff] [blame] | 780 | { |
| 781 | struct gsm_network *net = gsmnet; |
| 782 | struct gsm_bts *bts; |
| 783 | int bts_nr; |
| 784 | |
| 785 | if (argc >= 1) { |
| 786 | /* use the BTS number that the user has specified */ |
| 787 | bts_nr = atoi(argv[0]); |
| 788 | if (bts_nr >= net->num_bts) { |
| 789 | vty_out(vty, "%% can't find BTS %s%s", argv[0], |
| 790 | VTY_NEWLINE); |
| 791 | return CMD_WARNING; |
| 792 | } |
Harald Welte | e441d9c | 2009-06-21 16:17:15 +0200 | [diff] [blame] | 793 | bts = gsm_bts_num(net, bts_nr); |
Harald Welte | f5025b6 | 2009-03-28 16:55:11 +0000 | [diff] [blame] | 794 | bts_paging_dump_vty(vty, bts); |
| 795 | |
| 796 | return CMD_SUCCESS; |
| 797 | } |
| 798 | for (bts_nr = 0; bts_nr < net->num_bts; bts_nr++) { |
Harald Welte | e441d9c | 2009-06-21 16:17:15 +0200 | [diff] [blame] | 799 | bts = gsm_bts_num(net, bts_nr); |
Harald Welte | f5025b6 | 2009-03-28 16:55:11 +0000 | [diff] [blame] | 800 | bts_paging_dump_vty(vty, bts); |
| 801 | } |
| 802 | |
| 803 | return CMD_SUCCESS; |
| 804 | } |
| 805 | |
Harald Welte | 24ff6ee | 2009-12-22 00:41:05 +0100 | [diff] [blame] | 806 | DEFUN(show_stats, |
| 807 | show_stats_cmd, |
| 808 | "show statistics", |
| 809 | SHOW_STR "Display network statistics\n") |
| 810 | { |
| 811 | struct gsm_network *net = gsmnet; |
| 812 | |
| 813 | vty_out(vty, "Channel Requests: %lu total, %lu no channel%s", |
Harald Welte | ffa55a4 | 2009-12-22 19:07:32 +0100 | [diff] [blame^] | 814 | counter_get(net->stats.chreq.total), |
| 815 | counter_get(net->stats.chreq.no_channel), VTY_NEWLINE); |
Harald Welte | 24ff6ee | 2009-12-22 00:41:05 +0100 | [diff] [blame] | 816 | vty_out(vty, "Location Update: %lu attach, %lu normal, %lu periodic%s", |
Harald Welte | ffa55a4 | 2009-12-22 19:07:32 +0100 | [diff] [blame^] | 817 | counter_get(net->stats.loc_upd_type.attach), |
| 818 | counter_get(net->stats.loc_upd_type.normal), |
| 819 | counter_get(net->stats.loc_upd_type.periodic), VTY_NEWLINE); |
| 820 | vty_out(vty, "IMSI Detach Indications: %lu%s", |
| 821 | counter_get(net->stats.loc_upd_type.detach), VTY_NEWLINE); |
Harald Welte | 24ff6ee | 2009-12-22 00:41:05 +0100 | [diff] [blame] | 822 | vty_out(vty, "Location Update Response: %lu accept, %lu reject%s", |
Harald Welte | ffa55a4 | 2009-12-22 19:07:32 +0100 | [diff] [blame^] | 823 | counter_get(net->stats.loc_upd_resp.accept), |
| 824 | counter_get(net->stats.loc_upd_resp.reject), VTY_NEWLINE); |
Harald Welte | 24ff6ee | 2009-12-22 00:41:05 +0100 | [diff] [blame] | 825 | vty_out(vty, "Paging: %lu attempted, %lu complete, %lu expired%s", |
Harald Welte | ffa55a4 | 2009-12-22 19:07:32 +0100 | [diff] [blame^] | 826 | counter_get(net->stats.paging.attempted), |
| 827 | counter_get(net->stats.paging.completed), |
| 828 | counter_get(net->stats.paging.expired), VTY_NEWLINE); |
Harald Welte | 24ff6ee | 2009-12-22 00:41:05 +0100 | [diff] [blame] | 829 | vty_out(vty, "Handover: %lu attempted, %lu no_channel, %lu timeout, " |
Harald Welte | ffa55a4 | 2009-12-22 19:07:32 +0100 | [diff] [blame^] | 830 | "%lu completed, %lu failed%s", |
| 831 | counter_get(net->stats.handover.attempted), |
| 832 | counter_get(net->stats.handover.no_channel), |
| 833 | counter_get(net->stats.handover.timeout), |
| 834 | counter_get(net->stats.handover.completed), |
| 835 | counter_get(net->stats.handover.failed), VTY_NEWLINE); |
Harald Welte | 24ff6ee | 2009-12-22 00:41:05 +0100 | [diff] [blame] | 836 | vty_out(vty, "SMS MO: %lu submitted, %lu no receiver%s", |
Harald Welte | ffa55a4 | 2009-12-22 19:07:32 +0100 | [diff] [blame^] | 837 | counter_get(net->stats.sms.submitted), |
| 838 | counter_get(net->stats.sms.no_receiver), VTY_NEWLINE); |
Harald Welte | 24ff6ee | 2009-12-22 00:41:05 +0100 | [diff] [blame] | 839 | vty_out(vty, "SMS MT: %lu delivered, %lu no memory, %lu other error%s", |
Harald Welte | ffa55a4 | 2009-12-22 19:07:32 +0100 | [diff] [blame^] | 840 | counter_get(net->stats.sms.delivered), |
| 841 | counter_get(net->stats.sms.rp_err_mem), |
| 842 | counter_get(net->stats.sms.rp_err_other), VTY_NEWLINE); |
Harald Welte | 24ff6ee | 2009-12-22 00:41:05 +0100 | [diff] [blame] | 843 | return CMD_SUCCESS; |
| 844 | } |
| 845 | |
Harald Welte | 5013b2a | 2009-08-07 13:29:14 +0200 | [diff] [blame] | 846 | DEFUN(cfg_net, |
| 847 | cfg_net_cmd, |
| 848 | "network", |
| 849 | "Configure the GSM network") |
| 850 | { |
| 851 | vty->index = gsmnet; |
| 852 | vty->node = GSMNET_NODE; |
| 853 | |
| 854 | return CMD_SUCCESS; |
| 855 | } |
| 856 | |
| 857 | |
| 858 | DEFUN(cfg_net_ncc, |
| 859 | cfg_net_ncc_cmd, |
| 860 | "network country code <1-999>", |
| 861 | "Set the GSM network country code") |
| 862 | { |
| 863 | gsmnet->country_code = atoi(argv[0]); |
| 864 | |
| 865 | return CMD_SUCCESS; |
| 866 | } |
| 867 | |
| 868 | DEFUN(cfg_net_mnc, |
| 869 | cfg_net_mnc_cmd, |
| 870 | "mobile network code <1-999>", |
| 871 | "Set the GSM mobile network code") |
| 872 | { |
| 873 | gsmnet->network_code = atoi(argv[0]); |
| 874 | |
| 875 | return CMD_SUCCESS; |
| 876 | } |
| 877 | |
| 878 | DEFUN(cfg_net_name_short, |
| 879 | cfg_net_name_short_cmd, |
| 880 | "short name NAME", |
| 881 | "Set the short GSM network name") |
| 882 | { |
| 883 | if (gsmnet->name_short) |
| 884 | talloc_free(gsmnet->name_short); |
| 885 | |
| 886 | gsmnet->name_short = talloc_strdup(gsmnet, argv[0]); |
| 887 | |
| 888 | return CMD_SUCCESS; |
| 889 | } |
| 890 | |
| 891 | DEFUN(cfg_net_name_long, |
| 892 | cfg_net_name_long_cmd, |
| 893 | "long name NAME", |
| 894 | "Set the long GSM network name") |
| 895 | { |
| 896 | if (gsmnet->name_long) |
| 897 | talloc_free(gsmnet->name_long); |
| 898 | |
| 899 | gsmnet->name_long = talloc_strdup(gsmnet, argv[0]); |
| 900 | |
| 901 | return CMD_SUCCESS; |
| 902 | } |
Harald Welte | 40f8289 | 2009-05-23 17:31:39 +0000 | [diff] [blame] | 903 | |
Harald Welte (local) | 69de397 | 2009-08-12 14:42:23 +0200 | [diff] [blame] | 904 | DEFUN(cfg_net_auth_policy, |
| 905 | cfg_net_auth_policy_cmd, |
| 906 | "auth policy (closed|accept-all|token)", |
| 907 | "Set the GSM network authentication policy\n") |
| 908 | { |
| 909 | enum gsm_auth_policy policy = gsm_auth_policy_parse(argv[0]); |
| 910 | |
| 911 | gsmnet->auth_policy = policy; |
| 912 | |
| 913 | return CMD_SUCCESS; |
| 914 | } |
| 915 | |
Harald Welte | 1085c09 | 2009-11-18 20:33:19 +0100 | [diff] [blame] | 916 | DEFUN(cfg_net_reject_cause, |
| 917 | cfg_net_reject_cause_cmd, |
| 918 | "location updating reject cause <2-111>", |
| 919 | "Set the reject cause of location updating reject\n") |
| 920 | { |
| 921 | gsmnet->reject_cause = atoi(argv[0]); |
| 922 | |
| 923 | return CMD_SUCCESS; |
| 924 | } |
| 925 | |
Harald Welte | 4381cfe | 2009-08-30 15:47:06 +0900 | [diff] [blame] | 926 | DEFUN(cfg_net_encryption, |
| 927 | cfg_net_encryption_cmd, |
| 928 | "encryption a5 (0|1|2)", |
| 929 | "Enable or disable encryption (A5) for this network\n") |
| 930 | { |
Andreas.Eversberg | 1059deb | 2009-11-17 09:55:26 +0100 | [diff] [blame] | 931 | gsmnet->a5_encryption= atoi(argv[0]); |
Harald Welte | 4381cfe | 2009-08-30 15:47:06 +0900 | [diff] [blame] | 932 | |
| 933 | return CMD_SUCCESS; |
| 934 | } |
| 935 | |
Holger Hans Peter Freyther | f7d752f | 2009-11-16 17:12:38 +0100 | [diff] [blame] | 936 | DEFUN(cfg_net_neci, |
| 937 | cfg_net_neci_cmd, |
| 938 | "neci (0|1)", |
| 939 | "Set if NECI of cell selection is to be set") |
| 940 | { |
| 941 | gsmnet->neci = atoi(argv[0]); |
| 942 | return CMD_SUCCESS; |
| 943 | } |
| 944 | |
Harald Welte | eab84a1 | 2009-12-13 10:53:12 +0100 | [diff] [blame] | 945 | DEFUN(cfg_net_rrlp_mode, cfg_net_rrlp_mode_cmd, |
| 946 | "rrlp mode (none|ms-based|ms-preferred|ass-preferred)", |
| 947 | "Set the Radio Resource Location Protocol Mode") |
| 948 | { |
| 949 | gsmnet->rrlp.mode = rrlp_mode_parse(argv[0]); |
| 950 | |
| 951 | return CMD_SUCCESS; |
| 952 | } |
| 953 | |
Harald Welte | 648b6ce | 2009-12-14 09:00:24 +0100 | [diff] [blame] | 954 | DEFUN(cfg_net_mm_info, cfg_net_mm_info_cmd, |
| 955 | "mm info (0|1)", |
| 956 | "Whether to send MM INFO after LOC UPD ACCEPT") |
| 957 | { |
| 958 | gsmnet->send_mm_info = atoi(argv[0]); |
| 959 | |
| 960 | return CMD_SUCCESS; |
| 961 | } |
| 962 | |
Harald Welte | bc81450 | 2009-12-19 21:41:52 +0100 | [diff] [blame] | 963 | DEFUN(cfg_net_handover, cfg_net_handover_cmd, |
| 964 | "handover (0|1)", |
| 965 | "Whether or not to use in-call handover") |
| 966 | { |
Harald Welte | fe03f0d | 2009-12-20 13:51:01 +0100 | [diff] [blame] | 967 | if (ipacc_rtp_direct) { |
| 968 | vty_out(vty, "%% Cannot enable handover unless RTP Proxy mode " |
| 969 | "is enabled by using the -P command line option%s", |
| 970 | VTY_NEWLINE); |
| 971 | return CMD_WARNING; |
| 972 | } |
Harald Welte | bc81450 | 2009-12-19 21:41:52 +0100 | [diff] [blame] | 973 | gsmnet->handover.active = atoi(argv[0]); |
| 974 | |
| 975 | return CMD_SUCCESS; |
| 976 | } |
| 977 | |
Harald Welte | b720bd3 | 2009-12-21 16:51:50 +0100 | [diff] [blame] | 978 | DEFUN(cfg_net_ho_win_rxlev_avg, cfg_net_ho_win_rxlev_avg_cmd, |
| 979 | "handover window rxlev averaging <1-10>", |
| 980 | "How many RxLev measurements are used for averaging") |
| 981 | { |
| 982 | gsmnet->handover.win_rxlev_avg = atoi(argv[0]); |
| 983 | return CMD_SUCCESS; |
| 984 | } |
| 985 | |
| 986 | DEFUN(cfg_net_ho_win_rxqual_avg, cfg_net_ho_win_rxqual_avg_cmd, |
| 987 | "handover window rxqual averaging <1-10>", |
| 988 | "How many RxQual measurements are used for averaging") |
| 989 | { |
| 990 | gsmnet->handover.win_rxqual_avg = atoi(argv[0]); |
| 991 | return CMD_SUCCESS; |
| 992 | } |
| 993 | |
| 994 | DEFUN(cfg_net_ho_win_rxlev_neigh_avg, cfg_net_ho_win_rxlev_avg_neigh_cmd, |
| 995 | "handover window rxlev neighbor averaging <1-10>", |
| 996 | "How many RxQual measurements are used for averaging") |
| 997 | { |
| 998 | gsmnet->handover.win_rxlev_avg_neigh = atoi(argv[0]); |
| 999 | return CMD_SUCCESS; |
| 1000 | } |
| 1001 | |
| 1002 | DEFUN(cfg_net_ho_pwr_interval, cfg_net_ho_pwr_interval_cmd, |
| 1003 | "handover power budget interval <1-99>", |
| 1004 | "How often to check if we have a better cell (SACCH frames)") |
| 1005 | { |
| 1006 | gsmnet->handover.pwr_interval = atoi(argv[0]); |
| 1007 | return CMD_SUCCESS; |
| 1008 | } |
| 1009 | |
| 1010 | DEFUN(cfg_net_ho_pwr_hysteresis, cfg_net_ho_pwr_hysteresis_cmd, |
| 1011 | "handover power budget hysteresis <0-999>", |
| 1012 | "How many dB does a neighbor to be stronger to become a HO candidate") |
| 1013 | { |
| 1014 | gsmnet->handover.pwr_hysteresis = atoi(argv[0]); |
| 1015 | return CMD_SUCCESS; |
| 1016 | } |
| 1017 | |
| 1018 | DEFUN(cfg_net_ho_max_distance, cfg_net_ho_max_distance_cmd, |
| 1019 | "handover maximum distance <0-9999>", |
| 1020 | "How big is the maximum timing advance before HO is forced") |
| 1021 | { |
| 1022 | gsmnet->handover.max_distance = atoi(argv[0]); |
| 1023 | return CMD_SUCCESS; |
| 1024 | } |
Harald Welte | bc81450 | 2009-12-19 21:41:52 +0100 | [diff] [blame] | 1025 | |
Holger Hans Peter Freyther | c802106 | 2009-12-22 08:27:21 +0100 | [diff] [blame] | 1026 | #define DECLARE_TIMER(number, doc) \ |
Holger Hans Peter Freyther | c4d88ad | 2009-11-21 21:18:38 +0100 | [diff] [blame] | 1027 | DEFUN(cfg_net_T##number, \ |
| 1028 | cfg_net_T##number##_cmd, \ |
| 1029 | "timer t" #number " <0-65535>", \ |
Holger Hans Peter Freyther | c802106 | 2009-12-22 08:27:21 +0100 | [diff] [blame] | 1030 | doc) \ |
Holger Hans Peter Freyther | c4d88ad | 2009-11-21 21:18:38 +0100 | [diff] [blame] | 1031 | { \ |
| 1032 | int value = atoi(argv[0]); \ |
| 1033 | \ |
| 1034 | if (value < 0 || value > 65535) { \ |
| 1035 | vty_out(vty, "Timer value %s out of range.%s", \ |
| 1036 | argv[0], VTY_NEWLINE); \ |
| 1037 | return CMD_WARNING; \ |
| 1038 | } \ |
| 1039 | \ |
| 1040 | gsmnet->T##number = value; \ |
| 1041 | return CMD_SUCCESS; \ |
| 1042 | } |
| 1043 | |
Holger Hans Peter Freyther | c802106 | 2009-12-22 08:27:21 +0100 | [diff] [blame] | 1044 | DECLARE_TIMER(3101, "Set the timeout value for IMMEDIATE ASSIGNMENT.") |
| 1045 | DECLARE_TIMER(3103, "Set the timeout value for HANDOVER.") |
| 1046 | DECLARE_TIMER(3105, "Currently not used.") |
| 1047 | DECLARE_TIMER(3107, "Currently not used.") |
| 1048 | DECLARE_TIMER(3109, "Currently not used.") |
| 1049 | DECLARE_TIMER(3111, "Currently not used.") |
| 1050 | DECLARE_TIMER(3113, "Set the time to try paging a subscriber.") |
| 1051 | DECLARE_TIMER(3115, "Currently not used.") |
| 1052 | DECLARE_TIMER(3117, "Currently not used.") |
| 1053 | DECLARE_TIMER(3119, "Currently not used.") |
| 1054 | DECLARE_TIMER(3141, "Currently not used.") |
Holger Hans Peter Freyther | c4d88ad | 2009-11-21 21:18:38 +0100 | [diff] [blame] | 1055 | |
| 1056 | |
Harald Welte | 5258fc4 | 2009-03-28 19:07:53 +0000 | [diff] [blame] | 1057 | /* per-BTS configuration */ |
| 1058 | DEFUN(cfg_bts, |
| 1059 | cfg_bts_cmd, |
| 1060 | "bts BTS_NR", |
| 1061 | "Select a BTS to configure\n") |
| 1062 | { |
| 1063 | int bts_nr = atoi(argv[0]); |
| 1064 | struct gsm_bts *bts; |
| 1065 | |
Harald Welte | e441d9c | 2009-06-21 16:17:15 +0200 | [diff] [blame] | 1066 | if (bts_nr > gsmnet->num_bts) { |
| 1067 | vty_out(vty, "%% The next unused BTS number is %u%s", |
| 1068 | gsmnet->num_bts, VTY_NEWLINE); |
Harald Welte | 5258fc4 | 2009-03-28 19:07:53 +0000 | [diff] [blame] | 1069 | return CMD_WARNING; |
Harald Welte | e441d9c | 2009-06-21 16:17:15 +0200 | [diff] [blame] | 1070 | } else if (bts_nr == gsmnet->num_bts) { |
| 1071 | /* allocate a new one */ |
| 1072 | bts = gsm_bts_alloc(gsmnet, GSM_BTS_TYPE_UNKNOWN, |
| 1073 | HARDCODED_TSC, HARDCODED_BSIC); |
| 1074 | } else |
| 1075 | bts = gsm_bts_num(gsmnet, bts_nr); |
| 1076 | |
| 1077 | if (!bts) |
| 1078 | return CMD_WARNING; |
Harald Welte | 5258fc4 | 2009-03-28 19:07:53 +0000 | [diff] [blame] | 1079 | |
| 1080 | vty->index = bts; |
| 1081 | vty->node = BTS_NODE; |
| 1082 | |
| 1083 | return CMD_SUCCESS; |
| 1084 | } |
| 1085 | |
| 1086 | DEFUN(cfg_bts_type, |
| 1087 | cfg_bts_type_cmd, |
| 1088 | "type TYPE", |
| 1089 | "Set the BTS type\n") |
| 1090 | { |
| 1091 | struct gsm_bts *bts = vty->index; |
| 1092 | |
Harald Welte | a6fd58e | 2009-08-07 00:25:23 +0200 | [diff] [blame] | 1093 | bts->type = parse_btstype(argv[0]); |
| 1094 | |
Harald Welte | 8175e95 | 2009-10-20 00:22:00 +0200 | [diff] [blame] | 1095 | if (is_ipaccess_bts(bts)) { |
| 1096 | /* Set the default OML Stream ID to 0xff */ |
| 1097 | bts->oml_tei = 0xff; |
| 1098 | } |
| 1099 | |
Harald Welte | 5258fc4 | 2009-03-28 19:07:53 +0000 | [diff] [blame] | 1100 | return CMD_SUCCESS; |
| 1101 | } |
| 1102 | |
Harald Welte | fcd2445 | 2009-06-20 18:15:19 +0200 | [diff] [blame] | 1103 | DEFUN(cfg_bts_band, |
| 1104 | cfg_bts_band_cmd, |
| 1105 | "band BAND", |
| 1106 | "Set the frequency band of this BTS\n") |
| 1107 | { |
| 1108 | struct gsm_bts *bts = vty->index; |
Harald Welte | 4258182 | 2009-08-08 16:12:58 +0200 | [diff] [blame] | 1109 | int band = gsm_band_parse(argv[0]); |
Harald Welte | fcd2445 | 2009-06-20 18:15:19 +0200 | [diff] [blame] | 1110 | |
| 1111 | if (band < 0) { |
| 1112 | vty_out(vty, "%% BAND %d is not a valid GSM band%s", |
| 1113 | band, VTY_NEWLINE); |
| 1114 | return CMD_WARNING; |
| 1115 | } |
| 1116 | |
| 1117 | bts->band = band; |
| 1118 | |
| 1119 | return CMD_SUCCESS; |
| 1120 | } |
| 1121 | |
Holger Hans Peter Freyther | c4a49e3 | 2009-08-21 14:44:12 +0200 | [diff] [blame] | 1122 | DEFUN(cfg_bts_ci, |
| 1123 | cfg_bts_ci_cmd, |
| 1124 | "cell_identity <0-65535>", |
| 1125 | "Set the Cell identity of this BTS\n") |
| 1126 | { |
| 1127 | struct gsm_bts *bts = vty->index; |
| 1128 | int ci = atoi(argv[0]); |
| 1129 | |
| 1130 | if (ci < 0 || ci > 0xffff) { |
| 1131 | vty_out(vty, "%% CI %d is not in the valid range (0-65535)%s", |
| 1132 | ci, VTY_NEWLINE); |
| 1133 | return CMD_WARNING; |
| 1134 | } |
| 1135 | bts->cell_identity = ci; |
| 1136 | |
| 1137 | return CMD_SUCCESS; |
| 1138 | } |
| 1139 | |
Harald Welte | 5258fc4 | 2009-03-28 19:07:53 +0000 | [diff] [blame] | 1140 | DEFUN(cfg_bts_lac, |
| 1141 | cfg_bts_lac_cmd, |
Holger Hans Peter Freyther | 0b7f4b3 | 2009-09-29 14:02:33 +0200 | [diff] [blame] | 1142 | "location_area_code <0-65535>", |
Harald Welte | 5258fc4 | 2009-03-28 19:07:53 +0000 | [diff] [blame] | 1143 | "Set the Location Area Code (LAC) of this BTS\n") |
| 1144 | { |
| 1145 | struct gsm_bts *bts = vty->index; |
| 1146 | int lac = atoi(argv[0]); |
| 1147 | |
Holger Hans Peter Freyther | 0b7f4b3 | 2009-09-29 14:02:33 +0200 | [diff] [blame] | 1148 | if (lac < 0 || lac > 0xffff) { |
| 1149 | vty_out(vty, "%% LAC %d is not in the valid range (0-65535)%s", |
Harald Welte | 5258fc4 | 2009-03-28 19:07:53 +0000 | [diff] [blame] | 1150 | lac, VTY_NEWLINE); |
| 1151 | return CMD_WARNING; |
| 1152 | } |
Holger Hans Peter Freyther | e48b956 | 2009-10-01 04:07:15 +0200 | [diff] [blame] | 1153 | |
| 1154 | if (lac == GSM_LAC_RESERVED_DETACHED || lac == GSM_LAC_RESERVED_ALL_BTS) { |
| 1155 | vty_out(vty, "%% LAC %d is reserved by GSM 04.08%s", |
| 1156 | lac, VTY_NEWLINE); |
| 1157 | return CMD_WARNING; |
| 1158 | } |
| 1159 | |
Harald Welte | 5258fc4 | 2009-03-28 19:07:53 +0000 | [diff] [blame] | 1160 | bts->location_area_code = lac; |
| 1161 | |
| 1162 | return CMD_SUCCESS; |
| 1163 | } |
| 1164 | |
Harald Welte | a43f789 | 2009-12-01 18:04:30 +0530 | [diff] [blame] | 1165 | |
Harald Welte | 5258fc4 | 2009-03-28 19:07:53 +0000 | [diff] [blame] | 1166 | DEFUN(cfg_bts_tsc, |
| 1167 | cfg_bts_tsc_cmd, |
| 1168 | "training_sequence_code <0-255>", |
| 1169 | "Set the Training Sequence Code (TSC) of this BTS\n") |
| 1170 | { |
| 1171 | struct gsm_bts *bts = vty->index; |
| 1172 | int tsc = atoi(argv[0]); |
| 1173 | |
| 1174 | if (tsc < 0 || tsc > 0xff) { |
| 1175 | vty_out(vty, "%% TSC %d is not in the valid range (0-255)%s", |
| 1176 | tsc, VTY_NEWLINE); |
| 1177 | return CMD_WARNING; |
| 1178 | } |
| 1179 | bts->tsc = tsc; |
| 1180 | |
| 1181 | return CMD_SUCCESS; |
| 1182 | } |
| 1183 | |
Harald Welte | 78f2f50 | 2009-05-23 16:56:52 +0000 | [diff] [blame] | 1184 | DEFUN(cfg_bts_bsic, |
| 1185 | cfg_bts_bsic_cmd, |
| 1186 | "base_station_id_code <0-63>", |
| 1187 | "Set the Base Station Identity Code (BSIC) of this BTS\n") |
| 1188 | { |
| 1189 | struct gsm_bts *bts = vty->index; |
| 1190 | int bsic = atoi(argv[0]); |
| 1191 | |
| 1192 | if (bsic < 0 || bsic > 0x3f) { |
Harald Welte | 4258182 | 2009-08-08 16:12:58 +0200 | [diff] [blame] | 1193 | vty_out(vty, "%% BSIC %d is not in the valid range (0-255)%s", |
Harald Welte | 78f2f50 | 2009-05-23 16:56:52 +0000 | [diff] [blame] | 1194 | bsic, VTY_NEWLINE); |
| 1195 | return CMD_WARNING; |
| 1196 | } |
| 1197 | bts->bsic = bsic; |
| 1198 | |
| 1199 | return CMD_SUCCESS; |
| 1200 | } |
| 1201 | |
| 1202 | |
Harald Welte | 4cc3422 | 2009-05-01 15:12:31 +0000 | [diff] [blame] | 1203 | DEFUN(cfg_bts_unit_id, |
| 1204 | cfg_bts_unit_id_cmd, |
Harald Welte | 07dc73d | 2009-08-07 13:27:09 +0200 | [diff] [blame] | 1205 | "ip.access unit_id <0-65534> <0-255>", |
| 1206 | "Set the ip.access BTS Unit ID of this BTS\n") |
Harald Welte | 4cc3422 | 2009-05-01 15:12:31 +0000 | [diff] [blame] | 1207 | { |
| 1208 | struct gsm_bts *bts = vty->index; |
| 1209 | int site_id = atoi(argv[0]); |
| 1210 | int bts_id = atoi(argv[1]); |
| 1211 | |
Harald Welte | 07dc73d | 2009-08-07 13:27:09 +0200 | [diff] [blame] | 1212 | if (!is_ipaccess_bts(bts)) { |
| 1213 | vty_out(vty, "%% BTS is not of ip.access type%s", VTY_NEWLINE); |
| 1214 | return CMD_WARNING; |
| 1215 | } |
| 1216 | |
Harald Welte | 4cc3422 | 2009-05-01 15:12:31 +0000 | [diff] [blame] | 1217 | bts->ip_access.site_id = site_id; |
| 1218 | bts->ip_access.bts_id = bts_id; |
| 1219 | |
| 1220 | return CMD_SUCCESS; |
| 1221 | } |
| 1222 | |
Harald Welte | 8175e95 | 2009-10-20 00:22:00 +0200 | [diff] [blame] | 1223 | DEFUN(cfg_bts_stream_id, |
| 1224 | cfg_bts_stream_id_cmd, |
| 1225 | "oml ip.access stream_id <0-255>", |
| 1226 | "Set the ip.access Stream ID of the OML link of this BTS\n") |
| 1227 | { |
| 1228 | struct gsm_bts *bts = vty->index; |
| 1229 | int stream_id = atoi(argv[0]); |
| 1230 | |
| 1231 | if (!is_ipaccess_bts(bts)) { |
| 1232 | vty_out(vty, "%% BTS is not of ip.access type%s", VTY_NEWLINE); |
| 1233 | return CMD_WARNING; |
| 1234 | } |
| 1235 | |
| 1236 | bts->oml_tei = stream_id; |
| 1237 | |
| 1238 | return CMD_SUCCESS; |
| 1239 | } |
| 1240 | |
| 1241 | |
Harald Welte | 4258182 | 2009-08-08 16:12:58 +0200 | [diff] [blame] | 1242 | DEFUN(cfg_bts_oml_e1, |
| 1243 | cfg_bts_oml_e1_cmd, |
| 1244 | "oml e1 line E1_LINE timeslot <1-31> sub-slot (0|1|2|3|full)", |
| 1245 | "E1 interface to be used for OML\n") |
| 1246 | { |
| 1247 | struct gsm_bts *bts = vty->index; |
| 1248 | |
| 1249 | parse_e1_link(&bts->oml_e1_link, argv[0], argv[1], argv[2]); |
| 1250 | |
| 1251 | return CMD_SUCCESS; |
| 1252 | } |
| 1253 | |
| 1254 | |
| 1255 | DEFUN(cfg_bts_oml_e1_tei, |
| 1256 | cfg_bts_oml_e1_tei_cmd, |
| 1257 | "oml e1 tei <0-63>", |
| 1258 | "Set the TEI to be used for OML") |
| 1259 | { |
| 1260 | struct gsm_bts *bts = vty->index; |
| 1261 | |
| 1262 | bts->oml_tei = atoi(argv[0]); |
| 1263 | |
| 1264 | return CMD_SUCCESS; |
| 1265 | } |
| 1266 | |
Harald Welte | 7a8fa41 | 2009-08-10 13:48:16 +0200 | [diff] [blame] | 1267 | DEFUN(cfg_bts_challoc, cfg_bts_challoc_cmd, |
| 1268 | "channel allocator (ascending|descending)", |
| 1269 | "Should the channel allocator allocate in reverse TRX order?") |
| 1270 | { |
| 1271 | struct gsm_bts *bts = vty->index; |
| 1272 | |
| 1273 | if (!strcmp(argv[0], "ascending")) |
| 1274 | bts->chan_alloc_reverse = 0; |
| 1275 | else |
| 1276 | bts->chan_alloc_reverse = 1; |
| 1277 | |
| 1278 | return CMD_SUCCESS; |
| 1279 | } |
| 1280 | |
Sylvain Munaut | 4010f1e | 2009-12-22 13:43:26 +0100 | [diff] [blame] | 1281 | DEFUN(cfg_bts_rach_tx_integer, |
| 1282 | cfg_bts_rach_tx_integer_cmd, |
| 1283 | "rach tx integer <0-15>", |
| 1284 | "Set the raw tx integer value in RACH Control parameters IE") |
| 1285 | { |
| 1286 | struct gsm_bts *bts = vty->index; |
| 1287 | bts->si_common.rach_control.tx_integer = atoi(argv[0]) & 0xf; |
| 1288 | return CMD_SUCCESS; |
| 1289 | } |
| 1290 | |
| 1291 | DEFUN(cfg_bts_rach_max_trans, |
| 1292 | cfg_bts_rach_max_trans_cmd, |
| 1293 | "rach max transmission (1|2|4|7)", |
| 1294 | "Set the maximum number of RACH burst transmissions") |
| 1295 | { |
| 1296 | struct gsm_bts *bts = vty->index; |
| 1297 | bts->si_common.rach_control.max_trans = rach_max_trans_val2raw(atoi(argv[0])); |
| 1298 | return CMD_SUCCESS; |
| 1299 | } |
| 1300 | |
Harald Welte (local) | 5dececf | 2009-08-12 13:28:23 +0200 | [diff] [blame] | 1301 | DEFUN(cfg_bts_cell_barred, cfg_bts_cell_barred_cmd, |
| 1302 | "cell barred (0|1)", |
| 1303 | "Should this cell be barred from access?") |
| 1304 | { |
| 1305 | struct gsm_bts *bts = vty->index; |
| 1306 | |
Harald Welte | 7135501 | 2009-12-21 23:08:18 +0100 | [diff] [blame] | 1307 | bts->si_common.rach_control.cell_bar = atoi(argv[0]); |
Harald Welte (local) | 5dececf | 2009-08-12 13:28:23 +0200 | [diff] [blame] | 1308 | |
| 1309 | return CMD_SUCCESS; |
| 1310 | } |
| 1311 | |
Harald Welte (local) | 0e451d0 | 2009-08-13 10:14:26 +0200 | [diff] [blame] | 1312 | DEFUN(cfg_bts_ms_max_power, cfg_bts_ms_max_power_cmd, |
| 1313 | "ms max power <0-40>", |
| 1314 | "Maximum transmit power of the MS") |
| 1315 | { |
| 1316 | struct gsm_bts *bts = vty->index; |
| 1317 | |
| 1318 | bts->ms_max_power = atoi(argv[0]); |
| 1319 | |
| 1320 | return CMD_SUCCESS; |
| 1321 | } |
| 1322 | |
Harald Welte | 7322528 | 2009-12-12 18:17:25 +0100 | [diff] [blame] | 1323 | DEFUN(cfg_bts_cell_resel_hyst, cfg_bts_cell_resel_hyst_cmd, |
| 1324 | "cell reselection hysteresis <0-14>", |
| 1325 | "Cell Re-Selection Hysteresis in dB") |
| 1326 | { |
| 1327 | struct gsm_bts *bts = vty->index; |
| 1328 | |
| 1329 | bts->si_common.cell_sel_par.cell_resel_hyst = atoi(argv[0])/2; |
| 1330 | |
| 1331 | return CMD_SUCCESS; |
| 1332 | } |
| 1333 | |
| 1334 | DEFUN(cfg_bts_rxlev_acc_min, cfg_bts_rxlev_acc_min_cmd, |
| 1335 | "rxlev access min <0-63>", |
| 1336 | "Minimum RxLev needed for cell access (better than -110dBm)") |
| 1337 | { |
| 1338 | struct gsm_bts *bts = vty->index; |
| 1339 | |
| 1340 | bts->si_common.cell_sel_par.rxlev_acc_min = atoi(argv[0]); |
| 1341 | |
| 1342 | return CMD_SUCCESS; |
| 1343 | } |
| 1344 | |
Harald Welte (local) | efc9231 | 2009-08-14 23:09:25 +0200 | [diff] [blame] | 1345 | DEFUN(cfg_bts_per_loc_upd, cfg_bts_per_loc_upd_cmd, |
| 1346 | "periodic location update <0-1530>", |
| 1347 | "Periodic Location Updating Interval in Minutes") |
| 1348 | { |
| 1349 | struct gsm_bts *bts = vty->index; |
| 1350 | |
Harald Welte | a43f789 | 2009-12-01 18:04:30 +0530 | [diff] [blame] | 1351 | bts->si_common.chan_desc.t3212 = atoi(argv[0]) / 10; |
Harald Welte (local) | efc9231 | 2009-08-14 23:09:25 +0200 | [diff] [blame] | 1352 | |
| 1353 | return CMD_SUCCESS; |
| 1354 | } |
| 1355 | |
Harald Welte | 7a8fa41 | 2009-08-10 13:48:16 +0200 | [diff] [blame] | 1356 | |
Harald Welte | 5258fc4 | 2009-03-28 19:07:53 +0000 | [diff] [blame] | 1357 | /* per TRX configuration */ |
| 1358 | DEFUN(cfg_trx, |
| 1359 | cfg_trx_cmd, |
| 1360 | "trx TRX_NR", |
| 1361 | "Select a TRX to configure") |
| 1362 | { |
| 1363 | int trx_nr = atoi(argv[0]); |
| 1364 | struct gsm_bts *bts = vty->index; |
| 1365 | struct gsm_bts_trx *trx; |
| 1366 | |
Harald Welte | e441d9c | 2009-06-21 16:17:15 +0200 | [diff] [blame] | 1367 | if (trx_nr > bts->num_trx) { |
| 1368 | vty_out(vty, "%% The next unused TRX number in this BTS is %u%s", |
| 1369 | bts->num_trx, VTY_NEWLINE); |
Harald Welte | 5258fc4 | 2009-03-28 19:07:53 +0000 | [diff] [blame] | 1370 | return CMD_WARNING; |
Harald Welte | e441d9c | 2009-06-21 16:17:15 +0200 | [diff] [blame] | 1371 | } else if (trx_nr == bts->num_trx) { |
| 1372 | /* we need to allocate a new one */ |
| 1373 | trx = gsm_bts_trx_alloc(bts); |
| 1374 | } else |
| 1375 | trx = gsm_bts_trx_num(bts, trx_nr); |
| 1376 | |
| 1377 | if (!trx) |
| 1378 | return CMD_WARNING; |
Harald Welte | 5258fc4 | 2009-03-28 19:07:53 +0000 | [diff] [blame] | 1379 | |
| 1380 | vty->index = trx; |
| 1381 | vty->node = TRX_NODE; |
| 1382 | |
| 1383 | return CMD_SUCCESS; |
| 1384 | } |
| 1385 | |
| 1386 | DEFUN(cfg_trx_arfcn, |
| 1387 | cfg_trx_arfcn_cmd, |
| 1388 | "arfcn <1-1024>", |
| 1389 | "Set the ARFCN for this TRX\n") |
| 1390 | { |
| 1391 | int arfcn = atoi(argv[0]); |
| 1392 | struct gsm_bts_trx *trx = vty->index; |
| 1393 | |
| 1394 | /* FIXME: check if this ARFCN is supported by this TRX */ |
| 1395 | |
| 1396 | trx->arfcn = arfcn; |
| 1397 | |
| 1398 | /* FIXME: patch ARFCN into SYSTEM INFORMATION */ |
| 1399 | /* FIXME: use OML layer to update the ARFCN */ |
| 1400 | /* FIXME: use RSL layer to update SYSTEM INFORMATION */ |
| 1401 | |
| 1402 | return CMD_SUCCESS; |
| 1403 | } |
| 1404 | |
Harald Welte | fcd2445 | 2009-06-20 18:15:19 +0200 | [diff] [blame] | 1405 | DEFUN(cfg_trx_max_power_red, |
| 1406 | cfg_trx_max_power_red_cmd, |
| 1407 | "max_power_red <0-100>", |
| 1408 | "Reduction of maximum BS RF Power in dB\n") |
| 1409 | { |
| 1410 | int maxpwr_r = atoi(argv[0]); |
| 1411 | struct gsm_bts_trx *trx = vty->index; |
Harald Welte | 61a83b2 | 2009-11-18 09:20:22 +0100 | [diff] [blame] | 1412 | int upper_limit = 24; /* default 12.21 max power red. */ |
Harald Welte | fcd2445 | 2009-06-20 18:15:19 +0200 | [diff] [blame] | 1413 | |
| 1414 | /* FIXME: check if our BTS type supports more than 12 */ |
| 1415 | if (maxpwr_r < 0 || maxpwr_r > upper_limit) { |
| 1416 | vty_out(vty, "%% Power %d dB is not in the valid range%s", |
| 1417 | maxpwr_r, VTY_NEWLINE); |
| 1418 | return CMD_WARNING; |
| 1419 | } |
| 1420 | if (maxpwr_r & 1) { |
| 1421 | vty_out(vty, "%% Power %d dB is not an even value%s", |
| 1422 | maxpwr_r, VTY_NEWLINE); |
| 1423 | return CMD_WARNING; |
| 1424 | } |
| 1425 | |
| 1426 | trx->max_power_red = maxpwr_r; |
| 1427 | |
| 1428 | /* FIXME: make sure we update this using OML */ |
| 1429 | |
| 1430 | return CMD_SUCCESS; |
| 1431 | } |
| 1432 | |
Harald Welte | 4258182 | 2009-08-08 16:12:58 +0200 | [diff] [blame] | 1433 | DEFUN(cfg_trx_rsl_e1, |
| 1434 | cfg_trx_rsl_e1_cmd, |
| 1435 | "rsl e1 line E1_LINE timeslot <1-31> sub-slot (0|1|2|3|full)", |
| 1436 | "E1 interface to be used for RSL\n") |
| 1437 | { |
| 1438 | struct gsm_bts_trx *trx = vty->index; |
| 1439 | |
| 1440 | parse_e1_link(&trx->rsl_e1_link, argv[0], argv[1], argv[2]); |
| 1441 | |
| 1442 | return CMD_SUCCESS; |
| 1443 | } |
| 1444 | |
| 1445 | DEFUN(cfg_trx_rsl_e1_tei, |
| 1446 | cfg_trx_rsl_e1_tei_cmd, |
| 1447 | "rsl e1 tei <0-63>", |
| 1448 | "Set the TEI to be used for RSL") |
| 1449 | { |
| 1450 | struct gsm_bts_trx *trx = vty->index; |
| 1451 | |
| 1452 | trx->rsl_tei = atoi(argv[0]); |
| 1453 | |
| 1454 | return CMD_SUCCESS; |
| 1455 | } |
| 1456 | |
Holger Hans Peter Freyther | 2d501ea | 2009-11-11 11:54:24 +0100 | [diff] [blame] | 1457 | DEFUN(cfg_trx_rf_locked, |
| 1458 | cfg_trx_rf_locked_cmd, |
| 1459 | "rf_locked (0|1)", |
| 1460 | "Turn off RF of the TRX.\n") |
| 1461 | { |
| 1462 | int locked = atoi(argv[0]); |
| 1463 | struct gsm_bts_trx *trx = vty->index; |
| 1464 | |
| 1465 | gsm_trx_lock_rf(trx, locked); |
| 1466 | return CMD_SUCCESS; |
| 1467 | } |
Harald Welte | 4258182 | 2009-08-08 16:12:58 +0200 | [diff] [blame] | 1468 | |
Harald Welte | 5258fc4 | 2009-03-28 19:07:53 +0000 | [diff] [blame] | 1469 | /* per TS configuration */ |
| 1470 | DEFUN(cfg_ts, |
| 1471 | cfg_ts_cmd, |
Harald Welte | 4258182 | 2009-08-08 16:12:58 +0200 | [diff] [blame] | 1472 | "timeslot <0-7>", |
Harald Welte | 5258fc4 | 2009-03-28 19:07:53 +0000 | [diff] [blame] | 1473 | "Select a Timeslot to configure") |
| 1474 | { |
| 1475 | int ts_nr = atoi(argv[0]); |
| 1476 | struct gsm_bts_trx *trx = vty->index; |
| 1477 | struct gsm_bts_trx_ts *ts; |
| 1478 | |
| 1479 | if (ts_nr >= TRX_NR_TS) { |
| 1480 | vty_out(vty, "%% A GSM TRX only has %u Timeslots per TRX%s", |
| 1481 | TRX_NR_TS, VTY_NEWLINE); |
| 1482 | return CMD_WARNING; |
| 1483 | } |
| 1484 | |
| 1485 | ts = &trx->ts[ts_nr]; |
| 1486 | |
| 1487 | vty->index = ts; |
| 1488 | vty->node = TS_NODE; |
| 1489 | |
| 1490 | return CMD_SUCCESS; |
| 1491 | } |
| 1492 | |
Harald Welte | a6fd58e | 2009-08-07 00:25:23 +0200 | [diff] [blame] | 1493 | DEFUN(cfg_ts_pchan, |
| 1494 | cfg_ts_pchan_cmd, |
| 1495 | "phys_chan_config PCHAN", |
| 1496 | "Physical Channel configuration (TCH/SDCCH/...)") |
| 1497 | { |
| 1498 | struct gsm_bts_trx_ts *ts = vty->index; |
| 1499 | int pchanc; |
| 1500 | |
| 1501 | pchanc = gsm_pchan_parse(argv[0]); |
| 1502 | if (pchanc < 0) |
| 1503 | return CMD_WARNING; |
| 1504 | |
| 1505 | ts->pchan = pchanc; |
| 1506 | |
| 1507 | return CMD_SUCCESS; |
| 1508 | } |
| 1509 | |
| 1510 | DEFUN(cfg_ts_e1_subslot, |
| 1511 | cfg_ts_e1_subslot_cmd, |
Harald Welte | 4258182 | 2009-08-08 16:12:58 +0200 | [diff] [blame] | 1512 | "e1 line E1_LINE timeslot <1-31> sub-slot (0|1|2|3|full)", |
Harald Welte | a6fd58e | 2009-08-07 00:25:23 +0200 | [diff] [blame] | 1513 | "E1 sub-slot connected to this on-air timeslot") |
| 1514 | { |
| 1515 | struct gsm_bts_trx_ts *ts = vty->index; |
| 1516 | |
Harald Welte | 4258182 | 2009-08-08 16:12:58 +0200 | [diff] [blame] | 1517 | parse_e1_link(&ts->e1_link, argv[0], argv[1], argv[2]); |
Harald Welte | a6fd58e | 2009-08-07 00:25:23 +0200 | [diff] [blame] | 1518 | |
| 1519 | return CMD_SUCCESS; |
| 1520 | } |
Harald Welte | 5258fc4 | 2009-03-28 19:07:53 +0000 | [diff] [blame] | 1521 | |
Harald Welte | 68628e8 | 2009-03-10 12:17:57 +0000 | [diff] [blame] | 1522 | int bsc_vty_init(struct gsm_network *net) |
| 1523 | { |
| 1524 | gsmnet = net; |
| 1525 | |
| 1526 | cmd_init(1); |
| 1527 | vty_init(); |
| 1528 | |
| 1529 | install_element(VIEW_NODE, &show_net_cmd); |
| 1530 | install_element(VIEW_NODE, &show_bts_cmd); |
| 1531 | install_element(VIEW_NODE, &show_trx_cmd); |
| 1532 | install_element(VIEW_NODE, &show_ts_cmd); |
| 1533 | install_element(VIEW_NODE, &show_lchan_cmd); |
Harald Welte | 1bc7735 | 2009-03-10 19:47:51 +0000 | [diff] [blame] | 1534 | |
| 1535 | install_element(VIEW_NODE, &show_e1drv_cmd); |
Harald Welte | 68628e8 | 2009-03-10 12:17:57 +0000 | [diff] [blame] | 1536 | install_element(VIEW_NODE, &show_e1line_cmd); |
| 1537 | install_element(VIEW_NODE, &show_e1ts_cmd); |
| 1538 | |
Harald Welte | f5025b6 | 2009-03-28 16:55:11 +0000 | [diff] [blame] | 1539 | install_element(VIEW_NODE, &show_paging_cmd); |
Harald Welte | 24ff6ee | 2009-12-22 00:41:05 +0100 | [diff] [blame] | 1540 | install_element(VIEW_NODE, &show_stats_cmd); |
Harald Welte | 5258fc4 | 2009-03-28 19:07:53 +0000 | [diff] [blame] | 1541 | |
Harald Welte | 5013b2a | 2009-08-07 13:29:14 +0200 | [diff] [blame] | 1542 | install_element(CONFIG_NODE, &cfg_net_cmd); |
| 1543 | install_node(&net_node, config_write_net); |
| 1544 | install_default(GSMNET_NODE); |
Harald Welte | 4258182 | 2009-08-08 16:12:58 +0200 | [diff] [blame] | 1545 | install_element(GSMNET_NODE, &cfg_net_ncc_cmd); |
Harald Welte | 5013b2a | 2009-08-07 13:29:14 +0200 | [diff] [blame] | 1546 | install_element(GSMNET_NODE, &cfg_net_mnc_cmd); |
| 1547 | install_element(GSMNET_NODE, &cfg_net_name_short_cmd); |
| 1548 | install_element(GSMNET_NODE, &cfg_net_name_long_cmd); |
Harald Welte (local) | 69de397 | 2009-08-12 14:42:23 +0200 | [diff] [blame] | 1549 | install_element(GSMNET_NODE, &cfg_net_auth_policy_cmd); |
Harald Welte | 1085c09 | 2009-11-18 20:33:19 +0100 | [diff] [blame] | 1550 | install_element(GSMNET_NODE, &cfg_net_reject_cause_cmd); |
Harald Welte | 4381cfe | 2009-08-30 15:47:06 +0900 | [diff] [blame] | 1551 | install_element(GSMNET_NODE, &cfg_net_encryption_cmd); |
Holger Hans Peter Freyther | f7d752f | 2009-11-16 17:12:38 +0100 | [diff] [blame] | 1552 | install_element(GSMNET_NODE, &cfg_net_neci_cmd); |
Harald Welte | eab84a1 | 2009-12-13 10:53:12 +0100 | [diff] [blame] | 1553 | install_element(GSMNET_NODE, &cfg_net_rrlp_mode_cmd); |
Harald Welte | 3d23db4 | 2009-12-14 17:49:15 +0100 | [diff] [blame] | 1554 | install_element(GSMNET_NODE, &cfg_net_mm_info_cmd); |
Harald Welte | bc81450 | 2009-12-19 21:41:52 +0100 | [diff] [blame] | 1555 | install_element(GSMNET_NODE, &cfg_net_handover_cmd); |
Harald Welte | b720bd3 | 2009-12-21 16:51:50 +0100 | [diff] [blame] | 1556 | install_element(GSMNET_NODE, &cfg_net_ho_win_rxlev_avg_cmd); |
| 1557 | install_element(GSMNET_NODE, &cfg_net_ho_win_rxqual_avg_cmd); |
| 1558 | install_element(GSMNET_NODE, &cfg_net_ho_win_rxlev_avg_neigh_cmd); |
| 1559 | install_element(GSMNET_NODE, &cfg_net_ho_pwr_interval_cmd); |
| 1560 | install_element(GSMNET_NODE, &cfg_net_ho_pwr_hysteresis_cmd); |
| 1561 | install_element(GSMNET_NODE, &cfg_net_ho_max_distance_cmd); |
Holger Hans Peter Freyther | c4d88ad | 2009-11-21 21:18:38 +0100 | [diff] [blame] | 1562 | install_element(GSMNET_NODE, &cfg_net_T3101_cmd); |
Holger Hans Peter Freyther | 23975e7 | 2009-11-21 21:42:26 +0100 | [diff] [blame] | 1563 | install_element(GSMNET_NODE, &cfg_net_T3103_cmd); |
| 1564 | install_element(GSMNET_NODE, &cfg_net_T3105_cmd); |
| 1565 | install_element(GSMNET_NODE, &cfg_net_T3107_cmd); |
| 1566 | install_element(GSMNET_NODE, &cfg_net_T3109_cmd); |
| 1567 | install_element(GSMNET_NODE, &cfg_net_T3111_cmd); |
| 1568 | install_element(GSMNET_NODE, &cfg_net_T3113_cmd); |
| 1569 | install_element(GSMNET_NODE, &cfg_net_T3115_cmd); |
| 1570 | install_element(GSMNET_NODE, &cfg_net_T3117_cmd); |
| 1571 | install_element(GSMNET_NODE, &cfg_net_T3119_cmd); |
| 1572 | install_element(GSMNET_NODE, &cfg_net_T3141_cmd); |
Harald Welte | 5013b2a | 2009-08-07 13:29:14 +0200 | [diff] [blame] | 1573 | |
| 1574 | install_element(GSMNET_NODE, &cfg_bts_cmd); |
Harald Welte | 67ce073 | 2009-08-06 19:06:46 +0200 | [diff] [blame] | 1575 | install_node(&bts_node, config_write_bts); |
Harald Welte | 68628e8 | 2009-03-10 12:17:57 +0000 | [diff] [blame] | 1576 | install_default(BTS_NODE); |
Harald Welte | 5258fc4 | 2009-03-28 19:07:53 +0000 | [diff] [blame] | 1577 | install_element(BTS_NODE, &cfg_bts_type_cmd); |
Harald Welte | fcd2445 | 2009-06-20 18:15:19 +0200 | [diff] [blame] | 1578 | install_element(BTS_NODE, &cfg_bts_band_cmd); |
Holger Hans Peter Freyther | c4a49e3 | 2009-08-21 14:44:12 +0200 | [diff] [blame] | 1579 | install_element(BTS_NODE, &cfg_bts_ci_cmd); |
Harald Welte | 5258fc4 | 2009-03-28 19:07:53 +0000 | [diff] [blame] | 1580 | install_element(BTS_NODE, &cfg_bts_lac_cmd); |
| 1581 | install_element(BTS_NODE, &cfg_bts_tsc_cmd); |
Harald Welte | 4258182 | 2009-08-08 16:12:58 +0200 | [diff] [blame] | 1582 | install_element(BTS_NODE, &cfg_bts_bsic_cmd); |
Harald Welte | 4cc3422 | 2009-05-01 15:12:31 +0000 | [diff] [blame] | 1583 | install_element(BTS_NODE, &cfg_bts_unit_id_cmd); |
Harald Welte | 8175e95 | 2009-10-20 00:22:00 +0200 | [diff] [blame] | 1584 | install_element(BTS_NODE, &cfg_bts_stream_id_cmd); |
Harald Welte | 4258182 | 2009-08-08 16:12:58 +0200 | [diff] [blame] | 1585 | install_element(BTS_NODE, &cfg_bts_oml_e1_cmd); |
| 1586 | install_element(BTS_NODE, &cfg_bts_oml_e1_tei_cmd); |
Harald Welte | 7a8fa41 | 2009-08-10 13:48:16 +0200 | [diff] [blame] | 1587 | install_element(BTS_NODE, &cfg_bts_challoc_cmd); |
Sylvain Munaut | 4010f1e | 2009-12-22 13:43:26 +0100 | [diff] [blame] | 1588 | install_element(BTS_NODE, &cfg_bts_rach_tx_integer_cmd); |
| 1589 | install_element(BTS_NODE, &cfg_bts_rach_max_trans_cmd); |
Harald Welte (local) | 5dececf | 2009-08-12 13:28:23 +0200 | [diff] [blame] | 1590 | install_element(BTS_NODE, &cfg_bts_cell_barred_cmd); |
Harald Welte (local) | 0e451d0 | 2009-08-13 10:14:26 +0200 | [diff] [blame] | 1591 | install_element(BTS_NODE, &cfg_bts_ms_max_power_cmd); |
Harald Welte (local) | efc9231 | 2009-08-14 23:09:25 +0200 | [diff] [blame] | 1592 | install_element(BTS_NODE, &cfg_bts_per_loc_upd_cmd); |
Harald Welte | 7322528 | 2009-12-12 18:17:25 +0100 | [diff] [blame] | 1593 | install_element(BTS_NODE, &cfg_bts_cell_resel_hyst_cmd); |
| 1594 | install_element(BTS_NODE, &cfg_bts_rxlev_acc_min_cmd); |
Harald Welte | 7a8fa41 | 2009-08-10 13:48:16 +0200 | [diff] [blame] | 1595 | |
Harald Welte | 68628e8 | 2009-03-10 12:17:57 +0000 | [diff] [blame] | 1596 | |
Harald Welte | 5258fc4 | 2009-03-28 19:07:53 +0000 | [diff] [blame] | 1597 | install_element(BTS_NODE, &cfg_trx_cmd); |
Harald Welte | 68628e8 | 2009-03-10 12:17:57 +0000 | [diff] [blame] | 1598 | install_node(&trx_node, dummy_config_write); |
Harald Welte | 68628e8 | 2009-03-10 12:17:57 +0000 | [diff] [blame] | 1599 | install_default(TRX_NODE); |
Harald Welte | 5258fc4 | 2009-03-28 19:07:53 +0000 | [diff] [blame] | 1600 | install_element(TRX_NODE, &cfg_trx_arfcn_cmd); |
Harald Welte | 879dc97 | 2009-06-20 22:36:12 +0200 | [diff] [blame] | 1601 | install_element(TRX_NODE, &cfg_trx_max_power_red_cmd); |
Harald Welte | 4258182 | 2009-08-08 16:12:58 +0200 | [diff] [blame] | 1602 | install_element(TRX_NODE, &cfg_trx_rsl_e1_cmd); |
| 1603 | install_element(TRX_NODE, &cfg_trx_rsl_e1_tei_cmd); |
Holger Hans Peter Freyther | 2d501ea | 2009-11-11 11:54:24 +0100 | [diff] [blame] | 1604 | install_element(TRX_NODE, &cfg_trx_rf_locked_cmd); |
Harald Welte | 68628e8 | 2009-03-10 12:17:57 +0000 | [diff] [blame] | 1605 | |
Harald Welte | 5258fc4 | 2009-03-28 19:07:53 +0000 | [diff] [blame] | 1606 | install_element(TRX_NODE, &cfg_ts_cmd); |
Harald Welte | 68628e8 | 2009-03-10 12:17:57 +0000 | [diff] [blame] | 1607 | install_node(&ts_node, dummy_config_write); |
Harald Welte | 68628e8 | 2009-03-10 12:17:57 +0000 | [diff] [blame] | 1608 | install_default(TS_NODE); |
Harald Welte | a6fd58e | 2009-08-07 00:25:23 +0200 | [diff] [blame] | 1609 | install_element(TS_NODE, &cfg_ts_pchan_cmd); |
| 1610 | install_element(TS_NODE, &cfg_ts_e1_subslot_cmd); |
Harald Welte | 68628e8 | 2009-03-10 12:17:57 +0000 | [diff] [blame] | 1611 | |
Holger Hans Peter Freyther | cfa90d4 | 2009-08-10 10:17:50 +0200 | [diff] [blame] | 1612 | bsc_vty_init_extra(net); |
Harald Welte | 40f8289 | 2009-05-23 17:31:39 +0000 | [diff] [blame] | 1613 | |
Harald Welte | 68628e8 | 2009-03-10 12:17:57 +0000 | [diff] [blame] | 1614 | return 0; |
| 1615 | } |