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