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