Harald Welte | 59b0468 | 2009-06-10 05:40:52 +0800 | [diff] [blame] | 1 | /* OpenBSC interface to quagga VTY */ |
| 2 | /* (C) 2009 by Harald Welte <laforge@gnumonks.org> |
| 3 | * All Rights Reserved |
| 4 | * |
| 5 | * This program is free software; you can redistribute it and/or modify |
| 6 | * it under the terms of the GNU General Public License as published by |
| 7 | * the Free Software Foundation; either version 2 of the License, or |
| 8 | * (at your option) any later version. |
| 9 | * |
| 10 | * This program is distributed in the hope that it will be useful, |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | * GNU General Public License for more details. |
| 14 | * |
| 15 | * You should have received a copy of the GNU General Public License along |
| 16 | * with this program; if not, write to the Free Software Foundation, Inc., |
| 17 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
| 18 | * |
| 19 | */ |
| 20 | |
| 21 | #include <stdlib.h> |
| 22 | #include <unistd.h> |
| 23 | #include <sys/types.h> |
| 24 | |
| 25 | #include <vty/command.h> |
Harald Welte | 684b975 | 2009-08-09 15:13:54 +0200 | [diff] [blame] | 26 | #include <vty/buffer.h> |
Harald Welte | 59b0468 | 2009-06-10 05:40:52 +0800 | [diff] [blame] | 27 | #include <vty/vty.h> |
| 28 | |
| 29 | #include <arpa/inet.h> |
| 30 | |
| 31 | #include <openbsc/linuxlist.h> |
| 32 | #include <openbsc/gsm_data.h> |
Harald Welte | 59b0468 | 2009-06-10 05:40:52 +0800 | [diff] [blame] | 33 | #include <openbsc/e1_input.h> |
| 34 | #include <openbsc/abis_nm.h> |
Harald Welte | 684b975 | 2009-08-09 15:13:54 +0200 | [diff] [blame] | 35 | #include <openbsc/gsm_utils.h> |
Harald Welte | 59b0468 | 2009-06-10 05:40:52 +0800 | [diff] [blame] | 36 | #include <openbsc/db.h> |
Harald Welte | e87eb46 | 2009-08-07 13:29:14 +0200 | [diff] [blame] | 37 | #include <openbsc/talloc.h> |
Harald Welte | 59b0468 | 2009-06-10 05:40:52 +0800 | [diff] [blame] | 38 | |
| 39 | static struct gsm_network *gsmnet; |
| 40 | |
Harald Welte | e87eb46 | 2009-08-07 13:29:14 +0200 | [diff] [blame] | 41 | struct cmd_node net_node = { |
| 42 | GSMNET_NODE, |
| 43 | "%s(network)#", |
| 44 | 1, |
| 45 | }; |
| 46 | |
Harald Welte | 59b0468 | 2009-06-10 05:40:52 +0800 | [diff] [blame] | 47 | struct cmd_node bts_node = { |
| 48 | BTS_NODE, |
| 49 | "%s(bts)#", |
| 50 | 1, |
| 51 | }; |
| 52 | |
| 53 | struct cmd_node trx_node = { |
| 54 | TRX_NODE, |
| 55 | "%s(trx)#", |
| 56 | 1, |
| 57 | }; |
| 58 | |
| 59 | struct cmd_node ts_node = { |
| 60 | TS_NODE, |
| 61 | "%s(ts)#", |
| 62 | 1, |
| 63 | }; |
| 64 | |
Harald Welte | 59b0468 | 2009-06-10 05:40:52 +0800 | [diff] [blame] | 65 | static int dummy_config_write(struct vty *v) |
| 66 | { |
| 67 | return CMD_SUCCESS; |
| 68 | } |
| 69 | |
| 70 | static void net_dump_nmstate(struct vty *vty, struct gsm_nm_state *nms) |
| 71 | { |
| 72 | vty_out(vty,"Oper '%s', Admin %u, Avail '%s'%s", |
| 73 | nm_opstate_name(nms->operational), nms->administrative, |
| 74 | nm_avail_name(nms->availability), VTY_NEWLINE); |
| 75 | } |
| 76 | |
| 77 | static void net_dump_vty(struct vty *vty, struct gsm_network *net) |
| 78 | { |
| 79 | vty_out(vty, "BSC is on Country Code %u, Network Code %u " |
| 80 | "and has %u BTS%s", net->country_code, net->network_code, |
| 81 | net->num_bts, VTY_NEWLINE); |
| 82 | vty_out(vty, " Long network name: '%s'%s", |
| 83 | net->name_long, VTY_NEWLINE); |
| 84 | vty_out(vty, " Short network name: '%s'%s", |
| 85 | net->name_short, VTY_NEWLINE); |
Harald Welte (local) | a59a27e | 2009-08-12 14:42:23 +0200 | [diff] [blame] | 86 | vty_out(vty, " Authentication policy: %s%s", |
| 87 | gsm_auth_policy_name(net->auth_policy), VTY_NEWLINE); |
Harald Welte | 59936d7 | 2009-11-18 20:33:19 +0100 | [diff] [blame] | 88 | vty_out(vty, " Location updating reject cause: %u%s", |
| 89 | net->reject_cause, VTY_NEWLINE); |
Harald Welte | cca253a | 2009-08-30 15:47:06 +0900 | [diff] [blame] | 90 | vty_out(vty, " Encryption: A5/%u%s", net->a5_encryption, |
| 91 | VTY_NEWLINE); |
Holger Hans Peter Freyther | 96c8982 | 2009-11-16 17:12:38 +0100 | [diff] [blame] | 92 | vty_out(vty, " NECI (TCH/H): %u%s", net->neci, |
| 93 | VTY_NEWLINE); |
Harald Welte | 59b0468 | 2009-06-10 05:40:52 +0800 | [diff] [blame] | 94 | } |
| 95 | |
| 96 | DEFUN(show_net, show_net_cmd, "show network", |
| 97 | SHOW_STR "Display information about a GSM NETWORK\n") |
| 98 | { |
| 99 | struct gsm_network *net = gsmnet; |
| 100 | net_dump_vty(vty, net); |
| 101 | |
| 102 | return CMD_SUCCESS; |
| 103 | } |
| 104 | |
| 105 | static void e1isl_dump_vty(struct vty *vty, struct e1inp_sign_link *e1l) |
| 106 | { |
| 107 | struct e1inp_line *line; |
| 108 | |
| 109 | if (!e1l) { |
| 110 | vty_out(vty, " None%s", VTY_NEWLINE); |
| 111 | return; |
| 112 | } |
| 113 | |
| 114 | line = e1l->ts->line; |
| 115 | |
| 116 | vty_out(vty, " E1 Line %u, Type %s: Timeslot %u, Mode %s%s", |
| 117 | line->num, line->driver->name, e1l->ts->num, |
| 118 | e1inp_signtype_name(e1l->type), VTY_NEWLINE); |
| 119 | vty_out(vty, " E1 TEI %u, SAPI %u%s", |
| 120 | e1l->tei, e1l->sapi, VTY_NEWLINE); |
| 121 | } |
| 122 | |
| 123 | static void bts_dump_vty(struct vty *vty, struct gsm_bts *bts) |
| 124 | { |
Holger Hans Peter Freyther | a098dfb | 2009-08-21 14:44:12 +0200 | [diff] [blame] | 125 | vty_out(vty, "BTS %u is of %s type in band %s, has CI %u LAC %u, " |
Harald Welte | 91afe4c | 2009-06-20 18:15:19 +0200 | [diff] [blame] | 126 | "BSIC %u, TSC %u and %u TRX%s", |
| 127 | bts->nr, btstype2str(bts->type), gsm_band_name(bts->band), |
Holger Hans Peter Freyther | a098dfb | 2009-08-21 14:44:12 +0200 | [diff] [blame] | 128 | bts->cell_identity, |
Harald Welte | 91afe4c | 2009-06-20 18:15:19 +0200 | [diff] [blame] | 129 | bts->location_area_code, bts->bsic, bts->tsc, |
| 130 | bts->num_trx, VTY_NEWLINE); |
Harald Welte | 8e9d179 | 2009-12-12 15:38:16 +0100 | [diff] [blame] | 131 | vty_out(vty, "MS Max power: %u dBm%s", bts->ms_max_power, VTY_NEWLINE); |
Harald Welte | b761bf8 | 2009-12-12 18:17:25 +0100 | [diff] [blame] | 132 | vty_out(vty, "Minimum Rx Level for Access: %i dBm%s", |
Harald Welte | 8e9d179 | 2009-12-12 15:38:16 +0100 | [diff] [blame] | 133 | rxlev2dbm(bts->si_common.cell_sel_par.rxlev_acc_min), |
| 134 | VTY_NEWLINE); |
| 135 | vty_out(vty, "Cell Reselection Hysteresis: %u dBm%s", |
Harald Welte | b761bf8 | 2009-12-12 18:17:25 +0100 | [diff] [blame] | 136 | bts->si_common.cell_sel_par.cell_resel_hyst*2, VTY_NEWLINE); |
Harald Welte (local) | e19be3f | 2009-08-12 13:28:23 +0200 | [diff] [blame] | 137 | if (bts->cell_barred) |
| 138 | vty_out(vty, " CELL IS BARRED%s", VTY_NEWLINE); |
Harald Welte | 59b0468 | 2009-06-10 05:40:52 +0800 | [diff] [blame] | 139 | if (is_ipaccess_bts(bts)) |
Harald Welte | 2557287 | 2009-10-20 00:22:00 +0200 | [diff] [blame] | 140 | vty_out(vty, " Unit ID: %u/%u/0, OML Stream ID 0x%02x%s", |
Harald Welte | 59b0468 | 2009-06-10 05:40:52 +0800 | [diff] [blame] | 141 | bts->ip_access.site_id, bts->ip_access.bts_id, |
Harald Welte | 2557287 | 2009-10-20 00:22:00 +0200 | [diff] [blame] | 142 | bts->oml_tei, VTY_NEWLINE); |
Harald Welte | 59b0468 | 2009-06-10 05:40:52 +0800 | [diff] [blame] | 143 | vty_out(vty, " NM State: "); |
| 144 | net_dump_nmstate(vty, &bts->nm_state); |
| 145 | vty_out(vty, " Site Mgr NM State: "); |
| 146 | net_dump_nmstate(vty, &bts->site_mgr.nm_state); |
| 147 | vty_out(vty, " Paging: FIXME pending requests, %u free slots%s", |
| 148 | bts->paging.available_slots, VTY_NEWLINE); |
Harald Welte | 2557287 | 2009-10-20 00:22:00 +0200 | [diff] [blame] | 149 | if (!is_ipaccess_bts(bts)) { |
| 150 | vty_out(vty, " E1 Signalling Link:%s", VTY_NEWLINE); |
| 151 | e1isl_dump_vty(vty, bts->oml_link); |
| 152 | } |
Harald Welte | 59b0468 | 2009-06-10 05:40:52 +0800 | [diff] [blame] | 153 | /* FIXME: oml_link, chan_desc */ |
| 154 | } |
| 155 | |
| 156 | DEFUN(show_bts, show_bts_cmd, "show bts [number]", |
| 157 | SHOW_STR "Display information about a BTS\n" |
| 158 | "BTS number") |
| 159 | { |
| 160 | struct gsm_network *net = gsmnet; |
| 161 | int bts_nr; |
| 162 | |
| 163 | if (argc != 0) { |
| 164 | /* use the BTS number that the user has specified */ |
| 165 | bts_nr = atoi(argv[0]); |
| 166 | if (bts_nr > net->num_bts) { |
| 167 | vty_out(vty, "%% can't find BTS '%s'%s", argv[0], |
| 168 | VTY_NEWLINE); |
| 169 | return CMD_WARNING; |
| 170 | } |
Harald Welte | e712a5f | 2009-06-21 16:17:15 +0200 | [diff] [blame] | 171 | bts_dump_vty(vty, gsm_bts_num(net, bts_nr)); |
Harald Welte | 59b0468 | 2009-06-10 05:40:52 +0800 | [diff] [blame] | 172 | return CMD_SUCCESS; |
| 173 | } |
| 174 | /* print all BTS's */ |
| 175 | for (bts_nr = 0; bts_nr < net->num_bts; bts_nr++) |
Harald Welte | e712a5f | 2009-06-21 16:17:15 +0200 | [diff] [blame] | 176 | bts_dump_vty(vty, gsm_bts_num(net, bts_nr)); |
Harald Welte | 59b0468 | 2009-06-10 05:40:52 +0800 | [diff] [blame] | 177 | |
| 178 | return CMD_SUCCESS; |
| 179 | } |
| 180 | |
Harald Welte | 6286888 | 2009-08-08 16:12:58 +0200 | [diff] [blame] | 181 | /* utility functions */ |
| 182 | static void parse_e1_link(struct gsm_e1_subslot *e1_link, const char *line, |
| 183 | const char *ts, const char *ss) |
| 184 | { |
| 185 | e1_link->e1_nr = atoi(line); |
| 186 | e1_link->e1_ts = atoi(ts); |
| 187 | if (!strcmp(ss, "full")) |
| 188 | e1_link->e1_ts_ss = 255; |
| 189 | else |
| 190 | e1_link->e1_ts_ss = atoi(ss); |
| 191 | } |
| 192 | |
| 193 | static void config_write_e1_link(struct vty *vty, struct gsm_e1_subslot *e1_link, |
| 194 | const char *prefix) |
| 195 | { |
| 196 | if (!e1_link->e1_ts) |
| 197 | return; |
| 198 | |
| 199 | if (e1_link->e1_ts_ss == 255) |
| 200 | vty_out(vty, "%se1 line %u timeslot %u sub-slot full%s", |
| 201 | prefix, e1_link->e1_nr, e1_link->e1_ts, VTY_NEWLINE); |
| 202 | else |
| 203 | vty_out(vty, "%se1 line %u timeslot %u sub-slot %u%s", |
| 204 | prefix, e1_link->e1_nr, e1_link->e1_ts, |
| 205 | e1_link->e1_ts_ss, VTY_NEWLINE); |
| 206 | } |
| 207 | |
| 208 | |
Harald Welte | 97ceef9 | 2009-08-06 19:06:46 +0200 | [diff] [blame] | 209 | static void config_write_ts_single(struct vty *vty, struct gsm_bts_trx_ts *ts) |
| 210 | { |
Harald Welte | 6286888 | 2009-08-08 16:12:58 +0200 | [diff] [blame] | 211 | vty_out(vty, " timeslot %u%s", ts->nr, VTY_NEWLINE); |
| 212 | if (ts->pchan != GSM_PCHAN_NONE) |
| 213 | vty_out(vty, " phys_chan_config %s%s", |
| 214 | gsm_pchan_name(ts->pchan), VTY_NEWLINE); |
| 215 | config_write_e1_link(vty, &ts->e1_link, " "); |
Harald Welte | 97ceef9 | 2009-08-06 19:06:46 +0200 | [diff] [blame] | 216 | } |
| 217 | |
| 218 | static void config_write_trx_single(struct vty *vty, struct gsm_bts_trx *trx) |
| 219 | { |
| 220 | int i; |
| 221 | |
Harald Welte | e87eb46 | 2009-08-07 13:29:14 +0200 | [diff] [blame] | 222 | vty_out(vty, " trx %u%s", trx->nr, VTY_NEWLINE); |
| 223 | vty_out(vty, " arfcn %u%s", trx->arfcn, VTY_NEWLINE); |
| 224 | vty_out(vty, " max_power_red %u%s", trx->max_power_red, VTY_NEWLINE); |
Harald Welte | 6286888 | 2009-08-08 16:12:58 +0200 | [diff] [blame] | 225 | config_write_e1_link(vty, &trx->rsl_e1_link, " rsl "); |
| 226 | vty_out(vty, " rsl e1 tei %u%s", trx->rsl_tei, VTY_NEWLINE); |
Harald Welte | 97ceef9 | 2009-08-06 19:06:46 +0200 | [diff] [blame] | 227 | |
| 228 | for (i = 0; i < TRX_NR_TS; i++) |
| 229 | config_write_ts_single(vty, &trx->ts[i]); |
| 230 | } |
| 231 | |
| 232 | static void config_write_bts_single(struct vty *vty, struct gsm_bts *bts) |
| 233 | { |
| 234 | struct gsm_bts_trx *trx; |
| 235 | |
Harald Welte | e87eb46 | 2009-08-07 13:29:14 +0200 | [diff] [blame] | 236 | vty_out(vty, " bts %u%s", bts->nr, VTY_NEWLINE); |
| 237 | vty_out(vty, " type %s%s", btstype2str(bts->type), VTY_NEWLINE); |
| 238 | vty_out(vty, " band %s%s", gsm_band_name(bts->band), VTY_NEWLINE); |
Holger Hans Peter Freyther | 6d82b7c | 2009-11-19 16:38:49 +0100 | [diff] [blame] | 239 | vty_out(vty, " cell_identity %u%s", bts->cell_identity, VTY_NEWLINE); |
Harald Welte | e87eb46 | 2009-08-07 13:29:14 +0200 | [diff] [blame] | 240 | vty_out(vty, " location_area_code %u%s", bts->location_area_code, |
Harald Welte | 97ceef9 | 2009-08-06 19:06:46 +0200 | [diff] [blame] | 241 | VTY_NEWLINE); |
Harald Welte | e87eb46 | 2009-08-07 13:29:14 +0200 | [diff] [blame] | 242 | vty_out(vty, " training_sequence_code %u%s", bts->tsc, VTY_NEWLINE); |
| 243 | vty_out(vty, " base_station_id_code %u%s", bts->bsic, VTY_NEWLINE); |
Harald Welte (local) | cbd4610 | 2009-08-13 10:14:26 +0200 | [diff] [blame] | 244 | vty_out(vty, " ms max power %u%s", bts->ms_max_power, VTY_NEWLINE); |
Harald Welte | b761bf8 | 2009-12-12 18:17:25 +0100 | [diff] [blame] | 245 | vty_out(vty, " cell reselection hysteresis %u%s", |
| 246 | bts->si_common.cell_sel_par.cell_resel_hyst*2, VTY_NEWLINE); |
| 247 | vty_out(vty, " rxlev access min %u%s", |
| 248 | bts->si_common.cell_sel_par.rxlev_acc_min, VTY_NEWLINE); |
Harald Welte | a54a2bb | 2009-12-01 18:04:30 +0530 | [diff] [blame] | 249 | if (bts->si_common.chan_desc.t3212) |
Harald Welte (local) | b6ea7f7 | 2009-08-14 23:09:25 +0200 | [diff] [blame] | 250 | vty_out(vty, " periodic location update %u%s", |
Harald Welte | a54a2bb | 2009-12-01 18:04:30 +0530 | [diff] [blame] | 251 | bts->si_common.chan_desc.t3212 * 10, VTY_NEWLINE); |
Harald Welte | 3e77461 | 2009-08-10 13:48:16 +0200 | [diff] [blame] | 252 | vty_out(vty, " channel allocator %s%s", |
| 253 | bts->chan_alloc_reverse ? "descending" : "ascending", |
| 254 | VTY_NEWLINE); |
Harald Welte (local) | e19be3f | 2009-08-12 13:28:23 +0200 | [diff] [blame] | 255 | if (bts->cell_barred) |
| 256 | vty_out(vty, " cell barred 1%s", VTY_NEWLINE); |
Harald Welte | 2557287 | 2009-10-20 00:22:00 +0200 | [diff] [blame] | 257 | if (is_ipaccess_bts(bts)) { |
Harald Welte | e87eb46 | 2009-08-07 13:29:14 +0200 | [diff] [blame] | 258 | vty_out(vty, " ip.access unit_id %u %u%s", |
Harald Welte | 3ffe1b3 | 2009-08-07 00:25:23 +0200 | [diff] [blame] | 259 | bts->ip_access.site_id, bts->ip_access.bts_id, VTY_NEWLINE); |
Harald Welte | 2557287 | 2009-10-20 00:22:00 +0200 | [diff] [blame] | 260 | vty_out(vty, " oml ip.access stream_id %u%s", bts->oml_tei, VTY_NEWLINE); |
| 261 | } else { |
Harald Welte | 6286888 | 2009-08-08 16:12:58 +0200 | [diff] [blame] | 262 | config_write_e1_link(vty, &bts->oml_e1_link, " oml "); |
| 263 | vty_out(vty, " oml e1 tei %u%s", bts->oml_tei, VTY_NEWLINE); |
| 264 | } |
Harald Welte | 97ceef9 | 2009-08-06 19:06:46 +0200 | [diff] [blame] | 265 | |
| 266 | llist_for_each_entry(trx, &bts->trx_list, list) |
| 267 | config_write_trx_single(vty, trx); |
| 268 | } |
| 269 | |
| 270 | static int config_write_bts(struct vty *v) |
| 271 | { |
| 272 | struct gsm_bts *bts; |
| 273 | |
| 274 | llist_for_each_entry(bts, &gsmnet->bts_list, list) |
| 275 | config_write_bts_single(v, bts); |
| 276 | |
| 277 | return CMD_SUCCESS; |
| 278 | } |
| 279 | |
Harald Welte | e87eb46 | 2009-08-07 13:29:14 +0200 | [diff] [blame] | 280 | static int config_write_net(struct vty *vty) |
| 281 | { |
| 282 | vty_out(vty, "network%s", VTY_NEWLINE); |
Harald Welte | 6286888 | 2009-08-08 16:12:58 +0200 | [diff] [blame] | 283 | vty_out(vty, " network country code %u%s", gsmnet->country_code, VTY_NEWLINE); |
Harald Welte | e87eb46 | 2009-08-07 13:29:14 +0200 | [diff] [blame] | 284 | vty_out(vty, " mobile network code %u%s", gsmnet->network_code, VTY_NEWLINE); |
Harald Welte | 6286888 | 2009-08-08 16:12:58 +0200 | [diff] [blame] | 285 | vty_out(vty, " short name %s%s", gsmnet->name_short, VTY_NEWLINE); |
| 286 | vty_out(vty, " long name %s%s", gsmnet->name_long, VTY_NEWLINE); |
Harald Welte (local) | a59a27e | 2009-08-12 14:42:23 +0200 | [diff] [blame] | 287 | vty_out(vty, " auth policy %s%s", gsm_auth_policy_name(gsmnet->auth_policy), VTY_NEWLINE); |
Harald Welte | 59936d7 | 2009-11-18 20:33:19 +0100 | [diff] [blame] | 288 | vty_out(vty, " location updating reject cause %u%s", |
| 289 | gsmnet->reject_cause, VTY_NEWLINE); |
Harald Welte | cca253a | 2009-08-30 15:47:06 +0900 | [diff] [blame] | 290 | vty_out(vty, " encryption a5 %u%s", gsmnet->a5_encryption, VTY_NEWLINE); |
Holger Hans Peter Freyther | 6b4f546 | 2009-11-19 16:37:48 +0100 | [diff] [blame] | 291 | vty_out(vty, " neci %u%s", gsmnet->neci, VTY_NEWLINE); |
Holger Hans Peter Freyther | 26ba2e7 | 2009-11-21 21:18:38 +0100 | [diff] [blame] | 292 | vty_out(vty, " timer t3101 %u%s", gsmnet->T3101, VTY_NEWLINE); |
Holger Hans Peter Freyther | 8973386 | 2009-11-21 21:42:26 +0100 | [diff] [blame] | 293 | vty_out(vty, " timer t3103 %u%s", gsmnet->T3103, VTY_NEWLINE); |
| 294 | vty_out(vty, " timer t3105 %u%s", gsmnet->T3105, VTY_NEWLINE); |
| 295 | vty_out(vty, " timer t3107 %u%s", gsmnet->T3107, VTY_NEWLINE); |
| 296 | vty_out(vty, " timer t3109 %u%s", gsmnet->T3109, VTY_NEWLINE); |
| 297 | vty_out(vty, " timer t3111 %u%s", gsmnet->T3111, VTY_NEWLINE); |
| 298 | vty_out(vty, " timer t3113 %u%s", gsmnet->T3113, VTY_NEWLINE); |
| 299 | vty_out(vty, " timer t3115 %u%s", gsmnet->T3115, VTY_NEWLINE); |
| 300 | vty_out(vty, " timer t3117 %u%s", gsmnet->T3117, VTY_NEWLINE); |
| 301 | vty_out(vty, " timer t3119 %u%s", gsmnet->T3119, VTY_NEWLINE); |
| 302 | vty_out(vty, " timer t3141 %u%s", gsmnet->T3141, VTY_NEWLINE); |
Harald Welte | e87eb46 | 2009-08-07 13:29:14 +0200 | [diff] [blame] | 303 | |
| 304 | return CMD_SUCCESS; |
| 305 | } |
Harald Welte | 97ceef9 | 2009-08-06 19:06:46 +0200 | [diff] [blame] | 306 | |
Harald Welte | 59b0468 | 2009-06-10 05:40:52 +0800 | [diff] [blame] | 307 | static void trx_dump_vty(struct vty *vty, struct gsm_bts_trx *trx) |
| 308 | { |
| 309 | vty_out(vty, "TRX %u of BTS %u is on ARFCN %u%s", |
| 310 | trx->nr, trx->bts->nr, trx->arfcn, VTY_NEWLINE); |
Harald Welte | 91afe4c | 2009-06-20 18:15:19 +0200 | [diff] [blame] | 311 | vty_out(vty, " RF Nominal Power: %d dBm, reduced by %u dB, " |
Harald Welte | 6286888 | 2009-08-08 16:12:58 +0200 | [diff] [blame] | 312 | "resulting BS power: %d dBm%s", |
Harald Welte | 91afe4c | 2009-06-20 18:15:19 +0200 | [diff] [blame] | 313 | trx->nominal_power, trx->max_power_red, |
Harald Welte | 6286888 | 2009-08-08 16:12:58 +0200 | [diff] [blame] | 314 | trx->nominal_power - trx->max_power_red, VTY_NEWLINE); |
Harald Welte | 59b0468 | 2009-06-10 05:40:52 +0800 | [diff] [blame] | 315 | vty_out(vty, " NM State: "); |
| 316 | net_dump_nmstate(vty, &trx->nm_state); |
| 317 | vty_out(vty, " Baseband Transceiver NM State: "); |
| 318 | net_dump_nmstate(vty, &trx->bb_transc.nm_state); |
Harald Welte | 2557287 | 2009-10-20 00:22:00 +0200 | [diff] [blame] | 319 | if (is_ipaccess_bts(trx->bts)) { |
| 320 | vty_out(vty, " ip.access stream ID: 0x%02x%s", |
| 321 | trx->rsl_tei, VTY_NEWLINE); |
| 322 | } else { |
| 323 | vty_out(vty, " E1 Signalling Link:%s", VTY_NEWLINE); |
| 324 | e1isl_dump_vty(vty, trx->rsl_link); |
| 325 | } |
Harald Welte | 59b0468 | 2009-06-10 05:40:52 +0800 | [diff] [blame] | 326 | } |
| 327 | |
| 328 | DEFUN(show_trx, |
| 329 | show_trx_cmd, |
| 330 | "show trx [bts_nr] [trx_nr]", |
| 331 | SHOW_STR "Display information about a TRX\n") |
| 332 | { |
| 333 | struct gsm_network *net = gsmnet; |
| 334 | struct gsm_bts *bts = NULL; |
| 335 | struct gsm_bts_trx *trx; |
| 336 | int bts_nr, trx_nr; |
| 337 | |
| 338 | if (argc >= 1) { |
| 339 | /* use the BTS number that the user has specified */ |
| 340 | bts_nr = atoi(argv[0]); |
| 341 | if (bts_nr >= net->num_bts) { |
| 342 | vty_out(vty, "%% can't find BTS '%s'%s", argv[0], |
| 343 | VTY_NEWLINE); |
| 344 | return CMD_WARNING; |
| 345 | } |
Harald Welte | e712a5f | 2009-06-21 16:17:15 +0200 | [diff] [blame] | 346 | bts = gsm_bts_num(net, bts_nr); |
Harald Welte | 59b0468 | 2009-06-10 05:40:52 +0800 | [diff] [blame] | 347 | } |
| 348 | if (argc >= 2) { |
| 349 | trx_nr = atoi(argv[1]); |
| 350 | if (trx_nr >= bts->num_trx) { |
| 351 | vty_out(vty, "%% can't find TRX '%s'%s", argv[1], |
| 352 | VTY_NEWLINE); |
| 353 | return CMD_WARNING; |
| 354 | } |
Harald Welte | e712a5f | 2009-06-21 16:17:15 +0200 | [diff] [blame] | 355 | trx = gsm_bts_trx_num(bts, trx_nr); |
Harald Welte | 59b0468 | 2009-06-10 05:40:52 +0800 | [diff] [blame] | 356 | trx_dump_vty(vty, trx); |
| 357 | return CMD_SUCCESS; |
| 358 | } |
| 359 | if (bts) { |
| 360 | /* print all TRX in this BTS */ |
| 361 | for (trx_nr = 0; trx_nr < bts->num_trx; trx_nr++) { |
Harald Welte | e712a5f | 2009-06-21 16:17:15 +0200 | [diff] [blame] | 362 | trx = gsm_bts_trx_num(bts, trx_nr); |
Harald Welte | 59b0468 | 2009-06-10 05:40:52 +0800 | [diff] [blame] | 363 | trx_dump_vty(vty, trx); |
| 364 | } |
| 365 | return CMD_SUCCESS; |
| 366 | } |
| 367 | |
| 368 | for (bts_nr = 0; bts_nr < net->num_bts; bts_nr++) { |
Harald Welte | e712a5f | 2009-06-21 16:17:15 +0200 | [diff] [blame] | 369 | bts = gsm_bts_num(net, bts_nr); |
Harald Welte | 59b0468 | 2009-06-10 05:40:52 +0800 | [diff] [blame] | 370 | for (trx_nr = 0; trx_nr < bts->num_trx; trx_nr++) { |
Harald Welte | e712a5f | 2009-06-21 16:17:15 +0200 | [diff] [blame] | 371 | trx = gsm_bts_trx_num(bts, trx_nr); |
Harald Welte | 59b0468 | 2009-06-10 05:40:52 +0800 | [diff] [blame] | 372 | trx_dump_vty(vty, trx); |
| 373 | } |
| 374 | } |
| 375 | |
| 376 | return CMD_SUCCESS; |
| 377 | } |
| 378 | |
Harald Welte | 97ceef9 | 2009-08-06 19:06:46 +0200 | [diff] [blame] | 379 | |
Harald Welte | 59b0468 | 2009-06-10 05:40:52 +0800 | [diff] [blame] | 380 | static void ts_dump_vty(struct vty *vty, struct gsm_bts_trx_ts *ts) |
| 381 | { |
Harald Welte | 59b0468 | 2009-06-10 05:40:52 +0800 | [diff] [blame] | 382 | vty_out(vty, "Timeslot %u of TRX %u in BTS %u, phys cfg %s%s", |
| 383 | ts->nr, ts->trx->nr, ts->trx->bts->nr, |
| 384 | gsm_pchan_name(ts->pchan), VTY_NEWLINE); |
| 385 | vty_out(vty, " NM State: "); |
| 386 | net_dump_nmstate(vty, &ts->nm_state); |
Harald Welte | 8750421 | 2009-12-02 01:56:49 +0530 | [diff] [blame] | 387 | if (!is_ipaccess_bts(ts->trx->bts)) |
Harald Welte | 59b0468 | 2009-06-10 05:40:52 +0800 | [diff] [blame] | 388 | vty_out(vty, " E1 Line %u, Timeslot %u, Subslot %u%s", |
| 389 | ts->e1_link.e1_nr, ts->e1_link.e1_ts, |
| 390 | ts->e1_link.e1_ts_ss, VTY_NEWLINE); |
Harald Welte | 59b0468 | 2009-06-10 05:40:52 +0800 | [diff] [blame] | 391 | } |
| 392 | |
| 393 | DEFUN(show_ts, |
| 394 | show_ts_cmd, |
| 395 | "show timeslot [bts_nr] [trx_nr] [ts_nr]", |
| 396 | SHOW_STR "Display information about a TS\n") |
| 397 | { |
| 398 | struct gsm_network *net = gsmnet; |
| 399 | struct gsm_bts *bts; |
| 400 | struct gsm_bts_trx *trx; |
| 401 | struct gsm_bts_trx_ts *ts; |
| 402 | int bts_nr, trx_nr, ts_nr; |
| 403 | |
| 404 | if (argc >= 1) { |
| 405 | /* use the BTS number that the user has specified */ |
| 406 | bts_nr = atoi(argv[0]); |
| 407 | if (bts_nr >= net->num_bts) { |
| 408 | vty_out(vty, "%% can't find BTS '%s'%s", argv[0], |
| 409 | VTY_NEWLINE); |
| 410 | return CMD_WARNING; |
| 411 | } |
Harald Welte | e712a5f | 2009-06-21 16:17:15 +0200 | [diff] [blame] | 412 | bts = gsm_bts_num(net, bts_nr); |
Harald Welte | 59b0468 | 2009-06-10 05:40:52 +0800 | [diff] [blame] | 413 | } |
| 414 | if (argc >= 2) { |
| 415 | trx_nr = atoi(argv[1]); |
| 416 | if (trx_nr >= bts->num_trx) { |
| 417 | vty_out(vty, "%% can't find TRX '%s'%s", argv[1], |
| 418 | VTY_NEWLINE); |
| 419 | return CMD_WARNING; |
| 420 | } |
Harald Welte | e712a5f | 2009-06-21 16:17:15 +0200 | [diff] [blame] | 421 | trx = gsm_bts_trx_num(bts, trx_nr); |
Harald Welte | 59b0468 | 2009-06-10 05:40:52 +0800 | [diff] [blame] | 422 | } |
| 423 | if (argc >= 3) { |
| 424 | ts_nr = atoi(argv[2]); |
| 425 | if (ts_nr >= TRX_NR_TS) { |
| 426 | vty_out(vty, "%% can't find TS '%s'%s", argv[2], |
| 427 | VTY_NEWLINE); |
| 428 | return CMD_WARNING; |
| 429 | } |
| 430 | ts = &trx->ts[ts_nr]; |
| 431 | ts_dump_vty(vty, ts); |
| 432 | return CMD_SUCCESS; |
| 433 | } |
| 434 | for (bts_nr = 0; bts_nr < net->num_bts; bts_nr++) { |
Harald Welte | e712a5f | 2009-06-21 16:17:15 +0200 | [diff] [blame] | 435 | bts = gsm_bts_num(net, bts_nr); |
Harald Welte | 59b0468 | 2009-06-10 05:40:52 +0800 | [diff] [blame] | 436 | for (trx_nr = 0; trx_nr < bts->num_trx; trx_nr++) { |
Harald Welte | e712a5f | 2009-06-21 16:17:15 +0200 | [diff] [blame] | 437 | trx = gsm_bts_trx_num(bts, trx_nr); |
Harald Welte | 59b0468 | 2009-06-10 05:40:52 +0800 | [diff] [blame] | 438 | for (ts_nr = 0; ts_nr < TRX_NR_TS; ts_nr++) { |
| 439 | ts = &trx->ts[ts_nr]; |
| 440 | ts_dump_vty(vty, ts); |
| 441 | } |
| 442 | } |
| 443 | } |
| 444 | |
| 445 | return CMD_SUCCESS; |
| 446 | } |
| 447 | |
Holger Hans Peter Freyther | bdae6f9 | 2009-08-10 10:17:50 +0200 | [diff] [blame] | 448 | void subscr_dump_vty(struct vty *vty, struct gsm_subscriber *subscr) |
Harald Welte | 59b0468 | 2009-06-10 05:40:52 +0800 | [diff] [blame] | 449 | { |
Harald Welte | 91afe4c | 2009-06-20 18:15:19 +0200 | [diff] [blame] | 450 | vty_out(vty, " ID: %llu, Authorized: %d%s", subscr->id, |
Harald Welte | 59b0468 | 2009-06-10 05:40:52 +0800 | [diff] [blame] | 451 | subscr->authorized, VTY_NEWLINE); |
| 452 | if (subscr->name) |
| 453 | vty_out(vty, " Name: '%s'%s", subscr->name, VTY_NEWLINE); |
| 454 | if (subscr->extension) |
| 455 | vty_out(vty, " Extension: %s%s", subscr->extension, |
| 456 | VTY_NEWLINE); |
| 457 | if (subscr->imsi) |
| 458 | vty_out(vty, " IMSI: %s%s", subscr->imsi, VTY_NEWLINE); |
Holger Hans Peter Freyther | cd8bacf | 2009-08-19 12:53:57 +0200 | [diff] [blame] | 459 | if (subscr->tmsi != GSM_RESERVED_TMSI) |
| 460 | vty_out(vty, " TMSI: %08X%s", subscr->tmsi, |
Harald Welte | 270c06c | 2009-08-15 03:24:51 +0200 | [diff] [blame] | 461 | VTY_NEWLINE); |
Harald Welte (local) | 02d5efa | 2009-08-14 20:27:16 +0200 | [diff] [blame] | 462 | vty_out(vty, " Use count: %u%s", subscr->use_count, VTY_NEWLINE); |
Harald Welte | 59b0468 | 2009-06-10 05:40:52 +0800 | [diff] [blame] | 463 | } |
| 464 | |
| 465 | static void lchan_dump_vty(struct vty *vty, struct gsm_lchan *lchan) |
| 466 | { |
| 467 | vty_out(vty, "Lchan %u in Timeslot %u of TRX %u in BTS %u, Type %s%s", |
| 468 | lchan->nr, lchan->ts->nr, lchan->ts->trx->nr, |
| 469 | lchan->ts->trx->bts->nr, gsm_lchan_name(lchan->type), |
| 470 | VTY_NEWLINE); |
| 471 | vty_out(vty, " Use Count: %u%s", lchan->use_count, VTY_NEWLINE); |
Harald Welte | b761bf8 | 2009-12-12 18:17:25 +0100 | [diff] [blame] | 472 | vty_out(vty, " BS Power: %u dBm, MS Power: %u dBm%s", |
| 473 | lchan->ts->trx->nominal_power - lchan->ts->trx->max_power_red |
| 474 | - lchan->bs_power*2, |
| 475 | ms_pwr_dbm(lchan->ts->trx->bts->band, lchan->ms_power), |
| 476 | VTY_NEWLINE); |
Harald Welte | 59b0468 | 2009-06-10 05:40:52 +0800 | [diff] [blame] | 477 | if (lchan->subscr) { |
| 478 | vty_out(vty, " Subscriber:%s", VTY_NEWLINE); |
| 479 | subscr_dump_vty(vty, lchan->subscr); |
| 480 | } else |
| 481 | vty_out(vty, " No Subscriber%s", VTY_NEWLINE); |
Harald Welte | 8750421 | 2009-12-02 01:56:49 +0530 | [diff] [blame] | 482 | if (is_ipaccess_bts(lchan->ts->trx->bts)) { |
| 483 | struct in_addr ia; |
| 484 | ia.s_addr = lchan->abis_ip.bound_ip; |
| 485 | vty_out(vty, " Bound IP: %s Port %u RTP_TYPE2=%u CONN_ID=%u%s", |
| 486 | inet_ntoa(ia), lchan->abis_ip.bound_port, |
| 487 | lchan->abis_ip.rtp_payload2, lchan->abis_ip.conn_id, |
| 488 | VTY_NEWLINE); |
| 489 | } |
Harald Welte | 59b0468 | 2009-06-10 05:40:52 +0800 | [diff] [blame] | 490 | } |
| 491 | |
Harald Welte | 0374084 | 2009-06-10 23:11:52 +0800 | [diff] [blame] | 492 | #if 0 |
| 493 | TODO: callref and remote callref of call must be resolved to get gsm_trans object |
Harald Welte | 59b0468 | 2009-06-10 05:40:52 +0800 | [diff] [blame] | 494 | static void call_dump_vty(struct vty *vty, struct gsm_call *call) |
| 495 | { |
| 496 | vty_out(vty, "Call Type %u, State %u, Transaction ID %u%s", |
| 497 | call->type, call->state, call->transaction_id, VTY_NEWLINE); |
| 498 | |
| 499 | if (call->local_lchan) { |
| 500 | vty_out(vty, "Call Local Channel:%s", VTY_NEWLINE); |
| 501 | lchan_dump_vty(vty, call->local_lchan); |
| 502 | } else |
| 503 | vty_out(vty, "Call has no Local Channel%s", VTY_NEWLINE); |
| 504 | |
| 505 | if (call->remote_lchan) { |
| 506 | vty_out(vty, "Call Remote Channel:%s", VTY_NEWLINE); |
| 507 | lchan_dump_vty(vty, call->remote_lchan); |
| 508 | } else |
| 509 | vty_out(vty, "Call has no Remote Channel%s", VTY_NEWLINE); |
| 510 | |
| 511 | if (call->called_subscr) { |
| 512 | vty_out(vty, "Called Subscriber:%s", VTY_NEWLINE); |
| 513 | subscr_dump_vty(vty, call->called_subscr); |
| 514 | } else |
| 515 | vty_out(vty, "Call has no Called Subscriber%s", VTY_NEWLINE); |
| 516 | } |
Harald Welte | 0374084 | 2009-06-10 23:11:52 +0800 | [diff] [blame] | 517 | #endif |
Harald Welte | 59b0468 | 2009-06-10 05:40:52 +0800 | [diff] [blame] | 518 | |
| 519 | DEFUN(show_lchan, |
| 520 | show_lchan_cmd, |
| 521 | "show lchan [bts_nr] [trx_nr] [ts_nr] [lchan_nr]", |
| 522 | SHOW_STR "Display information about a logical channel\n") |
| 523 | { |
| 524 | struct gsm_network *net = gsmnet; |
| 525 | struct gsm_bts *bts; |
| 526 | struct gsm_bts_trx *trx; |
| 527 | struct gsm_bts_trx_ts *ts; |
| 528 | struct gsm_lchan *lchan; |
| 529 | int bts_nr, trx_nr, ts_nr, lchan_nr; |
| 530 | |
| 531 | if (argc >= 1) { |
| 532 | /* use the BTS number that the user has specified */ |
| 533 | bts_nr = atoi(argv[0]); |
| 534 | if (bts_nr >= net->num_bts) { |
| 535 | vty_out(vty, "%% can't find BTS %s%s", argv[0], |
| 536 | VTY_NEWLINE); |
| 537 | return CMD_WARNING; |
| 538 | } |
Harald Welte | e712a5f | 2009-06-21 16:17:15 +0200 | [diff] [blame] | 539 | bts = gsm_bts_num(net, bts_nr); |
Harald Welte | 59b0468 | 2009-06-10 05:40:52 +0800 | [diff] [blame] | 540 | } |
| 541 | if (argc >= 2) { |
| 542 | trx_nr = atoi(argv[1]); |
| 543 | if (trx_nr >= bts->num_trx) { |
| 544 | vty_out(vty, "%% can't find TRX %s%s", argv[1], |
| 545 | VTY_NEWLINE); |
| 546 | return CMD_WARNING; |
| 547 | } |
Harald Welte | e712a5f | 2009-06-21 16:17:15 +0200 | [diff] [blame] | 548 | trx = gsm_bts_trx_num(bts, trx_nr); |
Harald Welte | 59b0468 | 2009-06-10 05:40:52 +0800 | [diff] [blame] | 549 | } |
| 550 | if (argc >= 3) { |
| 551 | ts_nr = atoi(argv[2]); |
| 552 | if (ts_nr >= TRX_NR_TS) { |
| 553 | vty_out(vty, "%% can't find TS %s%s", argv[2], |
| 554 | VTY_NEWLINE); |
| 555 | return CMD_WARNING; |
| 556 | } |
| 557 | ts = &trx->ts[ts_nr]; |
| 558 | } |
| 559 | if (argc >= 4) { |
| 560 | lchan_nr = atoi(argv[3]); |
| 561 | if (lchan_nr >= TS_MAX_LCHAN) { |
| 562 | vty_out(vty, "%% can't find LCHAN %s%s", argv[3], |
| 563 | VTY_NEWLINE); |
| 564 | return CMD_WARNING; |
| 565 | } |
| 566 | lchan = &ts->lchan[lchan_nr]; |
| 567 | lchan_dump_vty(vty, lchan); |
| 568 | return CMD_SUCCESS; |
| 569 | } |
| 570 | for (bts_nr = 0; bts_nr < net->num_bts; bts_nr++) { |
Harald Welte | e712a5f | 2009-06-21 16:17:15 +0200 | [diff] [blame] | 571 | bts = gsm_bts_num(net, bts_nr); |
Harald Welte | 59b0468 | 2009-06-10 05:40:52 +0800 | [diff] [blame] | 572 | for (trx_nr = 0; trx_nr < bts->num_trx; trx_nr++) { |
Harald Welte | e712a5f | 2009-06-21 16:17:15 +0200 | [diff] [blame] | 573 | trx = gsm_bts_trx_num(bts, trx_nr); |
Harald Welte | 59b0468 | 2009-06-10 05:40:52 +0800 | [diff] [blame] | 574 | for (ts_nr = 0; ts_nr < TRX_NR_TS; ts_nr++) { |
| 575 | ts = &trx->ts[ts_nr]; |
| 576 | for (lchan_nr = 0; lchan_nr < TS_MAX_LCHAN; |
| 577 | lchan_nr++) { |
| 578 | lchan = &ts->lchan[lchan_nr]; |
| 579 | if (lchan->type == GSM_LCHAN_NONE) |
| 580 | continue; |
| 581 | lchan_dump_vty(vty, lchan); |
| 582 | } |
| 583 | } |
| 584 | } |
| 585 | } |
| 586 | |
| 587 | return CMD_SUCCESS; |
| 588 | } |
| 589 | |
| 590 | static void e1drv_dump_vty(struct vty *vty, struct e1inp_driver *drv) |
| 591 | { |
| 592 | vty_out(vty, "E1 Input Driver %s%s", drv->name, VTY_NEWLINE); |
| 593 | } |
| 594 | |
| 595 | DEFUN(show_e1drv, |
| 596 | show_e1drv_cmd, |
| 597 | "show e1_driver", |
| 598 | SHOW_STR "Display information about available E1 drivers\n") |
| 599 | { |
| 600 | struct e1inp_driver *drv; |
| 601 | |
| 602 | llist_for_each_entry(drv, &e1inp_driver_list, list) |
| 603 | e1drv_dump_vty(vty, drv); |
| 604 | |
| 605 | return CMD_SUCCESS; |
| 606 | } |
| 607 | |
| 608 | static void e1line_dump_vty(struct vty *vty, struct e1inp_line *line) |
| 609 | { |
| 610 | vty_out(vty, "E1 Line Number %u, Name %s, Driver %s%s", |
| 611 | line->num, line->name ? line->name : "", |
| 612 | line->driver->name, VTY_NEWLINE); |
| 613 | } |
| 614 | |
| 615 | DEFUN(show_e1line, |
| 616 | show_e1line_cmd, |
| 617 | "show e1_line [line_nr]", |
| 618 | SHOW_STR "Display information about a E1 line\n") |
| 619 | { |
| 620 | struct e1inp_line *line; |
| 621 | |
| 622 | if (argc >= 1) { |
| 623 | int num = atoi(argv[0]); |
| 624 | llist_for_each_entry(line, &e1inp_line_list, list) { |
| 625 | if (line->num == num) { |
| 626 | e1line_dump_vty(vty, line); |
| 627 | return CMD_SUCCESS; |
| 628 | } |
| 629 | } |
| 630 | return CMD_WARNING; |
| 631 | } |
| 632 | |
| 633 | llist_for_each_entry(line, &e1inp_line_list, list) |
| 634 | e1line_dump_vty(vty, line); |
| 635 | |
| 636 | return CMD_SUCCESS; |
| 637 | } |
| 638 | |
| 639 | static void e1ts_dump_vty(struct vty *vty, struct e1inp_ts *ts) |
| 640 | { |
Harald Welte | 6286888 | 2009-08-08 16:12:58 +0200 | [diff] [blame] | 641 | if (ts->type == E1INP_TS_TYPE_NONE) |
| 642 | return; |
Harald Welte | 59b0468 | 2009-06-10 05:40:52 +0800 | [diff] [blame] | 643 | vty_out(vty, "E1 Timeslot %2u of Line %u is Type %s%s", |
| 644 | ts->num, ts->line->num, e1inp_tstype_name(ts->type), |
| 645 | VTY_NEWLINE); |
| 646 | } |
| 647 | |
| 648 | DEFUN(show_e1ts, |
| 649 | show_e1ts_cmd, |
| 650 | "show e1_timeslot [line_nr] [ts_nr]", |
| 651 | SHOW_STR "Display information about a E1 timeslot\n") |
| 652 | { |
Harald Welte | 49c7956 | 2009-11-17 06:12:16 +0100 | [diff] [blame] | 653 | struct e1inp_line *line = NULL; |
Harald Welte | 59b0468 | 2009-06-10 05:40:52 +0800 | [diff] [blame] | 654 | struct e1inp_ts *ts; |
| 655 | int ts_nr; |
| 656 | |
| 657 | if (argc == 0) { |
| 658 | llist_for_each_entry(line, &e1inp_line_list, list) { |
| 659 | for (ts_nr = 0; ts_nr < NUM_E1_TS; ts_nr++) { |
| 660 | ts = &line->ts[ts_nr]; |
| 661 | e1ts_dump_vty(vty, ts); |
| 662 | } |
| 663 | } |
| 664 | return CMD_SUCCESS; |
| 665 | } |
| 666 | if (argc >= 1) { |
| 667 | int num = atoi(argv[0]); |
| 668 | llist_for_each_entry(line, &e1inp_line_list, list) { |
| 669 | if (line->num == num) |
| 670 | break; |
| 671 | } |
| 672 | if (!line || line->num != num) { |
| 673 | vty_out(vty, "E1 line %s is invalid%s", |
| 674 | argv[0], VTY_NEWLINE); |
| 675 | return CMD_WARNING; |
| 676 | } |
| 677 | } |
| 678 | if (argc >= 2) { |
| 679 | ts_nr = atoi(argv[1]); |
| 680 | if (ts_nr > NUM_E1_TS) { |
| 681 | vty_out(vty, "E1 timeslot %s is invalid%s", |
| 682 | argv[1], VTY_NEWLINE); |
| 683 | return CMD_WARNING; |
| 684 | } |
| 685 | ts = &line->ts[ts_nr]; |
| 686 | e1ts_dump_vty(vty, ts); |
| 687 | return CMD_SUCCESS; |
| 688 | } else { |
| 689 | for (ts_nr = 0; ts_nr < NUM_E1_TS; ts_nr++) { |
| 690 | ts = &line->ts[ts_nr]; |
| 691 | e1ts_dump_vty(vty, ts); |
| 692 | } |
| 693 | return CMD_SUCCESS; |
| 694 | } |
| 695 | return CMD_SUCCESS; |
| 696 | } |
| 697 | |
| 698 | static void paging_dump_vty(struct vty *vty, struct gsm_paging_request *pag) |
| 699 | { |
| 700 | vty_out(vty, "Paging on BTS %u%s", pag->bts->nr, VTY_NEWLINE); |
| 701 | subscr_dump_vty(vty, pag->subscr); |
| 702 | } |
| 703 | |
| 704 | static void bts_paging_dump_vty(struct vty *vty, struct gsm_bts *bts) |
| 705 | { |
| 706 | struct gsm_paging_request *pag; |
| 707 | |
| 708 | llist_for_each_entry(pag, &bts->paging.pending_requests, entry) |
| 709 | paging_dump_vty(vty, pag); |
| 710 | } |
| 711 | |
| 712 | DEFUN(show_paging, |
| 713 | show_paging_cmd, |
| 714 | "show paging [bts_nr]", |
| 715 | SHOW_STR "Display information about paging reuqests of a BTS\n") |
| 716 | { |
| 717 | struct gsm_network *net = gsmnet; |
| 718 | struct gsm_bts *bts; |
| 719 | int bts_nr; |
| 720 | |
| 721 | if (argc >= 1) { |
| 722 | /* use the BTS number that the user has specified */ |
| 723 | bts_nr = atoi(argv[0]); |
| 724 | if (bts_nr >= net->num_bts) { |
| 725 | vty_out(vty, "%% can't find BTS %s%s", argv[0], |
| 726 | VTY_NEWLINE); |
| 727 | return CMD_WARNING; |
| 728 | } |
Harald Welte | e712a5f | 2009-06-21 16:17:15 +0200 | [diff] [blame] | 729 | bts = gsm_bts_num(net, bts_nr); |
Harald Welte | 59b0468 | 2009-06-10 05:40:52 +0800 | [diff] [blame] | 730 | bts_paging_dump_vty(vty, bts); |
| 731 | |
| 732 | return CMD_SUCCESS; |
| 733 | } |
| 734 | for (bts_nr = 0; bts_nr < net->num_bts; bts_nr++) { |
Harald Welte | e712a5f | 2009-06-21 16:17:15 +0200 | [diff] [blame] | 735 | bts = gsm_bts_num(net, bts_nr); |
Harald Welte | 59b0468 | 2009-06-10 05:40:52 +0800 | [diff] [blame] | 736 | bts_paging_dump_vty(vty, bts); |
| 737 | } |
| 738 | |
| 739 | return CMD_SUCCESS; |
| 740 | } |
| 741 | |
Harald Welte | e87eb46 | 2009-08-07 13:29:14 +0200 | [diff] [blame] | 742 | DEFUN(cfg_net, |
| 743 | cfg_net_cmd, |
| 744 | "network", |
| 745 | "Configure the GSM network") |
| 746 | { |
| 747 | vty->index = gsmnet; |
| 748 | vty->node = GSMNET_NODE; |
| 749 | |
| 750 | return CMD_SUCCESS; |
| 751 | } |
| 752 | |
| 753 | |
| 754 | DEFUN(cfg_net_ncc, |
| 755 | cfg_net_ncc_cmd, |
| 756 | "network country code <1-999>", |
| 757 | "Set the GSM network country code") |
| 758 | { |
| 759 | gsmnet->country_code = atoi(argv[0]); |
| 760 | |
| 761 | return CMD_SUCCESS; |
| 762 | } |
| 763 | |
| 764 | DEFUN(cfg_net_mnc, |
| 765 | cfg_net_mnc_cmd, |
| 766 | "mobile network code <1-999>", |
| 767 | "Set the GSM mobile network code") |
| 768 | { |
| 769 | gsmnet->network_code = atoi(argv[0]); |
| 770 | |
| 771 | return CMD_SUCCESS; |
| 772 | } |
| 773 | |
| 774 | DEFUN(cfg_net_name_short, |
| 775 | cfg_net_name_short_cmd, |
| 776 | "short name NAME", |
| 777 | "Set the short GSM network name") |
| 778 | { |
| 779 | if (gsmnet->name_short) |
| 780 | talloc_free(gsmnet->name_short); |
| 781 | |
| 782 | gsmnet->name_short = talloc_strdup(gsmnet, argv[0]); |
| 783 | |
| 784 | return CMD_SUCCESS; |
| 785 | } |
| 786 | |
| 787 | DEFUN(cfg_net_name_long, |
| 788 | cfg_net_name_long_cmd, |
| 789 | "long name NAME", |
| 790 | "Set the long GSM network name") |
| 791 | { |
| 792 | if (gsmnet->name_long) |
| 793 | talloc_free(gsmnet->name_long); |
| 794 | |
| 795 | gsmnet->name_long = talloc_strdup(gsmnet, argv[0]); |
| 796 | |
| 797 | return CMD_SUCCESS; |
| 798 | } |
Harald Welte | 59b0468 | 2009-06-10 05:40:52 +0800 | [diff] [blame] | 799 | |
Harald Welte (local) | a59a27e | 2009-08-12 14:42:23 +0200 | [diff] [blame] | 800 | DEFUN(cfg_net_auth_policy, |
| 801 | cfg_net_auth_policy_cmd, |
| 802 | "auth policy (closed|accept-all|token)", |
| 803 | "Set the GSM network authentication policy\n") |
| 804 | { |
| 805 | enum gsm_auth_policy policy = gsm_auth_policy_parse(argv[0]); |
| 806 | |
| 807 | gsmnet->auth_policy = policy; |
| 808 | |
| 809 | return CMD_SUCCESS; |
| 810 | } |
| 811 | |
Harald Welte | 59936d7 | 2009-11-18 20:33:19 +0100 | [diff] [blame] | 812 | DEFUN(cfg_net_reject_cause, |
| 813 | cfg_net_reject_cause_cmd, |
| 814 | "location updating reject cause <2-111>", |
| 815 | "Set the reject cause of location updating reject\n") |
| 816 | { |
| 817 | gsmnet->reject_cause = atoi(argv[0]); |
| 818 | |
| 819 | return CMD_SUCCESS; |
| 820 | } |
| 821 | |
Harald Welte | cca253a | 2009-08-30 15:47:06 +0900 | [diff] [blame] | 822 | DEFUN(cfg_net_encryption, |
| 823 | cfg_net_encryption_cmd, |
| 824 | "encryption a5 (0|1|2)", |
| 825 | "Enable or disable encryption (A5) for this network\n") |
| 826 | { |
Andreas.Eversberg | 5329329 | 2009-11-17 09:55:26 +0100 | [diff] [blame] | 827 | gsmnet->a5_encryption= atoi(argv[0]); |
Harald Welte | cca253a | 2009-08-30 15:47:06 +0900 | [diff] [blame] | 828 | |
| 829 | return CMD_SUCCESS; |
| 830 | } |
| 831 | |
Holger Hans Peter Freyther | 96c8982 | 2009-11-16 17:12:38 +0100 | [diff] [blame] | 832 | DEFUN(cfg_net_neci, |
| 833 | cfg_net_neci_cmd, |
| 834 | "neci (0|1)", |
| 835 | "Set if NECI of cell selection is to be set") |
| 836 | { |
| 837 | gsmnet->neci = atoi(argv[0]); |
| 838 | return CMD_SUCCESS; |
| 839 | } |
| 840 | |
Holger Hans Peter Freyther | 26ba2e7 | 2009-11-21 21:18:38 +0100 | [diff] [blame] | 841 | #define DECLARE_TIMER(number) \ |
| 842 | DEFUN(cfg_net_T##number, \ |
| 843 | cfg_net_T##number##_cmd, \ |
| 844 | "timer t" #number " <0-65535>", \ |
| 845 | "Set the T" #number " value.") \ |
| 846 | { \ |
| 847 | int value = atoi(argv[0]); \ |
| 848 | \ |
| 849 | if (value < 0 || value > 65535) { \ |
| 850 | vty_out(vty, "Timer value %s out of range.%s", \ |
| 851 | argv[0], VTY_NEWLINE); \ |
| 852 | return CMD_WARNING; \ |
| 853 | } \ |
| 854 | \ |
| 855 | gsmnet->T##number = value; \ |
| 856 | return CMD_SUCCESS; \ |
| 857 | } |
| 858 | |
| 859 | DECLARE_TIMER(3101) |
Holger Hans Peter Freyther | 8973386 | 2009-11-21 21:42:26 +0100 | [diff] [blame] | 860 | DECLARE_TIMER(3103) |
| 861 | DECLARE_TIMER(3105) |
| 862 | DECLARE_TIMER(3107) |
| 863 | DECLARE_TIMER(3109) |
| 864 | DECLARE_TIMER(3111) |
| 865 | DECLARE_TIMER(3113) |
| 866 | DECLARE_TIMER(3115) |
| 867 | DECLARE_TIMER(3117) |
| 868 | DECLARE_TIMER(3119) |
| 869 | DECLARE_TIMER(3141) |
Holger Hans Peter Freyther | 26ba2e7 | 2009-11-21 21:18:38 +0100 | [diff] [blame] | 870 | |
| 871 | |
Harald Welte | 59b0468 | 2009-06-10 05:40:52 +0800 | [diff] [blame] | 872 | /* per-BTS configuration */ |
| 873 | DEFUN(cfg_bts, |
| 874 | cfg_bts_cmd, |
| 875 | "bts BTS_NR", |
| 876 | "Select a BTS to configure\n") |
| 877 | { |
| 878 | int bts_nr = atoi(argv[0]); |
| 879 | struct gsm_bts *bts; |
| 880 | |
Harald Welte | e712a5f | 2009-06-21 16:17:15 +0200 | [diff] [blame] | 881 | if (bts_nr > gsmnet->num_bts) { |
| 882 | vty_out(vty, "%% The next unused BTS number is %u%s", |
| 883 | gsmnet->num_bts, VTY_NEWLINE); |
Harald Welte | 59b0468 | 2009-06-10 05:40:52 +0800 | [diff] [blame] | 884 | return CMD_WARNING; |
Harald Welte | e712a5f | 2009-06-21 16:17:15 +0200 | [diff] [blame] | 885 | } else if (bts_nr == gsmnet->num_bts) { |
| 886 | /* allocate a new one */ |
| 887 | bts = gsm_bts_alloc(gsmnet, GSM_BTS_TYPE_UNKNOWN, |
| 888 | HARDCODED_TSC, HARDCODED_BSIC); |
| 889 | } else |
| 890 | bts = gsm_bts_num(gsmnet, bts_nr); |
| 891 | |
| 892 | if (!bts) |
| 893 | return CMD_WARNING; |
Harald Welte | 59b0468 | 2009-06-10 05:40:52 +0800 | [diff] [blame] | 894 | |
| 895 | vty->index = bts; |
| 896 | vty->node = BTS_NODE; |
| 897 | |
| 898 | return CMD_SUCCESS; |
| 899 | } |
| 900 | |
| 901 | DEFUN(cfg_bts_type, |
| 902 | cfg_bts_type_cmd, |
| 903 | "type TYPE", |
| 904 | "Set the BTS type\n") |
| 905 | { |
| 906 | struct gsm_bts *bts = vty->index; |
| 907 | |
Harald Welte | 3ffe1b3 | 2009-08-07 00:25:23 +0200 | [diff] [blame] | 908 | bts->type = parse_btstype(argv[0]); |
| 909 | |
Harald Welte | 2557287 | 2009-10-20 00:22:00 +0200 | [diff] [blame] | 910 | if (is_ipaccess_bts(bts)) { |
| 911 | /* Set the default OML Stream ID to 0xff */ |
| 912 | bts->oml_tei = 0xff; |
| 913 | } |
| 914 | |
Harald Welte | 59b0468 | 2009-06-10 05:40:52 +0800 | [diff] [blame] | 915 | return CMD_SUCCESS; |
| 916 | } |
| 917 | |
Harald Welte | 91afe4c | 2009-06-20 18:15:19 +0200 | [diff] [blame] | 918 | DEFUN(cfg_bts_band, |
| 919 | cfg_bts_band_cmd, |
| 920 | "band BAND", |
| 921 | "Set the frequency band of this BTS\n") |
| 922 | { |
| 923 | struct gsm_bts *bts = vty->index; |
Harald Welte | 6286888 | 2009-08-08 16:12:58 +0200 | [diff] [blame] | 924 | int band = gsm_band_parse(argv[0]); |
Harald Welte | 91afe4c | 2009-06-20 18:15:19 +0200 | [diff] [blame] | 925 | |
| 926 | if (band < 0) { |
| 927 | vty_out(vty, "%% BAND %d is not a valid GSM band%s", |
| 928 | band, VTY_NEWLINE); |
| 929 | return CMD_WARNING; |
| 930 | } |
| 931 | |
| 932 | bts->band = band; |
| 933 | |
| 934 | return CMD_SUCCESS; |
| 935 | } |
| 936 | |
Holger Hans Peter Freyther | a098dfb | 2009-08-21 14:44:12 +0200 | [diff] [blame] | 937 | DEFUN(cfg_bts_ci, |
| 938 | cfg_bts_ci_cmd, |
| 939 | "cell_identity <0-65535>", |
| 940 | "Set the Cell identity of this BTS\n") |
| 941 | { |
| 942 | struct gsm_bts *bts = vty->index; |
| 943 | int ci = atoi(argv[0]); |
| 944 | |
| 945 | if (ci < 0 || ci > 0xffff) { |
| 946 | vty_out(vty, "%% CI %d is not in the valid range (0-65535)%s", |
| 947 | ci, VTY_NEWLINE); |
| 948 | return CMD_WARNING; |
| 949 | } |
| 950 | bts->cell_identity = ci; |
| 951 | |
| 952 | return CMD_SUCCESS; |
| 953 | } |
| 954 | |
Harald Welte | 59b0468 | 2009-06-10 05:40:52 +0800 | [diff] [blame] | 955 | DEFUN(cfg_bts_lac, |
| 956 | cfg_bts_lac_cmd, |
Holger Hans Peter Freyther | 54a2283 | 2009-09-29 14:02:33 +0200 | [diff] [blame] | 957 | "location_area_code <0-65535>", |
Harald Welte | 59b0468 | 2009-06-10 05:40:52 +0800 | [diff] [blame] | 958 | "Set the Location Area Code (LAC) of this BTS\n") |
| 959 | { |
| 960 | struct gsm_bts *bts = vty->index; |
| 961 | int lac = atoi(argv[0]); |
| 962 | |
Holger Hans Peter Freyther | 54a2283 | 2009-09-29 14:02:33 +0200 | [diff] [blame] | 963 | if (lac < 0 || lac > 0xffff) { |
| 964 | vty_out(vty, "%% LAC %d is not in the valid range (0-65535)%s", |
Harald Welte | 59b0468 | 2009-06-10 05:40:52 +0800 | [diff] [blame] | 965 | lac, VTY_NEWLINE); |
| 966 | return CMD_WARNING; |
| 967 | } |
Holger Hans Peter Freyther | 6c6ab86 | 2009-10-01 04:07:15 +0200 | [diff] [blame] | 968 | |
| 969 | if (lac == GSM_LAC_RESERVED_DETACHED || lac == GSM_LAC_RESERVED_ALL_BTS) { |
| 970 | vty_out(vty, "%% LAC %d is reserved by GSM 04.08%s", |
| 971 | lac, VTY_NEWLINE); |
| 972 | return CMD_WARNING; |
| 973 | } |
| 974 | |
Harald Welte | 59b0468 | 2009-06-10 05:40:52 +0800 | [diff] [blame] | 975 | bts->location_area_code = lac; |
| 976 | |
| 977 | return CMD_SUCCESS; |
| 978 | } |
| 979 | |
Harald Welte | a54a2bb | 2009-12-01 18:04:30 +0530 | [diff] [blame] | 980 | |
Harald Welte | 59b0468 | 2009-06-10 05:40:52 +0800 | [diff] [blame] | 981 | DEFUN(cfg_bts_tsc, |
| 982 | cfg_bts_tsc_cmd, |
| 983 | "training_sequence_code <0-255>", |
| 984 | "Set the Training Sequence Code (TSC) of this BTS\n") |
| 985 | { |
| 986 | struct gsm_bts *bts = vty->index; |
| 987 | int tsc = atoi(argv[0]); |
| 988 | |
| 989 | if (tsc < 0 || tsc > 0xff) { |
| 990 | vty_out(vty, "%% TSC %d is not in the valid range (0-255)%s", |
| 991 | tsc, VTY_NEWLINE); |
| 992 | return CMD_WARNING; |
| 993 | } |
| 994 | bts->tsc = tsc; |
| 995 | |
| 996 | return CMD_SUCCESS; |
| 997 | } |
| 998 | |
| 999 | DEFUN(cfg_bts_bsic, |
| 1000 | cfg_bts_bsic_cmd, |
| 1001 | "base_station_id_code <0-63>", |
| 1002 | "Set the Base Station Identity Code (BSIC) of this BTS\n") |
| 1003 | { |
| 1004 | struct gsm_bts *bts = vty->index; |
| 1005 | int bsic = atoi(argv[0]); |
| 1006 | |
| 1007 | if (bsic < 0 || bsic > 0x3f) { |
Harald Welte | 6286888 | 2009-08-08 16:12:58 +0200 | [diff] [blame] | 1008 | vty_out(vty, "%% BSIC %d is not in the valid range (0-255)%s", |
Harald Welte | 59b0468 | 2009-06-10 05:40:52 +0800 | [diff] [blame] | 1009 | bsic, VTY_NEWLINE); |
| 1010 | return CMD_WARNING; |
| 1011 | } |
| 1012 | bts->bsic = bsic; |
| 1013 | |
| 1014 | return CMD_SUCCESS; |
| 1015 | } |
| 1016 | |
| 1017 | |
| 1018 | DEFUN(cfg_bts_unit_id, |
| 1019 | cfg_bts_unit_id_cmd, |
Harald Welte | f515aa0 | 2009-08-07 13:27:09 +0200 | [diff] [blame] | 1020 | "ip.access unit_id <0-65534> <0-255>", |
| 1021 | "Set the ip.access BTS Unit ID of this BTS\n") |
Harald Welte | 59b0468 | 2009-06-10 05:40:52 +0800 | [diff] [blame] | 1022 | { |
| 1023 | struct gsm_bts *bts = vty->index; |
| 1024 | int site_id = atoi(argv[0]); |
| 1025 | int bts_id = atoi(argv[1]); |
| 1026 | |
Harald Welte | f515aa0 | 2009-08-07 13:27:09 +0200 | [diff] [blame] | 1027 | if (!is_ipaccess_bts(bts)) { |
| 1028 | vty_out(vty, "%% BTS is not of ip.access type%s", VTY_NEWLINE); |
| 1029 | return CMD_WARNING; |
| 1030 | } |
| 1031 | |
Harald Welte | 59b0468 | 2009-06-10 05:40:52 +0800 | [diff] [blame] | 1032 | bts->ip_access.site_id = site_id; |
| 1033 | bts->ip_access.bts_id = bts_id; |
| 1034 | |
| 1035 | return CMD_SUCCESS; |
| 1036 | } |
| 1037 | |
Harald Welte | 2557287 | 2009-10-20 00:22:00 +0200 | [diff] [blame] | 1038 | DEFUN(cfg_bts_stream_id, |
| 1039 | cfg_bts_stream_id_cmd, |
| 1040 | "oml ip.access stream_id <0-255>", |
| 1041 | "Set the ip.access Stream ID of the OML link of this BTS\n") |
| 1042 | { |
| 1043 | struct gsm_bts *bts = vty->index; |
| 1044 | int stream_id = atoi(argv[0]); |
| 1045 | |
| 1046 | if (!is_ipaccess_bts(bts)) { |
| 1047 | vty_out(vty, "%% BTS is not of ip.access type%s", VTY_NEWLINE); |
| 1048 | return CMD_WARNING; |
| 1049 | } |
| 1050 | |
| 1051 | bts->oml_tei = stream_id; |
| 1052 | |
| 1053 | return CMD_SUCCESS; |
| 1054 | } |
| 1055 | |
| 1056 | |
Harald Welte | 6286888 | 2009-08-08 16:12:58 +0200 | [diff] [blame] | 1057 | DEFUN(cfg_bts_oml_e1, |
| 1058 | cfg_bts_oml_e1_cmd, |
| 1059 | "oml e1 line E1_LINE timeslot <1-31> sub-slot (0|1|2|3|full)", |
| 1060 | "E1 interface to be used for OML\n") |
| 1061 | { |
| 1062 | struct gsm_bts *bts = vty->index; |
| 1063 | |
| 1064 | parse_e1_link(&bts->oml_e1_link, argv[0], argv[1], argv[2]); |
| 1065 | |
| 1066 | return CMD_SUCCESS; |
| 1067 | } |
| 1068 | |
| 1069 | |
| 1070 | DEFUN(cfg_bts_oml_e1_tei, |
| 1071 | cfg_bts_oml_e1_tei_cmd, |
| 1072 | "oml e1 tei <0-63>", |
| 1073 | "Set the TEI to be used for OML") |
| 1074 | { |
| 1075 | struct gsm_bts *bts = vty->index; |
| 1076 | |
| 1077 | bts->oml_tei = atoi(argv[0]); |
| 1078 | |
| 1079 | return CMD_SUCCESS; |
| 1080 | } |
| 1081 | |
Harald Welte | 3e77461 | 2009-08-10 13:48:16 +0200 | [diff] [blame] | 1082 | DEFUN(cfg_bts_challoc, cfg_bts_challoc_cmd, |
| 1083 | "channel allocator (ascending|descending)", |
| 1084 | "Should the channel allocator allocate in reverse TRX order?") |
| 1085 | { |
| 1086 | struct gsm_bts *bts = vty->index; |
| 1087 | |
| 1088 | if (!strcmp(argv[0], "ascending")) |
| 1089 | bts->chan_alloc_reverse = 0; |
| 1090 | else |
| 1091 | bts->chan_alloc_reverse = 1; |
| 1092 | |
| 1093 | return CMD_SUCCESS; |
| 1094 | } |
| 1095 | |
Harald Welte (local) | e19be3f | 2009-08-12 13:28:23 +0200 | [diff] [blame] | 1096 | DEFUN(cfg_bts_cell_barred, cfg_bts_cell_barred_cmd, |
| 1097 | "cell barred (0|1)", |
| 1098 | "Should this cell be barred from access?") |
| 1099 | { |
| 1100 | struct gsm_bts *bts = vty->index; |
| 1101 | |
| 1102 | bts->cell_barred = atoi(argv[0]); |
| 1103 | |
| 1104 | return CMD_SUCCESS; |
| 1105 | } |
| 1106 | |
Harald Welte (local) | cbd4610 | 2009-08-13 10:14:26 +0200 | [diff] [blame] | 1107 | DEFUN(cfg_bts_ms_max_power, cfg_bts_ms_max_power_cmd, |
| 1108 | "ms max power <0-40>", |
| 1109 | "Maximum transmit power of the MS") |
| 1110 | { |
| 1111 | struct gsm_bts *bts = vty->index; |
| 1112 | |
| 1113 | bts->ms_max_power = atoi(argv[0]); |
| 1114 | |
| 1115 | return CMD_SUCCESS; |
| 1116 | } |
| 1117 | |
Harald Welte | b761bf8 | 2009-12-12 18:17:25 +0100 | [diff] [blame] | 1118 | DEFUN(cfg_bts_cell_resel_hyst, cfg_bts_cell_resel_hyst_cmd, |
| 1119 | "cell reselection hysteresis <0-14>", |
| 1120 | "Cell Re-Selection Hysteresis in dB") |
| 1121 | { |
| 1122 | struct gsm_bts *bts = vty->index; |
| 1123 | |
| 1124 | bts->si_common.cell_sel_par.cell_resel_hyst = atoi(argv[0])/2; |
| 1125 | |
| 1126 | return CMD_SUCCESS; |
| 1127 | } |
| 1128 | |
| 1129 | DEFUN(cfg_bts_rxlev_acc_min, cfg_bts_rxlev_acc_min_cmd, |
| 1130 | "rxlev access min <0-63>", |
| 1131 | "Minimum RxLev needed for cell access (better than -110dBm)") |
| 1132 | { |
| 1133 | struct gsm_bts *bts = vty->index; |
| 1134 | |
| 1135 | bts->si_common.cell_sel_par.rxlev_acc_min = atoi(argv[0]); |
| 1136 | |
| 1137 | return CMD_SUCCESS; |
| 1138 | } |
| 1139 | |
Harald Welte (local) | b6ea7f7 | 2009-08-14 23:09:25 +0200 | [diff] [blame] | 1140 | DEFUN(cfg_bts_per_loc_upd, cfg_bts_per_loc_upd_cmd, |
| 1141 | "periodic location update <0-1530>", |
| 1142 | "Periodic Location Updating Interval in Minutes") |
| 1143 | { |
| 1144 | struct gsm_bts *bts = vty->index; |
| 1145 | |
Harald Welte | a54a2bb | 2009-12-01 18:04:30 +0530 | [diff] [blame] | 1146 | bts->si_common.chan_desc.t3212 = atoi(argv[0]) / 10; |
Harald Welte (local) | b6ea7f7 | 2009-08-14 23:09:25 +0200 | [diff] [blame] | 1147 | |
| 1148 | return CMD_SUCCESS; |
| 1149 | } |
| 1150 | |
Harald Welte | 3e77461 | 2009-08-10 13:48:16 +0200 | [diff] [blame] | 1151 | |
Harald Welte | 59b0468 | 2009-06-10 05:40:52 +0800 | [diff] [blame] | 1152 | /* per TRX configuration */ |
| 1153 | DEFUN(cfg_trx, |
| 1154 | cfg_trx_cmd, |
| 1155 | "trx TRX_NR", |
| 1156 | "Select a TRX to configure") |
| 1157 | { |
| 1158 | int trx_nr = atoi(argv[0]); |
| 1159 | struct gsm_bts *bts = vty->index; |
| 1160 | struct gsm_bts_trx *trx; |
| 1161 | |
Harald Welte | e712a5f | 2009-06-21 16:17:15 +0200 | [diff] [blame] | 1162 | if (trx_nr > bts->num_trx) { |
| 1163 | vty_out(vty, "%% The next unused TRX number in this BTS is %u%s", |
| 1164 | bts->num_trx, VTY_NEWLINE); |
Harald Welte | 59b0468 | 2009-06-10 05:40:52 +0800 | [diff] [blame] | 1165 | return CMD_WARNING; |
Harald Welte | e712a5f | 2009-06-21 16:17:15 +0200 | [diff] [blame] | 1166 | } else if (trx_nr == bts->num_trx) { |
| 1167 | /* we need to allocate a new one */ |
| 1168 | trx = gsm_bts_trx_alloc(bts); |
| 1169 | } else |
| 1170 | trx = gsm_bts_trx_num(bts, trx_nr); |
| 1171 | |
| 1172 | if (!trx) |
| 1173 | return CMD_WARNING; |
Harald Welte | 59b0468 | 2009-06-10 05:40:52 +0800 | [diff] [blame] | 1174 | |
| 1175 | vty->index = trx; |
| 1176 | vty->node = TRX_NODE; |
| 1177 | |
| 1178 | return CMD_SUCCESS; |
| 1179 | } |
| 1180 | |
| 1181 | DEFUN(cfg_trx_arfcn, |
| 1182 | cfg_trx_arfcn_cmd, |
| 1183 | "arfcn <1-1024>", |
| 1184 | "Set the ARFCN for this TRX\n") |
| 1185 | { |
| 1186 | int arfcn = atoi(argv[0]); |
| 1187 | struct gsm_bts_trx *trx = vty->index; |
| 1188 | |
| 1189 | /* FIXME: check if this ARFCN is supported by this TRX */ |
| 1190 | |
| 1191 | trx->arfcn = arfcn; |
| 1192 | |
| 1193 | /* FIXME: patch ARFCN into SYSTEM INFORMATION */ |
| 1194 | /* FIXME: use OML layer to update the ARFCN */ |
| 1195 | /* FIXME: use RSL layer to update SYSTEM INFORMATION */ |
| 1196 | |
| 1197 | return CMD_SUCCESS; |
| 1198 | } |
| 1199 | |
Harald Welte | 91afe4c | 2009-06-20 18:15:19 +0200 | [diff] [blame] | 1200 | DEFUN(cfg_trx_max_power_red, |
| 1201 | cfg_trx_max_power_red_cmd, |
| 1202 | "max_power_red <0-100>", |
| 1203 | "Reduction of maximum BS RF Power in dB\n") |
| 1204 | { |
| 1205 | int maxpwr_r = atoi(argv[0]); |
| 1206 | struct gsm_bts_trx *trx = vty->index; |
Harald Welte | 01acd74 | 2009-11-18 09:20:22 +0100 | [diff] [blame] | 1207 | int upper_limit = 24; /* default 12.21 max power red. */ |
Harald Welte | 91afe4c | 2009-06-20 18:15:19 +0200 | [diff] [blame] | 1208 | |
| 1209 | /* FIXME: check if our BTS type supports more than 12 */ |
| 1210 | if (maxpwr_r < 0 || maxpwr_r > upper_limit) { |
| 1211 | vty_out(vty, "%% Power %d dB is not in the valid range%s", |
| 1212 | maxpwr_r, VTY_NEWLINE); |
| 1213 | return CMD_WARNING; |
| 1214 | } |
| 1215 | if (maxpwr_r & 1) { |
| 1216 | vty_out(vty, "%% Power %d dB is not an even value%s", |
| 1217 | maxpwr_r, VTY_NEWLINE); |
| 1218 | return CMD_WARNING; |
| 1219 | } |
| 1220 | |
| 1221 | trx->max_power_red = maxpwr_r; |
| 1222 | |
| 1223 | /* FIXME: make sure we update this using OML */ |
| 1224 | |
| 1225 | return CMD_SUCCESS; |
| 1226 | } |
| 1227 | |
Harald Welte | 6286888 | 2009-08-08 16:12:58 +0200 | [diff] [blame] | 1228 | DEFUN(cfg_trx_rsl_e1, |
| 1229 | cfg_trx_rsl_e1_cmd, |
| 1230 | "rsl e1 line E1_LINE timeslot <1-31> sub-slot (0|1|2|3|full)", |
| 1231 | "E1 interface to be used for RSL\n") |
| 1232 | { |
| 1233 | struct gsm_bts_trx *trx = vty->index; |
| 1234 | |
| 1235 | parse_e1_link(&trx->rsl_e1_link, argv[0], argv[1], argv[2]); |
| 1236 | |
| 1237 | return CMD_SUCCESS; |
| 1238 | } |
| 1239 | |
| 1240 | DEFUN(cfg_trx_rsl_e1_tei, |
| 1241 | cfg_trx_rsl_e1_tei_cmd, |
| 1242 | "rsl e1 tei <0-63>", |
| 1243 | "Set the TEI to be used for RSL") |
| 1244 | { |
| 1245 | struct gsm_bts_trx *trx = vty->index; |
| 1246 | |
| 1247 | trx->rsl_tei = atoi(argv[0]); |
| 1248 | |
| 1249 | return CMD_SUCCESS; |
| 1250 | } |
| 1251 | |
Holger Hans Peter Freyther | 1c8b480 | 2009-11-11 11:54:24 +0100 | [diff] [blame] | 1252 | DEFUN(cfg_trx_rf_locked, |
| 1253 | cfg_trx_rf_locked_cmd, |
| 1254 | "rf_locked (0|1)", |
| 1255 | "Turn off RF of the TRX.\n") |
| 1256 | { |
| 1257 | int locked = atoi(argv[0]); |
| 1258 | struct gsm_bts_trx *trx = vty->index; |
| 1259 | |
| 1260 | gsm_trx_lock_rf(trx, locked); |
| 1261 | return CMD_SUCCESS; |
| 1262 | } |
Harald Welte | 6286888 | 2009-08-08 16:12:58 +0200 | [diff] [blame] | 1263 | |
Harald Welte | 59b0468 | 2009-06-10 05:40:52 +0800 | [diff] [blame] | 1264 | /* per TS configuration */ |
| 1265 | DEFUN(cfg_ts, |
| 1266 | cfg_ts_cmd, |
Harald Welte | 6286888 | 2009-08-08 16:12:58 +0200 | [diff] [blame] | 1267 | "timeslot <0-7>", |
Harald Welte | 59b0468 | 2009-06-10 05:40:52 +0800 | [diff] [blame] | 1268 | "Select a Timeslot to configure") |
| 1269 | { |
| 1270 | int ts_nr = atoi(argv[0]); |
| 1271 | struct gsm_bts_trx *trx = vty->index; |
| 1272 | struct gsm_bts_trx_ts *ts; |
| 1273 | |
| 1274 | if (ts_nr >= TRX_NR_TS) { |
| 1275 | vty_out(vty, "%% A GSM TRX only has %u Timeslots per TRX%s", |
| 1276 | TRX_NR_TS, VTY_NEWLINE); |
| 1277 | return CMD_WARNING; |
| 1278 | } |
| 1279 | |
| 1280 | ts = &trx->ts[ts_nr]; |
| 1281 | |
| 1282 | vty->index = ts; |
| 1283 | vty->node = TS_NODE; |
| 1284 | |
| 1285 | return CMD_SUCCESS; |
| 1286 | } |
| 1287 | |
Harald Welte | 3ffe1b3 | 2009-08-07 00:25:23 +0200 | [diff] [blame] | 1288 | DEFUN(cfg_ts_pchan, |
| 1289 | cfg_ts_pchan_cmd, |
| 1290 | "phys_chan_config PCHAN", |
| 1291 | "Physical Channel configuration (TCH/SDCCH/...)") |
| 1292 | { |
| 1293 | struct gsm_bts_trx_ts *ts = vty->index; |
| 1294 | int pchanc; |
| 1295 | |
| 1296 | pchanc = gsm_pchan_parse(argv[0]); |
| 1297 | if (pchanc < 0) |
| 1298 | return CMD_WARNING; |
| 1299 | |
| 1300 | ts->pchan = pchanc; |
| 1301 | |
| 1302 | return CMD_SUCCESS; |
| 1303 | } |
| 1304 | |
| 1305 | DEFUN(cfg_ts_e1_subslot, |
| 1306 | cfg_ts_e1_subslot_cmd, |
Harald Welte | 6286888 | 2009-08-08 16:12:58 +0200 | [diff] [blame] | 1307 | "e1 line E1_LINE timeslot <1-31> sub-slot (0|1|2|3|full)", |
Harald Welte | 3ffe1b3 | 2009-08-07 00:25:23 +0200 | [diff] [blame] | 1308 | "E1 sub-slot connected to this on-air timeslot") |
| 1309 | { |
| 1310 | struct gsm_bts_trx_ts *ts = vty->index; |
| 1311 | |
Harald Welte | 6286888 | 2009-08-08 16:12:58 +0200 | [diff] [blame] | 1312 | parse_e1_link(&ts->e1_link, argv[0], argv[1], argv[2]); |
Harald Welte | 3ffe1b3 | 2009-08-07 00:25:23 +0200 | [diff] [blame] | 1313 | |
| 1314 | return CMD_SUCCESS; |
| 1315 | } |
Harald Welte | 59b0468 | 2009-06-10 05:40:52 +0800 | [diff] [blame] | 1316 | |
Harald Welte | 59b0468 | 2009-06-10 05:40:52 +0800 | [diff] [blame] | 1317 | int bsc_vty_init(struct gsm_network *net) |
| 1318 | { |
| 1319 | gsmnet = net; |
| 1320 | |
| 1321 | cmd_init(1); |
| 1322 | vty_init(); |
| 1323 | |
| 1324 | install_element(VIEW_NODE, &show_net_cmd); |
| 1325 | install_element(VIEW_NODE, &show_bts_cmd); |
| 1326 | install_element(VIEW_NODE, &show_trx_cmd); |
| 1327 | install_element(VIEW_NODE, &show_ts_cmd); |
| 1328 | install_element(VIEW_NODE, &show_lchan_cmd); |
| 1329 | |
| 1330 | install_element(VIEW_NODE, &show_e1drv_cmd); |
| 1331 | install_element(VIEW_NODE, &show_e1line_cmd); |
| 1332 | install_element(VIEW_NODE, &show_e1ts_cmd); |
| 1333 | |
| 1334 | install_element(VIEW_NODE, &show_paging_cmd); |
| 1335 | |
Harald Welte | e87eb46 | 2009-08-07 13:29:14 +0200 | [diff] [blame] | 1336 | install_element(CONFIG_NODE, &cfg_net_cmd); |
| 1337 | install_node(&net_node, config_write_net); |
| 1338 | install_default(GSMNET_NODE); |
Harald Welte | 6286888 | 2009-08-08 16:12:58 +0200 | [diff] [blame] | 1339 | install_element(GSMNET_NODE, &cfg_net_ncc_cmd); |
Harald Welte | e87eb46 | 2009-08-07 13:29:14 +0200 | [diff] [blame] | 1340 | install_element(GSMNET_NODE, &cfg_net_mnc_cmd); |
| 1341 | install_element(GSMNET_NODE, &cfg_net_name_short_cmd); |
| 1342 | install_element(GSMNET_NODE, &cfg_net_name_long_cmd); |
Harald Welte (local) | a59a27e | 2009-08-12 14:42:23 +0200 | [diff] [blame] | 1343 | install_element(GSMNET_NODE, &cfg_net_auth_policy_cmd); |
Harald Welte | 59936d7 | 2009-11-18 20:33:19 +0100 | [diff] [blame] | 1344 | install_element(GSMNET_NODE, &cfg_net_reject_cause_cmd); |
Harald Welte | cca253a | 2009-08-30 15:47:06 +0900 | [diff] [blame] | 1345 | install_element(GSMNET_NODE, &cfg_net_encryption_cmd); |
Holger Hans Peter Freyther | 96c8982 | 2009-11-16 17:12:38 +0100 | [diff] [blame] | 1346 | install_element(GSMNET_NODE, &cfg_net_neci_cmd); |
Holger Hans Peter Freyther | 26ba2e7 | 2009-11-21 21:18:38 +0100 | [diff] [blame] | 1347 | install_element(GSMNET_NODE, &cfg_net_T3101_cmd); |
Holger Hans Peter Freyther | 8973386 | 2009-11-21 21:42:26 +0100 | [diff] [blame] | 1348 | install_element(GSMNET_NODE, &cfg_net_T3103_cmd); |
| 1349 | install_element(GSMNET_NODE, &cfg_net_T3105_cmd); |
| 1350 | install_element(GSMNET_NODE, &cfg_net_T3107_cmd); |
| 1351 | install_element(GSMNET_NODE, &cfg_net_T3109_cmd); |
| 1352 | install_element(GSMNET_NODE, &cfg_net_T3111_cmd); |
| 1353 | install_element(GSMNET_NODE, &cfg_net_T3113_cmd); |
| 1354 | install_element(GSMNET_NODE, &cfg_net_T3115_cmd); |
| 1355 | install_element(GSMNET_NODE, &cfg_net_T3117_cmd); |
| 1356 | install_element(GSMNET_NODE, &cfg_net_T3119_cmd); |
| 1357 | install_element(GSMNET_NODE, &cfg_net_T3141_cmd); |
Harald Welte | e87eb46 | 2009-08-07 13:29:14 +0200 | [diff] [blame] | 1358 | |
| 1359 | install_element(GSMNET_NODE, &cfg_bts_cmd); |
Harald Welte | 97ceef9 | 2009-08-06 19:06:46 +0200 | [diff] [blame] | 1360 | install_node(&bts_node, config_write_bts); |
Harald Welte | 59b0468 | 2009-06-10 05:40:52 +0800 | [diff] [blame] | 1361 | install_default(BTS_NODE); |
| 1362 | install_element(BTS_NODE, &cfg_bts_type_cmd); |
Harald Welte | 91afe4c | 2009-06-20 18:15:19 +0200 | [diff] [blame] | 1363 | install_element(BTS_NODE, &cfg_bts_band_cmd); |
Holger Hans Peter Freyther | a098dfb | 2009-08-21 14:44:12 +0200 | [diff] [blame] | 1364 | install_element(BTS_NODE, &cfg_bts_ci_cmd); |
Harald Welte | 59b0468 | 2009-06-10 05:40:52 +0800 | [diff] [blame] | 1365 | install_element(BTS_NODE, &cfg_bts_lac_cmd); |
| 1366 | install_element(BTS_NODE, &cfg_bts_tsc_cmd); |
Harald Welte | 6286888 | 2009-08-08 16:12:58 +0200 | [diff] [blame] | 1367 | install_element(BTS_NODE, &cfg_bts_bsic_cmd); |
Harald Welte | 59b0468 | 2009-06-10 05:40:52 +0800 | [diff] [blame] | 1368 | install_element(BTS_NODE, &cfg_bts_unit_id_cmd); |
Harald Welte | 2557287 | 2009-10-20 00:22:00 +0200 | [diff] [blame] | 1369 | install_element(BTS_NODE, &cfg_bts_stream_id_cmd); |
Harald Welte | 6286888 | 2009-08-08 16:12:58 +0200 | [diff] [blame] | 1370 | install_element(BTS_NODE, &cfg_bts_oml_e1_cmd); |
| 1371 | install_element(BTS_NODE, &cfg_bts_oml_e1_tei_cmd); |
Harald Welte | 3e77461 | 2009-08-10 13:48:16 +0200 | [diff] [blame] | 1372 | install_element(BTS_NODE, &cfg_bts_challoc_cmd); |
Harald Welte (local) | e19be3f | 2009-08-12 13:28:23 +0200 | [diff] [blame] | 1373 | install_element(BTS_NODE, &cfg_bts_cell_barred_cmd); |
Harald Welte (local) | cbd4610 | 2009-08-13 10:14:26 +0200 | [diff] [blame] | 1374 | install_element(BTS_NODE, &cfg_bts_ms_max_power_cmd); |
Harald Welte (local) | b6ea7f7 | 2009-08-14 23:09:25 +0200 | [diff] [blame] | 1375 | install_element(BTS_NODE, &cfg_bts_per_loc_upd_cmd); |
Harald Welte | b761bf8 | 2009-12-12 18:17:25 +0100 | [diff] [blame] | 1376 | install_element(BTS_NODE, &cfg_bts_cell_resel_hyst_cmd); |
| 1377 | install_element(BTS_NODE, &cfg_bts_rxlev_acc_min_cmd); |
Harald Welte | 3e77461 | 2009-08-10 13:48:16 +0200 | [diff] [blame] | 1378 | |
Harald Welte | 59b0468 | 2009-06-10 05:40:52 +0800 | [diff] [blame] | 1379 | |
| 1380 | install_element(BTS_NODE, &cfg_trx_cmd); |
| 1381 | install_node(&trx_node, dummy_config_write); |
| 1382 | install_default(TRX_NODE); |
| 1383 | install_element(TRX_NODE, &cfg_trx_arfcn_cmd); |
Harald Welte | 7f597bc | 2009-06-20 22:36:12 +0200 | [diff] [blame] | 1384 | install_element(TRX_NODE, &cfg_trx_max_power_red_cmd); |
Harald Welte | 6286888 | 2009-08-08 16:12:58 +0200 | [diff] [blame] | 1385 | install_element(TRX_NODE, &cfg_trx_rsl_e1_cmd); |
| 1386 | install_element(TRX_NODE, &cfg_trx_rsl_e1_tei_cmd); |
Holger Hans Peter Freyther | 1c8b480 | 2009-11-11 11:54:24 +0100 | [diff] [blame] | 1387 | install_element(TRX_NODE, &cfg_trx_rf_locked_cmd); |
Harald Welte | 59b0468 | 2009-06-10 05:40:52 +0800 | [diff] [blame] | 1388 | |
| 1389 | install_element(TRX_NODE, &cfg_ts_cmd); |
| 1390 | install_node(&ts_node, dummy_config_write); |
| 1391 | install_default(TS_NODE); |
Harald Welte | 3ffe1b3 | 2009-08-07 00:25:23 +0200 | [diff] [blame] | 1392 | install_element(TS_NODE, &cfg_ts_pchan_cmd); |
| 1393 | install_element(TS_NODE, &cfg_ts_e1_subslot_cmd); |
Harald Welte | 59b0468 | 2009-06-10 05:40:52 +0800 | [diff] [blame] | 1394 | |
Holger Hans Peter Freyther | bdae6f9 | 2009-08-10 10:17:50 +0200 | [diff] [blame] | 1395 | bsc_vty_init_extra(net); |
Harald Welte | 59b0468 | 2009-06-10 05:40:52 +0800 | [diff] [blame] | 1396 | |
| 1397 | return 0; |
| 1398 | } |