blob: 55eeb14154170d9b731a6f3edd956d506e8e626d [file] [log] [blame]
Harald Welte68628e82009-03-10 12:17:57 +00001/* OpenBSC interface to quagga VTY */
Harald Welteaf387632010-03-14 23:30:30 +08002/* (C) 2009-2010 by Harald Welte <laforge@gnumonks.org>
Harald Welte68628e82009-03-10 12:17:57 +00003 * All Rights Reserved
4 *
5 * This program is free software; you can redistribute it and/or modify
Harald Welte9af6ddf2011-01-01 15:25:50 +01006 * it under the terms of the GNU Affero General Public License as published by
7 * the Free Software Foundation; either version 3 of the License, or
Harald Welte68628e82009-03-10 12:17:57 +00008 * (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
Harald Welte9af6ddf2011-01-01 15:25:50 +010013 * GNU Affero General Public License for more details.
Harald Welte68628e82009-03-10 12:17:57 +000014 *
Harald Welte9af6ddf2011-01-01 15:25:50 +010015 * You should have received a copy of the GNU Affero General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
Harald Welte68628e82009-03-10 12:17:57 +000017 *
18 */
19
20#include <stdlib.h>
21#include <unistd.h>
22#include <sys/types.h>
23
Harald Welte4b037e42010-05-19 19:45:32 +020024#include <osmocom/vty/command.h>
25#include <osmocom/vty/buffer.h>
26#include <osmocom/vty/vty.h>
27#include <osmocom/vty/logging.h>
28#include <osmocom/vty/telnet_interface.h>
Harald Welte68628e82009-03-10 12:17:57 +000029
30#include <arpa/inet.h>
31
Harald Weltedfe6c7d2010-02-20 16:24:02 +010032#include <osmocore/linuxlist.h>
Harald Welte68628e82009-03-10 12:17:57 +000033#include <openbsc/gsm_data.h>
Harald Welte68628e82009-03-10 12:17:57 +000034#include <openbsc/e1_input.h>
Harald Welte1bc77352009-03-10 19:47:51 +000035#include <openbsc/abis_nm.h>
Harald Welte9fbff4a2010-07-30 11:50:09 +020036#include <osmocore/utils.h>
Harald Weltedfe6c7d2010-02-20 16:24:02 +010037#include <osmocore/gsm_utils.h>
Harald Welteb908cb72009-12-22 13:09:29 +010038#include <openbsc/chan_alloc.h>
Harald Welte8387a492009-12-22 21:43:14 +010039#include <openbsc/meas_rep.h>
Harald Welte40f82892009-05-23 17:31:39 +000040#include <openbsc/db.h>
Harald Weltedfe6c7d2010-02-20 16:24:02 +010041#include <osmocore/talloc.h>
Holger Hans Peter Freyther3c712322010-04-06 11:55:37 +020042#include <openbsc/vty.h>
Harald Welte22229d62010-05-12 20:28:04 +020043#include <openbsc/gprs_ns.h>
Harald Welte9fbff4a2010-07-30 11:50:09 +020044#include <openbsc/system_information.h>
Harald Welte5bc61dc2010-05-16 22:02:16 +020045#include <openbsc/debug.h>
Holger Hans Peter Freyther85334f12010-11-09 17:00:42 +010046#include <openbsc/paging.h>
Holger Hans Peter Freytherdab8e272010-11-15 20:29:46 +010047#include <openbsc/ipaccess.h>
Harald Welted0d2b0b2010-12-23 13:18:07 +010048#include <openbsc/abis_rsl.h>
Harald Welte68628e82009-03-10 12:17:57 +000049
Harald Welte1353f962010-05-16 19:20:24 +020050#include "../bscconfig.h"
51
Harald Welteea4647d2010-05-12 17:19:53 +000052/* FIXME: this should go to some common file */
53static const struct value_string gprs_ns_timer_strs[] = {
Harald Welte615e9562010-05-11 23:50:21 +020054 { 0, "tns-block" },
55 { 1, "tns-block-retries" },
56 { 2, "tns-reset" },
57 { 3, "tns-reset-retries" },
58 { 4, "tns-test" },
59 { 5, "tns-alive" },
60 { 6, "tns-alive-retries" },
61 { 0, NULL }
62};
63
Harald Welteea4647d2010-05-12 17:19:53 +000064static const struct value_string gprs_bssgp_cfg_strs[] = {
Harald Welte615e9562010-05-11 23:50:21 +020065 { 0, "blocking-timer" },
66 { 1, "blocking-retries" },
67 { 2, "unblocking-retries" },
68 { 3, "reset-timer" },
69 { 4, "reset-retries" },
70 { 5, "suspend-timer" },
71 { 6, "suspend-retries" },
72 { 7, "resume-timer" },
73 { 8, "resume-retries" },
74 { 9, "capability-update-timer" },
75 { 10, "capability-update-retries" },
76 { 0, NULL }
77};
78
Harald Welte5013b2a2009-08-07 13:29:14 +020079struct cmd_node net_node = {
80 GSMNET_NODE,
81 "%s(network)#",
82 1,
83};
84
Harald Welte68628e82009-03-10 12:17:57 +000085struct cmd_node bts_node = {
86 BTS_NODE,
87 "%s(bts)#",
88 1,
89};
90
91struct cmd_node trx_node = {
92 TRX_NODE,
93 "%s(trx)#",
94 1,
95};
96
97struct cmd_node ts_node = {
98 TS_NODE,
99 "%s(ts)#",
100 1,
101};
102
Harald Welte39231152010-05-27 13:39:40 +0200103extern struct gsm_network *bsc_gsmnet;
104
Harald Weltedcccb182010-05-16 20:52:23 +0200105struct gsm_network *gsmnet_from_vty(struct vty *v)
106{
Harald Welte39231152010-05-27 13:39:40 +0200107 /* In case we read from the config file, the vty->priv cannot
108 * point to a struct telnet_connection, and thus conn->priv
109 * will not point to the gsm_network structure */
110#if 0
Harald Weltedcccb182010-05-16 20:52:23 +0200111 struct telnet_connection *conn = v->priv;
112 return (struct gsm_network *) conn->priv;
Harald Welte39231152010-05-27 13:39:40 +0200113#else
114 return bsc_gsmnet;
115#endif
Harald Weltedcccb182010-05-16 20:52:23 +0200116}
117
Harald Welte68628e82009-03-10 12:17:57 +0000118static int dummy_config_write(struct vty *v)
119{
120 return CMD_SUCCESS;
121}
122
123static void net_dump_nmstate(struct vty *vty, struct gsm_nm_state *nms)
124{
Harald Welte1bc77352009-03-10 19:47:51 +0000125 vty_out(vty,"Oper '%s', Admin %u, Avail '%s'%s",
126 nm_opstate_name(nms->operational), nms->administrative,
127 nm_avail_name(nms->availability), VTY_NEWLINE);
Harald Welte68628e82009-03-10 12:17:57 +0000128}
129
Harald Welteb908cb72009-12-22 13:09:29 +0100130static void dump_pchan_load_vty(struct vty *vty, char *prefix,
131 const struct pchan_load *pl)
132{
133 int i;
134
135 for (i = 0; i < ARRAY_SIZE(pl->pchan); i++) {
136 const struct load_counter *lc = &pl->pchan[i];
137 unsigned int percent;
138
139 if (lc->total == 0)
140 continue;
141
142 percent = (lc->used * 100) / lc->total;
143
144 vty_out(vty, "%s%20s: %3u%% (%u/%u)%s", prefix,
145 gsm_pchan_name(i), percent, lc->used, lc->total,
146 VTY_NEWLINE);
147 }
148}
149
Harald Welte68628e82009-03-10 12:17:57 +0000150static void net_dump_vty(struct vty *vty, struct gsm_network *net)
151{
Harald Welteb908cb72009-12-22 13:09:29 +0100152 struct pchan_load pl;
153
Harald Welteef235b52009-03-10 12:34:02 +0000154 vty_out(vty, "BSC is on Country Code %u, Network Code %u "
155 "and has %u BTS%s", net->country_code, net->network_code,
156 net->num_bts, VTY_NEWLINE);
Harald Welte1bc77352009-03-10 19:47:51 +0000157 vty_out(vty, " Long network name: '%s'%s",
Harald Welte68628e82009-03-10 12:17:57 +0000158 net->name_long, VTY_NEWLINE);
Harald Welte1bc77352009-03-10 19:47:51 +0000159 vty_out(vty, " Short network name: '%s'%s",
Harald Welte68628e82009-03-10 12:17:57 +0000160 net->name_short, VTY_NEWLINE);
Harald Welte (local)69de3972009-08-12 14:42:23 +0200161 vty_out(vty, " Authentication policy: %s%s",
162 gsm_auth_policy_name(net->auth_policy), VTY_NEWLINE);
Harald Welte1085c092009-11-18 20:33:19 +0100163 vty_out(vty, " Location updating reject cause: %u%s",
164 net->reject_cause, VTY_NEWLINE);
Harald Welte4381cfe2009-08-30 15:47:06 +0900165 vty_out(vty, " Encryption: A5/%u%s", net->a5_encryption,
166 VTY_NEWLINE);
Holger Hans Peter Freytherf7d752f2009-11-16 17:12:38 +0100167 vty_out(vty, " NECI (TCH/H): %u%s", net->neci,
168 VTY_NEWLINE);
Holger Hans Peter Freyther76fc4a32010-09-06 09:41:50 +0800169 vty_out(vty, " Use TCH for Paging any: %d%s", net->pag_any_tch,
170 VTY_NEWLINE);
Harald Welteeab84a12009-12-13 10:53:12 +0100171 vty_out(vty, " RRLP Mode: %s%s", rrlp_mode_name(net->rrlp.mode),
172 VTY_NEWLINE);
Harald Welte648b6ce2009-12-14 09:00:24 +0100173 vty_out(vty, " MM Info: %s%s", net->send_mm_info ? "On" : "Off",
174 VTY_NEWLINE);
Harald Weltebc814502009-12-19 21:41:52 +0100175 vty_out(vty, " Handover: %s%s", net->handover.active ? "On" : "Off",
176 VTY_NEWLINE);
Harald Welteb908cb72009-12-22 13:09:29 +0100177 network_chan_load(&pl, net);
178 vty_out(vty, " Current Channel Load:%s", VTY_NEWLINE);
179 dump_pchan_load_vty(vty, " ", &pl);
Harald Welte68628e82009-03-10 12:17:57 +0000180}
181
182DEFUN(show_net, show_net_cmd, "show network",
183 SHOW_STR "Display information about a GSM NETWORK\n")
184{
Harald Weltedcccb182010-05-16 20:52:23 +0200185 struct gsm_network *net = gsmnet_from_vty(vty);
Harald Welte68628e82009-03-10 12:17:57 +0000186 net_dump_vty(vty, net);
187
188 return CMD_SUCCESS;
189}
190
191static void e1isl_dump_vty(struct vty *vty, struct e1inp_sign_link *e1l)
192{
Harald Welteedb37782009-05-01 14:59:07 +0000193 struct e1inp_line *line;
194
195 if (!e1l) {
196 vty_out(vty, " None%s", VTY_NEWLINE);
197 return;
198 }
199
200 line = e1l->ts->line;
201
202 vty_out(vty, " E1 Line %u, Type %s: Timeslot %u, Mode %s%s",
203 line->num, line->driver->name, e1l->ts->num,
Harald Welte1bc77352009-03-10 19:47:51 +0000204 e1inp_signtype_name(e1l->type), VTY_NEWLINE);
Harald Welteedb37782009-05-01 14:59:07 +0000205 vty_out(vty, " E1 TEI %u, SAPI %u%s",
Harald Welte68628e82009-03-10 12:17:57 +0000206 e1l->tei, e1l->sapi, VTY_NEWLINE);
207}
208
209static void bts_dump_vty(struct vty *vty, struct gsm_bts *bts)
210{
Harald Welteb908cb72009-12-22 13:09:29 +0100211 struct pchan_load pl;
212
Holger Hans Peter Freytherc4a49e32009-08-21 14:44:12 +0200213 vty_out(vty, "BTS %u is of %s type in band %s, has CI %u LAC %u, "
Harald Weltefcd24452009-06-20 18:15:19 +0200214 "BSIC %u, TSC %u and %u TRX%s",
215 bts->nr, btstype2str(bts->type), gsm_band_name(bts->band),
Holger Hans Peter Freytherc4a49e32009-08-21 14:44:12 +0200216 bts->cell_identity,
Holger Hans Peter Freytheracf8a0c2010-03-29 08:47:44 +0200217 bts->location_area_code, bts->bsic, bts->tsc,
Harald Weltefcd24452009-06-20 18:15:19 +0200218 bts->num_trx, VTY_NEWLINE);
Harald Welte197dea92010-05-14 17:59:53 +0200219 vty_out(vty, "Description: %s%s",
220 bts->description ? bts->description : "(null)", VTY_NEWLINE);
Harald Welte1d8dbc42009-12-12 15:38:16 +0100221 vty_out(vty, "MS Max power: %u dBm%s", bts->ms_max_power, VTY_NEWLINE);
Harald Welte73225282009-12-12 18:17:25 +0100222 vty_out(vty, "Minimum Rx Level for Access: %i dBm%s",
Harald Welte1d8dbc42009-12-12 15:38:16 +0100223 rxlev2dbm(bts->si_common.cell_sel_par.rxlev_acc_min),
224 VTY_NEWLINE);
225 vty_out(vty, "Cell Reselection Hysteresis: %u dBm%s",
Harald Welte73225282009-12-12 18:17:25 +0100226 bts->si_common.cell_sel_par.cell_resel_hyst*2, VTY_NEWLINE);
Sylvain Munaut4010f1e2009-12-22 13:43:26 +0100227 vty_out(vty, "RACH TX-Integer: %u%s", bts->si_common.rach_control.tx_integer,
228 VTY_NEWLINE);
229 vty_out(vty, "RACH Max transmissions: %u%s",
230 rach_max_trans_raw2val(bts->si_common.rach_control.max_trans),
231 VTY_NEWLINE);
Harald Welte71355012009-12-21 23:08:18 +0100232 if (bts->si_common.rach_control.cell_bar)
Harald Welte (local)5dececf2009-08-12 13:28:23 +0200233 vty_out(vty, " CELL IS BARRED%s", VTY_NEWLINE);
Harald Welte9fbff4a2010-07-30 11:50:09 +0200234 vty_out(vty, "System Information present: 0x%08x, static: 0x%08x%s",
235 bts->si_valid, bts->si_mode_static, VTY_NEWLINE);
Harald Welte4cc34222009-05-01 15:12:31 +0000236 if (is_ipaccess_bts(bts))
Harald Welte8175e952009-10-20 00:22:00 +0200237 vty_out(vty, " Unit ID: %u/%u/0, OML Stream ID 0x%02x%s",
Harald Welte4cc34222009-05-01 15:12:31 +0000238 bts->ip_access.site_id, bts->ip_access.bts_id,
Harald Welte8175e952009-10-20 00:22:00 +0200239 bts->oml_tei, VTY_NEWLINE);
Harald Welte68628e82009-03-10 12:17:57 +0000240 vty_out(vty, " NM State: ");
241 net_dump_nmstate(vty, &bts->nm_state);
242 vty_out(vty, " Site Mgr NM State: ");
243 net_dump_nmstate(vty, &bts->site_mgr.nm_state);
244 vty_out(vty, " Paging: FIXME pending requests, %u free slots%s",
245 bts->paging.available_slots, VTY_NEWLINE);
Holger Hans Peter Freytherd283db42010-11-25 16:28:45 +0100246 if (is_ipaccess_bts(bts)) {
247 vty_out(vty, " OML Link state: %s.%s",
248 bts->oml_link ? "connected" : "disconnected", VTY_NEWLINE);
249 } else {
Harald Welte8175e952009-10-20 00:22:00 +0200250 vty_out(vty, " E1 Signalling Link:%s", VTY_NEWLINE);
251 e1isl_dump_vty(vty, bts->oml_link);
252 }
Holger Hans Peter Freytherd283db42010-11-25 16:28:45 +0100253
254 /* FIXME: chan_desc */
Harald Welteb908cb72009-12-22 13:09:29 +0100255 memset(&pl, 0, sizeof(pl));
256 bts_chan_load(&pl, bts);
257 vty_out(vty, " Current Channel Load:%s", VTY_NEWLINE);
258 dump_pchan_load_vty(vty, " ", &pl);
Harald Welte68628e82009-03-10 12:17:57 +0000259}
260
261DEFUN(show_bts, show_bts_cmd, "show bts [number]",
262 SHOW_STR "Display information about a BTS\n"
263 "BTS number")
264{
Harald Weltedcccb182010-05-16 20:52:23 +0200265 struct gsm_network *net = gsmnet_from_vty(vty);
Harald Welte68628e82009-03-10 12:17:57 +0000266 int bts_nr;
267
268 if (argc != 0) {
269 /* use the BTS number that the user has specified */
270 bts_nr = atoi(argv[0]);
Harald Welte712ddbc2010-12-24 12:24:03 +0100271 if (bts_nr >= net->num_bts) {
Harald Welte1bc77352009-03-10 19:47:51 +0000272 vty_out(vty, "%% can't find BTS '%s'%s", argv[0],
Harald Welte68628e82009-03-10 12:17:57 +0000273 VTY_NEWLINE);
274 return CMD_WARNING;
275 }
Harald Weltee441d9c2009-06-21 16:17:15 +0200276 bts_dump_vty(vty, gsm_bts_num(net, bts_nr));
Harald Welte68628e82009-03-10 12:17:57 +0000277 return CMD_SUCCESS;
278 }
279 /* print all BTS's */
280 for (bts_nr = 0; bts_nr < net->num_bts; bts_nr++)
Harald Weltee441d9c2009-06-21 16:17:15 +0200281 bts_dump_vty(vty, gsm_bts_num(net, bts_nr));
Harald Welte68628e82009-03-10 12:17:57 +0000282
283 return CMD_SUCCESS;
284}
285
Harald Welte42581822009-08-08 16:12:58 +0200286/* utility functions */
287static void parse_e1_link(struct gsm_e1_subslot *e1_link, const char *line,
288 const char *ts, const char *ss)
289{
290 e1_link->e1_nr = atoi(line);
291 e1_link->e1_ts = atoi(ts);
292 if (!strcmp(ss, "full"))
293 e1_link->e1_ts_ss = 255;
294 else
295 e1_link->e1_ts_ss = atoi(ss);
296}
297
298static void config_write_e1_link(struct vty *vty, struct gsm_e1_subslot *e1_link,
299 const char *prefix)
300{
301 if (!e1_link->e1_ts)
302 return;
303
304 if (e1_link->e1_ts_ss == 255)
305 vty_out(vty, "%se1 line %u timeslot %u sub-slot full%s",
306 prefix, e1_link->e1_nr, e1_link->e1_ts, VTY_NEWLINE);
307 else
308 vty_out(vty, "%se1 line %u timeslot %u sub-slot %u%s",
309 prefix, e1_link->e1_nr, e1_link->e1_ts,
310 e1_link->e1_ts_ss, VTY_NEWLINE);
311}
312
313
Harald Welte67ce0732009-08-06 19:06:46 +0200314static void config_write_ts_single(struct vty *vty, struct gsm_bts_trx_ts *ts)
315{
Harald Welte42581822009-08-08 16:12:58 +0200316 vty_out(vty, " timeslot %u%s", ts->nr, VTY_NEWLINE);
317 if (ts->pchan != GSM_PCHAN_NONE)
318 vty_out(vty, " phys_chan_config %s%s",
319 gsm_pchan_name(ts->pchan), VTY_NEWLINE);
Harald Weltea39b0f22010-06-14 22:26:10 +0200320 vty_out(vty, " hopping enabled %u%s",
321 ts->hopping.enabled, VTY_NEWLINE);
322 if (ts->hopping.enabled) {
323 unsigned int i;
324 vty_out(vty, " hopping sequence-number %u%s",
Harald Welte6e0cd042009-09-12 13:05:33 +0200325 ts->hopping.hsn, VTY_NEWLINE);
Harald Weltea39b0f22010-06-14 22:26:10 +0200326 vty_out(vty, " hopping maio %u%s",
Harald Welte6e0cd042009-09-12 13:05:33 +0200327 ts->hopping.maio, VTY_NEWLINE);
Harald Weltea39b0f22010-06-14 22:26:10 +0200328 for (i = 0; i < ts->hopping.arfcns.data_len*8; i++) {
329 if (!bitvec_get_bit_pos(&ts->hopping.arfcns, i))
330 continue;
331 vty_out(vty, " hopping arfcn add %u%s",
332 i, VTY_NEWLINE);
333 }
Harald Welte127af342010-12-24 12:07:07 +0100334 }
Harald Welte42581822009-08-08 16:12:58 +0200335 config_write_e1_link(vty, &ts->e1_link, " ");
Harald Welteface7ed2011-02-14 16:15:21 +0100336
337 if (ts->trx->bts->model->config_write_ts)
338 ts->trx->bts->model->config_write_ts(vty, ts);
Harald Welte67ce0732009-08-06 19:06:46 +0200339}
340
341static void config_write_trx_single(struct vty *vty, struct gsm_bts_trx *trx)
342{
343 int i;
344
Harald Welte5013b2a2009-08-07 13:29:14 +0200345 vty_out(vty, " trx %u%s", trx->nr, VTY_NEWLINE);
Harald Welte197dea92010-05-14 17:59:53 +0200346 if (trx->description)
347 vty_out(vty, " description %s%s", trx->description,
348 VTY_NEWLINE);
Holger Hans Peter Freyther2ba40af2010-04-17 06:42:07 +0200349 vty_out(vty, " rf_locked %u%s",
350 trx->nm_state.administrative == NM_STATE_LOCKED ? 1 : 0,
351 VTY_NEWLINE);
Harald Welte5013b2a2009-08-07 13:29:14 +0200352 vty_out(vty, " arfcn %u%s", trx->arfcn, VTY_NEWLINE);
Harald Welte (local)7b37d972009-12-27 20:56:38 +0100353 vty_out(vty, " nominal power %u%s", trx->nominal_power, VTY_NEWLINE);
Harald Welte5013b2a2009-08-07 13:29:14 +0200354 vty_out(vty, " max_power_red %u%s", trx->max_power_red, VTY_NEWLINE);
Harald Welte42581822009-08-08 16:12:58 +0200355 config_write_e1_link(vty, &trx->rsl_e1_link, " rsl ");
356 vty_out(vty, " rsl e1 tei %u%s", trx->rsl_tei, VTY_NEWLINE);
Harald Welte67ce0732009-08-06 19:06:46 +0200357
Harald Welteface7ed2011-02-14 16:15:21 +0100358 if (trx->bts->model->config_write_trx)
359 trx->bts->model->config_write_trx(vty, trx);
360
Harald Welte67ce0732009-08-06 19:06:46 +0200361 for (i = 0; i < TRX_NR_TS; i++)
362 config_write_ts_single(vty, &trx->ts[i]);
363}
364
Harald Welte615e9562010-05-11 23:50:21 +0200365static void config_write_bts_gprs(struct vty *vty, struct gsm_bts *bts)
366{
367 unsigned int i;
368 vty_out(vty, " gprs mode %s%s", bts_gprs_mode_name(bts->gprs.mode),
369 VTY_NEWLINE);
370 if (bts->gprs.mode == BTS_GPRS_NONE)
371 return;
372
373 vty_out(vty, " gprs routing area %u%s", bts->gprs.rac,
374 VTY_NEWLINE);
375 vty_out(vty, " gprs cell bvci %u%s", bts->gprs.cell.bvci,
376 VTY_NEWLINE);
377 for (i = 0; i < ARRAY_SIZE(bts->gprs.cell.timer); i++)
378 vty_out(vty, " gprs cell timer %s %u%s",
379 get_value_string(gprs_bssgp_cfg_strs, i),
380 bts->gprs.cell.timer[i], VTY_NEWLINE);
381 vty_out(vty, " gprs nsei %u%s", bts->gprs.nse.nsei,
382 VTY_NEWLINE);
383 for (i = 0; i < ARRAY_SIZE(bts->gprs.nse.timer); i++)
384 vty_out(vty, " gprs ns timer %s %u%s",
385 get_value_string(gprs_ns_timer_strs, i),
386 bts->gprs.nse.timer[i], VTY_NEWLINE);
387 for (i = 0; i < ARRAY_SIZE(bts->gprs.nsvc); i++) {
388 struct gsm_bts_gprs_nsvc *nsvc =
389 &bts->gprs.nsvc[i];
390 struct in_addr ia;
391
392 ia.s_addr = htonl(nsvc->remote_ip);
393 vty_out(vty, " gprs nsvc %u nsvci %u%s", i,
394 nsvc->nsvci, VTY_NEWLINE);
395 vty_out(vty, " gprs nsvc %u local udp port %u%s", i,
396 nsvc->local_port, VTY_NEWLINE);
397 vty_out(vty, " gprs nsvc %u remote udp port %u%s", i,
398 nsvc->remote_port, VTY_NEWLINE);
399 vty_out(vty, " gprs nsvc %u remote ip %s%s", i,
400 inet_ntoa(ia), VTY_NEWLINE);
401 }
402}
403
Harald Welte67ce0732009-08-06 19:06:46 +0200404static void config_write_bts_single(struct vty *vty, struct gsm_bts *bts)
405{
406 struct gsm_bts_trx *trx;
Harald Welte9fbff4a2010-07-30 11:50:09 +0200407 int i;
Harald Welte67ce0732009-08-06 19:06:46 +0200408
Harald Welte5013b2a2009-08-07 13:29:14 +0200409 vty_out(vty, " bts %u%s", bts->nr, VTY_NEWLINE);
410 vty_out(vty, " type %s%s", btstype2str(bts->type), VTY_NEWLINE);
Harald Welte197dea92010-05-14 17:59:53 +0200411 if (bts->description)
412 vty_out(vty, " description %s%s", bts->description, VTY_NEWLINE);
Harald Welte5013b2a2009-08-07 13:29:14 +0200413 vty_out(vty, " band %s%s", gsm_band_name(bts->band), VTY_NEWLINE);
Holger Hans Peter Freytherf926ed62009-11-19 16:38:49 +0100414 vty_out(vty, " cell_identity %u%s", bts->cell_identity, VTY_NEWLINE);
Harald Welte5013b2a2009-08-07 13:29:14 +0200415 vty_out(vty, " location_area_code %u%s", bts->location_area_code,
Harald Welte67ce0732009-08-06 19:06:46 +0200416 VTY_NEWLINE);
Harald Welte5013b2a2009-08-07 13:29:14 +0200417 vty_out(vty, " training_sequence_code %u%s", bts->tsc, VTY_NEWLINE);
418 vty_out(vty, " base_station_id_code %u%s", bts->bsic, VTY_NEWLINE);
Harald Welte (local)0e451d02009-08-13 10:14:26 +0200419 vty_out(vty, " ms max power %u%s", bts->ms_max_power, VTY_NEWLINE);
Harald Welte73225282009-12-12 18:17:25 +0100420 vty_out(vty, " cell reselection hysteresis %u%s",
421 bts->si_common.cell_sel_par.cell_resel_hyst*2, VTY_NEWLINE);
422 vty_out(vty, " rxlev access min %u%s",
423 bts->si_common.cell_sel_par.rxlev_acc_min, VTY_NEWLINE);
Sylvain Munaute0b06b02010-11-28 18:17:28 +0100424
425 if (bts->si_common.cell_ro_sel_par.present) {
426 struct gsm48_si_selection_params *sp;
427 sp = &bts->si_common.cell_ro_sel_par;
428
429 if (sp->cbq)
430 vty_out(vty, " cell bar qualify %u%s",
431 sp->cbq, VTY_NEWLINE);
432
433 if (sp->cell_resel_off)
434 vty_out(vty, " cell reselection offset %u%s",
435 sp->cell_resel_off*2, VTY_NEWLINE);
436
437 if (sp->temp_offs == 7)
438 vty_out(vty, " temporary offset infinite%s",
439 VTY_NEWLINE);
440 else if (sp->temp_offs)
441 vty_out(vty, " temporary offset %u%s",
442 sp->temp_offs*10, VTY_NEWLINE);
443
444 if (sp->penalty_time == 31)
445 vty_out(vty, " penalty time reserved%s",
446 VTY_NEWLINE);
447 else if (sp->penalty_time)
448 vty_out(vty, " penalty time %u%s",
449 (sp->penalty_time*20)+20, VTY_NEWLINE);
450 }
451
Harald Weltea43f7892009-12-01 18:04:30 +0530452 if (bts->si_common.chan_desc.t3212)
Harald Welte (local)efc92312009-08-14 23:09:25 +0200453 vty_out(vty, " periodic location update %u%s",
Dieter Spaard6613e02010-10-05 21:10:55 +0200454 bts->si_common.chan_desc.t3212 * 6, VTY_NEWLINE);
Harald Welte7a8fa412009-08-10 13:48:16 +0200455 vty_out(vty, " channel allocator %s%s",
456 bts->chan_alloc_reverse ? "descending" : "ascending",
457 VTY_NEWLINE);
Sylvain Munaut4010f1e2009-12-22 13:43:26 +0100458 vty_out(vty, " rach tx integer %u%s",
459 bts->si_common.rach_control.tx_integer, VTY_NEWLINE);
460 vty_out(vty, " rach max transmission %u%s",
461 rach_max_trans_raw2val(bts->si_common.rach_control.max_trans),
462 VTY_NEWLINE);
Holger Hans Peter Freyther95c22902010-04-25 23:08:39 +0800463
464 if (bts->rach_b_thresh != -1)
465 vty_out(vty, " rach nm busy threshold %u%s",
466 bts->rach_b_thresh, VTY_NEWLINE);
467 if (bts->rach_ldavg_slots != -1)
468 vty_out(vty, " rach nm load average %u%s",
469 bts->rach_ldavg_slots, VTY_NEWLINE);
Harald Welte71355012009-12-21 23:08:18 +0100470 if (bts->si_common.rach_control.cell_bar)
Harald Welte (local)5dececf2009-08-12 13:28:23 +0200471 vty_out(vty, " cell barred 1%s", VTY_NEWLINE);
Holger Hans Peter Freyther3a0a4632010-05-14 00:39:19 +0800472 if ((bts->si_common.rach_control.t2 & 0x4) == 0)
473 vty_out(vty, " rach emergency call allowed 1%s", VTY_NEWLINE);
Harald Welte9fbff4a2010-07-30 11:50:09 +0200474 for (i = SYSINFO_TYPE_1; i < _MAX_SYSINFO_TYPE; i++) {
475 if (bts->si_mode_static & (1 << i)) {
476 vty_out(vty, " system-information %s mode static%s",
477 get_value_string(osmo_sitype_strs, i), VTY_NEWLINE);
478 vty_out(vty, " system-information %s static %s%s",
479 get_value_string(osmo_sitype_strs, i),
480 hexdump_nospc(bts->si_buf[i], sizeof(bts->si_buf[i])),
481 VTY_NEWLINE);
482 }
483 }
Harald Welte8175e952009-10-20 00:22:00 +0200484 if (is_ipaccess_bts(bts)) {
Harald Welte5013b2a2009-08-07 13:29:14 +0200485 vty_out(vty, " ip.access unit_id %u %u%s",
Harald Weltea6fd58e2009-08-07 00:25:23 +0200486 bts->ip_access.site_id, bts->ip_access.bts_id, VTY_NEWLINE);
Harald Welte8175e952009-10-20 00:22:00 +0200487 vty_out(vty, " oml ip.access stream_id %u%s", bts->oml_tei, VTY_NEWLINE);
488 } else {
Harald Welte42581822009-08-08 16:12:58 +0200489 config_write_e1_link(vty, &bts->oml_e1_link, " oml ");
490 vty_out(vty, " oml e1 tei %u%s", bts->oml_tei, VTY_NEWLINE);
491 }
Holger Hans Peter Freythere66bf1f2010-09-06 10:11:25 +0800492
493 /* if we have a limit, write it */
494 if (bts->paging.free_chans_need >= 0)
495 vty_out(vty, " paging free %d%s", bts->paging.free_chans_need, VTY_NEWLINE);
496
Harald Welte32c09622011-01-11 23:44:56 +0100497 vty_out(vty, " neighbor-list mode %s%s",
498 bts->neigh_list_manual_mode ? "manual" : "automatic", VTY_NEWLINE);
499 if (bts->neigh_list_manual_mode) {
500 for (i = 0; i < 1024; i++) {
501 if (bitvec_get_bit_pos(&bts->si_common.neigh_list, i))
502 vty_out(vty, " neighbor-list add arfcn %u%s",
503 i, VTY_NEWLINE);
504 }
505 }
506
Harald Welte615e9562010-05-11 23:50:21 +0200507 config_write_bts_gprs(vty, bts);
Harald Welte67ce0732009-08-06 19:06:46 +0200508
Harald Welteface7ed2011-02-14 16:15:21 +0100509 if (bts->model->config_write_bts)
510 bts->model->config_write_bts(vty, bts);
511
Harald Welte67ce0732009-08-06 19:06:46 +0200512 llist_for_each_entry(trx, &bts->trx_list, list)
513 config_write_trx_single(vty, trx);
514}
515
516static int config_write_bts(struct vty *v)
517{
Harald Weltedcccb182010-05-16 20:52:23 +0200518 struct gsm_network *gsmnet = gsmnet_from_vty(v);
Harald Welte67ce0732009-08-06 19:06:46 +0200519 struct gsm_bts *bts;
520
521 llist_for_each_entry(bts, &gsmnet->bts_list, list)
522 config_write_bts_single(v, bts);
523
524 return CMD_SUCCESS;
525}
526
Harald Welte5013b2a2009-08-07 13:29:14 +0200527static int config_write_net(struct vty *vty)
528{
Harald Weltedcccb182010-05-16 20:52:23 +0200529 struct gsm_network *gsmnet = gsmnet_from_vty(vty);
530
Harald Welte5013b2a2009-08-07 13:29:14 +0200531 vty_out(vty, "network%s", VTY_NEWLINE);
Harald Welte42581822009-08-08 16:12:58 +0200532 vty_out(vty, " network country code %u%s", gsmnet->country_code, VTY_NEWLINE);
Harald Welte5013b2a2009-08-07 13:29:14 +0200533 vty_out(vty, " mobile network code %u%s", gsmnet->network_code, VTY_NEWLINE);
Harald Welte42581822009-08-08 16:12:58 +0200534 vty_out(vty, " short name %s%s", gsmnet->name_short, VTY_NEWLINE);
535 vty_out(vty, " long name %s%s", gsmnet->name_long, VTY_NEWLINE);
Harald Welte (local)69de3972009-08-12 14:42:23 +0200536 vty_out(vty, " auth policy %s%s", gsm_auth_policy_name(gsmnet->auth_policy), VTY_NEWLINE);
Harald Welte1085c092009-11-18 20:33:19 +0100537 vty_out(vty, " location updating reject cause %u%s",
538 gsmnet->reject_cause, VTY_NEWLINE);
Harald Welte4381cfe2009-08-30 15:47:06 +0900539 vty_out(vty, " encryption a5 %u%s", gsmnet->a5_encryption, VTY_NEWLINE);
Holger Hans Peter Freytherd54c3372009-11-19 16:37:48 +0100540 vty_out(vty, " neci %u%s", gsmnet->neci, VTY_NEWLINE);
Holger Hans Peter Freyther76fc4a32010-09-06 09:41:50 +0800541 vty_out(vty, " paging any use tch %d%s", gsmnet->pag_any_tch, VTY_NEWLINE);
Harald Welteeab84a12009-12-13 10:53:12 +0100542 vty_out(vty, " rrlp mode %s%s", rrlp_mode_name(gsmnet->rrlp.mode),
543 VTY_NEWLINE);
Harald Welte648b6ce2009-12-14 09:00:24 +0100544 vty_out(vty, " mm info %u%s", gsmnet->send_mm_info, VTY_NEWLINE);
Harald Weltebc814502009-12-19 21:41:52 +0100545 vty_out(vty, " handover %u%s", gsmnet->handover.active, VTY_NEWLINE);
Harald Welteb720bd32009-12-21 16:51:50 +0100546 vty_out(vty, " handover window rxlev averaging %u%s",
547 gsmnet->handover.win_rxlev_avg, VTY_NEWLINE);
548 vty_out(vty, " handover window rxqual averaging %u%s",
549 gsmnet->handover.win_rxqual_avg, VTY_NEWLINE);
550 vty_out(vty, " handover window rxlev neighbor averaging %u%s",
551 gsmnet->handover.win_rxlev_avg_neigh, VTY_NEWLINE);
552 vty_out(vty, " handover power budget interval %u%s",
553 gsmnet->handover.pwr_interval, VTY_NEWLINE);
554 vty_out(vty, " handover power budget hysteresis %u%s",
555 gsmnet->handover.pwr_hysteresis, VTY_NEWLINE);
556 vty_out(vty, " handover maximum distance %u%s",
557 gsmnet->handover.max_distance, VTY_NEWLINE);
Holger Hans Peter Freytherc4d88ad2009-11-21 21:18:38 +0100558 vty_out(vty, " timer t3101 %u%s", gsmnet->T3101, VTY_NEWLINE);
Holger Hans Peter Freyther23975e72009-11-21 21:42:26 +0100559 vty_out(vty, " timer t3103 %u%s", gsmnet->T3103, VTY_NEWLINE);
560 vty_out(vty, " timer t3105 %u%s", gsmnet->T3105, VTY_NEWLINE);
561 vty_out(vty, " timer t3107 %u%s", gsmnet->T3107, VTY_NEWLINE);
562 vty_out(vty, " timer t3109 %u%s", gsmnet->T3109, VTY_NEWLINE);
563 vty_out(vty, " timer t3111 %u%s", gsmnet->T3111, VTY_NEWLINE);
564 vty_out(vty, " timer t3113 %u%s", gsmnet->T3113, VTY_NEWLINE);
565 vty_out(vty, " timer t3115 %u%s", gsmnet->T3115, VTY_NEWLINE);
566 vty_out(vty, " timer t3117 %u%s", gsmnet->T3117, VTY_NEWLINE);
567 vty_out(vty, " timer t3119 %u%s", gsmnet->T3119, VTY_NEWLINE);
Harald Welte2862dca2010-12-23 14:39:29 +0100568 vty_out(vty, " timer t3122 %u%s", gsmnet->T3122, VTY_NEWLINE);
Holger Hans Peter Freyther23975e72009-11-21 21:42:26 +0100569 vty_out(vty, " timer t3141 %u%s", gsmnet->T3141, VTY_NEWLINE);
Harald Welte63dbfc62010-12-15 15:34:23 +0100570 vty_out(vty, " dtx-used %u%s", gsmnet->dtx_enabled, VTY_NEWLINE);
Holger Hans Peter Freytherae9006a2010-12-22 16:26:04 +0100571 vty_out(vty, " subscriber-keep-in-ram %d%s",
572 gsmnet->keep_subscr, VTY_NEWLINE);
Harald Welte5013b2a2009-08-07 13:29:14 +0200573
574 return CMD_SUCCESS;
575}
Harald Welte67ce0732009-08-06 19:06:46 +0200576
Harald Welte68628e82009-03-10 12:17:57 +0000577static void trx_dump_vty(struct vty *vty, struct gsm_bts_trx *trx)
578{
579 vty_out(vty, "TRX %u of BTS %u is on ARFCN %u%s",
580 trx->nr, trx->bts->nr, trx->arfcn, VTY_NEWLINE);
Harald Welte197dea92010-05-14 17:59:53 +0200581 vty_out(vty, "Description: %s%s",
582 trx->description ? trx->description : "(null)", VTY_NEWLINE);
Harald Weltefcd24452009-06-20 18:15:19 +0200583 vty_out(vty, " RF Nominal Power: %d dBm, reduced by %u dB, "
Harald Welte42581822009-08-08 16:12:58 +0200584 "resulting BS power: %d dBm%s",
Harald Weltefcd24452009-06-20 18:15:19 +0200585 trx->nominal_power, trx->max_power_red,
Harald Welte42581822009-08-08 16:12:58 +0200586 trx->nominal_power - trx->max_power_red, VTY_NEWLINE);
Harald Welte68628e82009-03-10 12:17:57 +0000587 vty_out(vty, " NM State: ");
588 net_dump_nmstate(vty, &trx->nm_state);
589 vty_out(vty, " Baseband Transceiver NM State: ");
590 net_dump_nmstate(vty, &trx->bb_transc.nm_state);
Harald Welte8175e952009-10-20 00:22:00 +0200591 if (is_ipaccess_bts(trx->bts)) {
592 vty_out(vty, " ip.access stream ID: 0x%02x%s",
593 trx->rsl_tei, VTY_NEWLINE);
594 } else {
595 vty_out(vty, " E1 Signalling Link:%s", VTY_NEWLINE);
596 e1isl_dump_vty(vty, trx->rsl_link);
597 }
Harald Welte68628e82009-03-10 12:17:57 +0000598}
599
600DEFUN(show_trx,
601 show_trx_cmd,
602 "show trx [bts_nr] [trx_nr]",
Harald Welte8f0ed552010-05-11 21:53:49 +0200603 SHOW_STR "Display information about a TRX\n"
604 "BTS Number\n"
605 "TRX Number\n")
Harald Welte68628e82009-03-10 12:17:57 +0000606{
Harald Weltedcccb182010-05-16 20:52:23 +0200607 struct gsm_network *net = gsmnet_from_vty(vty);
Harald Welte68628e82009-03-10 12:17:57 +0000608 struct gsm_bts *bts = NULL;
609 struct gsm_bts_trx *trx;
610 int bts_nr, trx_nr;
611
612 if (argc >= 1) {
613 /* use the BTS number that the user has specified */
614 bts_nr = atoi(argv[0]);
615 if (bts_nr >= net->num_bts) {
Harald Welte1bc77352009-03-10 19:47:51 +0000616 vty_out(vty, "%% can't find BTS '%s'%s", argv[0],
Harald Welte68628e82009-03-10 12:17:57 +0000617 VTY_NEWLINE);
618 return CMD_WARNING;
619 }
Harald Weltee441d9c2009-06-21 16:17:15 +0200620 bts = gsm_bts_num(net, bts_nr);
Harald Welte68628e82009-03-10 12:17:57 +0000621 }
622 if (argc >= 2) {
623 trx_nr = atoi(argv[1]);
624 if (trx_nr >= bts->num_trx) {
Harald Welte1bc77352009-03-10 19:47:51 +0000625 vty_out(vty, "%% can't find TRX '%s'%s", argv[1],
Harald Welte68628e82009-03-10 12:17:57 +0000626 VTY_NEWLINE);
627 return CMD_WARNING;
628 }
Harald Weltee441d9c2009-06-21 16:17:15 +0200629 trx = gsm_bts_trx_num(bts, trx_nr);
Harald Welte68628e82009-03-10 12:17:57 +0000630 trx_dump_vty(vty, trx);
631 return CMD_SUCCESS;
632 }
633 if (bts) {
634 /* print all TRX in this BTS */
635 for (trx_nr = 0; trx_nr < bts->num_trx; trx_nr++) {
Harald Weltee441d9c2009-06-21 16:17:15 +0200636 trx = gsm_bts_trx_num(bts, trx_nr);
Harald Welte68628e82009-03-10 12:17:57 +0000637 trx_dump_vty(vty, trx);
638 }
639 return CMD_SUCCESS;
640 }
641
642 for (bts_nr = 0; bts_nr < net->num_bts; bts_nr++) {
Harald Weltee441d9c2009-06-21 16:17:15 +0200643 bts = gsm_bts_num(net, bts_nr);
Harald Welte68628e82009-03-10 12:17:57 +0000644 for (trx_nr = 0; trx_nr < bts->num_trx; trx_nr++) {
Harald Weltee441d9c2009-06-21 16:17:15 +0200645 trx = gsm_bts_trx_num(bts, trx_nr);
Harald Welte68628e82009-03-10 12:17:57 +0000646 trx_dump_vty(vty, trx);
647 }
648 }
649
650 return CMD_SUCCESS;
651}
652
Harald Welte67ce0732009-08-06 19:06:46 +0200653
Harald Welte68628e82009-03-10 12:17:57 +0000654static void ts_dump_vty(struct vty *vty, struct gsm_bts_trx_ts *ts)
655{
Harald Weltecd103a92010-12-24 12:14:52 +0100656 vty_out(vty, "BTS %u, TRX %u, Timeslot %u, phys cfg %s",
Harald Welte026b4ca2010-12-24 12:12:10 +0100657 ts->trx->bts->nr, ts->trx->nr, ts->nr,
Harald Weltecd103a92010-12-24 12:14:52 +0100658 gsm_pchan_name(ts->pchan));
659 if (ts->pchan == GSM_PCHAN_TCH_F_PDCH)
Harald Welteb29cea12010-12-24 12:26:13 +0100660 vty_out(vty, " (%s mode)",
Harald Weltecd103a92010-12-24 12:14:52 +0100661 ts->flags & TS_F_PDCH_MODE ? "PDCH" : "TCH/F");
662 vty_out(vty, "%s", VTY_NEWLINE);
Harald Welte68628e82009-03-10 12:17:57 +0000663 vty_out(vty, " NM State: ");
664 net_dump_nmstate(vty, &ts->nm_state);
Harald Welte2c828992009-12-02 01:56:49 +0530665 if (!is_ipaccess_bts(ts->trx->bts))
Harald Welteef235b52009-03-10 12:34:02 +0000666 vty_out(vty, " E1 Line %u, Timeslot %u, Subslot %u%s",
667 ts->e1_link.e1_nr, ts->e1_link.e1_ts,
668 ts->e1_link.e1_ts_ss, VTY_NEWLINE);
Harald Welte68628e82009-03-10 12:17:57 +0000669}
670
671DEFUN(show_ts,
672 show_ts_cmd,
Harald Welte1bc77352009-03-10 19:47:51 +0000673 "show timeslot [bts_nr] [trx_nr] [ts_nr]",
Harald Welte8f0ed552010-05-11 21:53:49 +0200674 SHOW_STR "Display information about a TS\n"
675 "BTS Number\n" "TRX Number\n" "Timeslot Number\n")
Harald Welte68628e82009-03-10 12:17:57 +0000676{
Harald Weltedcccb182010-05-16 20:52:23 +0200677 struct gsm_network *net = gsmnet_from_vty(vty);
Harald Welte274d0152010-12-24 12:05:03 +0100678 struct gsm_bts *bts = NULL;
679 struct gsm_bts_trx *trx = NULL;
680 struct gsm_bts_trx_ts *ts = NULL;
Harald Welte68628e82009-03-10 12:17:57 +0000681 int bts_nr, trx_nr, ts_nr;
682
683 if (argc >= 1) {
684 /* use the BTS number that the user has specified */
685 bts_nr = atoi(argv[0]);
686 if (bts_nr >= net->num_bts) {
Harald Welte1bc77352009-03-10 19:47:51 +0000687 vty_out(vty, "%% can't find BTS '%s'%s", argv[0],
Harald Welte68628e82009-03-10 12:17:57 +0000688 VTY_NEWLINE);
689 return CMD_WARNING;
690 }
Harald Weltee441d9c2009-06-21 16:17:15 +0200691 bts = gsm_bts_num(net, bts_nr);
Harald Welte68628e82009-03-10 12:17:57 +0000692 }
693 if (argc >= 2) {
694 trx_nr = atoi(argv[1]);
695 if (trx_nr >= bts->num_trx) {
Harald Welte1bc77352009-03-10 19:47:51 +0000696 vty_out(vty, "%% can't find TRX '%s'%s", argv[1],
Harald Welte68628e82009-03-10 12:17:57 +0000697 VTY_NEWLINE);
698 return CMD_WARNING;
699 }
Harald Weltee441d9c2009-06-21 16:17:15 +0200700 trx = gsm_bts_trx_num(bts, trx_nr);
Harald Welte68628e82009-03-10 12:17:57 +0000701 }
702 if (argc >= 3) {
703 ts_nr = atoi(argv[2]);
704 if (ts_nr >= TRX_NR_TS) {
Harald Welte1bc77352009-03-10 19:47:51 +0000705 vty_out(vty, "%% can't find TS '%s'%s", argv[2],
Harald Welte68628e82009-03-10 12:17:57 +0000706 VTY_NEWLINE);
707 return CMD_WARNING;
708 }
Harald Welte274d0152010-12-24 12:05:03 +0100709 /* Fully Specified: print and exit */
Harald Welte68628e82009-03-10 12:17:57 +0000710 ts = &trx->ts[ts_nr];
711 ts_dump_vty(vty, ts);
712 return CMD_SUCCESS;
713 }
Harald Welte274d0152010-12-24 12:05:03 +0100714
715 if (bts && trx) {
716 /* Iterate over all TS in this TRX */
717 for (ts_nr = 0; ts_nr < TRX_NR_TS; ts_nr++) {
718 ts = &trx->ts[ts_nr];
719 ts_dump_vty(vty, ts);
720 }
721 } else if (bts) {
722 /* Iterate over all TRX in this BTS, TS in each TRX */
Harald Welte68628e82009-03-10 12:17:57 +0000723 for (trx_nr = 0; trx_nr < bts->num_trx; trx_nr++) {
Harald Weltee441d9c2009-06-21 16:17:15 +0200724 trx = gsm_bts_trx_num(bts, trx_nr);
Harald Welte68628e82009-03-10 12:17:57 +0000725 for (ts_nr = 0; ts_nr < TRX_NR_TS; ts_nr++) {
726 ts = &trx->ts[ts_nr];
727 ts_dump_vty(vty, ts);
728 }
729 }
Harald Welte274d0152010-12-24 12:05:03 +0100730 } else {
731 /* Iterate over all BTS, TRX in each BTS, TS in each TRX */
732 for (bts_nr = 0; bts_nr < net->num_bts; bts_nr++) {
733 bts = gsm_bts_num(net, bts_nr);
734 for (trx_nr = 0; trx_nr < bts->num_trx; trx_nr++) {
735 trx = gsm_bts_trx_num(bts, trx_nr);
736 for (ts_nr = 0; ts_nr < TRX_NR_TS; ts_nr++) {
737 ts = &trx->ts[ts_nr];
738 ts_dump_vty(vty, ts);
739 }
740 }
741 }
Harald Welte68628e82009-03-10 12:17:57 +0000742 }
743
744 return CMD_SUCCESS;
745}
746
Holger Hans Peter Freyther424c4f02010-01-06 06:00:40 +0100747static void subscr_dump_vty(struct vty *vty, struct gsm_subscriber *subscr)
Harald Welte68628e82009-03-10 12:17:57 +0000748{
Harald Weltefcd24452009-06-20 18:15:19 +0200749 vty_out(vty, " ID: %llu, Authorized: %d%s", subscr->id,
Harald Welte40f82892009-05-23 17:31:39 +0000750 subscr->authorized, VTY_NEWLINE);
Harald Welte68628e82009-03-10 12:17:57 +0000751 if (subscr->name)
Harald Welte1bc77352009-03-10 19:47:51 +0000752 vty_out(vty, " Name: '%s'%s", subscr->name, VTY_NEWLINE);
Harald Welte68628e82009-03-10 12:17:57 +0000753 if (subscr->extension)
754 vty_out(vty, " Extension: %s%s", subscr->extension,
755 VTY_NEWLINE);
756 if (subscr->imsi)
757 vty_out(vty, " IMSI: %s%s", subscr->imsi, VTY_NEWLINE);
Holger Hans Peter Freyther22230252009-08-19 12:53:57 +0200758 if (subscr->tmsi != GSM_RESERVED_TMSI)
759 vty_out(vty, " TMSI: %08X%s", subscr->tmsi,
Harald Welte731fd912009-08-15 03:24:51 +0200760 VTY_NEWLINE);
Sylvain Munautaf292642009-12-27 19:29:28 +0100761
Harald Welte (local)15920de2009-08-14 20:27:16 +0200762 vty_out(vty, " Use count: %u%s", subscr->use_count, VTY_NEWLINE);
Harald Welte68628e82009-03-10 12:17:57 +0000763}
764
Harald Welte8387a492009-12-22 21:43:14 +0100765static void meas_rep_dump_uni_vty(struct vty *vty,
766 struct gsm_meas_rep_unidir *mru,
767 const char *prefix,
768 const char *dir)
769{
770 vty_out(vty, "%s RXL-FULL-%s: %4d dBm, RXL-SUB-%s: %4d dBm ",
771 prefix, dir, rxlev2dbm(mru->full.rx_lev),
772 dir, rxlev2dbm(mru->sub.rx_lev));
773 vty_out(vty, "RXQ-FULL-%s: %d, RXQ-SUB-%s: %d%s",
774 dir, mru->full.rx_qual, dir, mru->sub.rx_qual,
775 VTY_NEWLINE);
776}
777
778static void meas_rep_dump_vty(struct vty *vty, struct gsm_meas_rep *mr,
779 const char *prefix)
780{
781 vty_out(vty, "%sMeasurement Report:%s", prefix, VTY_NEWLINE);
782 vty_out(vty, "%s Flags: %s%s%s%s%s", prefix,
783 mr->flags & MEAS_REP_F_UL_DTX ? "DTXu " : "",
784 mr->flags & MEAS_REP_F_DL_DTX ? "DTXd " : "",
785 mr->flags & MEAS_REP_F_FPC ? "FPC " : "",
786 mr->flags & MEAS_REP_F_DL_VALID ? " " : "DLinval ",
787 VTY_NEWLINE);
788 if (mr->flags & MEAS_REP_F_MS_TO)
789 vty_out(vty, "%s MS Timing Offset: %u%s", prefix,
790 mr->ms_timing_offset, VTY_NEWLINE);
791 if (mr->flags & MEAS_REP_F_MS_L1)
792 vty_out(vty, "%s L1 MS Power: %u dBm, Timing Advance: %u%s",
793 prefix, mr->ms_l1.pwr, mr->ms_l1.ta, VTY_NEWLINE);
794 if (mr->flags & MEAS_REP_F_DL_VALID)
795 meas_rep_dump_uni_vty(vty, &mr->dl, prefix, "dl");
796 meas_rep_dump_uni_vty(vty, &mr->ul, prefix, "ul");
797}
798
Holger Hans Peter Freyther029235e2010-05-14 02:03:16 +0800799static void lchan_dump_full_vty(struct vty *vty, struct gsm_lchan *lchan)
Harald Welte68628e82009-03-10 12:17:57 +0000800{
Harald Welte8387a492009-12-22 21:43:14 +0100801 int idx;
802
Harald Welte85bded82010-12-24 12:22:34 +0100803 vty_out(vty, "BTS %u, TRX %u, Timeslot %u, Lchan %u: Type %s%s",
804 lchan->ts->trx->bts->nr, lchan->ts->trx->nr, lchan->ts->nr,
805 lchan->nr, gsm_lchant_name(lchan->type), VTY_NEWLINE);
Holger Hans Peter Freyther40494552010-06-28 17:09:29 +0800806 vty_out(vty, " Connection: %u, State: %s%s",
807 lchan->conn ? 1: 0,
Harald Welte1887f9d2009-12-29 10:52:38 +0100808 gsm_lchans_name(lchan->state), VTY_NEWLINE);
Harald Welte73225282009-12-12 18:17:25 +0100809 vty_out(vty, " BS Power: %u dBm, MS Power: %u dBm%s",
810 lchan->ts->trx->nominal_power - lchan->ts->trx->max_power_red
811 - lchan->bs_power*2,
812 ms_pwr_dbm(lchan->ts->trx->bts->band, lchan->ms_power),
813 VTY_NEWLINE);
Holger Hans Peter Freyther2412a072010-06-28 15:47:12 +0800814 if (lchan->conn && lchan->conn->subscr) {
Harald Welte68628e82009-03-10 12:17:57 +0000815 vty_out(vty, " Subscriber:%s", VTY_NEWLINE);
Holger Hans Peter Freyther2412a072010-06-28 15:47:12 +0800816 subscr_dump_vty(vty, lchan->conn->subscr);
Harald Welte68628e82009-03-10 12:17:57 +0000817 } else
818 vty_out(vty, " No Subscriber%s", VTY_NEWLINE);
Harald Welte2c828992009-12-02 01:56:49 +0530819 if (is_ipaccess_bts(lchan->ts->trx->bts)) {
820 struct in_addr ia;
Holger Hans Peter Freyther54fa7992010-04-07 15:39:16 +0200821 ia.s_addr = htonl(lchan->abis_ip.bound_ip);
Harald Welte2c828992009-12-02 01:56:49 +0530822 vty_out(vty, " Bound IP: %s Port %u RTP_TYPE2=%u CONN_ID=%u%s",
823 inet_ntoa(ia), lchan->abis_ip.bound_port,
824 lchan->abis_ip.rtp_payload2, lchan->abis_ip.conn_id,
825 VTY_NEWLINE);
826 }
Harald Welte8387a492009-12-22 21:43:14 +0100827
828 /* we want to report the last measurement report */
829 idx = calc_initial_idx(ARRAY_SIZE(lchan->meas_rep),
830 lchan->meas_rep_idx, 1);
831 meas_rep_dump_vty(vty, &lchan->meas_rep[idx], " ");
Harald Welte68628e82009-03-10 12:17:57 +0000832}
833
Holger Hans Peter Freyther3d6a5d62010-05-14 02:08:49 +0800834static void lchan_dump_short_vty(struct vty *vty, struct gsm_lchan *lchan)
835{
Holger Hans Peter Freythercf5cc5b2010-05-14 01:57:02 +0800836 struct gsm_meas_rep *mr;
837 int idx;
838
839 /* we want to report the last measurement report */
840 idx = calc_initial_idx(ARRAY_SIZE(lchan->meas_rep),
841 lchan->meas_rep_idx, 1);
842 mr = &lchan->meas_rep[idx];
843
Harald Welte85bded82010-12-24 12:22:34 +0100844 vty_out(vty, "BTS %u, TRX %u, Timeslot %u, Lchan %u, Type %s - "
845 "L1 MS Power: %u dBm RXL-FULL-dl: %4d dBm RXL-FULL-ul: %4d dBm%s",
846 lchan->ts->trx->bts->nr, lchan->ts->trx->nr, lchan->ts->nr,
Harald Welteb29cea12010-12-24 12:26:13 +0100847 lchan->nr, gsm_lchant_name(lchan->type), mr->ms_l1.pwr,
Holger Hans Peter Freythercf5cc5b2010-05-14 01:57:02 +0800848 rxlev2dbm(mr->dl.full.rx_lev),
849 rxlev2dbm(mr->ul.full.rx_lev),
Holger Hans Peter Freyther3d6a5d62010-05-14 02:08:49 +0800850 VTY_NEWLINE);
851}
852
Holger Hans Peter Freyther029235e2010-05-14 02:03:16 +0800853static int lchan_summary(struct vty *vty, int argc, const char **argv,
854 void (*dump_cb)(struct vty *, struct gsm_lchan *))
Harald Welte68628e82009-03-10 12:17:57 +0000855{
Harald Weltedcccb182010-05-16 20:52:23 +0200856 struct gsm_network *net = gsmnet_from_vty(vty);
Harald Welte68628e82009-03-10 12:17:57 +0000857 struct gsm_bts *bts;
858 struct gsm_bts_trx *trx;
859 struct gsm_bts_trx_ts *ts;
860 struct gsm_lchan *lchan;
861 int bts_nr, trx_nr, ts_nr, lchan_nr;
862
863 if (argc >= 1) {
864 /* use the BTS number that the user has specified */
865 bts_nr = atoi(argv[0]);
866 if (bts_nr >= net->num_bts) {
867 vty_out(vty, "%% can't find BTS %s%s", argv[0],
868 VTY_NEWLINE);
869 return CMD_WARNING;
870 }
Harald Weltee441d9c2009-06-21 16:17:15 +0200871 bts = gsm_bts_num(net, bts_nr);
Harald Welte68628e82009-03-10 12:17:57 +0000872 }
873 if (argc >= 2) {
874 trx_nr = atoi(argv[1]);
875 if (trx_nr >= bts->num_trx) {
876 vty_out(vty, "%% can't find TRX %s%s", argv[1],
877 VTY_NEWLINE);
878 return CMD_WARNING;
879 }
Harald Weltee441d9c2009-06-21 16:17:15 +0200880 trx = gsm_bts_trx_num(bts, trx_nr);
Harald Welte68628e82009-03-10 12:17:57 +0000881 }
882 if (argc >= 3) {
883 ts_nr = atoi(argv[2]);
884 if (ts_nr >= TRX_NR_TS) {
885 vty_out(vty, "%% can't find TS %s%s", argv[2],
886 VTY_NEWLINE);
887 return CMD_WARNING;
888 }
889 ts = &trx->ts[ts_nr];
890 }
891 if (argc >= 4) {
892 lchan_nr = atoi(argv[3]);
893 if (lchan_nr >= TS_MAX_LCHAN) {
894 vty_out(vty, "%% can't find LCHAN %s%s", argv[3],
895 VTY_NEWLINE);
896 return CMD_WARNING;
897 }
898 lchan = &ts->lchan[lchan_nr];
Holger Hans Peter Freyther029235e2010-05-14 02:03:16 +0800899 dump_cb(vty, lchan);
Harald Welte68628e82009-03-10 12:17:57 +0000900 return CMD_SUCCESS;
901 }
902 for (bts_nr = 0; bts_nr < net->num_bts; bts_nr++) {
Harald Weltee441d9c2009-06-21 16:17:15 +0200903 bts = gsm_bts_num(net, bts_nr);
Harald Welte68628e82009-03-10 12:17:57 +0000904 for (trx_nr = 0; trx_nr < bts->num_trx; trx_nr++) {
Harald Weltee441d9c2009-06-21 16:17:15 +0200905 trx = gsm_bts_trx_num(bts, trx_nr);
Harald Welte68628e82009-03-10 12:17:57 +0000906 for (ts_nr = 0; ts_nr < TRX_NR_TS; ts_nr++) {
907 ts = &trx->ts[ts_nr];
908 for (lchan_nr = 0; lchan_nr < TS_MAX_LCHAN;
909 lchan_nr++) {
910 lchan = &ts->lchan[lchan_nr];
Harald Welteef235b52009-03-10 12:34:02 +0000911 if (lchan->type == GSM_LCHAN_NONE)
912 continue;
Holger Hans Peter Freyther029235e2010-05-14 02:03:16 +0800913 dump_cb(vty, lchan);
Harald Welte68628e82009-03-10 12:17:57 +0000914 }
915 }
916 }
917 }
918
919 return CMD_SUCCESS;
920}
921
Holger Hans Peter Freyther029235e2010-05-14 02:03:16 +0800922
923DEFUN(show_lchan,
924 show_lchan_cmd,
925 "show lchan [bts_nr] [trx_nr] [ts_nr] [lchan_nr]",
926 SHOW_STR "Display information about a logical channel\n"
927 "BTS Number\n" "TRX Number\n" "Timeslot Number\n"
928 "Logical Channel Number\n")
929
930{
931 return lchan_summary(vty, argc, argv, lchan_dump_full_vty);
932}
933
Holger Hans Peter Freyther3d6a5d62010-05-14 02:08:49 +0800934DEFUN(show_lchan_summary,
935 show_lchan_summary_cmd,
936 "show lchan summary [bts_nr] [trx_nr] [ts_nr] [lchan_nr]",
937 SHOW_STR "Display information about a logical channel\n"
938 "BTS Number\n" "TRX Number\n" "Timeslot Number\n"
939 "Logical Channel Number\n")
940{
941 return lchan_summary(vty, argc, argv, lchan_dump_short_vty);
942}
943
Harald Welte1bc77352009-03-10 19:47:51 +0000944static void e1drv_dump_vty(struct vty *vty, struct e1inp_driver *drv)
945{
946 vty_out(vty, "E1 Input Driver %s%s", drv->name, VTY_NEWLINE);
947}
948
949DEFUN(show_e1drv,
950 show_e1drv_cmd,
951 "show e1_driver",
952 SHOW_STR "Display information about available E1 drivers\n")
953{
954 struct e1inp_driver *drv;
955
956 llist_for_each_entry(drv, &e1inp_driver_list, list)
957 e1drv_dump_vty(vty, drv);
958
959 return CMD_SUCCESS;
960}
961
Harald Welte68628e82009-03-10 12:17:57 +0000962static void e1line_dump_vty(struct vty *vty, struct e1inp_line *line)
963{
964 vty_out(vty, "E1 Line Number %u, Name %s, Driver %s%s",
965 line->num, line->name ? line->name : "",
966 line->driver->name, VTY_NEWLINE);
967}
968
969DEFUN(show_e1line,
970 show_e1line_cmd,
971 "show e1_line [line_nr]",
Harald Welte8f0ed552010-05-11 21:53:49 +0200972 SHOW_STR "Display information about a E1 line\n"
973 "E1 Line Number\n")
Harald Welte68628e82009-03-10 12:17:57 +0000974{
Harald Welte1bc77352009-03-10 19:47:51 +0000975 struct e1inp_line *line;
976
977 if (argc >= 1) {
978 int num = atoi(argv[0]);
979 llist_for_each_entry(line, &e1inp_line_list, list) {
980 if (line->num == num) {
981 e1line_dump_vty(vty, line);
982 return CMD_SUCCESS;
983 }
984 }
985 return CMD_WARNING;
986 }
987
988 llist_for_each_entry(line, &e1inp_line_list, list)
989 e1line_dump_vty(vty, line);
990
991 return CMD_SUCCESS;
Harald Welte68628e82009-03-10 12:17:57 +0000992}
993
994static void e1ts_dump_vty(struct vty *vty, struct e1inp_ts *ts)
995{
Harald Welte42581822009-08-08 16:12:58 +0200996 if (ts->type == E1INP_TS_TYPE_NONE)
997 return;
Harald Welte1bc77352009-03-10 19:47:51 +0000998 vty_out(vty, "E1 Timeslot %2u of Line %u is Type %s%s",
999 ts->num, ts->line->num, e1inp_tstype_name(ts->type),
1000 VTY_NEWLINE);
Harald Welte68628e82009-03-10 12:17:57 +00001001}
1002
1003DEFUN(show_e1ts,
1004 show_e1ts_cmd,
1005 "show e1_timeslot [line_nr] [ts_nr]",
Harald Welte8f0ed552010-05-11 21:53:49 +02001006 SHOW_STR "Display information about a E1 timeslot\n"
1007 "E1 Line Number\n" "E1 Timeslot Number\n")
Harald Welte68628e82009-03-10 12:17:57 +00001008{
Harald Welte986c3d72009-11-17 06:12:16 +01001009 struct e1inp_line *line = NULL;
Harald Welte1bc77352009-03-10 19:47:51 +00001010 struct e1inp_ts *ts;
1011 int ts_nr;
Harald Welte68628e82009-03-10 12:17:57 +00001012
Harald Welte1bc77352009-03-10 19:47:51 +00001013 if (argc == 0) {
1014 llist_for_each_entry(line, &e1inp_line_list, list) {
1015 for (ts_nr = 0; ts_nr < NUM_E1_TS; ts_nr++) {
1016 ts = &line->ts[ts_nr];
1017 e1ts_dump_vty(vty, ts);
1018 }
1019 }
1020 return CMD_SUCCESS;
1021 }
1022 if (argc >= 1) {
1023 int num = atoi(argv[0]);
1024 llist_for_each_entry(line, &e1inp_line_list, list) {
1025 if (line->num == num)
1026 break;
1027 }
1028 if (!line || line->num != num) {
1029 vty_out(vty, "E1 line %s is invalid%s",
1030 argv[0], VTY_NEWLINE);
1031 return CMD_WARNING;
1032 }
1033 }
1034 if (argc >= 2) {
1035 ts_nr = atoi(argv[1]);
1036 if (ts_nr > NUM_E1_TS) {
1037 vty_out(vty, "E1 timeslot %s is invalid%s",
1038 argv[1], VTY_NEWLINE);
1039 return CMD_WARNING;
1040 }
1041 ts = &line->ts[ts_nr];
1042 e1ts_dump_vty(vty, ts);
1043 return CMD_SUCCESS;
1044 } else {
1045 for (ts_nr = 0; ts_nr < NUM_E1_TS; ts_nr++) {
1046 ts = &line->ts[ts_nr];
1047 e1ts_dump_vty(vty, ts);
1048 }
1049 return CMD_SUCCESS;
1050 }
1051 return CMD_SUCCESS;
Harald Welte68628e82009-03-10 12:17:57 +00001052}
1053
Harald Weltebe4b7302009-05-23 16:59:33 +00001054static void paging_dump_vty(struct vty *vty, struct gsm_paging_request *pag)
Harald Weltef5025b62009-03-28 16:55:11 +00001055{
1056 vty_out(vty, "Paging on BTS %u%s", pag->bts->nr, VTY_NEWLINE);
1057 subscr_dump_vty(vty, pag->subscr);
1058}
1059
Harald Weltebe4b7302009-05-23 16:59:33 +00001060static void bts_paging_dump_vty(struct vty *vty, struct gsm_bts *bts)
Harald Weltef5025b62009-03-28 16:55:11 +00001061{
1062 struct gsm_paging_request *pag;
1063
1064 llist_for_each_entry(pag, &bts->paging.pending_requests, entry)
1065 paging_dump_vty(vty, pag);
1066}
1067
1068DEFUN(show_paging,
1069 show_paging_cmd,
1070 "show paging [bts_nr]",
Harald Welte8f0ed552010-05-11 21:53:49 +02001071 SHOW_STR "Display information about paging reuqests of a BTS\n"
1072 "BTS Number\n")
Harald Weltef5025b62009-03-28 16:55:11 +00001073{
Harald Weltedcccb182010-05-16 20:52:23 +02001074 struct gsm_network *net = gsmnet_from_vty(vty);
Harald Weltef5025b62009-03-28 16:55:11 +00001075 struct gsm_bts *bts;
1076 int bts_nr;
1077
1078 if (argc >= 1) {
1079 /* use the BTS number that the user has specified */
1080 bts_nr = atoi(argv[0]);
1081 if (bts_nr >= net->num_bts) {
1082 vty_out(vty, "%% can't find BTS %s%s", argv[0],
1083 VTY_NEWLINE);
1084 return CMD_WARNING;
1085 }
Harald Weltee441d9c2009-06-21 16:17:15 +02001086 bts = gsm_bts_num(net, bts_nr);
Harald Weltef5025b62009-03-28 16:55:11 +00001087 bts_paging_dump_vty(vty, bts);
1088
1089 return CMD_SUCCESS;
1090 }
1091 for (bts_nr = 0; bts_nr < net->num_bts; bts_nr++) {
Harald Weltee441d9c2009-06-21 16:17:15 +02001092 bts = gsm_bts_num(net, bts_nr);
Harald Weltef5025b62009-03-28 16:55:11 +00001093 bts_paging_dump_vty(vty, bts);
1094 }
1095
1096 return CMD_SUCCESS;
1097}
1098
Harald Welte8f0ed552010-05-11 21:53:49 +02001099#define NETWORK_STR "Configure the GSM network\n"
1100
Harald Welte5013b2a2009-08-07 13:29:14 +02001101DEFUN(cfg_net,
1102 cfg_net_cmd,
Harald Welte8f0ed552010-05-11 21:53:49 +02001103 "network", NETWORK_STR)
Harald Welte5013b2a2009-08-07 13:29:14 +02001104{
Harald Weltedcccb182010-05-16 20:52:23 +02001105 vty->index = gsmnet_from_vty(vty);
Harald Welte5013b2a2009-08-07 13:29:14 +02001106 vty->node = GSMNET_NODE;
1107
1108 return CMD_SUCCESS;
1109}
1110
1111
1112DEFUN(cfg_net_ncc,
1113 cfg_net_ncc_cmd,
1114 "network country code <1-999>",
1115 "Set the GSM network country code")
1116{
Harald Weltedcccb182010-05-16 20:52:23 +02001117 struct gsm_network *gsmnet = gsmnet_from_vty(vty);
1118
Harald Welte5013b2a2009-08-07 13:29:14 +02001119 gsmnet->country_code = atoi(argv[0]);
1120
1121 return CMD_SUCCESS;
1122}
1123
1124DEFUN(cfg_net_mnc,
1125 cfg_net_mnc_cmd,
1126 "mobile network code <1-999>",
1127 "Set the GSM mobile network code")
1128{
Harald Weltedcccb182010-05-16 20:52:23 +02001129 struct gsm_network *gsmnet = gsmnet_from_vty(vty);
1130
Harald Welte5013b2a2009-08-07 13:29:14 +02001131 gsmnet->network_code = atoi(argv[0]);
1132
1133 return CMD_SUCCESS;
1134}
1135
1136DEFUN(cfg_net_name_short,
1137 cfg_net_name_short_cmd,
1138 "short name NAME",
1139 "Set the short GSM network name")
1140{
Harald Weltedcccb182010-05-16 20:52:23 +02001141 struct gsm_network *gsmnet = gsmnet_from_vty(vty);
1142
Holger Hans Peter Freyther3e9a7f82010-10-12 23:21:54 +02001143 bsc_replace_string(gsmnet, &gsmnet->name_short, argv[0]);
Harald Welte5013b2a2009-08-07 13:29:14 +02001144 return CMD_SUCCESS;
1145}
1146
1147DEFUN(cfg_net_name_long,
1148 cfg_net_name_long_cmd,
1149 "long name NAME",
1150 "Set the long GSM network name")
1151{
Harald Weltedcccb182010-05-16 20:52:23 +02001152 struct gsm_network *gsmnet = gsmnet_from_vty(vty);
1153
Holger Hans Peter Freyther3e9a7f82010-10-12 23:21:54 +02001154 bsc_replace_string(gsmnet, &gsmnet->name_long, argv[0]);
Harald Welte5013b2a2009-08-07 13:29:14 +02001155 return CMD_SUCCESS;
1156}
Harald Welte40f82892009-05-23 17:31:39 +00001157
Harald Welte (local)69de3972009-08-12 14:42:23 +02001158DEFUN(cfg_net_auth_policy,
1159 cfg_net_auth_policy_cmd,
1160 "auth policy (closed|accept-all|token)",
Harald Welte8f0ed552010-05-11 21:53:49 +02001161 "Authentication (not cryptographic)\n"
1162 "Set the GSM network authentication policy\n"
1163 "Require the MS to be activated in HLR\n"
1164 "Accept all MS, whether in HLR or not\n"
1165 "Use SMS-token based authentication\n")
Harald Welte (local)69de3972009-08-12 14:42:23 +02001166{
1167 enum gsm_auth_policy policy = gsm_auth_policy_parse(argv[0]);
Harald Weltedcccb182010-05-16 20:52:23 +02001168 struct gsm_network *gsmnet = gsmnet_from_vty(vty);
Harald Welte (local)69de3972009-08-12 14:42:23 +02001169
1170 gsmnet->auth_policy = policy;
1171
1172 return CMD_SUCCESS;
1173}
1174
Harald Welte1085c092009-11-18 20:33:19 +01001175DEFUN(cfg_net_reject_cause,
1176 cfg_net_reject_cause_cmd,
1177 "location updating reject cause <2-111>",
1178 "Set the reject cause of location updating reject\n")
1179{
Harald Weltedcccb182010-05-16 20:52:23 +02001180 struct gsm_network *gsmnet = gsmnet_from_vty(vty);
1181
Harald Welte1085c092009-11-18 20:33:19 +01001182 gsmnet->reject_cause = atoi(argv[0]);
1183
1184 return CMD_SUCCESS;
1185}
1186
Harald Welte4381cfe2009-08-30 15:47:06 +09001187DEFUN(cfg_net_encryption,
1188 cfg_net_encryption_cmd,
1189 "encryption a5 (0|1|2)",
Harald Welte28326062010-05-14 20:05:17 +02001190 "Encryption options\n"
1191 "A5 encryption\n" "A5/0: No encryption\n"
1192 "A5/1: Encryption\n" "A5/2: Export-grade Encryption\n")
Harald Welte4381cfe2009-08-30 15:47:06 +09001193{
Harald Weltedcccb182010-05-16 20:52:23 +02001194 struct gsm_network *gsmnet = gsmnet_from_vty(vty);
1195
Andreas.Eversberg1059deb2009-11-17 09:55:26 +01001196 gsmnet->a5_encryption= atoi(argv[0]);
Harald Welte4381cfe2009-08-30 15:47:06 +09001197
1198 return CMD_SUCCESS;
1199}
1200
Holger Hans Peter Freytherf7d752f2009-11-16 17:12:38 +01001201DEFUN(cfg_net_neci,
1202 cfg_net_neci_cmd,
1203 "neci (0|1)",
Harald Welte28326062010-05-14 20:05:17 +02001204 "New Establish Cause Indication\n"
1205 "Don't set the NECI bit\n" "Set the NECI bit\n")
Holger Hans Peter Freytherf7d752f2009-11-16 17:12:38 +01001206{
Harald Weltedcccb182010-05-16 20:52:23 +02001207 struct gsm_network *gsmnet = gsmnet_from_vty(vty);
1208
Holger Hans Peter Freytherf7d752f2009-11-16 17:12:38 +01001209 gsmnet->neci = atoi(argv[0]);
Holger Hans Peter Freyther78891072010-09-06 09:36:02 +08001210 gsm_net_update_ctype(gsmnet);
Holger Hans Peter Freytherf7d752f2009-11-16 17:12:38 +01001211 return CMD_SUCCESS;
1212}
1213
Harald Welteeab84a12009-12-13 10:53:12 +01001214DEFUN(cfg_net_rrlp_mode, cfg_net_rrlp_mode_cmd,
1215 "rrlp mode (none|ms-based|ms-preferred|ass-preferred)",
Harald Welte8f0ed552010-05-11 21:53:49 +02001216 "Radio Resource Location Protocol\n"
1217 "Set the Radio Resource Location Protocol Mode\n"
1218 "Don't send RRLP request\n"
1219 "Request MS-based location\n"
1220 "Request any location, prefer MS-based\n"
1221 "Request any location, prefer MS-assisted\n")
Harald Welteeab84a12009-12-13 10:53:12 +01001222{
Harald Weltedcccb182010-05-16 20:52:23 +02001223 struct gsm_network *gsmnet = gsmnet_from_vty(vty);
1224
Harald Welteeab84a12009-12-13 10:53:12 +01001225 gsmnet->rrlp.mode = rrlp_mode_parse(argv[0]);
1226
1227 return CMD_SUCCESS;
1228}
1229
Harald Welte648b6ce2009-12-14 09:00:24 +01001230DEFUN(cfg_net_mm_info, cfg_net_mm_info_cmd,
1231 "mm info (0|1)",
1232 "Whether to send MM INFO after LOC UPD ACCEPT")
1233{
Harald Weltedcccb182010-05-16 20:52:23 +02001234 struct gsm_network *gsmnet = gsmnet_from_vty(vty);
1235
Harald Welte648b6ce2009-12-14 09:00:24 +01001236 gsmnet->send_mm_info = atoi(argv[0]);
1237
1238 return CMD_SUCCESS;
1239}
1240
Harald Welte8f0ed552010-05-11 21:53:49 +02001241#define HANDOVER_STR "Handover Options\n"
1242
Harald Weltebc814502009-12-19 21:41:52 +01001243DEFUN(cfg_net_handover, cfg_net_handover_cmd,
1244 "handover (0|1)",
Harald Welte8f0ed552010-05-11 21:53:49 +02001245 HANDOVER_STR
1246 "Don't perform in-call handover\n"
1247 "Perform in-call handover\n")
Harald Weltebc814502009-12-19 21:41:52 +01001248{
Holger Hans Peter Freythercbcfe242010-01-07 16:14:38 +01001249 int enable = atoi(argv[0]);
Harald Weltedcccb182010-05-16 20:52:23 +02001250 struct gsm_network *gsmnet = gsmnet_from_vty(vty);
Holger Hans Peter Freythercbcfe242010-01-07 16:14:38 +01001251
1252 if (enable && ipacc_rtp_direct) {
Harald Weltefe03f0d2009-12-20 13:51:01 +01001253 vty_out(vty, "%% Cannot enable handover unless RTP Proxy mode "
1254 "is enabled by using the -P command line option%s",
1255 VTY_NEWLINE);
1256 return CMD_WARNING;
1257 }
Holger Hans Peter Freythercbcfe242010-01-07 16:14:38 +01001258 gsmnet->handover.active = enable;
Harald Weltebc814502009-12-19 21:41:52 +01001259
1260 return CMD_SUCCESS;
1261}
1262
Harald Welte8f0ed552010-05-11 21:53:49 +02001263#define HO_WIN_STR HANDOVER_STR "Measurement Window\n"
1264#define HO_WIN_RXLEV_STR HO_WIN_STR "Received Level Averaging\n"
1265#define HO_WIN_RXQUAL_STR HO_WIN_STR "Received Quality Averaging\n"
1266#define HO_PBUDGET_STR HANDOVER_STR "Power Budget\n"
1267
Harald Welteb720bd32009-12-21 16:51:50 +01001268DEFUN(cfg_net_ho_win_rxlev_avg, cfg_net_ho_win_rxlev_avg_cmd,
1269 "handover window rxlev averaging <1-10>",
Harald Welte8f0ed552010-05-11 21:53:49 +02001270 HO_WIN_RXLEV_STR
Harald Welteb720bd32009-12-21 16:51:50 +01001271 "How many RxLev measurements are used for averaging")
1272{
Harald Weltedcccb182010-05-16 20:52:23 +02001273 struct gsm_network *gsmnet = gsmnet_from_vty(vty);
Harald Welteb720bd32009-12-21 16:51:50 +01001274 gsmnet->handover.win_rxlev_avg = atoi(argv[0]);
1275 return CMD_SUCCESS;
1276}
1277
1278DEFUN(cfg_net_ho_win_rxqual_avg, cfg_net_ho_win_rxqual_avg_cmd,
1279 "handover window rxqual averaging <1-10>",
Harald Welte8f0ed552010-05-11 21:53:49 +02001280 HO_WIN_RXQUAL_STR
Harald Welteb720bd32009-12-21 16:51:50 +01001281 "How many RxQual measurements are used for averaging")
1282{
Harald Weltedcccb182010-05-16 20:52:23 +02001283 struct gsm_network *gsmnet = gsmnet_from_vty(vty);
Harald Welteb720bd32009-12-21 16:51:50 +01001284 gsmnet->handover.win_rxqual_avg = atoi(argv[0]);
1285 return CMD_SUCCESS;
1286}
1287
1288DEFUN(cfg_net_ho_win_rxlev_neigh_avg, cfg_net_ho_win_rxlev_avg_neigh_cmd,
1289 "handover window rxlev neighbor averaging <1-10>",
Harald Welte8f0ed552010-05-11 21:53:49 +02001290 HO_WIN_RXLEV_STR
Harald Welteb720bd32009-12-21 16:51:50 +01001291 "How many RxQual measurements are used for averaging")
1292{
Harald Weltedcccb182010-05-16 20:52:23 +02001293 struct gsm_network *gsmnet = gsmnet_from_vty(vty);
Harald Welteb720bd32009-12-21 16:51:50 +01001294 gsmnet->handover.win_rxlev_avg_neigh = atoi(argv[0]);
1295 return CMD_SUCCESS;
1296}
1297
1298DEFUN(cfg_net_ho_pwr_interval, cfg_net_ho_pwr_interval_cmd,
1299 "handover power budget interval <1-99>",
Harald Welte8f0ed552010-05-11 21:53:49 +02001300 HO_PBUDGET_STR
Harald Welteb720bd32009-12-21 16:51:50 +01001301 "How often to check if we have a better cell (SACCH frames)")
1302{
Harald Weltedcccb182010-05-16 20:52:23 +02001303 struct gsm_network *gsmnet = gsmnet_from_vty(vty);
Harald Welteb720bd32009-12-21 16:51:50 +01001304 gsmnet->handover.pwr_interval = atoi(argv[0]);
1305 return CMD_SUCCESS;
1306}
1307
1308DEFUN(cfg_net_ho_pwr_hysteresis, cfg_net_ho_pwr_hysteresis_cmd,
1309 "handover power budget hysteresis <0-999>",
Harald Welte8f0ed552010-05-11 21:53:49 +02001310 HO_PBUDGET_STR
Harald Welteb720bd32009-12-21 16:51:50 +01001311 "How many dB does a neighbor to be stronger to become a HO candidate")
1312{
Harald Weltedcccb182010-05-16 20:52:23 +02001313 struct gsm_network *gsmnet = gsmnet_from_vty(vty);
Harald Welteb720bd32009-12-21 16:51:50 +01001314 gsmnet->handover.pwr_hysteresis = atoi(argv[0]);
1315 return CMD_SUCCESS;
1316}
1317
1318DEFUN(cfg_net_ho_max_distance, cfg_net_ho_max_distance_cmd,
1319 "handover maximum distance <0-9999>",
Harald Welte8f0ed552010-05-11 21:53:49 +02001320 HANDOVER_STR
Harald Welteb720bd32009-12-21 16:51:50 +01001321 "How big is the maximum timing advance before HO is forced")
1322{
Harald Weltedcccb182010-05-16 20:52:23 +02001323 struct gsm_network *gsmnet = gsmnet_from_vty(vty);
Harald Welteb720bd32009-12-21 16:51:50 +01001324 gsmnet->handover.max_distance = atoi(argv[0]);
1325 return CMD_SUCCESS;
1326}
Harald Weltebc814502009-12-19 21:41:52 +01001327
Holger Hans Peter Freyther76fc4a32010-09-06 09:41:50 +08001328DEFUN(cfg_net_pag_any_tch,
1329 cfg_net_pag_any_tch_cmd,
1330 "paging any use tch (0|1)",
1331 "Assign a TCH when receiving a Paging Any request")
1332{
Holger Hans Peter Freytherb0e88b82010-09-06 10:09:19 +08001333 struct gsm_network *gsmnet = gsmnet_from_vty(vty);
Holger Hans Peter Freyther76fc4a32010-09-06 09:41:50 +08001334 gsmnet->pag_any_tch = atoi(argv[0]);
1335 gsm_net_update_ctype(gsmnet);
1336 return CMD_SUCCESS;
1337}
1338
Holger Hans Peter Freytherc8021062009-12-22 08:27:21 +01001339#define DECLARE_TIMER(number, doc) \
Holger Hans Peter Freytherc4d88ad2009-11-21 21:18:38 +01001340 DEFUN(cfg_net_T##number, \
1341 cfg_net_T##number##_cmd, \
1342 "timer t" #number " <0-65535>", \
Harald Welte8f0ed552010-05-11 21:53:49 +02001343 "Configure GSM Timers\n" \
Holger Hans Peter Freytherc8021062009-12-22 08:27:21 +01001344 doc) \
Holger Hans Peter Freytherc4d88ad2009-11-21 21:18:38 +01001345{ \
Harald Weltedcccb182010-05-16 20:52:23 +02001346 struct gsm_network *gsmnet = gsmnet_from_vty(vty); \
Holger Hans Peter Freytherc4d88ad2009-11-21 21:18:38 +01001347 int value = atoi(argv[0]); \
1348 \
1349 if (value < 0 || value > 65535) { \
1350 vty_out(vty, "Timer value %s out of range.%s", \
1351 argv[0], VTY_NEWLINE); \
1352 return CMD_WARNING; \
1353 } \
1354 \
1355 gsmnet->T##number = value; \
1356 return CMD_SUCCESS; \
1357}
1358
Holger Hans Peter Freytherc8021062009-12-22 08:27:21 +01001359DECLARE_TIMER(3101, "Set the timeout value for IMMEDIATE ASSIGNMENT.")
1360DECLARE_TIMER(3103, "Set the timeout value for HANDOVER.")
1361DECLARE_TIMER(3105, "Currently not used.")
1362DECLARE_TIMER(3107, "Currently not used.")
1363DECLARE_TIMER(3109, "Currently not used.")
Holger Hans Peter Freytherf30c0dc2010-05-31 21:33:15 +08001364DECLARE_TIMER(3111, "Set the RSL timeout to wait before releasing the RF Channel.")
Holger Hans Peter Freytherc8021062009-12-22 08:27:21 +01001365DECLARE_TIMER(3113, "Set the time to try paging a subscriber.")
1366DECLARE_TIMER(3115, "Currently not used.")
1367DECLARE_TIMER(3117, "Currently not used.")
1368DECLARE_TIMER(3119, "Currently not used.")
Harald Welte2862dca2010-12-23 14:39:29 +01001369DECLARE_TIMER(3122, "Waiting time (seconds) after IMM ASS REJECT")
Holger Hans Peter Freytherc8021062009-12-22 08:27:21 +01001370DECLARE_TIMER(3141, "Currently not used.")
Holger Hans Peter Freytherc4d88ad2009-11-21 21:18:38 +01001371
Holger Hans Peter Freyther5a3a61d2010-09-06 09:25:48 +08001372DEFUN(cfg_net_dtx,
1373 cfg_net_dtx_cmd,
1374 "dtx-used (0|1)",
1375 "Enable the usage of DTX.\n"
1376 "DTX is enabled/disabled")
1377{
1378 struct gsm_network *gsmnet = gsmnet_from_vty(vty);
1379 gsmnet->dtx_enabled = atoi(argv[0]);
1380 return CMD_SUCCESS;
1381}
Holger Hans Peter Freytherc4d88ad2009-11-21 21:18:38 +01001382
Holger Hans Peter Freytherae9006a2010-12-22 16:26:04 +01001383DEFUN(cfg_net_subscr_keep,
1384 cfg_net_subscr_keep_cmd,
1385 "subscriber-keep-in-ram (0|1)",
1386 "Keep unused subscribers in RAM.\n"
1387 "Delete unused subscribers\n" "Keep unused subscribers\n")
1388{
1389 struct gsm_network *gsmnet = gsmnet_from_vty(vty);
1390 gsmnet->keep_subscr = atoi(argv[0]);
1391 return CMD_SUCCESS;
1392}
1393
Harald Welte5258fc42009-03-28 19:07:53 +00001394/* per-BTS configuration */
1395DEFUN(cfg_bts,
1396 cfg_bts_cmd,
1397 "bts BTS_NR",
Harald Welte8f0ed552010-05-11 21:53:49 +02001398 "Select a BTS to configure\n"
1399 "BTS Number\n")
Harald Welte5258fc42009-03-28 19:07:53 +00001400{
Harald Weltedcccb182010-05-16 20:52:23 +02001401 struct gsm_network *gsmnet = gsmnet_from_vty(vty);
Harald Welte5258fc42009-03-28 19:07:53 +00001402 int bts_nr = atoi(argv[0]);
1403 struct gsm_bts *bts;
1404
Harald Weltee441d9c2009-06-21 16:17:15 +02001405 if (bts_nr > gsmnet->num_bts) {
1406 vty_out(vty, "%% The next unused BTS number is %u%s",
1407 gsmnet->num_bts, VTY_NEWLINE);
Harald Welte5258fc42009-03-28 19:07:53 +00001408 return CMD_WARNING;
Harald Weltee441d9c2009-06-21 16:17:15 +02001409 } else if (bts_nr == gsmnet->num_bts) {
1410 /* allocate a new one */
1411 bts = gsm_bts_alloc(gsmnet, GSM_BTS_TYPE_UNKNOWN,
1412 HARDCODED_TSC, HARDCODED_BSIC);
Holger Hans Peter Freytheracf8a0c2010-03-29 08:47:44 +02001413 } else
Harald Weltee441d9c2009-06-21 16:17:15 +02001414 bts = gsm_bts_num(gsmnet, bts_nr);
1415
Daniel Willmannf15c2762010-01-11 13:43:07 +01001416 if (!bts) {
1417 vty_out(vty, "%% Unable to allocate BTS %u%s",
1418 gsmnet->num_bts, VTY_NEWLINE);
Harald Weltee441d9c2009-06-21 16:17:15 +02001419 return CMD_WARNING;
Daniel Willmannf15c2762010-01-11 13:43:07 +01001420 }
Harald Welte5258fc42009-03-28 19:07:53 +00001421
1422 vty->index = bts;
Harald Welte197dea92010-05-14 17:59:53 +02001423 vty->index_sub = &bts->description;
Harald Welte5258fc42009-03-28 19:07:53 +00001424 vty->node = BTS_NODE;
1425
1426 return CMD_SUCCESS;
1427}
1428
1429DEFUN(cfg_bts_type,
1430 cfg_bts_type_cmd,
1431 "type TYPE",
1432 "Set the BTS type\n")
1433{
1434 struct gsm_bts *bts = vty->index;
Harald Welte39315c42010-01-10 18:01:52 +01001435 int rc;
Harald Welte5258fc42009-03-28 19:07:53 +00001436
Harald Welte39315c42010-01-10 18:01:52 +01001437 rc = gsm_set_bts_type(bts, parse_btstype(argv[0]));
1438 if (rc < 0)
1439 return CMD_WARNING;
Harald Welte8175e952009-10-20 00:22:00 +02001440
Harald Welte5258fc42009-03-28 19:07:53 +00001441 return CMD_SUCCESS;
1442}
1443
Harald Weltefcd24452009-06-20 18:15:19 +02001444DEFUN(cfg_bts_band,
1445 cfg_bts_band_cmd,
1446 "band BAND",
1447 "Set the frequency band of this BTS\n")
1448{
1449 struct gsm_bts *bts = vty->index;
Harald Welte42581822009-08-08 16:12:58 +02001450 int band = gsm_band_parse(argv[0]);
Harald Weltefcd24452009-06-20 18:15:19 +02001451
1452 if (band < 0) {
1453 vty_out(vty, "%% BAND %d is not a valid GSM band%s",
1454 band, VTY_NEWLINE);
1455 return CMD_WARNING;
1456 }
1457
1458 bts->band = band;
1459
1460 return CMD_SUCCESS;
1461}
1462
Holger Hans Peter Freytherc4a49e32009-08-21 14:44:12 +02001463DEFUN(cfg_bts_ci,
1464 cfg_bts_ci_cmd,
1465 "cell_identity <0-65535>",
1466 "Set the Cell identity of this BTS\n")
1467{
1468 struct gsm_bts *bts = vty->index;
1469 int ci = atoi(argv[0]);
1470
1471 if (ci < 0 || ci > 0xffff) {
1472 vty_out(vty, "%% CI %d is not in the valid range (0-65535)%s",
1473 ci, VTY_NEWLINE);
1474 return CMD_WARNING;
1475 }
1476 bts->cell_identity = ci;
1477
1478 return CMD_SUCCESS;
1479}
1480
Harald Welte5258fc42009-03-28 19:07:53 +00001481DEFUN(cfg_bts_lac,
1482 cfg_bts_lac_cmd,
Holger Hans Peter Freyther0b7f4b32009-09-29 14:02:33 +02001483 "location_area_code <0-65535>",
Harald Welte5258fc42009-03-28 19:07:53 +00001484 "Set the Location Area Code (LAC) of this BTS\n")
1485{
1486 struct gsm_bts *bts = vty->index;
1487 int lac = atoi(argv[0]);
1488
Holger Hans Peter Freyther0b7f4b32009-09-29 14:02:33 +02001489 if (lac < 0 || lac > 0xffff) {
1490 vty_out(vty, "%% LAC %d is not in the valid range (0-65535)%s",
Harald Welte5258fc42009-03-28 19:07:53 +00001491 lac, VTY_NEWLINE);
1492 return CMD_WARNING;
1493 }
Holger Hans Peter Freythere48b9562009-10-01 04:07:15 +02001494
1495 if (lac == GSM_LAC_RESERVED_DETACHED || lac == GSM_LAC_RESERVED_ALL_BTS) {
1496 vty_out(vty, "%% LAC %d is reserved by GSM 04.08%s",
1497 lac, VTY_NEWLINE);
1498 return CMD_WARNING;
1499 }
1500
Harald Welte5258fc42009-03-28 19:07:53 +00001501 bts->location_area_code = lac;
1502
1503 return CMD_SUCCESS;
1504}
1505
Harald Weltea43f7892009-12-01 18:04:30 +05301506
Harald Welte5258fc42009-03-28 19:07:53 +00001507DEFUN(cfg_bts_tsc,
1508 cfg_bts_tsc_cmd,
1509 "training_sequence_code <0-255>",
1510 "Set the Training Sequence Code (TSC) of this BTS\n")
1511{
1512 struct gsm_bts *bts = vty->index;
1513 int tsc = atoi(argv[0]);
1514
1515 if (tsc < 0 || tsc > 0xff) {
1516 vty_out(vty, "%% TSC %d is not in the valid range (0-255)%s",
1517 tsc, VTY_NEWLINE);
1518 return CMD_WARNING;
1519 }
1520 bts->tsc = tsc;
1521
1522 return CMD_SUCCESS;
1523}
1524
Harald Welte78f2f502009-05-23 16:56:52 +00001525DEFUN(cfg_bts_bsic,
1526 cfg_bts_bsic_cmd,
1527 "base_station_id_code <0-63>",
1528 "Set the Base Station Identity Code (BSIC) of this BTS\n")
1529{
1530 struct gsm_bts *bts = vty->index;
1531 int bsic = atoi(argv[0]);
1532
1533 if (bsic < 0 || bsic > 0x3f) {
Harald Welte42581822009-08-08 16:12:58 +02001534 vty_out(vty, "%% BSIC %d is not in the valid range (0-255)%s",
Harald Welte78f2f502009-05-23 16:56:52 +00001535 bsic, VTY_NEWLINE);
1536 return CMD_WARNING;
1537 }
1538 bts->bsic = bsic;
1539
1540 return CMD_SUCCESS;
1541}
1542
1543
Harald Welte4cc34222009-05-01 15:12:31 +00001544DEFUN(cfg_bts_unit_id,
1545 cfg_bts_unit_id_cmd,
Harald Welte07dc73d2009-08-07 13:27:09 +02001546 "ip.access unit_id <0-65534> <0-255>",
1547 "Set the ip.access BTS Unit ID of this BTS\n")
Harald Welte4cc34222009-05-01 15:12:31 +00001548{
1549 struct gsm_bts *bts = vty->index;
1550 int site_id = atoi(argv[0]);
1551 int bts_id = atoi(argv[1]);
1552
Harald Welte07dc73d2009-08-07 13:27:09 +02001553 if (!is_ipaccess_bts(bts)) {
1554 vty_out(vty, "%% BTS is not of ip.access type%s", VTY_NEWLINE);
1555 return CMD_WARNING;
1556 }
1557
Harald Welte4cc34222009-05-01 15:12:31 +00001558 bts->ip_access.site_id = site_id;
1559 bts->ip_access.bts_id = bts_id;
1560
1561 return CMD_SUCCESS;
1562}
1563
Harald Welte8f0ed552010-05-11 21:53:49 +02001564#define OML_STR "Organization & Maintenance Link\n"
1565#define IPA_STR "ip.access Specific Options\n"
1566
Harald Welte8175e952009-10-20 00:22:00 +02001567DEFUN(cfg_bts_stream_id,
1568 cfg_bts_stream_id_cmd,
1569 "oml ip.access stream_id <0-255>",
Harald Welte8f0ed552010-05-11 21:53:49 +02001570 OML_STR IPA_STR
Harald Welte8175e952009-10-20 00:22:00 +02001571 "Set the ip.access Stream ID of the OML link of this BTS\n")
1572{
1573 struct gsm_bts *bts = vty->index;
1574 int stream_id = atoi(argv[0]);
1575
1576 if (!is_ipaccess_bts(bts)) {
1577 vty_out(vty, "%% BTS is not of ip.access type%s", VTY_NEWLINE);
1578 return CMD_WARNING;
1579 }
1580
1581 bts->oml_tei = stream_id;
1582
1583 return CMD_SUCCESS;
1584}
1585
Harald Welte8f0ed552010-05-11 21:53:49 +02001586#define OML_E1_STR OML_STR "E1 Line\n"
Harald Welte8175e952009-10-20 00:22:00 +02001587
Harald Welte42581822009-08-08 16:12:58 +02001588DEFUN(cfg_bts_oml_e1,
1589 cfg_bts_oml_e1_cmd,
1590 "oml e1 line E1_LINE timeslot <1-31> sub-slot (0|1|2|3|full)",
Harald Welte8f0ed552010-05-11 21:53:49 +02001591 OML_E1_STR
Harald Welte42581822009-08-08 16:12:58 +02001592 "E1 interface to be used for OML\n")
1593{
1594 struct gsm_bts *bts = vty->index;
1595
1596 parse_e1_link(&bts->oml_e1_link, argv[0], argv[1], argv[2]);
1597
1598 return CMD_SUCCESS;
1599}
1600
1601
1602DEFUN(cfg_bts_oml_e1_tei,
1603 cfg_bts_oml_e1_tei_cmd,
1604 "oml e1 tei <0-63>",
Harald Welte8f0ed552010-05-11 21:53:49 +02001605 OML_E1_STR
Harald Welte42581822009-08-08 16:12:58 +02001606 "Set the TEI to be used for OML")
1607{
1608 struct gsm_bts *bts = vty->index;
1609
1610 bts->oml_tei = atoi(argv[0]);
1611
1612 return CMD_SUCCESS;
1613}
1614
Harald Welte7a8fa412009-08-10 13:48:16 +02001615DEFUN(cfg_bts_challoc, cfg_bts_challoc_cmd,
1616 "channel allocator (ascending|descending)",
Harald Welte8f0ed552010-05-11 21:53:49 +02001617 "Channnel Allocator\n" "Channel Allocator\n"
1618 "Allocate Timeslots and Transceivers in ascending order\n"
1619 "Allocate Timeslots and Transceivers in descending order\n")
Harald Welte7a8fa412009-08-10 13:48:16 +02001620{
1621 struct gsm_bts *bts = vty->index;
1622
1623 if (!strcmp(argv[0], "ascending"))
1624 bts->chan_alloc_reverse = 0;
1625 else
1626 bts->chan_alloc_reverse = 1;
1627
1628 return CMD_SUCCESS;
1629}
1630
Harald Welte8f0ed552010-05-11 21:53:49 +02001631#define RACH_STR "Random Access Control Channel\n"
1632
Sylvain Munaut4010f1e2009-12-22 13:43:26 +01001633DEFUN(cfg_bts_rach_tx_integer,
1634 cfg_bts_rach_tx_integer_cmd,
1635 "rach tx integer <0-15>",
Harald Welte8f0ed552010-05-11 21:53:49 +02001636 RACH_STR
Sylvain Munaut4010f1e2009-12-22 13:43:26 +01001637 "Set the raw tx integer value in RACH Control parameters IE")
1638{
1639 struct gsm_bts *bts = vty->index;
1640 bts->si_common.rach_control.tx_integer = atoi(argv[0]) & 0xf;
1641 return CMD_SUCCESS;
1642}
1643
1644DEFUN(cfg_bts_rach_max_trans,
1645 cfg_bts_rach_max_trans_cmd,
1646 "rach max transmission (1|2|4|7)",
Harald Welte8f0ed552010-05-11 21:53:49 +02001647 RACH_STR
Sylvain Munaut4010f1e2009-12-22 13:43:26 +01001648 "Set the maximum number of RACH burst transmissions")
1649{
1650 struct gsm_bts *bts = vty->index;
1651 bts->si_common.rach_control.max_trans = rach_max_trans_val2raw(atoi(argv[0]));
1652 return CMD_SUCCESS;
1653}
1654
Harald Welte8f0ed552010-05-11 21:53:49 +02001655#define NM_STR "Network Management\n"
1656
Holger Hans Peter Freyther95c22902010-04-25 23:08:39 +08001657DEFUN(cfg_bts_rach_nm_b_thresh,
1658 cfg_bts_rach_nm_b_thresh_cmd,
1659 "rach nm busy threshold <0-255>",
Harald Welte8f0ed552010-05-11 21:53:49 +02001660 RACH_STR NM_STR
1661 "Set the NM Busy Threshold in dB")
Holger Hans Peter Freyther95c22902010-04-25 23:08:39 +08001662{
1663 struct gsm_bts *bts = vty->index;
1664 bts->rach_b_thresh = atoi(argv[0]);
1665 return CMD_SUCCESS;
1666}
1667
1668DEFUN(cfg_bts_rach_nm_ldavg,
1669 cfg_bts_rach_nm_ldavg_cmd,
1670 "rach nm load average <0-65535>",
Harald Welte8f0ed552010-05-11 21:53:49 +02001671 RACH_STR NM_STR
1672 "Set the NM Loadaverage Slots value")
Holger Hans Peter Freyther95c22902010-04-25 23:08:39 +08001673{
1674 struct gsm_bts *bts = vty->index;
1675 bts->rach_ldavg_slots = atoi(argv[0]);
1676 return CMD_SUCCESS;
1677}
1678
Harald Welte (local)5dececf2009-08-12 13:28:23 +02001679DEFUN(cfg_bts_cell_barred, cfg_bts_cell_barred_cmd,
1680 "cell barred (0|1)",
1681 "Should this cell be barred from access?")
1682{
1683 struct gsm_bts *bts = vty->index;
1684
Harald Welte71355012009-12-21 23:08:18 +01001685 bts->si_common.rach_control.cell_bar = atoi(argv[0]);
Harald Welte (local)5dececf2009-08-12 13:28:23 +02001686
1687 return CMD_SUCCESS;
1688}
1689
Holger Hans Peter Freyther3a0a4632010-05-14 00:39:19 +08001690DEFUN(cfg_bts_rach_ec_allowed, cfg_bts_rach_ec_allowed_cmd,
1691 "rach emergency call allowed (0|1)",
1692 "Should this cell allow emergency calls?")
1693{
1694 struct gsm_bts *bts = vty->index;
1695
1696 if (atoi(argv[0]) == 0)
1697 bts->si_common.rach_control.t2 |= 0x4;
1698 else
1699 bts->si_common.rach_control.t2 &= ~0x4;
1700
1701 return CMD_SUCCESS;
1702}
1703
Harald Welte (local)0e451d02009-08-13 10:14:26 +02001704DEFUN(cfg_bts_ms_max_power, cfg_bts_ms_max_power_cmd,
1705 "ms max power <0-40>",
1706 "Maximum transmit power of the MS")
1707{
1708 struct gsm_bts *bts = vty->index;
1709
1710 bts->ms_max_power = atoi(argv[0]);
1711
1712 return CMD_SUCCESS;
1713}
1714
Harald Welte73225282009-12-12 18:17:25 +01001715DEFUN(cfg_bts_cell_resel_hyst, cfg_bts_cell_resel_hyst_cmd,
1716 "cell reselection hysteresis <0-14>",
1717 "Cell Re-Selection Hysteresis in dB")
1718{
1719 struct gsm_bts *bts = vty->index;
1720
1721 bts->si_common.cell_sel_par.cell_resel_hyst = atoi(argv[0])/2;
1722
1723 return CMD_SUCCESS;
1724}
1725
1726DEFUN(cfg_bts_rxlev_acc_min, cfg_bts_rxlev_acc_min_cmd,
1727 "rxlev access min <0-63>",
1728 "Minimum RxLev needed for cell access (better than -110dBm)")
1729{
1730 struct gsm_bts *bts = vty->index;
1731
1732 bts->si_common.cell_sel_par.rxlev_acc_min = atoi(argv[0]);
1733
1734 return CMD_SUCCESS;
1735}
1736
Sylvain Munaute0b06b02010-11-28 18:17:28 +01001737DEFUN(cfg_bts_cell_bar_qualify, cfg_bts_cell_bar_qualify_cmd,
1738 "cell bar qualify (0|1)",
1739 "Cell Bar Qualify")
1740{
1741 struct gsm_bts *bts = vty->index;
1742
1743 bts->si_common.cell_ro_sel_par.present = 1;
1744 bts->si_common.cell_ro_sel_par.cbq = atoi(argv[0]);
1745
1746 return CMD_SUCCESS;
1747}
1748
1749DEFUN(cfg_bts_cell_resel_ofs, cfg_bts_cell_resel_ofs_cmd,
1750 "cell reselection offset <0-126>",
1751 "Cell Re-Selection Offset in dB")
1752{
1753 struct gsm_bts *bts = vty->index;
1754
1755 bts->si_common.cell_ro_sel_par.present = 1;
1756 bts->si_common.cell_ro_sel_par.cell_resel_off = atoi(argv[0])/2;
1757
1758 return CMD_SUCCESS;
1759}
1760
1761DEFUN(cfg_bts_temp_ofs, cfg_bts_temp_ofs_cmd,
1762 "temporary offset <0-60>",
1763 "Cell selection temporary negative offset in dB")
1764{
1765 struct gsm_bts *bts = vty->index;
1766
1767 bts->si_common.cell_ro_sel_par.present = 1;
1768 bts->si_common.cell_ro_sel_par.temp_offs = atoi(argv[0])/10;
1769
1770 return CMD_SUCCESS;
1771}
1772
1773DEFUN(cfg_bts_temp_ofs_inf, cfg_bts_temp_ofs_inf_cmd,
1774 "temporary offset infinite",
1775 "Sets cell selection temporary negative offset to infinity")
1776{
1777 struct gsm_bts *bts = vty->index;
1778
1779 bts->si_common.cell_ro_sel_par.present = 1;
1780 bts->si_common.cell_ro_sel_par.temp_offs = 7;
1781
1782 return CMD_SUCCESS;
1783}
1784
1785DEFUN(cfg_bts_penalty_time, cfg_bts_penalty_time_cmd,
1786 "penalty time <20-620>",
1787 "Cell selection penalty time in seconds (by 20s increments)")
1788{
1789 struct gsm_bts *bts = vty->index;
1790
1791 bts->si_common.cell_ro_sel_par.present = 1;
1792 bts->si_common.cell_ro_sel_par.penalty_time = (atoi(argv[0])-20)/20;
1793
1794 return CMD_SUCCESS;
1795}
1796
1797DEFUN(cfg_bts_penalty_time_rsvd, cfg_bts_penalty_time_rsvd_cmd,
1798 "penalty time reserved",
1799 "Set cell selection penalty time to reserved value 31\n"
1800 "(indicate that CELL_RESELECT_OFFSET is subtracted from C2 "
1801 "and TEMPORARY_OFFSET is ignored)")
1802{
1803 struct gsm_bts *bts = vty->index;
1804
1805 bts->si_common.cell_ro_sel_par.present = 1;
1806 bts->si_common.cell_ro_sel_par.penalty_time = 31;
1807
1808 return CMD_SUCCESS;
1809}
1810
Harald Welte (local)efc92312009-08-14 23:09:25 +02001811DEFUN(cfg_bts_per_loc_upd, cfg_bts_per_loc_upd_cmd,
1812 "periodic location update <0-1530>",
1813 "Periodic Location Updating Interval in Minutes")
1814{
1815 struct gsm_bts *bts = vty->index;
1816
Dieter Spaard6613e02010-10-05 21:10:55 +02001817 bts->si_common.chan_desc.t3212 = atoi(argv[0]) / 6;
Harald Welte (local)efc92312009-08-14 23:09:25 +02001818
1819 return CMD_SUCCESS;
1820}
1821
Harald Welte8f0ed552010-05-11 21:53:49 +02001822#define GPRS_TEXT "GPRS Packet Network\n"
1823
Harald Welteaf387632010-03-14 23:30:30 +08001824DEFUN(cfg_bts_prs_bvci, cfg_bts_gprs_bvci_cmd,
Harald Welte57ba7e32010-04-18 14:00:26 +02001825 "gprs cell bvci <2-65535>",
Harald Welte8f0ed552010-05-11 21:53:49 +02001826 GPRS_TEXT
1827 "GPRS Cell Settings\n"
Harald Welte97a282b2010-03-14 15:37:43 +08001828 "GPRS BSSGP VC Identifier")
1829{
1830 struct gsm_bts *bts = vty->index;
1831
Harald Welte4511d892010-04-18 15:51:20 +02001832 if (bts->gprs.mode == BTS_GPRS_NONE) {
Harald Welte94036702010-03-14 23:56:56 +08001833 vty_out(vty, "%% GPRS not enabled on this BTS%s", VTY_NEWLINE);
1834 return CMD_WARNING;
1835 }
1836
Harald Welte97a282b2010-03-14 15:37:43 +08001837 bts->gprs.cell.bvci = atoi(argv[0]);
1838
1839 return CMD_SUCCESS;
1840}
1841
Harald Weltea5731cf2010-03-22 11:48:36 +08001842DEFUN(cfg_bts_gprs_nsei, cfg_bts_gprs_nsei_cmd,
1843 "gprs nsei <0-65535>",
Harald Welte8f0ed552010-05-11 21:53:49 +02001844 GPRS_TEXT
Harald Weltea5731cf2010-03-22 11:48:36 +08001845 "GPRS NS Entity Identifier")
1846{
1847 struct gsm_bts *bts = vty->index;
1848
Harald Welte4511d892010-04-18 15:51:20 +02001849 if (bts->gprs.mode == BTS_GPRS_NONE) {
Harald Weltea5731cf2010-03-22 11:48:36 +08001850 vty_out(vty, "%% GPRS not enabled on this BTS%s", VTY_NEWLINE);
1851 return CMD_WARNING;
1852 }
1853
1854 bts->gprs.nse.nsei = atoi(argv[0]);
1855
1856 return CMD_SUCCESS;
1857}
1858
Harald Welte8f0ed552010-05-11 21:53:49 +02001859#define NSVC_TEXT "Network Service Virtual Connection (NS-VC)\n" \
1860 "NSVC Logical Number\n"
Harald Weltea5731cf2010-03-22 11:48:36 +08001861
Harald Welte97a282b2010-03-14 15:37:43 +08001862DEFUN(cfg_bts_gprs_nsvci, cfg_bts_gprs_nsvci_cmd,
1863 "gprs nsvc <0-1> nsvci <0-65535>",
Harald Welte8f0ed552010-05-11 21:53:49 +02001864 GPRS_TEXT NSVC_TEXT
1865 "NS Virtual Connection Identifier\n"
Harald Welte97a282b2010-03-14 15:37:43 +08001866 "GPRS NS VC Identifier")
1867{
1868 struct gsm_bts *bts = vty->index;
1869 int idx = atoi(argv[0]);
1870
Harald Welte4511d892010-04-18 15:51:20 +02001871 if (bts->gprs.mode == BTS_GPRS_NONE) {
Harald Welte94036702010-03-14 23:56:56 +08001872 vty_out(vty, "%% GPRS not enabled on this BTS%s", VTY_NEWLINE);
1873 return CMD_WARNING;
1874 }
1875
Harald Welte97a282b2010-03-14 15:37:43 +08001876 bts->gprs.nsvc[idx].nsvci = atoi(argv[1]);
1877
1878 return CMD_SUCCESS;
1879}
1880
Harald Welteaf387632010-03-14 23:30:30 +08001881DEFUN(cfg_bts_gprs_nsvc_lport, cfg_bts_gprs_nsvc_lport_cmd,
1882 "gprs nsvc <0-1> local udp port <0-65535>",
Harald Welte8f0ed552010-05-11 21:53:49 +02001883 GPRS_TEXT NSVC_TEXT
Harald Welteaf387632010-03-14 23:30:30 +08001884 "GPRS NS Local UDP Port")
1885{
1886 struct gsm_bts *bts = vty->index;
1887 int idx = atoi(argv[0]);
1888
Harald Welte4511d892010-04-18 15:51:20 +02001889 if (bts->gprs.mode == BTS_GPRS_NONE) {
Harald Welte94036702010-03-14 23:56:56 +08001890 vty_out(vty, "%% GPRS not enabled on this BTS%s", VTY_NEWLINE);
1891 return CMD_WARNING;
1892 }
1893
Harald Welteaf387632010-03-14 23:30:30 +08001894 bts->gprs.nsvc[idx].local_port = atoi(argv[1]);
1895
1896 return CMD_SUCCESS;
1897}
1898
1899DEFUN(cfg_bts_gprs_nsvc_rport, cfg_bts_gprs_nsvc_rport_cmd,
1900 "gprs nsvc <0-1> remote udp port <0-65535>",
Harald Welte8f0ed552010-05-11 21:53:49 +02001901 GPRS_TEXT NSVC_TEXT
Harald Welteaf387632010-03-14 23:30:30 +08001902 "GPRS NS Remote UDP Port")
1903{
1904 struct gsm_bts *bts = vty->index;
1905 int idx = atoi(argv[0]);
1906
Harald Welte4511d892010-04-18 15:51:20 +02001907 if (bts->gprs.mode == BTS_GPRS_NONE) {
Harald Welte94036702010-03-14 23:56:56 +08001908 vty_out(vty, "%% GPRS not enabled on this BTS%s", VTY_NEWLINE);
1909 return CMD_WARNING;
1910 }
1911
Harald Welteaf387632010-03-14 23:30:30 +08001912 bts->gprs.nsvc[idx].remote_port = atoi(argv[1]);
1913
1914 return CMD_SUCCESS;
1915}
1916
1917DEFUN(cfg_bts_gprs_nsvc_rip, cfg_bts_gprs_nsvc_rip_cmd,
1918 "gprs nsvc <0-1> remote ip A.B.C.D",
Harald Welte8f0ed552010-05-11 21:53:49 +02001919 GPRS_TEXT NSVC_TEXT
Harald Welteaf387632010-03-14 23:30:30 +08001920 "GPRS NS Remote IP Address")
1921{
1922 struct gsm_bts *bts = vty->index;
1923 int idx = atoi(argv[0]);
1924 struct in_addr ia;
1925
Harald Welte4511d892010-04-18 15:51:20 +02001926 if (bts->gprs.mode == BTS_GPRS_NONE) {
Harald Welte94036702010-03-14 23:56:56 +08001927 vty_out(vty, "%% GPRS not enabled on this BTS%s", VTY_NEWLINE);
1928 return CMD_WARNING;
1929 }
1930
Harald Welteaf387632010-03-14 23:30:30 +08001931 inet_aton(argv[1], &ia);
1932 bts->gprs.nsvc[idx].remote_ip = ntohl(ia.s_addr);
1933
1934 return CMD_SUCCESS;
1935}
1936
Holger Hans Peter Freythere66bf1f2010-09-06 10:11:25 +08001937DEFUN(cfg_bts_pag_free, cfg_bts_pag_free_cmd,
1938 "paging free FREE_NR",
1939 "Only page when having a certain amount of free slots. -1 to disable")
1940{
1941 struct gsm_bts *bts = vty->index;
1942
1943 bts->paging.free_chans_need = atoi(argv[0]);
1944 return CMD_SUCCESS;
1945}
1946
Harald Welte615e9562010-05-11 23:50:21 +02001947DEFUN(cfg_bts_gprs_ns_timer, cfg_bts_gprs_ns_timer_cmd,
1948 "gprs ns timer " NS_TIMERS " <0-255>",
1949 GPRS_TEXT "Network Service\n"
1950 "Network Service Timer\n"
1951 NS_TIMERS_HELP "Timer Value\n")
1952{
1953 struct gsm_bts *bts = vty->index;
1954 int idx = get_string_value(gprs_ns_timer_strs, argv[0]);
1955 int val = atoi(argv[1]);
1956
1957 if (bts->gprs.mode == BTS_GPRS_NONE) {
1958 vty_out(vty, "%% GPRS not enabled on this BTS%s", VTY_NEWLINE);
1959 return CMD_WARNING;
1960 }
1961
1962 if (idx < 0 || idx >= ARRAY_SIZE(bts->gprs.nse.timer))
1963 return CMD_WARNING;
1964
1965 bts->gprs.nse.timer[idx] = val;
1966
1967 return CMD_SUCCESS;
1968}
1969
1970#define BSSGP_TIMERS "(blocking-timer|blocking-retries|unblocking-retries|reset-timer|reset-retries|suspend-timer|suspend-retries|resume-timer|resume-retries|capability-update-timer|capability-update-retries)"
Harald Welte28326062010-05-14 20:05:17 +02001971#define BSSGP_TIMERS_HELP \
1972 "Tbvc-block timeout\n" \
1973 "Tbvc-block retries\n" \
1974 "Tbvc-unblock retries\n" \
1975 "Tbvcc-reset timeout\n" \
1976 "Tbvc-reset retries\n" \
1977 "Tbvc-suspend timeout\n" \
1978 "Tbvc-suspend retries\n" \
1979 "Tbvc-resume timeout\n" \
1980 "Tbvc-resume retries\n" \
1981 "Tbvc-capa-update timeout\n" \
1982 "Tbvc-capa-update retries\n"
Harald Welte615e9562010-05-11 23:50:21 +02001983
1984DEFUN(cfg_bts_gprs_cell_timer, cfg_bts_gprs_cell_timer_cmd,
1985 "gprs cell timer " BSSGP_TIMERS " <0-255>",
1986 GPRS_TEXT "Cell / BSSGP\n"
1987 "Cell/BSSGP Timer\n"
1988 BSSGP_TIMERS_HELP "Timer Value\n")
1989{
1990 struct gsm_bts *bts = vty->index;
1991 int idx = get_string_value(gprs_bssgp_cfg_strs, argv[0]);
1992 int val = atoi(argv[1]);
1993
1994 if (bts->gprs.mode == BTS_GPRS_NONE) {
1995 vty_out(vty, "%% GPRS not enabled on this BTS%s", VTY_NEWLINE);
1996 return CMD_WARNING;
1997 }
1998
1999 if (idx < 0 || idx >= ARRAY_SIZE(bts->gprs.cell.timer))
2000 return CMD_WARNING;
2001
2002 bts->gprs.cell.timer[idx] = val;
2003
2004 return CMD_SUCCESS;
2005}
2006
Harald Welte97a282b2010-03-14 15:37:43 +08002007DEFUN(cfg_bts_gprs_rac, cfg_bts_gprs_rac_cmd,
2008 "gprs routing area <0-255>",
Harald Welte8f0ed552010-05-11 21:53:49 +02002009 GPRS_TEXT
Harald Welte97a282b2010-03-14 15:37:43 +08002010 "GPRS Routing Area Code")
2011{
2012 struct gsm_bts *bts = vty->index;
2013
Harald Welte4511d892010-04-18 15:51:20 +02002014 if (bts->gprs.mode == BTS_GPRS_NONE) {
Harald Welte94036702010-03-14 23:56:56 +08002015 vty_out(vty, "%% GPRS not enabled on this BTS%s", VTY_NEWLINE);
2016 return CMD_WARNING;
2017 }
2018
Harald Welte97a282b2010-03-14 15:37:43 +08002019 bts->gprs.rac = atoi(argv[0]);
2020
2021 return CMD_SUCCESS;
2022}
2023
Harald Welte4511d892010-04-18 15:51:20 +02002024DEFUN(cfg_bts_gprs_mode, cfg_bts_gprs_mode_cmd,
2025 "gprs mode (none|gprs|egprs)",
Harald Welte8f0ed552010-05-11 21:53:49 +02002026 GPRS_TEXT
2027 "GPRS Mode for this BTS\n"
2028 "GPRS Disabled on this BTS\n"
2029 "GPRS Enabled on this BTS\n"
2030 "EGPRS (EDGE) Enabled on this BTS\n")
Harald Welteaf387632010-03-14 23:30:30 +08002031{
2032 struct gsm_bts *bts = vty->index;
Harald Weltef3d8e922010-06-14 22:44:42 +02002033 enum bts_gprs_mode mode = bts_gprs_mode_parse(argv[0]);
Harald Welteaf387632010-03-14 23:30:30 +08002034
Harald Weltef3d8e922010-06-14 22:44:42 +02002035 if (mode != BTS_GPRS_NONE &&
2036 !gsm_bts_has_feature(bts, BTS_FEAT_GPRS)) {
2037 vty_out(vty, "This BTS type does not support %s%s", argv[0],
2038 VTY_NEWLINE);
2039 return CMD_WARNING;
2040 }
2041 if (mode == BTS_GPRS_EGPRS &&
2042 !gsm_bts_has_feature(bts, BTS_FEAT_EGPRS)) {
2043 vty_out(vty, "This BTS type does not support %s%s", argv[0],
2044 VTY_NEWLINE);
2045 return CMD_WARNING;
2046 }
2047
2048 bts->gprs.mode = mode;
Harald Welteaf387632010-03-14 23:30:30 +08002049
2050 return CMD_SUCCESS;
2051}
2052
Harald Welte9fbff4a2010-07-30 11:50:09 +02002053#define SI_TEXT "System Information Messages\n"
2054#define SI_TYPE_TEXT "(1|2|3|4|5|6|7|8|9|10|13|16|17|18|19|20|2bis|2ter|2quater|5bis|5ter)"
2055#define SI_TYPE_HELP "System Information Type 1\n" \
2056 "System Information Type 2\n" \
2057 "System Information Type 3\n" \
2058 "System Information Type 4\n" \
2059 "System Information Type 5\n" \
2060 "System Information Type 6\n" \
2061 "System Information Type 7\n" \
2062 "System Information Type 8\n" \
2063 "System Information Type 9\n" \
2064 "System Information Type 10\n" \
2065 "System Information Type 13\n" \
2066 "System Information Type 16\n" \
2067 "System Information Type 17\n" \
2068 "System Information Type 18\n" \
2069 "System Information Type 19\n" \
2070 "System Information Type 20\n" \
2071 "System Information Type 2bis\n" \
2072 "System Information Type 2ter\n" \
2073 "System Information Type 2quater\n" \
2074 "System Information Type 5bis\n" \
2075 "System Information Type 5ter\n"
2076
2077DEFUN(cfg_bts_si_mode, cfg_bts_si_mode_cmd,
2078 "system-information " SI_TYPE_TEXT " mode (static|computed)",
2079 SI_TEXT SI_TYPE_HELP
2080 "System Information Mode\n"
2081 "Static user-specified\n"
2082 "Dynamic, BSC-computed\n")
2083{
2084 struct gsm_bts *bts = vty->index;
2085 int type;
2086
2087 type = get_string_value(osmo_sitype_strs, argv[0]);
2088 if (type < 0) {
2089 vty_out(vty, "Error SI Type%s", VTY_NEWLINE);
2090 return CMD_WARNING;
2091 }
2092
2093 if (!strcmp(argv[1], "static"))
2094 bts->si_mode_static |= (1 << type);
2095 else
2096 bts->si_mode_static &= ~(1 << type);
2097
2098 return CMD_SUCCESS;
2099}
2100
2101DEFUN(cfg_bts_si_static, cfg_bts_si_static_cmd,
2102 "system-information " SI_TYPE_TEXT " static HEXSTRING",
2103 SI_TEXT SI_TYPE_HELP
2104 "Static System Information filling\n"
2105 "Static user-specified SI content in HEX notation\n")
2106{
2107 struct gsm_bts *bts = vty->index;
2108 int rc, type;
2109
2110 type = get_string_value(osmo_sitype_strs, argv[0]);
2111 if (type < 0) {
2112 vty_out(vty, "Error SI Type%s", VTY_NEWLINE);
2113 return CMD_WARNING;
2114 }
2115
2116 if (!(bts->si_mode_static & (1 << type))) {
2117 vty_out(vty, "SI Type %s is not configured in static mode%s",
2118 get_value_string(osmo_sitype_strs, type), VTY_NEWLINE);
2119 return CMD_WARNING;
2120 }
2121
Harald Welte290aaed2010-07-30 11:53:18 +02002122 /* Fill buffer with padding pattern */
2123 memset(bts->si_buf[type], 0x2b, sizeof(bts->si_buf[type]));
2124
2125 /* Parse the user-specified SI in hex format, [partially] overwriting padding */
Harald Welte9fbff4a2010-07-30 11:50:09 +02002126 rc = hexparse(argv[1], bts->si_buf[type], sizeof(bts->si_buf[0]));
2127 if (rc < 0 || rc > sizeof(bts->si_buf[0])) {
2128 vty_out(vty, "Error parsing HEXSTRING%s", VTY_NEWLINE);
2129 return CMD_WARNING;
2130 }
2131
2132 /* Mark this SI as present */
2133 bts->si_valid |= (1 << type);
2134
2135 return CMD_SUCCESS;
2136}
2137
Harald Welte32c09622011-01-11 23:44:56 +01002138DEFUN(cfg_bts_neigh_mode, cfg_bts_neigh_mode_cmd,
2139 "neighbor-list mode (automatic|manual)",
2140 "Neighbor List\n" "Mode of Neighbor List generation\n"
2141 "Automatically from all BTS in this OpenBSC\n" "Manual\n")
2142{
2143 struct gsm_bts *bts = vty->index;
2144
2145 if (!strcmp(argv[0], "manual")) {
2146 /* make sure we clear the current list when switching to
2147 * manual mode */
2148 if (bts->neigh_list_manual_mode == 0)
2149 memset(&bts->si_common.data.neigh_list, 0,
2150 sizeof(bts->si_common.data.neigh_list));
2151 bts->neigh_list_manual_mode = 1;
2152 } else
2153 bts->neigh_list_manual_mode = 0;
2154
2155 return CMD_SUCCESS;
2156}
2157
2158DEFUN(cfg_bts_neigh, cfg_bts_neigh_cmd,
2159 "neighbor-list (add|del) arfcn <0-1024>",
2160 "Neighbor List\n" "Add to manual neighbor list\n"
2161 "Delete from manual neighbor list\n" "ARFCN of neighbor\n"
2162 "ARFCN of neighbor\n")
2163{
2164 struct gsm_bts *bts = vty->index;
2165 struct bitvec *bv = &bts->si_common.neigh_list;
2166 uint16_t arfcn = atoi(argv[1]);
2167
2168 if (!bts->neigh_list_manual_mode) {
2169 vty_out(vty, "%% Cannot configure neighbor list in "
2170 "automatic mode%s", VTY_NEWLINE);
2171 return CMD_WARNING;
2172 }
2173
2174 if (!strcmp(argv[0], "add"))
2175 bitvec_set_bit_pos(bv, arfcn, 1);
2176 else
2177 bitvec_set_bit_pos(bv, arfcn, 0);
2178
2179 return CMD_SUCCESS;
2180}
2181
Harald Welte9fbff4a2010-07-30 11:50:09 +02002182
Harald Welte8f0ed552010-05-11 21:53:49 +02002183#define TRX_TEXT "Radio Transceiver\n"
Harald Welte7a8fa412009-08-10 13:48:16 +02002184
Harald Welte5258fc42009-03-28 19:07:53 +00002185/* per TRX configuration */
2186DEFUN(cfg_trx,
2187 cfg_trx_cmd,
2188 "trx TRX_NR",
Harald Welte8f0ed552010-05-11 21:53:49 +02002189 TRX_TEXT
Harald Welte5258fc42009-03-28 19:07:53 +00002190 "Select a TRX to configure")
2191{
2192 int trx_nr = atoi(argv[0]);
2193 struct gsm_bts *bts = vty->index;
2194 struct gsm_bts_trx *trx;
2195
Harald Weltee441d9c2009-06-21 16:17:15 +02002196 if (trx_nr > bts->num_trx) {
2197 vty_out(vty, "%% The next unused TRX number in this BTS is %u%s",
2198 bts->num_trx, VTY_NEWLINE);
Harald Welte5258fc42009-03-28 19:07:53 +00002199 return CMD_WARNING;
Harald Weltee441d9c2009-06-21 16:17:15 +02002200 } else if (trx_nr == bts->num_trx) {
2201 /* we need to allocate a new one */
2202 trx = gsm_bts_trx_alloc(bts);
Holger Hans Peter Freytheracf8a0c2010-03-29 08:47:44 +02002203 } else
Harald Weltee441d9c2009-06-21 16:17:15 +02002204 trx = gsm_bts_trx_num(bts, trx_nr);
Holger Hans Peter Freytheracf8a0c2010-03-29 08:47:44 +02002205
Harald Weltee441d9c2009-06-21 16:17:15 +02002206 if (!trx)
2207 return CMD_WARNING;
Harald Welte5258fc42009-03-28 19:07:53 +00002208
2209 vty->index = trx;
Harald Welte197dea92010-05-14 17:59:53 +02002210 vty->index_sub = &trx->description;
Harald Welte5258fc42009-03-28 19:07:53 +00002211 vty->node = TRX_NODE;
2212
2213 return CMD_SUCCESS;
2214}
2215
2216DEFUN(cfg_trx_arfcn,
2217 cfg_trx_arfcn_cmd,
Harald Welte93e90202010-05-14 19:00:52 +02002218 "arfcn <0-1024>",
Harald Welte5258fc42009-03-28 19:07:53 +00002219 "Set the ARFCN for this TRX\n")
2220{
2221 int arfcn = atoi(argv[0]);
2222 struct gsm_bts_trx *trx = vty->index;
2223
2224 /* FIXME: check if this ARFCN is supported by this TRX */
2225
2226 trx->arfcn = arfcn;
2227
2228 /* FIXME: patch ARFCN into SYSTEM INFORMATION */
2229 /* FIXME: use OML layer to update the ARFCN */
2230 /* FIXME: use RSL layer to update SYSTEM INFORMATION */
2231
2232 return CMD_SUCCESS;
2233}
2234
Harald Welte (local)7b37d972009-12-27 20:56:38 +01002235DEFUN(cfg_trx_nominal_power,
2236 cfg_trx_nominal_power_cmd,
2237 "nominal power <0-100>",
2238 "Nominal TRX RF Power in dB\n")
2239{
2240 struct gsm_bts_trx *trx = vty->index;
2241
2242 trx->nominal_power = atoi(argv[0]);
2243
2244 return CMD_SUCCESS;
2245}
2246
Harald Weltefcd24452009-06-20 18:15:19 +02002247DEFUN(cfg_trx_max_power_red,
2248 cfg_trx_max_power_red_cmd,
2249 "max_power_red <0-100>",
2250 "Reduction of maximum BS RF Power in dB\n")
2251{
2252 int maxpwr_r = atoi(argv[0]);
2253 struct gsm_bts_trx *trx = vty->index;
Harald Welte61a83b22009-11-18 09:20:22 +01002254 int upper_limit = 24; /* default 12.21 max power red. */
Harald Weltefcd24452009-06-20 18:15:19 +02002255
2256 /* FIXME: check if our BTS type supports more than 12 */
2257 if (maxpwr_r < 0 || maxpwr_r > upper_limit) {
2258 vty_out(vty, "%% Power %d dB is not in the valid range%s",
2259 maxpwr_r, VTY_NEWLINE);
2260 return CMD_WARNING;
2261 }
2262 if (maxpwr_r & 1) {
2263 vty_out(vty, "%% Power %d dB is not an even value%s",
2264 maxpwr_r, VTY_NEWLINE);
2265 return CMD_WARNING;
2266 }
2267
2268 trx->max_power_red = maxpwr_r;
2269
2270 /* FIXME: make sure we update this using OML */
2271
2272 return CMD_SUCCESS;
2273}
2274
Harald Welte42581822009-08-08 16:12:58 +02002275DEFUN(cfg_trx_rsl_e1,
2276 cfg_trx_rsl_e1_cmd,
2277 "rsl e1 line E1_LINE timeslot <1-31> sub-slot (0|1|2|3|full)",
2278 "E1 interface to be used for RSL\n")
2279{
2280 struct gsm_bts_trx *trx = vty->index;
2281
2282 parse_e1_link(&trx->rsl_e1_link, argv[0], argv[1], argv[2]);
2283
2284 return CMD_SUCCESS;
2285}
2286
2287DEFUN(cfg_trx_rsl_e1_tei,
2288 cfg_trx_rsl_e1_tei_cmd,
2289 "rsl e1 tei <0-63>",
2290 "Set the TEI to be used for RSL")
2291{
2292 struct gsm_bts_trx *trx = vty->index;
2293
2294 trx->rsl_tei = atoi(argv[0]);
2295
2296 return CMD_SUCCESS;
2297}
2298
Holger Hans Peter Freyther2d501ea2009-11-11 11:54:24 +01002299DEFUN(cfg_trx_rf_locked,
2300 cfg_trx_rf_locked_cmd,
2301 "rf_locked (0|1)",
2302 "Turn off RF of the TRX.\n")
2303{
2304 int locked = atoi(argv[0]);
2305 struct gsm_bts_trx *trx = vty->index;
2306
2307 gsm_trx_lock_rf(trx, locked);
2308 return CMD_SUCCESS;
2309}
Harald Welte42581822009-08-08 16:12:58 +02002310
Harald Welte5258fc42009-03-28 19:07:53 +00002311/* per TS configuration */
2312DEFUN(cfg_ts,
2313 cfg_ts_cmd,
Harald Welte42581822009-08-08 16:12:58 +02002314 "timeslot <0-7>",
Harald Welte5258fc42009-03-28 19:07:53 +00002315 "Select a Timeslot to configure")
2316{
2317 int ts_nr = atoi(argv[0]);
2318 struct gsm_bts_trx *trx = vty->index;
2319 struct gsm_bts_trx_ts *ts;
2320
2321 if (ts_nr >= TRX_NR_TS) {
2322 vty_out(vty, "%% A GSM TRX only has %u Timeslots per TRX%s",
2323 TRX_NR_TS, VTY_NEWLINE);
2324 return CMD_WARNING;
2325 }
2326
2327 ts = &trx->ts[ts_nr];
2328
2329 vty->index = ts;
2330 vty->node = TS_NODE;
2331
2332 return CMD_SUCCESS;
2333}
2334
Harald Weltea6fd58e2009-08-07 00:25:23 +02002335DEFUN(cfg_ts_pchan,
2336 cfg_ts_pchan_cmd,
2337 "phys_chan_config PCHAN",
2338 "Physical Channel configuration (TCH/SDCCH/...)")
2339{
2340 struct gsm_bts_trx_ts *ts = vty->index;
2341 int pchanc;
2342
2343 pchanc = gsm_pchan_parse(argv[0]);
2344 if (pchanc < 0)
2345 return CMD_WARNING;
2346
2347 ts->pchan = pchanc;
2348
2349 return CMD_SUCCESS;
2350}
2351
Harald Weltea39b0f22010-06-14 22:26:10 +02002352#define HOPPING_STR "Configure frequency hopping\n"
2353
2354DEFUN(cfg_ts_hopping,
2355 cfg_ts_hopping_cmd,
2356 "hopping enabled (0|1)",
2357 HOPPING_STR "Enable or disable frequency hopping\n"
2358 "Disable frequency hopping\n" "Enable frequency hopping\n")
2359{
2360 struct gsm_bts_trx_ts *ts = vty->index;
Harald Weltec2fb3d02010-06-14 22:47:37 +02002361 int enabled = atoi(argv[0]);
Harald Weltea39b0f22010-06-14 22:26:10 +02002362
Harald Weltec2fb3d02010-06-14 22:47:37 +02002363 if (enabled && !gsm_bts_has_feature(ts->trx->bts, BTS_FEAT_HOPPING)) {
2364 vty_out(vty, "BTS model does not support hopping%s",
2365 VTY_NEWLINE);
2366 return CMD_WARNING;
2367 }
2368
2369 ts->hopping.enabled = enabled;
Harald Weltea39b0f22010-06-14 22:26:10 +02002370
2371 return CMD_SUCCESS;
2372}
2373
Harald Welte6e0cd042009-09-12 13:05:33 +02002374DEFUN(cfg_ts_hsn,
2375 cfg_ts_hsn_cmd,
Harald Weltea39b0f22010-06-14 22:26:10 +02002376 "hopping sequence-number <0-63>",
2377 HOPPING_STR
Harald Welte6e0cd042009-09-12 13:05:33 +02002378 "Which hopping sequence to use for this channel")
2379{
2380 struct gsm_bts_trx_ts *ts = vty->index;
2381
2382 ts->hopping.hsn = atoi(argv[0]);
2383
2384 return CMD_SUCCESS;
2385}
2386
2387DEFUN(cfg_ts_maio,
2388 cfg_ts_maio_cmd,
2389 "hopping maio <0-63>",
Harald Weltea39b0f22010-06-14 22:26:10 +02002390 HOPPING_STR
Harald Welte6e0cd042009-09-12 13:05:33 +02002391 "Which hopping MAIO to use for this channel")
2392{
2393 struct gsm_bts_trx_ts *ts = vty->index;
2394
2395 ts->hopping.maio = atoi(argv[0]);
2396
2397 return CMD_SUCCESS;
2398}
2399
2400DEFUN(cfg_ts_arfcn_add,
2401 cfg_ts_arfcn_add_cmd,
2402 "hopping arfcn add <0-1023>",
Harald Weltea39b0f22010-06-14 22:26:10 +02002403 HOPPING_STR "Configure hopping ARFCN list\n"
2404 "Add an entry to the hopping ARFCN list\n" "ARFCN\n")
Harald Welte6e0cd042009-09-12 13:05:33 +02002405{
2406 struct gsm_bts_trx_ts *ts = vty->index;
2407 int arfcn = atoi(argv[0]);
2408
Harald Weltea39b0f22010-06-14 22:26:10 +02002409 bitvec_set_bit_pos(&ts->hopping.arfcns, arfcn, 1);
2410
Harald Welte6e0cd042009-09-12 13:05:33 +02002411 return CMD_SUCCESS;
2412}
2413
2414DEFUN(cfg_ts_arfcn_del,
2415 cfg_ts_arfcn_del_cmd,
2416 "hopping arfcn del <0-1023>",
Harald Weltea39b0f22010-06-14 22:26:10 +02002417 HOPPING_STR "Configure hopping ARFCN list\n"
2418 "Delete an entry to the hopping ARFCN list\n" "ARFCN\n")
Harald Welte6e0cd042009-09-12 13:05:33 +02002419{
2420 struct gsm_bts_trx_ts *ts = vty->index;
2421 int arfcn = atoi(argv[0]);
2422
Harald Weltea39b0f22010-06-14 22:26:10 +02002423 bitvec_set_bit_pos(&ts->hopping.arfcns, arfcn, 0);
2424
Harald Welte6e0cd042009-09-12 13:05:33 +02002425 return CMD_SUCCESS;
2426}
2427
Harald Weltea6fd58e2009-08-07 00:25:23 +02002428DEFUN(cfg_ts_e1_subslot,
2429 cfg_ts_e1_subslot_cmd,
Harald Welte42581822009-08-08 16:12:58 +02002430 "e1 line E1_LINE timeslot <1-31> sub-slot (0|1|2|3|full)",
Harald Weltea6fd58e2009-08-07 00:25:23 +02002431 "E1 sub-slot connected to this on-air timeslot")
2432{
2433 struct gsm_bts_trx_ts *ts = vty->index;
2434
Harald Welte42581822009-08-08 16:12:58 +02002435 parse_e1_link(&ts->e1_link, argv[0], argv[1], argv[2]);
Harald Weltea6fd58e2009-08-07 00:25:23 +02002436
2437 return CMD_SUCCESS;
2438}
Harald Welte5258fc42009-03-28 19:07:53 +00002439
Harald Welte4f10c252010-05-16 21:47:13 +02002440void openbsc_vty_print_statistics(struct vty *vty, struct gsm_network *net)
2441{
2442 vty_out(vty, "Channel Requests : %lu total, %lu no channel%s",
2443 counter_get(net->stats.chreq.total),
2444 counter_get(net->stats.chreq.no_channel), VTY_NEWLINE);
2445 vty_out(vty, "Channel Failures : %lu rf_failures, %lu rll failures%s",
2446 counter_get(net->stats.chan.rf_fail),
2447 counter_get(net->stats.chan.rll_err), VTY_NEWLINE);
2448 vty_out(vty, "Paging : %lu attempted, %lu complete, %lu expired%s",
2449 counter_get(net->stats.paging.attempted),
2450 counter_get(net->stats.paging.completed),
2451 counter_get(net->stats.paging.expired), VTY_NEWLINE);
2452 vty_out(vty, "BTS failures : %lu OML, %lu RSL%s",
2453 counter_get(net->stats.bts.oml_fail),
2454 counter_get(net->stats.bts.rsl_fail), VTY_NEWLINE);
2455}
2456
Harald Welte5bc61dc2010-05-16 22:02:16 +02002457DEFUN(logging_fltr_imsi,
2458 logging_fltr_imsi_cmd,
2459 "logging filter imsi IMSI",
2460 LOGGING_STR FILTER_STR
2461 "Filter log messages by IMSI\n" "IMSI to be used as filter\n")
2462{
2463 struct telnet_connection *conn;
2464
2465 conn = (struct telnet_connection *) vty->priv;
2466 if (!conn->dbg) {
2467 vty_out(vty, "Logging was not enabled.%s", VTY_NEWLINE);
2468 return CMD_WARNING;
2469 }
2470
2471 log_set_imsi_filter(conn->dbg, argv[0]);
2472 return CMD_SUCCESS;
2473}
2474
Holger Hans Peter Freyther2484ceb2010-10-26 09:40:13 +02002475DEFUN(drop_bts,
2476 drop_bts_cmd,
Holger Hans Peter Freyther0586b0f2010-04-11 12:46:45 +02002477 "drop bts connection <0-65535> (oml|rsl)",
2478 "Debug/Simulation command to drop ipaccess BTS\n"
2479 "BTS NR\n" "Connection Type\n")
Holger Hans Peter Freyther2484ceb2010-10-26 09:40:13 +02002480{
2481 struct gsm_network *gsmnet;
2482 struct gsm_bts_trx *trx;
2483 struct gsm_bts *bts;
2484 unsigned int bts_nr;
2485
2486 gsmnet = gsmnet_from_vty(vty);
2487
2488 bts_nr = atoi(argv[0]);
2489 if (bts_nr >= gsmnet->num_bts) {
2490 vty_out(vty, "BTS number must be between 0 and %d. It was %d.%s",
2491 gsmnet->num_bts, bts_nr, VTY_NEWLINE);
2492 return CMD_WARNING;
2493 }
2494
2495 bts = gsm_bts_num(gsmnet, bts_nr);
2496 if (!bts) {
2497 vty_out(vty, "BTS Nr. %d could not be found.%s", bts_nr, VTY_NEWLINE);
2498 return CMD_WARNING;
2499 }
2500
2501 if (!is_ipaccess_bts(bts)) {
2502 vty_out(vty, "This command only works for ipaccess.%s", VTY_NEWLINE);
2503 return CMD_WARNING;
2504 }
2505
2506
2507 /* close all connections */
2508 if (strcmp(argv[1], "oml") == 0) {
Holger Hans Peter Freytherdab8e272010-11-15 20:29:46 +01002509 ipaccess_drop_oml(bts);
Holger Hans Peter Freyther2484ceb2010-10-26 09:40:13 +02002510 } else if (strcmp(argv[1], "rsl") == 0) {
2511 /* close all rsl connections */
2512 llist_for_each_entry(trx, &bts->trx_list, list) {
Holger Hans Peter Freytherdab8e272010-11-15 20:29:46 +01002513 ipaccess_drop_rsl(trx);
Holger Hans Peter Freyther2484ceb2010-10-26 09:40:13 +02002514 }
2515 } else {
2516 vty_out(vty, "Argument must be 'oml# or 'rsl'.%s", VTY_NEWLINE);
2517 return CMD_WARNING;
2518 }
2519
2520 return CMD_SUCCESS;
2521}
2522
Harald Welted0d2b0b2010-12-23 13:18:07 +01002523DEFUN(pdch_act, pdch_act_cmd,
2524 "bts <0-255> trx <0-255> timeslot <0-7> pdch (activate|deactivate)",
2525 "BTS related commands\n" "BTS Number\n" "Transceiver\n" "Transceiver Number\n"
2526 "TRX Timeslot\n" "Timeslot Number\n" "Packet Data Channel\n"
2527 "Activate Dynamic PDCH/TCH (-> PDCH mode)\n"
2528 "Deactivate Dynamic PDCH/TCH (-> TCH mode)\n")
2529{
2530 struct gsm_bts *bts;
2531 struct gsm_bts_trx *trx;
2532 struct gsm_bts_trx_ts *ts;
2533 int bts_nr = atoi(argv[0]);
2534 int trx_nr = atoi(argv[1]);
2535 int ts_nr = atoi(argv[2]);
2536 int activate;
2537
2538 bts = gsm_bts_num(bsc_gsmnet, bts_nr);
2539 if (!bts) {
2540 vty_out(vty, "%% No such BTS (%d)%s", bts_nr, VTY_NEWLINE);
2541 return CMD_WARNING;
2542 }
2543
2544 if (!is_ipaccess_bts(bts)) {
2545 vty_out(vty, "%% This command only works for ipaccess BTS%s",
2546 VTY_NEWLINE);
2547 return CMD_WARNING;
2548 }
2549
2550 trx = gsm_bts_trx_num(bts, trx_nr);
2551 if (!trx) {
2552 vty_out(vty, "%% No such TRX (%d)%s", trx_nr, VTY_NEWLINE);
2553 return CMD_WARNING;
2554 }
2555
2556 ts = &trx->ts[ts_nr];
2557 if (ts->pchan != GSM_PCHAN_TCH_F_PDCH) {
2558 vty_out(vty, "%% Timeslot %u is not in dynamic TCH_F/PDCH "
2559 "mode%s", ts_nr, VTY_NEWLINE);
2560 return CMD_WARNING;
2561 }
2562
2563 if (!strcmp(argv[3], "activate"))
2564 activate = 1;
2565 else
2566 activate = 0;
2567
2568 rsl_ipacc_pdch_activate(ts, activate);
2569
2570 return CMD_SUCCESS;
2571
2572}
Holger Hans Peter Freyther2484ceb2010-10-26 09:40:13 +02002573
Harald Weltedcccb182010-05-16 20:52:23 +02002574extern int bsc_vty_init_extra(void);
Harald Welte1353f962010-05-16 19:20:24 +02002575extern const char *openbsc_copyright;
Holger Hans Peter Freythere1ffc082010-04-10 00:08:28 +02002576
Harald Weltedcccb182010-05-16 20:52:23 +02002577int bsc_vty_init(void)
Harald Welte68628e82009-03-10 12:17:57 +00002578{
Harald Welteb4d5b172010-05-12 16:10:35 +00002579 install_element_ve(&show_net_cmd);
2580 install_element_ve(&show_bts_cmd);
2581 install_element_ve(&show_trx_cmd);
2582 install_element_ve(&show_ts_cmd);
2583 install_element_ve(&show_lchan_cmd);
Holger Hans Peter Freyther3d6a5d62010-05-14 02:08:49 +08002584 install_element_ve(&show_lchan_summary_cmd);
Harald Welte5bc61dc2010-05-16 22:02:16 +02002585 install_element_ve(&logging_fltr_imsi_cmd);
Harald Welte1bc77352009-03-10 19:47:51 +00002586
Harald Welteb4d5b172010-05-12 16:10:35 +00002587 install_element_ve(&show_e1drv_cmd);
2588 install_element_ve(&show_e1line_cmd);
2589 install_element_ve(&show_e1ts_cmd);
Harald Welte68628e82009-03-10 12:17:57 +00002590
Harald Welteb4d5b172010-05-12 16:10:35 +00002591 install_element_ve(&show_paging_cmd);
Harald Welte5258fc42009-03-28 19:07:53 +00002592
Harald Welte5bc61dc2010-05-16 22:02:16 +02002593 logging_vty_add_cmds();
Holger Hans Peter Freytherb61e3b22009-12-22 22:32:51 +01002594
Harald Welte5013b2a2009-08-07 13:29:14 +02002595 install_element(CONFIG_NODE, &cfg_net_cmd);
2596 install_node(&net_node, config_write_net);
2597 install_default(GSMNET_NODE);
Harald Welte62ab20c2010-05-14 18:59:17 +02002598 install_element(GSMNET_NODE, &ournode_exit_cmd);
Harald Welte54f74242010-05-14 19:11:04 +02002599 install_element(GSMNET_NODE, &ournode_end_cmd);
Harald Welte42581822009-08-08 16:12:58 +02002600 install_element(GSMNET_NODE, &cfg_net_ncc_cmd);
Harald Welte5013b2a2009-08-07 13:29:14 +02002601 install_element(GSMNET_NODE, &cfg_net_mnc_cmd);
2602 install_element(GSMNET_NODE, &cfg_net_name_short_cmd);
2603 install_element(GSMNET_NODE, &cfg_net_name_long_cmd);
Harald Welte (local)69de3972009-08-12 14:42:23 +02002604 install_element(GSMNET_NODE, &cfg_net_auth_policy_cmd);
Harald Welte1085c092009-11-18 20:33:19 +01002605 install_element(GSMNET_NODE, &cfg_net_reject_cause_cmd);
Harald Welte4381cfe2009-08-30 15:47:06 +09002606 install_element(GSMNET_NODE, &cfg_net_encryption_cmd);
Holger Hans Peter Freytherf7d752f2009-11-16 17:12:38 +01002607 install_element(GSMNET_NODE, &cfg_net_neci_cmd);
Harald Welteeab84a12009-12-13 10:53:12 +01002608 install_element(GSMNET_NODE, &cfg_net_rrlp_mode_cmd);
Harald Welte3d23db42009-12-14 17:49:15 +01002609 install_element(GSMNET_NODE, &cfg_net_mm_info_cmd);
Harald Weltebc814502009-12-19 21:41:52 +01002610 install_element(GSMNET_NODE, &cfg_net_handover_cmd);
Harald Welteb720bd32009-12-21 16:51:50 +01002611 install_element(GSMNET_NODE, &cfg_net_ho_win_rxlev_avg_cmd);
2612 install_element(GSMNET_NODE, &cfg_net_ho_win_rxqual_avg_cmd);
2613 install_element(GSMNET_NODE, &cfg_net_ho_win_rxlev_avg_neigh_cmd);
2614 install_element(GSMNET_NODE, &cfg_net_ho_pwr_interval_cmd);
2615 install_element(GSMNET_NODE, &cfg_net_ho_pwr_hysteresis_cmd);
2616 install_element(GSMNET_NODE, &cfg_net_ho_max_distance_cmd);
Holger Hans Peter Freytherc4d88ad2009-11-21 21:18:38 +01002617 install_element(GSMNET_NODE, &cfg_net_T3101_cmd);
Holger Hans Peter Freyther23975e72009-11-21 21:42:26 +01002618 install_element(GSMNET_NODE, &cfg_net_T3103_cmd);
2619 install_element(GSMNET_NODE, &cfg_net_T3105_cmd);
2620 install_element(GSMNET_NODE, &cfg_net_T3107_cmd);
2621 install_element(GSMNET_NODE, &cfg_net_T3109_cmd);
2622 install_element(GSMNET_NODE, &cfg_net_T3111_cmd);
2623 install_element(GSMNET_NODE, &cfg_net_T3113_cmd);
2624 install_element(GSMNET_NODE, &cfg_net_T3115_cmd);
2625 install_element(GSMNET_NODE, &cfg_net_T3117_cmd);
2626 install_element(GSMNET_NODE, &cfg_net_T3119_cmd);
Harald Weltec9f499f2010-12-23 22:53:50 +01002627 install_element(GSMNET_NODE, &cfg_net_T3122_cmd);
Holger Hans Peter Freyther23975e72009-11-21 21:42:26 +01002628 install_element(GSMNET_NODE, &cfg_net_T3141_cmd);
Holger Hans Peter Freyther5a3a61d2010-09-06 09:25:48 +08002629 install_element(GSMNET_NODE, &cfg_net_dtx_cmd);
Holger Hans Peter Freytherae9006a2010-12-22 16:26:04 +01002630 install_element(GSMNET_NODE, &cfg_net_subscr_keep_cmd);
Holger Hans Peter Freyther76fc4a32010-09-06 09:41:50 +08002631 install_element(GSMNET_NODE, &cfg_net_pag_any_tch_cmd);
Harald Welte5013b2a2009-08-07 13:29:14 +02002632
2633 install_element(GSMNET_NODE, &cfg_bts_cmd);
Harald Welte67ce0732009-08-06 19:06:46 +02002634 install_node(&bts_node, config_write_bts);
Harald Welte68628e82009-03-10 12:17:57 +00002635 install_default(BTS_NODE);
Harald Welte62ab20c2010-05-14 18:59:17 +02002636 install_element(BTS_NODE, &ournode_exit_cmd);
Harald Welte54f74242010-05-14 19:11:04 +02002637 install_element(BTS_NODE, &ournode_end_cmd);
Harald Welte5258fc42009-03-28 19:07:53 +00002638 install_element(BTS_NODE, &cfg_bts_type_cmd);
Harald Welte197dea92010-05-14 17:59:53 +02002639 install_element(BTS_NODE, &cfg_description_cmd);
2640 install_element(BTS_NODE, &cfg_no_description_cmd);
Harald Weltefcd24452009-06-20 18:15:19 +02002641 install_element(BTS_NODE, &cfg_bts_band_cmd);
Holger Hans Peter Freytherc4a49e32009-08-21 14:44:12 +02002642 install_element(BTS_NODE, &cfg_bts_ci_cmd);
Harald Welte5258fc42009-03-28 19:07:53 +00002643 install_element(BTS_NODE, &cfg_bts_lac_cmd);
2644 install_element(BTS_NODE, &cfg_bts_tsc_cmd);
Harald Welte42581822009-08-08 16:12:58 +02002645 install_element(BTS_NODE, &cfg_bts_bsic_cmd);
Harald Welte4cc34222009-05-01 15:12:31 +00002646 install_element(BTS_NODE, &cfg_bts_unit_id_cmd);
Harald Welte8175e952009-10-20 00:22:00 +02002647 install_element(BTS_NODE, &cfg_bts_stream_id_cmd);
Harald Welte42581822009-08-08 16:12:58 +02002648 install_element(BTS_NODE, &cfg_bts_oml_e1_cmd);
2649 install_element(BTS_NODE, &cfg_bts_oml_e1_tei_cmd);
Harald Welte7a8fa412009-08-10 13:48:16 +02002650 install_element(BTS_NODE, &cfg_bts_challoc_cmd);
Sylvain Munaut4010f1e2009-12-22 13:43:26 +01002651 install_element(BTS_NODE, &cfg_bts_rach_tx_integer_cmd);
2652 install_element(BTS_NODE, &cfg_bts_rach_max_trans_cmd);
Holger Hans Peter Freyther95c22902010-04-25 23:08:39 +08002653 install_element(BTS_NODE, &cfg_bts_rach_nm_b_thresh_cmd);
2654 install_element(BTS_NODE, &cfg_bts_rach_nm_ldavg_cmd);
Harald Welte (local)5dececf2009-08-12 13:28:23 +02002655 install_element(BTS_NODE, &cfg_bts_cell_barred_cmd);
Holger Hans Peter Freyther3a0a4632010-05-14 00:39:19 +08002656 install_element(BTS_NODE, &cfg_bts_rach_ec_allowed_cmd);
Harald Welte (local)0e451d02009-08-13 10:14:26 +02002657 install_element(BTS_NODE, &cfg_bts_ms_max_power_cmd);
Harald Welte (local)efc92312009-08-14 23:09:25 +02002658 install_element(BTS_NODE, &cfg_bts_per_loc_upd_cmd);
Harald Welte73225282009-12-12 18:17:25 +01002659 install_element(BTS_NODE, &cfg_bts_cell_resel_hyst_cmd);
2660 install_element(BTS_NODE, &cfg_bts_rxlev_acc_min_cmd);
Sylvain Munaute0b06b02010-11-28 18:17:28 +01002661 install_element(BTS_NODE, &cfg_bts_cell_bar_qualify_cmd);
2662 install_element(BTS_NODE, &cfg_bts_cell_resel_ofs_cmd);
2663 install_element(BTS_NODE, &cfg_bts_temp_ofs_cmd);
2664 install_element(BTS_NODE, &cfg_bts_temp_ofs_inf_cmd);
2665 install_element(BTS_NODE, &cfg_bts_penalty_time_cmd);
2666 install_element(BTS_NODE, &cfg_bts_penalty_time_rsvd_cmd);
Harald Welte4511d892010-04-18 15:51:20 +02002667 install_element(BTS_NODE, &cfg_bts_gprs_mode_cmd);
Harald Welte615e9562010-05-11 23:50:21 +02002668 install_element(BTS_NODE, &cfg_bts_gprs_ns_timer_cmd);
Harald Welte97a282b2010-03-14 15:37:43 +08002669 install_element(BTS_NODE, &cfg_bts_gprs_rac_cmd);
2670 install_element(BTS_NODE, &cfg_bts_gprs_bvci_cmd);
Harald Welte615e9562010-05-11 23:50:21 +02002671 install_element(BTS_NODE, &cfg_bts_gprs_cell_timer_cmd);
Harald Weltea5731cf2010-03-22 11:48:36 +08002672 install_element(BTS_NODE, &cfg_bts_gprs_nsei_cmd);
Harald Welte97a282b2010-03-14 15:37:43 +08002673 install_element(BTS_NODE, &cfg_bts_gprs_nsvci_cmd);
Harald Welteaf387632010-03-14 23:30:30 +08002674 install_element(BTS_NODE, &cfg_bts_gprs_nsvc_lport_cmd);
2675 install_element(BTS_NODE, &cfg_bts_gprs_nsvc_rport_cmd);
2676 install_element(BTS_NODE, &cfg_bts_gprs_nsvc_rip_cmd);
Holger Hans Peter Freythere66bf1f2010-09-06 10:11:25 +08002677 install_element(BTS_NODE, &cfg_bts_pag_free_cmd);
Harald Welte9fbff4a2010-07-30 11:50:09 +02002678 install_element(BTS_NODE, &cfg_bts_si_mode_cmd);
2679 install_element(BTS_NODE, &cfg_bts_si_static_cmd);
Harald Welte32c09622011-01-11 23:44:56 +01002680 install_element(BTS_NODE, &cfg_bts_neigh_mode_cmd);
2681 install_element(BTS_NODE, &cfg_bts_neigh_cmd);
Harald Welte68628e82009-03-10 12:17:57 +00002682
Harald Welte5258fc42009-03-28 19:07:53 +00002683 install_element(BTS_NODE, &cfg_trx_cmd);
Harald Welte68628e82009-03-10 12:17:57 +00002684 install_node(&trx_node, dummy_config_write);
Harald Welte68628e82009-03-10 12:17:57 +00002685 install_default(TRX_NODE);
Harald Welte62ab20c2010-05-14 18:59:17 +02002686 install_element(TRX_NODE, &ournode_exit_cmd);
Harald Welte54f74242010-05-14 19:11:04 +02002687 install_element(TRX_NODE, &ournode_end_cmd);
Harald Welte5258fc42009-03-28 19:07:53 +00002688 install_element(TRX_NODE, &cfg_trx_arfcn_cmd);
Harald Welte197dea92010-05-14 17:59:53 +02002689 install_element(TRX_NODE, &cfg_description_cmd);
2690 install_element(TRX_NODE, &cfg_no_description_cmd);
Harald Welte (local)7b37d972009-12-27 20:56:38 +01002691 install_element(TRX_NODE, &cfg_trx_nominal_power_cmd);
Harald Welte879dc972009-06-20 22:36:12 +02002692 install_element(TRX_NODE, &cfg_trx_max_power_red_cmd);
Harald Welte42581822009-08-08 16:12:58 +02002693 install_element(TRX_NODE, &cfg_trx_rsl_e1_cmd);
2694 install_element(TRX_NODE, &cfg_trx_rsl_e1_tei_cmd);
Holger Hans Peter Freyther2d501ea2009-11-11 11:54:24 +01002695 install_element(TRX_NODE, &cfg_trx_rf_locked_cmd);
Harald Welte68628e82009-03-10 12:17:57 +00002696
Harald Welte5258fc42009-03-28 19:07:53 +00002697 install_element(TRX_NODE, &cfg_ts_cmd);
Harald Welte68628e82009-03-10 12:17:57 +00002698 install_node(&ts_node, dummy_config_write);
Harald Welte68628e82009-03-10 12:17:57 +00002699 install_default(TS_NODE);
Harald Welte62ab20c2010-05-14 18:59:17 +02002700 install_element(TS_NODE, &ournode_exit_cmd);
Harald Welte54f74242010-05-14 19:11:04 +02002701 install_element(TS_NODE, &ournode_end_cmd);
Harald Weltea6fd58e2009-08-07 00:25:23 +02002702 install_element(TS_NODE, &cfg_ts_pchan_cmd);
Harald Weltea39b0f22010-06-14 22:26:10 +02002703 install_element(TS_NODE, &cfg_ts_hopping_cmd);
Harald Welte6e0cd042009-09-12 13:05:33 +02002704 install_element(TS_NODE, &cfg_ts_hsn_cmd);
2705 install_element(TS_NODE, &cfg_ts_maio_cmd);
2706 install_element(TS_NODE, &cfg_ts_arfcn_add_cmd);
2707 install_element(TS_NODE, &cfg_ts_arfcn_del_cmd);
Harald Weltea6fd58e2009-08-07 00:25:23 +02002708 install_element(TS_NODE, &cfg_ts_e1_subslot_cmd);
Harald Welte68628e82009-03-10 12:17:57 +00002709
Holger Hans Peter Freyther2484ceb2010-10-26 09:40:13 +02002710 install_element(ENABLE_NODE, &drop_bts_cmd);
Harald Welted0d2b0b2010-12-23 13:18:07 +01002711 install_element(ENABLE_NODE, &pdch_act_cmd);
Holger Hans Peter Freyther2484ceb2010-10-26 09:40:13 +02002712
Harald Welte81c9b9c2010-05-31 16:40:40 +02002713 abis_nm_vty_init();
Harald Weltee1d5eca2011-02-12 14:42:59 +01002714 abis_om2k_vty_init();
Harald Welte3016d9f2011-02-05 13:54:41 +01002715 e1inp_vty_init();
Harald Welte81c9b9c2010-05-31 16:40:40 +02002716
Harald Weltedcccb182010-05-16 20:52:23 +02002717 bsc_vty_init_extra();
Harald Welte40f82892009-05-23 17:31:39 +00002718
Harald Welte68628e82009-03-10 12:17:57 +00002719 return 0;
2720}