blob: 55a667cdf45664927bbce5c9fede4dc376324e98 [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 Welte64c07d22011-02-15 11:43:27 +010079static const struct value_string bts_neigh_mode_strs[] = {
80 { NL_MODE_AUTOMATIC, "automatic" },
81 { NL_MODE_MANUAL, "manual" },
82 { NL_MODE_MANUAL_SI5SEP, "manual-si5" },
83 { 0, NULL }
84};
85
Harald Welte5013b2a2009-08-07 13:29:14 +020086struct cmd_node net_node = {
87 GSMNET_NODE,
88 "%s(network)#",
89 1,
90};
91
Harald Welte68628e82009-03-10 12:17:57 +000092struct cmd_node bts_node = {
93 BTS_NODE,
94 "%s(bts)#",
95 1,
96};
97
98struct cmd_node trx_node = {
99 TRX_NODE,
100 "%s(trx)#",
101 1,
102};
103
104struct cmd_node ts_node = {
105 TS_NODE,
106 "%s(ts)#",
107 1,
108};
109
Harald Welte39231152010-05-27 13:39:40 +0200110extern struct gsm_network *bsc_gsmnet;
111
Harald Weltedcccb182010-05-16 20:52:23 +0200112struct gsm_network *gsmnet_from_vty(struct vty *v)
113{
Harald Welte39231152010-05-27 13:39:40 +0200114 /* In case we read from the config file, the vty->priv cannot
115 * point to a struct telnet_connection, and thus conn->priv
116 * will not point to the gsm_network structure */
117#if 0
Harald Weltedcccb182010-05-16 20:52:23 +0200118 struct telnet_connection *conn = v->priv;
119 return (struct gsm_network *) conn->priv;
Harald Welte39231152010-05-27 13:39:40 +0200120#else
121 return bsc_gsmnet;
122#endif
Harald Weltedcccb182010-05-16 20:52:23 +0200123}
124
Harald Welte68628e82009-03-10 12:17:57 +0000125static int dummy_config_write(struct vty *v)
126{
127 return CMD_SUCCESS;
128}
129
130static void net_dump_nmstate(struct vty *vty, struct gsm_nm_state *nms)
131{
Harald Welte1bc77352009-03-10 19:47:51 +0000132 vty_out(vty,"Oper '%s', Admin %u, Avail '%s'%s",
133 nm_opstate_name(nms->operational), nms->administrative,
134 nm_avail_name(nms->availability), VTY_NEWLINE);
Harald Welte68628e82009-03-10 12:17:57 +0000135}
136
Harald Welteb908cb72009-12-22 13:09:29 +0100137static void dump_pchan_load_vty(struct vty *vty, char *prefix,
138 const struct pchan_load *pl)
139{
140 int i;
141
142 for (i = 0; i < ARRAY_SIZE(pl->pchan); i++) {
143 const struct load_counter *lc = &pl->pchan[i];
144 unsigned int percent;
145
146 if (lc->total == 0)
147 continue;
148
149 percent = (lc->used * 100) / lc->total;
150
151 vty_out(vty, "%s%20s: %3u%% (%u/%u)%s", prefix,
152 gsm_pchan_name(i), percent, lc->used, lc->total,
153 VTY_NEWLINE);
154 }
155}
156
Harald Welte68628e82009-03-10 12:17:57 +0000157static void net_dump_vty(struct vty *vty, struct gsm_network *net)
158{
Harald Welteb908cb72009-12-22 13:09:29 +0100159 struct pchan_load pl;
160
Harald Welteef235b52009-03-10 12:34:02 +0000161 vty_out(vty, "BSC is on Country Code %u, Network Code %u "
162 "and has %u BTS%s", net->country_code, net->network_code,
163 net->num_bts, VTY_NEWLINE);
Harald Welte1bc77352009-03-10 19:47:51 +0000164 vty_out(vty, " Long network name: '%s'%s",
Harald Welte68628e82009-03-10 12:17:57 +0000165 net->name_long, VTY_NEWLINE);
Harald Welte1bc77352009-03-10 19:47:51 +0000166 vty_out(vty, " Short network name: '%s'%s",
Harald Welte68628e82009-03-10 12:17:57 +0000167 net->name_short, VTY_NEWLINE);
Harald Welte (local)69de3972009-08-12 14:42:23 +0200168 vty_out(vty, " Authentication policy: %s%s",
169 gsm_auth_policy_name(net->auth_policy), VTY_NEWLINE);
Harald Welte1085c092009-11-18 20:33:19 +0100170 vty_out(vty, " Location updating reject cause: %u%s",
171 net->reject_cause, VTY_NEWLINE);
Harald Welte4381cfe2009-08-30 15:47:06 +0900172 vty_out(vty, " Encryption: A5/%u%s", net->a5_encryption,
173 VTY_NEWLINE);
Holger Hans Peter Freytherf7d752f2009-11-16 17:12:38 +0100174 vty_out(vty, " NECI (TCH/H): %u%s", net->neci,
175 VTY_NEWLINE);
Holger Hans Peter Freyther76fc4a32010-09-06 09:41:50 +0800176 vty_out(vty, " Use TCH for Paging any: %d%s", net->pag_any_tch,
177 VTY_NEWLINE);
Harald Welteeab84a12009-12-13 10:53:12 +0100178 vty_out(vty, " RRLP Mode: %s%s", rrlp_mode_name(net->rrlp.mode),
179 VTY_NEWLINE);
Harald Welte648b6ce2009-12-14 09:00:24 +0100180 vty_out(vty, " MM Info: %s%s", net->send_mm_info ? "On" : "Off",
181 VTY_NEWLINE);
Harald Weltebc814502009-12-19 21:41:52 +0100182 vty_out(vty, " Handover: %s%s", net->handover.active ? "On" : "Off",
183 VTY_NEWLINE);
Harald Welteb908cb72009-12-22 13:09:29 +0100184 network_chan_load(&pl, net);
185 vty_out(vty, " Current Channel Load:%s", VTY_NEWLINE);
186 dump_pchan_load_vty(vty, " ", &pl);
Harald Welte68628e82009-03-10 12:17:57 +0000187}
188
189DEFUN(show_net, show_net_cmd, "show network",
190 SHOW_STR "Display information about a GSM NETWORK\n")
191{
Harald Weltedcccb182010-05-16 20:52:23 +0200192 struct gsm_network *net = gsmnet_from_vty(vty);
Harald Welte68628e82009-03-10 12:17:57 +0000193 net_dump_vty(vty, net);
194
195 return CMD_SUCCESS;
196}
197
198static void e1isl_dump_vty(struct vty *vty, struct e1inp_sign_link *e1l)
199{
Harald Welteedb37782009-05-01 14:59:07 +0000200 struct e1inp_line *line;
201
202 if (!e1l) {
203 vty_out(vty, " None%s", VTY_NEWLINE);
204 return;
205 }
206
207 line = e1l->ts->line;
208
209 vty_out(vty, " E1 Line %u, Type %s: Timeslot %u, Mode %s%s",
210 line->num, line->driver->name, e1l->ts->num,
Harald Welte1bc77352009-03-10 19:47:51 +0000211 e1inp_signtype_name(e1l->type), VTY_NEWLINE);
Harald Welteedb37782009-05-01 14:59:07 +0000212 vty_out(vty, " E1 TEI %u, SAPI %u%s",
Harald Welte68628e82009-03-10 12:17:57 +0000213 e1l->tei, e1l->sapi, VTY_NEWLINE);
214}
215
216static void bts_dump_vty(struct vty *vty, struct gsm_bts *bts)
217{
Harald Welteb908cb72009-12-22 13:09:29 +0100218 struct pchan_load pl;
219
Holger Hans Peter Freytherc4a49e32009-08-21 14:44:12 +0200220 vty_out(vty, "BTS %u is of %s type in band %s, has CI %u LAC %u, "
Harald Weltefcd24452009-06-20 18:15:19 +0200221 "BSIC %u, TSC %u and %u TRX%s",
222 bts->nr, btstype2str(bts->type), gsm_band_name(bts->band),
Holger Hans Peter Freytherc4a49e32009-08-21 14:44:12 +0200223 bts->cell_identity,
Holger Hans Peter Freytheracf8a0c2010-03-29 08:47:44 +0200224 bts->location_area_code, bts->bsic, bts->tsc,
Harald Weltefcd24452009-06-20 18:15:19 +0200225 bts->num_trx, VTY_NEWLINE);
Harald Welte197dea92010-05-14 17:59:53 +0200226 vty_out(vty, "Description: %s%s",
227 bts->description ? bts->description : "(null)", VTY_NEWLINE);
Harald Welte1d8dbc42009-12-12 15:38:16 +0100228 vty_out(vty, "MS Max power: %u dBm%s", bts->ms_max_power, VTY_NEWLINE);
Harald Welte73225282009-12-12 18:17:25 +0100229 vty_out(vty, "Minimum Rx Level for Access: %i dBm%s",
Harald Welte1d8dbc42009-12-12 15:38:16 +0100230 rxlev2dbm(bts->si_common.cell_sel_par.rxlev_acc_min),
231 VTY_NEWLINE);
232 vty_out(vty, "Cell Reselection Hysteresis: %u dBm%s",
Harald Welte73225282009-12-12 18:17:25 +0100233 bts->si_common.cell_sel_par.cell_resel_hyst*2, VTY_NEWLINE);
Sylvain Munaut4010f1e2009-12-22 13:43:26 +0100234 vty_out(vty, "RACH TX-Integer: %u%s", bts->si_common.rach_control.tx_integer,
235 VTY_NEWLINE);
236 vty_out(vty, "RACH Max transmissions: %u%s",
237 rach_max_trans_raw2val(bts->si_common.rach_control.max_trans),
238 VTY_NEWLINE);
Harald Welte71355012009-12-21 23:08:18 +0100239 if (bts->si_common.rach_control.cell_bar)
Harald Welte (local)5dececf2009-08-12 13:28:23 +0200240 vty_out(vty, " CELL IS BARRED%s", VTY_NEWLINE);
Harald Welte9fbff4a2010-07-30 11:50:09 +0200241 vty_out(vty, "System Information present: 0x%08x, static: 0x%08x%s",
242 bts->si_valid, bts->si_mode_static, VTY_NEWLINE);
Harald Welte4cc34222009-05-01 15:12:31 +0000243 if (is_ipaccess_bts(bts))
Harald Welte8175e952009-10-20 00:22:00 +0200244 vty_out(vty, " Unit ID: %u/%u/0, OML Stream ID 0x%02x%s",
Harald Welte4cc34222009-05-01 15:12:31 +0000245 bts->ip_access.site_id, bts->ip_access.bts_id,
Harald Welte8175e952009-10-20 00:22:00 +0200246 bts->oml_tei, VTY_NEWLINE);
Harald Welte68628e82009-03-10 12:17:57 +0000247 vty_out(vty, " NM State: ");
248 net_dump_nmstate(vty, &bts->nm_state);
249 vty_out(vty, " Site Mgr NM State: ");
250 net_dump_nmstate(vty, &bts->site_mgr.nm_state);
251 vty_out(vty, " Paging: FIXME pending requests, %u free slots%s",
252 bts->paging.available_slots, VTY_NEWLINE);
Holger Hans Peter Freytherd283db42010-11-25 16:28:45 +0100253 if (is_ipaccess_bts(bts)) {
254 vty_out(vty, " OML Link state: %s.%s",
255 bts->oml_link ? "connected" : "disconnected", VTY_NEWLINE);
256 } else {
Harald Welte8175e952009-10-20 00:22:00 +0200257 vty_out(vty, " E1 Signalling Link:%s", VTY_NEWLINE);
258 e1isl_dump_vty(vty, bts->oml_link);
259 }
Holger Hans Peter Freytherd283db42010-11-25 16:28:45 +0100260
261 /* FIXME: chan_desc */
Harald Welteb908cb72009-12-22 13:09:29 +0100262 memset(&pl, 0, sizeof(pl));
263 bts_chan_load(&pl, bts);
264 vty_out(vty, " Current Channel Load:%s", VTY_NEWLINE);
265 dump_pchan_load_vty(vty, " ", &pl);
Harald Welte68628e82009-03-10 12:17:57 +0000266}
267
268DEFUN(show_bts, show_bts_cmd, "show bts [number]",
269 SHOW_STR "Display information about a BTS\n"
270 "BTS number")
271{
Harald Weltedcccb182010-05-16 20:52:23 +0200272 struct gsm_network *net = gsmnet_from_vty(vty);
Harald Welte68628e82009-03-10 12:17:57 +0000273 int bts_nr;
274
275 if (argc != 0) {
276 /* use the BTS number that the user has specified */
277 bts_nr = atoi(argv[0]);
Harald Welte712ddbc2010-12-24 12:24:03 +0100278 if (bts_nr >= net->num_bts) {
Harald Welte1bc77352009-03-10 19:47:51 +0000279 vty_out(vty, "%% can't find BTS '%s'%s", argv[0],
Harald Welte68628e82009-03-10 12:17:57 +0000280 VTY_NEWLINE);
281 return CMD_WARNING;
282 }
Harald Weltee441d9c2009-06-21 16:17:15 +0200283 bts_dump_vty(vty, gsm_bts_num(net, bts_nr));
Harald Welte68628e82009-03-10 12:17:57 +0000284 return CMD_SUCCESS;
285 }
286 /* print all BTS's */
287 for (bts_nr = 0; bts_nr < net->num_bts; bts_nr++)
Harald Weltee441d9c2009-06-21 16:17:15 +0200288 bts_dump_vty(vty, gsm_bts_num(net, bts_nr));
Harald Welte68628e82009-03-10 12:17:57 +0000289
290 return CMD_SUCCESS;
291}
292
Harald Welte42581822009-08-08 16:12:58 +0200293/* utility functions */
294static void parse_e1_link(struct gsm_e1_subslot *e1_link, const char *line,
295 const char *ts, const char *ss)
296{
297 e1_link->e1_nr = atoi(line);
298 e1_link->e1_ts = atoi(ts);
299 if (!strcmp(ss, "full"))
300 e1_link->e1_ts_ss = 255;
301 else
302 e1_link->e1_ts_ss = atoi(ss);
303}
304
305static void config_write_e1_link(struct vty *vty, struct gsm_e1_subslot *e1_link,
306 const char *prefix)
307{
308 if (!e1_link->e1_ts)
309 return;
310
311 if (e1_link->e1_ts_ss == 255)
312 vty_out(vty, "%se1 line %u timeslot %u sub-slot full%s",
313 prefix, e1_link->e1_nr, e1_link->e1_ts, VTY_NEWLINE);
314 else
315 vty_out(vty, "%se1 line %u timeslot %u sub-slot %u%s",
316 prefix, e1_link->e1_nr, e1_link->e1_ts,
317 e1_link->e1_ts_ss, VTY_NEWLINE);
318}
319
320
Harald Welte67ce0732009-08-06 19:06:46 +0200321static void config_write_ts_single(struct vty *vty, struct gsm_bts_trx_ts *ts)
322{
Harald Welte42581822009-08-08 16:12:58 +0200323 vty_out(vty, " timeslot %u%s", ts->nr, VTY_NEWLINE);
324 if (ts->pchan != GSM_PCHAN_NONE)
325 vty_out(vty, " phys_chan_config %s%s",
326 gsm_pchan_name(ts->pchan), VTY_NEWLINE);
Harald Weltea39b0f22010-06-14 22:26:10 +0200327 vty_out(vty, " hopping enabled %u%s",
328 ts->hopping.enabled, VTY_NEWLINE);
329 if (ts->hopping.enabled) {
330 unsigned int i;
331 vty_out(vty, " hopping sequence-number %u%s",
Harald Welte6e0cd042009-09-12 13:05:33 +0200332 ts->hopping.hsn, VTY_NEWLINE);
Harald Weltea39b0f22010-06-14 22:26:10 +0200333 vty_out(vty, " hopping maio %u%s",
Harald Welte6e0cd042009-09-12 13:05:33 +0200334 ts->hopping.maio, VTY_NEWLINE);
Harald Weltea39b0f22010-06-14 22:26:10 +0200335 for (i = 0; i < ts->hopping.arfcns.data_len*8; i++) {
336 if (!bitvec_get_bit_pos(&ts->hopping.arfcns, i))
337 continue;
338 vty_out(vty, " hopping arfcn add %u%s",
339 i, VTY_NEWLINE);
340 }
Harald Welte127af342010-12-24 12:07:07 +0100341 }
Harald Welte42581822009-08-08 16:12:58 +0200342 config_write_e1_link(vty, &ts->e1_link, " ");
Harald Welteface7ed2011-02-14 16:15:21 +0100343
344 if (ts->trx->bts->model->config_write_ts)
345 ts->trx->bts->model->config_write_ts(vty, ts);
Harald Welte67ce0732009-08-06 19:06:46 +0200346}
347
348static void config_write_trx_single(struct vty *vty, struct gsm_bts_trx *trx)
349{
350 int i;
351
Harald Welte5013b2a2009-08-07 13:29:14 +0200352 vty_out(vty, " trx %u%s", trx->nr, VTY_NEWLINE);
Harald Welte197dea92010-05-14 17:59:53 +0200353 if (trx->description)
354 vty_out(vty, " description %s%s", trx->description,
355 VTY_NEWLINE);
Holger Hans Peter Freyther2ba40af2010-04-17 06:42:07 +0200356 vty_out(vty, " rf_locked %u%s",
357 trx->nm_state.administrative == NM_STATE_LOCKED ? 1 : 0,
358 VTY_NEWLINE);
Harald Welte5013b2a2009-08-07 13:29:14 +0200359 vty_out(vty, " arfcn %u%s", trx->arfcn, VTY_NEWLINE);
Harald Welte (local)7b37d972009-12-27 20:56:38 +0100360 vty_out(vty, " nominal power %u%s", trx->nominal_power, VTY_NEWLINE);
Harald Welte5013b2a2009-08-07 13:29:14 +0200361 vty_out(vty, " max_power_red %u%s", trx->max_power_red, VTY_NEWLINE);
Harald Welte42581822009-08-08 16:12:58 +0200362 config_write_e1_link(vty, &trx->rsl_e1_link, " rsl ");
363 vty_out(vty, " rsl e1 tei %u%s", trx->rsl_tei, VTY_NEWLINE);
Harald Welte67ce0732009-08-06 19:06:46 +0200364
Harald Welteface7ed2011-02-14 16:15:21 +0100365 if (trx->bts->model->config_write_trx)
366 trx->bts->model->config_write_trx(vty, trx);
367
Harald Welte67ce0732009-08-06 19:06:46 +0200368 for (i = 0; i < TRX_NR_TS; i++)
369 config_write_ts_single(vty, &trx->ts[i]);
370}
371
Harald Welte615e9562010-05-11 23:50:21 +0200372static void config_write_bts_gprs(struct vty *vty, struct gsm_bts *bts)
373{
374 unsigned int i;
375 vty_out(vty, " gprs mode %s%s", bts_gprs_mode_name(bts->gprs.mode),
376 VTY_NEWLINE);
377 if (bts->gprs.mode == BTS_GPRS_NONE)
378 return;
379
380 vty_out(vty, " gprs routing area %u%s", bts->gprs.rac,
381 VTY_NEWLINE);
382 vty_out(vty, " gprs cell bvci %u%s", bts->gprs.cell.bvci,
383 VTY_NEWLINE);
384 for (i = 0; i < ARRAY_SIZE(bts->gprs.cell.timer); i++)
385 vty_out(vty, " gprs cell timer %s %u%s",
386 get_value_string(gprs_bssgp_cfg_strs, i),
387 bts->gprs.cell.timer[i], VTY_NEWLINE);
388 vty_out(vty, " gprs nsei %u%s", bts->gprs.nse.nsei,
389 VTY_NEWLINE);
390 for (i = 0; i < ARRAY_SIZE(bts->gprs.nse.timer); i++)
391 vty_out(vty, " gprs ns timer %s %u%s",
392 get_value_string(gprs_ns_timer_strs, i),
393 bts->gprs.nse.timer[i], VTY_NEWLINE);
394 for (i = 0; i < ARRAY_SIZE(bts->gprs.nsvc); i++) {
395 struct gsm_bts_gprs_nsvc *nsvc =
396 &bts->gprs.nsvc[i];
397 struct in_addr ia;
398
399 ia.s_addr = htonl(nsvc->remote_ip);
400 vty_out(vty, " gprs nsvc %u nsvci %u%s", i,
401 nsvc->nsvci, VTY_NEWLINE);
402 vty_out(vty, " gprs nsvc %u local udp port %u%s", i,
403 nsvc->local_port, VTY_NEWLINE);
404 vty_out(vty, " gprs nsvc %u remote udp port %u%s", i,
405 nsvc->remote_port, VTY_NEWLINE);
406 vty_out(vty, " gprs nsvc %u remote ip %s%s", i,
407 inet_ntoa(ia), VTY_NEWLINE);
408 }
409}
410
Harald Welte67ce0732009-08-06 19:06:46 +0200411static void config_write_bts_single(struct vty *vty, struct gsm_bts *bts)
412{
413 struct gsm_bts_trx *trx;
Harald Welte9fbff4a2010-07-30 11:50:09 +0200414 int i;
Harald Welte67ce0732009-08-06 19:06:46 +0200415
Harald Welte5013b2a2009-08-07 13:29:14 +0200416 vty_out(vty, " bts %u%s", bts->nr, VTY_NEWLINE);
417 vty_out(vty, " type %s%s", btstype2str(bts->type), VTY_NEWLINE);
Harald Welte197dea92010-05-14 17:59:53 +0200418 if (bts->description)
419 vty_out(vty, " description %s%s", bts->description, VTY_NEWLINE);
Harald Welte5013b2a2009-08-07 13:29:14 +0200420 vty_out(vty, " band %s%s", gsm_band_name(bts->band), VTY_NEWLINE);
Holger Hans Peter Freytherf926ed62009-11-19 16:38:49 +0100421 vty_out(vty, " cell_identity %u%s", bts->cell_identity, VTY_NEWLINE);
Harald Welte5013b2a2009-08-07 13:29:14 +0200422 vty_out(vty, " location_area_code %u%s", bts->location_area_code,
Harald Welte67ce0732009-08-06 19:06:46 +0200423 VTY_NEWLINE);
Harald Welte5013b2a2009-08-07 13:29:14 +0200424 vty_out(vty, " training_sequence_code %u%s", bts->tsc, VTY_NEWLINE);
425 vty_out(vty, " base_station_id_code %u%s", bts->bsic, VTY_NEWLINE);
Harald Welte (local)0e451d02009-08-13 10:14:26 +0200426 vty_out(vty, " ms max power %u%s", bts->ms_max_power, VTY_NEWLINE);
Harald Welte73225282009-12-12 18:17:25 +0100427 vty_out(vty, " cell reselection hysteresis %u%s",
428 bts->si_common.cell_sel_par.cell_resel_hyst*2, VTY_NEWLINE);
429 vty_out(vty, " rxlev access min %u%s",
430 bts->si_common.cell_sel_par.rxlev_acc_min, VTY_NEWLINE);
Sylvain Munaute0b06b02010-11-28 18:17:28 +0100431
432 if (bts->si_common.cell_ro_sel_par.present) {
433 struct gsm48_si_selection_params *sp;
434 sp = &bts->si_common.cell_ro_sel_par;
435
436 if (sp->cbq)
437 vty_out(vty, " cell bar qualify %u%s",
438 sp->cbq, VTY_NEWLINE);
439
440 if (sp->cell_resel_off)
441 vty_out(vty, " cell reselection offset %u%s",
442 sp->cell_resel_off*2, VTY_NEWLINE);
443
444 if (sp->temp_offs == 7)
445 vty_out(vty, " temporary offset infinite%s",
446 VTY_NEWLINE);
447 else if (sp->temp_offs)
448 vty_out(vty, " temporary offset %u%s",
449 sp->temp_offs*10, VTY_NEWLINE);
450
451 if (sp->penalty_time == 31)
452 vty_out(vty, " penalty time reserved%s",
453 VTY_NEWLINE);
454 else if (sp->penalty_time)
455 vty_out(vty, " penalty time %u%s",
456 (sp->penalty_time*20)+20, VTY_NEWLINE);
457 }
458
Harald Weltea43f7892009-12-01 18:04:30 +0530459 if (bts->si_common.chan_desc.t3212)
Harald Welte (local)efc92312009-08-14 23:09:25 +0200460 vty_out(vty, " periodic location update %u%s",
Dieter Spaard6613e02010-10-05 21:10:55 +0200461 bts->si_common.chan_desc.t3212 * 6, VTY_NEWLINE);
Harald Welte7a8fa412009-08-10 13:48:16 +0200462 vty_out(vty, " channel allocator %s%s",
463 bts->chan_alloc_reverse ? "descending" : "ascending",
464 VTY_NEWLINE);
Sylvain Munaut4010f1e2009-12-22 13:43:26 +0100465 vty_out(vty, " rach tx integer %u%s",
466 bts->si_common.rach_control.tx_integer, VTY_NEWLINE);
467 vty_out(vty, " rach max transmission %u%s",
468 rach_max_trans_raw2val(bts->si_common.rach_control.max_trans),
469 VTY_NEWLINE);
Holger Hans Peter Freyther95c22902010-04-25 23:08:39 +0800470
471 if (bts->rach_b_thresh != -1)
472 vty_out(vty, " rach nm busy threshold %u%s",
473 bts->rach_b_thresh, VTY_NEWLINE);
474 if (bts->rach_ldavg_slots != -1)
475 vty_out(vty, " rach nm load average %u%s",
476 bts->rach_ldavg_slots, VTY_NEWLINE);
Harald Welte71355012009-12-21 23:08:18 +0100477 if (bts->si_common.rach_control.cell_bar)
Harald Welte (local)5dececf2009-08-12 13:28:23 +0200478 vty_out(vty, " cell barred 1%s", VTY_NEWLINE);
Holger Hans Peter Freyther3a0a4632010-05-14 00:39:19 +0800479 if ((bts->si_common.rach_control.t2 & 0x4) == 0)
480 vty_out(vty, " rach emergency call allowed 1%s", VTY_NEWLINE);
Harald Welte9fbff4a2010-07-30 11:50:09 +0200481 for (i = SYSINFO_TYPE_1; i < _MAX_SYSINFO_TYPE; i++) {
482 if (bts->si_mode_static & (1 << i)) {
483 vty_out(vty, " system-information %s mode static%s",
484 get_value_string(osmo_sitype_strs, i), VTY_NEWLINE);
485 vty_out(vty, " system-information %s static %s%s",
486 get_value_string(osmo_sitype_strs, i),
487 hexdump_nospc(bts->si_buf[i], sizeof(bts->si_buf[i])),
488 VTY_NEWLINE);
489 }
490 }
Harald Welte8175e952009-10-20 00:22:00 +0200491 if (is_ipaccess_bts(bts)) {
Harald Welte5013b2a2009-08-07 13:29:14 +0200492 vty_out(vty, " ip.access unit_id %u %u%s",
Harald Weltea6fd58e2009-08-07 00:25:23 +0200493 bts->ip_access.site_id, bts->ip_access.bts_id, VTY_NEWLINE);
Harald Welte8175e952009-10-20 00:22:00 +0200494 vty_out(vty, " oml ip.access stream_id %u%s", bts->oml_tei, VTY_NEWLINE);
495 } else {
Harald Welte42581822009-08-08 16:12:58 +0200496 config_write_e1_link(vty, &bts->oml_e1_link, " oml ");
497 vty_out(vty, " oml e1 tei %u%s", bts->oml_tei, VTY_NEWLINE);
498 }
Holger Hans Peter Freythere66bf1f2010-09-06 10:11:25 +0800499
500 /* if we have a limit, write it */
501 if (bts->paging.free_chans_need >= 0)
502 vty_out(vty, " paging free %d%s", bts->paging.free_chans_need, VTY_NEWLINE);
503
Harald Welte32c09622011-01-11 23:44:56 +0100504 vty_out(vty, " neighbor-list mode %s%s",
Harald Welte64c07d22011-02-15 11:43:27 +0100505 get_value_string(bts_neigh_mode_strs, bts->neigh_list_manual_mode), VTY_NEWLINE);
506 if (bts->neigh_list_manual_mode != NL_MODE_AUTOMATIC) {
Harald Welte32c09622011-01-11 23:44:56 +0100507 for (i = 0; i < 1024; i++) {
508 if (bitvec_get_bit_pos(&bts->si_common.neigh_list, i))
509 vty_out(vty, " neighbor-list add arfcn %u%s",
510 i, VTY_NEWLINE);
511 }
512 }
Harald Welte64c07d22011-02-15 11:43:27 +0100513 if (bts->neigh_list_manual_mode == NL_MODE_MANUAL_SI5SEP) {
514 for (i = 0; i < 1024; i++) {
515 if (bitvec_get_bit_pos(&bts->si_common.si5_neigh_list, i))
516 vty_out(vty, " si5 neighbor-list add arfcn %u%s",
517 i, VTY_NEWLINE);
518 }
519 }
Harald Welte32c09622011-01-11 23:44:56 +0100520
Harald Welte615e9562010-05-11 23:50:21 +0200521 config_write_bts_gprs(vty, bts);
Harald Welte67ce0732009-08-06 19:06:46 +0200522
Harald Welteface7ed2011-02-14 16:15:21 +0100523 if (bts->model->config_write_bts)
524 bts->model->config_write_bts(vty, bts);
525
Harald Welte67ce0732009-08-06 19:06:46 +0200526 llist_for_each_entry(trx, &bts->trx_list, list)
527 config_write_trx_single(vty, trx);
528}
529
530static int config_write_bts(struct vty *v)
531{
Harald Weltedcccb182010-05-16 20:52:23 +0200532 struct gsm_network *gsmnet = gsmnet_from_vty(v);
Harald Welte67ce0732009-08-06 19:06:46 +0200533 struct gsm_bts *bts;
534
535 llist_for_each_entry(bts, &gsmnet->bts_list, list)
536 config_write_bts_single(v, bts);
537
538 return CMD_SUCCESS;
539}
540
Harald Welte5013b2a2009-08-07 13:29:14 +0200541static int config_write_net(struct vty *vty)
542{
Harald Weltedcccb182010-05-16 20:52:23 +0200543 struct gsm_network *gsmnet = gsmnet_from_vty(vty);
544
Harald Welte5013b2a2009-08-07 13:29:14 +0200545 vty_out(vty, "network%s", VTY_NEWLINE);
Harald Welte42581822009-08-08 16:12:58 +0200546 vty_out(vty, " network country code %u%s", gsmnet->country_code, VTY_NEWLINE);
Harald Welte5013b2a2009-08-07 13:29:14 +0200547 vty_out(vty, " mobile network code %u%s", gsmnet->network_code, VTY_NEWLINE);
Harald Welte42581822009-08-08 16:12:58 +0200548 vty_out(vty, " short name %s%s", gsmnet->name_short, VTY_NEWLINE);
549 vty_out(vty, " long name %s%s", gsmnet->name_long, VTY_NEWLINE);
Harald Welte (local)69de3972009-08-12 14:42:23 +0200550 vty_out(vty, " auth policy %s%s", gsm_auth_policy_name(gsmnet->auth_policy), VTY_NEWLINE);
Harald Welte1085c092009-11-18 20:33:19 +0100551 vty_out(vty, " location updating reject cause %u%s",
552 gsmnet->reject_cause, VTY_NEWLINE);
Harald Welte4381cfe2009-08-30 15:47:06 +0900553 vty_out(vty, " encryption a5 %u%s", gsmnet->a5_encryption, VTY_NEWLINE);
Holger Hans Peter Freytherd54c3372009-11-19 16:37:48 +0100554 vty_out(vty, " neci %u%s", gsmnet->neci, VTY_NEWLINE);
Holger Hans Peter Freyther76fc4a32010-09-06 09:41:50 +0800555 vty_out(vty, " paging any use tch %d%s", gsmnet->pag_any_tch, VTY_NEWLINE);
Harald Welteeab84a12009-12-13 10:53:12 +0100556 vty_out(vty, " rrlp mode %s%s", rrlp_mode_name(gsmnet->rrlp.mode),
557 VTY_NEWLINE);
Harald Welte648b6ce2009-12-14 09:00:24 +0100558 vty_out(vty, " mm info %u%s", gsmnet->send_mm_info, VTY_NEWLINE);
Harald Weltebc814502009-12-19 21:41:52 +0100559 vty_out(vty, " handover %u%s", gsmnet->handover.active, VTY_NEWLINE);
Harald Welteb720bd32009-12-21 16:51:50 +0100560 vty_out(vty, " handover window rxlev averaging %u%s",
561 gsmnet->handover.win_rxlev_avg, VTY_NEWLINE);
562 vty_out(vty, " handover window rxqual averaging %u%s",
563 gsmnet->handover.win_rxqual_avg, VTY_NEWLINE);
564 vty_out(vty, " handover window rxlev neighbor averaging %u%s",
565 gsmnet->handover.win_rxlev_avg_neigh, VTY_NEWLINE);
566 vty_out(vty, " handover power budget interval %u%s",
567 gsmnet->handover.pwr_interval, VTY_NEWLINE);
568 vty_out(vty, " handover power budget hysteresis %u%s",
569 gsmnet->handover.pwr_hysteresis, VTY_NEWLINE);
570 vty_out(vty, " handover maximum distance %u%s",
571 gsmnet->handover.max_distance, VTY_NEWLINE);
Holger Hans Peter Freytherc4d88ad2009-11-21 21:18:38 +0100572 vty_out(vty, " timer t3101 %u%s", gsmnet->T3101, VTY_NEWLINE);
Holger Hans Peter Freyther23975e72009-11-21 21:42:26 +0100573 vty_out(vty, " timer t3103 %u%s", gsmnet->T3103, VTY_NEWLINE);
574 vty_out(vty, " timer t3105 %u%s", gsmnet->T3105, VTY_NEWLINE);
575 vty_out(vty, " timer t3107 %u%s", gsmnet->T3107, VTY_NEWLINE);
576 vty_out(vty, " timer t3109 %u%s", gsmnet->T3109, VTY_NEWLINE);
577 vty_out(vty, " timer t3111 %u%s", gsmnet->T3111, VTY_NEWLINE);
578 vty_out(vty, " timer t3113 %u%s", gsmnet->T3113, VTY_NEWLINE);
579 vty_out(vty, " timer t3115 %u%s", gsmnet->T3115, VTY_NEWLINE);
580 vty_out(vty, " timer t3117 %u%s", gsmnet->T3117, VTY_NEWLINE);
581 vty_out(vty, " timer t3119 %u%s", gsmnet->T3119, VTY_NEWLINE);
Harald Welte2862dca2010-12-23 14:39:29 +0100582 vty_out(vty, " timer t3122 %u%s", gsmnet->T3122, VTY_NEWLINE);
Holger Hans Peter Freyther23975e72009-11-21 21:42:26 +0100583 vty_out(vty, " timer t3141 %u%s", gsmnet->T3141, VTY_NEWLINE);
Harald Welte63dbfc62010-12-15 15:34:23 +0100584 vty_out(vty, " dtx-used %u%s", gsmnet->dtx_enabled, VTY_NEWLINE);
Holger Hans Peter Freytherae9006a2010-12-22 16:26:04 +0100585 vty_out(vty, " subscriber-keep-in-ram %d%s",
586 gsmnet->keep_subscr, VTY_NEWLINE);
Harald Welte5013b2a2009-08-07 13:29:14 +0200587
588 return CMD_SUCCESS;
589}
Harald Welte67ce0732009-08-06 19:06:46 +0200590
Harald Welte68628e82009-03-10 12:17:57 +0000591static void trx_dump_vty(struct vty *vty, struct gsm_bts_trx *trx)
592{
593 vty_out(vty, "TRX %u of BTS %u is on ARFCN %u%s",
594 trx->nr, trx->bts->nr, trx->arfcn, VTY_NEWLINE);
Harald Welte197dea92010-05-14 17:59:53 +0200595 vty_out(vty, "Description: %s%s",
596 trx->description ? trx->description : "(null)", VTY_NEWLINE);
Harald Weltefcd24452009-06-20 18:15:19 +0200597 vty_out(vty, " RF Nominal Power: %d dBm, reduced by %u dB, "
Harald Welte42581822009-08-08 16:12:58 +0200598 "resulting BS power: %d dBm%s",
Harald Weltefcd24452009-06-20 18:15:19 +0200599 trx->nominal_power, trx->max_power_red,
Harald Welte42581822009-08-08 16:12:58 +0200600 trx->nominal_power - trx->max_power_red, VTY_NEWLINE);
Harald Welte68628e82009-03-10 12:17:57 +0000601 vty_out(vty, " NM State: ");
602 net_dump_nmstate(vty, &trx->nm_state);
603 vty_out(vty, " Baseband Transceiver NM State: ");
604 net_dump_nmstate(vty, &trx->bb_transc.nm_state);
Harald Welte8175e952009-10-20 00:22:00 +0200605 if (is_ipaccess_bts(trx->bts)) {
606 vty_out(vty, " ip.access stream ID: 0x%02x%s",
607 trx->rsl_tei, VTY_NEWLINE);
608 } else {
609 vty_out(vty, " E1 Signalling Link:%s", VTY_NEWLINE);
610 e1isl_dump_vty(vty, trx->rsl_link);
611 }
Harald Welte68628e82009-03-10 12:17:57 +0000612}
613
614DEFUN(show_trx,
615 show_trx_cmd,
616 "show trx [bts_nr] [trx_nr]",
Harald Welte8f0ed552010-05-11 21:53:49 +0200617 SHOW_STR "Display information about a TRX\n"
618 "BTS Number\n"
619 "TRX Number\n")
Harald Welte68628e82009-03-10 12:17:57 +0000620{
Harald Weltedcccb182010-05-16 20:52:23 +0200621 struct gsm_network *net = gsmnet_from_vty(vty);
Harald Welte68628e82009-03-10 12:17:57 +0000622 struct gsm_bts *bts = NULL;
623 struct gsm_bts_trx *trx;
624 int bts_nr, trx_nr;
625
626 if (argc >= 1) {
627 /* use the BTS number that the user has specified */
628 bts_nr = atoi(argv[0]);
629 if (bts_nr >= net->num_bts) {
Harald Welte1bc77352009-03-10 19:47:51 +0000630 vty_out(vty, "%% can't find BTS '%s'%s", argv[0],
Harald Welte68628e82009-03-10 12:17:57 +0000631 VTY_NEWLINE);
632 return CMD_WARNING;
633 }
Harald Weltee441d9c2009-06-21 16:17:15 +0200634 bts = gsm_bts_num(net, bts_nr);
Harald Welte68628e82009-03-10 12:17:57 +0000635 }
636 if (argc >= 2) {
637 trx_nr = atoi(argv[1]);
638 if (trx_nr >= bts->num_trx) {
Harald Welte1bc77352009-03-10 19:47:51 +0000639 vty_out(vty, "%% can't find TRX '%s'%s", argv[1],
Harald Welte68628e82009-03-10 12:17:57 +0000640 VTY_NEWLINE);
641 return CMD_WARNING;
642 }
Harald Weltee441d9c2009-06-21 16:17:15 +0200643 trx = gsm_bts_trx_num(bts, trx_nr);
Harald Welte68628e82009-03-10 12:17:57 +0000644 trx_dump_vty(vty, trx);
645 return CMD_SUCCESS;
646 }
647 if (bts) {
648 /* print all TRX in this BTS */
649 for (trx_nr = 0; trx_nr < bts->num_trx; trx_nr++) {
Harald Weltee441d9c2009-06-21 16:17:15 +0200650 trx = gsm_bts_trx_num(bts, trx_nr);
Harald Welte68628e82009-03-10 12:17:57 +0000651 trx_dump_vty(vty, trx);
652 }
653 return CMD_SUCCESS;
654 }
655
656 for (bts_nr = 0; bts_nr < net->num_bts; bts_nr++) {
Harald Weltee441d9c2009-06-21 16:17:15 +0200657 bts = gsm_bts_num(net, bts_nr);
Harald Welte68628e82009-03-10 12:17:57 +0000658 for (trx_nr = 0; trx_nr < bts->num_trx; trx_nr++) {
Harald Weltee441d9c2009-06-21 16:17:15 +0200659 trx = gsm_bts_trx_num(bts, trx_nr);
Harald Welte68628e82009-03-10 12:17:57 +0000660 trx_dump_vty(vty, trx);
661 }
662 }
663
664 return CMD_SUCCESS;
665}
666
Harald Welte67ce0732009-08-06 19:06:46 +0200667
Harald Welte68628e82009-03-10 12:17:57 +0000668static void ts_dump_vty(struct vty *vty, struct gsm_bts_trx_ts *ts)
669{
Harald Weltecd103a92010-12-24 12:14:52 +0100670 vty_out(vty, "BTS %u, TRX %u, Timeslot %u, phys cfg %s",
Harald Welte026b4ca2010-12-24 12:12:10 +0100671 ts->trx->bts->nr, ts->trx->nr, ts->nr,
Harald Weltecd103a92010-12-24 12:14:52 +0100672 gsm_pchan_name(ts->pchan));
673 if (ts->pchan == GSM_PCHAN_TCH_F_PDCH)
Harald Welteb29cea12010-12-24 12:26:13 +0100674 vty_out(vty, " (%s mode)",
Harald Weltecd103a92010-12-24 12:14:52 +0100675 ts->flags & TS_F_PDCH_MODE ? "PDCH" : "TCH/F");
676 vty_out(vty, "%s", VTY_NEWLINE);
Harald Welte68628e82009-03-10 12:17:57 +0000677 vty_out(vty, " NM State: ");
678 net_dump_nmstate(vty, &ts->nm_state);
Harald Welte2c828992009-12-02 01:56:49 +0530679 if (!is_ipaccess_bts(ts->trx->bts))
Harald Welteef235b52009-03-10 12:34:02 +0000680 vty_out(vty, " E1 Line %u, Timeslot %u, Subslot %u%s",
681 ts->e1_link.e1_nr, ts->e1_link.e1_ts,
682 ts->e1_link.e1_ts_ss, VTY_NEWLINE);
Harald Welte68628e82009-03-10 12:17:57 +0000683}
684
685DEFUN(show_ts,
686 show_ts_cmd,
Harald Welte1bc77352009-03-10 19:47:51 +0000687 "show timeslot [bts_nr] [trx_nr] [ts_nr]",
Harald Welte8f0ed552010-05-11 21:53:49 +0200688 SHOW_STR "Display information about a TS\n"
689 "BTS Number\n" "TRX Number\n" "Timeslot Number\n")
Harald Welte68628e82009-03-10 12:17:57 +0000690{
Harald Weltedcccb182010-05-16 20:52:23 +0200691 struct gsm_network *net = gsmnet_from_vty(vty);
Harald Welte274d0152010-12-24 12:05:03 +0100692 struct gsm_bts *bts = NULL;
693 struct gsm_bts_trx *trx = NULL;
694 struct gsm_bts_trx_ts *ts = NULL;
Harald Welte68628e82009-03-10 12:17:57 +0000695 int bts_nr, trx_nr, ts_nr;
696
697 if (argc >= 1) {
698 /* use the BTS number that the user has specified */
699 bts_nr = atoi(argv[0]);
700 if (bts_nr >= net->num_bts) {
Harald Welte1bc77352009-03-10 19:47:51 +0000701 vty_out(vty, "%% can't find BTS '%s'%s", argv[0],
Harald Welte68628e82009-03-10 12:17:57 +0000702 VTY_NEWLINE);
703 return CMD_WARNING;
704 }
Harald Weltee441d9c2009-06-21 16:17:15 +0200705 bts = gsm_bts_num(net, bts_nr);
Harald Welte68628e82009-03-10 12:17:57 +0000706 }
707 if (argc >= 2) {
708 trx_nr = atoi(argv[1]);
709 if (trx_nr >= bts->num_trx) {
Harald Welte1bc77352009-03-10 19:47:51 +0000710 vty_out(vty, "%% can't find TRX '%s'%s", argv[1],
Harald Welte68628e82009-03-10 12:17:57 +0000711 VTY_NEWLINE);
712 return CMD_WARNING;
713 }
Harald Weltee441d9c2009-06-21 16:17:15 +0200714 trx = gsm_bts_trx_num(bts, trx_nr);
Harald Welte68628e82009-03-10 12:17:57 +0000715 }
716 if (argc >= 3) {
717 ts_nr = atoi(argv[2]);
718 if (ts_nr >= TRX_NR_TS) {
Harald Welte1bc77352009-03-10 19:47:51 +0000719 vty_out(vty, "%% can't find TS '%s'%s", argv[2],
Harald Welte68628e82009-03-10 12:17:57 +0000720 VTY_NEWLINE);
721 return CMD_WARNING;
722 }
Harald Welte274d0152010-12-24 12:05:03 +0100723 /* Fully Specified: print and exit */
Harald Welte68628e82009-03-10 12:17:57 +0000724 ts = &trx->ts[ts_nr];
725 ts_dump_vty(vty, ts);
726 return CMD_SUCCESS;
727 }
Harald Welte274d0152010-12-24 12:05:03 +0100728
729 if (bts && trx) {
730 /* Iterate over all TS in this TRX */
731 for (ts_nr = 0; ts_nr < TRX_NR_TS; ts_nr++) {
732 ts = &trx->ts[ts_nr];
733 ts_dump_vty(vty, ts);
734 }
735 } else if (bts) {
736 /* Iterate over all TRX in this BTS, TS in each TRX */
Harald Welte68628e82009-03-10 12:17:57 +0000737 for (trx_nr = 0; trx_nr < bts->num_trx; trx_nr++) {
Harald Weltee441d9c2009-06-21 16:17:15 +0200738 trx = gsm_bts_trx_num(bts, trx_nr);
Harald Welte68628e82009-03-10 12:17:57 +0000739 for (ts_nr = 0; ts_nr < TRX_NR_TS; ts_nr++) {
740 ts = &trx->ts[ts_nr];
741 ts_dump_vty(vty, ts);
742 }
743 }
Harald Welte274d0152010-12-24 12:05:03 +0100744 } else {
745 /* Iterate over all BTS, TRX in each BTS, TS in each TRX */
746 for (bts_nr = 0; bts_nr < net->num_bts; bts_nr++) {
747 bts = gsm_bts_num(net, bts_nr);
748 for (trx_nr = 0; trx_nr < bts->num_trx; trx_nr++) {
749 trx = gsm_bts_trx_num(bts, trx_nr);
750 for (ts_nr = 0; ts_nr < TRX_NR_TS; ts_nr++) {
751 ts = &trx->ts[ts_nr];
752 ts_dump_vty(vty, ts);
753 }
754 }
755 }
Harald Welte68628e82009-03-10 12:17:57 +0000756 }
757
758 return CMD_SUCCESS;
759}
760
Holger Hans Peter Freyther424c4f02010-01-06 06:00:40 +0100761static void subscr_dump_vty(struct vty *vty, struct gsm_subscriber *subscr)
Harald Welte68628e82009-03-10 12:17:57 +0000762{
Harald Weltefcd24452009-06-20 18:15:19 +0200763 vty_out(vty, " ID: %llu, Authorized: %d%s", subscr->id,
Harald Welte40f82892009-05-23 17:31:39 +0000764 subscr->authorized, VTY_NEWLINE);
Harald Welte68628e82009-03-10 12:17:57 +0000765 if (subscr->name)
Harald Welte1bc77352009-03-10 19:47:51 +0000766 vty_out(vty, " Name: '%s'%s", subscr->name, VTY_NEWLINE);
Harald Welte68628e82009-03-10 12:17:57 +0000767 if (subscr->extension)
768 vty_out(vty, " Extension: %s%s", subscr->extension,
769 VTY_NEWLINE);
770 if (subscr->imsi)
771 vty_out(vty, " IMSI: %s%s", subscr->imsi, VTY_NEWLINE);
Holger Hans Peter Freyther22230252009-08-19 12:53:57 +0200772 if (subscr->tmsi != GSM_RESERVED_TMSI)
773 vty_out(vty, " TMSI: %08X%s", subscr->tmsi,
Harald Welte731fd912009-08-15 03:24:51 +0200774 VTY_NEWLINE);
Sylvain Munautaf292642009-12-27 19:29:28 +0100775
Harald Welte (local)15920de2009-08-14 20:27:16 +0200776 vty_out(vty, " Use count: %u%s", subscr->use_count, VTY_NEWLINE);
Harald Welte68628e82009-03-10 12:17:57 +0000777}
778
Harald Welte8387a492009-12-22 21:43:14 +0100779static void meas_rep_dump_uni_vty(struct vty *vty,
780 struct gsm_meas_rep_unidir *mru,
781 const char *prefix,
782 const char *dir)
783{
784 vty_out(vty, "%s RXL-FULL-%s: %4d dBm, RXL-SUB-%s: %4d dBm ",
785 prefix, dir, rxlev2dbm(mru->full.rx_lev),
786 dir, rxlev2dbm(mru->sub.rx_lev));
787 vty_out(vty, "RXQ-FULL-%s: %d, RXQ-SUB-%s: %d%s",
788 dir, mru->full.rx_qual, dir, mru->sub.rx_qual,
789 VTY_NEWLINE);
790}
791
792static void meas_rep_dump_vty(struct vty *vty, struct gsm_meas_rep *mr,
793 const char *prefix)
794{
795 vty_out(vty, "%sMeasurement Report:%s", prefix, VTY_NEWLINE);
796 vty_out(vty, "%s Flags: %s%s%s%s%s", prefix,
797 mr->flags & MEAS_REP_F_UL_DTX ? "DTXu " : "",
798 mr->flags & MEAS_REP_F_DL_DTX ? "DTXd " : "",
799 mr->flags & MEAS_REP_F_FPC ? "FPC " : "",
800 mr->flags & MEAS_REP_F_DL_VALID ? " " : "DLinval ",
801 VTY_NEWLINE);
802 if (mr->flags & MEAS_REP_F_MS_TO)
803 vty_out(vty, "%s MS Timing Offset: %u%s", prefix,
804 mr->ms_timing_offset, VTY_NEWLINE);
805 if (mr->flags & MEAS_REP_F_MS_L1)
806 vty_out(vty, "%s L1 MS Power: %u dBm, Timing Advance: %u%s",
807 prefix, mr->ms_l1.pwr, mr->ms_l1.ta, VTY_NEWLINE);
808 if (mr->flags & MEAS_REP_F_DL_VALID)
809 meas_rep_dump_uni_vty(vty, &mr->dl, prefix, "dl");
810 meas_rep_dump_uni_vty(vty, &mr->ul, prefix, "ul");
811}
812
Holger Hans Peter Freyther029235e2010-05-14 02:03:16 +0800813static void lchan_dump_full_vty(struct vty *vty, struct gsm_lchan *lchan)
Harald Welte68628e82009-03-10 12:17:57 +0000814{
Harald Welte8387a492009-12-22 21:43:14 +0100815 int idx;
816
Harald Welte85bded82010-12-24 12:22:34 +0100817 vty_out(vty, "BTS %u, TRX %u, Timeslot %u, Lchan %u: Type %s%s",
818 lchan->ts->trx->bts->nr, lchan->ts->trx->nr, lchan->ts->nr,
819 lchan->nr, gsm_lchant_name(lchan->type), VTY_NEWLINE);
Holger Hans Peter Freyther40494552010-06-28 17:09:29 +0800820 vty_out(vty, " Connection: %u, State: %s%s",
821 lchan->conn ? 1: 0,
Harald Welte1887f9d2009-12-29 10:52:38 +0100822 gsm_lchans_name(lchan->state), VTY_NEWLINE);
Harald Welte73225282009-12-12 18:17:25 +0100823 vty_out(vty, " BS Power: %u dBm, MS Power: %u dBm%s",
824 lchan->ts->trx->nominal_power - lchan->ts->trx->max_power_red
825 - lchan->bs_power*2,
826 ms_pwr_dbm(lchan->ts->trx->bts->band, lchan->ms_power),
827 VTY_NEWLINE);
Holger Hans Peter Freyther2412a072010-06-28 15:47:12 +0800828 if (lchan->conn && lchan->conn->subscr) {
Harald Welte68628e82009-03-10 12:17:57 +0000829 vty_out(vty, " Subscriber:%s", VTY_NEWLINE);
Holger Hans Peter Freyther2412a072010-06-28 15:47:12 +0800830 subscr_dump_vty(vty, lchan->conn->subscr);
Harald Welte68628e82009-03-10 12:17:57 +0000831 } else
832 vty_out(vty, " No Subscriber%s", VTY_NEWLINE);
Harald Welte2c828992009-12-02 01:56:49 +0530833 if (is_ipaccess_bts(lchan->ts->trx->bts)) {
834 struct in_addr ia;
Holger Hans Peter Freyther54fa7992010-04-07 15:39:16 +0200835 ia.s_addr = htonl(lchan->abis_ip.bound_ip);
Harald Welte2c828992009-12-02 01:56:49 +0530836 vty_out(vty, " Bound IP: %s Port %u RTP_TYPE2=%u CONN_ID=%u%s",
837 inet_ntoa(ia), lchan->abis_ip.bound_port,
838 lchan->abis_ip.rtp_payload2, lchan->abis_ip.conn_id,
839 VTY_NEWLINE);
840 }
Harald Welte8387a492009-12-22 21:43:14 +0100841
842 /* we want to report the last measurement report */
843 idx = calc_initial_idx(ARRAY_SIZE(lchan->meas_rep),
844 lchan->meas_rep_idx, 1);
845 meas_rep_dump_vty(vty, &lchan->meas_rep[idx], " ");
Harald Welte68628e82009-03-10 12:17:57 +0000846}
847
Holger Hans Peter Freyther3d6a5d62010-05-14 02:08:49 +0800848static void lchan_dump_short_vty(struct vty *vty, struct gsm_lchan *lchan)
849{
Holger Hans Peter Freythercf5cc5b2010-05-14 01:57:02 +0800850 struct gsm_meas_rep *mr;
851 int idx;
852
853 /* we want to report the last measurement report */
854 idx = calc_initial_idx(ARRAY_SIZE(lchan->meas_rep),
855 lchan->meas_rep_idx, 1);
856 mr = &lchan->meas_rep[idx];
857
Harald Welte85bded82010-12-24 12:22:34 +0100858 vty_out(vty, "BTS %u, TRX %u, Timeslot %u, Lchan %u, Type %s - "
859 "L1 MS Power: %u dBm RXL-FULL-dl: %4d dBm RXL-FULL-ul: %4d dBm%s",
860 lchan->ts->trx->bts->nr, lchan->ts->trx->nr, lchan->ts->nr,
Harald Welteb29cea12010-12-24 12:26:13 +0100861 lchan->nr, gsm_lchant_name(lchan->type), mr->ms_l1.pwr,
Holger Hans Peter Freythercf5cc5b2010-05-14 01:57:02 +0800862 rxlev2dbm(mr->dl.full.rx_lev),
863 rxlev2dbm(mr->ul.full.rx_lev),
Holger Hans Peter Freyther3d6a5d62010-05-14 02:08:49 +0800864 VTY_NEWLINE);
865}
866
Holger Hans Peter Freyther029235e2010-05-14 02:03:16 +0800867static int lchan_summary(struct vty *vty, int argc, const char **argv,
868 void (*dump_cb)(struct vty *, struct gsm_lchan *))
Harald Welte68628e82009-03-10 12:17:57 +0000869{
Harald Weltedcccb182010-05-16 20:52:23 +0200870 struct gsm_network *net = gsmnet_from_vty(vty);
Harald Welte68628e82009-03-10 12:17:57 +0000871 struct gsm_bts *bts;
872 struct gsm_bts_trx *trx;
873 struct gsm_bts_trx_ts *ts;
874 struct gsm_lchan *lchan;
875 int bts_nr, trx_nr, ts_nr, lchan_nr;
876
877 if (argc >= 1) {
878 /* use the BTS number that the user has specified */
879 bts_nr = atoi(argv[0]);
880 if (bts_nr >= net->num_bts) {
881 vty_out(vty, "%% can't find BTS %s%s", argv[0],
882 VTY_NEWLINE);
883 return CMD_WARNING;
884 }
Harald Weltee441d9c2009-06-21 16:17:15 +0200885 bts = gsm_bts_num(net, bts_nr);
Harald Welte68628e82009-03-10 12:17:57 +0000886 }
887 if (argc >= 2) {
888 trx_nr = atoi(argv[1]);
889 if (trx_nr >= bts->num_trx) {
890 vty_out(vty, "%% can't find TRX %s%s", argv[1],
891 VTY_NEWLINE);
892 return CMD_WARNING;
893 }
Harald Weltee441d9c2009-06-21 16:17:15 +0200894 trx = gsm_bts_trx_num(bts, trx_nr);
Harald Welte68628e82009-03-10 12:17:57 +0000895 }
896 if (argc >= 3) {
897 ts_nr = atoi(argv[2]);
898 if (ts_nr >= TRX_NR_TS) {
899 vty_out(vty, "%% can't find TS %s%s", argv[2],
900 VTY_NEWLINE);
901 return CMD_WARNING;
902 }
903 ts = &trx->ts[ts_nr];
904 }
905 if (argc >= 4) {
906 lchan_nr = atoi(argv[3]);
907 if (lchan_nr >= TS_MAX_LCHAN) {
908 vty_out(vty, "%% can't find LCHAN %s%s", argv[3],
909 VTY_NEWLINE);
910 return CMD_WARNING;
911 }
912 lchan = &ts->lchan[lchan_nr];
Holger Hans Peter Freyther029235e2010-05-14 02:03:16 +0800913 dump_cb(vty, lchan);
Harald Welte68628e82009-03-10 12:17:57 +0000914 return CMD_SUCCESS;
915 }
916 for (bts_nr = 0; bts_nr < net->num_bts; bts_nr++) {
Harald Weltee441d9c2009-06-21 16:17:15 +0200917 bts = gsm_bts_num(net, bts_nr);
Harald Welte68628e82009-03-10 12:17:57 +0000918 for (trx_nr = 0; trx_nr < bts->num_trx; trx_nr++) {
Harald Weltee441d9c2009-06-21 16:17:15 +0200919 trx = gsm_bts_trx_num(bts, trx_nr);
Harald Welte68628e82009-03-10 12:17:57 +0000920 for (ts_nr = 0; ts_nr < TRX_NR_TS; ts_nr++) {
921 ts = &trx->ts[ts_nr];
922 for (lchan_nr = 0; lchan_nr < TS_MAX_LCHAN;
923 lchan_nr++) {
924 lchan = &ts->lchan[lchan_nr];
Harald Welteef235b52009-03-10 12:34:02 +0000925 if (lchan->type == GSM_LCHAN_NONE)
926 continue;
Holger Hans Peter Freyther029235e2010-05-14 02:03:16 +0800927 dump_cb(vty, lchan);
Harald Welte68628e82009-03-10 12:17:57 +0000928 }
929 }
930 }
931 }
932
933 return CMD_SUCCESS;
934}
935
Holger Hans Peter Freyther029235e2010-05-14 02:03:16 +0800936
937DEFUN(show_lchan,
938 show_lchan_cmd,
939 "show lchan [bts_nr] [trx_nr] [ts_nr] [lchan_nr]",
940 SHOW_STR "Display information about a logical channel\n"
941 "BTS Number\n" "TRX Number\n" "Timeslot Number\n"
942 "Logical Channel Number\n")
943
944{
945 return lchan_summary(vty, argc, argv, lchan_dump_full_vty);
946}
947
Holger Hans Peter Freyther3d6a5d62010-05-14 02:08:49 +0800948DEFUN(show_lchan_summary,
949 show_lchan_summary_cmd,
950 "show lchan summary [bts_nr] [trx_nr] [ts_nr] [lchan_nr]",
951 SHOW_STR "Display information about a logical channel\n"
952 "BTS Number\n" "TRX Number\n" "Timeslot Number\n"
953 "Logical Channel Number\n")
954{
955 return lchan_summary(vty, argc, argv, lchan_dump_short_vty);
956}
957
Harald Welte1bc77352009-03-10 19:47:51 +0000958static void e1drv_dump_vty(struct vty *vty, struct e1inp_driver *drv)
959{
960 vty_out(vty, "E1 Input Driver %s%s", drv->name, VTY_NEWLINE);
961}
962
963DEFUN(show_e1drv,
964 show_e1drv_cmd,
965 "show e1_driver",
966 SHOW_STR "Display information about available E1 drivers\n")
967{
968 struct e1inp_driver *drv;
969
970 llist_for_each_entry(drv, &e1inp_driver_list, list)
971 e1drv_dump_vty(vty, drv);
972
973 return CMD_SUCCESS;
974}
975
Harald Welte68628e82009-03-10 12:17:57 +0000976static void e1line_dump_vty(struct vty *vty, struct e1inp_line *line)
977{
978 vty_out(vty, "E1 Line Number %u, Name %s, Driver %s%s",
979 line->num, line->name ? line->name : "",
980 line->driver->name, VTY_NEWLINE);
981}
982
983DEFUN(show_e1line,
984 show_e1line_cmd,
985 "show e1_line [line_nr]",
Harald Welte8f0ed552010-05-11 21:53:49 +0200986 SHOW_STR "Display information about a E1 line\n"
987 "E1 Line Number\n")
Harald Welte68628e82009-03-10 12:17:57 +0000988{
Harald Welte1bc77352009-03-10 19:47:51 +0000989 struct e1inp_line *line;
990
991 if (argc >= 1) {
992 int num = atoi(argv[0]);
993 llist_for_each_entry(line, &e1inp_line_list, list) {
994 if (line->num == num) {
995 e1line_dump_vty(vty, line);
996 return CMD_SUCCESS;
997 }
998 }
999 return CMD_WARNING;
1000 }
1001
1002 llist_for_each_entry(line, &e1inp_line_list, list)
1003 e1line_dump_vty(vty, line);
1004
1005 return CMD_SUCCESS;
Harald Welte68628e82009-03-10 12:17:57 +00001006}
1007
1008static void e1ts_dump_vty(struct vty *vty, struct e1inp_ts *ts)
1009{
Harald Welte42581822009-08-08 16:12:58 +02001010 if (ts->type == E1INP_TS_TYPE_NONE)
1011 return;
Harald Welte1bc77352009-03-10 19:47:51 +00001012 vty_out(vty, "E1 Timeslot %2u of Line %u is Type %s%s",
1013 ts->num, ts->line->num, e1inp_tstype_name(ts->type),
1014 VTY_NEWLINE);
Harald Welte68628e82009-03-10 12:17:57 +00001015}
1016
1017DEFUN(show_e1ts,
1018 show_e1ts_cmd,
1019 "show e1_timeslot [line_nr] [ts_nr]",
Harald Welte8f0ed552010-05-11 21:53:49 +02001020 SHOW_STR "Display information about a E1 timeslot\n"
1021 "E1 Line Number\n" "E1 Timeslot Number\n")
Harald Welte68628e82009-03-10 12:17:57 +00001022{
Harald Welte986c3d72009-11-17 06:12:16 +01001023 struct e1inp_line *line = NULL;
Harald Welte1bc77352009-03-10 19:47:51 +00001024 struct e1inp_ts *ts;
1025 int ts_nr;
Harald Welte68628e82009-03-10 12:17:57 +00001026
Harald Welte1bc77352009-03-10 19:47:51 +00001027 if (argc == 0) {
1028 llist_for_each_entry(line, &e1inp_line_list, list) {
1029 for (ts_nr = 0; ts_nr < NUM_E1_TS; ts_nr++) {
1030 ts = &line->ts[ts_nr];
1031 e1ts_dump_vty(vty, ts);
1032 }
1033 }
1034 return CMD_SUCCESS;
1035 }
1036 if (argc >= 1) {
1037 int num = atoi(argv[0]);
1038 llist_for_each_entry(line, &e1inp_line_list, list) {
1039 if (line->num == num)
1040 break;
1041 }
1042 if (!line || line->num != num) {
1043 vty_out(vty, "E1 line %s is invalid%s",
1044 argv[0], VTY_NEWLINE);
1045 return CMD_WARNING;
1046 }
1047 }
1048 if (argc >= 2) {
1049 ts_nr = atoi(argv[1]);
1050 if (ts_nr > NUM_E1_TS) {
1051 vty_out(vty, "E1 timeslot %s is invalid%s",
1052 argv[1], VTY_NEWLINE);
1053 return CMD_WARNING;
1054 }
1055 ts = &line->ts[ts_nr];
1056 e1ts_dump_vty(vty, ts);
1057 return CMD_SUCCESS;
1058 } else {
1059 for (ts_nr = 0; ts_nr < NUM_E1_TS; ts_nr++) {
1060 ts = &line->ts[ts_nr];
1061 e1ts_dump_vty(vty, ts);
1062 }
1063 return CMD_SUCCESS;
1064 }
1065 return CMD_SUCCESS;
Harald Welte68628e82009-03-10 12:17:57 +00001066}
1067
Harald Weltebe4b7302009-05-23 16:59:33 +00001068static void paging_dump_vty(struct vty *vty, struct gsm_paging_request *pag)
Harald Weltef5025b62009-03-28 16:55:11 +00001069{
1070 vty_out(vty, "Paging on BTS %u%s", pag->bts->nr, VTY_NEWLINE);
1071 subscr_dump_vty(vty, pag->subscr);
1072}
1073
Harald Weltebe4b7302009-05-23 16:59:33 +00001074static void bts_paging_dump_vty(struct vty *vty, struct gsm_bts *bts)
Harald Weltef5025b62009-03-28 16:55:11 +00001075{
1076 struct gsm_paging_request *pag;
1077
1078 llist_for_each_entry(pag, &bts->paging.pending_requests, entry)
1079 paging_dump_vty(vty, pag);
1080}
1081
1082DEFUN(show_paging,
1083 show_paging_cmd,
1084 "show paging [bts_nr]",
Harald Welte8f0ed552010-05-11 21:53:49 +02001085 SHOW_STR "Display information about paging reuqests of a BTS\n"
1086 "BTS Number\n")
Harald Weltef5025b62009-03-28 16:55:11 +00001087{
Harald Weltedcccb182010-05-16 20:52:23 +02001088 struct gsm_network *net = gsmnet_from_vty(vty);
Harald Weltef5025b62009-03-28 16:55:11 +00001089 struct gsm_bts *bts;
1090 int bts_nr;
1091
1092 if (argc >= 1) {
1093 /* use the BTS number that the user has specified */
1094 bts_nr = atoi(argv[0]);
1095 if (bts_nr >= net->num_bts) {
1096 vty_out(vty, "%% can't find BTS %s%s", argv[0],
1097 VTY_NEWLINE);
1098 return CMD_WARNING;
1099 }
Harald Weltee441d9c2009-06-21 16:17:15 +02001100 bts = gsm_bts_num(net, bts_nr);
Harald Weltef5025b62009-03-28 16:55:11 +00001101 bts_paging_dump_vty(vty, bts);
1102
1103 return CMD_SUCCESS;
1104 }
1105 for (bts_nr = 0; bts_nr < net->num_bts; bts_nr++) {
Harald Weltee441d9c2009-06-21 16:17:15 +02001106 bts = gsm_bts_num(net, bts_nr);
Harald Weltef5025b62009-03-28 16:55:11 +00001107 bts_paging_dump_vty(vty, bts);
1108 }
1109
1110 return CMD_SUCCESS;
1111}
1112
Harald Welte8f0ed552010-05-11 21:53:49 +02001113#define NETWORK_STR "Configure the GSM network\n"
1114
Harald Welte5013b2a2009-08-07 13:29:14 +02001115DEFUN(cfg_net,
1116 cfg_net_cmd,
Harald Welte8f0ed552010-05-11 21:53:49 +02001117 "network", NETWORK_STR)
Harald Welte5013b2a2009-08-07 13:29:14 +02001118{
Harald Weltedcccb182010-05-16 20:52:23 +02001119 vty->index = gsmnet_from_vty(vty);
Harald Welte5013b2a2009-08-07 13:29:14 +02001120 vty->node = GSMNET_NODE;
1121
1122 return CMD_SUCCESS;
1123}
1124
1125
1126DEFUN(cfg_net_ncc,
1127 cfg_net_ncc_cmd,
1128 "network country code <1-999>",
1129 "Set the GSM network country code")
1130{
Harald Weltedcccb182010-05-16 20:52:23 +02001131 struct gsm_network *gsmnet = gsmnet_from_vty(vty);
1132
Harald Welte5013b2a2009-08-07 13:29:14 +02001133 gsmnet->country_code = atoi(argv[0]);
1134
1135 return CMD_SUCCESS;
1136}
1137
1138DEFUN(cfg_net_mnc,
1139 cfg_net_mnc_cmd,
1140 "mobile network code <1-999>",
1141 "Set the GSM mobile network code")
1142{
Harald Weltedcccb182010-05-16 20:52:23 +02001143 struct gsm_network *gsmnet = gsmnet_from_vty(vty);
1144
Harald Welte5013b2a2009-08-07 13:29:14 +02001145 gsmnet->network_code = atoi(argv[0]);
1146
1147 return CMD_SUCCESS;
1148}
1149
1150DEFUN(cfg_net_name_short,
1151 cfg_net_name_short_cmd,
1152 "short name NAME",
1153 "Set the short GSM network name")
1154{
Harald Weltedcccb182010-05-16 20:52:23 +02001155 struct gsm_network *gsmnet = gsmnet_from_vty(vty);
1156
Holger Hans Peter Freyther3e9a7f82010-10-12 23:21:54 +02001157 bsc_replace_string(gsmnet, &gsmnet->name_short, argv[0]);
Harald Welte5013b2a2009-08-07 13:29:14 +02001158 return CMD_SUCCESS;
1159}
1160
1161DEFUN(cfg_net_name_long,
1162 cfg_net_name_long_cmd,
1163 "long name NAME",
1164 "Set the long GSM network name")
1165{
Harald Weltedcccb182010-05-16 20:52:23 +02001166 struct gsm_network *gsmnet = gsmnet_from_vty(vty);
1167
Holger Hans Peter Freyther3e9a7f82010-10-12 23:21:54 +02001168 bsc_replace_string(gsmnet, &gsmnet->name_long, argv[0]);
Harald Welte5013b2a2009-08-07 13:29:14 +02001169 return CMD_SUCCESS;
1170}
Harald Welte40f82892009-05-23 17:31:39 +00001171
Harald Welte (local)69de3972009-08-12 14:42:23 +02001172DEFUN(cfg_net_auth_policy,
1173 cfg_net_auth_policy_cmd,
1174 "auth policy (closed|accept-all|token)",
Harald Welte8f0ed552010-05-11 21:53:49 +02001175 "Authentication (not cryptographic)\n"
1176 "Set the GSM network authentication policy\n"
1177 "Require the MS to be activated in HLR\n"
1178 "Accept all MS, whether in HLR or not\n"
1179 "Use SMS-token based authentication\n")
Harald Welte (local)69de3972009-08-12 14:42:23 +02001180{
1181 enum gsm_auth_policy policy = gsm_auth_policy_parse(argv[0]);
Harald Weltedcccb182010-05-16 20:52:23 +02001182 struct gsm_network *gsmnet = gsmnet_from_vty(vty);
Harald Welte (local)69de3972009-08-12 14:42:23 +02001183
1184 gsmnet->auth_policy = policy;
1185
1186 return CMD_SUCCESS;
1187}
1188
Harald Welte1085c092009-11-18 20:33:19 +01001189DEFUN(cfg_net_reject_cause,
1190 cfg_net_reject_cause_cmd,
1191 "location updating reject cause <2-111>",
1192 "Set the reject cause of location updating reject\n")
1193{
Harald Weltedcccb182010-05-16 20:52:23 +02001194 struct gsm_network *gsmnet = gsmnet_from_vty(vty);
1195
Harald Welte1085c092009-11-18 20:33:19 +01001196 gsmnet->reject_cause = atoi(argv[0]);
1197
1198 return CMD_SUCCESS;
1199}
1200
Harald Welte4381cfe2009-08-30 15:47:06 +09001201DEFUN(cfg_net_encryption,
1202 cfg_net_encryption_cmd,
1203 "encryption a5 (0|1|2)",
Harald Welte28326062010-05-14 20:05:17 +02001204 "Encryption options\n"
1205 "A5 encryption\n" "A5/0: No encryption\n"
1206 "A5/1: Encryption\n" "A5/2: Export-grade Encryption\n")
Harald Welte4381cfe2009-08-30 15:47:06 +09001207{
Harald Weltedcccb182010-05-16 20:52:23 +02001208 struct gsm_network *gsmnet = gsmnet_from_vty(vty);
1209
Andreas.Eversberg1059deb2009-11-17 09:55:26 +01001210 gsmnet->a5_encryption= atoi(argv[0]);
Harald Welte4381cfe2009-08-30 15:47:06 +09001211
1212 return CMD_SUCCESS;
1213}
1214
Holger Hans Peter Freytherf7d752f2009-11-16 17:12:38 +01001215DEFUN(cfg_net_neci,
1216 cfg_net_neci_cmd,
1217 "neci (0|1)",
Harald Welte28326062010-05-14 20:05:17 +02001218 "New Establish Cause Indication\n"
1219 "Don't set the NECI bit\n" "Set the NECI bit\n")
Holger Hans Peter Freytherf7d752f2009-11-16 17:12:38 +01001220{
Harald Weltedcccb182010-05-16 20:52:23 +02001221 struct gsm_network *gsmnet = gsmnet_from_vty(vty);
1222
Holger Hans Peter Freytherf7d752f2009-11-16 17:12:38 +01001223 gsmnet->neci = atoi(argv[0]);
Holger Hans Peter Freyther78891072010-09-06 09:36:02 +08001224 gsm_net_update_ctype(gsmnet);
Holger Hans Peter Freytherf7d752f2009-11-16 17:12:38 +01001225 return CMD_SUCCESS;
1226}
1227
Harald Welteeab84a12009-12-13 10:53:12 +01001228DEFUN(cfg_net_rrlp_mode, cfg_net_rrlp_mode_cmd,
1229 "rrlp mode (none|ms-based|ms-preferred|ass-preferred)",
Harald Welte8f0ed552010-05-11 21:53:49 +02001230 "Radio Resource Location Protocol\n"
1231 "Set the Radio Resource Location Protocol Mode\n"
1232 "Don't send RRLP request\n"
1233 "Request MS-based location\n"
1234 "Request any location, prefer MS-based\n"
1235 "Request any location, prefer MS-assisted\n")
Harald Welteeab84a12009-12-13 10:53:12 +01001236{
Harald Weltedcccb182010-05-16 20:52:23 +02001237 struct gsm_network *gsmnet = gsmnet_from_vty(vty);
1238
Harald Welteeab84a12009-12-13 10:53:12 +01001239 gsmnet->rrlp.mode = rrlp_mode_parse(argv[0]);
1240
1241 return CMD_SUCCESS;
1242}
1243
Harald Welte648b6ce2009-12-14 09:00:24 +01001244DEFUN(cfg_net_mm_info, cfg_net_mm_info_cmd,
1245 "mm info (0|1)",
1246 "Whether to send MM INFO after LOC UPD ACCEPT")
1247{
Harald Weltedcccb182010-05-16 20:52:23 +02001248 struct gsm_network *gsmnet = gsmnet_from_vty(vty);
1249
Harald Welte648b6ce2009-12-14 09:00:24 +01001250 gsmnet->send_mm_info = atoi(argv[0]);
1251
1252 return CMD_SUCCESS;
1253}
1254
Harald Welte8f0ed552010-05-11 21:53:49 +02001255#define HANDOVER_STR "Handover Options\n"
1256
Harald Weltebc814502009-12-19 21:41:52 +01001257DEFUN(cfg_net_handover, cfg_net_handover_cmd,
1258 "handover (0|1)",
Harald Welte8f0ed552010-05-11 21:53:49 +02001259 HANDOVER_STR
1260 "Don't perform in-call handover\n"
1261 "Perform in-call handover\n")
Harald Weltebc814502009-12-19 21:41:52 +01001262{
Holger Hans Peter Freythercbcfe242010-01-07 16:14:38 +01001263 int enable = atoi(argv[0]);
Harald Weltedcccb182010-05-16 20:52:23 +02001264 struct gsm_network *gsmnet = gsmnet_from_vty(vty);
Holger Hans Peter Freythercbcfe242010-01-07 16:14:38 +01001265
1266 if (enable && ipacc_rtp_direct) {
Harald Weltefe03f0d2009-12-20 13:51:01 +01001267 vty_out(vty, "%% Cannot enable handover unless RTP Proxy mode "
1268 "is enabled by using the -P command line option%s",
1269 VTY_NEWLINE);
1270 return CMD_WARNING;
1271 }
Holger Hans Peter Freythercbcfe242010-01-07 16:14:38 +01001272 gsmnet->handover.active = enable;
Harald Weltebc814502009-12-19 21:41:52 +01001273
1274 return CMD_SUCCESS;
1275}
1276
Harald Welte8f0ed552010-05-11 21:53:49 +02001277#define HO_WIN_STR HANDOVER_STR "Measurement Window\n"
1278#define HO_WIN_RXLEV_STR HO_WIN_STR "Received Level Averaging\n"
1279#define HO_WIN_RXQUAL_STR HO_WIN_STR "Received Quality Averaging\n"
1280#define HO_PBUDGET_STR HANDOVER_STR "Power Budget\n"
1281
Harald Welteb720bd32009-12-21 16:51:50 +01001282DEFUN(cfg_net_ho_win_rxlev_avg, cfg_net_ho_win_rxlev_avg_cmd,
1283 "handover window rxlev averaging <1-10>",
Harald Welte8f0ed552010-05-11 21:53:49 +02001284 HO_WIN_RXLEV_STR
Harald Welteb720bd32009-12-21 16:51:50 +01001285 "How many RxLev measurements are used for averaging")
1286{
Harald Weltedcccb182010-05-16 20:52:23 +02001287 struct gsm_network *gsmnet = gsmnet_from_vty(vty);
Harald Welteb720bd32009-12-21 16:51:50 +01001288 gsmnet->handover.win_rxlev_avg = atoi(argv[0]);
1289 return CMD_SUCCESS;
1290}
1291
1292DEFUN(cfg_net_ho_win_rxqual_avg, cfg_net_ho_win_rxqual_avg_cmd,
1293 "handover window rxqual averaging <1-10>",
Harald Welte8f0ed552010-05-11 21:53:49 +02001294 HO_WIN_RXQUAL_STR
Harald Welteb720bd32009-12-21 16:51:50 +01001295 "How many RxQual measurements are used for averaging")
1296{
Harald Weltedcccb182010-05-16 20:52:23 +02001297 struct gsm_network *gsmnet = gsmnet_from_vty(vty);
Harald Welteb720bd32009-12-21 16:51:50 +01001298 gsmnet->handover.win_rxqual_avg = atoi(argv[0]);
1299 return CMD_SUCCESS;
1300}
1301
1302DEFUN(cfg_net_ho_win_rxlev_neigh_avg, cfg_net_ho_win_rxlev_avg_neigh_cmd,
1303 "handover window rxlev neighbor averaging <1-10>",
Harald Welte8f0ed552010-05-11 21:53:49 +02001304 HO_WIN_RXLEV_STR
Harald Welteb720bd32009-12-21 16:51:50 +01001305 "How many RxQual measurements are used for averaging")
1306{
Harald Weltedcccb182010-05-16 20:52:23 +02001307 struct gsm_network *gsmnet = gsmnet_from_vty(vty);
Harald Welteb720bd32009-12-21 16:51:50 +01001308 gsmnet->handover.win_rxlev_avg_neigh = atoi(argv[0]);
1309 return CMD_SUCCESS;
1310}
1311
1312DEFUN(cfg_net_ho_pwr_interval, cfg_net_ho_pwr_interval_cmd,
1313 "handover power budget interval <1-99>",
Harald Welte8f0ed552010-05-11 21:53:49 +02001314 HO_PBUDGET_STR
Harald Welteb720bd32009-12-21 16:51:50 +01001315 "How often to check if we have a better cell (SACCH frames)")
1316{
Harald Weltedcccb182010-05-16 20:52:23 +02001317 struct gsm_network *gsmnet = gsmnet_from_vty(vty);
Harald Welteb720bd32009-12-21 16:51:50 +01001318 gsmnet->handover.pwr_interval = atoi(argv[0]);
1319 return CMD_SUCCESS;
1320}
1321
1322DEFUN(cfg_net_ho_pwr_hysteresis, cfg_net_ho_pwr_hysteresis_cmd,
1323 "handover power budget hysteresis <0-999>",
Harald Welte8f0ed552010-05-11 21:53:49 +02001324 HO_PBUDGET_STR
Harald Welteb720bd32009-12-21 16:51:50 +01001325 "How many dB does a neighbor to be stronger to become a HO candidate")
1326{
Harald Weltedcccb182010-05-16 20:52:23 +02001327 struct gsm_network *gsmnet = gsmnet_from_vty(vty);
Harald Welteb720bd32009-12-21 16:51:50 +01001328 gsmnet->handover.pwr_hysteresis = atoi(argv[0]);
1329 return CMD_SUCCESS;
1330}
1331
1332DEFUN(cfg_net_ho_max_distance, cfg_net_ho_max_distance_cmd,
1333 "handover maximum distance <0-9999>",
Harald Welte8f0ed552010-05-11 21:53:49 +02001334 HANDOVER_STR
Harald Welteb720bd32009-12-21 16:51:50 +01001335 "How big is the maximum timing advance before HO is forced")
1336{
Harald Weltedcccb182010-05-16 20:52:23 +02001337 struct gsm_network *gsmnet = gsmnet_from_vty(vty);
Harald Welteb720bd32009-12-21 16:51:50 +01001338 gsmnet->handover.max_distance = atoi(argv[0]);
1339 return CMD_SUCCESS;
1340}
Harald Weltebc814502009-12-19 21:41:52 +01001341
Holger Hans Peter Freyther76fc4a32010-09-06 09:41:50 +08001342DEFUN(cfg_net_pag_any_tch,
1343 cfg_net_pag_any_tch_cmd,
1344 "paging any use tch (0|1)",
1345 "Assign a TCH when receiving a Paging Any request")
1346{
Holger Hans Peter Freytherb0e88b82010-09-06 10:09:19 +08001347 struct gsm_network *gsmnet = gsmnet_from_vty(vty);
Holger Hans Peter Freyther76fc4a32010-09-06 09:41:50 +08001348 gsmnet->pag_any_tch = atoi(argv[0]);
1349 gsm_net_update_ctype(gsmnet);
1350 return CMD_SUCCESS;
1351}
1352
Holger Hans Peter Freytherc8021062009-12-22 08:27:21 +01001353#define DECLARE_TIMER(number, doc) \
Holger Hans Peter Freytherc4d88ad2009-11-21 21:18:38 +01001354 DEFUN(cfg_net_T##number, \
1355 cfg_net_T##number##_cmd, \
1356 "timer t" #number " <0-65535>", \
Harald Welte8f0ed552010-05-11 21:53:49 +02001357 "Configure GSM Timers\n" \
Holger Hans Peter Freytherc8021062009-12-22 08:27:21 +01001358 doc) \
Holger Hans Peter Freytherc4d88ad2009-11-21 21:18:38 +01001359{ \
Harald Weltedcccb182010-05-16 20:52:23 +02001360 struct gsm_network *gsmnet = gsmnet_from_vty(vty); \
Holger Hans Peter Freytherc4d88ad2009-11-21 21:18:38 +01001361 int value = atoi(argv[0]); \
1362 \
1363 if (value < 0 || value > 65535) { \
1364 vty_out(vty, "Timer value %s out of range.%s", \
1365 argv[0], VTY_NEWLINE); \
1366 return CMD_WARNING; \
1367 } \
1368 \
1369 gsmnet->T##number = value; \
1370 return CMD_SUCCESS; \
1371}
1372
Holger Hans Peter Freytherc8021062009-12-22 08:27:21 +01001373DECLARE_TIMER(3101, "Set the timeout value for IMMEDIATE ASSIGNMENT.")
1374DECLARE_TIMER(3103, "Set the timeout value for HANDOVER.")
1375DECLARE_TIMER(3105, "Currently not used.")
1376DECLARE_TIMER(3107, "Currently not used.")
1377DECLARE_TIMER(3109, "Currently not used.")
Holger Hans Peter Freytherf30c0dc2010-05-31 21:33:15 +08001378DECLARE_TIMER(3111, "Set the RSL timeout to wait before releasing the RF Channel.")
Holger Hans Peter Freytherc8021062009-12-22 08:27:21 +01001379DECLARE_TIMER(3113, "Set the time to try paging a subscriber.")
1380DECLARE_TIMER(3115, "Currently not used.")
1381DECLARE_TIMER(3117, "Currently not used.")
1382DECLARE_TIMER(3119, "Currently not used.")
Harald Welte2862dca2010-12-23 14:39:29 +01001383DECLARE_TIMER(3122, "Waiting time (seconds) after IMM ASS REJECT")
Holger Hans Peter Freytherc8021062009-12-22 08:27:21 +01001384DECLARE_TIMER(3141, "Currently not used.")
Holger Hans Peter Freytherc4d88ad2009-11-21 21:18:38 +01001385
Holger Hans Peter Freyther5a3a61d2010-09-06 09:25:48 +08001386DEFUN(cfg_net_dtx,
1387 cfg_net_dtx_cmd,
1388 "dtx-used (0|1)",
1389 "Enable the usage of DTX.\n"
1390 "DTX is enabled/disabled")
1391{
1392 struct gsm_network *gsmnet = gsmnet_from_vty(vty);
1393 gsmnet->dtx_enabled = atoi(argv[0]);
1394 return CMD_SUCCESS;
1395}
Holger Hans Peter Freytherc4d88ad2009-11-21 21:18:38 +01001396
Holger Hans Peter Freytherae9006a2010-12-22 16:26:04 +01001397DEFUN(cfg_net_subscr_keep,
1398 cfg_net_subscr_keep_cmd,
1399 "subscriber-keep-in-ram (0|1)",
1400 "Keep unused subscribers in RAM.\n"
1401 "Delete unused subscribers\n" "Keep unused subscribers\n")
1402{
1403 struct gsm_network *gsmnet = gsmnet_from_vty(vty);
1404 gsmnet->keep_subscr = atoi(argv[0]);
1405 return CMD_SUCCESS;
1406}
1407
Harald Welte5258fc42009-03-28 19:07:53 +00001408/* per-BTS configuration */
1409DEFUN(cfg_bts,
1410 cfg_bts_cmd,
1411 "bts BTS_NR",
Harald Welte8f0ed552010-05-11 21:53:49 +02001412 "Select a BTS to configure\n"
1413 "BTS Number\n")
Harald Welte5258fc42009-03-28 19:07:53 +00001414{
Harald Weltedcccb182010-05-16 20:52:23 +02001415 struct gsm_network *gsmnet = gsmnet_from_vty(vty);
Harald Welte5258fc42009-03-28 19:07:53 +00001416 int bts_nr = atoi(argv[0]);
1417 struct gsm_bts *bts;
1418
Harald Weltee441d9c2009-06-21 16:17:15 +02001419 if (bts_nr > gsmnet->num_bts) {
1420 vty_out(vty, "%% The next unused BTS number is %u%s",
1421 gsmnet->num_bts, VTY_NEWLINE);
Harald Welte5258fc42009-03-28 19:07:53 +00001422 return CMD_WARNING;
Harald Weltee441d9c2009-06-21 16:17:15 +02001423 } else if (bts_nr == gsmnet->num_bts) {
1424 /* allocate a new one */
1425 bts = gsm_bts_alloc(gsmnet, GSM_BTS_TYPE_UNKNOWN,
1426 HARDCODED_TSC, HARDCODED_BSIC);
Holger Hans Peter Freytheracf8a0c2010-03-29 08:47:44 +02001427 } else
Harald Weltee441d9c2009-06-21 16:17:15 +02001428 bts = gsm_bts_num(gsmnet, bts_nr);
1429
Daniel Willmannf15c2762010-01-11 13:43:07 +01001430 if (!bts) {
1431 vty_out(vty, "%% Unable to allocate BTS %u%s",
1432 gsmnet->num_bts, VTY_NEWLINE);
Harald Weltee441d9c2009-06-21 16:17:15 +02001433 return CMD_WARNING;
Daniel Willmannf15c2762010-01-11 13:43:07 +01001434 }
Harald Welte5258fc42009-03-28 19:07:53 +00001435
1436 vty->index = bts;
Harald Welte197dea92010-05-14 17:59:53 +02001437 vty->index_sub = &bts->description;
Harald Welte5258fc42009-03-28 19:07:53 +00001438 vty->node = BTS_NODE;
1439
1440 return CMD_SUCCESS;
1441}
1442
1443DEFUN(cfg_bts_type,
1444 cfg_bts_type_cmd,
1445 "type TYPE",
1446 "Set the BTS type\n")
1447{
1448 struct gsm_bts *bts = vty->index;
Harald Welte39315c42010-01-10 18:01:52 +01001449 int rc;
Harald Welte5258fc42009-03-28 19:07:53 +00001450
Harald Welte39315c42010-01-10 18:01:52 +01001451 rc = gsm_set_bts_type(bts, parse_btstype(argv[0]));
1452 if (rc < 0)
1453 return CMD_WARNING;
Harald Welte8175e952009-10-20 00:22:00 +02001454
Harald Welte5258fc42009-03-28 19:07:53 +00001455 return CMD_SUCCESS;
1456}
1457
Harald Weltefcd24452009-06-20 18:15:19 +02001458DEFUN(cfg_bts_band,
1459 cfg_bts_band_cmd,
1460 "band BAND",
1461 "Set the frequency band of this BTS\n")
1462{
1463 struct gsm_bts *bts = vty->index;
Harald Welte42581822009-08-08 16:12:58 +02001464 int band = gsm_band_parse(argv[0]);
Harald Weltefcd24452009-06-20 18:15:19 +02001465
1466 if (band < 0) {
1467 vty_out(vty, "%% BAND %d is not a valid GSM band%s",
1468 band, VTY_NEWLINE);
1469 return CMD_WARNING;
1470 }
1471
1472 bts->band = band;
1473
1474 return CMD_SUCCESS;
1475}
1476
Holger Hans Peter Freytherc4a49e32009-08-21 14:44:12 +02001477DEFUN(cfg_bts_ci,
1478 cfg_bts_ci_cmd,
1479 "cell_identity <0-65535>",
1480 "Set the Cell identity of this BTS\n")
1481{
1482 struct gsm_bts *bts = vty->index;
1483 int ci = atoi(argv[0]);
1484
1485 if (ci < 0 || ci > 0xffff) {
1486 vty_out(vty, "%% CI %d is not in the valid range (0-65535)%s",
1487 ci, VTY_NEWLINE);
1488 return CMD_WARNING;
1489 }
1490 bts->cell_identity = ci;
1491
1492 return CMD_SUCCESS;
1493}
1494
Harald Welte5258fc42009-03-28 19:07:53 +00001495DEFUN(cfg_bts_lac,
1496 cfg_bts_lac_cmd,
Holger Hans Peter Freyther0b7f4b32009-09-29 14:02:33 +02001497 "location_area_code <0-65535>",
Harald Welte5258fc42009-03-28 19:07:53 +00001498 "Set the Location Area Code (LAC) of this BTS\n")
1499{
1500 struct gsm_bts *bts = vty->index;
1501 int lac = atoi(argv[0]);
1502
Holger Hans Peter Freyther0b7f4b32009-09-29 14:02:33 +02001503 if (lac < 0 || lac > 0xffff) {
1504 vty_out(vty, "%% LAC %d is not in the valid range (0-65535)%s",
Harald Welte5258fc42009-03-28 19:07:53 +00001505 lac, VTY_NEWLINE);
1506 return CMD_WARNING;
1507 }
Holger Hans Peter Freythere48b9562009-10-01 04:07:15 +02001508
1509 if (lac == GSM_LAC_RESERVED_DETACHED || lac == GSM_LAC_RESERVED_ALL_BTS) {
1510 vty_out(vty, "%% LAC %d is reserved by GSM 04.08%s",
1511 lac, VTY_NEWLINE);
1512 return CMD_WARNING;
1513 }
1514
Harald Welte5258fc42009-03-28 19:07:53 +00001515 bts->location_area_code = lac;
1516
1517 return CMD_SUCCESS;
1518}
1519
Harald Weltea43f7892009-12-01 18:04:30 +05301520
Harald Welte5258fc42009-03-28 19:07:53 +00001521DEFUN(cfg_bts_tsc,
1522 cfg_bts_tsc_cmd,
1523 "training_sequence_code <0-255>",
1524 "Set the Training Sequence Code (TSC) of this BTS\n")
1525{
1526 struct gsm_bts *bts = vty->index;
1527 int tsc = atoi(argv[0]);
1528
1529 if (tsc < 0 || tsc > 0xff) {
1530 vty_out(vty, "%% TSC %d is not in the valid range (0-255)%s",
1531 tsc, VTY_NEWLINE);
1532 return CMD_WARNING;
1533 }
1534 bts->tsc = tsc;
1535
1536 return CMD_SUCCESS;
1537}
1538
Harald Welte78f2f502009-05-23 16:56:52 +00001539DEFUN(cfg_bts_bsic,
1540 cfg_bts_bsic_cmd,
1541 "base_station_id_code <0-63>",
1542 "Set the Base Station Identity Code (BSIC) of this BTS\n")
1543{
1544 struct gsm_bts *bts = vty->index;
1545 int bsic = atoi(argv[0]);
1546
1547 if (bsic < 0 || bsic > 0x3f) {
Harald Welte42581822009-08-08 16:12:58 +02001548 vty_out(vty, "%% BSIC %d is not in the valid range (0-255)%s",
Harald Welte78f2f502009-05-23 16:56:52 +00001549 bsic, VTY_NEWLINE);
1550 return CMD_WARNING;
1551 }
1552 bts->bsic = bsic;
1553
1554 return CMD_SUCCESS;
1555}
1556
1557
Harald Welte4cc34222009-05-01 15:12:31 +00001558DEFUN(cfg_bts_unit_id,
1559 cfg_bts_unit_id_cmd,
Harald Welte07dc73d2009-08-07 13:27:09 +02001560 "ip.access unit_id <0-65534> <0-255>",
1561 "Set the ip.access BTS Unit ID of this BTS\n")
Harald Welte4cc34222009-05-01 15:12:31 +00001562{
1563 struct gsm_bts *bts = vty->index;
1564 int site_id = atoi(argv[0]);
1565 int bts_id = atoi(argv[1]);
1566
Harald Welte07dc73d2009-08-07 13:27:09 +02001567 if (!is_ipaccess_bts(bts)) {
1568 vty_out(vty, "%% BTS is not of ip.access type%s", VTY_NEWLINE);
1569 return CMD_WARNING;
1570 }
1571
Harald Welte4cc34222009-05-01 15:12:31 +00001572 bts->ip_access.site_id = site_id;
1573 bts->ip_access.bts_id = bts_id;
1574
1575 return CMD_SUCCESS;
1576}
1577
Harald Welte8f0ed552010-05-11 21:53:49 +02001578#define OML_STR "Organization & Maintenance Link\n"
1579#define IPA_STR "ip.access Specific Options\n"
1580
Harald Welte8175e952009-10-20 00:22:00 +02001581DEFUN(cfg_bts_stream_id,
1582 cfg_bts_stream_id_cmd,
1583 "oml ip.access stream_id <0-255>",
Harald Welte8f0ed552010-05-11 21:53:49 +02001584 OML_STR IPA_STR
Harald Welte8175e952009-10-20 00:22:00 +02001585 "Set the ip.access Stream ID of the OML link of this BTS\n")
1586{
1587 struct gsm_bts *bts = vty->index;
1588 int stream_id = atoi(argv[0]);
1589
1590 if (!is_ipaccess_bts(bts)) {
1591 vty_out(vty, "%% BTS is not of ip.access type%s", VTY_NEWLINE);
1592 return CMD_WARNING;
1593 }
1594
1595 bts->oml_tei = stream_id;
1596
1597 return CMD_SUCCESS;
1598}
1599
Harald Welte8f0ed552010-05-11 21:53:49 +02001600#define OML_E1_STR OML_STR "E1 Line\n"
Harald Welte8175e952009-10-20 00:22:00 +02001601
Harald Welte42581822009-08-08 16:12:58 +02001602DEFUN(cfg_bts_oml_e1,
1603 cfg_bts_oml_e1_cmd,
1604 "oml e1 line E1_LINE timeslot <1-31> sub-slot (0|1|2|3|full)",
Harald Welte8f0ed552010-05-11 21:53:49 +02001605 OML_E1_STR
Harald Welte42581822009-08-08 16:12:58 +02001606 "E1 interface to be used for OML\n")
1607{
1608 struct gsm_bts *bts = vty->index;
1609
1610 parse_e1_link(&bts->oml_e1_link, argv[0], argv[1], argv[2]);
1611
1612 return CMD_SUCCESS;
1613}
1614
1615
1616DEFUN(cfg_bts_oml_e1_tei,
1617 cfg_bts_oml_e1_tei_cmd,
1618 "oml e1 tei <0-63>",
Harald Welte8f0ed552010-05-11 21:53:49 +02001619 OML_E1_STR
Harald Welte42581822009-08-08 16:12:58 +02001620 "Set the TEI to be used for OML")
1621{
1622 struct gsm_bts *bts = vty->index;
1623
1624 bts->oml_tei = atoi(argv[0]);
1625
1626 return CMD_SUCCESS;
1627}
1628
Harald Welte7a8fa412009-08-10 13:48:16 +02001629DEFUN(cfg_bts_challoc, cfg_bts_challoc_cmd,
1630 "channel allocator (ascending|descending)",
Harald Welte8f0ed552010-05-11 21:53:49 +02001631 "Channnel Allocator\n" "Channel Allocator\n"
1632 "Allocate Timeslots and Transceivers in ascending order\n"
1633 "Allocate Timeslots and Transceivers in descending order\n")
Harald Welte7a8fa412009-08-10 13:48:16 +02001634{
1635 struct gsm_bts *bts = vty->index;
1636
1637 if (!strcmp(argv[0], "ascending"))
1638 bts->chan_alloc_reverse = 0;
1639 else
1640 bts->chan_alloc_reverse = 1;
1641
1642 return CMD_SUCCESS;
1643}
1644
Harald Welte8f0ed552010-05-11 21:53:49 +02001645#define RACH_STR "Random Access Control Channel\n"
1646
Sylvain Munaut4010f1e2009-12-22 13:43:26 +01001647DEFUN(cfg_bts_rach_tx_integer,
1648 cfg_bts_rach_tx_integer_cmd,
1649 "rach tx integer <0-15>",
Harald Welte8f0ed552010-05-11 21:53:49 +02001650 RACH_STR
Sylvain Munaut4010f1e2009-12-22 13:43:26 +01001651 "Set the raw tx integer value in RACH Control parameters IE")
1652{
1653 struct gsm_bts *bts = vty->index;
1654 bts->si_common.rach_control.tx_integer = atoi(argv[0]) & 0xf;
1655 return CMD_SUCCESS;
1656}
1657
1658DEFUN(cfg_bts_rach_max_trans,
1659 cfg_bts_rach_max_trans_cmd,
1660 "rach max transmission (1|2|4|7)",
Harald Welte8f0ed552010-05-11 21:53:49 +02001661 RACH_STR
Sylvain Munaut4010f1e2009-12-22 13:43:26 +01001662 "Set the maximum number of RACH burst transmissions")
1663{
1664 struct gsm_bts *bts = vty->index;
1665 bts->si_common.rach_control.max_trans = rach_max_trans_val2raw(atoi(argv[0]));
1666 return CMD_SUCCESS;
1667}
1668
Harald Welte8f0ed552010-05-11 21:53:49 +02001669#define NM_STR "Network Management\n"
1670
Holger Hans Peter Freyther95c22902010-04-25 23:08:39 +08001671DEFUN(cfg_bts_rach_nm_b_thresh,
1672 cfg_bts_rach_nm_b_thresh_cmd,
1673 "rach nm busy threshold <0-255>",
Harald Welte8f0ed552010-05-11 21:53:49 +02001674 RACH_STR NM_STR
1675 "Set the NM Busy Threshold in dB")
Holger Hans Peter Freyther95c22902010-04-25 23:08:39 +08001676{
1677 struct gsm_bts *bts = vty->index;
1678 bts->rach_b_thresh = atoi(argv[0]);
1679 return CMD_SUCCESS;
1680}
1681
1682DEFUN(cfg_bts_rach_nm_ldavg,
1683 cfg_bts_rach_nm_ldavg_cmd,
1684 "rach nm load average <0-65535>",
Harald Welte8f0ed552010-05-11 21:53:49 +02001685 RACH_STR NM_STR
1686 "Set the NM Loadaverage Slots value")
Holger Hans Peter Freyther95c22902010-04-25 23:08:39 +08001687{
1688 struct gsm_bts *bts = vty->index;
1689 bts->rach_ldavg_slots = atoi(argv[0]);
1690 return CMD_SUCCESS;
1691}
1692
Harald Welte (local)5dececf2009-08-12 13:28:23 +02001693DEFUN(cfg_bts_cell_barred, cfg_bts_cell_barred_cmd,
1694 "cell barred (0|1)",
1695 "Should this cell be barred from access?")
1696{
1697 struct gsm_bts *bts = vty->index;
1698
Harald Welte71355012009-12-21 23:08:18 +01001699 bts->si_common.rach_control.cell_bar = atoi(argv[0]);
Harald Welte (local)5dececf2009-08-12 13:28:23 +02001700
1701 return CMD_SUCCESS;
1702}
1703
Holger Hans Peter Freyther3a0a4632010-05-14 00:39:19 +08001704DEFUN(cfg_bts_rach_ec_allowed, cfg_bts_rach_ec_allowed_cmd,
1705 "rach emergency call allowed (0|1)",
1706 "Should this cell allow emergency calls?")
1707{
1708 struct gsm_bts *bts = vty->index;
1709
1710 if (atoi(argv[0]) == 0)
1711 bts->si_common.rach_control.t2 |= 0x4;
1712 else
1713 bts->si_common.rach_control.t2 &= ~0x4;
1714
1715 return CMD_SUCCESS;
1716}
1717
Harald Welte (local)0e451d02009-08-13 10:14:26 +02001718DEFUN(cfg_bts_ms_max_power, cfg_bts_ms_max_power_cmd,
1719 "ms max power <0-40>",
1720 "Maximum transmit power of the MS")
1721{
1722 struct gsm_bts *bts = vty->index;
1723
1724 bts->ms_max_power = atoi(argv[0]);
1725
1726 return CMD_SUCCESS;
1727}
1728
Harald Welte73225282009-12-12 18:17:25 +01001729DEFUN(cfg_bts_cell_resel_hyst, cfg_bts_cell_resel_hyst_cmd,
1730 "cell reselection hysteresis <0-14>",
1731 "Cell Re-Selection Hysteresis in dB")
1732{
1733 struct gsm_bts *bts = vty->index;
1734
1735 bts->si_common.cell_sel_par.cell_resel_hyst = atoi(argv[0])/2;
1736
1737 return CMD_SUCCESS;
1738}
1739
1740DEFUN(cfg_bts_rxlev_acc_min, cfg_bts_rxlev_acc_min_cmd,
1741 "rxlev access min <0-63>",
1742 "Minimum RxLev needed for cell access (better than -110dBm)")
1743{
1744 struct gsm_bts *bts = vty->index;
1745
1746 bts->si_common.cell_sel_par.rxlev_acc_min = atoi(argv[0]);
1747
1748 return CMD_SUCCESS;
1749}
1750
Sylvain Munaute0b06b02010-11-28 18:17:28 +01001751DEFUN(cfg_bts_cell_bar_qualify, cfg_bts_cell_bar_qualify_cmd,
1752 "cell bar qualify (0|1)",
1753 "Cell Bar Qualify")
1754{
1755 struct gsm_bts *bts = vty->index;
1756
1757 bts->si_common.cell_ro_sel_par.present = 1;
1758 bts->si_common.cell_ro_sel_par.cbq = atoi(argv[0]);
1759
1760 return CMD_SUCCESS;
1761}
1762
1763DEFUN(cfg_bts_cell_resel_ofs, cfg_bts_cell_resel_ofs_cmd,
1764 "cell reselection offset <0-126>",
1765 "Cell Re-Selection Offset in dB")
1766{
1767 struct gsm_bts *bts = vty->index;
1768
1769 bts->si_common.cell_ro_sel_par.present = 1;
1770 bts->si_common.cell_ro_sel_par.cell_resel_off = atoi(argv[0])/2;
1771
1772 return CMD_SUCCESS;
1773}
1774
1775DEFUN(cfg_bts_temp_ofs, cfg_bts_temp_ofs_cmd,
1776 "temporary offset <0-60>",
1777 "Cell selection temporary negative offset in dB")
1778{
1779 struct gsm_bts *bts = vty->index;
1780
1781 bts->si_common.cell_ro_sel_par.present = 1;
1782 bts->si_common.cell_ro_sel_par.temp_offs = atoi(argv[0])/10;
1783
1784 return CMD_SUCCESS;
1785}
1786
1787DEFUN(cfg_bts_temp_ofs_inf, cfg_bts_temp_ofs_inf_cmd,
1788 "temporary offset infinite",
1789 "Sets cell selection temporary negative offset to infinity")
1790{
1791 struct gsm_bts *bts = vty->index;
1792
1793 bts->si_common.cell_ro_sel_par.present = 1;
1794 bts->si_common.cell_ro_sel_par.temp_offs = 7;
1795
1796 return CMD_SUCCESS;
1797}
1798
1799DEFUN(cfg_bts_penalty_time, cfg_bts_penalty_time_cmd,
1800 "penalty time <20-620>",
1801 "Cell selection penalty time in seconds (by 20s increments)")
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 = (atoi(argv[0])-20)/20;
1807
1808 return CMD_SUCCESS;
1809}
1810
1811DEFUN(cfg_bts_penalty_time_rsvd, cfg_bts_penalty_time_rsvd_cmd,
1812 "penalty time reserved",
1813 "Set cell selection penalty time to reserved value 31\n"
1814 "(indicate that CELL_RESELECT_OFFSET is subtracted from C2 "
1815 "and TEMPORARY_OFFSET is ignored)")
1816{
1817 struct gsm_bts *bts = vty->index;
1818
1819 bts->si_common.cell_ro_sel_par.present = 1;
1820 bts->si_common.cell_ro_sel_par.penalty_time = 31;
1821
1822 return CMD_SUCCESS;
1823}
1824
Harald Welte (local)efc92312009-08-14 23:09:25 +02001825DEFUN(cfg_bts_per_loc_upd, cfg_bts_per_loc_upd_cmd,
1826 "periodic location update <0-1530>",
1827 "Periodic Location Updating Interval in Minutes")
1828{
1829 struct gsm_bts *bts = vty->index;
1830
Dieter Spaard6613e02010-10-05 21:10:55 +02001831 bts->si_common.chan_desc.t3212 = atoi(argv[0]) / 6;
Harald Welte (local)efc92312009-08-14 23:09:25 +02001832
1833 return CMD_SUCCESS;
1834}
1835
Harald Welte8f0ed552010-05-11 21:53:49 +02001836#define GPRS_TEXT "GPRS Packet Network\n"
1837
Harald Welteaf387632010-03-14 23:30:30 +08001838DEFUN(cfg_bts_prs_bvci, cfg_bts_gprs_bvci_cmd,
Harald Welte57ba7e32010-04-18 14:00:26 +02001839 "gprs cell bvci <2-65535>",
Harald Welte8f0ed552010-05-11 21:53:49 +02001840 GPRS_TEXT
1841 "GPRS Cell Settings\n"
Harald Welte97a282b2010-03-14 15:37:43 +08001842 "GPRS BSSGP VC Identifier")
1843{
1844 struct gsm_bts *bts = vty->index;
1845
Harald Welte4511d892010-04-18 15:51:20 +02001846 if (bts->gprs.mode == BTS_GPRS_NONE) {
Harald Welte94036702010-03-14 23:56:56 +08001847 vty_out(vty, "%% GPRS not enabled on this BTS%s", VTY_NEWLINE);
1848 return CMD_WARNING;
1849 }
1850
Harald Welte97a282b2010-03-14 15:37:43 +08001851 bts->gprs.cell.bvci = atoi(argv[0]);
1852
1853 return CMD_SUCCESS;
1854}
1855
Harald Weltea5731cf2010-03-22 11:48:36 +08001856DEFUN(cfg_bts_gprs_nsei, cfg_bts_gprs_nsei_cmd,
1857 "gprs nsei <0-65535>",
Harald Welte8f0ed552010-05-11 21:53:49 +02001858 GPRS_TEXT
Harald Weltea5731cf2010-03-22 11:48:36 +08001859 "GPRS NS Entity Identifier")
1860{
1861 struct gsm_bts *bts = vty->index;
1862
Harald Welte4511d892010-04-18 15:51:20 +02001863 if (bts->gprs.mode == BTS_GPRS_NONE) {
Harald Weltea5731cf2010-03-22 11:48:36 +08001864 vty_out(vty, "%% GPRS not enabled on this BTS%s", VTY_NEWLINE);
1865 return CMD_WARNING;
1866 }
1867
1868 bts->gprs.nse.nsei = atoi(argv[0]);
1869
1870 return CMD_SUCCESS;
1871}
1872
Harald Welte8f0ed552010-05-11 21:53:49 +02001873#define NSVC_TEXT "Network Service Virtual Connection (NS-VC)\n" \
1874 "NSVC Logical Number\n"
Harald Weltea5731cf2010-03-22 11:48:36 +08001875
Harald Welte97a282b2010-03-14 15:37:43 +08001876DEFUN(cfg_bts_gprs_nsvci, cfg_bts_gprs_nsvci_cmd,
1877 "gprs nsvc <0-1> nsvci <0-65535>",
Harald Welte8f0ed552010-05-11 21:53:49 +02001878 GPRS_TEXT NSVC_TEXT
1879 "NS Virtual Connection Identifier\n"
Harald Welte97a282b2010-03-14 15:37:43 +08001880 "GPRS NS VC Identifier")
1881{
1882 struct gsm_bts *bts = vty->index;
1883 int idx = atoi(argv[0]);
1884
Harald Welte4511d892010-04-18 15:51:20 +02001885 if (bts->gprs.mode == BTS_GPRS_NONE) {
Harald Welte94036702010-03-14 23:56:56 +08001886 vty_out(vty, "%% GPRS not enabled on this BTS%s", VTY_NEWLINE);
1887 return CMD_WARNING;
1888 }
1889
Harald Welte97a282b2010-03-14 15:37:43 +08001890 bts->gprs.nsvc[idx].nsvci = atoi(argv[1]);
1891
1892 return CMD_SUCCESS;
1893}
1894
Harald Welteaf387632010-03-14 23:30:30 +08001895DEFUN(cfg_bts_gprs_nsvc_lport, cfg_bts_gprs_nsvc_lport_cmd,
1896 "gprs nsvc <0-1> local udp port <0-65535>",
Harald Welte8f0ed552010-05-11 21:53:49 +02001897 GPRS_TEXT NSVC_TEXT
Harald Welteaf387632010-03-14 23:30:30 +08001898 "GPRS NS Local UDP Port")
1899{
1900 struct gsm_bts *bts = vty->index;
1901 int idx = atoi(argv[0]);
1902
Harald Welte4511d892010-04-18 15:51:20 +02001903 if (bts->gprs.mode == BTS_GPRS_NONE) {
Harald Welte94036702010-03-14 23:56:56 +08001904 vty_out(vty, "%% GPRS not enabled on this BTS%s", VTY_NEWLINE);
1905 return CMD_WARNING;
1906 }
1907
Harald Welteaf387632010-03-14 23:30:30 +08001908 bts->gprs.nsvc[idx].local_port = atoi(argv[1]);
1909
1910 return CMD_SUCCESS;
1911}
1912
1913DEFUN(cfg_bts_gprs_nsvc_rport, cfg_bts_gprs_nsvc_rport_cmd,
1914 "gprs nsvc <0-1> remote udp port <0-65535>",
Harald Welte8f0ed552010-05-11 21:53:49 +02001915 GPRS_TEXT NSVC_TEXT
Harald Welteaf387632010-03-14 23:30:30 +08001916 "GPRS NS Remote UDP Port")
1917{
1918 struct gsm_bts *bts = vty->index;
1919 int idx = atoi(argv[0]);
1920
Harald Welte4511d892010-04-18 15:51:20 +02001921 if (bts->gprs.mode == BTS_GPRS_NONE) {
Harald Welte94036702010-03-14 23:56:56 +08001922 vty_out(vty, "%% GPRS not enabled on this BTS%s", VTY_NEWLINE);
1923 return CMD_WARNING;
1924 }
1925
Harald Welteaf387632010-03-14 23:30:30 +08001926 bts->gprs.nsvc[idx].remote_port = atoi(argv[1]);
1927
1928 return CMD_SUCCESS;
1929}
1930
1931DEFUN(cfg_bts_gprs_nsvc_rip, cfg_bts_gprs_nsvc_rip_cmd,
1932 "gprs nsvc <0-1> remote ip A.B.C.D",
Harald Welte8f0ed552010-05-11 21:53:49 +02001933 GPRS_TEXT NSVC_TEXT
Harald Welteaf387632010-03-14 23:30:30 +08001934 "GPRS NS Remote IP Address")
1935{
1936 struct gsm_bts *bts = vty->index;
1937 int idx = atoi(argv[0]);
1938 struct in_addr ia;
1939
Harald Welte4511d892010-04-18 15:51:20 +02001940 if (bts->gprs.mode == BTS_GPRS_NONE) {
Harald Welte94036702010-03-14 23:56:56 +08001941 vty_out(vty, "%% GPRS not enabled on this BTS%s", VTY_NEWLINE);
1942 return CMD_WARNING;
1943 }
1944
Harald Welteaf387632010-03-14 23:30:30 +08001945 inet_aton(argv[1], &ia);
1946 bts->gprs.nsvc[idx].remote_ip = ntohl(ia.s_addr);
1947
1948 return CMD_SUCCESS;
1949}
1950
Holger Hans Peter Freythere66bf1f2010-09-06 10:11:25 +08001951DEFUN(cfg_bts_pag_free, cfg_bts_pag_free_cmd,
1952 "paging free FREE_NR",
1953 "Only page when having a certain amount of free slots. -1 to disable")
1954{
1955 struct gsm_bts *bts = vty->index;
1956
1957 bts->paging.free_chans_need = atoi(argv[0]);
1958 return CMD_SUCCESS;
1959}
1960
Harald Welte615e9562010-05-11 23:50:21 +02001961DEFUN(cfg_bts_gprs_ns_timer, cfg_bts_gprs_ns_timer_cmd,
1962 "gprs ns timer " NS_TIMERS " <0-255>",
1963 GPRS_TEXT "Network Service\n"
1964 "Network Service Timer\n"
1965 NS_TIMERS_HELP "Timer Value\n")
1966{
1967 struct gsm_bts *bts = vty->index;
1968 int idx = get_string_value(gprs_ns_timer_strs, argv[0]);
1969 int val = atoi(argv[1]);
1970
1971 if (bts->gprs.mode == BTS_GPRS_NONE) {
1972 vty_out(vty, "%% GPRS not enabled on this BTS%s", VTY_NEWLINE);
1973 return CMD_WARNING;
1974 }
1975
1976 if (idx < 0 || idx >= ARRAY_SIZE(bts->gprs.nse.timer))
1977 return CMD_WARNING;
1978
1979 bts->gprs.nse.timer[idx] = val;
1980
1981 return CMD_SUCCESS;
1982}
1983
1984#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 +02001985#define BSSGP_TIMERS_HELP \
1986 "Tbvc-block timeout\n" \
1987 "Tbvc-block retries\n" \
1988 "Tbvc-unblock retries\n" \
1989 "Tbvcc-reset timeout\n" \
1990 "Tbvc-reset retries\n" \
1991 "Tbvc-suspend timeout\n" \
1992 "Tbvc-suspend retries\n" \
1993 "Tbvc-resume timeout\n" \
1994 "Tbvc-resume retries\n" \
1995 "Tbvc-capa-update timeout\n" \
1996 "Tbvc-capa-update retries\n"
Harald Welte615e9562010-05-11 23:50:21 +02001997
1998DEFUN(cfg_bts_gprs_cell_timer, cfg_bts_gprs_cell_timer_cmd,
1999 "gprs cell timer " BSSGP_TIMERS " <0-255>",
2000 GPRS_TEXT "Cell / BSSGP\n"
2001 "Cell/BSSGP Timer\n"
2002 BSSGP_TIMERS_HELP "Timer Value\n")
2003{
2004 struct gsm_bts *bts = vty->index;
2005 int idx = get_string_value(gprs_bssgp_cfg_strs, argv[0]);
2006 int val = atoi(argv[1]);
2007
2008 if (bts->gprs.mode == BTS_GPRS_NONE) {
2009 vty_out(vty, "%% GPRS not enabled on this BTS%s", VTY_NEWLINE);
2010 return CMD_WARNING;
2011 }
2012
2013 if (idx < 0 || idx >= ARRAY_SIZE(bts->gprs.cell.timer))
2014 return CMD_WARNING;
2015
2016 bts->gprs.cell.timer[idx] = val;
2017
2018 return CMD_SUCCESS;
2019}
2020
Harald Welte97a282b2010-03-14 15:37:43 +08002021DEFUN(cfg_bts_gprs_rac, cfg_bts_gprs_rac_cmd,
2022 "gprs routing area <0-255>",
Harald Welte8f0ed552010-05-11 21:53:49 +02002023 GPRS_TEXT
Harald Welte97a282b2010-03-14 15:37:43 +08002024 "GPRS Routing Area Code")
2025{
2026 struct gsm_bts *bts = vty->index;
2027
Harald Welte4511d892010-04-18 15:51:20 +02002028 if (bts->gprs.mode == BTS_GPRS_NONE) {
Harald Welte94036702010-03-14 23:56:56 +08002029 vty_out(vty, "%% GPRS not enabled on this BTS%s", VTY_NEWLINE);
2030 return CMD_WARNING;
2031 }
2032
Harald Welte97a282b2010-03-14 15:37:43 +08002033 bts->gprs.rac = atoi(argv[0]);
2034
2035 return CMD_SUCCESS;
2036}
2037
Harald Welte4511d892010-04-18 15:51:20 +02002038DEFUN(cfg_bts_gprs_mode, cfg_bts_gprs_mode_cmd,
2039 "gprs mode (none|gprs|egprs)",
Harald Welte8f0ed552010-05-11 21:53:49 +02002040 GPRS_TEXT
2041 "GPRS Mode for this BTS\n"
2042 "GPRS Disabled on this BTS\n"
2043 "GPRS Enabled on this BTS\n"
2044 "EGPRS (EDGE) Enabled on this BTS\n")
Harald Welteaf387632010-03-14 23:30:30 +08002045{
2046 struct gsm_bts *bts = vty->index;
Harald Weltef3d8e922010-06-14 22:44:42 +02002047 enum bts_gprs_mode mode = bts_gprs_mode_parse(argv[0]);
Harald Welteaf387632010-03-14 23:30:30 +08002048
Harald Weltef3d8e922010-06-14 22:44:42 +02002049 if (mode != BTS_GPRS_NONE &&
2050 !gsm_bts_has_feature(bts, BTS_FEAT_GPRS)) {
2051 vty_out(vty, "This BTS type does not support %s%s", argv[0],
2052 VTY_NEWLINE);
2053 return CMD_WARNING;
2054 }
2055 if (mode == BTS_GPRS_EGPRS &&
2056 !gsm_bts_has_feature(bts, BTS_FEAT_EGPRS)) {
2057 vty_out(vty, "This BTS type does not support %s%s", argv[0],
2058 VTY_NEWLINE);
2059 return CMD_WARNING;
2060 }
2061
2062 bts->gprs.mode = mode;
Harald Welteaf387632010-03-14 23:30:30 +08002063
2064 return CMD_SUCCESS;
2065}
2066
Harald Welte9fbff4a2010-07-30 11:50:09 +02002067#define SI_TEXT "System Information Messages\n"
2068#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)"
2069#define SI_TYPE_HELP "System Information Type 1\n" \
2070 "System Information Type 2\n" \
2071 "System Information Type 3\n" \
2072 "System Information Type 4\n" \
2073 "System Information Type 5\n" \
2074 "System Information Type 6\n" \
2075 "System Information Type 7\n" \
2076 "System Information Type 8\n" \
2077 "System Information Type 9\n" \
2078 "System Information Type 10\n" \
2079 "System Information Type 13\n" \
2080 "System Information Type 16\n" \
2081 "System Information Type 17\n" \
2082 "System Information Type 18\n" \
2083 "System Information Type 19\n" \
2084 "System Information Type 20\n" \
2085 "System Information Type 2bis\n" \
2086 "System Information Type 2ter\n" \
2087 "System Information Type 2quater\n" \
2088 "System Information Type 5bis\n" \
2089 "System Information Type 5ter\n"
2090
2091DEFUN(cfg_bts_si_mode, cfg_bts_si_mode_cmd,
2092 "system-information " SI_TYPE_TEXT " mode (static|computed)",
2093 SI_TEXT SI_TYPE_HELP
2094 "System Information Mode\n"
2095 "Static user-specified\n"
2096 "Dynamic, BSC-computed\n")
2097{
2098 struct gsm_bts *bts = vty->index;
2099 int type;
2100
2101 type = get_string_value(osmo_sitype_strs, argv[0]);
2102 if (type < 0) {
2103 vty_out(vty, "Error SI Type%s", VTY_NEWLINE);
2104 return CMD_WARNING;
2105 }
2106
2107 if (!strcmp(argv[1], "static"))
2108 bts->si_mode_static |= (1 << type);
2109 else
2110 bts->si_mode_static &= ~(1 << type);
2111
2112 return CMD_SUCCESS;
2113}
2114
2115DEFUN(cfg_bts_si_static, cfg_bts_si_static_cmd,
2116 "system-information " SI_TYPE_TEXT " static HEXSTRING",
2117 SI_TEXT SI_TYPE_HELP
2118 "Static System Information filling\n"
2119 "Static user-specified SI content in HEX notation\n")
2120{
2121 struct gsm_bts *bts = vty->index;
2122 int rc, type;
2123
2124 type = get_string_value(osmo_sitype_strs, argv[0]);
2125 if (type < 0) {
2126 vty_out(vty, "Error SI Type%s", VTY_NEWLINE);
2127 return CMD_WARNING;
2128 }
2129
2130 if (!(bts->si_mode_static & (1 << type))) {
2131 vty_out(vty, "SI Type %s is not configured in static mode%s",
2132 get_value_string(osmo_sitype_strs, type), VTY_NEWLINE);
2133 return CMD_WARNING;
2134 }
2135
Harald Welte290aaed2010-07-30 11:53:18 +02002136 /* Fill buffer with padding pattern */
2137 memset(bts->si_buf[type], 0x2b, sizeof(bts->si_buf[type]));
2138
2139 /* Parse the user-specified SI in hex format, [partially] overwriting padding */
Harald Welte9fbff4a2010-07-30 11:50:09 +02002140 rc = hexparse(argv[1], bts->si_buf[type], sizeof(bts->si_buf[0]));
2141 if (rc < 0 || rc > sizeof(bts->si_buf[0])) {
2142 vty_out(vty, "Error parsing HEXSTRING%s", VTY_NEWLINE);
2143 return CMD_WARNING;
2144 }
2145
2146 /* Mark this SI as present */
2147 bts->si_valid |= (1 << type);
2148
2149 return CMD_SUCCESS;
2150}
2151
Harald Welte32c09622011-01-11 23:44:56 +01002152DEFUN(cfg_bts_neigh_mode, cfg_bts_neigh_mode_cmd,
Harald Welte64c07d22011-02-15 11:43:27 +01002153 "neighbor-list mode (automatic|manual|manual-si5)",
Harald Welte32c09622011-01-11 23:44:56 +01002154 "Neighbor List\n" "Mode of Neighbor List generation\n"
Harald Welte64c07d22011-02-15 11:43:27 +01002155 "Automatically from all BTS in this OpenBSC\n" "Manual\n"
2156 "Manual with different lists for SI2 and SI5\n")
Harald Welte32c09622011-01-11 23:44:56 +01002157{
2158 struct gsm_bts *bts = vty->index;
Harald Welte64c07d22011-02-15 11:43:27 +01002159 int mode = get_string_value(bts_neigh_mode_strs, argv[0]);
Harald Welte32c09622011-01-11 23:44:56 +01002160
Harald Welte64c07d22011-02-15 11:43:27 +01002161 switch (mode) {
2162 case NL_MODE_MANUAL_SI5SEP:
2163 case NL_MODE_MANUAL:
Harald Welte32c09622011-01-11 23:44:56 +01002164 /* make sure we clear the current list when switching to
2165 * manual mode */
2166 if (bts->neigh_list_manual_mode == 0)
2167 memset(&bts->si_common.data.neigh_list, 0,
2168 sizeof(bts->si_common.data.neigh_list));
Harald Welte64c07d22011-02-15 11:43:27 +01002169 break;
2170 default:
2171 break;
2172 }
2173
2174 bts->neigh_list_manual_mode = mode;
Harald Welte32c09622011-01-11 23:44:56 +01002175
2176 return CMD_SUCCESS;
2177}
2178
2179DEFUN(cfg_bts_neigh, cfg_bts_neigh_cmd,
2180 "neighbor-list (add|del) arfcn <0-1024>",
2181 "Neighbor List\n" "Add to manual neighbor list\n"
2182 "Delete from manual neighbor list\n" "ARFCN of neighbor\n"
2183 "ARFCN of neighbor\n")
2184{
2185 struct gsm_bts *bts = vty->index;
2186 struct bitvec *bv = &bts->si_common.neigh_list;
2187 uint16_t arfcn = atoi(argv[1]);
2188
2189 if (!bts->neigh_list_manual_mode) {
2190 vty_out(vty, "%% Cannot configure neighbor list in "
2191 "automatic mode%s", VTY_NEWLINE);
2192 return CMD_WARNING;
2193 }
2194
2195 if (!strcmp(argv[0], "add"))
2196 bitvec_set_bit_pos(bv, arfcn, 1);
2197 else
2198 bitvec_set_bit_pos(bv, arfcn, 0);
2199
2200 return CMD_SUCCESS;
2201}
2202
Harald Welte64c07d22011-02-15 11:43:27 +01002203DEFUN(cfg_bts_si5_neigh, cfg_bts_si5_neigh_cmd,
2204 "si5 neighbor-list (add|del) arfcn <0-1024>",
2205 "SI5 Neighbor List\n" "Add to manual SI5 neighbor list\n"
2206 "Delete from SI5 manual neighbor list\n" "ARFCN of neighbor\n"
2207 "ARFCN of neighbor\n")
2208{
2209 struct gsm_bts *bts = vty->index;
2210 struct bitvec *bv = &bts->si_common.si5_neigh_list;
2211 uint16_t arfcn = atoi(argv[1]);
2212
2213 if (!bts->neigh_list_manual_mode) {
2214 vty_out(vty, "%% Cannot configure neighbor list in "
2215 "automatic mode%s", VTY_NEWLINE);
2216 return CMD_WARNING;
2217 }
2218
2219 if (!strcmp(argv[0], "add"))
2220 bitvec_set_bit_pos(bv, arfcn, 1);
2221 else
2222 bitvec_set_bit_pos(bv, arfcn, 0);
2223
2224 return CMD_SUCCESS;
2225}
Harald Welte9fbff4a2010-07-30 11:50:09 +02002226
Harald Welte8f0ed552010-05-11 21:53:49 +02002227#define TRX_TEXT "Radio Transceiver\n"
Harald Welte7a8fa412009-08-10 13:48:16 +02002228
Harald Welte5258fc42009-03-28 19:07:53 +00002229/* per TRX configuration */
2230DEFUN(cfg_trx,
2231 cfg_trx_cmd,
2232 "trx TRX_NR",
Harald Welte8f0ed552010-05-11 21:53:49 +02002233 TRX_TEXT
Harald Welte5258fc42009-03-28 19:07:53 +00002234 "Select a TRX to configure")
2235{
2236 int trx_nr = atoi(argv[0]);
2237 struct gsm_bts *bts = vty->index;
2238 struct gsm_bts_trx *trx;
2239
Harald Weltee441d9c2009-06-21 16:17:15 +02002240 if (trx_nr > bts->num_trx) {
2241 vty_out(vty, "%% The next unused TRX number in this BTS is %u%s",
2242 bts->num_trx, VTY_NEWLINE);
Harald Welte5258fc42009-03-28 19:07:53 +00002243 return CMD_WARNING;
Harald Weltee441d9c2009-06-21 16:17:15 +02002244 } else if (trx_nr == bts->num_trx) {
2245 /* we need to allocate a new one */
2246 trx = gsm_bts_trx_alloc(bts);
Holger Hans Peter Freytheracf8a0c2010-03-29 08:47:44 +02002247 } else
Harald Weltee441d9c2009-06-21 16:17:15 +02002248 trx = gsm_bts_trx_num(bts, trx_nr);
Holger Hans Peter Freytheracf8a0c2010-03-29 08:47:44 +02002249
Harald Weltee441d9c2009-06-21 16:17:15 +02002250 if (!trx)
2251 return CMD_WARNING;
Harald Welte5258fc42009-03-28 19:07:53 +00002252
2253 vty->index = trx;
Harald Welte197dea92010-05-14 17:59:53 +02002254 vty->index_sub = &trx->description;
Harald Welte5258fc42009-03-28 19:07:53 +00002255 vty->node = TRX_NODE;
2256
2257 return CMD_SUCCESS;
2258}
2259
2260DEFUN(cfg_trx_arfcn,
2261 cfg_trx_arfcn_cmd,
Harald Welte93e90202010-05-14 19:00:52 +02002262 "arfcn <0-1024>",
Harald Welte5258fc42009-03-28 19:07:53 +00002263 "Set the ARFCN for this TRX\n")
2264{
2265 int arfcn = atoi(argv[0]);
2266 struct gsm_bts_trx *trx = vty->index;
2267
2268 /* FIXME: check if this ARFCN is supported by this TRX */
2269
2270 trx->arfcn = arfcn;
2271
2272 /* FIXME: patch ARFCN into SYSTEM INFORMATION */
2273 /* FIXME: use OML layer to update the ARFCN */
2274 /* FIXME: use RSL layer to update SYSTEM INFORMATION */
2275
2276 return CMD_SUCCESS;
2277}
2278
Harald Welte (local)7b37d972009-12-27 20:56:38 +01002279DEFUN(cfg_trx_nominal_power,
2280 cfg_trx_nominal_power_cmd,
2281 "nominal power <0-100>",
2282 "Nominal TRX RF Power in dB\n")
2283{
2284 struct gsm_bts_trx *trx = vty->index;
2285
2286 trx->nominal_power = atoi(argv[0]);
2287
2288 return CMD_SUCCESS;
2289}
2290
Harald Weltefcd24452009-06-20 18:15:19 +02002291DEFUN(cfg_trx_max_power_red,
2292 cfg_trx_max_power_red_cmd,
2293 "max_power_red <0-100>",
2294 "Reduction of maximum BS RF Power in dB\n")
2295{
2296 int maxpwr_r = atoi(argv[0]);
2297 struct gsm_bts_trx *trx = vty->index;
Harald Welte61a83b22009-11-18 09:20:22 +01002298 int upper_limit = 24; /* default 12.21 max power red. */
Harald Weltefcd24452009-06-20 18:15:19 +02002299
2300 /* FIXME: check if our BTS type supports more than 12 */
2301 if (maxpwr_r < 0 || maxpwr_r > upper_limit) {
2302 vty_out(vty, "%% Power %d dB is not in the valid range%s",
2303 maxpwr_r, VTY_NEWLINE);
2304 return CMD_WARNING;
2305 }
2306 if (maxpwr_r & 1) {
2307 vty_out(vty, "%% Power %d dB is not an even value%s",
2308 maxpwr_r, VTY_NEWLINE);
2309 return CMD_WARNING;
2310 }
2311
2312 trx->max_power_red = maxpwr_r;
2313
2314 /* FIXME: make sure we update this using OML */
2315
2316 return CMD_SUCCESS;
2317}
2318
Harald Welte42581822009-08-08 16:12:58 +02002319DEFUN(cfg_trx_rsl_e1,
2320 cfg_trx_rsl_e1_cmd,
2321 "rsl e1 line E1_LINE timeslot <1-31> sub-slot (0|1|2|3|full)",
2322 "E1 interface to be used for RSL\n")
2323{
2324 struct gsm_bts_trx *trx = vty->index;
2325
2326 parse_e1_link(&trx->rsl_e1_link, argv[0], argv[1], argv[2]);
2327
2328 return CMD_SUCCESS;
2329}
2330
2331DEFUN(cfg_trx_rsl_e1_tei,
2332 cfg_trx_rsl_e1_tei_cmd,
2333 "rsl e1 tei <0-63>",
2334 "Set the TEI to be used for RSL")
2335{
2336 struct gsm_bts_trx *trx = vty->index;
2337
2338 trx->rsl_tei = atoi(argv[0]);
2339
2340 return CMD_SUCCESS;
2341}
2342
Holger Hans Peter Freyther2d501ea2009-11-11 11:54:24 +01002343DEFUN(cfg_trx_rf_locked,
2344 cfg_trx_rf_locked_cmd,
2345 "rf_locked (0|1)",
2346 "Turn off RF of the TRX.\n")
2347{
2348 int locked = atoi(argv[0]);
2349 struct gsm_bts_trx *trx = vty->index;
2350
2351 gsm_trx_lock_rf(trx, locked);
2352 return CMD_SUCCESS;
2353}
Harald Welte42581822009-08-08 16:12:58 +02002354
Harald Welte5258fc42009-03-28 19:07:53 +00002355/* per TS configuration */
2356DEFUN(cfg_ts,
2357 cfg_ts_cmd,
Harald Welte42581822009-08-08 16:12:58 +02002358 "timeslot <0-7>",
Harald Welte5258fc42009-03-28 19:07:53 +00002359 "Select a Timeslot to configure")
2360{
2361 int ts_nr = atoi(argv[0]);
2362 struct gsm_bts_trx *trx = vty->index;
2363 struct gsm_bts_trx_ts *ts;
2364
2365 if (ts_nr >= TRX_NR_TS) {
2366 vty_out(vty, "%% A GSM TRX only has %u Timeslots per TRX%s",
2367 TRX_NR_TS, VTY_NEWLINE);
2368 return CMD_WARNING;
2369 }
2370
2371 ts = &trx->ts[ts_nr];
2372
2373 vty->index = ts;
2374 vty->node = TS_NODE;
2375
2376 return CMD_SUCCESS;
2377}
2378
Harald Weltea6fd58e2009-08-07 00:25:23 +02002379DEFUN(cfg_ts_pchan,
2380 cfg_ts_pchan_cmd,
2381 "phys_chan_config PCHAN",
2382 "Physical Channel configuration (TCH/SDCCH/...)")
2383{
2384 struct gsm_bts_trx_ts *ts = vty->index;
2385 int pchanc;
2386
2387 pchanc = gsm_pchan_parse(argv[0]);
2388 if (pchanc < 0)
2389 return CMD_WARNING;
2390
2391 ts->pchan = pchanc;
2392
2393 return CMD_SUCCESS;
2394}
2395
Harald Weltea39b0f22010-06-14 22:26:10 +02002396#define HOPPING_STR "Configure frequency hopping\n"
2397
2398DEFUN(cfg_ts_hopping,
2399 cfg_ts_hopping_cmd,
2400 "hopping enabled (0|1)",
2401 HOPPING_STR "Enable or disable frequency hopping\n"
2402 "Disable frequency hopping\n" "Enable frequency hopping\n")
2403{
2404 struct gsm_bts_trx_ts *ts = vty->index;
Harald Weltec2fb3d02010-06-14 22:47:37 +02002405 int enabled = atoi(argv[0]);
Harald Weltea39b0f22010-06-14 22:26:10 +02002406
Harald Weltec2fb3d02010-06-14 22:47:37 +02002407 if (enabled && !gsm_bts_has_feature(ts->trx->bts, BTS_FEAT_HOPPING)) {
2408 vty_out(vty, "BTS model does not support hopping%s",
2409 VTY_NEWLINE);
2410 return CMD_WARNING;
2411 }
2412
2413 ts->hopping.enabled = enabled;
Harald Weltea39b0f22010-06-14 22:26:10 +02002414
2415 return CMD_SUCCESS;
2416}
2417
Harald Welte6e0cd042009-09-12 13:05:33 +02002418DEFUN(cfg_ts_hsn,
2419 cfg_ts_hsn_cmd,
Harald Weltea39b0f22010-06-14 22:26:10 +02002420 "hopping sequence-number <0-63>",
2421 HOPPING_STR
Harald Welte6e0cd042009-09-12 13:05:33 +02002422 "Which hopping sequence to use for this channel")
2423{
2424 struct gsm_bts_trx_ts *ts = vty->index;
2425
2426 ts->hopping.hsn = atoi(argv[0]);
2427
2428 return CMD_SUCCESS;
2429}
2430
2431DEFUN(cfg_ts_maio,
2432 cfg_ts_maio_cmd,
2433 "hopping maio <0-63>",
Harald Weltea39b0f22010-06-14 22:26:10 +02002434 HOPPING_STR
Harald Welte6e0cd042009-09-12 13:05:33 +02002435 "Which hopping MAIO to use for this channel")
2436{
2437 struct gsm_bts_trx_ts *ts = vty->index;
2438
2439 ts->hopping.maio = atoi(argv[0]);
2440
2441 return CMD_SUCCESS;
2442}
2443
2444DEFUN(cfg_ts_arfcn_add,
2445 cfg_ts_arfcn_add_cmd,
2446 "hopping arfcn add <0-1023>",
Harald Weltea39b0f22010-06-14 22:26:10 +02002447 HOPPING_STR "Configure hopping ARFCN list\n"
2448 "Add an entry to the hopping ARFCN list\n" "ARFCN\n")
Harald Welte6e0cd042009-09-12 13:05:33 +02002449{
2450 struct gsm_bts_trx_ts *ts = vty->index;
2451 int arfcn = atoi(argv[0]);
2452
Harald Weltea39b0f22010-06-14 22:26:10 +02002453 bitvec_set_bit_pos(&ts->hopping.arfcns, arfcn, 1);
2454
Harald Welte6e0cd042009-09-12 13:05:33 +02002455 return CMD_SUCCESS;
2456}
2457
2458DEFUN(cfg_ts_arfcn_del,
2459 cfg_ts_arfcn_del_cmd,
2460 "hopping arfcn del <0-1023>",
Harald Weltea39b0f22010-06-14 22:26:10 +02002461 HOPPING_STR "Configure hopping ARFCN list\n"
2462 "Delete an entry to the hopping ARFCN list\n" "ARFCN\n")
Harald Welte6e0cd042009-09-12 13:05:33 +02002463{
2464 struct gsm_bts_trx_ts *ts = vty->index;
2465 int arfcn = atoi(argv[0]);
2466
Harald Weltea39b0f22010-06-14 22:26:10 +02002467 bitvec_set_bit_pos(&ts->hopping.arfcns, arfcn, 0);
2468
Harald Welte6e0cd042009-09-12 13:05:33 +02002469 return CMD_SUCCESS;
2470}
2471
Harald Weltea6fd58e2009-08-07 00:25:23 +02002472DEFUN(cfg_ts_e1_subslot,
2473 cfg_ts_e1_subslot_cmd,
Harald Welte42581822009-08-08 16:12:58 +02002474 "e1 line E1_LINE timeslot <1-31> sub-slot (0|1|2|3|full)",
Harald Weltea6fd58e2009-08-07 00:25:23 +02002475 "E1 sub-slot connected to this on-air timeslot")
2476{
2477 struct gsm_bts_trx_ts *ts = vty->index;
2478
Harald Welte42581822009-08-08 16:12:58 +02002479 parse_e1_link(&ts->e1_link, argv[0], argv[1], argv[2]);
Harald Weltea6fd58e2009-08-07 00:25:23 +02002480
2481 return CMD_SUCCESS;
2482}
Harald Welte5258fc42009-03-28 19:07:53 +00002483
Harald Welte4f10c252010-05-16 21:47:13 +02002484void openbsc_vty_print_statistics(struct vty *vty, struct gsm_network *net)
2485{
2486 vty_out(vty, "Channel Requests : %lu total, %lu no channel%s",
2487 counter_get(net->stats.chreq.total),
2488 counter_get(net->stats.chreq.no_channel), VTY_NEWLINE);
2489 vty_out(vty, "Channel Failures : %lu rf_failures, %lu rll failures%s",
2490 counter_get(net->stats.chan.rf_fail),
2491 counter_get(net->stats.chan.rll_err), VTY_NEWLINE);
2492 vty_out(vty, "Paging : %lu attempted, %lu complete, %lu expired%s",
2493 counter_get(net->stats.paging.attempted),
2494 counter_get(net->stats.paging.completed),
2495 counter_get(net->stats.paging.expired), VTY_NEWLINE);
2496 vty_out(vty, "BTS failures : %lu OML, %lu RSL%s",
2497 counter_get(net->stats.bts.oml_fail),
2498 counter_get(net->stats.bts.rsl_fail), VTY_NEWLINE);
2499}
2500
Harald Welte5bc61dc2010-05-16 22:02:16 +02002501DEFUN(logging_fltr_imsi,
2502 logging_fltr_imsi_cmd,
2503 "logging filter imsi IMSI",
2504 LOGGING_STR FILTER_STR
2505 "Filter log messages by IMSI\n" "IMSI to be used as filter\n")
2506{
2507 struct telnet_connection *conn;
2508
2509 conn = (struct telnet_connection *) vty->priv;
2510 if (!conn->dbg) {
2511 vty_out(vty, "Logging was not enabled.%s", VTY_NEWLINE);
2512 return CMD_WARNING;
2513 }
2514
2515 log_set_imsi_filter(conn->dbg, argv[0]);
2516 return CMD_SUCCESS;
2517}
2518
Holger Hans Peter Freyther2484ceb2010-10-26 09:40:13 +02002519DEFUN(drop_bts,
2520 drop_bts_cmd,
Holger Hans Peter Freyther0586b0f2010-04-11 12:46:45 +02002521 "drop bts connection <0-65535> (oml|rsl)",
2522 "Debug/Simulation command to drop ipaccess BTS\n"
2523 "BTS NR\n" "Connection Type\n")
Holger Hans Peter Freyther2484ceb2010-10-26 09:40:13 +02002524{
2525 struct gsm_network *gsmnet;
2526 struct gsm_bts_trx *trx;
2527 struct gsm_bts *bts;
2528 unsigned int bts_nr;
2529
2530 gsmnet = gsmnet_from_vty(vty);
2531
2532 bts_nr = atoi(argv[0]);
2533 if (bts_nr >= gsmnet->num_bts) {
2534 vty_out(vty, "BTS number must be between 0 and %d. It was %d.%s",
2535 gsmnet->num_bts, bts_nr, VTY_NEWLINE);
2536 return CMD_WARNING;
2537 }
2538
2539 bts = gsm_bts_num(gsmnet, bts_nr);
2540 if (!bts) {
2541 vty_out(vty, "BTS Nr. %d could not be found.%s", bts_nr, VTY_NEWLINE);
2542 return CMD_WARNING;
2543 }
2544
2545 if (!is_ipaccess_bts(bts)) {
2546 vty_out(vty, "This command only works for ipaccess.%s", VTY_NEWLINE);
2547 return CMD_WARNING;
2548 }
2549
2550
2551 /* close all connections */
2552 if (strcmp(argv[1], "oml") == 0) {
Holger Hans Peter Freytherdab8e272010-11-15 20:29:46 +01002553 ipaccess_drop_oml(bts);
Holger Hans Peter Freyther2484ceb2010-10-26 09:40:13 +02002554 } else if (strcmp(argv[1], "rsl") == 0) {
2555 /* close all rsl connections */
2556 llist_for_each_entry(trx, &bts->trx_list, list) {
Holger Hans Peter Freytherdab8e272010-11-15 20:29:46 +01002557 ipaccess_drop_rsl(trx);
Holger Hans Peter Freyther2484ceb2010-10-26 09:40:13 +02002558 }
2559 } else {
2560 vty_out(vty, "Argument must be 'oml# or 'rsl'.%s", VTY_NEWLINE);
2561 return CMD_WARNING;
2562 }
2563
2564 return CMD_SUCCESS;
2565}
2566
Harald Welted0d2b0b2010-12-23 13:18:07 +01002567DEFUN(pdch_act, pdch_act_cmd,
2568 "bts <0-255> trx <0-255> timeslot <0-7> pdch (activate|deactivate)",
2569 "BTS related commands\n" "BTS Number\n" "Transceiver\n" "Transceiver Number\n"
2570 "TRX Timeslot\n" "Timeslot Number\n" "Packet Data Channel\n"
2571 "Activate Dynamic PDCH/TCH (-> PDCH mode)\n"
2572 "Deactivate Dynamic PDCH/TCH (-> TCH mode)\n")
2573{
2574 struct gsm_bts *bts;
2575 struct gsm_bts_trx *trx;
2576 struct gsm_bts_trx_ts *ts;
2577 int bts_nr = atoi(argv[0]);
2578 int trx_nr = atoi(argv[1]);
2579 int ts_nr = atoi(argv[2]);
2580 int activate;
2581
2582 bts = gsm_bts_num(bsc_gsmnet, bts_nr);
2583 if (!bts) {
2584 vty_out(vty, "%% No such BTS (%d)%s", bts_nr, VTY_NEWLINE);
2585 return CMD_WARNING;
2586 }
2587
2588 if (!is_ipaccess_bts(bts)) {
2589 vty_out(vty, "%% This command only works for ipaccess BTS%s",
2590 VTY_NEWLINE);
2591 return CMD_WARNING;
2592 }
2593
2594 trx = gsm_bts_trx_num(bts, trx_nr);
2595 if (!trx) {
2596 vty_out(vty, "%% No such TRX (%d)%s", trx_nr, VTY_NEWLINE);
2597 return CMD_WARNING;
2598 }
2599
2600 ts = &trx->ts[ts_nr];
2601 if (ts->pchan != GSM_PCHAN_TCH_F_PDCH) {
2602 vty_out(vty, "%% Timeslot %u is not in dynamic TCH_F/PDCH "
2603 "mode%s", ts_nr, VTY_NEWLINE);
2604 return CMD_WARNING;
2605 }
2606
2607 if (!strcmp(argv[3], "activate"))
2608 activate = 1;
2609 else
2610 activate = 0;
2611
2612 rsl_ipacc_pdch_activate(ts, activate);
2613
2614 return CMD_SUCCESS;
2615
2616}
Holger Hans Peter Freyther2484ceb2010-10-26 09:40:13 +02002617
Harald Weltedcccb182010-05-16 20:52:23 +02002618extern int bsc_vty_init_extra(void);
Harald Welte1353f962010-05-16 19:20:24 +02002619extern const char *openbsc_copyright;
Holger Hans Peter Freythere1ffc082010-04-10 00:08:28 +02002620
Harald Weltedcccb182010-05-16 20:52:23 +02002621int bsc_vty_init(void)
Harald Welte68628e82009-03-10 12:17:57 +00002622{
Harald Welteb4d5b172010-05-12 16:10:35 +00002623 install_element_ve(&show_net_cmd);
2624 install_element_ve(&show_bts_cmd);
2625 install_element_ve(&show_trx_cmd);
2626 install_element_ve(&show_ts_cmd);
2627 install_element_ve(&show_lchan_cmd);
Holger Hans Peter Freyther3d6a5d62010-05-14 02:08:49 +08002628 install_element_ve(&show_lchan_summary_cmd);
Harald Welte5bc61dc2010-05-16 22:02:16 +02002629 install_element_ve(&logging_fltr_imsi_cmd);
Harald Welte1bc77352009-03-10 19:47:51 +00002630
Harald Welteb4d5b172010-05-12 16:10:35 +00002631 install_element_ve(&show_e1drv_cmd);
2632 install_element_ve(&show_e1line_cmd);
2633 install_element_ve(&show_e1ts_cmd);
Harald Welte68628e82009-03-10 12:17:57 +00002634
Harald Welteb4d5b172010-05-12 16:10:35 +00002635 install_element_ve(&show_paging_cmd);
Harald Welte5258fc42009-03-28 19:07:53 +00002636
Harald Welte5bc61dc2010-05-16 22:02:16 +02002637 logging_vty_add_cmds();
Holger Hans Peter Freytherb61e3b22009-12-22 22:32:51 +01002638
Harald Welte5013b2a2009-08-07 13:29:14 +02002639 install_element(CONFIG_NODE, &cfg_net_cmd);
2640 install_node(&net_node, config_write_net);
2641 install_default(GSMNET_NODE);
Harald Welte62ab20c2010-05-14 18:59:17 +02002642 install_element(GSMNET_NODE, &ournode_exit_cmd);
Harald Welte54f74242010-05-14 19:11:04 +02002643 install_element(GSMNET_NODE, &ournode_end_cmd);
Harald Welte42581822009-08-08 16:12:58 +02002644 install_element(GSMNET_NODE, &cfg_net_ncc_cmd);
Harald Welte5013b2a2009-08-07 13:29:14 +02002645 install_element(GSMNET_NODE, &cfg_net_mnc_cmd);
2646 install_element(GSMNET_NODE, &cfg_net_name_short_cmd);
2647 install_element(GSMNET_NODE, &cfg_net_name_long_cmd);
Harald Welte (local)69de3972009-08-12 14:42:23 +02002648 install_element(GSMNET_NODE, &cfg_net_auth_policy_cmd);
Harald Welte1085c092009-11-18 20:33:19 +01002649 install_element(GSMNET_NODE, &cfg_net_reject_cause_cmd);
Harald Welte4381cfe2009-08-30 15:47:06 +09002650 install_element(GSMNET_NODE, &cfg_net_encryption_cmd);
Holger Hans Peter Freytherf7d752f2009-11-16 17:12:38 +01002651 install_element(GSMNET_NODE, &cfg_net_neci_cmd);
Harald Welteeab84a12009-12-13 10:53:12 +01002652 install_element(GSMNET_NODE, &cfg_net_rrlp_mode_cmd);
Harald Welte3d23db42009-12-14 17:49:15 +01002653 install_element(GSMNET_NODE, &cfg_net_mm_info_cmd);
Harald Weltebc814502009-12-19 21:41:52 +01002654 install_element(GSMNET_NODE, &cfg_net_handover_cmd);
Harald Welteb720bd32009-12-21 16:51:50 +01002655 install_element(GSMNET_NODE, &cfg_net_ho_win_rxlev_avg_cmd);
2656 install_element(GSMNET_NODE, &cfg_net_ho_win_rxqual_avg_cmd);
2657 install_element(GSMNET_NODE, &cfg_net_ho_win_rxlev_avg_neigh_cmd);
2658 install_element(GSMNET_NODE, &cfg_net_ho_pwr_interval_cmd);
2659 install_element(GSMNET_NODE, &cfg_net_ho_pwr_hysteresis_cmd);
2660 install_element(GSMNET_NODE, &cfg_net_ho_max_distance_cmd);
Holger Hans Peter Freytherc4d88ad2009-11-21 21:18:38 +01002661 install_element(GSMNET_NODE, &cfg_net_T3101_cmd);
Holger Hans Peter Freyther23975e72009-11-21 21:42:26 +01002662 install_element(GSMNET_NODE, &cfg_net_T3103_cmd);
2663 install_element(GSMNET_NODE, &cfg_net_T3105_cmd);
2664 install_element(GSMNET_NODE, &cfg_net_T3107_cmd);
2665 install_element(GSMNET_NODE, &cfg_net_T3109_cmd);
2666 install_element(GSMNET_NODE, &cfg_net_T3111_cmd);
2667 install_element(GSMNET_NODE, &cfg_net_T3113_cmd);
2668 install_element(GSMNET_NODE, &cfg_net_T3115_cmd);
2669 install_element(GSMNET_NODE, &cfg_net_T3117_cmd);
2670 install_element(GSMNET_NODE, &cfg_net_T3119_cmd);
Harald Weltec9f499f2010-12-23 22:53:50 +01002671 install_element(GSMNET_NODE, &cfg_net_T3122_cmd);
Holger Hans Peter Freyther23975e72009-11-21 21:42:26 +01002672 install_element(GSMNET_NODE, &cfg_net_T3141_cmd);
Holger Hans Peter Freyther5a3a61d2010-09-06 09:25:48 +08002673 install_element(GSMNET_NODE, &cfg_net_dtx_cmd);
Holger Hans Peter Freytherae9006a2010-12-22 16:26:04 +01002674 install_element(GSMNET_NODE, &cfg_net_subscr_keep_cmd);
Holger Hans Peter Freyther76fc4a32010-09-06 09:41:50 +08002675 install_element(GSMNET_NODE, &cfg_net_pag_any_tch_cmd);
Harald Welte5013b2a2009-08-07 13:29:14 +02002676
2677 install_element(GSMNET_NODE, &cfg_bts_cmd);
Harald Welte67ce0732009-08-06 19:06:46 +02002678 install_node(&bts_node, config_write_bts);
Harald Welte68628e82009-03-10 12:17:57 +00002679 install_default(BTS_NODE);
Harald Welte62ab20c2010-05-14 18:59:17 +02002680 install_element(BTS_NODE, &ournode_exit_cmd);
Harald Welte54f74242010-05-14 19:11:04 +02002681 install_element(BTS_NODE, &ournode_end_cmd);
Harald Welte5258fc42009-03-28 19:07:53 +00002682 install_element(BTS_NODE, &cfg_bts_type_cmd);
Harald Welte197dea92010-05-14 17:59:53 +02002683 install_element(BTS_NODE, &cfg_description_cmd);
2684 install_element(BTS_NODE, &cfg_no_description_cmd);
Harald Weltefcd24452009-06-20 18:15:19 +02002685 install_element(BTS_NODE, &cfg_bts_band_cmd);
Holger Hans Peter Freytherc4a49e32009-08-21 14:44:12 +02002686 install_element(BTS_NODE, &cfg_bts_ci_cmd);
Harald Welte5258fc42009-03-28 19:07:53 +00002687 install_element(BTS_NODE, &cfg_bts_lac_cmd);
2688 install_element(BTS_NODE, &cfg_bts_tsc_cmd);
Harald Welte42581822009-08-08 16:12:58 +02002689 install_element(BTS_NODE, &cfg_bts_bsic_cmd);
Harald Welte4cc34222009-05-01 15:12:31 +00002690 install_element(BTS_NODE, &cfg_bts_unit_id_cmd);
Harald Welte8175e952009-10-20 00:22:00 +02002691 install_element(BTS_NODE, &cfg_bts_stream_id_cmd);
Harald Welte42581822009-08-08 16:12:58 +02002692 install_element(BTS_NODE, &cfg_bts_oml_e1_cmd);
2693 install_element(BTS_NODE, &cfg_bts_oml_e1_tei_cmd);
Harald Welte7a8fa412009-08-10 13:48:16 +02002694 install_element(BTS_NODE, &cfg_bts_challoc_cmd);
Sylvain Munaut4010f1e2009-12-22 13:43:26 +01002695 install_element(BTS_NODE, &cfg_bts_rach_tx_integer_cmd);
2696 install_element(BTS_NODE, &cfg_bts_rach_max_trans_cmd);
Holger Hans Peter Freyther95c22902010-04-25 23:08:39 +08002697 install_element(BTS_NODE, &cfg_bts_rach_nm_b_thresh_cmd);
2698 install_element(BTS_NODE, &cfg_bts_rach_nm_ldavg_cmd);
Harald Welte (local)5dececf2009-08-12 13:28:23 +02002699 install_element(BTS_NODE, &cfg_bts_cell_barred_cmd);
Holger Hans Peter Freyther3a0a4632010-05-14 00:39:19 +08002700 install_element(BTS_NODE, &cfg_bts_rach_ec_allowed_cmd);
Harald Welte (local)0e451d02009-08-13 10:14:26 +02002701 install_element(BTS_NODE, &cfg_bts_ms_max_power_cmd);
Harald Welte (local)efc92312009-08-14 23:09:25 +02002702 install_element(BTS_NODE, &cfg_bts_per_loc_upd_cmd);
Harald Welte73225282009-12-12 18:17:25 +01002703 install_element(BTS_NODE, &cfg_bts_cell_resel_hyst_cmd);
2704 install_element(BTS_NODE, &cfg_bts_rxlev_acc_min_cmd);
Sylvain Munaute0b06b02010-11-28 18:17:28 +01002705 install_element(BTS_NODE, &cfg_bts_cell_bar_qualify_cmd);
2706 install_element(BTS_NODE, &cfg_bts_cell_resel_ofs_cmd);
2707 install_element(BTS_NODE, &cfg_bts_temp_ofs_cmd);
2708 install_element(BTS_NODE, &cfg_bts_temp_ofs_inf_cmd);
2709 install_element(BTS_NODE, &cfg_bts_penalty_time_cmd);
2710 install_element(BTS_NODE, &cfg_bts_penalty_time_rsvd_cmd);
Harald Welte4511d892010-04-18 15:51:20 +02002711 install_element(BTS_NODE, &cfg_bts_gprs_mode_cmd);
Harald Welte615e9562010-05-11 23:50:21 +02002712 install_element(BTS_NODE, &cfg_bts_gprs_ns_timer_cmd);
Harald Welte97a282b2010-03-14 15:37:43 +08002713 install_element(BTS_NODE, &cfg_bts_gprs_rac_cmd);
2714 install_element(BTS_NODE, &cfg_bts_gprs_bvci_cmd);
Harald Welte615e9562010-05-11 23:50:21 +02002715 install_element(BTS_NODE, &cfg_bts_gprs_cell_timer_cmd);
Harald Weltea5731cf2010-03-22 11:48:36 +08002716 install_element(BTS_NODE, &cfg_bts_gprs_nsei_cmd);
Harald Welte97a282b2010-03-14 15:37:43 +08002717 install_element(BTS_NODE, &cfg_bts_gprs_nsvci_cmd);
Harald Welteaf387632010-03-14 23:30:30 +08002718 install_element(BTS_NODE, &cfg_bts_gprs_nsvc_lport_cmd);
2719 install_element(BTS_NODE, &cfg_bts_gprs_nsvc_rport_cmd);
2720 install_element(BTS_NODE, &cfg_bts_gprs_nsvc_rip_cmd);
Holger Hans Peter Freythere66bf1f2010-09-06 10:11:25 +08002721 install_element(BTS_NODE, &cfg_bts_pag_free_cmd);
Harald Welte9fbff4a2010-07-30 11:50:09 +02002722 install_element(BTS_NODE, &cfg_bts_si_mode_cmd);
2723 install_element(BTS_NODE, &cfg_bts_si_static_cmd);
Harald Welte32c09622011-01-11 23:44:56 +01002724 install_element(BTS_NODE, &cfg_bts_neigh_mode_cmd);
2725 install_element(BTS_NODE, &cfg_bts_neigh_cmd);
Harald Welte64c07d22011-02-15 11:43:27 +01002726 install_element(BTS_NODE, &cfg_bts_si5_neigh_cmd);
Harald Welte68628e82009-03-10 12:17:57 +00002727
Harald Welte5258fc42009-03-28 19:07:53 +00002728 install_element(BTS_NODE, &cfg_trx_cmd);
Harald Welte68628e82009-03-10 12:17:57 +00002729 install_node(&trx_node, dummy_config_write);
Harald Welte68628e82009-03-10 12:17:57 +00002730 install_default(TRX_NODE);
Harald Welte62ab20c2010-05-14 18:59:17 +02002731 install_element(TRX_NODE, &ournode_exit_cmd);
Harald Welte54f74242010-05-14 19:11:04 +02002732 install_element(TRX_NODE, &ournode_end_cmd);
Harald Welte5258fc42009-03-28 19:07:53 +00002733 install_element(TRX_NODE, &cfg_trx_arfcn_cmd);
Harald Welte197dea92010-05-14 17:59:53 +02002734 install_element(TRX_NODE, &cfg_description_cmd);
2735 install_element(TRX_NODE, &cfg_no_description_cmd);
Harald Welte (local)7b37d972009-12-27 20:56:38 +01002736 install_element(TRX_NODE, &cfg_trx_nominal_power_cmd);
Harald Welte879dc972009-06-20 22:36:12 +02002737 install_element(TRX_NODE, &cfg_trx_max_power_red_cmd);
Harald Welte42581822009-08-08 16:12:58 +02002738 install_element(TRX_NODE, &cfg_trx_rsl_e1_cmd);
2739 install_element(TRX_NODE, &cfg_trx_rsl_e1_tei_cmd);
Holger Hans Peter Freyther2d501ea2009-11-11 11:54:24 +01002740 install_element(TRX_NODE, &cfg_trx_rf_locked_cmd);
Harald Welte68628e82009-03-10 12:17:57 +00002741
Harald Welte5258fc42009-03-28 19:07:53 +00002742 install_element(TRX_NODE, &cfg_ts_cmd);
Harald Welte68628e82009-03-10 12:17:57 +00002743 install_node(&ts_node, dummy_config_write);
Harald Welte68628e82009-03-10 12:17:57 +00002744 install_default(TS_NODE);
Harald Welte62ab20c2010-05-14 18:59:17 +02002745 install_element(TS_NODE, &ournode_exit_cmd);
Harald Welte54f74242010-05-14 19:11:04 +02002746 install_element(TS_NODE, &ournode_end_cmd);
Harald Weltea6fd58e2009-08-07 00:25:23 +02002747 install_element(TS_NODE, &cfg_ts_pchan_cmd);
Harald Weltea39b0f22010-06-14 22:26:10 +02002748 install_element(TS_NODE, &cfg_ts_hopping_cmd);
Harald Welte6e0cd042009-09-12 13:05:33 +02002749 install_element(TS_NODE, &cfg_ts_hsn_cmd);
2750 install_element(TS_NODE, &cfg_ts_maio_cmd);
2751 install_element(TS_NODE, &cfg_ts_arfcn_add_cmd);
2752 install_element(TS_NODE, &cfg_ts_arfcn_del_cmd);
Harald Weltea6fd58e2009-08-07 00:25:23 +02002753 install_element(TS_NODE, &cfg_ts_e1_subslot_cmd);
Harald Welte68628e82009-03-10 12:17:57 +00002754
Holger Hans Peter Freyther2484ceb2010-10-26 09:40:13 +02002755 install_element(ENABLE_NODE, &drop_bts_cmd);
Harald Welted0d2b0b2010-12-23 13:18:07 +01002756 install_element(ENABLE_NODE, &pdch_act_cmd);
Holger Hans Peter Freyther2484ceb2010-10-26 09:40:13 +02002757
Harald Welte81c9b9c2010-05-31 16:40:40 +02002758 abis_nm_vty_init();
Harald Weltee1d5eca2011-02-12 14:42:59 +01002759 abis_om2k_vty_init();
Harald Welte3016d9f2011-02-05 13:54:41 +01002760 e1inp_vty_init();
Harald Welte81c9b9c2010-05-31 16:40:40 +02002761
Harald Weltedcccb182010-05-16 20:52:23 +02002762 bsc_vty_init_extra();
Harald Welte40f82892009-05-23 17:31:39 +00002763
Harald Welte68628e82009-03-10 12:17:57 +00002764 return 0;
2765}