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