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