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 | 731fd91 | 2009-08-15 03:24:51 +0200 | [diff] [blame] | 436 | vty_out(vty, " TMSI: %08X%s", atoi(subscr->tmsi), |
| 437 | VTY_NEWLINE); |
Harald Welte (local) | 15920de | 2009-08-14 20:27:16 +0200 | [diff] [blame] | 438 | vty_out(vty, " Use count: %u%s", subscr->use_count, VTY_NEWLINE); |
Harald Welte | 68628e8 | 2009-03-10 12:17:57 +0000 | [diff] [blame] | 439 | } |
| 440 | |
| 441 | static void lchan_dump_vty(struct vty *vty, struct gsm_lchan *lchan) |
| 442 | { |
| 443 | vty_out(vty, "Lchan %u in Timeslot %u of TRX %u in BTS %u, Type %s%s", |
| 444 | lchan->nr, lchan->ts->nr, lchan->ts->trx->nr, |
| 445 | lchan->ts->trx->bts->nr, gsm_lchan_name(lchan->type), |
| 446 | VTY_NEWLINE); |
| 447 | vty_out(vty, " Use Count: %u%s", lchan->use_count, VTY_NEWLINE); |
| 448 | vty_out(vty, " BS Power %u, MS Power %u%s", lchan->bs_power, |
| 449 | lchan->ms_power, VTY_NEWLINE); |
| 450 | if (lchan->subscr) { |
| 451 | vty_out(vty, " Subscriber:%s", VTY_NEWLINE); |
| 452 | subscr_dump_vty(vty, lchan->subscr); |
| 453 | } else |
| 454 | vty_out(vty, " No Subscriber%s", VTY_NEWLINE); |
| 455 | } |
| 456 | |
Harald Welte | 4bfdfe7 | 2009-06-10 23:11:52 +0800 | [diff] [blame] | 457 | #if 0 |
| 458 | 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] | 459 | static void call_dump_vty(struct vty *vty, struct gsm_call *call) |
| 460 | { |
| 461 | vty_out(vty, "Call Type %u, State %u, Transaction ID %u%s", |
| 462 | call->type, call->state, call->transaction_id, VTY_NEWLINE); |
| 463 | |
| 464 | if (call->local_lchan) { |
| 465 | vty_out(vty, "Call Local Channel:%s", VTY_NEWLINE); |
| 466 | lchan_dump_vty(vty, call->local_lchan); |
| 467 | } else |
| 468 | vty_out(vty, "Call has no Local Channel%s", VTY_NEWLINE); |
| 469 | |
| 470 | if (call->remote_lchan) { |
| 471 | vty_out(vty, "Call Remote Channel:%s", VTY_NEWLINE); |
| 472 | lchan_dump_vty(vty, call->remote_lchan); |
| 473 | } else |
| 474 | vty_out(vty, "Call has no Remote Channel%s", VTY_NEWLINE); |
| 475 | |
| 476 | if (call->called_subscr) { |
| 477 | vty_out(vty, "Called Subscriber:%s", VTY_NEWLINE); |
| 478 | subscr_dump_vty(vty, call->called_subscr); |
| 479 | } else |
| 480 | vty_out(vty, "Call has no Called Subscriber%s", VTY_NEWLINE); |
| 481 | } |
Harald Welte | 4bfdfe7 | 2009-06-10 23:11:52 +0800 | [diff] [blame] | 482 | #endif |
Harald Welte | 68628e8 | 2009-03-10 12:17:57 +0000 | [diff] [blame] | 483 | |
| 484 | DEFUN(show_lchan, |
| 485 | show_lchan_cmd, |
| 486 | "show lchan [bts_nr] [trx_nr] [ts_nr] [lchan_nr]", |
| 487 | SHOW_STR "Display information about a logical channel\n") |
| 488 | { |
| 489 | struct gsm_network *net = gsmnet; |
| 490 | struct gsm_bts *bts; |
| 491 | struct gsm_bts_trx *trx; |
| 492 | struct gsm_bts_trx_ts *ts; |
| 493 | struct gsm_lchan *lchan; |
| 494 | int bts_nr, trx_nr, ts_nr, lchan_nr; |
| 495 | |
| 496 | if (argc >= 1) { |
| 497 | /* use the BTS number that the user has specified */ |
| 498 | bts_nr = atoi(argv[0]); |
| 499 | if (bts_nr >= net->num_bts) { |
| 500 | vty_out(vty, "%% can't find BTS %s%s", argv[0], |
| 501 | VTY_NEWLINE); |
| 502 | return CMD_WARNING; |
| 503 | } |
Harald Welte | e441d9c | 2009-06-21 16:17:15 +0200 | [diff] [blame] | 504 | bts = gsm_bts_num(net, bts_nr); |
Harald Welte | 68628e8 | 2009-03-10 12:17:57 +0000 | [diff] [blame] | 505 | } |
| 506 | if (argc >= 2) { |
| 507 | trx_nr = atoi(argv[1]); |
| 508 | if (trx_nr >= bts->num_trx) { |
| 509 | vty_out(vty, "%% can't find TRX %s%s", argv[1], |
| 510 | VTY_NEWLINE); |
| 511 | return CMD_WARNING; |
| 512 | } |
Harald Welte | e441d9c | 2009-06-21 16:17:15 +0200 | [diff] [blame] | 513 | trx = gsm_bts_trx_num(bts, trx_nr); |
Harald Welte | 68628e8 | 2009-03-10 12:17:57 +0000 | [diff] [blame] | 514 | } |
| 515 | if (argc >= 3) { |
| 516 | ts_nr = atoi(argv[2]); |
| 517 | if (ts_nr >= TRX_NR_TS) { |
| 518 | vty_out(vty, "%% can't find TS %s%s", argv[2], |
| 519 | VTY_NEWLINE); |
| 520 | return CMD_WARNING; |
| 521 | } |
| 522 | ts = &trx->ts[ts_nr]; |
| 523 | } |
| 524 | if (argc >= 4) { |
| 525 | lchan_nr = atoi(argv[3]); |
| 526 | if (lchan_nr >= TS_MAX_LCHAN) { |
| 527 | vty_out(vty, "%% can't find LCHAN %s%s", argv[3], |
| 528 | VTY_NEWLINE); |
| 529 | return CMD_WARNING; |
| 530 | } |
| 531 | lchan = &ts->lchan[lchan_nr]; |
| 532 | lchan_dump_vty(vty, lchan); |
| 533 | return CMD_SUCCESS; |
| 534 | } |
| 535 | for (bts_nr = 0; bts_nr < net->num_bts; bts_nr++) { |
Harald Welte | e441d9c | 2009-06-21 16:17:15 +0200 | [diff] [blame] | 536 | bts = gsm_bts_num(net, bts_nr); |
Harald Welte | 68628e8 | 2009-03-10 12:17:57 +0000 | [diff] [blame] | 537 | for (trx_nr = 0; trx_nr < bts->num_trx; trx_nr++) { |
Harald Welte | e441d9c | 2009-06-21 16:17:15 +0200 | [diff] [blame] | 538 | trx = gsm_bts_trx_num(bts, trx_nr); |
Harald Welte | 68628e8 | 2009-03-10 12:17:57 +0000 | [diff] [blame] | 539 | for (ts_nr = 0; ts_nr < TRX_NR_TS; ts_nr++) { |
| 540 | ts = &trx->ts[ts_nr]; |
| 541 | for (lchan_nr = 0; lchan_nr < TS_MAX_LCHAN; |
| 542 | lchan_nr++) { |
| 543 | lchan = &ts->lchan[lchan_nr]; |
Harald Welte | ef235b5 | 2009-03-10 12:34:02 +0000 | [diff] [blame] | 544 | if (lchan->type == GSM_LCHAN_NONE) |
| 545 | continue; |
Harald Welte | 68628e8 | 2009-03-10 12:17:57 +0000 | [diff] [blame] | 546 | lchan_dump_vty(vty, lchan); |
| 547 | } |
| 548 | } |
| 549 | } |
| 550 | } |
| 551 | |
| 552 | return CMD_SUCCESS; |
| 553 | } |
| 554 | |
Harald Welte | 1bc7735 | 2009-03-10 19:47:51 +0000 | [diff] [blame] | 555 | static void e1drv_dump_vty(struct vty *vty, struct e1inp_driver *drv) |
| 556 | { |
| 557 | vty_out(vty, "E1 Input Driver %s%s", drv->name, VTY_NEWLINE); |
| 558 | } |
| 559 | |
| 560 | DEFUN(show_e1drv, |
| 561 | show_e1drv_cmd, |
| 562 | "show e1_driver", |
| 563 | SHOW_STR "Display information about available E1 drivers\n") |
| 564 | { |
| 565 | struct e1inp_driver *drv; |
| 566 | |
| 567 | llist_for_each_entry(drv, &e1inp_driver_list, list) |
| 568 | e1drv_dump_vty(vty, drv); |
| 569 | |
| 570 | return CMD_SUCCESS; |
| 571 | } |
| 572 | |
Harald Welte | 68628e8 | 2009-03-10 12:17:57 +0000 | [diff] [blame] | 573 | static void e1line_dump_vty(struct vty *vty, struct e1inp_line *line) |
| 574 | { |
| 575 | vty_out(vty, "E1 Line Number %u, Name %s, Driver %s%s", |
| 576 | line->num, line->name ? line->name : "", |
| 577 | line->driver->name, VTY_NEWLINE); |
| 578 | } |
| 579 | |
| 580 | DEFUN(show_e1line, |
| 581 | show_e1line_cmd, |
| 582 | "show e1_line [line_nr]", |
| 583 | SHOW_STR "Display information about a E1 line\n") |
| 584 | { |
Harald Welte | 1bc7735 | 2009-03-10 19:47:51 +0000 | [diff] [blame] | 585 | struct e1inp_line *line; |
| 586 | |
| 587 | if (argc >= 1) { |
| 588 | int num = atoi(argv[0]); |
| 589 | llist_for_each_entry(line, &e1inp_line_list, list) { |
| 590 | if (line->num == num) { |
| 591 | e1line_dump_vty(vty, line); |
| 592 | return CMD_SUCCESS; |
| 593 | } |
| 594 | } |
| 595 | return CMD_WARNING; |
| 596 | } |
| 597 | |
| 598 | llist_for_each_entry(line, &e1inp_line_list, list) |
| 599 | e1line_dump_vty(vty, line); |
| 600 | |
| 601 | return CMD_SUCCESS; |
Harald Welte | 68628e8 | 2009-03-10 12:17:57 +0000 | [diff] [blame] | 602 | } |
| 603 | |
| 604 | static void e1ts_dump_vty(struct vty *vty, struct e1inp_ts *ts) |
| 605 | { |
Harald Welte | 4258182 | 2009-08-08 16:12:58 +0200 | [diff] [blame] | 606 | if (ts->type == E1INP_TS_TYPE_NONE) |
| 607 | return; |
Harald Welte | 1bc7735 | 2009-03-10 19:47:51 +0000 | [diff] [blame] | 608 | vty_out(vty, "E1 Timeslot %2u of Line %u is Type %s%s", |
| 609 | ts->num, ts->line->num, e1inp_tstype_name(ts->type), |
| 610 | VTY_NEWLINE); |
Harald Welte | 68628e8 | 2009-03-10 12:17:57 +0000 | [diff] [blame] | 611 | } |
| 612 | |
| 613 | DEFUN(show_e1ts, |
| 614 | show_e1ts_cmd, |
| 615 | "show e1_timeslot [line_nr] [ts_nr]", |
| 616 | SHOW_STR "Display information about a E1 timeslot\n") |
| 617 | { |
Harald Welte | 1bc7735 | 2009-03-10 19:47:51 +0000 | [diff] [blame] | 618 | struct e1inp_line *line; |
| 619 | struct e1inp_ts *ts; |
| 620 | int ts_nr; |
Harald Welte | 68628e8 | 2009-03-10 12:17:57 +0000 | [diff] [blame] | 621 | |
Harald Welte | 1bc7735 | 2009-03-10 19:47:51 +0000 | [diff] [blame] | 622 | if (argc == 0) { |
| 623 | llist_for_each_entry(line, &e1inp_line_list, list) { |
| 624 | for (ts_nr = 0; ts_nr < NUM_E1_TS; ts_nr++) { |
| 625 | ts = &line->ts[ts_nr]; |
| 626 | e1ts_dump_vty(vty, ts); |
| 627 | } |
| 628 | } |
| 629 | return CMD_SUCCESS; |
| 630 | } |
| 631 | if (argc >= 1) { |
| 632 | int num = atoi(argv[0]); |
| 633 | llist_for_each_entry(line, &e1inp_line_list, list) { |
| 634 | if (line->num == num) |
| 635 | break; |
| 636 | } |
| 637 | if (!line || line->num != num) { |
| 638 | vty_out(vty, "E1 line %s is invalid%s", |
| 639 | argv[0], VTY_NEWLINE); |
| 640 | return CMD_WARNING; |
| 641 | } |
| 642 | } |
| 643 | if (argc >= 2) { |
| 644 | ts_nr = atoi(argv[1]); |
| 645 | if (ts_nr > NUM_E1_TS) { |
| 646 | vty_out(vty, "E1 timeslot %s is invalid%s", |
| 647 | argv[1], VTY_NEWLINE); |
| 648 | return CMD_WARNING; |
| 649 | } |
| 650 | ts = &line->ts[ts_nr]; |
| 651 | e1ts_dump_vty(vty, ts); |
| 652 | return CMD_SUCCESS; |
| 653 | } else { |
| 654 | for (ts_nr = 0; ts_nr < NUM_E1_TS; ts_nr++) { |
| 655 | ts = &line->ts[ts_nr]; |
| 656 | e1ts_dump_vty(vty, ts); |
| 657 | } |
| 658 | return CMD_SUCCESS; |
| 659 | } |
| 660 | return CMD_SUCCESS; |
Harald Welte | 68628e8 | 2009-03-10 12:17:57 +0000 | [diff] [blame] | 661 | } |
| 662 | |
Harald Welte | be4b730 | 2009-05-23 16:59:33 +0000 | [diff] [blame] | 663 | 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] | 664 | { |
| 665 | vty_out(vty, "Paging on BTS %u%s", pag->bts->nr, VTY_NEWLINE); |
| 666 | subscr_dump_vty(vty, pag->subscr); |
| 667 | } |
| 668 | |
Harald Welte | be4b730 | 2009-05-23 16:59:33 +0000 | [diff] [blame] | 669 | 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] | 670 | { |
| 671 | struct gsm_paging_request *pag; |
| 672 | |
| 673 | llist_for_each_entry(pag, &bts->paging.pending_requests, entry) |
| 674 | paging_dump_vty(vty, pag); |
| 675 | } |
| 676 | |
| 677 | DEFUN(show_paging, |
| 678 | show_paging_cmd, |
| 679 | "show paging [bts_nr]", |
Harald Welte | be4b730 | 2009-05-23 16:59:33 +0000 | [diff] [blame] | 680 | SHOW_STR "Display information about paging reuqests of a BTS\n") |
Harald Welte | f5025b6 | 2009-03-28 16:55:11 +0000 | [diff] [blame] | 681 | { |
| 682 | struct gsm_network *net = gsmnet; |
| 683 | struct gsm_bts *bts; |
| 684 | int bts_nr; |
| 685 | |
| 686 | if (argc >= 1) { |
| 687 | /* use the BTS number that the user has specified */ |
| 688 | bts_nr = atoi(argv[0]); |
| 689 | if (bts_nr >= net->num_bts) { |
| 690 | vty_out(vty, "%% can't find BTS %s%s", argv[0], |
| 691 | VTY_NEWLINE); |
| 692 | return CMD_WARNING; |
| 693 | } |
Harald Welte | e441d9c | 2009-06-21 16:17:15 +0200 | [diff] [blame] | 694 | bts = gsm_bts_num(net, bts_nr); |
Harald Welte | f5025b6 | 2009-03-28 16:55:11 +0000 | [diff] [blame] | 695 | bts_paging_dump_vty(vty, bts); |
| 696 | |
| 697 | return CMD_SUCCESS; |
| 698 | } |
| 699 | for (bts_nr = 0; bts_nr < net->num_bts; bts_nr++) { |
Harald Welte | e441d9c | 2009-06-21 16:17:15 +0200 | [diff] [blame] | 700 | bts = gsm_bts_num(net, bts_nr); |
Harald Welte | f5025b6 | 2009-03-28 16:55:11 +0000 | [diff] [blame] | 701 | bts_paging_dump_vty(vty, bts); |
| 702 | } |
| 703 | |
| 704 | return CMD_SUCCESS; |
| 705 | } |
| 706 | |
Harald Welte | 40f8289 | 2009-05-23 17:31:39 +0000 | [diff] [blame] | 707 | /* per-subscriber configuration */ |
| 708 | DEFUN(cfg_subscr, |
| 709 | cfg_subscr_cmd, |
| 710 | "subscriber IMSI", |
| 711 | "Select a Subscriber to configure\n") |
| 712 | { |
| 713 | const char *imsi = argv[0]; |
| 714 | struct gsm_subscriber *subscr; |
| 715 | |
Harald Welte | 761e944 | 2009-07-23 19:21:02 +0200 | [diff] [blame] | 716 | subscr = subscr_get_by_imsi(gsmnet, imsi); |
Harald Welte | 40f8289 | 2009-05-23 17:31:39 +0000 | [diff] [blame] | 717 | if (!subscr) { |
| 718 | vty_out(vty, "%% No subscriber for IMSI %s%s", |
| 719 | imsi, VTY_NEWLINE); |
| 720 | return CMD_WARNING; |
| 721 | } |
| 722 | |
| 723 | vty->index = subscr; |
| 724 | vty->node = SUBSCR_NODE; |
| 725 | |
| 726 | return CMD_SUCCESS; |
| 727 | } |
| 728 | |
Harald Welte | 5013b2a | 2009-08-07 13:29:14 +0200 | [diff] [blame] | 729 | DEFUN(cfg_net, |
| 730 | cfg_net_cmd, |
| 731 | "network", |
| 732 | "Configure the GSM network") |
| 733 | { |
| 734 | vty->index = gsmnet; |
| 735 | vty->node = GSMNET_NODE; |
| 736 | |
| 737 | return CMD_SUCCESS; |
| 738 | } |
| 739 | |
| 740 | |
| 741 | DEFUN(cfg_net_ncc, |
| 742 | cfg_net_ncc_cmd, |
| 743 | "network country code <1-999>", |
| 744 | "Set the GSM network country code") |
| 745 | { |
| 746 | gsmnet->country_code = atoi(argv[0]); |
| 747 | |
| 748 | return CMD_SUCCESS; |
| 749 | } |
| 750 | |
| 751 | DEFUN(cfg_net_mnc, |
| 752 | cfg_net_mnc_cmd, |
| 753 | "mobile network code <1-999>", |
| 754 | "Set the GSM mobile network code") |
| 755 | { |
| 756 | gsmnet->network_code = atoi(argv[0]); |
| 757 | |
| 758 | return CMD_SUCCESS; |
| 759 | } |
| 760 | |
| 761 | DEFUN(cfg_net_name_short, |
| 762 | cfg_net_name_short_cmd, |
| 763 | "short name NAME", |
| 764 | "Set the short GSM network name") |
| 765 | { |
| 766 | if (gsmnet->name_short) |
| 767 | talloc_free(gsmnet->name_short); |
| 768 | |
| 769 | gsmnet->name_short = talloc_strdup(gsmnet, argv[0]); |
| 770 | |
| 771 | return CMD_SUCCESS; |
| 772 | } |
| 773 | |
| 774 | DEFUN(cfg_net_name_long, |
| 775 | cfg_net_name_long_cmd, |
| 776 | "long name NAME", |
| 777 | "Set the long GSM network name") |
| 778 | { |
| 779 | if (gsmnet->name_long) |
| 780 | talloc_free(gsmnet->name_long); |
| 781 | |
| 782 | gsmnet->name_long = talloc_strdup(gsmnet, argv[0]); |
| 783 | |
| 784 | return CMD_SUCCESS; |
| 785 | } |
Harald Welte | 40f8289 | 2009-05-23 17:31:39 +0000 | [diff] [blame] | 786 | |
Harald Welte (local) | 69de397 | 2009-08-12 14:42:23 +0200 | [diff] [blame] | 787 | DEFUN(cfg_net_auth_policy, |
| 788 | cfg_net_auth_policy_cmd, |
| 789 | "auth policy (closed|accept-all|token)", |
| 790 | "Set the GSM network authentication policy\n") |
| 791 | { |
| 792 | enum gsm_auth_policy policy = gsm_auth_policy_parse(argv[0]); |
| 793 | |
| 794 | gsmnet->auth_policy = policy; |
| 795 | |
| 796 | return CMD_SUCCESS; |
| 797 | } |
| 798 | |
Harald Welte | 5258fc4 | 2009-03-28 19:07:53 +0000 | [diff] [blame] | 799 | /* per-BTS configuration */ |
| 800 | DEFUN(cfg_bts, |
| 801 | cfg_bts_cmd, |
| 802 | "bts BTS_NR", |
| 803 | "Select a BTS to configure\n") |
| 804 | { |
| 805 | int bts_nr = atoi(argv[0]); |
| 806 | struct gsm_bts *bts; |
| 807 | |
Harald Welte | e441d9c | 2009-06-21 16:17:15 +0200 | [diff] [blame] | 808 | if (bts_nr > gsmnet->num_bts) { |
| 809 | vty_out(vty, "%% The next unused BTS number is %u%s", |
| 810 | gsmnet->num_bts, VTY_NEWLINE); |
Harald Welte | 5258fc4 | 2009-03-28 19:07:53 +0000 | [diff] [blame] | 811 | return CMD_WARNING; |
Harald Welte | e441d9c | 2009-06-21 16:17:15 +0200 | [diff] [blame] | 812 | } else if (bts_nr == gsmnet->num_bts) { |
| 813 | /* allocate a new one */ |
| 814 | bts = gsm_bts_alloc(gsmnet, GSM_BTS_TYPE_UNKNOWN, |
| 815 | HARDCODED_TSC, HARDCODED_BSIC); |
| 816 | } else |
| 817 | bts = gsm_bts_num(gsmnet, bts_nr); |
| 818 | |
| 819 | if (!bts) |
| 820 | return CMD_WARNING; |
Harald Welte | 5258fc4 | 2009-03-28 19:07:53 +0000 | [diff] [blame] | 821 | |
| 822 | vty->index = bts; |
| 823 | vty->node = BTS_NODE; |
| 824 | |
| 825 | return CMD_SUCCESS; |
| 826 | } |
| 827 | |
| 828 | DEFUN(cfg_bts_type, |
| 829 | cfg_bts_type_cmd, |
| 830 | "type TYPE", |
| 831 | "Set the BTS type\n") |
| 832 | { |
| 833 | struct gsm_bts *bts = vty->index; |
| 834 | |
Harald Welte | a6fd58e | 2009-08-07 00:25:23 +0200 | [diff] [blame] | 835 | bts->type = parse_btstype(argv[0]); |
| 836 | |
Harald Welte | 5258fc4 | 2009-03-28 19:07:53 +0000 | [diff] [blame] | 837 | return CMD_SUCCESS; |
| 838 | } |
| 839 | |
Harald Welte | fcd2445 | 2009-06-20 18:15:19 +0200 | [diff] [blame] | 840 | DEFUN(cfg_bts_band, |
| 841 | cfg_bts_band_cmd, |
| 842 | "band BAND", |
| 843 | "Set the frequency band of this BTS\n") |
| 844 | { |
| 845 | struct gsm_bts *bts = vty->index; |
Harald Welte | 4258182 | 2009-08-08 16:12:58 +0200 | [diff] [blame] | 846 | int band = gsm_band_parse(argv[0]); |
Harald Welte | fcd2445 | 2009-06-20 18:15:19 +0200 | [diff] [blame] | 847 | |
| 848 | if (band < 0) { |
| 849 | vty_out(vty, "%% BAND %d is not a valid GSM band%s", |
| 850 | band, VTY_NEWLINE); |
| 851 | return CMD_WARNING; |
| 852 | } |
| 853 | |
| 854 | bts->band = band; |
| 855 | |
| 856 | return CMD_SUCCESS; |
| 857 | } |
| 858 | |
Harald Welte | 5258fc4 | 2009-03-28 19:07:53 +0000 | [diff] [blame] | 859 | DEFUN(cfg_bts_lac, |
| 860 | cfg_bts_lac_cmd, |
| 861 | "location_area_code <0-255>", |
| 862 | "Set the Location Area Code (LAC) of this BTS\n") |
| 863 | { |
| 864 | struct gsm_bts *bts = vty->index; |
| 865 | int lac = atoi(argv[0]); |
| 866 | |
| 867 | if (lac < 0 || lac > 0xff) { |
| 868 | vty_out(vty, "%% LAC %d is not in the valid range (0-255)%s", |
| 869 | lac, VTY_NEWLINE); |
| 870 | return CMD_WARNING; |
| 871 | } |
| 872 | bts->location_area_code = lac; |
| 873 | |
| 874 | return CMD_SUCCESS; |
| 875 | } |
| 876 | |
| 877 | DEFUN(cfg_bts_tsc, |
| 878 | cfg_bts_tsc_cmd, |
| 879 | "training_sequence_code <0-255>", |
| 880 | "Set the Training Sequence Code (TSC) of this BTS\n") |
| 881 | { |
| 882 | struct gsm_bts *bts = vty->index; |
| 883 | int tsc = atoi(argv[0]); |
| 884 | |
| 885 | if (tsc < 0 || tsc > 0xff) { |
| 886 | vty_out(vty, "%% TSC %d is not in the valid range (0-255)%s", |
| 887 | tsc, VTY_NEWLINE); |
| 888 | return CMD_WARNING; |
| 889 | } |
| 890 | bts->tsc = tsc; |
| 891 | |
| 892 | return CMD_SUCCESS; |
| 893 | } |
| 894 | |
Harald Welte | 78f2f50 | 2009-05-23 16:56:52 +0000 | [diff] [blame] | 895 | DEFUN(cfg_bts_bsic, |
| 896 | cfg_bts_bsic_cmd, |
| 897 | "base_station_id_code <0-63>", |
| 898 | "Set the Base Station Identity Code (BSIC) of this BTS\n") |
| 899 | { |
| 900 | struct gsm_bts *bts = vty->index; |
| 901 | int bsic = atoi(argv[0]); |
| 902 | |
| 903 | if (bsic < 0 || bsic > 0x3f) { |
Harald Welte | 4258182 | 2009-08-08 16:12:58 +0200 | [diff] [blame] | 904 | 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] | 905 | bsic, VTY_NEWLINE); |
| 906 | return CMD_WARNING; |
| 907 | } |
| 908 | bts->bsic = bsic; |
| 909 | |
| 910 | return CMD_SUCCESS; |
| 911 | } |
| 912 | |
| 913 | |
Harald Welte | 4cc3422 | 2009-05-01 15:12:31 +0000 | [diff] [blame] | 914 | DEFUN(cfg_bts_unit_id, |
| 915 | cfg_bts_unit_id_cmd, |
Harald Welte | 07dc73d | 2009-08-07 13:27:09 +0200 | [diff] [blame] | 916 | "ip.access unit_id <0-65534> <0-255>", |
| 917 | "Set the ip.access BTS Unit ID of this BTS\n") |
Harald Welte | 4cc3422 | 2009-05-01 15:12:31 +0000 | [diff] [blame] | 918 | { |
| 919 | struct gsm_bts *bts = vty->index; |
| 920 | int site_id = atoi(argv[0]); |
| 921 | int bts_id = atoi(argv[1]); |
| 922 | |
Harald Welte | 07dc73d | 2009-08-07 13:27:09 +0200 | [diff] [blame] | 923 | if (!is_ipaccess_bts(bts)) { |
| 924 | vty_out(vty, "%% BTS is not of ip.access type%s", VTY_NEWLINE); |
| 925 | return CMD_WARNING; |
| 926 | } |
| 927 | |
Harald Welte | 4cc3422 | 2009-05-01 15:12:31 +0000 | [diff] [blame] | 928 | bts->ip_access.site_id = site_id; |
| 929 | bts->ip_access.bts_id = bts_id; |
| 930 | |
| 931 | return CMD_SUCCESS; |
| 932 | } |
| 933 | |
Harald Welte | 4258182 | 2009-08-08 16:12:58 +0200 | [diff] [blame] | 934 | DEFUN(cfg_bts_oml_e1, |
| 935 | cfg_bts_oml_e1_cmd, |
| 936 | "oml e1 line E1_LINE timeslot <1-31> sub-slot (0|1|2|3|full)", |
| 937 | "E1 interface to be used for OML\n") |
| 938 | { |
| 939 | struct gsm_bts *bts = vty->index; |
| 940 | |
| 941 | parse_e1_link(&bts->oml_e1_link, argv[0], argv[1], argv[2]); |
| 942 | |
| 943 | return CMD_SUCCESS; |
| 944 | } |
| 945 | |
| 946 | |
| 947 | DEFUN(cfg_bts_oml_e1_tei, |
| 948 | cfg_bts_oml_e1_tei_cmd, |
| 949 | "oml e1 tei <0-63>", |
| 950 | "Set the TEI to be used for OML") |
| 951 | { |
| 952 | struct gsm_bts *bts = vty->index; |
| 953 | |
| 954 | bts->oml_tei = atoi(argv[0]); |
| 955 | |
| 956 | return CMD_SUCCESS; |
| 957 | } |
| 958 | |
Harald Welte | 7a8fa41 | 2009-08-10 13:48:16 +0200 | [diff] [blame] | 959 | DEFUN(cfg_bts_challoc, cfg_bts_challoc_cmd, |
| 960 | "channel allocator (ascending|descending)", |
| 961 | "Should the channel allocator allocate in reverse TRX order?") |
| 962 | { |
| 963 | struct gsm_bts *bts = vty->index; |
| 964 | |
| 965 | if (!strcmp(argv[0], "ascending")) |
| 966 | bts->chan_alloc_reverse = 0; |
| 967 | else |
| 968 | bts->chan_alloc_reverse = 1; |
| 969 | |
| 970 | return CMD_SUCCESS; |
| 971 | } |
| 972 | |
Harald Welte (local) | 5dececf | 2009-08-12 13:28:23 +0200 | [diff] [blame] | 973 | DEFUN(cfg_bts_cell_barred, cfg_bts_cell_barred_cmd, |
| 974 | "cell barred (0|1)", |
| 975 | "Should this cell be barred from access?") |
| 976 | { |
| 977 | struct gsm_bts *bts = vty->index; |
| 978 | |
| 979 | bts->cell_barred = atoi(argv[0]); |
| 980 | |
| 981 | return CMD_SUCCESS; |
| 982 | } |
| 983 | |
Harald Welte (local) | 0e451d0 | 2009-08-13 10:14:26 +0200 | [diff] [blame] | 984 | DEFUN(cfg_bts_ms_max_power, cfg_bts_ms_max_power_cmd, |
| 985 | "ms max power <0-40>", |
| 986 | "Maximum transmit power of the MS") |
| 987 | { |
| 988 | struct gsm_bts *bts = vty->index; |
| 989 | |
| 990 | bts->ms_max_power = atoi(argv[0]); |
| 991 | |
| 992 | return CMD_SUCCESS; |
| 993 | } |
| 994 | |
Harald Welte (local) | efc9231 | 2009-08-14 23:09:25 +0200 | [diff] [blame] | 995 | DEFUN(cfg_bts_per_loc_upd, cfg_bts_per_loc_upd_cmd, |
| 996 | "periodic location update <0-1530>", |
| 997 | "Periodic Location Updating Interval in Minutes") |
| 998 | { |
| 999 | struct gsm_bts *bts = vty->index; |
| 1000 | |
| 1001 | bts->chan_desc.t3212 = atoi(argv[0]) / 10; |
| 1002 | |
| 1003 | return CMD_SUCCESS; |
| 1004 | } |
| 1005 | |
Harald Welte | 7a8fa41 | 2009-08-10 13:48:16 +0200 | [diff] [blame] | 1006 | |
Harald Welte | 5258fc4 | 2009-03-28 19:07:53 +0000 | [diff] [blame] | 1007 | /* per TRX configuration */ |
| 1008 | DEFUN(cfg_trx, |
| 1009 | cfg_trx_cmd, |
| 1010 | "trx TRX_NR", |
| 1011 | "Select a TRX to configure") |
| 1012 | { |
| 1013 | int trx_nr = atoi(argv[0]); |
| 1014 | struct gsm_bts *bts = vty->index; |
| 1015 | struct gsm_bts_trx *trx; |
| 1016 | |
Harald Welte | e441d9c | 2009-06-21 16:17:15 +0200 | [diff] [blame] | 1017 | if (trx_nr > bts->num_trx) { |
| 1018 | vty_out(vty, "%% The next unused TRX number in this BTS is %u%s", |
| 1019 | bts->num_trx, VTY_NEWLINE); |
Harald Welte | 5258fc4 | 2009-03-28 19:07:53 +0000 | [diff] [blame] | 1020 | return CMD_WARNING; |
Harald Welte | e441d9c | 2009-06-21 16:17:15 +0200 | [diff] [blame] | 1021 | } else if (trx_nr == bts->num_trx) { |
| 1022 | /* we need to allocate a new one */ |
| 1023 | trx = gsm_bts_trx_alloc(bts); |
| 1024 | } else |
| 1025 | trx = gsm_bts_trx_num(bts, trx_nr); |
| 1026 | |
| 1027 | if (!trx) |
| 1028 | return CMD_WARNING; |
Harald Welte | 5258fc4 | 2009-03-28 19:07:53 +0000 | [diff] [blame] | 1029 | |
| 1030 | vty->index = trx; |
| 1031 | vty->node = TRX_NODE; |
| 1032 | |
| 1033 | return CMD_SUCCESS; |
| 1034 | } |
| 1035 | |
| 1036 | DEFUN(cfg_trx_arfcn, |
| 1037 | cfg_trx_arfcn_cmd, |
| 1038 | "arfcn <1-1024>", |
| 1039 | "Set the ARFCN for this TRX\n") |
| 1040 | { |
| 1041 | int arfcn = atoi(argv[0]); |
| 1042 | struct gsm_bts_trx *trx = vty->index; |
| 1043 | |
| 1044 | /* FIXME: check if this ARFCN is supported by this TRX */ |
| 1045 | |
| 1046 | trx->arfcn = arfcn; |
| 1047 | |
| 1048 | /* FIXME: patch ARFCN into SYSTEM INFORMATION */ |
| 1049 | /* FIXME: use OML layer to update the ARFCN */ |
| 1050 | /* FIXME: use RSL layer to update SYSTEM INFORMATION */ |
| 1051 | |
| 1052 | return CMD_SUCCESS; |
| 1053 | } |
| 1054 | |
Harald Welte | fcd2445 | 2009-06-20 18:15:19 +0200 | [diff] [blame] | 1055 | DEFUN(cfg_trx_max_power_red, |
| 1056 | cfg_trx_max_power_red_cmd, |
| 1057 | "max_power_red <0-100>", |
| 1058 | "Reduction of maximum BS RF Power in dB\n") |
| 1059 | { |
| 1060 | int maxpwr_r = atoi(argv[0]); |
| 1061 | struct gsm_bts_trx *trx = vty->index; |
| 1062 | int upper_limit = 12; /* default 12.21 max power red. */ |
| 1063 | |
| 1064 | /* FIXME: check if our BTS type supports more than 12 */ |
| 1065 | if (maxpwr_r < 0 || maxpwr_r > upper_limit) { |
| 1066 | vty_out(vty, "%% Power %d dB is not in the valid range%s", |
| 1067 | maxpwr_r, VTY_NEWLINE); |
| 1068 | return CMD_WARNING; |
| 1069 | } |
| 1070 | if (maxpwr_r & 1) { |
| 1071 | vty_out(vty, "%% Power %d dB is not an even value%s", |
| 1072 | maxpwr_r, VTY_NEWLINE); |
| 1073 | return CMD_WARNING; |
| 1074 | } |
| 1075 | |
| 1076 | trx->max_power_red = maxpwr_r; |
| 1077 | |
| 1078 | /* FIXME: make sure we update this using OML */ |
| 1079 | |
| 1080 | return CMD_SUCCESS; |
| 1081 | } |
| 1082 | |
Harald Welte | 4258182 | 2009-08-08 16:12:58 +0200 | [diff] [blame] | 1083 | DEFUN(cfg_trx_rsl_e1, |
| 1084 | cfg_trx_rsl_e1_cmd, |
| 1085 | "rsl e1 line E1_LINE timeslot <1-31> sub-slot (0|1|2|3|full)", |
| 1086 | "E1 interface to be used for RSL\n") |
| 1087 | { |
| 1088 | struct gsm_bts_trx *trx = vty->index; |
| 1089 | |
| 1090 | parse_e1_link(&trx->rsl_e1_link, argv[0], argv[1], argv[2]); |
| 1091 | |
| 1092 | return CMD_SUCCESS; |
| 1093 | } |
| 1094 | |
| 1095 | DEFUN(cfg_trx_rsl_e1_tei, |
| 1096 | cfg_trx_rsl_e1_tei_cmd, |
| 1097 | "rsl e1 tei <0-63>", |
| 1098 | "Set the TEI to be used for RSL") |
| 1099 | { |
| 1100 | struct gsm_bts_trx *trx = vty->index; |
| 1101 | |
| 1102 | trx->rsl_tei = atoi(argv[0]); |
| 1103 | |
| 1104 | return CMD_SUCCESS; |
| 1105 | } |
| 1106 | |
| 1107 | |
Harald Welte | 5258fc4 | 2009-03-28 19:07:53 +0000 | [diff] [blame] | 1108 | /* per TS configuration */ |
| 1109 | DEFUN(cfg_ts, |
| 1110 | cfg_ts_cmd, |
Harald Welte | 4258182 | 2009-08-08 16:12:58 +0200 | [diff] [blame] | 1111 | "timeslot <0-7>", |
Harald Welte | 5258fc4 | 2009-03-28 19:07:53 +0000 | [diff] [blame] | 1112 | "Select a Timeslot to configure") |
| 1113 | { |
| 1114 | int ts_nr = atoi(argv[0]); |
| 1115 | struct gsm_bts_trx *trx = vty->index; |
| 1116 | struct gsm_bts_trx_ts *ts; |
| 1117 | |
| 1118 | if (ts_nr >= TRX_NR_TS) { |
| 1119 | vty_out(vty, "%% A GSM TRX only has %u Timeslots per TRX%s", |
| 1120 | TRX_NR_TS, VTY_NEWLINE); |
| 1121 | return CMD_WARNING; |
| 1122 | } |
| 1123 | |
| 1124 | ts = &trx->ts[ts_nr]; |
| 1125 | |
| 1126 | vty->index = ts; |
| 1127 | vty->node = TS_NODE; |
| 1128 | |
| 1129 | return CMD_SUCCESS; |
| 1130 | } |
| 1131 | |
Harald Welte | a6fd58e | 2009-08-07 00:25:23 +0200 | [diff] [blame] | 1132 | DEFUN(cfg_ts_pchan, |
| 1133 | cfg_ts_pchan_cmd, |
| 1134 | "phys_chan_config PCHAN", |
| 1135 | "Physical Channel configuration (TCH/SDCCH/...)") |
| 1136 | { |
| 1137 | struct gsm_bts_trx_ts *ts = vty->index; |
| 1138 | int pchanc; |
| 1139 | |
| 1140 | pchanc = gsm_pchan_parse(argv[0]); |
| 1141 | if (pchanc < 0) |
| 1142 | return CMD_WARNING; |
| 1143 | |
| 1144 | ts->pchan = pchanc; |
| 1145 | |
| 1146 | return CMD_SUCCESS; |
| 1147 | } |
| 1148 | |
| 1149 | DEFUN(cfg_ts_e1_subslot, |
| 1150 | cfg_ts_e1_subslot_cmd, |
Harald Welte | 4258182 | 2009-08-08 16:12:58 +0200 | [diff] [blame] | 1151 | "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] | 1152 | "E1 sub-slot connected to this on-air timeslot") |
| 1153 | { |
| 1154 | struct gsm_bts_trx_ts *ts = vty->index; |
| 1155 | |
Harald Welte | 4258182 | 2009-08-08 16:12:58 +0200 | [diff] [blame] | 1156 | parse_e1_link(&ts->e1_link, argv[0], argv[1], argv[2]); |
Harald Welte | a6fd58e | 2009-08-07 00:25:23 +0200 | [diff] [blame] | 1157 | |
| 1158 | return CMD_SUCCESS; |
| 1159 | } |
Harald Welte | 5258fc4 | 2009-03-28 19:07:53 +0000 | [diff] [blame] | 1160 | |
Harald Welte | 40f8289 | 2009-05-23 17:31:39 +0000 | [diff] [blame] | 1161 | /* Subscriber */ |
| 1162 | DEFUN(show_subscr, |
| 1163 | show_subscr_cmd, |
| 1164 | "show subscriber [IMSI]", |
| 1165 | SHOW_STR "Display information about a subscriber\n") |
| 1166 | { |
| 1167 | const char *imsi; |
| 1168 | struct gsm_subscriber *subscr; |
| 1169 | |
| 1170 | if (argc >= 1) { |
| 1171 | imsi = argv[0]; |
Harald Welte | 761e944 | 2009-07-23 19:21:02 +0200 | [diff] [blame] | 1172 | subscr = subscr_get_by_imsi(gsmnet, imsi); |
Harald Welte | 40f8289 | 2009-05-23 17:31:39 +0000 | [diff] [blame] | 1173 | if (!subscr) { |
| 1174 | vty_out(vty, "%% unknown subscriber%s", |
| 1175 | VTY_NEWLINE); |
| 1176 | return CMD_WARNING; |
| 1177 | } |
| 1178 | subscr_dump_vty(vty, subscr); |
| 1179 | |
| 1180 | return CMD_SUCCESS; |
| 1181 | } |
| 1182 | |
| 1183 | /* FIXME: iterate over all subscribers ? */ |
| 1184 | return CMD_WARNING; |
| 1185 | |
| 1186 | return CMD_SUCCESS; |
| 1187 | } |
| 1188 | |
Harald Welte (local) | 15920de | 2009-08-14 20:27:16 +0200 | [diff] [blame] | 1189 | DEFUN(show_subscr_cache, |
| 1190 | show_subscr_cache_cmd, |
| 1191 | "show subscriber cache", |
| 1192 | SHOW_STR "Display contents of subscriber cache\n") |
| 1193 | { |
| 1194 | struct gsm_subscriber *subscr; |
| 1195 | |
| 1196 | llist_for_each_entry(subscr, &active_subscribers, entry) { |
| 1197 | vty_out(vty, " Subscriber:%s", VTY_NEWLINE); |
| 1198 | subscr_dump_vty(vty, subscr); |
| 1199 | } |
| 1200 | |
| 1201 | return CMD_SUCCESS; |
| 1202 | } |
| 1203 | |
Harald Welte | 7604218 | 2009-08-08 16:03:15 +0200 | [diff] [blame] | 1204 | DEFUN(sms_send_pend, |
| 1205 | sms_send_pend_cmd, |
| 1206 | "sms send pending MIN_ID", |
| 1207 | "Send all pending SMS starting from MIN_ID") |
| 1208 | { |
| 1209 | struct gsm_sms *sms; |
Harald Welte (local) | 05e6763 | 2009-08-14 16:01:20 +0200 | [diff] [blame] | 1210 | int id = atoi(argv[0]); |
Harald Welte | 7604218 | 2009-08-08 16:03:15 +0200 | [diff] [blame] | 1211 | |
Harald Welte (local) | 05e6763 | 2009-08-14 16:01:20 +0200 | [diff] [blame] | 1212 | while (1) { |
| 1213 | sms = db_sms_get_unsent(gsmnet, id++); |
| 1214 | if (!sms) |
| 1215 | return CMD_WARNING; |
Harald Welte | 7604218 | 2009-08-08 16:03:15 +0200 | [diff] [blame] | 1216 | |
Harald Welte (local) | 05e6763 | 2009-08-14 16:01:20 +0200 | [diff] [blame] | 1217 | if (!sms->receiver) { |
| 1218 | sms_free(sms); |
| 1219 | continue; |
| 1220 | } |
| 1221 | |
| 1222 | gsm411_send_sms_subscr(sms->receiver, sms); |
Harald Welte | 7604218 | 2009-08-08 16:03:15 +0200 | [diff] [blame] | 1223 | } |
| 1224 | |
Harald Welte | 7604218 | 2009-08-08 16:03:15 +0200 | [diff] [blame] | 1225 | return CMD_SUCCESS; |
| 1226 | } |
| 1227 | |
Harald Welte | f9daefd | 2009-08-09 15:13:54 +0200 | [diff] [blame] | 1228 | static struct buffer *argv_to_buffer(int argc, const char *argv[], int base) |
| 1229 | { |
| 1230 | struct buffer *b = buffer_new(1024); |
| 1231 | int i; |
| 1232 | |
| 1233 | if (!b) |
| 1234 | return NULL; |
| 1235 | |
| 1236 | for (i = base; i < argc; i++) { |
| 1237 | buffer_putstr(b, argv[i]); |
| 1238 | buffer_putc(b, ' '); |
| 1239 | } |
| 1240 | buffer_putc(b, '\0'); |
| 1241 | |
| 1242 | return b; |
| 1243 | } |
| 1244 | |
Harald Welte | 10250e6 | 2009-08-15 03:28:15 +0200 | [diff] [blame^] | 1245 | struct gsm_sms *sms_from_text(struct gsm_subscriber *receiver, const char *text) |
Harald Welte | f9daefd | 2009-08-09 15:13:54 +0200 | [diff] [blame] | 1246 | { |
| 1247 | struct gsm_sms *sms = sms_alloc(); |
| 1248 | |
| 1249 | if (!sms) |
Harald Welte | 10250e6 | 2009-08-15 03:28:15 +0200 | [diff] [blame^] | 1250 | return NULL; |
Harald Welte | f9daefd | 2009-08-09 15:13:54 +0200 | [diff] [blame] | 1251 | |
| 1252 | if (!receiver->lac) { |
| 1253 | /* subscriber currently not attached, store in database? */ |
Harald Welte | 10250e6 | 2009-08-15 03:28:15 +0200 | [diff] [blame^] | 1254 | return NULL; |
Harald Welte | f9daefd | 2009-08-09 15:13:54 +0200 | [diff] [blame] | 1255 | } |
| 1256 | |
Harald Welte (local) | 571602f | 2009-08-13 13:25:32 +0200 | [diff] [blame] | 1257 | sms->receiver = subscr_get(receiver); |
Harald Welte | 8c340fe | 2009-08-13 00:57:31 +0200 | [diff] [blame] | 1258 | strncpy(sms->text, text, sizeof(sms->text)-1); |
Harald Welte | f9daefd | 2009-08-09 15:13:54 +0200 | [diff] [blame] | 1259 | |
| 1260 | /* FIXME: don't use ID 1 static */ |
| 1261 | sms->sender = subscr_get_by_id(gsmnet, 1); |
| 1262 | sms->reply_path_req = 0; |
| 1263 | sms->status_rep_req = 0; |
| 1264 | sms->ud_hdr_ind = 0; |
| 1265 | sms->protocol_id = 0; /* implicit */ |
| 1266 | sms->data_coding_scheme = 0; /* default 7bit */ |
| 1267 | strncpy(sms->dest_addr, receiver->extension, sizeof(sms->dest_addr)-1); |
| 1268 | /* Generate user_data */ |
| 1269 | sms->user_data_len = gsm_7bit_encode(sms->user_data, sms->text); |
| 1270 | |
Harald Welte | 8c340fe | 2009-08-13 00:57:31 +0200 | [diff] [blame] | 1271 | return sms; |
| 1272 | } |
| 1273 | |
| 1274 | static int _send_sms_buffer(struct gsm_subscriber *receiver, |
| 1275 | struct buffer *b) |
| 1276 | { |
| 1277 | struct gsm_sms *sms; |
| 1278 | |
| 1279 | sms = sms_from_text(receiver, buffer_getstr(b)); |
| 1280 | |
Harald Welte (local) | 571602f | 2009-08-13 13:25:32 +0200 | [diff] [blame] | 1281 | gsm411_send_sms_subscr(receiver, sms); |
Harald Welte | f9daefd | 2009-08-09 15:13:54 +0200 | [diff] [blame] | 1282 | |
| 1283 | return CMD_SUCCESS; |
| 1284 | } |
| 1285 | |
Harald Welte | 7604218 | 2009-08-08 16:03:15 +0200 | [diff] [blame] | 1286 | DEFUN(sms_send_ext, |
| 1287 | sms_send_ext_cmd, |
| 1288 | "sms send extension EXTEN .LINE", |
| 1289 | "Send a message to a subscriber identified by EXTEN") |
| 1290 | { |
Harald Welte | f9daefd | 2009-08-09 15:13:54 +0200 | [diff] [blame] | 1291 | struct gsm_subscriber *receiver; |
| 1292 | struct buffer *b; |
| 1293 | int rc; |
Harald Welte | 7604218 | 2009-08-08 16:03:15 +0200 | [diff] [blame] | 1294 | |
Harald Welte | f9daefd | 2009-08-09 15:13:54 +0200 | [diff] [blame] | 1295 | receiver = subscr_get_by_extension(gsmnet, argv[0]); |
| 1296 | if (!receiver) |
| 1297 | return CMD_WARNING; |
Harald Welte | 7604218 | 2009-08-08 16:03:15 +0200 | [diff] [blame] | 1298 | |
Harald Welte | f9daefd | 2009-08-09 15:13:54 +0200 | [diff] [blame] | 1299 | b = argv_to_buffer(argc, argv, 1); |
| 1300 | rc = _send_sms_buffer(receiver, b); |
| 1301 | buffer_free(b); |
| 1302 | |
| 1303 | return rc; |
Harald Welte | 7604218 | 2009-08-08 16:03:15 +0200 | [diff] [blame] | 1304 | } |
| 1305 | |
| 1306 | DEFUN(sms_send_imsi, |
| 1307 | sms_send_imsi_cmd, |
| 1308 | "sms send imsi IMSI .LINE", |
| 1309 | "Send a message to a subscriber identified by IMSI") |
| 1310 | { |
Harald Welte | f9daefd | 2009-08-09 15:13:54 +0200 | [diff] [blame] | 1311 | struct gsm_subscriber *receiver; |
| 1312 | struct buffer *b; |
| 1313 | int rc; |
Harald Welte | 7604218 | 2009-08-08 16:03:15 +0200 | [diff] [blame] | 1314 | |
Harald Welte | f9daefd | 2009-08-09 15:13:54 +0200 | [diff] [blame] | 1315 | receiver = subscr_get_by_imsi(gsmnet, argv[0]); |
| 1316 | if (!receiver) |
| 1317 | return CMD_WARNING; |
Harald Welte | 7604218 | 2009-08-08 16:03:15 +0200 | [diff] [blame] | 1318 | |
Harald Welte | f9daefd | 2009-08-09 15:13:54 +0200 | [diff] [blame] | 1319 | b = argv_to_buffer(argc, argv, 1); |
| 1320 | rc = _send_sms_buffer(receiver, b); |
| 1321 | buffer_free(b); |
| 1322 | |
| 1323 | return rc; |
Harald Welte | 7604218 | 2009-08-08 16:03:15 +0200 | [diff] [blame] | 1324 | } |
| 1325 | |
| 1326 | |
Harald Welte | 40f8289 | 2009-05-23 17:31:39 +0000 | [diff] [blame] | 1327 | DEFUN(cfg_subscr_name, |
| 1328 | cfg_subscr_name_cmd, |
| 1329 | "name NAME", |
| 1330 | "Set the name of the subscriber") |
| 1331 | { |
| 1332 | const char *name = argv[0]; |
| 1333 | struct gsm_subscriber *subscr = vty->index; |
| 1334 | |
| 1335 | strncpy(subscr->name, name, sizeof(subscr->name)); |
| 1336 | |
| 1337 | db_sync_subscriber(subscr); |
| 1338 | |
| 1339 | return CMD_SUCCESS; |
| 1340 | } |
| 1341 | |
| 1342 | DEFUN(cfg_subscr_extension, |
| 1343 | cfg_subscr_extension_cmd, |
| 1344 | "extension EXTENSION", |
| 1345 | "Set the extension of the subscriber") |
| 1346 | { |
| 1347 | const char *name = argv[0]; |
| 1348 | struct gsm_subscriber *subscr = vty->index; |
| 1349 | |
| 1350 | strncpy(subscr->extension, name, sizeof(subscr->extension)); |
| 1351 | |
| 1352 | db_sync_subscriber(subscr); |
| 1353 | |
| 1354 | return CMD_SUCCESS; |
| 1355 | } |
| 1356 | |
| 1357 | DEFUN(cfg_subscr_authorized, |
| 1358 | cfg_subscr_authorized_cmd, |
| 1359 | "auth <0-1>", |
| 1360 | "Set the authorization status of the subscriber") |
| 1361 | { |
| 1362 | int auth = atoi(argv[0]); |
| 1363 | struct gsm_subscriber *subscr = vty->index; |
| 1364 | |
| 1365 | if (auth) |
| 1366 | subscr->authorized = 1; |
| 1367 | else |
| 1368 | subscr->authorized = 0; |
| 1369 | |
| 1370 | db_sync_subscriber(subscr); |
| 1371 | |
| 1372 | return CMD_SUCCESS; |
| 1373 | } |
| 1374 | |
Harald Welte | 68628e8 | 2009-03-10 12:17:57 +0000 | [diff] [blame] | 1375 | int bsc_vty_init(struct gsm_network *net) |
| 1376 | { |
| 1377 | gsmnet = net; |
| 1378 | |
| 1379 | cmd_init(1); |
| 1380 | vty_init(); |
| 1381 | |
| 1382 | install_element(VIEW_NODE, &show_net_cmd); |
| 1383 | install_element(VIEW_NODE, &show_bts_cmd); |
| 1384 | install_element(VIEW_NODE, &show_trx_cmd); |
| 1385 | install_element(VIEW_NODE, &show_ts_cmd); |
| 1386 | install_element(VIEW_NODE, &show_lchan_cmd); |
Harald Welte | 1bc7735 | 2009-03-10 19:47:51 +0000 | [diff] [blame] | 1387 | |
| 1388 | install_element(VIEW_NODE, &show_e1drv_cmd); |
Harald Welte | 68628e8 | 2009-03-10 12:17:57 +0000 | [diff] [blame] | 1389 | install_element(VIEW_NODE, &show_e1line_cmd); |
| 1390 | install_element(VIEW_NODE, &show_e1ts_cmd); |
| 1391 | |
Harald Welte | f5025b6 | 2009-03-28 16:55:11 +0000 | [diff] [blame] | 1392 | install_element(VIEW_NODE, &show_paging_cmd); |
Harald Welte | 5258fc4 | 2009-03-28 19:07:53 +0000 | [diff] [blame] | 1393 | |
Harald Welte | 40f8289 | 2009-05-23 17:31:39 +0000 | [diff] [blame] | 1394 | install_element(VIEW_NODE, &show_subscr_cmd); |
Harald Welte (local) | 15920de | 2009-08-14 20:27:16 +0200 | [diff] [blame] | 1395 | install_element(VIEW_NODE, &show_subscr_cache_cmd); |
Harald Welte | 40f8289 | 2009-05-23 17:31:39 +0000 | [diff] [blame] | 1396 | |
Harald Welte | 7604218 | 2009-08-08 16:03:15 +0200 | [diff] [blame] | 1397 | install_element(VIEW_NODE, &sms_send_pend_cmd); |
Harald Welte | 7604218 | 2009-08-08 16:03:15 +0200 | [diff] [blame] | 1398 | install_element(VIEW_NODE, &sms_send_ext_cmd); |
| 1399 | install_element(VIEW_NODE, &sms_send_imsi_cmd); |
Harald Welte | 7604218 | 2009-08-08 16:03:15 +0200 | [diff] [blame] | 1400 | |
Harald Welte | 5013b2a | 2009-08-07 13:29:14 +0200 | [diff] [blame] | 1401 | install_element(CONFIG_NODE, &cfg_net_cmd); |
| 1402 | install_node(&net_node, config_write_net); |
| 1403 | install_default(GSMNET_NODE); |
Harald Welte | 4258182 | 2009-08-08 16:12:58 +0200 | [diff] [blame] | 1404 | install_element(GSMNET_NODE, &cfg_net_ncc_cmd); |
Harald Welte | 5013b2a | 2009-08-07 13:29:14 +0200 | [diff] [blame] | 1405 | install_element(GSMNET_NODE, &cfg_net_mnc_cmd); |
| 1406 | install_element(GSMNET_NODE, &cfg_net_name_short_cmd); |
| 1407 | install_element(GSMNET_NODE, &cfg_net_name_long_cmd); |
Harald Welte (local) | 69de397 | 2009-08-12 14:42:23 +0200 | [diff] [blame] | 1408 | install_element(GSMNET_NODE, &cfg_net_auth_policy_cmd); |
Harald Welte | 5013b2a | 2009-08-07 13:29:14 +0200 | [diff] [blame] | 1409 | |
| 1410 | install_element(GSMNET_NODE, &cfg_bts_cmd); |
Harald Welte | 67ce073 | 2009-08-06 19:06:46 +0200 | [diff] [blame] | 1411 | install_node(&bts_node, config_write_bts); |
Harald Welte | 68628e8 | 2009-03-10 12:17:57 +0000 | [diff] [blame] | 1412 | install_default(BTS_NODE); |
Harald Welte | 5258fc4 | 2009-03-28 19:07:53 +0000 | [diff] [blame] | 1413 | install_element(BTS_NODE, &cfg_bts_type_cmd); |
Harald Welte | fcd2445 | 2009-06-20 18:15:19 +0200 | [diff] [blame] | 1414 | install_element(BTS_NODE, &cfg_bts_band_cmd); |
Harald Welte | 5258fc4 | 2009-03-28 19:07:53 +0000 | [diff] [blame] | 1415 | install_element(BTS_NODE, &cfg_bts_lac_cmd); |
| 1416 | install_element(BTS_NODE, &cfg_bts_tsc_cmd); |
Harald Welte | 4258182 | 2009-08-08 16:12:58 +0200 | [diff] [blame] | 1417 | install_element(BTS_NODE, &cfg_bts_bsic_cmd); |
Harald Welte | 4cc3422 | 2009-05-01 15:12:31 +0000 | [diff] [blame] | 1418 | install_element(BTS_NODE, &cfg_bts_unit_id_cmd); |
Harald Welte | 4258182 | 2009-08-08 16:12:58 +0200 | [diff] [blame] | 1419 | install_element(BTS_NODE, &cfg_bts_oml_e1_cmd); |
| 1420 | install_element(BTS_NODE, &cfg_bts_oml_e1_tei_cmd); |
Harald Welte | 7a8fa41 | 2009-08-10 13:48:16 +0200 | [diff] [blame] | 1421 | install_element(BTS_NODE, &cfg_bts_challoc_cmd); |
Harald Welte (local) | 5dececf | 2009-08-12 13:28:23 +0200 | [diff] [blame] | 1422 | install_element(BTS_NODE, &cfg_bts_cell_barred_cmd); |
Harald Welte (local) | 0e451d0 | 2009-08-13 10:14:26 +0200 | [diff] [blame] | 1423 | install_element(BTS_NODE, &cfg_bts_ms_max_power_cmd); |
Harald Welte (local) | efc9231 | 2009-08-14 23:09:25 +0200 | [diff] [blame] | 1424 | install_element(BTS_NODE, &cfg_bts_per_loc_upd_cmd); |
Harald Welte | 7a8fa41 | 2009-08-10 13:48:16 +0200 | [diff] [blame] | 1425 | |
Harald Welte | 68628e8 | 2009-03-10 12:17:57 +0000 | [diff] [blame] | 1426 | |
Harald Welte | 5258fc4 | 2009-03-28 19:07:53 +0000 | [diff] [blame] | 1427 | install_element(BTS_NODE, &cfg_trx_cmd); |
Harald Welte | 68628e8 | 2009-03-10 12:17:57 +0000 | [diff] [blame] | 1428 | install_node(&trx_node, dummy_config_write); |
Harald Welte | 68628e8 | 2009-03-10 12:17:57 +0000 | [diff] [blame] | 1429 | install_default(TRX_NODE); |
Harald Welte | 5258fc4 | 2009-03-28 19:07:53 +0000 | [diff] [blame] | 1430 | install_element(TRX_NODE, &cfg_trx_arfcn_cmd); |
Harald Welte | 879dc97 | 2009-06-20 22:36:12 +0200 | [diff] [blame] | 1431 | install_element(TRX_NODE, &cfg_trx_max_power_red_cmd); |
Harald Welte | 4258182 | 2009-08-08 16:12:58 +0200 | [diff] [blame] | 1432 | install_element(TRX_NODE, &cfg_trx_rsl_e1_cmd); |
| 1433 | install_element(TRX_NODE, &cfg_trx_rsl_e1_tei_cmd); |
Harald Welte | 68628e8 | 2009-03-10 12:17:57 +0000 | [diff] [blame] | 1434 | |
Harald Welte | 5258fc4 | 2009-03-28 19:07:53 +0000 | [diff] [blame] | 1435 | install_element(TRX_NODE, &cfg_ts_cmd); |
Harald Welte | 68628e8 | 2009-03-10 12:17:57 +0000 | [diff] [blame] | 1436 | install_node(&ts_node, dummy_config_write); |
Harald Welte | 68628e8 | 2009-03-10 12:17:57 +0000 | [diff] [blame] | 1437 | install_default(TS_NODE); |
Harald Welte | a6fd58e | 2009-08-07 00:25:23 +0200 | [diff] [blame] | 1438 | install_element(TS_NODE, &cfg_ts_pchan_cmd); |
| 1439 | install_element(TS_NODE, &cfg_ts_e1_subslot_cmd); |
Harald Welte | 68628e8 | 2009-03-10 12:17:57 +0000 | [diff] [blame] | 1440 | |
Harald Welte | 40f8289 | 2009-05-23 17:31:39 +0000 | [diff] [blame] | 1441 | install_element(CONFIG_NODE, &cfg_subscr_cmd); |
| 1442 | install_node(&subscr_node, dummy_config_write); |
| 1443 | install_default(SUBSCR_NODE); |
| 1444 | install_element(SUBSCR_NODE, &cfg_subscr_name_cmd); |
| 1445 | install_element(SUBSCR_NODE, &cfg_subscr_extension_cmd); |
| 1446 | install_element(SUBSCR_NODE, &cfg_subscr_authorized_cmd); |
| 1447 | |
Harald Welte | 68628e8 | 2009-03-10 12:17:57 +0000 | [diff] [blame] | 1448 | return 0; |
| 1449 | } |