blob: c0909db51fffab8f10dd6efa46d97308f6320f47 [file] [log] [blame]
Jonathan Santos03fd8d02011-05-25 13:54:02 -04001/* OpenBSC interface to quagga VTY */
2/* (C) 2009-2010 by Harald Welte <laforge@gnumonks.org>
3 * All Rights Reserved
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU Affero General Public License as published by
7 * the Free Software Foundation; either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU Affero General Public License for more details.
14 *
15 * 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/>.
17 *
18 */
19
20#include <stdlib.h>
21#include <unistd.h>
22#include <sys/types.h>
23
24#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>
29
30#include <arpa/inet.h>
31
32#include <osmocore/linuxlist.h>
33#include <openbsc/gsm_data.h>
34#include <openbsc/e1_input.h>
35#include <openbsc/abis_nm.h>
36#include <openbsc/abis_om2000.h>
37#include <osmocore/utils.h>
38#include <osmocore/gsm_utils.h>
39#include <openbsc/chan_alloc.h>
40#include <openbsc/meas_rep.h>
41#include <openbsc/db.h>
42#include <osmocore/talloc.h>
43#include <openbsc/vty.h>
44#include <openbsc/gprs_ns.h>
45#include <openbsc/system_information.h>
46#include <openbsc/debug.h>
47#include <openbsc/paging.h>
48#include <openbsc/ipaccess.h>
49#include <openbsc/abis_rsl.h>
50#include <openbsc/osmo_msc_data.h>
51#include <openbsc/osmo_bsc_rf.h>
52
53#include "../../bscconfig.h"
54
55/* FIXME: this should go to some common file */
56static const struct value_string gprs_ns_timer_strs[] = {
57 { 0, "tns-block" },
58 { 1, "tns-block-retries" },
59 { 2, "tns-reset" },
60 { 3, "tns-reset-retries" },
61 { 4, "tns-test" },
62 { 5, "tns-alive" },
63 { 6, "tns-alive-retries" },
64 { 0, NULL }
65};
66
67static const struct value_string gprs_bssgp_cfg_strs[] = {
68 { 0, "blocking-timer" },
69 { 1, "blocking-retries" },
70 { 2, "unblocking-retries" },
71 { 3, "reset-timer" },
72 { 4, "reset-retries" },
73 { 5, "suspend-timer" },
74 { 6, "suspend-retries" },
75 { 7, "resume-timer" },
76 { 8, "resume-retries" },
77 { 9, "capability-update-timer" },
78 { 10, "capability-update-retries" },
79 { 0, NULL }
80};
81
82static const struct value_string bts_neigh_mode_strs[] = {
83 { NL_MODE_AUTOMATIC, "automatic" },
84 { NL_MODE_MANUAL, "manual" },
85 { NL_MODE_MANUAL_SI5SEP, "manual-si5" },
86 { 0, NULL }
87};
88
89struct cmd_node net_node = {
90 GSMNET_NODE,
91 "%s(network)#",
92 1,
93};
94
95struct cmd_node bts_node = {
96 BTS_NODE,
97 "%s(bts)#",
98 1,
99};
100
101struct cmd_node trx_node = {
102 TRX_NODE,
103 "%s(trx)#",
104 1,
105};
106
107struct cmd_node ts_node = {
108 TS_NODE,
109 "%s(ts)#",
110 1,
111};
112
113extern struct gsm_network *bsc_gsmnet;
114
115struct gsm_network *gsmnet_from_vty(struct vty *v)
116{
117 /* In case we read from the config file, the vty->priv cannot
118 * point to a struct telnet_connection, and thus conn->priv
119 * will not point to the gsm_network structure */
120#if 0
121 struct telnet_connection *conn = v->priv;
122 return (struct gsm_network *) conn->priv;
123#else
124 return bsc_gsmnet;
125#endif
126}
127
128static int dummy_config_write(struct vty *v)
129{
130 return CMD_SUCCESS;
131}
132
133static void net_dump_nmstate(struct vty *vty, struct gsm_nm_state *nms)
134{
135 vty_out(vty,"Oper '%s', Admin %u, Avail '%s'%s",
136 nm_opstate_name(nms->operational), nms->administrative,
137 nm_avail_name(nms->availability), VTY_NEWLINE);
138}
139
140static void dump_pchan_load_vty(struct vty *vty, char *prefix,
141 const struct pchan_load *pl)
142{
143 int i;
144
145 for (i = 0; i < ARRAY_SIZE(pl->pchan); i++) {
146 const struct load_counter *lc = &pl->pchan[i];
147 unsigned int percent;
148
149 if (lc->total == 0)
150 continue;
151
152 percent = (lc->used * 100) / lc->total;
153
154 vty_out(vty, "%s%20s: %3u%% (%u/%u)%s", prefix,
155 gsm_pchan_name(i), percent, lc->used, lc->total,
156 VTY_NEWLINE);
157 }
158}
159
160static void net_dump_vty(struct vty *vty, struct gsm_network *net)
161{
162 struct pchan_load pl;
163
164 vty_out(vty, "BSC is on Country Code %u, Network Code %u "
165 "and has %u BTS%s", net->country_code, net->network_code,
166 net->num_bts, VTY_NEWLINE);
167 vty_out(vty, " Long network name: '%s'%s",
168 net->name_long, VTY_NEWLINE);
169 vty_out(vty, " Short network name: '%s'%s",
170 net->name_short, VTY_NEWLINE);
171 vty_out(vty, " Authentication policy: %s%s",
172 gsm_auth_policy_name(net->auth_policy), VTY_NEWLINE);
173 vty_out(vty, " Location updating reject cause: %u%s",
174 net->reject_cause, VTY_NEWLINE);
175 vty_out(vty, " Encryption: A5/%u%s", net->a5_encryption,
176 VTY_NEWLINE);
177 vty_out(vty, " NECI (TCH/H): %u%s", net->neci,
178 VTY_NEWLINE);
179 vty_out(vty, " Use TCH for Paging any: %d%s", net->pag_any_tch,
180 VTY_NEWLINE);
181 vty_out(vty, " RRLP Mode: %s%s", rrlp_mode_name(net->rrlp.mode),
182 VTY_NEWLINE);
183 vty_out(vty, " MM Info: %s%s", net->send_mm_info ? "On" : "Off",
184 VTY_NEWLINE);
185 vty_out(vty, " Handover: %s%s", net->handover.active ? "On" : "Off",
186 VTY_NEWLINE);
187 network_chan_load(&pl, net);
188 vty_out(vty, " Current Channel Load:%s", VTY_NEWLINE);
189 dump_pchan_load_vty(vty, " ", &pl);
190
191 /* show rf */
192 if (net->msc_data)
193 vty_out(vty, " Last RF Command: %s%s",
194 net->msc_data->rf_ctl->last_state_command,
195 VTY_NEWLINE);
196}
197
198DEFUN(show_net, show_net_cmd, "show network",
199 SHOW_STR "Display information about a GSM NETWORK\n")
200{
201 struct gsm_network *net = gsmnet_from_vty(vty);
202 net_dump_vty(vty, net);
203
204 return CMD_SUCCESS;
205}
206
207static void e1isl_dump_vty(struct vty *vty, struct e1inp_sign_link *e1l)
208{
209 struct e1inp_line *line;
210
211 if (!e1l) {
212 vty_out(vty, " None%s", VTY_NEWLINE);
213 return;
214 }
215
216 line = e1l->ts->line;
217
218 vty_out(vty, " E1 Line %u, Type %s: Timeslot %u, Mode %s%s",
219 line->num, line->driver->name, e1l->ts->num,
220 e1inp_signtype_name(e1l->type), VTY_NEWLINE);
221 vty_out(vty, " E1 TEI %u, SAPI %u%s",
222 e1l->tei, e1l->sapi, VTY_NEWLINE);
223}
224
225static void bts_dump_vty(struct vty *vty, struct gsm_bts *bts)
226{
227 struct pchan_load pl;
228
229 vty_out(vty, "BTS %u is of %s type in band %s, has CI %u LAC %u, "
230 "BSIC %u, TSC %u and %u TRX%s",
231 bts->nr, btstype2str(bts->type), gsm_band_name(bts->band),
232 bts->cell_identity,
233 bts->location_area_code, bts->bsic, bts->tsc,
234 bts->num_trx, VTY_NEWLINE);
235 vty_out(vty, "Description: %s%s",
236 bts->description ? bts->description : "(null)", VTY_NEWLINE);
237 vty_out(vty, "MS Max power: %u dBm%s", bts->ms_max_power, VTY_NEWLINE);
238 vty_out(vty, "Minimum Rx Level for Access: %i dBm%s",
239 rxlev2dbm(bts->si_common.cell_sel_par.rxlev_acc_min),
240 VTY_NEWLINE);
241 vty_out(vty, "Cell Reselection Hysteresis: %u dBm%s",
242 bts->si_common.cell_sel_par.cell_resel_hyst*2, VTY_NEWLINE);
243 vty_out(vty, "RACH TX-Integer: %u%s", bts->si_common.rach_control.tx_integer,
244 VTY_NEWLINE);
245 vty_out(vty, "RACH Max transmissions: %u%s",
246 rach_max_trans_raw2val(bts->si_common.rach_control.max_trans),
247 VTY_NEWLINE);
248 if (bts->si_common.rach_control.cell_bar)
249 vty_out(vty, " CELL IS BARRED%s", VTY_NEWLINE);
250 vty_out(vty, "System Information present: 0x%08x, static: 0x%08x%s",
251 bts->si_valid, bts->si_mode_static, VTY_NEWLINE);
252 if (is_ipaccess_bts(bts))
253 vty_out(vty, " Unit ID: %u/%u/0, OML Stream ID 0x%02x%s",
254 bts->ip_access.site_id, bts->ip_access.bts_id,
255 bts->oml_tei, VTY_NEWLINE);
256 else if (bts->type == GSM_BTS_TYPE_HSL_FEMTO)
257 vty_out(vty, " Serial Number: %lu%s", bts->hsl.serno, VTY_NEWLINE);
258 vty_out(vty, " NM State: ");
259 net_dump_nmstate(vty, &bts->nm_state);
260 vty_out(vty, " Site Mgr NM State: ");
261 net_dump_nmstate(vty, &bts->site_mgr.nm_state);
262 vty_out(vty, " Paging: FIXME pending requests, %u free slots%s",
263 bts->paging.available_slots, VTY_NEWLINE);
264 if (is_ipaccess_bts(bts)) {
265 vty_out(vty, " OML Link state: %s.%s",
266 bts->oml_link ? "connected" : "disconnected", VTY_NEWLINE);
267 } else {
268 vty_out(vty, " E1 Signalling Link:%s", VTY_NEWLINE);
269 e1isl_dump_vty(vty, bts->oml_link);
270 }
271
272 /* FIXME: chan_desc */
273 memset(&pl, 0, sizeof(pl));
274 bts_chan_load(&pl, bts);
275 vty_out(vty, " Current Channel Load:%s", VTY_NEWLINE);
276 dump_pchan_load_vty(vty, " ", &pl);
277}
278
279DEFUN(show_bts, show_bts_cmd, "show bts [number]",
280 SHOW_STR "Display information about a BTS\n"
281 "BTS number")
282{
283 struct gsm_network *net = gsmnet_from_vty(vty);
284 int bts_nr;
285
286 if (argc != 0) {
287 /* use the BTS number that the user has specified */
288 bts_nr = atoi(argv[0]);
289 if (bts_nr >= net->num_bts) {
290 vty_out(vty, "%% can't find BTS '%s'%s", argv[0],
291 VTY_NEWLINE);
292 return CMD_WARNING;
293 }
294 bts_dump_vty(vty, gsm_bts_num(net, bts_nr));
295 return CMD_SUCCESS;
296 }
297 /* print all BTS's */
298 for (bts_nr = 0; bts_nr < net->num_bts; bts_nr++)
299 bts_dump_vty(vty, gsm_bts_num(net, bts_nr));
300
301 return CMD_SUCCESS;
302}
303
304/* utility functions */
305static void parse_e1_link(struct gsm_e1_subslot *e1_link, const char *line,
306 const char *ts, const char *ss)
307{
308 e1_link->e1_nr = atoi(line);
309 e1_link->e1_ts = atoi(ts);
310 if (!strcmp(ss, "full"))
311 e1_link->e1_ts_ss = 255;
312 else
313 e1_link->e1_ts_ss = atoi(ss);
314}
315
316static void config_write_e1_link(struct vty *vty, struct gsm_e1_subslot *e1_link,
317 const char *prefix)
318{
319 if (!e1_link->e1_ts)
320 return;
321
322 if (e1_link->e1_ts_ss == 255)
323 vty_out(vty, "%se1 line %u timeslot %u sub-slot full%s",
324 prefix, e1_link->e1_nr, e1_link->e1_ts, VTY_NEWLINE);
325 else
326 vty_out(vty, "%se1 line %u timeslot %u sub-slot %u%s",
327 prefix, e1_link->e1_nr, e1_link->e1_ts,
328 e1_link->e1_ts_ss, VTY_NEWLINE);
329}
330
331
332static void config_write_ts_single(struct vty *vty, struct gsm_bts_trx_ts *ts)
333{
334 vty_out(vty, " timeslot %u%s", ts->nr, VTY_NEWLINE);
335 if (ts->pchan != GSM_PCHAN_NONE)
336 vty_out(vty, " phys_chan_config %s%s",
337 gsm_pchan_name(ts->pchan), VTY_NEWLINE);
338 vty_out(vty, " hopping enabled %u%s",
339 ts->hopping.enabled, VTY_NEWLINE);
340 if (ts->hopping.enabled) {
341 unsigned int i;
342 vty_out(vty, " hopping sequence-number %u%s",
343 ts->hopping.hsn, VTY_NEWLINE);
344 vty_out(vty, " hopping maio %u%s",
345 ts->hopping.maio, VTY_NEWLINE);
346 for (i = 0; i < ts->hopping.arfcns.data_len*8; i++) {
347 if (!bitvec_get_bit_pos(&ts->hopping.arfcns, i))
348 continue;
349 vty_out(vty, " hopping arfcn add %u%s",
350 i, VTY_NEWLINE);
351 }
352 }
353 config_write_e1_link(vty, &ts->e1_link, " ");
354
355 if (ts->trx->bts->model->config_write_ts)
356 ts->trx->bts->model->config_write_ts(vty, ts);
357}
358
359static void config_write_trx_single(struct vty *vty, struct gsm_bts_trx *trx)
360{
361 int i;
362
363 vty_out(vty, " trx %u%s", trx->nr, VTY_NEWLINE);
364 if (trx->description)
365 vty_out(vty, " description %s%s", trx->description,
366 VTY_NEWLINE);
367 vty_out(vty, " rf_locked %u%s",
368 trx->nm_state.administrative == NM_STATE_LOCKED ? 1 : 0,
369 VTY_NEWLINE);
370 vty_out(vty, " arfcn %u%s", trx->arfcn, VTY_NEWLINE);
371 vty_out(vty, " nominal power %u%s", trx->nominal_power, VTY_NEWLINE);
372 vty_out(vty, " max_power_red %u%s", trx->max_power_red, VTY_NEWLINE);
373 config_write_e1_link(vty, &trx->rsl_e1_link, " rsl ");
374 vty_out(vty, " rsl e1 tei %u%s", trx->rsl_tei, VTY_NEWLINE);
375
376 if (trx->bts->model->config_write_trx)
377 trx->bts->model->config_write_trx(vty, trx);
378
379 for (i = 0; i < TRX_NR_TS; i++)
380 config_write_ts_single(vty, &trx->ts[i]);
381}
382
383static void config_write_bts_gprs(struct vty *vty, struct gsm_bts *bts)
384{
385 unsigned int i;
386 vty_out(vty, " gprs mode %s%s", bts_gprs_mode_name(bts->gprs.mode),
387 VTY_NEWLINE);
388 if (bts->gprs.mode == BTS_GPRS_NONE)
389 return;
390
391 vty_out(vty, " gprs routing area %u%s", bts->gprs.rac,
392 VTY_NEWLINE);
393 vty_out(vty, " gprs cell bvci %u%s", bts->gprs.cell.bvci,
394 VTY_NEWLINE);
395 for (i = 0; i < ARRAY_SIZE(bts->gprs.cell.timer); i++)
396 vty_out(vty, " gprs cell timer %s %u%s",
397 get_value_string(gprs_bssgp_cfg_strs, i),
398 bts->gprs.cell.timer[i], VTY_NEWLINE);
399 vty_out(vty, " gprs nsei %u%s", bts->gprs.nse.nsei,
400 VTY_NEWLINE);
401 for (i = 0; i < ARRAY_SIZE(bts->gprs.nse.timer); i++)
402 vty_out(vty, " gprs ns timer %s %u%s",
403 get_value_string(gprs_ns_timer_strs, i),
404 bts->gprs.nse.timer[i], VTY_NEWLINE);
405 for (i = 0; i < ARRAY_SIZE(bts->gprs.nsvc); i++) {
406 struct gsm_bts_gprs_nsvc *nsvc =
407 &bts->gprs.nsvc[i];
408 struct in_addr ia;
409
410 ia.s_addr = htonl(nsvc->remote_ip);
411 vty_out(vty, " gprs nsvc %u nsvci %u%s", i,
412 nsvc->nsvci, VTY_NEWLINE);
413 vty_out(vty, " gprs nsvc %u local udp port %u%s", i,
414 nsvc->local_port, VTY_NEWLINE);
415 vty_out(vty, " gprs nsvc %u remote udp port %u%s", i,
416 nsvc->remote_port, VTY_NEWLINE);
417 vty_out(vty, " gprs nsvc %u remote ip %s%s", i,
418 inet_ntoa(ia), VTY_NEWLINE);
419 }
420}
421
422static void config_write_bts_single(struct vty *vty, struct gsm_bts *bts)
423{
424 struct gsm_bts_trx *trx;
425 int i;
426
427 vty_out(vty, " bts %u%s", bts->nr, VTY_NEWLINE);
428 vty_out(vty, " type %s%s", btstype2str(bts->type), VTY_NEWLINE);
429 if (bts->description)
430 vty_out(vty, " description %s%s", bts->description, VTY_NEWLINE);
431 vty_out(vty, " band %s%s", gsm_band_name(bts->band), VTY_NEWLINE);
432 vty_out(vty, " cell_identity %u%s", bts->cell_identity, VTY_NEWLINE);
433 vty_out(vty, " location_area_code %u%s", bts->location_area_code,
434 VTY_NEWLINE);
435 vty_out(vty, " training_sequence_code %u%s", bts->tsc, VTY_NEWLINE);
436 vty_out(vty, " base_station_id_code %u%s", bts->bsic, VTY_NEWLINE);
437 vty_out(vty, " ms max power %u%s", bts->ms_max_power, VTY_NEWLINE);
438 vty_out(vty, " cell reselection hysteresis %u%s",
439 bts->si_common.cell_sel_par.cell_resel_hyst*2, VTY_NEWLINE);
440 vty_out(vty, " rxlev access min %u%s",
441 bts->si_common.cell_sel_par.rxlev_acc_min, VTY_NEWLINE);
442
443 if (bts->si_common.cell_ro_sel_par.present) {
444 struct gsm48_si_selection_params *sp;
445 sp = &bts->si_common.cell_ro_sel_par;
446
447 if (sp->cbq)
448 vty_out(vty, " cell bar qualify %u%s",
449 sp->cbq, VTY_NEWLINE);
450
451 if (sp->cell_resel_off)
452 vty_out(vty, " cell reselection offset %u%s",
453 sp->cell_resel_off*2, VTY_NEWLINE);
454
455 if (sp->temp_offs == 7)
456 vty_out(vty, " temporary offset infinite%s",
457 VTY_NEWLINE);
458 else if (sp->temp_offs)
459 vty_out(vty, " temporary offset %u%s",
460 sp->temp_offs*10, VTY_NEWLINE);
461
462 if (sp->penalty_time == 31)
463 vty_out(vty, " penalty time reserved%s",
464 VTY_NEWLINE);
465 else if (sp->penalty_time)
466 vty_out(vty, " penalty time %u%s",
467 (sp->penalty_time*20)+20, VTY_NEWLINE);
468 }
469
470 if (bts->si_common.chan_desc.t3212)
471 vty_out(vty, " periodic location update %u%s",
472 bts->si_common.chan_desc.t3212 * 6, VTY_NEWLINE);
473 vty_out(vty, " channel allocator %s%s",
474 bts->chan_alloc_reverse ? "descending" : "ascending",
475 VTY_NEWLINE);
476 vty_out(vty, " rach tx integer %u%s",
477 bts->si_common.rach_control.tx_integer, VTY_NEWLINE);
478 vty_out(vty, " rach max transmission %u%s",
479 rach_max_trans_raw2val(bts->si_common.rach_control.max_trans),
480 VTY_NEWLINE);
481
482 if (bts->rach_b_thresh != -1)
483 vty_out(vty, " rach nm busy threshold %u%s",
484 bts->rach_b_thresh, VTY_NEWLINE);
485 if (bts->rach_ldavg_slots != -1)
486 vty_out(vty, " rach nm load average %u%s",
487 bts->rach_ldavg_slots, VTY_NEWLINE);
488 if (bts->si_common.rach_control.cell_bar)
489 vty_out(vty, " cell barred 1%s", VTY_NEWLINE);
490 if ((bts->si_common.rach_control.t2 & 0x4) == 0)
491 vty_out(vty, " rach emergency call allowed 1%s", VTY_NEWLINE);
492 for (i = SYSINFO_TYPE_1; i < _MAX_SYSINFO_TYPE; i++) {
493 if (bts->si_mode_static & (1 << i)) {
494 vty_out(vty, " system-information %s mode static%s",
495 get_value_string(osmo_sitype_strs, i), VTY_NEWLINE);
496 vty_out(vty, " system-information %s static %s%s",
497 get_value_string(osmo_sitype_strs, i),
498 hexdump_nospc(bts->si_buf[i], sizeof(bts->si_buf[i])),
499 VTY_NEWLINE);
500 }
501 }
502 switch (bts->type) {
503 case GSM_BTS_TYPE_NANOBTS:
504 vty_out(vty, " ip.access unit_id %u %u%s",
505 bts->ip_access.site_id, bts->ip_access.bts_id, VTY_NEWLINE);
506 vty_out(vty, " oml ip.access stream_id %u%s", bts->oml_tei, VTY_NEWLINE);
507 break;
508 case GSM_BTS_TYPE_HSL_FEMTO:
509 vty_out(vty, " hsl serial-number %lu%s", bts->hsl.serno, VTY_NEWLINE);
510 break;
511 default:
512 config_write_e1_link(vty, &bts->oml_e1_link, " oml ");
513 vty_out(vty, " oml e1 tei %u%s", bts->oml_tei, VTY_NEWLINE);
514 break;
515 }
516
517 /* if we have a limit, write it */
518 if (bts->paging.free_chans_need >= 0)
519 vty_out(vty, " paging free %d%s", bts->paging.free_chans_need, VTY_NEWLINE);
520
521 vty_out(vty, " neighbor-list mode %s%s",
522 get_value_string(bts_neigh_mode_strs, bts->neigh_list_manual_mode), VTY_NEWLINE);
523 if (bts->neigh_list_manual_mode != NL_MODE_AUTOMATIC) {
524 for (i = 0; i < 1024; i++) {
525 if (bitvec_get_bit_pos(&bts->si_common.neigh_list, i))
526 vty_out(vty, " neighbor-list add arfcn %u%s",
527 i, VTY_NEWLINE);
528 }
529 }
530 if (bts->neigh_list_manual_mode == NL_MODE_MANUAL_SI5SEP) {
531 for (i = 0; i < 1024; i++) {
532 if (bitvec_get_bit_pos(&bts->si_common.si5_neigh_list, i))
533 vty_out(vty, " si5 neighbor-list add arfcn %u%s",
534 i, VTY_NEWLINE);
535 }
536 }
537
538 config_write_bts_gprs(vty, bts);
539
540 if (bts->model->config_write_bts)
541 bts->model->config_write_bts(vty, bts);
542
543 llist_for_each_entry(trx, &bts->trx_list, list)
544 config_write_trx_single(vty, trx);
545}
546
547static int config_write_bts(struct vty *v)
548{
549 struct gsm_network *gsmnet = gsmnet_from_vty(v);
550 struct gsm_bts *bts;
551
552 llist_for_each_entry(bts, &gsmnet->bts_list, list)
553 config_write_bts_single(v, bts);
554
555 return CMD_SUCCESS;
556}
557
558static int config_write_net(struct vty *vty)
559{
560 struct gsm_network *gsmnet = gsmnet_from_vty(vty);
561
562 vty_out(vty, "network%s", VTY_NEWLINE);
563 vty_out(vty, " network country code %u%s", gsmnet->country_code, VTY_NEWLINE);
564 vty_out(vty, " mobile network code %u%s", gsmnet->network_code, VTY_NEWLINE);
565 vty_out(vty, " short name %s%s", gsmnet->name_short, VTY_NEWLINE);
566 vty_out(vty, " long name %s%s", gsmnet->name_long, VTY_NEWLINE);
567 vty_out(vty, " auth policy %s%s", gsm_auth_policy_name(gsmnet->auth_policy), VTY_NEWLINE);
568 vty_out(vty, " location updating reject cause %u%s",
569 gsmnet->reject_cause, VTY_NEWLINE);
570 vty_out(vty, " encryption a5 %u%s", gsmnet->a5_encryption, VTY_NEWLINE);
571 vty_out(vty, " neci %u%s", gsmnet->neci, VTY_NEWLINE);
572 vty_out(vty, " paging any use tch %d%s", gsmnet->pag_any_tch, VTY_NEWLINE);
573 vty_out(vty, " rrlp mode %s%s", rrlp_mode_name(gsmnet->rrlp.mode),
574 VTY_NEWLINE);
575 vty_out(vty, " mm info %u%s", gsmnet->send_mm_info, VTY_NEWLINE);
576 vty_out(vty, " handover %u%s", gsmnet->handover.active, VTY_NEWLINE);
577 vty_out(vty, " handover window rxlev averaging %u%s",
578 gsmnet->handover.win_rxlev_avg, VTY_NEWLINE);
579 vty_out(vty, " handover window rxqual averaging %u%s",
580 gsmnet->handover.win_rxqual_avg, VTY_NEWLINE);
581 vty_out(vty, " handover window rxlev neighbor averaging %u%s",
582 gsmnet->handover.win_rxlev_avg_neigh, VTY_NEWLINE);
583 vty_out(vty, " handover power budget interval %u%s",
584 gsmnet->handover.pwr_interval, VTY_NEWLINE);
585 vty_out(vty, " handover power budget hysteresis %u%s",
586 gsmnet->handover.pwr_hysteresis, VTY_NEWLINE);
587 vty_out(vty, " handover maximum distance %u%s",
588 gsmnet->handover.max_distance, VTY_NEWLINE);
589 vty_out(vty, " timer t3101 %u%s", gsmnet->T3101, VTY_NEWLINE);
590 vty_out(vty, " timer t3103 %u%s", gsmnet->T3103, VTY_NEWLINE);
591 vty_out(vty, " timer t3105 %u%s", gsmnet->T3105, VTY_NEWLINE);
592 vty_out(vty, " timer t3107 %u%s", gsmnet->T3107, VTY_NEWLINE);
593 vty_out(vty, " timer t3109 %u%s", gsmnet->T3109, VTY_NEWLINE);
594 vty_out(vty, " timer t3111 %u%s", gsmnet->T3111, VTY_NEWLINE);
595 vty_out(vty, " timer t3113 %u%s", gsmnet->T3113, VTY_NEWLINE);
596 vty_out(vty, " timer t3115 %u%s", gsmnet->T3115, VTY_NEWLINE);
597 vty_out(vty, " timer t3117 %u%s", gsmnet->T3117, VTY_NEWLINE);
598 vty_out(vty, " timer t3119 %u%s", gsmnet->T3119, VTY_NEWLINE);
599 vty_out(vty, " timer t3122 %u%s", gsmnet->T3122, VTY_NEWLINE);
600 vty_out(vty, " timer t3141 %u%s", gsmnet->T3141, VTY_NEWLINE);
601 vty_out(vty, " dtx-used %u%s", gsmnet->dtx_enabled, VTY_NEWLINE);
602 vty_out(vty, " subscriber-keep-in-ram %d%s",
603 gsmnet->keep_subscr, VTY_NEWLINE);
604
605 return CMD_SUCCESS;
606}
607
608static void trx_dump_vty(struct vty *vty, struct gsm_bts_trx *trx)
609{
610 vty_out(vty, "TRX %u of BTS %u is on ARFCN %u%s",
611 trx->nr, trx->bts->nr, trx->arfcn, VTY_NEWLINE);
612 vty_out(vty, "Description: %s%s",
613 trx->description ? trx->description : "(null)", VTY_NEWLINE);
614 vty_out(vty, " RF Nominal Power: %d dBm, reduced by %u dB, "
615 "resulting BS power: %d dBm%s",
616 trx->nominal_power, trx->max_power_red,
617 trx->nominal_power - trx->max_power_red, VTY_NEWLINE);
618 vty_out(vty, " NM State: ");
619 net_dump_nmstate(vty, &trx->nm_state);
620 vty_out(vty, " Baseband Transceiver NM State: ");
621 net_dump_nmstate(vty, &trx->bb_transc.nm_state);
622 if (is_ipaccess_bts(trx->bts)) {
623 vty_out(vty, " ip.access stream ID: 0x%02x%s",
624 trx->rsl_tei, VTY_NEWLINE);
625 } else {
626 vty_out(vty, " E1 Signalling Link:%s", VTY_NEWLINE);
627 e1isl_dump_vty(vty, trx->rsl_link);
628 }
629}
630
631DEFUN(show_trx,
632 show_trx_cmd,
633 "show trx [bts_nr] [trx_nr]",
634 SHOW_STR "Display information about a TRX\n"
635 "BTS Number\n"
636 "TRX Number\n")
637{
638 struct gsm_network *net = gsmnet_from_vty(vty);
639 struct gsm_bts *bts = NULL;
640 struct gsm_bts_trx *trx;
641 int bts_nr, trx_nr;
642
643 if (argc >= 1) {
644 /* use the BTS number that the user has specified */
645 bts_nr = atoi(argv[0]);
646 if (bts_nr >= net->num_bts) {
647 vty_out(vty, "%% can't find BTS '%s'%s", argv[0],
648 VTY_NEWLINE);
649 return CMD_WARNING;
650 }
651 bts = gsm_bts_num(net, bts_nr);
652 }
653 if (argc >= 2) {
654 trx_nr = atoi(argv[1]);
655 if (trx_nr >= bts->num_trx) {
656 vty_out(vty, "%% can't find TRX '%s'%s", argv[1],
657 VTY_NEWLINE);
658 return CMD_WARNING;
659 }
660 trx = gsm_bts_trx_num(bts, trx_nr);
661 trx_dump_vty(vty, trx);
662 return CMD_SUCCESS;
663 }
664 if (bts) {
665 /* print all TRX in this BTS */
666 for (trx_nr = 0; trx_nr < bts->num_trx; trx_nr++) {
667 trx = gsm_bts_trx_num(bts, trx_nr);
668 trx_dump_vty(vty, trx);
669 }
670 return CMD_SUCCESS;
671 }
672
673 for (bts_nr = 0; bts_nr < net->num_bts; bts_nr++) {
674 bts = gsm_bts_num(net, bts_nr);
675 for (trx_nr = 0; trx_nr < bts->num_trx; trx_nr++) {
676 trx = gsm_bts_trx_num(bts, trx_nr);
677 trx_dump_vty(vty, trx);
678 }
679 }
680
681 return CMD_SUCCESS;
682}
683
684
685static void ts_dump_vty(struct vty *vty, struct gsm_bts_trx_ts *ts)
686{
687 vty_out(vty, "BTS %u, TRX %u, Timeslot %u, phys cfg %s",
688 ts->trx->bts->nr, ts->trx->nr, ts->nr,
689 gsm_pchan_name(ts->pchan));
690 if (ts->pchan == GSM_PCHAN_TCH_F_PDCH)
691 vty_out(vty, " (%s mode)",
692 ts->flags & TS_F_PDCH_MODE ? "PDCH" : "TCH/F");
693 vty_out(vty, "%s", VTY_NEWLINE);
694 vty_out(vty, " NM State: ");
695 net_dump_nmstate(vty, &ts->nm_state);
696 if (!is_ipaccess_bts(ts->trx->bts))
697 vty_out(vty, " E1 Line %u, Timeslot %u, Subslot %u%s",
698 ts->e1_link.e1_nr, ts->e1_link.e1_ts,
699 ts->e1_link.e1_ts_ss, VTY_NEWLINE);
700}
701
702DEFUN(show_ts,
703 show_ts_cmd,
704 "show timeslot [bts_nr] [trx_nr] [ts_nr]",
705 SHOW_STR "Display information about a TS\n"
706 "BTS Number\n" "TRX Number\n" "Timeslot Number\n")
707{
708 struct gsm_network *net = gsmnet_from_vty(vty);
709 struct gsm_bts *bts = NULL;
710 struct gsm_bts_trx *trx = NULL;
711 struct gsm_bts_trx_ts *ts = NULL;
712 int bts_nr, trx_nr, ts_nr;
713
714 if (argc >= 1) {
715 /* use the BTS number that the user has specified */
716 bts_nr = atoi(argv[0]);
717 if (bts_nr >= net->num_bts) {
718 vty_out(vty, "%% can't find BTS '%s'%s", argv[0],
719 VTY_NEWLINE);
720 return CMD_WARNING;
721 }
722 bts = gsm_bts_num(net, bts_nr);
723 }
724 if (argc >= 2) {
725 trx_nr = atoi(argv[1]);
726 if (trx_nr >= bts->num_trx) {
727 vty_out(vty, "%% can't find TRX '%s'%s", argv[1],
728 VTY_NEWLINE);
729 return CMD_WARNING;
730 }
731 trx = gsm_bts_trx_num(bts, trx_nr);
732 }
733 if (argc >= 3) {
734 ts_nr = atoi(argv[2]);
735 if (ts_nr >= TRX_NR_TS) {
736 vty_out(vty, "%% can't find TS '%s'%s", argv[2],
737 VTY_NEWLINE);
738 return CMD_WARNING;
739 }
740 /* Fully Specified: print and exit */
741 ts = &trx->ts[ts_nr];
742 ts_dump_vty(vty, ts);
743 return CMD_SUCCESS;
744 }
745
746 if (bts && trx) {
747 /* Iterate over all TS in this TRX */
748 for (ts_nr = 0; ts_nr < TRX_NR_TS; ts_nr++) {
749 ts = &trx->ts[ts_nr];
750 ts_dump_vty(vty, ts);
751 }
752 } else if (bts) {
753 /* Iterate over all TRX in this BTS, TS in each TRX */
754 for (trx_nr = 0; trx_nr < bts->num_trx; trx_nr++) {
755 trx = gsm_bts_trx_num(bts, trx_nr);
756 for (ts_nr = 0; ts_nr < TRX_NR_TS; ts_nr++) {
757 ts = &trx->ts[ts_nr];
758 ts_dump_vty(vty, ts);
759 }
760 }
761 } else {
762 /* Iterate over all BTS, TRX in each BTS, TS in each TRX */
763 for (bts_nr = 0; bts_nr < net->num_bts; bts_nr++) {
764 bts = gsm_bts_num(net, bts_nr);
765 for (trx_nr = 0; trx_nr < bts->num_trx; trx_nr++) {
766 trx = gsm_bts_trx_num(bts, trx_nr);
767 for (ts_nr = 0; ts_nr < TRX_NR_TS; ts_nr++) {
768 ts = &trx->ts[ts_nr];
769 ts_dump_vty(vty, ts);
770 }
771 }
772 }
773 }
774
775 return CMD_SUCCESS;
776}
777
778static void subscr_dump_vty(struct vty *vty, struct gsm_subscriber *subscr)
779{
780 vty_out(vty, " ID: %llu, Authorized: %d%s", subscr->id,
781 subscr->authorized, VTY_NEWLINE);
782 if (subscr->name)
783 vty_out(vty, " Name: '%s'%s", subscr->name, VTY_NEWLINE);
784 if (subscr->extension)
785 vty_out(vty, " Extension: %s%s", subscr->extension,
786 VTY_NEWLINE);
787 if (subscr->imsi)
788 vty_out(vty, " IMSI: %s%s", subscr->imsi, VTY_NEWLINE);
789 if (subscr->tmsi != GSM_RESERVED_TMSI)
790 vty_out(vty, " TMSI: %08X%s", subscr->tmsi,
791 VTY_NEWLINE);
792
793 vty_out(vty, " Use count: %u%s", subscr->use_count, VTY_NEWLINE);
794}
795
796static void meas_rep_dump_uni_vty(struct vty *vty,
797 struct gsm_meas_rep_unidir *mru,
798 const char *prefix,
799 const char *dir)
800{
801 vty_out(vty, "%s RXL-FULL-%s: %4d dBm, RXL-SUB-%s: %4d dBm ",
802 prefix, dir, rxlev2dbm(mru->full.rx_lev),
803 dir, rxlev2dbm(mru->sub.rx_lev));
804 vty_out(vty, "RXQ-FULL-%s: %d, RXQ-SUB-%s: %d%s",
805 dir, mru->full.rx_qual, dir, mru->sub.rx_qual,
806 VTY_NEWLINE);
807}
808
809static void meas_rep_dump_vty(struct vty *vty, struct gsm_meas_rep *mr,
810 const char *prefix)
811{
812 vty_out(vty, "%sMeasurement Report:%s", prefix, VTY_NEWLINE);
813 vty_out(vty, "%s Flags: %s%s%s%s%s", prefix,
814 mr->flags & MEAS_REP_F_UL_DTX ? "DTXu " : "",
815 mr->flags & MEAS_REP_F_DL_DTX ? "DTXd " : "",
816 mr->flags & MEAS_REP_F_FPC ? "FPC " : "",
817 mr->flags & MEAS_REP_F_DL_VALID ? " " : "DLinval ",
818 VTY_NEWLINE);
819 if (mr->flags & MEAS_REP_F_MS_TO)
820 vty_out(vty, "%s MS Timing Offset: %u%s", prefix,
821 mr->ms_timing_offset, VTY_NEWLINE);
822 if (mr->flags & MEAS_REP_F_MS_L1)
823 vty_out(vty, "%s L1 MS Power: %u dBm, Timing Advance: %u%s",
824 prefix, mr->ms_l1.pwr, mr->ms_l1.ta, VTY_NEWLINE);
825 if (mr->flags & MEAS_REP_F_DL_VALID)
826 meas_rep_dump_uni_vty(vty, &mr->dl, prefix, "dl");
827 meas_rep_dump_uni_vty(vty, &mr->ul, prefix, "ul");
828}
829
830static void lchan_dump_full_vty(struct vty *vty, struct gsm_lchan *lchan)
831{
832 int idx;
833
834 vty_out(vty, "BTS %u, TRX %u, Timeslot %u, Lchan %u: Type %s%s",
835 lchan->ts->trx->bts->nr, lchan->ts->trx->nr, lchan->ts->nr,
836 lchan->nr, gsm_lchant_name(lchan->type), VTY_NEWLINE);
837 vty_out(vty, " Connection: %u, State: %s%s",
838 lchan->conn ? 1: 0,
839 gsm_lchans_name(lchan->state), VTY_NEWLINE);
840 vty_out(vty, " BS Power: %u dBm, MS Power: %u dBm%s",
841 lchan->ts->trx->nominal_power - lchan->ts->trx->max_power_red
842 - lchan->bs_power*2,
843 ms_pwr_dbm(lchan->ts->trx->bts->band, lchan->ms_power),
844 VTY_NEWLINE);
845 if (lchan->conn && lchan->conn->subscr) {
846 vty_out(vty, " Subscriber:%s", VTY_NEWLINE);
847 subscr_dump_vty(vty, lchan->conn->subscr);
848 } else
849 vty_out(vty, " No Subscriber%s", VTY_NEWLINE);
850 if (is_ipaccess_bts(lchan->ts->trx->bts)) {
851 struct in_addr ia;
852 ia.s_addr = htonl(lchan->abis_ip.bound_ip);
853 vty_out(vty, " Bound IP: %s Port %u RTP_TYPE2=%u CONN_ID=%u%s",
854 inet_ntoa(ia), lchan->abis_ip.bound_port,
855 lchan->abis_ip.rtp_payload2, lchan->abis_ip.conn_id,
856 VTY_NEWLINE);
857 }
858
859 /* we want to report the last measurement report */
860 idx = calc_initial_idx(ARRAY_SIZE(lchan->meas_rep),
861 lchan->meas_rep_idx, 1);
862 meas_rep_dump_vty(vty, &lchan->meas_rep[idx], " ");
863}
864
865static void lchan_dump_short_vty(struct vty *vty, struct gsm_lchan *lchan)
866{
867 struct gsm_meas_rep *mr;
868 int idx;
869
870 /* we want to report the last measurement report */
871 idx = calc_initial_idx(ARRAY_SIZE(lchan->meas_rep),
872 lchan->meas_rep_idx, 1);
873 mr = &lchan->meas_rep[idx];
874
875 vty_out(vty, "BTS %u, TRX %u, Timeslot %u, Lchan %u, Type %s - "
876 "L1 MS Power: %u dBm RXL-FULL-dl: %4d dBm RXL-FULL-ul: %4d dBm%s",
877 lchan->ts->trx->bts->nr, lchan->ts->trx->nr, lchan->ts->nr,
878 lchan->nr, gsm_lchant_name(lchan->type), mr->ms_l1.pwr,
879 rxlev2dbm(mr->dl.full.rx_lev),
880 rxlev2dbm(mr->ul.full.rx_lev),
881 VTY_NEWLINE);
882}
883
884static int lchan_summary(struct vty *vty, int argc, const char **argv,
885 void (*dump_cb)(struct vty *, struct gsm_lchan *))
886{
887 struct gsm_network *net = gsmnet_from_vty(vty);
888 struct gsm_bts *bts;
889 struct gsm_bts_trx *trx;
890 struct gsm_bts_trx_ts *ts;
891 struct gsm_lchan *lchan;
892 int bts_nr, trx_nr, ts_nr, lchan_nr;
893
894 if (argc >= 1) {
895 /* use the BTS number that the user has specified */
896 bts_nr = atoi(argv[0]);
897 if (bts_nr >= net->num_bts) {
898 vty_out(vty, "%% can't find BTS %s%s", argv[0],
899 VTY_NEWLINE);
900 return CMD_WARNING;
901 }
902 bts = gsm_bts_num(net, bts_nr);
903 }
904 if (argc >= 2) {
905 trx_nr = atoi(argv[1]);
906 if (trx_nr >= bts->num_trx) {
907 vty_out(vty, "%% can't find TRX %s%s", argv[1],
908 VTY_NEWLINE);
909 return CMD_WARNING;
910 }
911 trx = gsm_bts_trx_num(bts, trx_nr);
912 }
913 if (argc >= 3) {
914 ts_nr = atoi(argv[2]);
915 if (ts_nr >= TRX_NR_TS) {
916 vty_out(vty, "%% can't find TS %s%s", argv[2],
917 VTY_NEWLINE);
918 return CMD_WARNING;
919 }
920 ts = &trx->ts[ts_nr];
921 }
922 if (argc >= 4) {
923 lchan_nr = atoi(argv[3]);
924 if (lchan_nr >= TS_MAX_LCHAN) {
925 vty_out(vty, "%% can't find LCHAN %s%s", argv[3],
926 VTY_NEWLINE);
927 return CMD_WARNING;
928 }
929 lchan = &ts->lchan[lchan_nr];
930 dump_cb(vty, lchan);
931 return CMD_SUCCESS;
932 }
933 for (bts_nr = 0; bts_nr < net->num_bts; bts_nr++) {
934 bts = gsm_bts_num(net, bts_nr);
935 for (trx_nr = 0; trx_nr < bts->num_trx; trx_nr++) {
936 trx = gsm_bts_trx_num(bts, trx_nr);
937 for (ts_nr = 0; ts_nr < TRX_NR_TS; ts_nr++) {
938 ts = &trx->ts[ts_nr];
939 for (lchan_nr = 0; lchan_nr < TS_MAX_LCHAN;
940 lchan_nr++) {
941 lchan = &ts->lchan[lchan_nr];
942 if (lchan->type == GSM_LCHAN_NONE)
943 continue;
944 dump_cb(vty, lchan);
945 }
946 }
947 }
948 }
949
950 return CMD_SUCCESS;
951}
952
953
954DEFUN(show_lchan,
955 show_lchan_cmd,
956 "show lchan [bts_nr] [trx_nr] [ts_nr] [lchan_nr]",
957 SHOW_STR "Display information about a logical channel\n"
958 "BTS Number\n" "TRX Number\n" "Timeslot Number\n"
959 "Logical Channel Number\n")
960
961{
962 return lchan_summary(vty, argc, argv, lchan_dump_full_vty);
963}
964
965DEFUN(show_lchan_summary,
966 show_lchan_summary_cmd,
967 "show lchan summary [bts_nr] [trx_nr] [ts_nr] [lchan_nr]",
968 SHOW_STR "Display information about a logical channel\n"
969 "BTS Number\n" "TRX Number\n" "Timeslot Number\n"
970 "Logical Channel Number\n")
971{
972 return lchan_summary(vty, argc, argv, lchan_dump_short_vty);
973}
974
975static void e1drv_dump_vty(struct vty *vty, struct e1inp_driver *drv)
976{
977 vty_out(vty, "E1 Input Driver %s%s", drv->name, VTY_NEWLINE);
978}
979
980DEFUN(show_e1drv,
981 show_e1drv_cmd,
982 "show e1_driver",
983 SHOW_STR "Display information about available E1 drivers\n")
984{
985 struct e1inp_driver *drv;
986
987 llist_for_each_entry(drv, &e1inp_driver_list, list)
988 e1drv_dump_vty(vty, drv);
989
990 return CMD_SUCCESS;
991}
992
993static void e1line_dump_vty(struct vty *vty, struct e1inp_line *line)
994{
995 vty_out(vty, "E1 Line Number %u, Name %s, Driver %s%s",
996 line->num, line->name ? line->name : "",
997 line->driver->name, VTY_NEWLINE);
998}
999
1000DEFUN(show_e1line,
1001 show_e1line_cmd,
1002 "show e1_line [line_nr]",
1003 SHOW_STR "Display information about a E1 line\n"
1004 "E1 Line Number\n")
1005{
1006 struct e1inp_line *line;
1007
1008 if (argc >= 1) {
1009 int num = atoi(argv[0]);
1010 llist_for_each_entry(line, &e1inp_line_list, list) {
1011 if (line->num == num) {
1012 e1line_dump_vty(vty, line);
1013 return CMD_SUCCESS;
1014 }
1015 }
1016 return CMD_WARNING;
1017 }
1018
1019 llist_for_each_entry(line, &e1inp_line_list, list)
1020 e1line_dump_vty(vty, line);
1021
1022 return CMD_SUCCESS;
1023}
1024
1025static void e1ts_dump_vty(struct vty *vty, struct e1inp_ts *ts)
1026{
1027 if (ts->type == E1INP_TS_TYPE_NONE)
1028 return;
1029 vty_out(vty, "E1 Timeslot %2u of Line %u is Type %s%s",
1030 ts->num, ts->line->num, e1inp_tstype_name(ts->type),
1031 VTY_NEWLINE);
1032}
1033
1034DEFUN(show_e1ts,
1035 show_e1ts_cmd,
1036 "show e1_timeslot [line_nr] [ts_nr]",
1037 SHOW_STR "Display information about a E1 timeslot\n"
1038 "E1 Line Number\n" "E1 Timeslot Number\n")
1039{
1040 struct e1inp_line *line = NULL;
1041 struct e1inp_ts *ts;
1042 int ts_nr;
1043
1044 if (argc == 0) {
1045 llist_for_each_entry(line, &e1inp_line_list, list) {
1046 for (ts_nr = 0; ts_nr < NUM_E1_TS; ts_nr++) {
1047 ts = &line->ts[ts_nr];
1048 e1ts_dump_vty(vty, ts);
1049 }
1050 }
1051 return CMD_SUCCESS;
1052 }
1053 if (argc >= 1) {
1054 int num = atoi(argv[0]);
1055 llist_for_each_entry(line, &e1inp_line_list, list) {
1056 if (line->num == num)
1057 break;
1058 }
1059 if (!line || line->num != num) {
1060 vty_out(vty, "E1 line %s is invalid%s",
1061 argv[0], VTY_NEWLINE);
1062 return CMD_WARNING;
1063 }
1064 }
1065 if (argc >= 2) {
1066 ts_nr = atoi(argv[1]);
1067 if (ts_nr > NUM_E1_TS) {
1068 vty_out(vty, "E1 timeslot %s is invalid%s",
1069 argv[1], VTY_NEWLINE);
1070 return CMD_WARNING;
1071 }
1072 ts = &line->ts[ts_nr];
1073 e1ts_dump_vty(vty, ts);
1074 return CMD_SUCCESS;
1075 } else {
1076 for (ts_nr = 0; ts_nr < NUM_E1_TS; ts_nr++) {
1077 ts = &line->ts[ts_nr];
1078 e1ts_dump_vty(vty, ts);
1079 }
1080 return CMD_SUCCESS;
1081 }
1082 return CMD_SUCCESS;
1083}
1084
1085static void paging_dump_vty(struct vty *vty, struct gsm_paging_request *pag)
1086{
1087 vty_out(vty, "Paging on BTS %u%s", pag->bts->nr, VTY_NEWLINE);
1088 subscr_dump_vty(vty, pag->subscr);
1089}
1090
1091static void bts_paging_dump_vty(struct vty *vty, struct gsm_bts *bts)
1092{
1093 struct gsm_paging_request *pag;
1094
1095 llist_for_each_entry(pag, &bts->paging.pending_requests, entry)
1096 paging_dump_vty(vty, pag);
1097}
1098
1099DEFUN(show_paging,
1100 show_paging_cmd,
1101 "show paging [bts_nr]",
1102 SHOW_STR "Display information about paging reuqests of a BTS\n"
1103 "BTS Number\n")
1104{
1105 struct gsm_network *net = gsmnet_from_vty(vty);
1106 struct gsm_bts *bts;
1107 int bts_nr;
1108
1109 if (argc >= 1) {
1110 /* use the BTS number that the user has specified */
1111 bts_nr = atoi(argv[0]);
1112 if (bts_nr >= net->num_bts) {
1113 vty_out(vty, "%% can't find BTS %s%s", argv[0],
1114 VTY_NEWLINE);
1115 return CMD_WARNING;
1116 }
1117 bts = gsm_bts_num(net, bts_nr);
1118 bts_paging_dump_vty(vty, bts);
1119
1120 return CMD_SUCCESS;
1121 }
1122 for (bts_nr = 0; bts_nr < net->num_bts; bts_nr++) {
1123 bts = gsm_bts_num(net, bts_nr);
1124 bts_paging_dump_vty(vty, bts);
1125 }
1126
1127 return CMD_SUCCESS;
1128}
1129
1130#define NETWORK_STR "Configure the GSM network\n"
1131
1132DEFUN(cfg_net,
1133 cfg_net_cmd,
1134 "network", NETWORK_STR)
1135{
1136 vty->index = gsmnet_from_vty(vty);
1137 vty->node = GSMNET_NODE;
1138
1139 return CMD_SUCCESS;
1140}
1141
1142
1143DEFUN(cfg_net_ncc,
1144 cfg_net_ncc_cmd,
1145 "network country code <1-999>",
1146 "Set the GSM network country code")
1147{
1148 struct gsm_network *gsmnet = gsmnet_from_vty(vty);
1149
1150 gsmnet->country_code = atoi(argv[0]);
1151
1152 return CMD_SUCCESS;
1153}
1154
1155DEFUN(cfg_net_mnc,
1156 cfg_net_mnc_cmd,
1157 "mobile network code <1-999>",
1158 "Set the GSM mobile network code")
1159{
1160 struct gsm_network *gsmnet = gsmnet_from_vty(vty);
1161
1162 gsmnet->network_code = atoi(argv[0]);
1163
1164 return CMD_SUCCESS;
1165}
1166
1167DEFUN(cfg_net_name_short,
1168 cfg_net_name_short_cmd,
1169 "short name NAME",
1170 "Set the short GSM network name")
1171{
1172 struct gsm_network *gsmnet = gsmnet_from_vty(vty);
1173
1174 bsc_replace_string(gsmnet, &gsmnet->name_short, argv[0]);
1175 return CMD_SUCCESS;
1176}
1177
1178DEFUN(cfg_net_name_long,
1179 cfg_net_name_long_cmd,
1180 "long name NAME",
1181 "Set the long GSM network name")
1182{
1183 struct gsm_network *gsmnet = gsmnet_from_vty(vty);
1184
1185 bsc_replace_string(gsmnet, &gsmnet->name_long, argv[0]);
1186 return CMD_SUCCESS;
1187}
1188
1189DEFUN(cfg_net_auth_policy,
1190 cfg_net_auth_policy_cmd,
1191 "auth policy (closed|accept-all|token)",
1192 "Authentication (not cryptographic)\n"
1193 "Set the GSM network authentication policy\n"
1194 "Require the MS to be activated in HLR\n"
1195 "Accept all MS, whether in HLR or not\n"
1196 "Use SMS-token based authentication\n")
1197{
1198 enum gsm_auth_policy policy = gsm_auth_policy_parse(argv[0]);
1199 struct gsm_network *gsmnet = gsmnet_from_vty(vty);
1200
1201 gsmnet->auth_policy = policy;
1202
1203 return CMD_SUCCESS;
1204}
1205
1206DEFUN(cfg_net_reject_cause,
1207 cfg_net_reject_cause_cmd,
1208 "location updating reject cause <2-111>",
1209 "Set the reject cause of location updating reject\n")
1210{
1211 struct gsm_network *gsmnet = gsmnet_from_vty(vty);
1212
1213 gsmnet->reject_cause = atoi(argv[0]);
1214
1215 return CMD_SUCCESS;
1216}
1217
1218DEFUN(cfg_net_encryption,
1219 cfg_net_encryption_cmd,
1220 "encryption a5 (0|1|2)",
1221 "Encryption options\n"
1222 "A5 encryption\n" "A5/0: No encryption\n"
1223 "A5/1: Encryption\n" "A5/2: Export-grade Encryption\n")
1224{
1225 struct gsm_network *gsmnet = gsmnet_from_vty(vty);
1226
1227 gsmnet->a5_encryption= atoi(argv[0]);
1228
1229 return CMD_SUCCESS;
1230}
1231
1232DEFUN(cfg_net_neci,
1233 cfg_net_neci_cmd,
1234 "neci (0|1)",
1235 "New Establish Cause Indication\n"
1236 "Don't set the NECI bit\n" "Set the NECI bit\n")
1237{
1238 struct gsm_network *gsmnet = gsmnet_from_vty(vty);
1239
1240 gsmnet->neci = atoi(argv[0]);
1241 gsm_net_update_ctype(gsmnet);
1242 return CMD_SUCCESS;
1243}
1244
1245DEFUN(cfg_net_rrlp_mode, cfg_net_rrlp_mode_cmd,
1246 "rrlp mode (none|ms-based|ms-preferred|ass-preferred)",
1247 "Radio Resource Location Protocol\n"
1248 "Set the Radio Resource Location Protocol Mode\n"
1249 "Don't send RRLP request\n"
1250 "Request MS-based location\n"
1251 "Request any location, prefer MS-based\n"
1252 "Request any location, prefer MS-assisted\n")
1253{
1254 struct gsm_network *gsmnet = gsmnet_from_vty(vty);
1255
1256 gsmnet->rrlp.mode = rrlp_mode_parse(argv[0]);
1257
1258 return CMD_SUCCESS;
1259}
1260
1261DEFUN(cfg_net_mm_info, cfg_net_mm_info_cmd,
1262 "mm info (0|1)",
1263 "Whether to send MM INFO after LOC UPD ACCEPT")
1264{
1265 struct gsm_network *gsmnet = gsmnet_from_vty(vty);
1266
1267 gsmnet->send_mm_info = atoi(argv[0]);
1268
1269 return CMD_SUCCESS;
1270}
1271
1272#define HANDOVER_STR "Handover Options\n"
1273
1274DEFUN(cfg_net_handover, cfg_net_handover_cmd,
1275 "handover (0|1)",
1276 HANDOVER_STR
1277 "Don't perform in-call handover\n"
1278 "Perform in-call handover\n")
1279{
1280 int enable = atoi(argv[0]);
1281 struct gsm_network *gsmnet = gsmnet_from_vty(vty);
1282
1283 if (enable && ipacc_rtp_direct) {
1284 vty_out(vty, "%% Cannot enable handover unless RTP Proxy mode "
1285 "is enabled by using the -P command line option%s",
1286 VTY_NEWLINE);
1287 return CMD_WARNING;
1288 }
1289 gsmnet->handover.active = enable;
1290
1291 return CMD_SUCCESS;
1292}
1293
1294#define HO_WIN_STR HANDOVER_STR "Measurement Window\n"
1295#define HO_WIN_RXLEV_STR HO_WIN_STR "Received Level Averaging\n"
1296#define HO_WIN_RXQUAL_STR HO_WIN_STR "Received Quality Averaging\n"
1297#define HO_PBUDGET_STR HANDOVER_STR "Power Budget\n"
1298
1299DEFUN(cfg_net_ho_win_rxlev_avg, cfg_net_ho_win_rxlev_avg_cmd,
1300 "handover window rxlev averaging <1-10>",
1301 HO_WIN_RXLEV_STR
1302 "How many RxLev measurements are used for averaging")
1303{
1304 struct gsm_network *gsmnet = gsmnet_from_vty(vty);
1305 gsmnet->handover.win_rxlev_avg = atoi(argv[0]);
1306 return CMD_SUCCESS;
1307}
1308
1309DEFUN(cfg_net_ho_win_rxqual_avg, cfg_net_ho_win_rxqual_avg_cmd,
1310 "handover window rxqual averaging <1-10>",
1311 HO_WIN_RXQUAL_STR
1312 "How many RxQual measurements are used for averaging")
1313{
1314 struct gsm_network *gsmnet = gsmnet_from_vty(vty);
1315 gsmnet->handover.win_rxqual_avg = atoi(argv[0]);
1316 return CMD_SUCCESS;
1317}
1318
1319DEFUN(cfg_net_ho_win_rxlev_neigh_avg, cfg_net_ho_win_rxlev_avg_neigh_cmd,
1320 "handover window rxlev neighbor averaging <1-10>",
1321 HO_WIN_RXLEV_STR
1322 "How many RxQual measurements are used for averaging")
1323{
1324 struct gsm_network *gsmnet = gsmnet_from_vty(vty);
1325 gsmnet->handover.win_rxlev_avg_neigh = atoi(argv[0]);
1326 return CMD_SUCCESS;
1327}
1328
1329DEFUN(cfg_net_ho_pwr_interval, cfg_net_ho_pwr_interval_cmd,
1330 "handover power budget interval <1-99>",
1331 HO_PBUDGET_STR
1332 "How often to check if we have a better cell (SACCH frames)")
1333{
1334 struct gsm_network *gsmnet = gsmnet_from_vty(vty);
1335 gsmnet->handover.pwr_interval = atoi(argv[0]);
1336 return CMD_SUCCESS;
1337}
1338
1339DEFUN(cfg_net_ho_pwr_hysteresis, cfg_net_ho_pwr_hysteresis_cmd,
1340 "handover power budget hysteresis <0-999>",
1341 HO_PBUDGET_STR
1342 "How many dB does a neighbor to be stronger to become a HO candidate")
1343{
1344 struct gsm_network *gsmnet = gsmnet_from_vty(vty);
1345 gsmnet->handover.pwr_hysteresis = atoi(argv[0]);
1346 return CMD_SUCCESS;
1347}
1348
1349DEFUN(cfg_net_ho_max_distance, cfg_net_ho_max_distance_cmd,
1350 "handover maximum distance <0-9999>",
1351 HANDOVER_STR
1352 "How big is the maximum timing advance before HO is forced")
1353{
1354 struct gsm_network *gsmnet = gsmnet_from_vty(vty);
1355 gsmnet->handover.max_distance = atoi(argv[0]);
1356 return CMD_SUCCESS;
1357}
1358
1359DEFUN(cfg_net_pag_any_tch,
1360 cfg_net_pag_any_tch_cmd,
1361 "paging any use tch (0|1)",
1362 "Assign a TCH when receiving a Paging Any request")
1363{
1364 struct gsm_network *gsmnet = gsmnet_from_vty(vty);
1365 gsmnet->pag_any_tch = atoi(argv[0]);
1366 gsm_net_update_ctype(gsmnet);
1367 return CMD_SUCCESS;
1368}
1369
1370#define DECLARE_TIMER(number, doc) \
1371 DEFUN(cfg_net_T##number, \
1372 cfg_net_T##number##_cmd, \
1373 "timer t" #number " <0-65535>", \
1374 "Configure GSM Timers\n" \
1375 doc) \
1376{ \
1377 struct gsm_network *gsmnet = gsmnet_from_vty(vty); \
1378 int value = atoi(argv[0]); \
1379 \
1380 if (value < 0 || value > 65535) { \
1381 vty_out(vty, "Timer value %s out of range.%s", \
1382 argv[0], VTY_NEWLINE); \
1383 return CMD_WARNING; \
1384 } \
1385 \
1386 gsmnet->T##number = value; \
1387 return CMD_SUCCESS; \
1388}
1389
1390DECLARE_TIMER(3101, "Set the timeout value for IMMEDIATE ASSIGNMENT.")
1391DECLARE_TIMER(3103, "Set the timeout value for HANDOVER.")
1392DECLARE_TIMER(3105, "Currently not used.")
1393DECLARE_TIMER(3107, "Currently not used.")
1394DECLARE_TIMER(3109, "Currently not used.")
1395DECLARE_TIMER(3111, "Set the RSL timeout to wait before releasing the RF Channel.")
1396DECLARE_TIMER(3113, "Set the time to try paging a subscriber.")
1397DECLARE_TIMER(3115, "Currently not used.")
1398DECLARE_TIMER(3117, "Currently not used.")
1399DECLARE_TIMER(3119, "Currently not used.")
1400DECLARE_TIMER(3122, "Waiting time (seconds) after IMM ASS REJECT")
1401DECLARE_TIMER(3141, "Currently not used.")
1402
1403DEFUN(cfg_net_dtx,
1404 cfg_net_dtx_cmd,
1405 "dtx-used (0|1)",
1406 "Enable the usage of DTX.\n"
1407 "DTX is enabled/disabled")
1408{
1409 struct gsm_network *gsmnet = gsmnet_from_vty(vty);
1410 gsmnet->dtx_enabled = atoi(argv[0]);
1411 return CMD_SUCCESS;
1412}
1413
1414DEFUN(cfg_net_subscr_keep,
1415 cfg_net_subscr_keep_cmd,
1416 "subscriber-keep-in-ram (0|1)",
1417 "Keep unused subscribers in RAM.\n"
1418 "Delete unused subscribers\n" "Keep unused subscribers\n")
1419{
1420 struct gsm_network *gsmnet = gsmnet_from_vty(vty);
1421 gsmnet->keep_subscr = atoi(argv[0]);
1422 return CMD_SUCCESS;
1423}
1424
1425/* per-BTS configuration */
1426DEFUN(cfg_bts,
1427 cfg_bts_cmd,
1428 "bts BTS_NR",
1429 "Select a BTS to configure\n"
1430 "BTS Number\n")
1431{
1432 struct gsm_network *gsmnet = gsmnet_from_vty(vty);
1433 int bts_nr = atoi(argv[0]);
1434 struct gsm_bts *bts;
1435
1436 if (bts_nr > gsmnet->num_bts) {
1437 vty_out(vty, "%% The next unused BTS number is %u%s",
1438 gsmnet->num_bts, VTY_NEWLINE);
1439 return CMD_WARNING;
1440 } else if (bts_nr == gsmnet->num_bts) {
1441 /* allocate a new one */
1442 bts = gsm_bts_alloc(gsmnet, GSM_BTS_TYPE_UNKNOWN,
1443 HARDCODED_TSC, HARDCODED_BSIC);
1444 } else
1445 bts = gsm_bts_num(gsmnet, bts_nr);
1446
1447 if (!bts) {
1448 vty_out(vty, "%% Unable to allocate BTS %u%s",
1449 gsmnet->num_bts, VTY_NEWLINE);
1450 return CMD_WARNING;
1451 }
1452
1453 vty->index = bts;
1454 vty->index_sub = &bts->description;
1455 vty->node = BTS_NODE;
1456
1457 return CMD_SUCCESS;
1458}
1459
1460DEFUN(cfg_bts_type,
1461 cfg_bts_type_cmd,
1462 "type TYPE",
1463 "Set the BTS type\n")
1464{
1465 struct gsm_bts *bts = vty->index;
1466 int rc;
1467
1468 rc = gsm_set_bts_type(bts, parse_btstype(argv[0]));
1469 if (rc < 0)
1470 return CMD_WARNING;
1471
1472 return CMD_SUCCESS;
1473}
1474
1475DEFUN(cfg_bts_band,
1476 cfg_bts_band_cmd,
1477 "band BAND",
1478 "Set the frequency band of this BTS\n")
1479{
1480 struct gsm_bts *bts = vty->index;
1481 int band = gsm_band_parse(argv[0]);
1482
1483 if (band < 0) {
1484 vty_out(vty, "%% BAND %d is not a valid GSM band%s",
1485 band, VTY_NEWLINE);
1486 return CMD_WARNING;
1487 }
1488
1489 bts->band = band;
1490
1491 return CMD_SUCCESS;
1492}
1493
1494DEFUN(cfg_bts_ci,
1495 cfg_bts_ci_cmd,
1496 "cell_identity <0-65535>",
1497 "Set the Cell identity of this BTS\n")
1498{
1499 struct gsm_bts *bts = vty->index;
1500 int ci = atoi(argv[0]);
1501
1502 if (ci < 0 || ci > 0xffff) {
1503 vty_out(vty, "%% CI %d is not in the valid range (0-65535)%s",
1504 ci, VTY_NEWLINE);
1505 return CMD_WARNING;
1506 }
1507 bts->cell_identity = ci;
1508
1509 return CMD_SUCCESS;
1510}
1511
1512DEFUN(cfg_bts_lac,
1513 cfg_bts_lac_cmd,
1514 "location_area_code <0-65535>",
1515 "Set the Location Area Code (LAC) of this BTS\n")
1516{
1517 struct gsm_bts *bts = vty->index;
1518 int lac = atoi(argv[0]);
1519
1520 if (lac < 0 || lac > 0xffff) {
1521 vty_out(vty, "%% LAC %d is not in the valid range (0-65535)%s",
1522 lac, VTY_NEWLINE);
1523 return CMD_WARNING;
1524 }
1525
1526 if (lac == GSM_LAC_RESERVED_DETACHED || lac == GSM_LAC_RESERVED_ALL_BTS) {
1527 vty_out(vty, "%% LAC %d is reserved by GSM 04.08%s",
1528 lac, VTY_NEWLINE);
1529 return CMD_WARNING;
1530 }
1531
1532 bts->location_area_code = lac;
1533
1534 return CMD_SUCCESS;
1535}
1536
1537
1538DEFUN(cfg_bts_tsc,
1539 cfg_bts_tsc_cmd,
1540 "training_sequence_code <0-255>",
1541 "Set the Training Sequence Code (TSC) of this BTS\n")
1542{
1543 struct gsm_bts *bts = vty->index;
1544 int tsc = atoi(argv[0]);
1545
1546 if (tsc < 0 || tsc > 0xff) {
1547 vty_out(vty, "%% TSC %d is not in the valid range (0-255)%s",
1548 tsc, VTY_NEWLINE);
1549 return CMD_WARNING;
1550 }
1551 bts->tsc = tsc;
1552
1553 return CMD_SUCCESS;
1554}
1555
1556DEFUN(cfg_bts_bsic,
1557 cfg_bts_bsic_cmd,
1558 "base_station_id_code <0-63>",
1559 "Set the Base Station Identity Code (BSIC) of this BTS\n")
1560{
1561 struct gsm_bts *bts = vty->index;
1562 int bsic = atoi(argv[0]);
1563
1564 if (bsic < 0 || bsic > 0x3f) {
1565 vty_out(vty, "%% BSIC %d is not in the valid range (0-255)%s",
1566 bsic, VTY_NEWLINE);
1567 return CMD_WARNING;
1568 }
1569 bts->bsic = bsic;
1570
1571 return CMD_SUCCESS;
1572}
1573
1574
1575DEFUN(cfg_bts_unit_id,
1576 cfg_bts_unit_id_cmd,
1577 "ip.access unit_id <0-65534> <0-255>",
1578 "Set the ip.access BTS Unit ID of this BTS\n")
1579{
1580 struct gsm_bts *bts = vty->index;
1581 int site_id = atoi(argv[0]);
1582 int bts_id = atoi(argv[1]);
1583
1584 if (!is_ipaccess_bts(bts)) {
1585 vty_out(vty, "%% BTS is not of ip.access type%s", VTY_NEWLINE);
1586 return CMD_WARNING;
1587 }
1588
1589 bts->ip_access.site_id = site_id;
1590 bts->ip_access.bts_id = bts_id;
1591
1592 return CMD_SUCCESS;
1593}
1594
1595DEFUN(cfg_bts_serno,
1596 cfg_bts_serno_cmd,
1597 "hsl serial-number STRING",
1598 "Set the HSL Serial Number of this BTS\n")
1599{
1600 struct gsm_bts *bts = vty->index;
1601
1602 if (bts->type != GSM_BTS_TYPE_HSL_FEMTO) {
1603 vty_out(vty, "%% BTS is not of HSL type%s", VTY_NEWLINE);
1604 return CMD_WARNING;
1605 }
1606
1607 bts->hsl.serno = strtoul(argv[0], NULL, 10);
1608
1609 return CMD_SUCCESS;
1610}
1611
1612#define OML_STR "Organization & Maintenance Link\n"
1613#define IPA_STR "ip.access Specific Options\n"
1614
1615DEFUN(cfg_bts_stream_id,
1616 cfg_bts_stream_id_cmd,
1617 "oml ip.access stream_id <0-255>",
1618 OML_STR IPA_STR
1619 "Set the ip.access Stream ID of the OML link of this BTS\n")
1620{
1621 struct gsm_bts *bts = vty->index;
1622 int stream_id = atoi(argv[0]);
1623
1624 if (!is_ipaccess_bts(bts)) {
1625 vty_out(vty, "%% BTS is not of ip.access type%s", VTY_NEWLINE);
1626 return CMD_WARNING;
1627 }
1628
1629 bts->oml_tei = stream_id;
1630
1631 return CMD_SUCCESS;
1632}
1633
1634#define OML_E1_STR OML_STR "E1 Line\n"
1635
1636DEFUN(cfg_bts_oml_e1,
1637 cfg_bts_oml_e1_cmd,
1638 "oml e1 line E1_LINE timeslot <1-31> sub-slot (0|1|2|3|full)",
1639 OML_E1_STR
1640 "E1 interface to be used for OML\n")
1641{
1642 struct gsm_bts *bts = vty->index;
1643
1644 parse_e1_link(&bts->oml_e1_link, argv[0], argv[1], argv[2]);
1645
1646 return CMD_SUCCESS;
1647}
1648
1649
1650DEFUN(cfg_bts_oml_e1_tei,
1651 cfg_bts_oml_e1_tei_cmd,
1652 "oml e1 tei <0-63>",
1653 OML_E1_STR
1654 "Set the TEI to be used for OML")
1655{
1656 struct gsm_bts *bts = vty->index;
1657
1658 bts->oml_tei = atoi(argv[0]);
1659
1660 return CMD_SUCCESS;
1661}
1662
1663DEFUN(cfg_bts_challoc, cfg_bts_challoc_cmd,
1664 "channel allocator (ascending|descending)",
1665 "Channnel Allocator\n" "Channel Allocator\n"
1666 "Allocate Timeslots and Transceivers in ascending order\n"
1667 "Allocate Timeslots and Transceivers in descending order\n")
1668{
1669 struct gsm_bts *bts = vty->index;
1670
1671 if (!strcmp(argv[0], "ascending"))
1672 bts->chan_alloc_reverse = 0;
1673 else
1674 bts->chan_alloc_reverse = 1;
1675
1676 return CMD_SUCCESS;
1677}
1678
1679#define RACH_STR "Random Access Control Channel\n"
1680
1681DEFUN(cfg_bts_rach_tx_integer,
1682 cfg_bts_rach_tx_integer_cmd,
1683 "rach tx integer <0-15>",
1684 RACH_STR
1685 "Set the raw tx integer value in RACH Control parameters IE")
1686{
1687 struct gsm_bts *bts = vty->index;
1688 bts->si_common.rach_control.tx_integer = atoi(argv[0]) & 0xf;
1689 return CMD_SUCCESS;
1690}
1691
1692DEFUN(cfg_bts_rach_max_trans,
1693 cfg_bts_rach_max_trans_cmd,
1694 "rach max transmission (1|2|4|7)",
1695 RACH_STR
1696 "Set the maximum number of RACH burst transmissions")
1697{
1698 struct gsm_bts *bts = vty->index;
1699 bts->si_common.rach_control.max_trans = rach_max_trans_val2raw(atoi(argv[0]));
1700 return CMD_SUCCESS;
1701}
1702
1703#define NM_STR "Network Management\n"
1704
1705DEFUN(cfg_bts_rach_nm_b_thresh,
1706 cfg_bts_rach_nm_b_thresh_cmd,
1707 "rach nm busy threshold <0-255>",
1708 RACH_STR NM_STR
1709 "Set the NM Busy Threshold in dB")
1710{
1711 struct gsm_bts *bts = vty->index;
1712 bts->rach_b_thresh = atoi(argv[0]);
1713 return CMD_SUCCESS;
1714}
1715
1716DEFUN(cfg_bts_rach_nm_ldavg,
1717 cfg_bts_rach_nm_ldavg_cmd,
1718 "rach nm load average <0-65535>",
1719 RACH_STR NM_STR
1720 "Set the NM Loadaverage Slots value")
1721{
1722 struct gsm_bts *bts = vty->index;
1723 bts->rach_ldavg_slots = atoi(argv[0]);
1724 return CMD_SUCCESS;
1725}
1726
1727DEFUN(cfg_bts_cell_barred, cfg_bts_cell_barred_cmd,
1728 "cell barred (0|1)",
1729 "Should this cell be barred from access?")
1730{
1731 struct gsm_bts *bts = vty->index;
1732
1733 bts->si_common.rach_control.cell_bar = atoi(argv[0]);
1734
1735 return CMD_SUCCESS;
1736}
1737
1738DEFUN(cfg_bts_rach_ec_allowed, cfg_bts_rach_ec_allowed_cmd,
1739 "rach emergency call allowed (0|1)",
1740 "Should this cell allow emergency calls?")
1741{
1742 struct gsm_bts *bts = vty->index;
1743
1744 if (atoi(argv[0]) == 0)
1745 bts->si_common.rach_control.t2 |= 0x4;
1746 else
1747 bts->si_common.rach_control.t2 &= ~0x4;
1748
1749 return CMD_SUCCESS;
1750}
1751
1752DEFUN(cfg_bts_ms_max_power, cfg_bts_ms_max_power_cmd,
1753 "ms max power <0-40>",
1754 "Maximum transmit power of the MS")
1755{
1756 struct gsm_bts *bts = vty->index;
1757
1758 bts->ms_max_power = atoi(argv[0]);
1759
1760 return CMD_SUCCESS;
1761}
1762
1763DEFUN(cfg_bts_cell_resel_hyst, cfg_bts_cell_resel_hyst_cmd,
1764 "cell reselection hysteresis <0-14>",
1765 "Cell Re-Selection Hysteresis in dB")
1766{
1767 struct gsm_bts *bts = vty->index;
1768
1769 bts->si_common.cell_sel_par.cell_resel_hyst = atoi(argv[0])/2;
1770
1771 return CMD_SUCCESS;
1772}
1773
1774DEFUN(cfg_bts_rxlev_acc_min, cfg_bts_rxlev_acc_min_cmd,
1775 "rxlev access min <0-63>",
1776 "Minimum RxLev needed for cell access (better than -110dBm)")
1777{
1778 struct gsm_bts *bts = vty->index;
1779
1780 bts->si_common.cell_sel_par.rxlev_acc_min = atoi(argv[0]);
1781
1782 return CMD_SUCCESS;
1783}
1784
1785DEFUN(cfg_bts_cell_bar_qualify, cfg_bts_cell_bar_qualify_cmd,
1786 "cell bar qualify (0|1)",
1787 "Cell Bar Qualify")
1788{
1789 struct gsm_bts *bts = vty->index;
1790
1791 bts->si_common.cell_ro_sel_par.present = 1;
1792 bts->si_common.cell_ro_sel_par.cbq = atoi(argv[0]);
1793
1794 return CMD_SUCCESS;
1795}
1796
1797DEFUN(cfg_bts_cell_resel_ofs, cfg_bts_cell_resel_ofs_cmd,
1798 "cell reselection offset <0-126>",
1799 "Cell Re-Selection Offset in dB")
1800{
1801 struct gsm_bts *bts = vty->index;
1802
1803 bts->si_common.cell_ro_sel_par.present = 1;
1804 bts->si_common.cell_ro_sel_par.cell_resel_off = atoi(argv[0])/2;
1805
1806 return CMD_SUCCESS;
1807}
1808
1809DEFUN(cfg_bts_temp_ofs, cfg_bts_temp_ofs_cmd,
1810 "temporary offset <0-60>",
1811 "Cell selection temporary negative offset in dB")
1812{
1813 struct gsm_bts *bts = vty->index;
1814
1815 bts->si_common.cell_ro_sel_par.present = 1;
1816 bts->si_common.cell_ro_sel_par.temp_offs = atoi(argv[0])/10;
1817
1818 return CMD_SUCCESS;
1819}
1820
1821DEFUN(cfg_bts_temp_ofs_inf, cfg_bts_temp_ofs_inf_cmd,
1822 "temporary offset infinite",
1823 "Sets cell selection temporary negative offset to infinity")
1824{
1825 struct gsm_bts *bts = vty->index;
1826
1827 bts->si_common.cell_ro_sel_par.present = 1;
1828 bts->si_common.cell_ro_sel_par.temp_offs = 7;
1829
1830 return CMD_SUCCESS;
1831}
1832
1833DEFUN(cfg_bts_penalty_time, cfg_bts_penalty_time_cmd,
1834 "penalty time <20-620>",
1835 "Cell selection penalty time in seconds (by 20s increments)")
1836{
1837 struct gsm_bts *bts = vty->index;
1838
1839 bts->si_common.cell_ro_sel_par.present = 1;
1840 bts->si_common.cell_ro_sel_par.penalty_time = (atoi(argv[0])-20)/20;
1841
1842 return CMD_SUCCESS;
1843}
1844
1845DEFUN(cfg_bts_penalty_time_rsvd, cfg_bts_penalty_time_rsvd_cmd,
1846 "penalty time reserved",
1847 "Set cell selection penalty time to reserved value 31\n"
1848 "(indicate that CELL_RESELECT_OFFSET is subtracted from C2 "
1849 "and TEMPORARY_OFFSET is ignored)")
1850{
1851 struct gsm_bts *bts = vty->index;
1852
1853 bts->si_common.cell_ro_sel_par.present = 1;
1854 bts->si_common.cell_ro_sel_par.penalty_time = 31;
1855
1856 return CMD_SUCCESS;
1857}
1858
1859DEFUN(cfg_bts_per_loc_upd, cfg_bts_per_loc_upd_cmd,
1860 "periodic location update <0-1530>",
1861 "Periodic Location Updating Interval in Minutes")
1862{
1863 struct gsm_bts *bts = vty->index;
1864
1865 bts->si_common.chan_desc.t3212 = atoi(argv[0]) / 6;
1866
1867 return CMD_SUCCESS;
1868}
1869
1870#define GPRS_TEXT "GPRS Packet Network\n"
1871
1872DEFUN(cfg_bts_prs_bvci, cfg_bts_gprs_bvci_cmd,
1873 "gprs cell bvci <2-65535>",
1874 GPRS_TEXT
1875 "GPRS Cell Settings\n"
1876 "GPRS BSSGP VC Identifier")
1877{
1878 struct gsm_bts *bts = vty->index;
1879
1880 if (bts->gprs.mode == BTS_GPRS_NONE) {
1881 vty_out(vty, "%% GPRS not enabled on this BTS%s", VTY_NEWLINE);
1882 return CMD_WARNING;
1883 }
1884
1885 bts->gprs.cell.bvci = atoi(argv[0]);
1886
1887 return CMD_SUCCESS;
1888}
1889
1890DEFUN(cfg_bts_gprs_nsei, cfg_bts_gprs_nsei_cmd,
1891 "gprs nsei <0-65535>",
1892 GPRS_TEXT
1893 "GPRS NS Entity Identifier")
1894{
1895 struct gsm_bts *bts = vty->index;
1896
1897 if (bts->gprs.mode == BTS_GPRS_NONE) {
1898 vty_out(vty, "%% GPRS not enabled on this BTS%s", VTY_NEWLINE);
1899 return CMD_WARNING;
1900 }
1901
1902 bts->gprs.nse.nsei = atoi(argv[0]);
1903
1904 return CMD_SUCCESS;
1905}
1906
1907#define NSVC_TEXT "Network Service Virtual Connection (NS-VC)\n" \
1908 "NSVC Logical Number\n"
1909
1910DEFUN(cfg_bts_gprs_nsvci, cfg_bts_gprs_nsvci_cmd,
1911 "gprs nsvc <0-1> nsvci <0-65535>",
1912 GPRS_TEXT NSVC_TEXT
1913 "NS Virtual Connection Identifier\n"
1914 "GPRS NS VC Identifier")
1915{
1916 struct gsm_bts *bts = vty->index;
1917 int idx = atoi(argv[0]);
1918
1919 if (bts->gprs.mode == BTS_GPRS_NONE) {
1920 vty_out(vty, "%% GPRS not enabled on this BTS%s", VTY_NEWLINE);
1921 return CMD_WARNING;
1922 }
1923
1924 bts->gprs.nsvc[idx].nsvci = atoi(argv[1]);
1925
1926 return CMD_SUCCESS;
1927}
1928
1929DEFUN(cfg_bts_gprs_nsvc_lport, cfg_bts_gprs_nsvc_lport_cmd,
1930 "gprs nsvc <0-1> local udp port <0-65535>",
1931 GPRS_TEXT NSVC_TEXT
1932 "GPRS NS Local UDP Port")
1933{
1934 struct gsm_bts *bts = vty->index;
1935 int idx = atoi(argv[0]);
1936
1937 if (bts->gprs.mode == BTS_GPRS_NONE) {
1938 vty_out(vty, "%% GPRS not enabled on this BTS%s", VTY_NEWLINE);
1939 return CMD_WARNING;
1940 }
1941
1942 bts->gprs.nsvc[idx].local_port = atoi(argv[1]);
1943
1944 return CMD_SUCCESS;
1945}
1946
1947DEFUN(cfg_bts_gprs_nsvc_rport, cfg_bts_gprs_nsvc_rport_cmd,
1948 "gprs nsvc <0-1> remote udp port <0-65535>",
1949 GPRS_TEXT NSVC_TEXT
1950 "GPRS NS Remote UDP Port")
1951{
1952 struct gsm_bts *bts = vty->index;
1953 int idx = atoi(argv[0]);
1954
1955 if (bts->gprs.mode == BTS_GPRS_NONE) {
1956 vty_out(vty, "%% GPRS not enabled on this BTS%s", VTY_NEWLINE);
1957 return CMD_WARNING;
1958 }
1959
1960 bts->gprs.nsvc[idx].remote_port = atoi(argv[1]);
1961
1962 return CMD_SUCCESS;
1963}
1964
1965DEFUN(cfg_bts_gprs_nsvc_rip, cfg_bts_gprs_nsvc_rip_cmd,
1966 "gprs nsvc <0-1> remote ip A.B.C.D",
1967 GPRS_TEXT NSVC_TEXT
1968 "GPRS NS Remote IP Address")
1969{
1970 struct gsm_bts *bts = vty->index;
1971 int idx = atoi(argv[0]);
1972 struct in_addr ia;
1973
1974 if (bts->gprs.mode == BTS_GPRS_NONE) {
1975 vty_out(vty, "%% GPRS not enabled on this BTS%s", VTY_NEWLINE);
1976 return CMD_WARNING;
1977 }
1978
1979 inet_aton(argv[1], &ia);
1980 bts->gprs.nsvc[idx].remote_ip = ntohl(ia.s_addr);
1981
1982 return CMD_SUCCESS;
1983}
1984
1985DEFUN(cfg_bts_pag_free, cfg_bts_pag_free_cmd,
1986 "paging free FREE_NR",
1987 "Only page when having a certain amount of free slots. -1 to disable")
1988{
1989 struct gsm_bts *bts = vty->index;
1990
1991 bts->paging.free_chans_need = atoi(argv[0]);
1992 return CMD_SUCCESS;
1993}
1994
1995DEFUN(cfg_bts_gprs_ns_timer, cfg_bts_gprs_ns_timer_cmd,
1996 "gprs ns timer " NS_TIMERS " <0-255>",
1997 GPRS_TEXT "Network Service\n"
1998 "Network Service Timer\n"
1999 NS_TIMERS_HELP "Timer Value\n")
2000{
2001 struct gsm_bts *bts = vty->index;
2002 int idx = get_string_value(gprs_ns_timer_strs, argv[0]);
2003 int val = atoi(argv[1]);
2004
2005 if (bts->gprs.mode == BTS_GPRS_NONE) {
2006 vty_out(vty, "%% GPRS not enabled on this BTS%s", VTY_NEWLINE);
2007 return CMD_WARNING;
2008 }
2009
2010 if (idx < 0 || idx >= ARRAY_SIZE(bts->gprs.nse.timer))
2011 return CMD_WARNING;
2012
2013 bts->gprs.nse.timer[idx] = val;
2014
2015 return CMD_SUCCESS;
2016}
2017
2018#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)"
2019#define BSSGP_TIMERS_HELP \
2020 "Tbvc-block timeout\n" \
2021 "Tbvc-block retries\n" \
2022 "Tbvc-unblock retries\n" \
2023 "Tbvcc-reset timeout\n" \
2024 "Tbvc-reset retries\n" \
2025 "Tbvc-suspend timeout\n" \
2026 "Tbvc-suspend retries\n" \
2027 "Tbvc-resume timeout\n" \
2028 "Tbvc-resume retries\n" \
2029 "Tbvc-capa-update timeout\n" \
2030 "Tbvc-capa-update retries\n"
2031
2032DEFUN(cfg_bts_gprs_cell_timer, cfg_bts_gprs_cell_timer_cmd,
2033 "gprs cell timer " BSSGP_TIMERS " <0-255>",
2034 GPRS_TEXT "Cell / BSSGP\n"
2035 "Cell/BSSGP Timer\n"
2036 BSSGP_TIMERS_HELP "Timer Value\n")
2037{
2038 struct gsm_bts *bts = vty->index;
2039 int idx = get_string_value(gprs_bssgp_cfg_strs, argv[0]);
2040 int val = atoi(argv[1]);
2041
2042 if (bts->gprs.mode == BTS_GPRS_NONE) {
2043 vty_out(vty, "%% GPRS not enabled on this BTS%s", VTY_NEWLINE);
2044 return CMD_WARNING;
2045 }
2046
2047 if (idx < 0 || idx >= ARRAY_SIZE(bts->gprs.cell.timer))
2048 return CMD_WARNING;
2049
2050 bts->gprs.cell.timer[idx] = val;
2051
2052 return CMD_SUCCESS;
2053}
2054
2055DEFUN(cfg_bts_gprs_rac, cfg_bts_gprs_rac_cmd,
2056 "gprs routing area <0-255>",
2057 GPRS_TEXT
2058 "GPRS Routing Area Code")
2059{
2060 struct gsm_bts *bts = vty->index;
2061
2062 if (bts->gprs.mode == BTS_GPRS_NONE) {
2063 vty_out(vty, "%% GPRS not enabled on this BTS%s", VTY_NEWLINE);
2064 return CMD_WARNING;
2065 }
2066
2067 bts->gprs.rac = atoi(argv[0]);
2068
2069 return CMD_SUCCESS;
2070}
2071
2072DEFUN(cfg_bts_gprs_mode, cfg_bts_gprs_mode_cmd,
2073 "gprs mode (none|gprs|egprs)",
2074 GPRS_TEXT
2075 "GPRS Mode for this BTS\n"
2076 "GPRS Disabled on this BTS\n"
2077 "GPRS Enabled on this BTS\n"
2078 "EGPRS (EDGE) Enabled on this BTS\n")
2079{
2080 struct gsm_bts *bts = vty->index;
2081 enum bts_gprs_mode mode = bts_gprs_mode_parse(argv[0]);
2082
2083 if (mode != BTS_GPRS_NONE &&
2084 !gsm_bts_has_feature(bts, BTS_FEAT_GPRS)) {
2085 vty_out(vty, "This BTS type does not support %s%s", argv[0],
2086 VTY_NEWLINE);
2087 return CMD_WARNING;
2088 }
2089 if (mode == BTS_GPRS_EGPRS &&
2090 !gsm_bts_has_feature(bts, BTS_FEAT_EGPRS)) {
2091 vty_out(vty, "This BTS type does not support %s%s", argv[0],
2092 VTY_NEWLINE);
2093 return CMD_WARNING;
2094 }
2095
2096 bts->gprs.mode = mode;
2097
2098 return CMD_SUCCESS;
2099}
2100
2101#define SI_TEXT "System Information Messages\n"
2102#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)"
2103#define SI_TYPE_HELP "System Information Type 1\n" \
2104 "System Information Type 2\n" \
2105 "System Information Type 3\n" \
2106 "System Information Type 4\n" \
2107 "System Information Type 5\n" \
2108 "System Information Type 6\n" \
2109 "System Information Type 7\n" \
2110 "System Information Type 8\n" \
2111 "System Information Type 9\n" \
2112 "System Information Type 10\n" \
2113 "System Information Type 13\n" \
2114 "System Information Type 16\n" \
2115 "System Information Type 17\n" \
2116 "System Information Type 18\n" \
2117 "System Information Type 19\n" \
2118 "System Information Type 20\n" \
2119 "System Information Type 2bis\n" \
2120 "System Information Type 2ter\n" \
2121 "System Information Type 2quater\n" \
2122 "System Information Type 5bis\n" \
2123 "System Information Type 5ter\n"
2124
2125DEFUN(cfg_bts_si_mode, cfg_bts_si_mode_cmd,
2126 "system-information " SI_TYPE_TEXT " mode (static|computed)",
2127 SI_TEXT SI_TYPE_HELP
2128 "System Information Mode\n"
2129 "Static user-specified\n"
2130 "Dynamic, BSC-computed\n")
2131{
2132 struct gsm_bts *bts = vty->index;
2133 int type;
2134
2135 type = get_string_value(osmo_sitype_strs, argv[0]);
2136 if (type < 0) {
2137 vty_out(vty, "Error SI Type%s", VTY_NEWLINE);
2138 return CMD_WARNING;
2139 }
2140
2141 if (!strcmp(argv[1], "static"))
2142 bts->si_mode_static |= (1 << type);
2143 else
2144 bts->si_mode_static &= ~(1 << type);
2145
2146 return CMD_SUCCESS;
2147}
2148
2149DEFUN(cfg_bts_si_static, cfg_bts_si_static_cmd,
2150 "system-information " SI_TYPE_TEXT " static HEXSTRING",
2151 SI_TEXT SI_TYPE_HELP
2152 "Static System Information filling\n"
2153 "Static user-specified SI content in HEX notation\n")
2154{
2155 struct gsm_bts *bts = vty->index;
2156 int rc, type;
2157
2158 type = get_string_value(osmo_sitype_strs, argv[0]);
2159 if (type < 0) {
2160 vty_out(vty, "Error SI Type%s", VTY_NEWLINE);
2161 return CMD_WARNING;
2162 }
2163
2164 if (!(bts->si_mode_static & (1 << type))) {
2165 vty_out(vty, "SI Type %s is not configured in static mode%s",
2166 get_value_string(osmo_sitype_strs, type), VTY_NEWLINE);
2167 return CMD_WARNING;
2168 }
2169
2170 /* Fill buffer with padding pattern */
2171 memset(bts->si_buf[type], 0x2b, sizeof(bts->si_buf[type]));
2172
2173 /* Parse the user-specified SI in hex format, [partially] overwriting padding */
2174 rc = hexparse(argv[1], bts->si_buf[type], sizeof(bts->si_buf[0]));
2175 if (rc < 0 || rc > sizeof(bts->si_buf[0])) {
2176 vty_out(vty, "Error parsing HEXSTRING%s", VTY_NEWLINE);
2177 return CMD_WARNING;
2178 }
2179
2180 /* Mark this SI as present */
2181 bts->si_valid |= (1 << type);
2182
2183 return CMD_SUCCESS;
2184}
2185
2186DEFUN(cfg_bts_neigh_mode, cfg_bts_neigh_mode_cmd,
2187 "neighbor-list mode (automatic|manual|manual-si5)",
2188 "Neighbor List\n" "Mode of Neighbor List generation\n"
2189 "Automatically from all BTS in this OpenBSC\n" "Manual\n"
2190 "Manual with different lists for SI2 and SI5\n")
2191{
2192 struct gsm_bts *bts = vty->index;
2193 int mode = get_string_value(bts_neigh_mode_strs, argv[0]);
2194
2195 switch (mode) {
2196 case NL_MODE_MANUAL_SI5SEP:
2197 case NL_MODE_MANUAL:
2198 /* make sure we clear the current list when switching to
2199 * manual mode */
2200 if (bts->neigh_list_manual_mode == 0)
2201 memset(&bts->si_common.data.neigh_list, 0,
2202 sizeof(bts->si_common.data.neigh_list));
2203 break;
2204 default:
2205 break;
2206 }
2207
2208 bts->neigh_list_manual_mode = mode;
2209
2210 return CMD_SUCCESS;
2211}
2212
2213DEFUN(cfg_bts_neigh, cfg_bts_neigh_cmd,
2214 "neighbor-list (add|del) arfcn <0-1024>",
2215 "Neighbor List\n" "Add to manual neighbor list\n"
2216 "Delete from manual neighbor list\n" "ARFCN of neighbor\n"
2217 "ARFCN of neighbor\n")
2218{
2219 struct gsm_bts *bts = vty->index;
2220 struct bitvec *bv = &bts->si_common.neigh_list;
2221 uint16_t arfcn = atoi(argv[1]);
2222
2223 if (!bts->neigh_list_manual_mode) {
2224 vty_out(vty, "%% Cannot configure neighbor list in "
2225 "automatic mode%s", VTY_NEWLINE);
2226 return CMD_WARNING;
2227 }
2228
2229 if (!strcmp(argv[0], "add"))
2230 bitvec_set_bit_pos(bv, arfcn, 1);
2231 else
2232 bitvec_set_bit_pos(bv, arfcn, 0);
2233
2234 return CMD_SUCCESS;
2235}
2236
2237DEFUN(cfg_bts_si5_neigh, cfg_bts_si5_neigh_cmd,
2238 "si5 neighbor-list (add|del) arfcn <0-1024>",
2239 "SI5 Neighbor List\n" "Add to manual SI5 neighbor list\n"
2240 "Delete from SI5 manual neighbor list\n" "ARFCN of neighbor\n"
2241 "ARFCN of neighbor\n")
2242{
2243 struct gsm_bts *bts = vty->index;
2244 struct bitvec *bv = &bts->si_common.si5_neigh_list;
2245 uint16_t arfcn = atoi(argv[1]);
2246
2247 if (!bts->neigh_list_manual_mode) {
2248 vty_out(vty, "%% Cannot configure neighbor list in "
2249 "automatic mode%s", VTY_NEWLINE);
2250 return CMD_WARNING;
2251 }
2252
2253 if (!strcmp(argv[0], "add"))
2254 bitvec_set_bit_pos(bv, arfcn, 1);
2255 else
2256 bitvec_set_bit_pos(bv, arfcn, 0);
2257
2258 return CMD_SUCCESS;
2259}
2260
2261#define TRX_TEXT "Radio Transceiver\n"
2262
2263/* per TRX configuration */
2264DEFUN(cfg_trx,
2265 cfg_trx_cmd,
2266 "trx TRX_NR",
2267 TRX_TEXT
2268 "Select a TRX to configure")
2269{
2270 int trx_nr = atoi(argv[0]);
2271 struct gsm_bts *bts = vty->index;
2272 struct gsm_bts_trx *trx;
2273
2274 if (trx_nr > bts->num_trx) {
2275 vty_out(vty, "%% The next unused TRX number in this BTS is %u%s",
2276 bts->num_trx, VTY_NEWLINE);
2277 return CMD_WARNING;
2278 } else if (trx_nr == bts->num_trx) {
2279 /* we need to allocate a new one */
2280 trx = gsm_bts_trx_alloc(bts);
2281 } else
2282 trx = gsm_bts_trx_num(bts, trx_nr);
2283
2284 if (!trx)
2285 return CMD_WARNING;
2286
2287 vty->index = trx;
2288 vty->index_sub = &trx->description;
2289 vty->node = TRX_NODE;
2290
2291 return CMD_SUCCESS;
2292}
2293
2294DEFUN(cfg_trx_arfcn,
2295 cfg_trx_arfcn_cmd,
2296 "arfcn <0-1024>",
2297 "Set the ARFCN for this TRX\n")
2298{
2299 int arfcn = atoi(argv[0]);
2300 struct gsm_bts_trx *trx = vty->index;
2301
2302 /* FIXME: check if this ARFCN is supported by this TRX */
2303
2304 trx->arfcn = arfcn;
2305
2306 /* FIXME: patch ARFCN into SYSTEM INFORMATION */
2307 /* FIXME: use OML layer to update the ARFCN */
2308 /* FIXME: use RSL layer to update SYSTEM INFORMATION */
2309
2310 return CMD_SUCCESS;
2311}
2312
2313DEFUN(cfg_trx_nominal_power,
2314 cfg_trx_nominal_power_cmd,
2315 "nominal power <0-100>",
2316 "Nominal TRX RF Power in dB\n")
2317{
2318 struct gsm_bts_trx *trx = vty->index;
2319
2320 trx->nominal_power = atoi(argv[0]);
2321
2322 return CMD_SUCCESS;
2323}
2324
2325DEFUN(cfg_trx_max_power_red,
2326 cfg_trx_max_power_red_cmd,
2327 "max_power_red <0-100>",
2328 "Reduction of maximum BS RF Power in dB\n")
2329{
2330 int maxpwr_r = atoi(argv[0]);
2331 struct gsm_bts_trx *trx = vty->index;
2332 int upper_limit = 24; /* default 12.21 max power red. */
2333
2334 /* FIXME: check if our BTS type supports more than 12 */
2335 if (maxpwr_r < 0 || maxpwr_r > upper_limit) {
2336 vty_out(vty, "%% Power %d dB is not in the valid range%s",
2337 maxpwr_r, VTY_NEWLINE);
2338 return CMD_WARNING;
2339 }
2340 if (maxpwr_r & 1) {
2341 vty_out(vty, "%% Power %d dB is not an even value%s",
2342 maxpwr_r, VTY_NEWLINE);
2343 return CMD_WARNING;
2344 }
2345
2346 trx->max_power_red = maxpwr_r;
2347
2348 /* FIXME: make sure we update this using OML */
2349
2350 return CMD_SUCCESS;
2351}
2352
2353DEFUN(cfg_trx_rsl_e1,
2354 cfg_trx_rsl_e1_cmd,
2355 "rsl e1 line E1_LINE timeslot <1-31> sub-slot (0|1|2|3|full)",
2356 "E1 interface to be used for RSL\n")
2357{
2358 struct gsm_bts_trx *trx = vty->index;
2359
2360 parse_e1_link(&trx->rsl_e1_link, argv[0], argv[1], argv[2]);
2361
2362 return CMD_SUCCESS;
2363}
2364
2365DEFUN(cfg_trx_rsl_e1_tei,
2366 cfg_trx_rsl_e1_tei_cmd,
2367 "rsl e1 tei <0-63>",
2368 "Set the TEI to be used for RSL")
2369{
2370 struct gsm_bts_trx *trx = vty->index;
2371
2372 trx->rsl_tei = atoi(argv[0]);
2373
2374 return CMD_SUCCESS;
2375}
2376
2377DEFUN(cfg_trx_rf_locked,
2378 cfg_trx_rf_locked_cmd,
2379 "rf_locked (0|1)",
2380 "Turn off RF of the TRX.\n")
2381{
2382 int locked = atoi(argv[0]);
2383 struct gsm_bts_trx *trx = vty->index;
2384
2385 gsm_trx_lock_rf(trx, locked);
2386 return CMD_SUCCESS;
2387}
2388
2389/* per TS configuration */
2390DEFUN(cfg_ts,
2391 cfg_ts_cmd,
2392 "timeslot <0-7>",
2393 "Select a Timeslot to configure")
2394{
2395 int ts_nr = atoi(argv[0]);
2396 struct gsm_bts_trx *trx = vty->index;
2397 struct gsm_bts_trx_ts *ts;
2398
2399 if (ts_nr >= TRX_NR_TS) {
2400 vty_out(vty, "%% A GSM TRX only has %u Timeslots per TRX%s",
2401 TRX_NR_TS, VTY_NEWLINE);
2402 return CMD_WARNING;
2403 }
2404
2405 ts = &trx->ts[ts_nr];
2406
2407 vty->index = ts;
2408 vty->node = TS_NODE;
2409
2410 return CMD_SUCCESS;
2411}
2412
2413DEFUN(cfg_ts_pchan,
2414 cfg_ts_pchan_cmd,
2415 "phys_chan_config PCHAN",
2416 "Physical Channel configuration (TCH/SDCCH/...)")
2417{
2418 struct gsm_bts_trx_ts *ts = vty->index;
2419 int pchanc;
2420
2421 pchanc = gsm_pchan_parse(argv[0]);
2422 if (pchanc < 0)
2423 return CMD_WARNING;
2424
2425 ts->pchan = pchanc;
2426
2427 return CMD_SUCCESS;
2428}
2429
2430#define HOPPING_STR "Configure frequency hopping\n"
2431
2432DEFUN(cfg_ts_hopping,
2433 cfg_ts_hopping_cmd,
2434 "hopping enabled (0|1)",
2435 HOPPING_STR "Enable or disable frequency hopping\n"
2436 "Disable frequency hopping\n" "Enable frequency hopping\n")
2437{
2438 struct gsm_bts_trx_ts *ts = vty->index;
2439 int enabled = atoi(argv[0]);
2440
2441 if (enabled && !gsm_bts_has_feature(ts->trx->bts, BTS_FEAT_HOPPING)) {
2442 vty_out(vty, "BTS model does not support hopping%s",
2443 VTY_NEWLINE);
2444 return CMD_WARNING;
2445 }
2446
2447 ts->hopping.enabled = enabled;
2448
2449 return CMD_SUCCESS;
2450}
2451
2452DEFUN(cfg_ts_hsn,
2453 cfg_ts_hsn_cmd,
2454 "hopping sequence-number <0-63>",
2455 HOPPING_STR
2456 "Which hopping sequence to use for this channel")
2457{
2458 struct gsm_bts_trx_ts *ts = vty->index;
2459
2460 ts->hopping.hsn = atoi(argv[0]);
2461
2462 return CMD_SUCCESS;
2463}
2464
2465DEFUN(cfg_ts_maio,
2466 cfg_ts_maio_cmd,
2467 "hopping maio <0-63>",
2468 HOPPING_STR
2469 "Which hopping MAIO to use for this channel")
2470{
2471 struct gsm_bts_trx_ts *ts = vty->index;
2472
2473 ts->hopping.maio = atoi(argv[0]);
2474
2475 return CMD_SUCCESS;
2476}
2477
2478DEFUN(cfg_ts_arfcn_add,
2479 cfg_ts_arfcn_add_cmd,
2480 "hopping arfcn add <0-1023>",
2481 HOPPING_STR "Configure hopping ARFCN list\n"
2482 "Add an entry to the hopping ARFCN list\n" "ARFCN\n")
2483{
2484 struct gsm_bts_trx_ts *ts = vty->index;
2485 int arfcn = atoi(argv[0]);
2486
2487 bitvec_set_bit_pos(&ts->hopping.arfcns, arfcn, 1);
2488
2489 return CMD_SUCCESS;
2490}
2491
2492DEFUN(cfg_ts_arfcn_del,
2493 cfg_ts_arfcn_del_cmd,
2494 "hopping arfcn del <0-1023>",
2495 HOPPING_STR "Configure hopping ARFCN list\n"
2496 "Delete an entry to the hopping ARFCN list\n" "ARFCN\n")
2497{
2498 struct gsm_bts_trx_ts *ts = vty->index;
2499 int arfcn = atoi(argv[0]);
2500
2501 bitvec_set_bit_pos(&ts->hopping.arfcns, arfcn, 0);
2502
2503 return CMD_SUCCESS;
2504}
2505
2506DEFUN(cfg_ts_e1_subslot,
2507 cfg_ts_e1_subslot_cmd,
2508 "e1 line E1_LINE timeslot <1-31> sub-slot (0|1|2|3|full)",
2509 "E1 sub-slot connected to this on-air timeslot")
2510{
2511 struct gsm_bts_trx_ts *ts = vty->index;
2512
2513 parse_e1_link(&ts->e1_link, argv[0], argv[1], argv[2]);
2514
2515 return CMD_SUCCESS;
2516}
2517
2518void openbsc_vty_print_statistics(struct vty *vty, struct gsm_network *net)
2519{
2520 vty_out(vty, "Channel Requests : %lu total, %lu no channel%s",
2521 counter_get(net->stats.chreq.total),
2522 counter_get(net->stats.chreq.no_channel), VTY_NEWLINE);
2523 vty_out(vty, "Channel Failures : %lu rf_failures, %lu rll failures%s",
2524 counter_get(net->stats.chan.rf_fail),
2525 counter_get(net->stats.chan.rll_err), VTY_NEWLINE);
2526 vty_out(vty, "Paging : %lu attempted, %lu complete, %lu expired%s",
2527 counter_get(net->stats.paging.attempted),
2528 counter_get(net->stats.paging.completed),
2529 counter_get(net->stats.paging.expired), VTY_NEWLINE);
2530 vty_out(vty, "BTS failures : %lu OML, %lu RSL%s",
2531 counter_get(net->stats.bts.oml_fail),
2532 counter_get(net->stats.bts.rsl_fail), VTY_NEWLINE);
2533}
2534
2535DEFUN(logging_fltr_imsi,
2536 logging_fltr_imsi_cmd,
2537 "logging filter imsi IMSI",
2538 LOGGING_STR FILTER_STR
2539 "Filter log messages by IMSI\n" "IMSI to be used as filter\n")
2540{
2541 struct log_target *tgt = osmo_log_vty2tgt(vty);
2542
2543 if (!tgt)
2544 return CMD_WARNING;
2545
2546 log_set_imsi_filter(tgt, argv[0]);
2547 return CMD_SUCCESS;
2548}
2549
2550
2551DEFUN(drop_bts,
2552 drop_bts_cmd,
2553 "drop bts connection <0-65535> (oml|rsl)",
2554 "Debug/Simulation command to drop ipaccess BTS\n"
2555 "BTS NR\n" "Connection Type\n")
2556{
2557 struct gsm_network *gsmnet;
2558 struct gsm_bts_trx *trx;
2559 struct gsm_bts *bts;
2560 unsigned int bts_nr;
2561
2562 gsmnet = gsmnet_from_vty(vty);
2563
2564 bts_nr = atoi(argv[0]);
2565 if (bts_nr >= gsmnet->num_bts) {
2566 vty_out(vty, "BTS number must be between 0 and %d. It was %d.%s",
2567 gsmnet->num_bts, bts_nr, VTY_NEWLINE);
2568 return CMD_WARNING;
2569 }
2570
2571 bts = gsm_bts_num(gsmnet, bts_nr);
2572 if (!bts) {
2573 vty_out(vty, "BTS Nr. %d could not be found.%s", bts_nr, VTY_NEWLINE);
2574 return CMD_WARNING;
2575 }
2576
2577 if (!is_ipaccess_bts(bts)) {
2578 vty_out(vty, "This command only works for ipaccess.%s", VTY_NEWLINE);
2579 return CMD_WARNING;
2580 }
2581
2582
2583 /* close all connections */
2584 if (strcmp(argv[1], "oml") == 0) {
2585 ipaccess_drop_oml(bts);
2586 } else if (strcmp(argv[1], "rsl") == 0) {
2587 /* close all rsl connections */
2588 llist_for_each_entry(trx, &bts->trx_list, list) {
2589 ipaccess_drop_rsl(trx);
2590 }
2591 } else {
2592 vty_out(vty, "Argument must be 'oml# or 'rsl'.%s", VTY_NEWLINE);
2593 return CMD_WARNING;
2594 }
2595
2596 return CMD_SUCCESS;
2597}
2598
2599DEFUN(pdch_act, pdch_act_cmd,
2600 "bts <0-255> trx <0-255> timeslot <0-7> pdch (activate|deactivate)",
2601 "BTS related commands\n" "BTS Number\n" "Transceiver\n" "Transceiver Number\n"
2602 "TRX Timeslot\n" "Timeslot Number\n" "Packet Data Channel\n"
2603 "Activate Dynamic PDCH/TCH (-> PDCH mode)\n"
2604 "Deactivate Dynamic PDCH/TCH (-> TCH mode)\n")
2605{
2606 struct gsm_bts *bts;
2607 struct gsm_bts_trx *trx;
2608 struct gsm_bts_trx_ts *ts;
2609 int bts_nr = atoi(argv[0]);
2610 int trx_nr = atoi(argv[1]);
2611 int ts_nr = atoi(argv[2]);
2612 int activate;
2613
2614 bts = gsm_bts_num(bsc_gsmnet, bts_nr);
2615 if (!bts) {
2616 vty_out(vty, "%% No such BTS (%d)%s", bts_nr, VTY_NEWLINE);
2617 return CMD_WARNING;
2618 }
2619
2620 if (!is_ipaccess_bts(bts)) {
2621 vty_out(vty, "%% This command only works for ipaccess BTS%s",
2622 VTY_NEWLINE);
2623 return CMD_WARNING;
2624 }
2625
2626 trx = gsm_bts_trx_num(bts, trx_nr);
2627 if (!trx) {
2628 vty_out(vty, "%% No such TRX (%d)%s", trx_nr, VTY_NEWLINE);
2629 return CMD_WARNING;
2630 }
2631
2632 ts = &trx->ts[ts_nr];
2633 if (ts->pchan != GSM_PCHAN_TCH_F_PDCH) {
2634 vty_out(vty, "%% Timeslot %u is not in dynamic TCH_F/PDCH "
2635 "mode%s", ts_nr, VTY_NEWLINE);
2636 return CMD_WARNING;
2637 }
2638
2639 if (!strcmp(argv[3], "activate"))
2640 activate = 1;
2641 else
2642 activate = 0;
2643
2644 rsl_ipacc_pdch_activate(ts, activate);
2645
2646 return CMD_SUCCESS;
2647
2648}
2649
2650extern int bsc_vty_init_extra(void);
2651extern const char *openbsc_copyright;
2652
2653int bsc_vty_init(void)
2654{
2655 install_element_ve(&show_net_cmd);
2656 install_element_ve(&show_bts_cmd);
2657 install_element_ve(&show_trx_cmd);
2658 install_element_ve(&show_ts_cmd);
2659 install_element_ve(&show_lchan_cmd);
2660 install_element_ve(&show_lchan_summary_cmd);
2661 install_element_ve(&logging_fltr_imsi_cmd);
2662
2663 install_element_ve(&show_e1drv_cmd);
2664 install_element_ve(&show_e1line_cmd);
2665 install_element_ve(&show_e1ts_cmd);
2666
2667 install_element_ve(&show_paging_cmd);
2668
2669 logging_vty_add_cmds();
2670 install_element(CFG_LOG_NODE, &logging_fltr_imsi_cmd);
2671
2672 install_element(CONFIG_NODE, &cfg_net_cmd);
2673 install_node(&net_node, config_write_net);
2674 install_default(GSMNET_NODE);
2675 install_element(GSMNET_NODE, &ournode_exit_cmd);
2676 install_element(GSMNET_NODE, &ournode_end_cmd);
2677 install_element(GSMNET_NODE, &cfg_net_ncc_cmd);
2678 install_element(GSMNET_NODE, &cfg_net_mnc_cmd);
2679 install_element(GSMNET_NODE, &cfg_net_name_short_cmd);
2680 install_element(GSMNET_NODE, &cfg_net_name_long_cmd);
2681 install_element(GSMNET_NODE, &cfg_net_auth_policy_cmd);
2682 install_element(GSMNET_NODE, &cfg_net_reject_cause_cmd);
2683 install_element(GSMNET_NODE, &cfg_net_encryption_cmd);
2684 install_element(GSMNET_NODE, &cfg_net_neci_cmd);
2685 install_element(GSMNET_NODE, &cfg_net_rrlp_mode_cmd);
2686 install_element(GSMNET_NODE, &cfg_net_mm_info_cmd);
2687 install_element(GSMNET_NODE, &cfg_net_handover_cmd);
2688 install_element(GSMNET_NODE, &cfg_net_ho_win_rxlev_avg_cmd);
2689 install_element(GSMNET_NODE, &cfg_net_ho_win_rxqual_avg_cmd);
2690 install_element(GSMNET_NODE, &cfg_net_ho_win_rxlev_avg_neigh_cmd);
2691 install_element(GSMNET_NODE, &cfg_net_ho_pwr_interval_cmd);
2692 install_element(GSMNET_NODE, &cfg_net_ho_pwr_hysteresis_cmd);
2693 install_element(GSMNET_NODE, &cfg_net_ho_max_distance_cmd);
2694 install_element(GSMNET_NODE, &cfg_net_T3101_cmd);
2695 install_element(GSMNET_NODE, &cfg_net_T3103_cmd);
2696 install_element(GSMNET_NODE, &cfg_net_T3105_cmd);
2697 install_element(GSMNET_NODE, &cfg_net_T3107_cmd);
2698 install_element(GSMNET_NODE, &cfg_net_T3109_cmd);
2699 install_element(GSMNET_NODE, &cfg_net_T3111_cmd);
2700 install_element(GSMNET_NODE, &cfg_net_T3113_cmd);
2701 install_element(GSMNET_NODE, &cfg_net_T3115_cmd);
2702 install_element(GSMNET_NODE, &cfg_net_T3117_cmd);
2703 install_element(GSMNET_NODE, &cfg_net_T3119_cmd);
2704 install_element(GSMNET_NODE, &cfg_net_T3122_cmd);
2705 install_element(GSMNET_NODE, &cfg_net_T3141_cmd);
2706 install_element(GSMNET_NODE, &cfg_net_dtx_cmd);
2707 install_element(GSMNET_NODE, &cfg_net_subscr_keep_cmd);
2708 install_element(GSMNET_NODE, &cfg_net_pag_any_tch_cmd);
2709
2710 install_element(GSMNET_NODE, &cfg_bts_cmd);
2711 install_node(&bts_node, config_write_bts);
2712 install_default(BTS_NODE);
2713 install_element(BTS_NODE, &ournode_exit_cmd);
2714 install_element(BTS_NODE, &ournode_end_cmd);
2715 install_element(BTS_NODE, &cfg_bts_type_cmd);
2716 install_element(BTS_NODE, &cfg_description_cmd);
2717 install_element(BTS_NODE, &cfg_no_description_cmd);
2718 install_element(BTS_NODE, &cfg_bts_band_cmd);
2719 install_element(BTS_NODE, &cfg_bts_ci_cmd);
2720 install_element(BTS_NODE, &cfg_bts_lac_cmd);
2721 install_element(BTS_NODE, &cfg_bts_tsc_cmd);
2722 install_element(BTS_NODE, &cfg_bts_bsic_cmd);
2723 install_element(BTS_NODE, &cfg_bts_unit_id_cmd);
2724 install_element(BTS_NODE, &cfg_bts_serno_cmd);
2725 install_element(BTS_NODE, &cfg_bts_stream_id_cmd);
2726 install_element(BTS_NODE, &cfg_bts_oml_e1_cmd);
2727 install_element(BTS_NODE, &cfg_bts_oml_e1_tei_cmd);
2728 install_element(BTS_NODE, &cfg_bts_challoc_cmd);
2729 install_element(BTS_NODE, &cfg_bts_rach_tx_integer_cmd);
2730 install_element(BTS_NODE, &cfg_bts_rach_max_trans_cmd);
2731 install_element(BTS_NODE, &cfg_bts_rach_nm_b_thresh_cmd);
2732 install_element(BTS_NODE, &cfg_bts_rach_nm_ldavg_cmd);
2733 install_element(BTS_NODE, &cfg_bts_cell_barred_cmd);
2734 install_element(BTS_NODE, &cfg_bts_rach_ec_allowed_cmd);
2735 install_element(BTS_NODE, &cfg_bts_ms_max_power_cmd);
2736 install_element(BTS_NODE, &cfg_bts_per_loc_upd_cmd);
2737 install_element(BTS_NODE, &cfg_bts_cell_resel_hyst_cmd);
2738 install_element(BTS_NODE, &cfg_bts_rxlev_acc_min_cmd);
2739 install_element(BTS_NODE, &cfg_bts_cell_bar_qualify_cmd);
2740 install_element(BTS_NODE, &cfg_bts_cell_resel_ofs_cmd);
2741 install_element(BTS_NODE, &cfg_bts_temp_ofs_cmd);
2742 install_element(BTS_NODE, &cfg_bts_temp_ofs_inf_cmd);
2743 install_element(BTS_NODE, &cfg_bts_penalty_time_cmd);
2744 install_element(BTS_NODE, &cfg_bts_penalty_time_rsvd_cmd);
2745 install_element(BTS_NODE, &cfg_bts_gprs_mode_cmd);
2746 install_element(BTS_NODE, &cfg_bts_gprs_ns_timer_cmd);
2747 install_element(BTS_NODE, &cfg_bts_gprs_rac_cmd);
2748 install_element(BTS_NODE, &cfg_bts_gprs_bvci_cmd);
2749 install_element(BTS_NODE, &cfg_bts_gprs_cell_timer_cmd);
2750 install_element(BTS_NODE, &cfg_bts_gprs_nsei_cmd);
2751 install_element(BTS_NODE, &cfg_bts_gprs_nsvci_cmd);
2752 install_element(BTS_NODE, &cfg_bts_gprs_nsvc_lport_cmd);
2753 install_element(BTS_NODE, &cfg_bts_gprs_nsvc_rport_cmd);
2754 install_element(BTS_NODE, &cfg_bts_gprs_nsvc_rip_cmd);
2755 install_element(BTS_NODE, &cfg_bts_pag_free_cmd);
2756 install_element(BTS_NODE, &cfg_bts_si_mode_cmd);
2757 install_element(BTS_NODE, &cfg_bts_si_static_cmd);
2758 install_element(BTS_NODE, &cfg_bts_neigh_mode_cmd);
2759 install_element(BTS_NODE, &cfg_bts_neigh_cmd);
2760 install_element(BTS_NODE, &cfg_bts_si5_neigh_cmd);
2761
2762 install_element(BTS_NODE, &cfg_trx_cmd);
2763 install_node(&trx_node, dummy_config_write);
2764 install_default(TRX_NODE);
2765 install_element(TRX_NODE, &ournode_exit_cmd);
2766 install_element(TRX_NODE, &ournode_end_cmd);
2767 install_element(TRX_NODE, &cfg_trx_arfcn_cmd);
2768 install_element(TRX_NODE, &cfg_description_cmd);
2769 install_element(TRX_NODE, &cfg_no_description_cmd);
2770 install_element(TRX_NODE, &cfg_trx_nominal_power_cmd);
2771 install_element(TRX_NODE, &cfg_trx_max_power_red_cmd);
2772 install_element(TRX_NODE, &cfg_trx_rsl_e1_cmd);
2773 install_element(TRX_NODE, &cfg_trx_rsl_e1_tei_cmd);
2774 install_element(TRX_NODE, &cfg_trx_rf_locked_cmd);
2775
2776 install_element(TRX_NODE, &cfg_ts_cmd);
2777 install_node(&ts_node, dummy_config_write);
2778 install_default(TS_NODE);
2779 install_element(TS_NODE, &ournode_exit_cmd);
2780 install_element(TS_NODE, &ournode_end_cmd);
2781 install_element(TS_NODE, &cfg_ts_pchan_cmd);
2782 install_element(TS_NODE, &cfg_ts_hopping_cmd);
2783 install_element(TS_NODE, &cfg_ts_hsn_cmd);
2784 install_element(TS_NODE, &cfg_ts_maio_cmd);
2785 install_element(TS_NODE, &cfg_ts_arfcn_add_cmd);
2786 install_element(TS_NODE, &cfg_ts_arfcn_del_cmd);
2787 install_element(TS_NODE, &cfg_ts_e1_subslot_cmd);
2788
2789 install_element(ENABLE_NODE, &drop_bts_cmd);
2790 install_element(ENABLE_NODE, &pdch_act_cmd);
2791
2792 abis_nm_vty_init();
2793 abis_om2k_vty_init();
2794 e1inp_vty_init();
2795
2796 bsc_vty_init_extra();
2797
2798 return 0;
2799}