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