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