blob: f56440ec1858c8645ff25b1da17662b5aa544c21 [file] [log] [blame]
Harald Welte59b04682009-06-10 05:40:52 +08001/* OpenBSC interface to quagga VTY */
Harald Welte410575a2010-03-14 23:30:30 +08002/* (C) 2009-2010 by Harald Welte <laforge@gnumonks.org>
Harald Welte59b04682009-06-10 05:40:52 +08003 * All Rights Reserved
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 */
20
21#include <stdlib.h>
22#include <unistd.h>
23#include <sys/types.h>
24
Harald Weltebd9591f2010-05-19 19:45:32 +020025#include <osmocom/vty/command.h>
26#include <osmocom/vty/buffer.h>
27#include <osmocom/vty/vty.h>
28#include <osmocom/vty/logging.h>
29#include <osmocom/vty/telnet_interface.h>
Harald Welte59b04682009-06-10 05:40:52 +080030
31#include <arpa/inet.h>
32
Harald Weltef4625b12010-02-20 16:24:02 +010033#include <osmocore/linuxlist.h>
Harald Welte59b04682009-06-10 05:40:52 +080034#include <openbsc/gsm_data.h>
Harald Welte59b04682009-06-10 05:40:52 +080035#include <openbsc/e1_input.h>
36#include <openbsc/abis_nm.h>
Harald Welted8acf142010-07-30 11:50:09 +020037#include <osmocore/utils.h>
Harald Weltef4625b12010-02-20 16:24:02 +010038#include <osmocore/gsm_utils.h>
Harald Weltefe96f382009-12-22 13:09:29 +010039#include <openbsc/chan_alloc.h>
Harald Welte44007742009-12-22 21:43:14 +010040#include <openbsc/meas_rep.h>
Harald Welte59b04682009-06-10 05:40:52 +080041#include <openbsc/db.h>
Harald Weltef4625b12010-02-20 16:24:02 +010042#include <osmocore/talloc.h>
Holger Hans Peter Freytherb70d45b2010-04-06 11:55:37 +020043#include <openbsc/vty.h>
Harald Weltef45981f2010-05-12 20:28:04 +020044#include <openbsc/gprs_ns.h>
Harald Welted8acf142010-07-30 11:50:09 +020045#include <openbsc/system_information.h>
Harald Welte682ee5f2010-05-16 22:02:16 +020046#include <openbsc/debug.h>
Harald Welte59b04682009-06-10 05:40:52 +080047
Harald Welte10c29f62010-05-16 19:20:24 +020048#include "../bscconfig.h"
49
Harald Welted6b62e32010-05-12 17:19:53 +000050/* FIXME: this should go to some common file */
51static const struct value_string gprs_ns_timer_strs[] = {
Harald Weltea9251762010-05-11 23:50:21 +020052 { 0, "tns-block" },
53 { 1, "tns-block-retries" },
54 { 2, "tns-reset" },
55 { 3, "tns-reset-retries" },
56 { 4, "tns-test" },
57 { 5, "tns-alive" },
58 { 6, "tns-alive-retries" },
59 { 0, NULL }
60};
61
Harald Welted6b62e32010-05-12 17:19:53 +000062static const struct value_string gprs_bssgp_cfg_strs[] = {
Harald Weltea9251762010-05-11 23:50:21 +020063 { 0, "blocking-timer" },
64 { 1, "blocking-retries" },
65 { 2, "unblocking-retries" },
66 { 3, "reset-timer" },
67 { 4, "reset-retries" },
68 { 5, "suspend-timer" },
69 { 6, "suspend-retries" },
70 { 7, "resume-timer" },
71 { 8, "resume-retries" },
72 { 9, "capability-update-timer" },
73 { 10, "capability-update-retries" },
74 { 0, NULL }
75};
76
Harald Weltee87eb462009-08-07 13:29:14 +020077struct cmd_node net_node = {
78 GSMNET_NODE,
79 "%s(network)#",
80 1,
81};
82
Harald Welte59b04682009-06-10 05:40:52 +080083struct cmd_node bts_node = {
84 BTS_NODE,
85 "%s(bts)#",
86 1,
87};
88
89struct cmd_node trx_node = {
90 TRX_NODE,
91 "%s(trx)#",
92 1,
93};
94
95struct cmd_node ts_node = {
96 TS_NODE,
97 "%s(ts)#",
98 1,
99};
100
Harald Welte61daf6d2010-05-27 13:39:40 +0200101extern struct gsm_network *bsc_gsmnet;
102
Harald Welte40152872010-05-16 20:52:23 +0200103struct gsm_network *gsmnet_from_vty(struct vty *v)
104{
Harald Welte61daf6d2010-05-27 13:39:40 +0200105 /* In case we read from the config file, the vty->priv cannot
106 * point to a struct telnet_connection, and thus conn->priv
107 * will not point to the gsm_network structure */
108#if 0
Harald Welte40152872010-05-16 20:52:23 +0200109 struct telnet_connection *conn = v->priv;
110 return (struct gsm_network *) conn->priv;
Harald Welte61daf6d2010-05-27 13:39:40 +0200111#else
112 return bsc_gsmnet;
113#endif
Harald Welte40152872010-05-16 20:52:23 +0200114}
115
Harald Welte59b04682009-06-10 05:40:52 +0800116static int dummy_config_write(struct vty *v)
117{
118 return CMD_SUCCESS;
119}
120
121static void net_dump_nmstate(struct vty *vty, struct gsm_nm_state *nms)
122{
123 vty_out(vty,"Oper '%s', Admin %u, Avail '%s'%s",
124 nm_opstate_name(nms->operational), nms->administrative,
125 nm_avail_name(nms->availability), VTY_NEWLINE);
126}
127
Harald Weltefe96f382009-12-22 13:09:29 +0100128static void dump_pchan_load_vty(struct vty *vty, char *prefix,
129 const struct pchan_load *pl)
130{
131 int i;
132
133 for (i = 0; i < ARRAY_SIZE(pl->pchan); i++) {
134 const struct load_counter *lc = &pl->pchan[i];
135 unsigned int percent;
136
137 if (lc->total == 0)
138 continue;
139
140 percent = (lc->used * 100) / lc->total;
141
142 vty_out(vty, "%s%20s: %3u%% (%u/%u)%s", prefix,
143 gsm_pchan_name(i), percent, lc->used, lc->total,
144 VTY_NEWLINE);
145 }
146}
147
Harald Welte59b04682009-06-10 05:40:52 +0800148static void net_dump_vty(struct vty *vty, struct gsm_network *net)
149{
Harald Weltefe96f382009-12-22 13:09:29 +0100150 struct pchan_load pl;
151
Harald Welte59b04682009-06-10 05:40:52 +0800152 vty_out(vty, "BSC is on Country Code %u, Network Code %u "
153 "and has %u BTS%s", net->country_code, net->network_code,
154 net->num_bts, VTY_NEWLINE);
155 vty_out(vty, " Long network name: '%s'%s",
156 net->name_long, VTY_NEWLINE);
157 vty_out(vty, " Short network name: '%s'%s",
158 net->name_short, VTY_NEWLINE);
Harald Welte (local)a59a27e2009-08-12 14:42:23 +0200159 vty_out(vty, " Authentication policy: %s%s",
160 gsm_auth_policy_name(net->auth_policy), VTY_NEWLINE);
Harald Welte59936d72009-11-18 20:33:19 +0100161 vty_out(vty, " Location updating reject cause: %u%s",
162 net->reject_cause, VTY_NEWLINE);
Harald Weltecca253a2009-08-30 15:47:06 +0900163 vty_out(vty, " Encryption: A5/%u%s", net->a5_encryption,
164 VTY_NEWLINE);
Holger Hans Peter Freyther96c89822009-11-16 17:12:38 +0100165 vty_out(vty, " NECI (TCH/H): %u%s", net->neci,
166 VTY_NEWLINE);
Harald Welte52af1952009-12-13 10:53:12 +0100167 vty_out(vty, " RRLP Mode: %s%s", rrlp_mode_name(net->rrlp.mode),
168 VTY_NEWLINE);
Harald Weltea310f3e2009-12-14 09:00:24 +0100169 vty_out(vty, " MM Info: %s%s", net->send_mm_info ? "On" : "Off",
170 VTY_NEWLINE);
Harald Welte0af9c9f2009-12-19 21:41:52 +0100171 vty_out(vty, " Handover: %s%s", net->handover.active ? "On" : "Off",
172 VTY_NEWLINE);
Harald Weltefe96f382009-12-22 13:09:29 +0100173 network_chan_load(&pl, net);
174 vty_out(vty, " Current Channel Load:%s", VTY_NEWLINE);
175 dump_pchan_load_vty(vty, " ", &pl);
Harald Welte59b04682009-06-10 05:40:52 +0800176}
177
178DEFUN(show_net, show_net_cmd, "show network",
179 SHOW_STR "Display information about a GSM NETWORK\n")
180{
Harald Welte40152872010-05-16 20:52:23 +0200181 struct gsm_network *net = gsmnet_from_vty(vty);
Harald Welte59b04682009-06-10 05:40:52 +0800182 net_dump_vty(vty, net);
183
184 return CMD_SUCCESS;
185}
186
187static void e1isl_dump_vty(struct vty *vty, struct e1inp_sign_link *e1l)
188{
189 struct e1inp_line *line;
190
191 if (!e1l) {
192 vty_out(vty, " None%s", VTY_NEWLINE);
193 return;
194 }
195
196 line = e1l->ts->line;
197
198 vty_out(vty, " E1 Line %u, Type %s: Timeslot %u, Mode %s%s",
199 line->num, line->driver->name, e1l->ts->num,
200 e1inp_signtype_name(e1l->type), VTY_NEWLINE);
201 vty_out(vty, " E1 TEI %u, SAPI %u%s",
202 e1l->tei, e1l->sapi, VTY_NEWLINE);
203}
204
205static void bts_dump_vty(struct vty *vty, struct gsm_bts *bts)
206{
Harald Weltefe96f382009-12-22 13:09:29 +0100207 struct pchan_load pl;
208
Holger Hans Peter Freythera098dfb2009-08-21 14:44:12 +0200209 vty_out(vty, "BTS %u is of %s type in band %s, has CI %u LAC %u, "
Harald Welte91afe4c2009-06-20 18:15:19 +0200210 "BSIC %u, TSC %u and %u TRX%s",
211 bts->nr, btstype2str(bts->type), gsm_band_name(bts->band),
Holger Hans Peter Freythera098dfb2009-08-21 14:44:12 +0200212 bts->cell_identity,
Holger Hans Peter Freyther71135142010-03-29 08:47:44 +0200213 bts->location_area_code, bts->bsic, bts->tsc,
Harald Welte91afe4c2009-06-20 18:15:19 +0200214 bts->num_trx, VTY_NEWLINE);
Harald Welte8791dac2010-05-14 17:59:53 +0200215 vty_out(vty, "Description: %s%s",
216 bts->description ? bts->description : "(null)", VTY_NEWLINE);
Harald Welte8e9d1792009-12-12 15:38:16 +0100217 vty_out(vty, "MS Max power: %u dBm%s", bts->ms_max_power, VTY_NEWLINE);
Harald Welteb761bf82009-12-12 18:17:25 +0100218 vty_out(vty, "Minimum Rx Level for Access: %i dBm%s",
Harald Welte8e9d1792009-12-12 15:38:16 +0100219 rxlev2dbm(bts->si_common.cell_sel_par.rxlev_acc_min),
220 VTY_NEWLINE);
221 vty_out(vty, "Cell Reselection Hysteresis: %u dBm%s",
Harald Welteb761bf82009-12-12 18:17:25 +0100222 bts->si_common.cell_sel_par.cell_resel_hyst*2, VTY_NEWLINE);
Sylvain Munaut8e2d8de2009-12-22 13:43:26 +0100223 vty_out(vty, "RACH TX-Integer: %u%s", bts->si_common.rach_control.tx_integer,
224 VTY_NEWLINE);
225 vty_out(vty, "RACH Max transmissions: %u%s",
226 rach_max_trans_raw2val(bts->si_common.rach_control.max_trans),
227 VTY_NEWLINE);
Harald Welte8c973ba2009-12-21 23:08:18 +0100228 if (bts->si_common.rach_control.cell_bar)
Harald Welte (local)e19be3f2009-08-12 13:28:23 +0200229 vty_out(vty, " CELL IS BARRED%s", VTY_NEWLINE);
Harald Welted8acf142010-07-30 11:50:09 +0200230 vty_out(vty, "System Information present: 0x%08x, static: 0x%08x%s",
231 bts->si_valid, bts->si_mode_static, VTY_NEWLINE);
Harald Welte59b04682009-06-10 05:40:52 +0800232 if (is_ipaccess_bts(bts))
Harald Welte25572872009-10-20 00:22:00 +0200233 vty_out(vty, " Unit ID: %u/%u/0, OML Stream ID 0x%02x%s",
Harald Welte59b04682009-06-10 05:40:52 +0800234 bts->ip_access.site_id, bts->ip_access.bts_id,
Harald Welte25572872009-10-20 00:22:00 +0200235 bts->oml_tei, VTY_NEWLINE);
Harald Welte59b04682009-06-10 05:40:52 +0800236 vty_out(vty, " NM State: ");
237 net_dump_nmstate(vty, &bts->nm_state);
238 vty_out(vty, " Site Mgr NM State: ");
239 net_dump_nmstate(vty, &bts->site_mgr.nm_state);
240 vty_out(vty, " Paging: FIXME pending requests, %u free slots%s",
241 bts->paging.available_slots, VTY_NEWLINE);
Harald Welte25572872009-10-20 00:22:00 +0200242 if (!is_ipaccess_bts(bts)) {
243 vty_out(vty, " E1 Signalling Link:%s", VTY_NEWLINE);
244 e1isl_dump_vty(vty, bts->oml_link);
245 }
Harald Welte59b04682009-06-10 05:40:52 +0800246 /* FIXME: oml_link, chan_desc */
Harald Weltefe96f382009-12-22 13:09:29 +0100247 memset(&pl, 0, sizeof(pl));
248 bts_chan_load(&pl, bts);
249 vty_out(vty, " Current Channel Load:%s", VTY_NEWLINE);
250 dump_pchan_load_vty(vty, " ", &pl);
Harald Welte59b04682009-06-10 05:40:52 +0800251}
252
253DEFUN(show_bts, show_bts_cmd, "show bts [number]",
254 SHOW_STR "Display information about a BTS\n"
255 "BTS number")
256{
Harald Welte40152872010-05-16 20:52:23 +0200257 struct gsm_network *net = gsmnet_from_vty(vty);
Harald Welte59b04682009-06-10 05:40:52 +0800258 int bts_nr;
259
260 if (argc != 0) {
261 /* use the BTS number that the user has specified */
262 bts_nr = atoi(argv[0]);
263 if (bts_nr > net->num_bts) {
264 vty_out(vty, "%% can't find BTS '%s'%s", argv[0],
265 VTY_NEWLINE);
266 return CMD_WARNING;
267 }
Harald Weltee712a5f2009-06-21 16:17:15 +0200268 bts_dump_vty(vty, gsm_bts_num(net, bts_nr));
Harald Welte59b04682009-06-10 05:40:52 +0800269 return CMD_SUCCESS;
270 }
271 /* print all BTS's */
272 for (bts_nr = 0; bts_nr < net->num_bts; bts_nr++)
Harald Weltee712a5f2009-06-21 16:17:15 +0200273 bts_dump_vty(vty, gsm_bts_num(net, bts_nr));
Harald Welte59b04682009-06-10 05:40:52 +0800274
275 return CMD_SUCCESS;
276}
277
Harald Welte62868882009-08-08 16:12:58 +0200278/* utility functions */
279static void parse_e1_link(struct gsm_e1_subslot *e1_link, const char *line,
280 const char *ts, const char *ss)
281{
282 e1_link->e1_nr = atoi(line);
283 e1_link->e1_ts = atoi(ts);
284 if (!strcmp(ss, "full"))
285 e1_link->e1_ts_ss = 255;
286 else
287 e1_link->e1_ts_ss = atoi(ss);
288}
289
290static void config_write_e1_link(struct vty *vty, struct gsm_e1_subslot *e1_link,
291 const char *prefix)
292{
293 if (!e1_link->e1_ts)
294 return;
295
296 if (e1_link->e1_ts_ss == 255)
297 vty_out(vty, "%se1 line %u timeslot %u sub-slot full%s",
298 prefix, e1_link->e1_nr, e1_link->e1_ts, VTY_NEWLINE);
299 else
300 vty_out(vty, "%se1 line %u timeslot %u sub-slot %u%s",
301 prefix, e1_link->e1_nr, e1_link->e1_ts,
302 e1_link->e1_ts_ss, VTY_NEWLINE);
303}
304
305
Harald Welte97ceef92009-08-06 19:06:46 +0200306static void config_write_ts_single(struct vty *vty, struct gsm_bts_trx_ts *ts)
307{
Harald Welte62868882009-08-08 16:12:58 +0200308 vty_out(vty, " timeslot %u%s", ts->nr, VTY_NEWLINE);
309 if (ts->pchan != GSM_PCHAN_NONE)
310 vty_out(vty, " phys_chan_config %s%s",
311 gsm_pchan_name(ts->pchan), VTY_NEWLINE);
Harald Weltea42a93f2010-06-14 22:26:10 +0200312 vty_out(vty, " hopping enabled %u%s",
313 ts->hopping.enabled, VTY_NEWLINE);
314 if (ts->hopping.enabled) {
315 unsigned int i;
316 vty_out(vty, " hopping sequence-number %u%s",
Harald Welte67104d12009-09-12 13:05:33 +0200317 ts->hopping.hsn, VTY_NEWLINE);
Harald Weltea42a93f2010-06-14 22:26:10 +0200318 vty_out(vty, " hopping maio %u%s",
Harald Welte67104d12009-09-12 13:05:33 +0200319 ts->hopping.maio, VTY_NEWLINE);
Harald Weltea42a93f2010-06-14 22:26:10 +0200320 for (i = 0; i < ts->hopping.arfcns.data_len*8; i++) {
321 if (!bitvec_get_bit_pos(&ts->hopping.arfcns, i))
322 continue;
323 vty_out(vty, " hopping arfcn add %u%s",
324 i, VTY_NEWLINE);
325 }
326 } else
Harald Welte62868882009-08-08 16:12:58 +0200327 config_write_e1_link(vty, &ts->e1_link, " ");
Harald Welte97ceef92009-08-06 19:06:46 +0200328}
329
330static void config_write_trx_single(struct vty *vty, struct gsm_bts_trx *trx)
331{
332 int i;
333
Harald Weltee87eb462009-08-07 13:29:14 +0200334 vty_out(vty, " trx %u%s", trx->nr, VTY_NEWLINE);
Harald Welte8791dac2010-05-14 17:59:53 +0200335 if (trx->description)
336 vty_out(vty, " description %s%s", trx->description,
337 VTY_NEWLINE);
Holger Hans Peter Freyther32be2aa2010-04-17 06:42:07 +0200338 vty_out(vty, " rf_locked %u%s",
339 trx->nm_state.administrative == NM_STATE_LOCKED ? 1 : 0,
340 VTY_NEWLINE);
Harald Weltee87eb462009-08-07 13:29:14 +0200341 vty_out(vty, " arfcn %u%s", trx->arfcn, VTY_NEWLINE);
Harald Welte (local)b709bfe2009-12-27 20:56:38 +0100342 vty_out(vty, " nominal power %u%s", trx->nominal_power, VTY_NEWLINE);
Harald Weltee87eb462009-08-07 13:29:14 +0200343 vty_out(vty, " max_power_red %u%s", trx->max_power_red, VTY_NEWLINE);
Harald Welte62868882009-08-08 16:12:58 +0200344 config_write_e1_link(vty, &trx->rsl_e1_link, " rsl ");
345 vty_out(vty, " rsl e1 tei %u%s", trx->rsl_tei, VTY_NEWLINE);
Harald Welte97ceef92009-08-06 19:06:46 +0200346
347 for (i = 0; i < TRX_NR_TS; i++)
348 config_write_ts_single(vty, &trx->ts[i]);
349}
350
Harald Weltea9251762010-05-11 23:50:21 +0200351static void config_write_bts_gprs(struct vty *vty, struct gsm_bts *bts)
352{
353 unsigned int i;
354 vty_out(vty, " gprs mode %s%s", bts_gprs_mode_name(bts->gprs.mode),
355 VTY_NEWLINE);
356 if (bts->gprs.mode == BTS_GPRS_NONE)
357 return;
358
359 vty_out(vty, " gprs routing area %u%s", bts->gprs.rac,
360 VTY_NEWLINE);
361 vty_out(vty, " gprs cell bvci %u%s", bts->gprs.cell.bvci,
362 VTY_NEWLINE);
363 for (i = 0; i < ARRAY_SIZE(bts->gprs.cell.timer); i++)
364 vty_out(vty, " gprs cell timer %s %u%s",
365 get_value_string(gprs_bssgp_cfg_strs, i),
366 bts->gprs.cell.timer[i], VTY_NEWLINE);
367 vty_out(vty, " gprs nsei %u%s", bts->gprs.nse.nsei,
368 VTY_NEWLINE);
369 for (i = 0; i < ARRAY_SIZE(bts->gprs.nse.timer); i++)
370 vty_out(vty, " gprs ns timer %s %u%s",
371 get_value_string(gprs_ns_timer_strs, i),
372 bts->gprs.nse.timer[i], VTY_NEWLINE);
373 for (i = 0; i < ARRAY_SIZE(bts->gprs.nsvc); i++) {
374 struct gsm_bts_gprs_nsvc *nsvc =
375 &bts->gprs.nsvc[i];
376 struct in_addr ia;
377
378 ia.s_addr = htonl(nsvc->remote_ip);
379 vty_out(vty, " gprs nsvc %u nsvci %u%s", i,
380 nsvc->nsvci, VTY_NEWLINE);
381 vty_out(vty, " gprs nsvc %u local udp port %u%s", i,
382 nsvc->local_port, VTY_NEWLINE);
383 vty_out(vty, " gprs nsvc %u remote udp port %u%s", i,
384 nsvc->remote_port, VTY_NEWLINE);
385 vty_out(vty, " gprs nsvc %u remote ip %s%s", i,
386 inet_ntoa(ia), VTY_NEWLINE);
387 }
388}
389
Harald Welte97ceef92009-08-06 19:06:46 +0200390static void config_write_bts_single(struct vty *vty, struct gsm_bts *bts)
391{
392 struct gsm_bts_trx *trx;
Harald Welted8acf142010-07-30 11:50:09 +0200393 int i;
Harald Welte97ceef92009-08-06 19:06:46 +0200394
Harald Weltee87eb462009-08-07 13:29:14 +0200395 vty_out(vty, " bts %u%s", bts->nr, VTY_NEWLINE);
396 vty_out(vty, " type %s%s", btstype2str(bts->type), VTY_NEWLINE);
Harald Welte8791dac2010-05-14 17:59:53 +0200397 if (bts->description)
398 vty_out(vty, " description %s%s", bts->description, VTY_NEWLINE);
Harald Weltee87eb462009-08-07 13:29:14 +0200399 vty_out(vty, " band %s%s", gsm_band_name(bts->band), VTY_NEWLINE);
Holger Hans Peter Freyther6d82b7c2009-11-19 16:38:49 +0100400 vty_out(vty, " cell_identity %u%s", bts->cell_identity, VTY_NEWLINE);
Harald Weltee87eb462009-08-07 13:29:14 +0200401 vty_out(vty, " location_area_code %u%s", bts->location_area_code,
Harald Welte97ceef92009-08-06 19:06:46 +0200402 VTY_NEWLINE);
Harald Weltee87eb462009-08-07 13:29:14 +0200403 vty_out(vty, " training_sequence_code %u%s", bts->tsc, VTY_NEWLINE);
404 vty_out(vty, " base_station_id_code %u%s", bts->bsic, VTY_NEWLINE);
Harald Welte (local)cbd46102009-08-13 10:14:26 +0200405 vty_out(vty, " ms max power %u%s", bts->ms_max_power, VTY_NEWLINE);
Harald Welteb761bf82009-12-12 18:17:25 +0100406 vty_out(vty, " cell reselection hysteresis %u%s",
407 bts->si_common.cell_sel_par.cell_resel_hyst*2, VTY_NEWLINE);
408 vty_out(vty, " rxlev access min %u%s",
409 bts->si_common.cell_sel_par.rxlev_acc_min, VTY_NEWLINE);
Harald Weltea54a2bb2009-12-01 18:04:30 +0530410 if (bts->si_common.chan_desc.t3212)
Harald Welte (local)b6ea7f72009-08-14 23:09:25 +0200411 vty_out(vty, " periodic location update %u%s",
Harald Weltea54a2bb2009-12-01 18:04:30 +0530412 bts->si_common.chan_desc.t3212 * 10, VTY_NEWLINE);
Harald Welte3e774612009-08-10 13:48:16 +0200413 vty_out(vty, " channel allocator %s%s",
414 bts->chan_alloc_reverse ? "descending" : "ascending",
415 VTY_NEWLINE);
Sylvain Munaut8e2d8de2009-12-22 13:43:26 +0100416 vty_out(vty, " rach tx integer %u%s",
417 bts->si_common.rach_control.tx_integer, VTY_NEWLINE);
418 vty_out(vty, " rach max transmission %u%s",
419 rach_max_trans_raw2val(bts->si_common.rach_control.max_trans),
420 VTY_NEWLINE);
Holger Hans Peter Freyther697ed2b2010-04-25 23:08:39 +0800421
422 if (bts->rach_b_thresh != -1)
423 vty_out(vty, " rach nm busy threshold %u%s",
424 bts->rach_b_thresh, VTY_NEWLINE);
425 if (bts->rach_ldavg_slots != -1)
426 vty_out(vty, " rach nm load average %u%s",
427 bts->rach_ldavg_slots, VTY_NEWLINE);
Harald Welte8c973ba2009-12-21 23:08:18 +0100428 if (bts->si_common.rach_control.cell_bar)
Harald Welte (local)e19be3f2009-08-12 13:28:23 +0200429 vty_out(vty, " cell barred 1%s", VTY_NEWLINE);
Holger Hans Peter Freyther440984b2010-05-14 00:39:19 +0800430 if ((bts->si_common.rach_control.t2 & 0x4) == 0)
431 vty_out(vty, " rach emergency call allowed 1%s", VTY_NEWLINE);
Harald Welted8acf142010-07-30 11:50:09 +0200432 for (i = SYSINFO_TYPE_1; i < _MAX_SYSINFO_TYPE; i++) {
433 if (bts->si_mode_static & (1 << i)) {
434 vty_out(vty, " system-information %s mode static%s",
435 get_value_string(osmo_sitype_strs, i), VTY_NEWLINE);
436 vty_out(vty, " system-information %s static %s%s",
437 get_value_string(osmo_sitype_strs, i),
438 hexdump_nospc(bts->si_buf[i], sizeof(bts->si_buf[i])),
439 VTY_NEWLINE);
440 }
441 }
Harald Welte25572872009-10-20 00:22:00 +0200442 if (is_ipaccess_bts(bts)) {
Harald Weltee87eb462009-08-07 13:29:14 +0200443 vty_out(vty, " ip.access unit_id %u %u%s",
Harald Welte3ffe1b32009-08-07 00:25:23 +0200444 bts->ip_access.site_id, bts->ip_access.bts_id, VTY_NEWLINE);
Harald Welte25572872009-10-20 00:22:00 +0200445 vty_out(vty, " oml ip.access stream_id %u%s", bts->oml_tei, VTY_NEWLINE);
446 } else {
Harald Welte62868882009-08-08 16:12:58 +0200447 config_write_e1_link(vty, &bts->oml_e1_link, " oml ");
448 vty_out(vty, " oml e1 tei %u%s", bts->oml_tei, VTY_NEWLINE);
449 }
Harald Weltea9251762010-05-11 23:50:21 +0200450 config_write_bts_gprs(vty, bts);
Harald Welte97ceef92009-08-06 19:06:46 +0200451
452 llist_for_each_entry(trx, &bts->trx_list, list)
453 config_write_trx_single(vty, trx);
454}
455
456static int config_write_bts(struct vty *v)
457{
Harald Welte40152872010-05-16 20:52:23 +0200458 struct gsm_network *gsmnet = gsmnet_from_vty(v);
Harald Welte97ceef92009-08-06 19:06:46 +0200459 struct gsm_bts *bts;
460
461 llist_for_each_entry(bts, &gsmnet->bts_list, list)
462 config_write_bts_single(v, bts);
463
464 return CMD_SUCCESS;
465}
466
Harald Weltee87eb462009-08-07 13:29:14 +0200467static int config_write_net(struct vty *vty)
468{
Harald Welte40152872010-05-16 20:52:23 +0200469 struct gsm_network *gsmnet = gsmnet_from_vty(vty);
470
Harald Weltee87eb462009-08-07 13:29:14 +0200471 vty_out(vty, "network%s", VTY_NEWLINE);
Harald Welte62868882009-08-08 16:12:58 +0200472 vty_out(vty, " network country code %u%s", gsmnet->country_code, VTY_NEWLINE);
Harald Weltee87eb462009-08-07 13:29:14 +0200473 vty_out(vty, " mobile network code %u%s", gsmnet->network_code, VTY_NEWLINE);
Harald Welte62868882009-08-08 16:12:58 +0200474 vty_out(vty, " short name %s%s", gsmnet->name_short, VTY_NEWLINE);
475 vty_out(vty, " long name %s%s", gsmnet->name_long, VTY_NEWLINE);
Harald Welte (local)a59a27e2009-08-12 14:42:23 +0200476 vty_out(vty, " auth policy %s%s", gsm_auth_policy_name(gsmnet->auth_policy), VTY_NEWLINE);
Harald Welte59936d72009-11-18 20:33:19 +0100477 vty_out(vty, " location updating reject cause %u%s",
478 gsmnet->reject_cause, VTY_NEWLINE);
Harald Weltecca253a2009-08-30 15:47:06 +0900479 vty_out(vty, " encryption a5 %u%s", gsmnet->a5_encryption, VTY_NEWLINE);
Holger Hans Peter Freyther6b4f5462009-11-19 16:37:48 +0100480 vty_out(vty, " neci %u%s", gsmnet->neci, VTY_NEWLINE);
Harald Welte52af1952009-12-13 10:53:12 +0100481 vty_out(vty, " rrlp mode %s%s", rrlp_mode_name(gsmnet->rrlp.mode),
482 VTY_NEWLINE);
Harald Weltea310f3e2009-12-14 09:00:24 +0100483 vty_out(vty, " mm info %u%s", gsmnet->send_mm_info, VTY_NEWLINE);
Harald Welte0af9c9f2009-12-19 21:41:52 +0100484 vty_out(vty, " handover %u%s", gsmnet->handover.active, VTY_NEWLINE);
Harald Weltea8062f12009-12-21 16:51:50 +0100485 vty_out(vty, " handover window rxlev averaging %u%s",
486 gsmnet->handover.win_rxlev_avg, VTY_NEWLINE);
487 vty_out(vty, " handover window rxqual averaging %u%s",
488 gsmnet->handover.win_rxqual_avg, VTY_NEWLINE);
489 vty_out(vty, " handover window rxlev neighbor averaging %u%s",
490 gsmnet->handover.win_rxlev_avg_neigh, VTY_NEWLINE);
491 vty_out(vty, " handover power budget interval %u%s",
492 gsmnet->handover.pwr_interval, VTY_NEWLINE);
493 vty_out(vty, " handover power budget hysteresis %u%s",
494 gsmnet->handover.pwr_hysteresis, VTY_NEWLINE);
495 vty_out(vty, " handover maximum distance %u%s",
496 gsmnet->handover.max_distance, VTY_NEWLINE);
Holger Hans Peter Freyther26ba2e72009-11-21 21:18:38 +0100497 vty_out(vty, " timer t3101 %u%s", gsmnet->T3101, VTY_NEWLINE);
Holger Hans Peter Freyther89733862009-11-21 21:42:26 +0100498 vty_out(vty, " timer t3103 %u%s", gsmnet->T3103, VTY_NEWLINE);
499 vty_out(vty, " timer t3105 %u%s", gsmnet->T3105, VTY_NEWLINE);
500 vty_out(vty, " timer t3107 %u%s", gsmnet->T3107, VTY_NEWLINE);
501 vty_out(vty, " timer t3109 %u%s", gsmnet->T3109, VTY_NEWLINE);
502 vty_out(vty, " timer t3111 %u%s", gsmnet->T3111, VTY_NEWLINE);
503 vty_out(vty, " timer t3113 %u%s", gsmnet->T3113, VTY_NEWLINE);
504 vty_out(vty, " timer t3115 %u%s", gsmnet->T3115, VTY_NEWLINE);
505 vty_out(vty, " timer t3117 %u%s", gsmnet->T3117, VTY_NEWLINE);
506 vty_out(vty, " timer t3119 %u%s", gsmnet->T3119, VTY_NEWLINE);
507 vty_out(vty, " timer t3141 %u%s", gsmnet->T3141, VTY_NEWLINE);
Holger Hans Peter Freyther21d63ff2010-09-06 09:25:48 +0800508 vty_out(vty, " use-dtx %u%s", gsmnet->dtx_enabled, VTY_NEWLINE);
Harald Weltee87eb462009-08-07 13:29:14 +0200509
510 return CMD_SUCCESS;
511}
Harald Welte97ceef92009-08-06 19:06:46 +0200512
Harald Welte59b04682009-06-10 05:40:52 +0800513static void trx_dump_vty(struct vty *vty, struct gsm_bts_trx *trx)
514{
515 vty_out(vty, "TRX %u of BTS %u is on ARFCN %u%s",
516 trx->nr, trx->bts->nr, trx->arfcn, VTY_NEWLINE);
Harald Welte8791dac2010-05-14 17:59:53 +0200517 vty_out(vty, "Description: %s%s",
518 trx->description ? trx->description : "(null)", VTY_NEWLINE);
Harald Welte91afe4c2009-06-20 18:15:19 +0200519 vty_out(vty, " RF Nominal Power: %d dBm, reduced by %u dB, "
Harald Welte62868882009-08-08 16:12:58 +0200520 "resulting BS power: %d dBm%s",
Harald Welte91afe4c2009-06-20 18:15:19 +0200521 trx->nominal_power, trx->max_power_red,
Harald Welte62868882009-08-08 16:12:58 +0200522 trx->nominal_power - trx->max_power_red, VTY_NEWLINE);
Harald Welte59b04682009-06-10 05:40:52 +0800523 vty_out(vty, " NM State: ");
524 net_dump_nmstate(vty, &trx->nm_state);
525 vty_out(vty, " Baseband Transceiver NM State: ");
526 net_dump_nmstate(vty, &trx->bb_transc.nm_state);
Harald Welte25572872009-10-20 00:22:00 +0200527 if (is_ipaccess_bts(trx->bts)) {
528 vty_out(vty, " ip.access stream ID: 0x%02x%s",
529 trx->rsl_tei, VTY_NEWLINE);
530 } else {
531 vty_out(vty, " E1 Signalling Link:%s", VTY_NEWLINE);
532 e1isl_dump_vty(vty, trx->rsl_link);
533 }
Harald Welte59b04682009-06-10 05:40:52 +0800534}
535
536DEFUN(show_trx,
537 show_trx_cmd,
538 "show trx [bts_nr] [trx_nr]",
Harald Welte9e002452010-05-11 21:53:49 +0200539 SHOW_STR "Display information about a TRX\n"
540 "BTS Number\n"
541 "TRX Number\n")
Harald Welte59b04682009-06-10 05:40:52 +0800542{
Harald Welte40152872010-05-16 20:52:23 +0200543 struct gsm_network *net = gsmnet_from_vty(vty);
Harald Welte59b04682009-06-10 05:40:52 +0800544 struct gsm_bts *bts = NULL;
545 struct gsm_bts_trx *trx;
546 int bts_nr, trx_nr;
547
548 if (argc >= 1) {
549 /* use the BTS number that the user has specified */
550 bts_nr = atoi(argv[0]);
551 if (bts_nr >= net->num_bts) {
552 vty_out(vty, "%% can't find BTS '%s'%s", argv[0],
553 VTY_NEWLINE);
554 return CMD_WARNING;
555 }
Harald Weltee712a5f2009-06-21 16:17:15 +0200556 bts = gsm_bts_num(net, bts_nr);
Harald Welte59b04682009-06-10 05:40:52 +0800557 }
558 if (argc >= 2) {
559 trx_nr = atoi(argv[1]);
560 if (trx_nr >= bts->num_trx) {
561 vty_out(vty, "%% can't find TRX '%s'%s", argv[1],
562 VTY_NEWLINE);
563 return CMD_WARNING;
564 }
Harald Weltee712a5f2009-06-21 16:17:15 +0200565 trx = gsm_bts_trx_num(bts, trx_nr);
Harald Welte59b04682009-06-10 05:40:52 +0800566 trx_dump_vty(vty, trx);
567 return CMD_SUCCESS;
568 }
569 if (bts) {
570 /* print all TRX in this BTS */
571 for (trx_nr = 0; trx_nr < bts->num_trx; trx_nr++) {
Harald Weltee712a5f2009-06-21 16:17:15 +0200572 trx = gsm_bts_trx_num(bts, trx_nr);
Harald Welte59b04682009-06-10 05:40:52 +0800573 trx_dump_vty(vty, trx);
574 }
575 return CMD_SUCCESS;
576 }
577
578 for (bts_nr = 0; bts_nr < net->num_bts; bts_nr++) {
Harald Weltee712a5f2009-06-21 16:17:15 +0200579 bts = gsm_bts_num(net, bts_nr);
Harald Welte59b04682009-06-10 05:40:52 +0800580 for (trx_nr = 0; trx_nr < bts->num_trx; trx_nr++) {
Harald Weltee712a5f2009-06-21 16:17:15 +0200581 trx = gsm_bts_trx_num(bts, trx_nr);
Harald Welte59b04682009-06-10 05:40:52 +0800582 trx_dump_vty(vty, trx);
583 }
584 }
585
586 return CMD_SUCCESS;
587}
588
Harald Welte97ceef92009-08-06 19:06:46 +0200589
Harald Welte59b04682009-06-10 05:40:52 +0800590static void ts_dump_vty(struct vty *vty, struct gsm_bts_trx_ts *ts)
591{
Harald Welte59b04682009-06-10 05:40:52 +0800592 vty_out(vty, "Timeslot %u of TRX %u in BTS %u, phys cfg %s%s",
593 ts->nr, ts->trx->nr, ts->trx->bts->nr,
594 gsm_pchan_name(ts->pchan), VTY_NEWLINE);
595 vty_out(vty, " NM State: ");
596 net_dump_nmstate(vty, &ts->nm_state);
Harald Welte87504212009-12-02 01:56:49 +0530597 if (!is_ipaccess_bts(ts->trx->bts))
Harald Welte59b04682009-06-10 05:40:52 +0800598 vty_out(vty, " E1 Line %u, Timeslot %u, Subslot %u%s",
599 ts->e1_link.e1_nr, ts->e1_link.e1_ts,
600 ts->e1_link.e1_ts_ss, VTY_NEWLINE);
Harald Welte59b04682009-06-10 05:40:52 +0800601}
602
603DEFUN(show_ts,
604 show_ts_cmd,
605 "show timeslot [bts_nr] [trx_nr] [ts_nr]",
Harald Welte9e002452010-05-11 21:53:49 +0200606 SHOW_STR "Display information about a TS\n"
607 "BTS Number\n" "TRX Number\n" "Timeslot Number\n")
Harald Welte59b04682009-06-10 05:40:52 +0800608{
Harald Welte40152872010-05-16 20:52:23 +0200609 struct gsm_network *net = gsmnet_from_vty(vty);
Harald Welte59b04682009-06-10 05:40:52 +0800610 struct gsm_bts *bts;
611 struct gsm_bts_trx *trx;
612 struct gsm_bts_trx_ts *ts;
613 int bts_nr, trx_nr, ts_nr;
614
615 if (argc >= 1) {
616 /* use the BTS number that the user has specified */
617 bts_nr = atoi(argv[0]);
618 if (bts_nr >= net->num_bts) {
619 vty_out(vty, "%% can't find BTS '%s'%s", argv[0],
620 VTY_NEWLINE);
621 return CMD_WARNING;
622 }
Harald Weltee712a5f2009-06-21 16:17:15 +0200623 bts = gsm_bts_num(net, bts_nr);
Harald Welte59b04682009-06-10 05:40:52 +0800624 }
625 if (argc >= 2) {
626 trx_nr = atoi(argv[1]);
627 if (trx_nr >= bts->num_trx) {
628 vty_out(vty, "%% can't find TRX '%s'%s", argv[1],
629 VTY_NEWLINE);
630 return CMD_WARNING;
631 }
Harald Weltee712a5f2009-06-21 16:17:15 +0200632 trx = gsm_bts_trx_num(bts, trx_nr);
Harald Welte59b04682009-06-10 05:40:52 +0800633 }
634 if (argc >= 3) {
635 ts_nr = atoi(argv[2]);
636 if (ts_nr >= TRX_NR_TS) {
637 vty_out(vty, "%% can't find TS '%s'%s", argv[2],
638 VTY_NEWLINE);
639 return CMD_WARNING;
640 }
641 ts = &trx->ts[ts_nr];
642 ts_dump_vty(vty, ts);
643 return CMD_SUCCESS;
644 }
645 for (bts_nr = 0; bts_nr < net->num_bts; bts_nr++) {
Harald Weltee712a5f2009-06-21 16:17:15 +0200646 bts = gsm_bts_num(net, bts_nr);
Harald Welte59b04682009-06-10 05:40:52 +0800647 for (trx_nr = 0; trx_nr < bts->num_trx; trx_nr++) {
Harald Weltee712a5f2009-06-21 16:17:15 +0200648 trx = gsm_bts_trx_num(bts, trx_nr);
Harald Welte59b04682009-06-10 05:40:52 +0800649 for (ts_nr = 0; ts_nr < TRX_NR_TS; ts_nr++) {
650 ts = &trx->ts[ts_nr];
651 ts_dump_vty(vty, ts);
652 }
653 }
654 }
655
656 return CMD_SUCCESS;
657}
658
Holger Hans Peter Freyther1dd0a1b2010-01-06 06:00:40 +0100659static void subscr_dump_vty(struct vty *vty, struct gsm_subscriber *subscr)
Harald Welte59b04682009-06-10 05:40:52 +0800660{
Harald Welte91afe4c2009-06-20 18:15:19 +0200661 vty_out(vty, " ID: %llu, Authorized: %d%s", subscr->id,
Harald Welte59b04682009-06-10 05:40:52 +0800662 subscr->authorized, VTY_NEWLINE);
663 if (subscr->name)
664 vty_out(vty, " Name: '%s'%s", subscr->name, VTY_NEWLINE);
665 if (subscr->extension)
666 vty_out(vty, " Extension: %s%s", subscr->extension,
667 VTY_NEWLINE);
668 if (subscr->imsi)
669 vty_out(vty, " IMSI: %s%s", subscr->imsi, VTY_NEWLINE);
Holger Hans Peter Freythercd8bacf2009-08-19 12:53:57 +0200670 if (subscr->tmsi != GSM_RESERVED_TMSI)
671 vty_out(vty, " TMSI: %08X%s", subscr->tmsi,
Harald Welte270c06c2009-08-15 03:24:51 +0200672 VTY_NEWLINE);
Sylvain Munaute5863a22009-12-27 19:29:28 +0100673
Harald Welte (local)02d5efa2009-08-14 20:27:16 +0200674 vty_out(vty, " Use count: %u%s", subscr->use_count, VTY_NEWLINE);
Harald Welte59b04682009-06-10 05:40:52 +0800675}
676
Harald Welte44007742009-12-22 21:43:14 +0100677static void meas_rep_dump_uni_vty(struct vty *vty,
678 struct gsm_meas_rep_unidir *mru,
679 const char *prefix,
680 const char *dir)
681{
682 vty_out(vty, "%s RXL-FULL-%s: %4d dBm, RXL-SUB-%s: %4d dBm ",
683 prefix, dir, rxlev2dbm(mru->full.rx_lev),
684 dir, rxlev2dbm(mru->sub.rx_lev));
685 vty_out(vty, "RXQ-FULL-%s: %d, RXQ-SUB-%s: %d%s",
686 dir, mru->full.rx_qual, dir, mru->sub.rx_qual,
687 VTY_NEWLINE);
688}
689
690static void meas_rep_dump_vty(struct vty *vty, struct gsm_meas_rep *mr,
691 const char *prefix)
692{
693 vty_out(vty, "%sMeasurement Report:%s", prefix, VTY_NEWLINE);
694 vty_out(vty, "%s Flags: %s%s%s%s%s", prefix,
695 mr->flags & MEAS_REP_F_UL_DTX ? "DTXu " : "",
696 mr->flags & MEAS_REP_F_DL_DTX ? "DTXd " : "",
697 mr->flags & MEAS_REP_F_FPC ? "FPC " : "",
698 mr->flags & MEAS_REP_F_DL_VALID ? " " : "DLinval ",
699 VTY_NEWLINE);
700 if (mr->flags & MEAS_REP_F_MS_TO)
701 vty_out(vty, "%s MS Timing Offset: %u%s", prefix,
702 mr->ms_timing_offset, VTY_NEWLINE);
703 if (mr->flags & MEAS_REP_F_MS_L1)
704 vty_out(vty, "%s L1 MS Power: %u dBm, Timing Advance: %u%s",
705 prefix, mr->ms_l1.pwr, mr->ms_l1.ta, VTY_NEWLINE);
706 if (mr->flags & MEAS_REP_F_DL_VALID)
707 meas_rep_dump_uni_vty(vty, &mr->dl, prefix, "dl");
708 meas_rep_dump_uni_vty(vty, &mr->ul, prefix, "ul");
709}
710
Holger Hans Peter Freyther5424e022010-05-14 02:03:16 +0800711static void lchan_dump_full_vty(struct vty *vty, struct gsm_lchan *lchan)
Harald Welte59b04682009-06-10 05:40:52 +0800712{
Harald Welte44007742009-12-22 21:43:14 +0100713 int idx;
714
Harald Welte59b04682009-06-10 05:40:52 +0800715 vty_out(vty, "Lchan %u in Timeslot %u of TRX %u in BTS %u, Type %s%s",
Holger Hans Peter Freyther71135142010-03-29 08:47:44 +0200716 lchan->nr, lchan->ts->nr, lchan->ts->trx->nr,
Harald Welte (local)02204d02009-12-27 18:05:25 +0100717 lchan->ts->trx->bts->nr, gsm_lchant_name(lchan->type),
Harald Welte59b04682009-06-10 05:40:52 +0800718 VTY_NEWLINE);
Holger Hans Peter Freyther6e5c50f2010-06-28 17:09:29 +0800719 vty_out(vty, " Connection: %u, State: %s%s",
720 lchan->conn ? 1: 0,
Harald Welteab2534c2009-12-29 10:52:38 +0100721 gsm_lchans_name(lchan->state), VTY_NEWLINE);
Harald Welteb761bf82009-12-12 18:17:25 +0100722 vty_out(vty, " BS Power: %u dBm, MS Power: %u dBm%s",
723 lchan->ts->trx->nominal_power - lchan->ts->trx->max_power_red
724 - lchan->bs_power*2,
725 ms_pwr_dbm(lchan->ts->trx->bts->band, lchan->ms_power),
726 VTY_NEWLINE);
Holger Hans Peter Freyther1a95fa82010-06-28 15:47:12 +0800727 if (lchan->conn && lchan->conn->subscr) {
Harald Welte59b04682009-06-10 05:40:52 +0800728 vty_out(vty, " Subscriber:%s", VTY_NEWLINE);
Holger Hans Peter Freyther1a95fa82010-06-28 15:47:12 +0800729 subscr_dump_vty(vty, lchan->conn->subscr);
Harald Welte59b04682009-06-10 05:40:52 +0800730 } else
731 vty_out(vty, " No Subscriber%s", VTY_NEWLINE);
Harald Welte87504212009-12-02 01:56:49 +0530732 if (is_ipaccess_bts(lchan->ts->trx->bts)) {
733 struct in_addr ia;
Holger Hans Peter Freythercec1ec52010-04-07 15:39:16 +0200734 ia.s_addr = htonl(lchan->abis_ip.bound_ip);
Harald Welte87504212009-12-02 01:56:49 +0530735 vty_out(vty, " Bound IP: %s Port %u RTP_TYPE2=%u CONN_ID=%u%s",
736 inet_ntoa(ia), lchan->abis_ip.bound_port,
737 lchan->abis_ip.rtp_payload2, lchan->abis_ip.conn_id,
738 VTY_NEWLINE);
739 }
Harald Welte44007742009-12-22 21:43:14 +0100740
741 /* we want to report the last measurement report */
742 idx = calc_initial_idx(ARRAY_SIZE(lchan->meas_rep),
743 lchan->meas_rep_idx, 1);
744 meas_rep_dump_vty(vty, &lchan->meas_rep[idx], " ");
Harald Welte59b04682009-06-10 05:40:52 +0800745}
746
Holger Hans Peter Freythere959b4e2010-05-14 02:08:49 +0800747static void lchan_dump_short_vty(struct vty *vty, struct gsm_lchan *lchan)
748{
Holger Hans Peter Freythercf13a922010-05-14 01:57:02 +0800749 struct gsm_meas_rep *mr;
750 int idx;
751
752 /* we want to report the last measurement report */
753 idx = calc_initial_idx(ARRAY_SIZE(lchan->meas_rep),
754 lchan->meas_rep_idx, 1);
755 mr = &lchan->meas_rep[idx];
756
757 vty_out(vty, "Lchan: %u Timeslot: %u TRX: %u BTS: %u Type: %s - L1 MS Power: %u dBm "
758 "RXL-FULL-dl: %4d dBm RXL-FULL-ul: %4d dBm%s",
Holger Hans Peter Freythere959b4e2010-05-14 02:08:49 +0800759 lchan->nr, lchan->ts->nr, lchan->ts->trx->nr,
760 lchan->ts->trx->bts->nr, gsm_lchant_name(lchan->type),
Holger Hans Peter Freythercf13a922010-05-14 01:57:02 +0800761 mr->ms_l1.pwr,
762 rxlev2dbm(mr->dl.full.rx_lev),
763 rxlev2dbm(mr->ul.full.rx_lev),
Holger Hans Peter Freythere959b4e2010-05-14 02:08:49 +0800764 VTY_NEWLINE);
765}
766
Holger Hans Peter Freyther5424e022010-05-14 02:03:16 +0800767static int lchan_summary(struct vty *vty, int argc, const char **argv,
768 void (*dump_cb)(struct vty *, struct gsm_lchan *))
Harald Welte59b04682009-06-10 05:40:52 +0800769{
Harald Welte40152872010-05-16 20:52:23 +0200770 struct gsm_network *net = gsmnet_from_vty(vty);
Harald Welte59b04682009-06-10 05:40:52 +0800771 struct gsm_bts *bts;
772 struct gsm_bts_trx *trx;
773 struct gsm_bts_trx_ts *ts;
774 struct gsm_lchan *lchan;
775 int bts_nr, trx_nr, ts_nr, lchan_nr;
776
777 if (argc >= 1) {
778 /* use the BTS number that the user has specified */
779 bts_nr = atoi(argv[0]);
780 if (bts_nr >= net->num_bts) {
781 vty_out(vty, "%% can't find BTS %s%s", argv[0],
782 VTY_NEWLINE);
783 return CMD_WARNING;
784 }
Harald Weltee712a5f2009-06-21 16:17:15 +0200785 bts = gsm_bts_num(net, bts_nr);
Harald Welte59b04682009-06-10 05:40:52 +0800786 }
787 if (argc >= 2) {
788 trx_nr = atoi(argv[1]);
789 if (trx_nr >= bts->num_trx) {
790 vty_out(vty, "%% can't find TRX %s%s", argv[1],
791 VTY_NEWLINE);
792 return CMD_WARNING;
793 }
Harald Weltee712a5f2009-06-21 16:17:15 +0200794 trx = gsm_bts_trx_num(bts, trx_nr);
Harald Welte59b04682009-06-10 05:40:52 +0800795 }
796 if (argc >= 3) {
797 ts_nr = atoi(argv[2]);
798 if (ts_nr >= TRX_NR_TS) {
799 vty_out(vty, "%% can't find TS %s%s", argv[2],
800 VTY_NEWLINE);
801 return CMD_WARNING;
802 }
803 ts = &trx->ts[ts_nr];
804 }
805 if (argc >= 4) {
806 lchan_nr = atoi(argv[3]);
807 if (lchan_nr >= TS_MAX_LCHAN) {
808 vty_out(vty, "%% can't find LCHAN %s%s", argv[3],
809 VTY_NEWLINE);
810 return CMD_WARNING;
811 }
812 lchan = &ts->lchan[lchan_nr];
Holger Hans Peter Freyther5424e022010-05-14 02:03:16 +0800813 dump_cb(vty, lchan);
Harald Welte59b04682009-06-10 05:40:52 +0800814 return CMD_SUCCESS;
815 }
816 for (bts_nr = 0; bts_nr < net->num_bts; bts_nr++) {
Harald Weltee712a5f2009-06-21 16:17:15 +0200817 bts = gsm_bts_num(net, bts_nr);
Harald Welte59b04682009-06-10 05:40:52 +0800818 for (trx_nr = 0; trx_nr < bts->num_trx; trx_nr++) {
Harald Weltee712a5f2009-06-21 16:17:15 +0200819 trx = gsm_bts_trx_num(bts, trx_nr);
Harald Welte59b04682009-06-10 05:40:52 +0800820 for (ts_nr = 0; ts_nr < TRX_NR_TS; ts_nr++) {
821 ts = &trx->ts[ts_nr];
822 for (lchan_nr = 0; lchan_nr < TS_MAX_LCHAN;
823 lchan_nr++) {
824 lchan = &ts->lchan[lchan_nr];
825 if (lchan->type == GSM_LCHAN_NONE)
826 continue;
Holger Hans Peter Freyther5424e022010-05-14 02:03:16 +0800827 dump_cb(vty, lchan);
Harald Welte59b04682009-06-10 05:40:52 +0800828 }
829 }
830 }
831 }
832
833 return CMD_SUCCESS;
834}
835
Holger Hans Peter Freyther5424e022010-05-14 02:03:16 +0800836
837DEFUN(show_lchan,
838 show_lchan_cmd,
839 "show lchan [bts_nr] [trx_nr] [ts_nr] [lchan_nr]",
840 SHOW_STR "Display information about a logical channel\n"
841 "BTS Number\n" "TRX Number\n" "Timeslot Number\n"
842 "Logical Channel Number\n")
843
844{
845 return lchan_summary(vty, argc, argv, lchan_dump_full_vty);
846}
847
Holger Hans Peter Freythere959b4e2010-05-14 02:08:49 +0800848DEFUN(show_lchan_summary,
849 show_lchan_summary_cmd,
850 "show lchan summary [bts_nr] [trx_nr] [ts_nr] [lchan_nr]",
851 SHOW_STR "Display information about a logical channel\n"
852 "BTS Number\n" "TRX Number\n" "Timeslot Number\n"
853 "Logical Channel Number\n")
854{
855 return lchan_summary(vty, argc, argv, lchan_dump_short_vty);
856}
857
Harald Welte59b04682009-06-10 05:40:52 +0800858static void e1drv_dump_vty(struct vty *vty, struct e1inp_driver *drv)
859{
860 vty_out(vty, "E1 Input Driver %s%s", drv->name, VTY_NEWLINE);
861}
862
863DEFUN(show_e1drv,
864 show_e1drv_cmd,
865 "show e1_driver",
866 SHOW_STR "Display information about available E1 drivers\n")
867{
868 struct e1inp_driver *drv;
869
870 llist_for_each_entry(drv, &e1inp_driver_list, list)
871 e1drv_dump_vty(vty, drv);
872
873 return CMD_SUCCESS;
874}
875
876static void e1line_dump_vty(struct vty *vty, struct e1inp_line *line)
877{
878 vty_out(vty, "E1 Line Number %u, Name %s, Driver %s%s",
879 line->num, line->name ? line->name : "",
880 line->driver->name, VTY_NEWLINE);
881}
882
883DEFUN(show_e1line,
884 show_e1line_cmd,
885 "show e1_line [line_nr]",
Harald Welte9e002452010-05-11 21:53:49 +0200886 SHOW_STR "Display information about a E1 line\n"
887 "E1 Line Number\n")
Harald Welte59b04682009-06-10 05:40:52 +0800888{
889 struct e1inp_line *line;
890
891 if (argc >= 1) {
892 int num = atoi(argv[0]);
893 llist_for_each_entry(line, &e1inp_line_list, list) {
894 if (line->num == num) {
895 e1line_dump_vty(vty, line);
896 return CMD_SUCCESS;
897 }
898 }
899 return CMD_WARNING;
900 }
901
902 llist_for_each_entry(line, &e1inp_line_list, list)
903 e1line_dump_vty(vty, line);
904
905 return CMD_SUCCESS;
906}
907
908static void e1ts_dump_vty(struct vty *vty, struct e1inp_ts *ts)
909{
Harald Welte62868882009-08-08 16:12:58 +0200910 if (ts->type == E1INP_TS_TYPE_NONE)
911 return;
Harald Welte59b04682009-06-10 05:40:52 +0800912 vty_out(vty, "E1 Timeslot %2u of Line %u is Type %s%s",
913 ts->num, ts->line->num, e1inp_tstype_name(ts->type),
914 VTY_NEWLINE);
915}
916
917DEFUN(show_e1ts,
918 show_e1ts_cmd,
919 "show e1_timeslot [line_nr] [ts_nr]",
Harald Welte9e002452010-05-11 21:53:49 +0200920 SHOW_STR "Display information about a E1 timeslot\n"
921 "E1 Line Number\n" "E1 Timeslot Number\n")
Harald Welte59b04682009-06-10 05:40:52 +0800922{
Harald Welte49c79562009-11-17 06:12:16 +0100923 struct e1inp_line *line = NULL;
Harald Welte59b04682009-06-10 05:40:52 +0800924 struct e1inp_ts *ts;
925 int ts_nr;
926
927 if (argc == 0) {
928 llist_for_each_entry(line, &e1inp_line_list, list) {
929 for (ts_nr = 0; ts_nr < NUM_E1_TS; ts_nr++) {
930 ts = &line->ts[ts_nr];
931 e1ts_dump_vty(vty, ts);
932 }
933 }
934 return CMD_SUCCESS;
935 }
936 if (argc >= 1) {
937 int num = atoi(argv[0]);
938 llist_for_each_entry(line, &e1inp_line_list, list) {
939 if (line->num == num)
940 break;
941 }
942 if (!line || line->num != num) {
943 vty_out(vty, "E1 line %s is invalid%s",
944 argv[0], VTY_NEWLINE);
945 return CMD_WARNING;
946 }
947 }
948 if (argc >= 2) {
949 ts_nr = atoi(argv[1]);
950 if (ts_nr > NUM_E1_TS) {
951 vty_out(vty, "E1 timeslot %s is invalid%s",
952 argv[1], VTY_NEWLINE);
953 return CMD_WARNING;
954 }
955 ts = &line->ts[ts_nr];
956 e1ts_dump_vty(vty, ts);
957 return CMD_SUCCESS;
958 } else {
959 for (ts_nr = 0; ts_nr < NUM_E1_TS; ts_nr++) {
960 ts = &line->ts[ts_nr];
961 e1ts_dump_vty(vty, ts);
962 }
963 return CMD_SUCCESS;
964 }
965 return CMD_SUCCESS;
966}
967
968static void paging_dump_vty(struct vty *vty, struct gsm_paging_request *pag)
969{
970 vty_out(vty, "Paging on BTS %u%s", pag->bts->nr, VTY_NEWLINE);
971 subscr_dump_vty(vty, pag->subscr);
972}
973
974static void bts_paging_dump_vty(struct vty *vty, struct gsm_bts *bts)
975{
976 struct gsm_paging_request *pag;
977
978 llist_for_each_entry(pag, &bts->paging.pending_requests, entry)
979 paging_dump_vty(vty, pag);
980}
981
982DEFUN(show_paging,
983 show_paging_cmd,
984 "show paging [bts_nr]",
Harald Welte9e002452010-05-11 21:53:49 +0200985 SHOW_STR "Display information about paging reuqests of a BTS\n"
986 "BTS Number\n")
Harald Welte59b04682009-06-10 05:40:52 +0800987{
Harald Welte40152872010-05-16 20:52:23 +0200988 struct gsm_network *net = gsmnet_from_vty(vty);
Harald Welte59b04682009-06-10 05:40:52 +0800989 struct gsm_bts *bts;
990 int bts_nr;
991
992 if (argc >= 1) {
993 /* use the BTS number that the user has specified */
994 bts_nr = atoi(argv[0]);
995 if (bts_nr >= net->num_bts) {
996 vty_out(vty, "%% can't find BTS %s%s", argv[0],
997 VTY_NEWLINE);
998 return CMD_WARNING;
999 }
Harald Weltee712a5f2009-06-21 16:17:15 +02001000 bts = gsm_bts_num(net, bts_nr);
Harald Welte59b04682009-06-10 05:40:52 +08001001 bts_paging_dump_vty(vty, bts);
1002
1003 return CMD_SUCCESS;
1004 }
1005 for (bts_nr = 0; bts_nr < net->num_bts; bts_nr++) {
Harald Weltee712a5f2009-06-21 16:17:15 +02001006 bts = gsm_bts_num(net, bts_nr);
Harald Welte59b04682009-06-10 05:40:52 +08001007 bts_paging_dump_vty(vty, bts);
1008 }
1009
1010 return CMD_SUCCESS;
1011}
1012
Harald Welte9e002452010-05-11 21:53:49 +02001013#define NETWORK_STR "Configure the GSM network\n"
1014
Harald Weltee87eb462009-08-07 13:29:14 +02001015DEFUN(cfg_net,
1016 cfg_net_cmd,
Harald Welte9e002452010-05-11 21:53:49 +02001017 "network", NETWORK_STR)
Harald Weltee87eb462009-08-07 13:29:14 +02001018{
Harald Welte40152872010-05-16 20:52:23 +02001019 vty->index = gsmnet_from_vty(vty);
Harald Weltee87eb462009-08-07 13:29:14 +02001020 vty->node = GSMNET_NODE;
1021
1022 return CMD_SUCCESS;
1023}
1024
1025
1026DEFUN(cfg_net_ncc,
1027 cfg_net_ncc_cmd,
1028 "network country code <1-999>",
1029 "Set the GSM network country code")
1030{
Harald Welte40152872010-05-16 20:52:23 +02001031 struct gsm_network *gsmnet = gsmnet_from_vty(vty);
1032
Harald Weltee87eb462009-08-07 13:29:14 +02001033 gsmnet->country_code = atoi(argv[0]);
1034
1035 return CMD_SUCCESS;
1036}
1037
1038DEFUN(cfg_net_mnc,
1039 cfg_net_mnc_cmd,
1040 "mobile network code <1-999>",
1041 "Set the GSM mobile network code")
1042{
Harald Welte40152872010-05-16 20:52:23 +02001043 struct gsm_network *gsmnet = gsmnet_from_vty(vty);
1044
Harald Weltee87eb462009-08-07 13:29:14 +02001045 gsmnet->network_code = atoi(argv[0]);
1046
1047 return CMD_SUCCESS;
1048}
1049
1050DEFUN(cfg_net_name_short,
1051 cfg_net_name_short_cmd,
1052 "short name NAME",
1053 "Set the short GSM network name")
1054{
Harald Welte40152872010-05-16 20:52:23 +02001055 struct gsm_network *gsmnet = gsmnet_from_vty(vty);
1056
Harald Weltee87eb462009-08-07 13:29:14 +02001057 if (gsmnet->name_short)
1058 talloc_free(gsmnet->name_short);
1059
1060 gsmnet->name_short = talloc_strdup(gsmnet, argv[0]);
1061
1062 return CMD_SUCCESS;
1063}
1064
1065DEFUN(cfg_net_name_long,
1066 cfg_net_name_long_cmd,
1067 "long name NAME",
1068 "Set the long GSM network name")
1069{
Harald Welte40152872010-05-16 20:52:23 +02001070 struct gsm_network *gsmnet = gsmnet_from_vty(vty);
1071
Harald Weltee87eb462009-08-07 13:29:14 +02001072 if (gsmnet->name_long)
1073 talloc_free(gsmnet->name_long);
1074
1075 gsmnet->name_long = talloc_strdup(gsmnet, argv[0]);
1076
1077 return CMD_SUCCESS;
1078}
Harald Welte59b04682009-06-10 05:40:52 +08001079
Harald Welte (local)a59a27e2009-08-12 14:42:23 +02001080DEFUN(cfg_net_auth_policy,
1081 cfg_net_auth_policy_cmd,
1082 "auth policy (closed|accept-all|token)",
Harald Welte9e002452010-05-11 21:53:49 +02001083 "Authentication (not cryptographic)\n"
1084 "Set the GSM network authentication policy\n"
1085 "Require the MS to be activated in HLR\n"
1086 "Accept all MS, whether in HLR or not\n"
1087 "Use SMS-token based authentication\n")
Harald Welte (local)a59a27e2009-08-12 14:42:23 +02001088{
1089 enum gsm_auth_policy policy = gsm_auth_policy_parse(argv[0]);
Harald Welte40152872010-05-16 20:52:23 +02001090 struct gsm_network *gsmnet = gsmnet_from_vty(vty);
Harald Welte (local)a59a27e2009-08-12 14:42:23 +02001091
1092 gsmnet->auth_policy = policy;
1093
1094 return CMD_SUCCESS;
1095}
1096
Harald Welte59936d72009-11-18 20:33:19 +01001097DEFUN(cfg_net_reject_cause,
1098 cfg_net_reject_cause_cmd,
1099 "location updating reject cause <2-111>",
1100 "Set the reject cause of location updating reject\n")
1101{
Harald Welte40152872010-05-16 20:52:23 +02001102 struct gsm_network *gsmnet = gsmnet_from_vty(vty);
1103
Harald Welte59936d72009-11-18 20:33:19 +01001104 gsmnet->reject_cause = atoi(argv[0]);
1105
1106 return CMD_SUCCESS;
1107}
1108
Harald Weltecca253a2009-08-30 15:47:06 +09001109DEFUN(cfg_net_encryption,
1110 cfg_net_encryption_cmd,
1111 "encryption a5 (0|1|2)",
Harald Welte18ce31c2010-05-14 20:05:17 +02001112 "Encryption options\n"
1113 "A5 encryption\n" "A5/0: No encryption\n"
1114 "A5/1: Encryption\n" "A5/2: Export-grade Encryption\n")
Harald Weltecca253a2009-08-30 15:47:06 +09001115{
Harald Welte40152872010-05-16 20:52:23 +02001116 struct gsm_network *gsmnet = gsmnet_from_vty(vty);
1117
Andreas.Eversberg53293292009-11-17 09:55:26 +01001118 gsmnet->a5_encryption= atoi(argv[0]);
Harald Weltecca253a2009-08-30 15:47:06 +09001119
1120 return CMD_SUCCESS;
1121}
1122
Holger Hans Peter Freyther96c89822009-11-16 17:12:38 +01001123DEFUN(cfg_net_neci,
1124 cfg_net_neci_cmd,
1125 "neci (0|1)",
Harald Welte18ce31c2010-05-14 20:05:17 +02001126 "New Establish Cause Indication\n"
1127 "Don't set the NECI bit\n" "Set the NECI bit\n")
Holger Hans Peter Freyther96c89822009-11-16 17:12:38 +01001128{
Harald Welte40152872010-05-16 20:52:23 +02001129 struct gsm_network *gsmnet = gsmnet_from_vty(vty);
1130
Holger Hans Peter Freyther96c89822009-11-16 17:12:38 +01001131 gsmnet->neci = atoi(argv[0]);
1132 return CMD_SUCCESS;
1133}
1134
Harald Welte52af1952009-12-13 10:53:12 +01001135DEFUN(cfg_net_rrlp_mode, cfg_net_rrlp_mode_cmd,
1136 "rrlp mode (none|ms-based|ms-preferred|ass-preferred)",
Harald Welte9e002452010-05-11 21:53:49 +02001137 "Radio Resource Location Protocol\n"
1138 "Set the Radio Resource Location Protocol Mode\n"
1139 "Don't send RRLP request\n"
1140 "Request MS-based location\n"
1141 "Request any location, prefer MS-based\n"
1142 "Request any location, prefer MS-assisted\n")
Harald Welte52af1952009-12-13 10:53:12 +01001143{
Harald Welte40152872010-05-16 20:52:23 +02001144 struct gsm_network *gsmnet = gsmnet_from_vty(vty);
1145
Harald Welte52af1952009-12-13 10:53:12 +01001146 gsmnet->rrlp.mode = rrlp_mode_parse(argv[0]);
1147
1148 return CMD_SUCCESS;
1149}
1150
Harald Weltea310f3e2009-12-14 09:00:24 +01001151DEFUN(cfg_net_mm_info, cfg_net_mm_info_cmd,
1152 "mm info (0|1)",
1153 "Whether to send MM INFO after LOC UPD ACCEPT")
1154{
Harald Welte40152872010-05-16 20:52:23 +02001155 struct gsm_network *gsmnet = gsmnet_from_vty(vty);
1156
Harald Weltea310f3e2009-12-14 09:00:24 +01001157 gsmnet->send_mm_info = atoi(argv[0]);
1158
1159 return CMD_SUCCESS;
1160}
1161
Harald Welte9e002452010-05-11 21:53:49 +02001162#define HANDOVER_STR "Handover Options\n"
1163
Harald Welte0af9c9f2009-12-19 21:41:52 +01001164DEFUN(cfg_net_handover, cfg_net_handover_cmd,
1165 "handover (0|1)",
Harald Welte9e002452010-05-11 21:53:49 +02001166 HANDOVER_STR
1167 "Don't perform in-call handover\n"
1168 "Perform in-call handover\n")
Harald Welte0af9c9f2009-12-19 21:41:52 +01001169{
Holger Hans Peter Freyther3524d4b2010-01-07 16:14:38 +01001170 int enable = atoi(argv[0]);
Harald Welte40152872010-05-16 20:52:23 +02001171 struct gsm_network *gsmnet = gsmnet_from_vty(vty);
Holger Hans Peter Freyther3524d4b2010-01-07 16:14:38 +01001172
1173 if (enable && ipacc_rtp_direct) {
Harald Welteaa2c3032009-12-20 13:51:01 +01001174 vty_out(vty, "%% Cannot enable handover unless RTP Proxy mode "
1175 "is enabled by using the -P command line option%s",
1176 VTY_NEWLINE);
1177 return CMD_WARNING;
1178 }
Holger Hans Peter Freyther3524d4b2010-01-07 16:14:38 +01001179 gsmnet->handover.active = enable;
Harald Welte0af9c9f2009-12-19 21:41:52 +01001180
1181 return CMD_SUCCESS;
1182}
1183
Harald Welte9e002452010-05-11 21:53:49 +02001184#define HO_WIN_STR HANDOVER_STR "Measurement Window\n"
1185#define HO_WIN_RXLEV_STR HO_WIN_STR "Received Level Averaging\n"
1186#define HO_WIN_RXQUAL_STR HO_WIN_STR "Received Quality Averaging\n"
1187#define HO_PBUDGET_STR HANDOVER_STR "Power Budget\n"
1188
Harald Weltea8062f12009-12-21 16:51:50 +01001189DEFUN(cfg_net_ho_win_rxlev_avg, cfg_net_ho_win_rxlev_avg_cmd,
1190 "handover window rxlev averaging <1-10>",
Harald Welte9e002452010-05-11 21:53:49 +02001191 HO_WIN_RXLEV_STR
Harald Weltea8062f12009-12-21 16:51:50 +01001192 "How many RxLev measurements are used for averaging")
1193{
Harald Welte40152872010-05-16 20:52:23 +02001194 struct gsm_network *gsmnet = gsmnet_from_vty(vty);
Harald Weltea8062f12009-12-21 16:51:50 +01001195 gsmnet->handover.win_rxlev_avg = atoi(argv[0]);
1196 return CMD_SUCCESS;
1197}
1198
1199DEFUN(cfg_net_ho_win_rxqual_avg, cfg_net_ho_win_rxqual_avg_cmd,
1200 "handover window rxqual averaging <1-10>",
Harald Welte9e002452010-05-11 21:53:49 +02001201 HO_WIN_RXQUAL_STR
Harald Weltea8062f12009-12-21 16:51:50 +01001202 "How many RxQual measurements are used for averaging")
1203{
Harald Welte40152872010-05-16 20:52:23 +02001204 struct gsm_network *gsmnet = gsmnet_from_vty(vty);
Harald Weltea8062f12009-12-21 16:51:50 +01001205 gsmnet->handover.win_rxqual_avg = atoi(argv[0]);
1206 return CMD_SUCCESS;
1207}
1208
1209DEFUN(cfg_net_ho_win_rxlev_neigh_avg, cfg_net_ho_win_rxlev_avg_neigh_cmd,
1210 "handover window rxlev neighbor averaging <1-10>",
Harald Welte9e002452010-05-11 21:53:49 +02001211 HO_WIN_RXLEV_STR
Harald Weltea8062f12009-12-21 16:51:50 +01001212 "How many RxQual measurements are used for averaging")
1213{
Harald Welte40152872010-05-16 20:52:23 +02001214 struct gsm_network *gsmnet = gsmnet_from_vty(vty);
Harald Weltea8062f12009-12-21 16:51:50 +01001215 gsmnet->handover.win_rxlev_avg_neigh = atoi(argv[0]);
1216 return CMD_SUCCESS;
1217}
1218
1219DEFUN(cfg_net_ho_pwr_interval, cfg_net_ho_pwr_interval_cmd,
1220 "handover power budget interval <1-99>",
Harald Welte9e002452010-05-11 21:53:49 +02001221 HO_PBUDGET_STR
Harald Weltea8062f12009-12-21 16:51:50 +01001222 "How often to check if we have a better cell (SACCH frames)")
1223{
Harald Welte40152872010-05-16 20:52:23 +02001224 struct gsm_network *gsmnet = gsmnet_from_vty(vty);
Harald Weltea8062f12009-12-21 16:51:50 +01001225 gsmnet->handover.pwr_interval = atoi(argv[0]);
1226 return CMD_SUCCESS;
1227}
1228
1229DEFUN(cfg_net_ho_pwr_hysteresis, cfg_net_ho_pwr_hysteresis_cmd,
1230 "handover power budget hysteresis <0-999>",
Harald Welte9e002452010-05-11 21:53:49 +02001231 HO_PBUDGET_STR
Harald Weltea8062f12009-12-21 16:51:50 +01001232 "How many dB does a neighbor to be stronger to become a HO candidate")
1233{
Harald Welte40152872010-05-16 20:52:23 +02001234 struct gsm_network *gsmnet = gsmnet_from_vty(vty);
Harald Weltea8062f12009-12-21 16:51:50 +01001235 gsmnet->handover.pwr_hysteresis = atoi(argv[0]);
1236 return CMD_SUCCESS;
1237}
1238
1239DEFUN(cfg_net_ho_max_distance, cfg_net_ho_max_distance_cmd,
1240 "handover maximum distance <0-9999>",
Harald Welte9e002452010-05-11 21:53:49 +02001241 HANDOVER_STR
Harald Weltea8062f12009-12-21 16:51:50 +01001242 "How big is the maximum timing advance before HO is forced")
1243{
Harald Welte40152872010-05-16 20:52:23 +02001244 struct gsm_network *gsmnet = gsmnet_from_vty(vty);
Harald Weltea8062f12009-12-21 16:51:50 +01001245 gsmnet->handover.max_distance = atoi(argv[0]);
1246 return CMD_SUCCESS;
1247}
Harald Welte0af9c9f2009-12-19 21:41:52 +01001248
Holger Hans Peter Freyther13ae9802009-12-22 08:27:21 +01001249#define DECLARE_TIMER(number, doc) \
Holger Hans Peter Freyther26ba2e72009-11-21 21:18:38 +01001250 DEFUN(cfg_net_T##number, \
1251 cfg_net_T##number##_cmd, \
1252 "timer t" #number " <0-65535>", \
Harald Welte9e002452010-05-11 21:53:49 +02001253 "Configure GSM Timers\n" \
Holger Hans Peter Freyther13ae9802009-12-22 08:27:21 +01001254 doc) \
Holger Hans Peter Freyther26ba2e72009-11-21 21:18:38 +01001255{ \
Harald Welte40152872010-05-16 20:52:23 +02001256 struct gsm_network *gsmnet = gsmnet_from_vty(vty); \
Holger Hans Peter Freyther26ba2e72009-11-21 21:18:38 +01001257 int value = atoi(argv[0]); \
1258 \
1259 if (value < 0 || value > 65535) { \
1260 vty_out(vty, "Timer value %s out of range.%s", \
1261 argv[0], VTY_NEWLINE); \
1262 return CMD_WARNING; \
1263 } \
1264 \
1265 gsmnet->T##number = value; \
1266 return CMD_SUCCESS; \
1267}
1268
Holger Hans Peter Freyther13ae9802009-12-22 08:27:21 +01001269DECLARE_TIMER(3101, "Set the timeout value for IMMEDIATE ASSIGNMENT.")
1270DECLARE_TIMER(3103, "Set the timeout value for HANDOVER.")
1271DECLARE_TIMER(3105, "Currently not used.")
1272DECLARE_TIMER(3107, "Currently not used.")
1273DECLARE_TIMER(3109, "Currently not used.")
Holger Hans Peter Freyther4a00c062010-05-31 21:33:15 +08001274DECLARE_TIMER(3111, "Set the RSL timeout to wait before releasing the RF Channel.")
Holger Hans Peter Freyther13ae9802009-12-22 08:27:21 +01001275DECLARE_TIMER(3113, "Set the time to try paging a subscriber.")
1276DECLARE_TIMER(3115, "Currently not used.")
1277DECLARE_TIMER(3117, "Currently not used.")
1278DECLARE_TIMER(3119, "Currently not used.")
1279DECLARE_TIMER(3141, "Currently not used.")
Holger Hans Peter Freyther26ba2e72009-11-21 21:18:38 +01001280
Holger Hans Peter Freyther21d63ff2010-09-06 09:25:48 +08001281DEFUN(cfg_net_dtx,
1282 cfg_net_dtx_cmd,
1283 "dtx-used (0|1)",
1284 "Enable the usage of DTX.\n"
1285 "DTX is enabled/disabled")
1286{
1287 struct gsm_network *gsmnet = gsmnet_from_vty(vty);
1288 gsmnet->dtx_enabled = atoi(argv[0]);
1289 return CMD_SUCCESS;
1290}
Holger Hans Peter Freyther26ba2e72009-11-21 21:18:38 +01001291
Harald Welte59b04682009-06-10 05:40:52 +08001292/* per-BTS configuration */
1293DEFUN(cfg_bts,
1294 cfg_bts_cmd,
1295 "bts BTS_NR",
Harald Welte9e002452010-05-11 21:53:49 +02001296 "Select a BTS to configure\n"
1297 "BTS Number\n")
Harald Welte59b04682009-06-10 05:40:52 +08001298{
Harald Welte40152872010-05-16 20:52:23 +02001299 struct gsm_network *gsmnet = gsmnet_from_vty(vty);
Harald Welte59b04682009-06-10 05:40:52 +08001300 int bts_nr = atoi(argv[0]);
1301 struct gsm_bts *bts;
1302
Harald Weltee712a5f2009-06-21 16:17:15 +02001303 if (bts_nr > gsmnet->num_bts) {
1304 vty_out(vty, "%% The next unused BTS number is %u%s",
1305 gsmnet->num_bts, VTY_NEWLINE);
Harald Welte59b04682009-06-10 05:40:52 +08001306 return CMD_WARNING;
Harald Weltee712a5f2009-06-21 16:17:15 +02001307 } else if (bts_nr == gsmnet->num_bts) {
1308 /* allocate a new one */
1309 bts = gsm_bts_alloc(gsmnet, GSM_BTS_TYPE_UNKNOWN,
1310 HARDCODED_TSC, HARDCODED_BSIC);
Holger Hans Peter Freyther71135142010-03-29 08:47:44 +02001311 } else
Harald Weltee712a5f2009-06-21 16:17:15 +02001312 bts = gsm_bts_num(gsmnet, bts_nr);
1313
Daniel Willmann580085f2010-01-11 13:43:07 +01001314 if (!bts) {
1315 vty_out(vty, "%% Unable to allocate BTS %u%s",
1316 gsmnet->num_bts, VTY_NEWLINE);
Harald Weltee712a5f2009-06-21 16:17:15 +02001317 return CMD_WARNING;
Daniel Willmann580085f2010-01-11 13:43:07 +01001318 }
Harald Welte59b04682009-06-10 05:40:52 +08001319
1320 vty->index = bts;
Harald Welte8791dac2010-05-14 17:59:53 +02001321 vty->index_sub = &bts->description;
Harald Welte59b04682009-06-10 05:40:52 +08001322 vty->node = BTS_NODE;
1323
1324 return CMD_SUCCESS;
1325}
1326
1327DEFUN(cfg_bts_type,
1328 cfg_bts_type_cmd,
1329 "type TYPE",
1330 "Set the BTS type\n")
1331{
1332 struct gsm_bts *bts = vty->index;
Harald Welte59698fb2010-01-10 18:01:52 +01001333 int rc;
Harald Welte59b04682009-06-10 05:40:52 +08001334
Harald Welte59698fb2010-01-10 18:01:52 +01001335 rc = gsm_set_bts_type(bts, parse_btstype(argv[0]));
1336 if (rc < 0)
1337 return CMD_WARNING;
Harald Welte25572872009-10-20 00:22:00 +02001338
Harald Welte59b04682009-06-10 05:40:52 +08001339 return CMD_SUCCESS;
1340}
1341
Harald Welte91afe4c2009-06-20 18:15:19 +02001342DEFUN(cfg_bts_band,
1343 cfg_bts_band_cmd,
1344 "band BAND",
1345 "Set the frequency band of this BTS\n")
1346{
1347 struct gsm_bts *bts = vty->index;
Harald Welte62868882009-08-08 16:12:58 +02001348 int band = gsm_band_parse(argv[0]);
Harald Welte91afe4c2009-06-20 18:15:19 +02001349
1350 if (band < 0) {
1351 vty_out(vty, "%% BAND %d is not a valid GSM band%s",
1352 band, VTY_NEWLINE);
1353 return CMD_WARNING;
1354 }
1355
1356 bts->band = band;
1357
1358 return CMD_SUCCESS;
1359}
1360
Holger Hans Peter Freythera098dfb2009-08-21 14:44:12 +02001361DEFUN(cfg_bts_ci,
1362 cfg_bts_ci_cmd,
1363 "cell_identity <0-65535>",
1364 "Set the Cell identity of this BTS\n")
1365{
1366 struct gsm_bts *bts = vty->index;
1367 int ci = atoi(argv[0]);
1368
1369 if (ci < 0 || ci > 0xffff) {
1370 vty_out(vty, "%% CI %d is not in the valid range (0-65535)%s",
1371 ci, VTY_NEWLINE);
1372 return CMD_WARNING;
1373 }
1374 bts->cell_identity = ci;
1375
1376 return CMD_SUCCESS;
1377}
1378
Harald Welte59b04682009-06-10 05:40:52 +08001379DEFUN(cfg_bts_lac,
1380 cfg_bts_lac_cmd,
Holger Hans Peter Freyther54a22832009-09-29 14:02:33 +02001381 "location_area_code <0-65535>",
Harald Welte59b04682009-06-10 05:40:52 +08001382 "Set the Location Area Code (LAC) of this BTS\n")
1383{
1384 struct gsm_bts *bts = vty->index;
1385 int lac = atoi(argv[0]);
1386
Holger Hans Peter Freyther54a22832009-09-29 14:02:33 +02001387 if (lac < 0 || lac > 0xffff) {
1388 vty_out(vty, "%% LAC %d is not in the valid range (0-65535)%s",
Harald Welte59b04682009-06-10 05:40:52 +08001389 lac, VTY_NEWLINE);
1390 return CMD_WARNING;
1391 }
Holger Hans Peter Freyther6c6ab862009-10-01 04:07:15 +02001392
1393 if (lac == GSM_LAC_RESERVED_DETACHED || lac == GSM_LAC_RESERVED_ALL_BTS) {
1394 vty_out(vty, "%% LAC %d is reserved by GSM 04.08%s",
1395 lac, VTY_NEWLINE);
1396 return CMD_WARNING;
1397 }
1398
Harald Welte59b04682009-06-10 05:40:52 +08001399 bts->location_area_code = lac;
1400
1401 return CMD_SUCCESS;
1402}
1403
Harald Weltea54a2bb2009-12-01 18:04:30 +05301404
Harald Welte59b04682009-06-10 05:40:52 +08001405DEFUN(cfg_bts_tsc,
1406 cfg_bts_tsc_cmd,
1407 "training_sequence_code <0-255>",
1408 "Set the Training Sequence Code (TSC) of this BTS\n")
1409{
1410 struct gsm_bts *bts = vty->index;
1411 int tsc = atoi(argv[0]);
1412
1413 if (tsc < 0 || tsc > 0xff) {
1414 vty_out(vty, "%% TSC %d is not in the valid range (0-255)%s",
1415 tsc, VTY_NEWLINE);
1416 return CMD_WARNING;
1417 }
1418 bts->tsc = tsc;
1419
1420 return CMD_SUCCESS;
1421}
1422
1423DEFUN(cfg_bts_bsic,
1424 cfg_bts_bsic_cmd,
1425 "base_station_id_code <0-63>",
1426 "Set the Base Station Identity Code (BSIC) of this BTS\n")
1427{
1428 struct gsm_bts *bts = vty->index;
1429 int bsic = atoi(argv[0]);
1430
1431 if (bsic < 0 || bsic > 0x3f) {
Harald Welte62868882009-08-08 16:12:58 +02001432 vty_out(vty, "%% BSIC %d is not in the valid range (0-255)%s",
Harald Welte59b04682009-06-10 05:40:52 +08001433 bsic, VTY_NEWLINE);
1434 return CMD_WARNING;
1435 }
1436 bts->bsic = bsic;
1437
1438 return CMD_SUCCESS;
1439}
1440
1441
1442DEFUN(cfg_bts_unit_id,
1443 cfg_bts_unit_id_cmd,
Harald Weltef515aa02009-08-07 13:27:09 +02001444 "ip.access unit_id <0-65534> <0-255>",
1445 "Set the ip.access BTS Unit ID of this BTS\n")
Harald Welte59b04682009-06-10 05:40:52 +08001446{
1447 struct gsm_bts *bts = vty->index;
1448 int site_id = atoi(argv[0]);
1449 int bts_id = atoi(argv[1]);
1450
Harald Weltef515aa02009-08-07 13:27:09 +02001451 if (!is_ipaccess_bts(bts)) {
1452 vty_out(vty, "%% BTS is not of ip.access type%s", VTY_NEWLINE);
1453 return CMD_WARNING;
1454 }
1455
Harald Welte59b04682009-06-10 05:40:52 +08001456 bts->ip_access.site_id = site_id;
1457 bts->ip_access.bts_id = bts_id;
1458
1459 return CMD_SUCCESS;
1460}
1461
Harald Welte9e002452010-05-11 21:53:49 +02001462#define OML_STR "Organization & Maintenance Link\n"
1463#define IPA_STR "ip.access Specific Options\n"
1464
Harald Welte25572872009-10-20 00:22:00 +02001465DEFUN(cfg_bts_stream_id,
1466 cfg_bts_stream_id_cmd,
1467 "oml ip.access stream_id <0-255>",
Harald Welte9e002452010-05-11 21:53:49 +02001468 OML_STR IPA_STR
Harald Welte25572872009-10-20 00:22:00 +02001469 "Set the ip.access Stream ID of the OML link of this BTS\n")
1470{
1471 struct gsm_bts *bts = vty->index;
1472 int stream_id = atoi(argv[0]);
1473
1474 if (!is_ipaccess_bts(bts)) {
1475 vty_out(vty, "%% BTS is not of ip.access type%s", VTY_NEWLINE);
1476 return CMD_WARNING;
1477 }
1478
1479 bts->oml_tei = stream_id;
1480
1481 return CMD_SUCCESS;
1482}
1483
Harald Welte9e002452010-05-11 21:53:49 +02001484#define OML_E1_STR OML_STR "E1 Line\n"
Harald Welte25572872009-10-20 00:22:00 +02001485
Harald Welte62868882009-08-08 16:12:58 +02001486DEFUN(cfg_bts_oml_e1,
1487 cfg_bts_oml_e1_cmd,
1488 "oml e1 line E1_LINE timeslot <1-31> sub-slot (0|1|2|3|full)",
Harald Welte9e002452010-05-11 21:53:49 +02001489 OML_E1_STR
Harald Welte62868882009-08-08 16:12:58 +02001490 "E1 interface to be used for OML\n")
1491{
1492 struct gsm_bts *bts = vty->index;
1493
1494 parse_e1_link(&bts->oml_e1_link, argv[0], argv[1], argv[2]);
1495
1496 return CMD_SUCCESS;
1497}
1498
1499
1500DEFUN(cfg_bts_oml_e1_tei,
1501 cfg_bts_oml_e1_tei_cmd,
1502 "oml e1 tei <0-63>",
Harald Welte9e002452010-05-11 21:53:49 +02001503 OML_E1_STR
Harald Welte62868882009-08-08 16:12:58 +02001504 "Set the TEI to be used for OML")
1505{
1506 struct gsm_bts *bts = vty->index;
1507
1508 bts->oml_tei = atoi(argv[0]);
1509
1510 return CMD_SUCCESS;
1511}
1512
Harald Welte3e774612009-08-10 13:48:16 +02001513DEFUN(cfg_bts_challoc, cfg_bts_challoc_cmd,
1514 "channel allocator (ascending|descending)",
Harald Welte9e002452010-05-11 21:53:49 +02001515 "Channnel Allocator\n" "Channel Allocator\n"
1516 "Allocate Timeslots and Transceivers in ascending order\n"
1517 "Allocate Timeslots and Transceivers in descending order\n")
Harald Welte3e774612009-08-10 13:48:16 +02001518{
1519 struct gsm_bts *bts = vty->index;
1520
1521 if (!strcmp(argv[0], "ascending"))
1522 bts->chan_alloc_reverse = 0;
1523 else
1524 bts->chan_alloc_reverse = 1;
1525
1526 return CMD_SUCCESS;
1527}
1528
Harald Welte9e002452010-05-11 21:53:49 +02001529#define RACH_STR "Random Access Control Channel\n"
1530
Sylvain Munaut8e2d8de2009-12-22 13:43:26 +01001531DEFUN(cfg_bts_rach_tx_integer,
1532 cfg_bts_rach_tx_integer_cmd,
1533 "rach tx integer <0-15>",
Harald Welte9e002452010-05-11 21:53:49 +02001534 RACH_STR
Sylvain Munaut8e2d8de2009-12-22 13:43:26 +01001535 "Set the raw tx integer value in RACH Control parameters IE")
1536{
1537 struct gsm_bts *bts = vty->index;
1538 bts->si_common.rach_control.tx_integer = atoi(argv[0]) & 0xf;
1539 return CMD_SUCCESS;
1540}
1541
1542DEFUN(cfg_bts_rach_max_trans,
1543 cfg_bts_rach_max_trans_cmd,
1544 "rach max transmission (1|2|4|7)",
Harald Welte9e002452010-05-11 21:53:49 +02001545 RACH_STR
Sylvain Munaut8e2d8de2009-12-22 13:43:26 +01001546 "Set the maximum number of RACH burst transmissions")
1547{
1548 struct gsm_bts *bts = vty->index;
1549 bts->si_common.rach_control.max_trans = rach_max_trans_val2raw(atoi(argv[0]));
1550 return CMD_SUCCESS;
1551}
1552
Harald Welte9e002452010-05-11 21:53:49 +02001553#define NM_STR "Network Management\n"
1554
Holger Hans Peter Freyther697ed2b2010-04-25 23:08:39 +08001555DEFUN(cfg_bts_rach_nm_b_thresh,
1556 cfg_bts_rach_nm_b_thresh_cmd,
1557 "rach nm busy threshold <0-255>",
Harald Welte9e002452010-05-11 21:53:49 +02001558 RACH_STR NM_STR
1559 "Set the NM Busy Threshold in dB")
Holger Hans Peter Freyther697ed2b2010-04-25 23:08:39 +08001560{
1561 struct gsm_bts *bts = vty->index;
1562 bts->rach_b_thresh = atoi(argv[0]);
1563 return CMD_SUCCESS;
1564}
1565
1566DEFUN(cfg_bts_rach_nm_ldavg,
1567 cfg_bts_rach_nm_ldavg_cmd,
1568 "rach nm load average <0-65535>",
Harald Welte9e002452010-05-11 21:53:49 +02001569 RACH_STR NM_STR
1570 "Set the NM Loadaverage Slots value")
Holger Hans Peter Freyther697ed2b2010-04-25 23:08:39 +08001571{
1572 struct gsm_bts *bts = vty->index;
1573 bts->rach_ldavg_slots = atoi(argv[0]);
1574 return CMD_SUCCESS;
1575}
1576
Harald Welte (local)e19be3f2009-08-12 13:28:23 +02001577DEFUN(cfg_bts_cell_barred, cfg_bts_cell_barred_cmd,
1578 "cell barred (0|1)",
1579 "Should this cell be barred from access?")
1580{
1581 struct gsm_bts *bts = vty->index;
1582
Harald Welte8c973ba2009-12-21 23:08:18 +01001583 bts->si_common.rach_control.cell_bar = atoi(argv[0]);
Harald Welte (local)e19be3f2009-08-12 13:28:23 +02001584
1585 return CMD_SUCCESS;
1586}
1587
Holger Hans Peter Freyther440984b2010-05-14 00:39:19 +08001588DEFUN(cfg_bts_rach_ec_allowed, cfg_bts_rach_ec_allowed_cmd,
1589 "rach emergency call allowed (0|1)",
1590 "Should this cell allow emergency calls?")
1591{
1592 struct gsm_bts *bts = vty->index;
1593
1594 if (atoi(argv[0]) == 0)
1595 bts->si_common.rach_control.t2 |= 0x4;
1596 else
1597 bts->si_common.rach_control.t2 &= ~0x4;
1598
1599 return CMD_SUCCESS;
1600}
1601
Harald Welte (local)cbd46102009-08-13 10:14:26 +02001602DEFUN(cfg_bts_ms_max_power, cfg_bts_ms_max_power_cmd,
1603 "ms max power <0-40>",
1604 "Maximum transmit power of the MS")
1605{
1606 struct gsm_bts *bts = vty->index;
1607
1608 bts->ms_max_power = atoi(argv[0]);
1609
1610 return CMD_SUCCESS;
1611}
1612
Harald Welteb761bf82009-12-12 18:17:25 +01001613DEFUN(cfg_bts_cell_resel_hyst, cfg_bts_cell_resel_hyst_cmd,
1614 "cell reselection hysteresis <0-14>",
1615 "Cell Re-Selection Hysteresis in dB")
1616{
1617 struct gsm_bts *bts = vty->index;
1618
1619 bts->si_common.cell_sel_par.cell_resel_hyst = atoi(argv[0])/2;
1620
1621 return CMD_SUCCESS;
1622}
1623
1624DEFUN(cfg_bts_rxlev_acc_min, cfg_bts_rxlev_acc_min_cmd,
1625 "rxlev access min <0-63>",
1626 "Minimum RxLev needed for cell access (better than -110dBm)")
1627{
1628 struct gsm_bts *bts = vty->index;
1629
1630 bts->si_common.cell_sel_par.rxlev_acc_min = atoi(argv[0]);
1631
1632 return CMD_SUCCESS;
1633}
1634
Harald Welte (local)b6ea7f72009-08-14 23:09:25 +02001635DEFUN(cfg_bts_per_loc_upd, cfg_bts_per_loc_upd_cmd,
1636 "periodic location update <0-1530>",
1637 "Periodic Location Updating Interval in Minutes")
1638{
1639 struct gsm_bts *bts = vty->index;
1640
Harald Weltea54a2bb2009-12-01 18:04:30 +05301641 bts->si_common.chan_desc.t3212 = atoi(argv[0]) / 10;
Harald Welte (local)b6ea7f72009-08-14 23:09:25 +02001642
1643 return CMD_SUCCESS;
1644}
1645
Harald Welte9e002452010-05-11 21:53:49 +02001646#define GPRS_TEXT "GPRS Packet Network\n"
1647
Harald Welte410575a2010-03-14 23:30:30 +08001648DEFUN(cfg_bts_prs_bvci, cfg_bts_gprs_bvci_cmd,
Harald Welteb42fe342010-04-18 14:00:26 +02001649 "gprs cell bvci <2-65535>",
Harald Welte9e002452010-05-11 21:53:49 +02001650 GPRS_TEXT
1651 "GPRS Cell Settings\n"
Harald Welte3055e332010-03-14 15:37:43 +08001652 "GPRS BSSGP VC Identifier")
1653{
1654 struct gsm_bts *bts = vty->index;
1655
Harald Weltecb20b7a2010-04-18 15:51:20 +02001656 if (bts->gprs.mode == BTS_GPRS_NONE) {
Harald Weltec05a4b12010-03-14 23:56:56 +08001657 vty_out(vty, "%% GPRS not enabled on this BTS%s", VTY_NEWLINE);
1658 return CMD_WARNING;
1659 }
1660
Harald Welte3055e332010-03-14 15:37:43 +08001661 bts->gprs.cell.bvci = atoi(argv[0]);
1662
1663 return CMD_SUCCESS;
1664}
1665
Harald Welte4a048c52010-03-22 11:48:36 +08001666DEFUN(cfg_bts_gprs_nsei, cfg_bts_gprs_nsei_cmd,
1667 "gprs nsei <0-65535>",
Harald Welte9e002452010-05-11 21:53:49 +02001668 GPRS_TEXT
Harald Welte4a048c52010-03-22 11:48:36 +08001669 "GPRS NS Entity Identifier")
1670{
1671 struct gsm_bts *bts = vty->index;
1672
Harald Weltecb20b7a2010-04-18 15:51:20 +02001673 if (bts->gprs.mode == BTS_GPRS_NONE) {
Harald Welte4a048c52010-03-22 11:48:36 +08001674 vty_out(vty, "%% GPRS not enabled on this BTS%s", VTY_NEWLINE);
1675 return CMD_WARNING;
1676 }
1677
1678 bts->gprs.nse.nsei = atoi(argv[0]);
1679
1680 return CMD_SUCCESS;
1681}
1682
Harald Welte9e002452010-05-11 21:53:49 +02001683#define NSVC_TEXT "Network Service Virtual Connection (NS-VC)\n" \
1684 "NSVC Logical Number\n"
Harald Welte4a048c52010-03-22 11:48:36 +08001685
Harald Welte3055e332010-03-14 15:37:43 +08001686DEFUN(cfg_bts_gprs_nsvci, cfg_bts_gprs_nsvci_cmd,
1687 "gprs nsvc <0-1> nsvci <0-65535>",
Harald Welte9e002452010-05-11 21:53:49 +02001688 GPRS_TEXT NSVC_TEXT
1689 "NS Virtual Connection Identifier\n"
Harald Welte3055e332010-03-14 15:37:43 +08001690 "GPRS NS VC Identifier")
1691{
1692 struct gsm_bts *bts = vty->index;
1693 int idx = atoi(argv[0]);
1694
Harald Weltecb20b7a2010-04-18 15:51:20 +02001695 if (bts->gprs.mode == BTS_GPRS_NONE) {
Harald Weltec05a4b12010-03-14 23:56:56 +08001696 vty_out(vty, "%% GPRS not enabled on this BTS%s", VTY_NEWLINE);
1697 return CMD_WARNING;
1698 }
1699
Harald Welte3055e332010-03-14 15:37:43 +08001700 bts->gprs.nsvc[idx].nsvci = atoi(argv[1]);
1701
1702 return CMD_SUCCESS;
1703}
1704
Harald Welte410575a2010-03-14 23:30:30 +08001705DEFUN(cfg_bts_gprs_nsvc_lport, cfg_bts_gprs_nsvc_lport_cmd,
1706 "gprs nsvc <0-1> local udp port <0-65535>",
Harald Welte9e002452010-05-11 21:53:49 +02001707 GPRS_TEXT NSVC_TEXT
Harald Welte410575a2010-03-14 23:30:30 +08001708 "GPRS NS Local UDP Port")
1709{
1710 struct gsm_bts *bts = vty->index;
1711 int idx = atoi(argv[0]);
1712
Harald Weltecb20b7a2010-04-18 15:51:20 +02001713 if (bts->gprs.mode == BTS_GPRS_NONE) {
Harald Weltec05a4b12010-03-14 23:56:56 +08001714 vty_out(vty, "%% GPRS not enabled on this BTS%s", VTY_NEWLINE);
1715 return CMD_WARNING;
1716 }
1717
Harald Welte410575a2010-03-14 23:30:30 +08001718 bts->gprs.nsvc[idx].local_port = atoi(argv[1]);
1719
1720 return CMD_SUCCESS;
1721}
1722
1723DEFUN(cfg_bts_gprs_nsvc_rport, cfg_bts_gprs_nsvc_rport_cmd,
1724 "gprs nsvc <0-1> remote udp port <0-65535>",
Harald Welte9e002452010-05-11 21:53:49 +02001725 GPRS_TEXT NSVC_TEXT
Harald Welte410575a2010-03-14 23:30:30 +08001726 "GPRS NS Remote UDP Port")
1727{
1728 struct gsm_bts *bts = vty->index;
1729 int idx = atoi(argv[0]);
1730
Harald Weltecb20b7a2010-04-18 15:51:20 +02001731 if (bts->gprs.mode == BTS_GPRS_NONE) {
Harald Weltec05a4b12010-03-14 23:56:56 +08001732 vty_out(vty, "%% GPRS not enabled on this BTS%s", VTY_NEWLINE);
1733 return CMD_WARNING;
1734 }
1735
Harald Welte410575a2010-03-14 23:30:30 +08001736 bts->gprs.nsvc[idx].remote_port = atoi(argv[1]);
1737
1738 return CMD_SUCCESS;
1739}
1740
1741DEFUN(cfg_bts_gprs_nsvc_rip, cfg_bts_gprs_nsvc_rip_cmd,
1742 "gprs nsvc <0-1> remote ip A.B.C.D",
Harald Welte9e002452010-05-11 21:53:49 +02001743 GPRS_TEXT NSVC_TEXT
Harald Welte410575a2010-03-14 23:30:30 +08001744 "GPRS NS Remote IP Address")
1745{
1746 struct gsm_bts *bts = vty->index;
1747 int idx = atoi(argv[0]);
1748 struct in_addr ia;
1749
Harald Weltecb20b7a2010-04-18 15:51:20 +02001750 if (bts->gprs.mode == BTS_GPRS_NONE) {
Harald Weltec05a4b12010-03-14 23:56:56 +08001751 vty_out(vty, "%% GPRS not enabled on this BTS%s", VTY_NEWLINE);
1752 return CMD_WARNING;
1753 }
1754
Harald Welte410575a2010-03-14 23:30:30 +08001755 inet_aton(argv[1], &ia);
1756 bts->gprs.nsvc[idx].remote_ip = ntohl(ia.s_addr);
1757
1758 return CMD_SUCCESS;
1759}
1760
Harald Weltea9251762010-05-11 23:50:21 +02001761DEFUN(cfg_bts_gprs_ns_timer, cfg_bts_gprs_ns_timer_cmd,
1762 "gprs ns timer " NS_TIMERS " <0-255>",
1763 GPRS_TEXT "Network Service\n"
1764 "Network Service Timer\n"
1765 NS_TIMERS_HELP "Timer Value\n")
1766{
1767 struct gsm_bts *bts = vty->index;
1768 int idx = get_string_value(gprs_ns_timer_strs, argv[0]);
1769 int val = atoi(argv[1]);
1770
1771 if (bts->gprs.mode == BTS_GPRS_NONE) {
1772 vty_out(vty, "%% GPRS not enabled on this BTS%s", VTY_NEWLINE);
1773 return CMD_WARNING;
1774 }
1775
1776 if (idx < 0 || idx >= ARRAY_SIZE(bts->gprs.nse.timer))
1777 return CMD_WARNING;
1778
1779 bts->gprs.nse.timer[idx] = val;
1780
1781 return CMD_SUCCESS;
1782}
1783
1784#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 Welte18ce31c2010-05-14 20:05:17 +02001785#define BSSGP_TIMERS_HELP \
1786 "Tbvc-block timeout\n" \
1787 "Tbvc-block retries\n" \
1788 "Tbvc-unblock retries\n" \
1789 "Tbvcc-reset timeout\n" \
1790 "Tbvc-reset retries\n" \
1791 "Tbvc-suspend timeout\n" \
1792 "Tbvc-suspend retries\n" \
1793 "Tbvc-resume timeout\n" \
1794 "Tbvc-resume retries\n" \
1795 "Tbvc-capa-update timeout\n" \
1796 "Tbvc-capa-update retries\n"
Harald Weltea9251762010-05-11 23:50:21 +02001797
1798DEFUN(cfg_bts_gprs_cell_timer, cfg_bts_gprs_cell_timer_cmd,
1799 "gprs cell timer " BSSGP_TIMERS " <0-255>",
1800 GPRS_TEXT "Cell / BSSGP\n"
1801 "Cell/BSSGP Timer\n"
1802 BSSGP_TIMERS_HELP "Timer Value\n")
1803{
1804 struct gsm_bts *bts = vty->index;
1805 int idx = get_string_value(gprs_bssgp_cfg_strs, argv[0]);
1806 int val = atoi(argv[1]);
1807
1808 if (bts->gprs.mode == BTS_GPRS_NONE) {
1809 vty_out(vty, "%% GPRS not enabled on this BTS%s", VTY_NEWLINE);
1810 return CMD_WARNING;
1811 }
1812
1813 if (idx < 0 || idx >= ARRAY_SIZE(bts->gprs.cell.timer))
1814 return CMD_WARNING;
1815
1816 bts->gprs.cell.timer[idx] = val;
1817
1818 return CMD_SUCCESS;
1819}
1820
Harald Welte3055e332010-03-14 15:37:43 +08001821DEFUN(cfg_bts_gprs_rac, cfg_bts_gprs_rac_cmd,
1822 "gprs routing area <0-255>",
Harald Welte9e002452010-05-11 21:53:49 +02001823 GPRS_TEXT
Harald Welte3055e332010-03-14 15:37:43 +08001824 "GPRS Routing Area Code")
1825{
1826 struct gsm_bts *bts = vty->index;
1827
Harald Weltecb20b7a2010-04-18 15:51:20 +02001828 if (bts->gprs.mode == BTS_GPRS_NONE) {
Harald Weltec05a4b12010-03-14 23:56:56 +08001829 vty_out(vty, "%% GPRS not enabled on this BTS%s", VTY_NEWLINE);
1830 return CMD_WARNING;
1831 }
1832
Harald Welte3055e332010-03-14 15:37:43 +08001833 bts->gprs.rac = atoi(argv[0]);
1834
1835 return CMD_SUCCESS;
1836}
1837
Harald Weltecb20b7a2010-04-18 15:51:20 +02001838DEFUN(cfg_bts_gprs_mode, cfg_bts_gprs_mode_cmd,
1839 "gprs mode (none|gprs|egprs)",
Harald Welte9e002452010-05-11 21:53:49 +02001840 GPRS_TEXT
1841 "GPRS Mode for this BTS\n"
1842 "GPRS Disabled on this BTS\n"
1843 "GPRS Enabled on this BTS\n"
1844 "EGPRS (EDGE) Enabled on this BTS\n")
Harald Welte410575a2010-03-14 23:30:30 +08001845{
1846 struct gsm_bts *bts = vty->index;
Harald Welte20e275a2010-06-14 22:44:42 +02001847 enum bts_gprs_mode mode = bts_gprs_mode_parse(argv[0]);
Harald Welte410575a2010-03-14 23:30:30 +08001848
Harald Welte20e275a2010-06-14 22:44:42 +02001849 if (mode != BTS_GPRS_NONE &&
1850 !gsm_bts_has_feature(bts, BTS_FEAT_GPRS)) {
1851 vty_out(vty, "This BTS type does not support %s%s", argv[0],
1852 VTY_NEWLINE);
1853 return CMD_WARNING;
1854 }
1855 if (mode == BTS_GPRS_EGPRS &&
1856 !gsm_bts_has_feature(bts, BTS_FEAT_EGPRS)) {
1857 vty_out(vty, "This BTS type does not support %s%s", argv[0],
1858 VTY_NEWLINE);
1859 return CMD_WARNING;
1860 }
1861
1862 bts->gprs.mode = mode;
Harald Welte410575a2010-03-14 23:30:30 +08001863
1864 return CMD_SUCCESS;
1865}
1866
Harald Welted8acf142010-07-30 11:50:09 +02001867#define SI_TEXT "System Information Messages\n"
1868#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)"
1869#define SI_TYPE_HELP "System Information Type 1\n" \
1870 "System Information Type 2\n" \
1871 "System Information Type 3\n" \
1872 "System Information Type 4\n" \
1873 "System Information Type 5\n" \
1874 "System Information Type 6\n" \
1875 "System Information Type 7\n" \
1876 "System Information Type 8\n" \
1877 "System Information Type 9\n" \
1878 "System Information Type 10\n" \
1879 "System Information Type 13\n" \
1880 "System Information Type 16\n" \
1881 "System Information Type 17\n" \
1882 "System Information Type 18\n" \
1883 "System Information Type 19\n" \
1884 "System Information Type 20\n" \
1885 "System Information Type 2bis\n" \
1886 "System Information Type 2ter\n" \
1887 "System Information Type 2quater\n" \
1888 "System Information Type 5bis\n" \
1889 "System Information Type 5ter\n"
1890
1891DEFUN(cfg_bts_si_mode, cfg_bts_si_mode_cmd,
1892 "system-information " SI_TYPE_TEXT " mode (static|computed)",
1893 SI_TEXT SI_TYPE_HELP
1894 "System Information Mode\n"
1895 "Static user-specified\n"
1896 "Dynamic, BSC-computed\n")
1897{
1898 struct gsm_bts *bts = vty->index;
1899 int type;
1900
1901 type = get_string_value(osmo_sitype_strs, argv[0]);
1902 if (type < 0) {
1903 vty_out(vty, "Error SI Type%s", VTY_NEWLINE);
1904 return CMD_WARNING;
1905 }
1906
1907 if (!strcmp(argv[1], "static"))
1908 bts->si_mode_static |= (1 << type);
1909 else
1910 bts->si_mode_static &= ~(1 << type);
1911
1912 return CMD_SUCCESS;
1913}
1914
1915DEFUN(cfg_bts_si_static, cfg_bts_si_static_cmd,
1916 "system-information " SI_TYPE_TEXT " static HEXSTRING",
1917 SI_TEXT SI_TYPE_HELP
1918 "Static System Information filling\n"
1919 "Static user-specified SI content in HEX notation\n")
1920{
1921 struct gsm_bts *bts = vty->index;
1922 int rc, type;
1923
1924 type = get_string_value(osmo_sitype_strs, argv[0]);
1925 if (type < 0) {
1926 vty_out(vty, "Error SI Type%s", VTY_NEWLINE);
1927 return CMD_WARNING;
1928 }
1929
1930 if (!(bts->si_mode_static & (1 << type))) {
1931 vty_out(vty, "SI Type %s is not configured in static mode%s",
1932 get_value_string(osmo_sitype_strs, type), VTY_NEWLINE);
1933 return CMD_WARNING;
1934 }
1935
Harald Welte9f09ac32010-07-30 11:53:18 +02001936 /* Fill buffer with padding pattern */
1937 memset(bts->si_buf[type], 0x2b, sizeof(bts->si_buf[type]));
1938
1939 /* Parse the user-specified SI in hex format, [partially] overwriting padding */
Harald Welted8acf142010-07-30 11:50:09 +02001940 rc = hexparse(argv[1], bts->si_buf[type], sizeof(bts->si_buf[0]));
1941 if (rc < 0 || rc > sizeof(bts->si_buf[0])) {
1942 vty_out(vty, "Error parsing HEXSTRING%s", VTY_NEWLINE);
1943 return CMD_WARNING;
1944 }
1945
1946 /* Mark this SI as present */
1947 bts->si_valid |= (1 << type);
1948
1949 return CMD_SUCCESS;
1950}
1951
1952
Harald Welte9e002452010-05-11 21:53:49 +02001953#define TRX_TEXT "Radio Transceiver\n"
Harald Welte3e774612009-08-10 13:48:16 +02001954
Harald Welte59b04682009-06-10 05:40:52 +08001955/* per TRX configuration */
1956DEFUN(cfg_trx,
1957 cfg_trx_cmd,
1958 "trx TRX_NR",
Harald Welte9e002452010-05-11 21:53:49 +02001959 TRX_TEXT
Harald Welte59b04682009-06-10 05:40:52 +08001960 "Select a TRX to configure")
1961{
1962 int trx_nr = atoi(argv[0]);
1963 struct gsm_bts *bts = vty->index;
1964 struct gsm_bts_trx *trx;
1965
Harald Weltee712a5f2009-06-21 16:17:15 +02001966 if (trx_nr > bts->num_trx) {
1967 vty_out(vty, "%% The next unused TRX number in this BTS is %u%s",
1968 bts->num_trx, VTY_NEWLINE);
Harald Welte59b04682009-06-10 05:40:52 +08001969 return CMD_WARNING;
Harald Weltee712a5f2009-06-21 16:17:15 +02001970 } else if (trx_nr == bts->num_trx) {
1971 /* we need to allocate a new one */
1972 trx = gsm_bts_trx_alloc(bts);
Holger Hans Peter Freyther71135142010-03-29 08:47:44 +02001973 } else
Harald Weltee712a5f2009-06-21 16:17:15 +02001974 trx = gsm_bts_trx_num(bts, trx_nr);
Holger Hans Peter Freyther71135142010-03-29 08:47:44 +02001975
Harald Weltee712a5f2009-06-21 16:17:15 +02001976 if (!trx)
1977 return CMD_WARNING;
Harald Welte59b04682009-06-10 05:40:52 +08001978
1979 vty->index = trx;
Harald Welte8791dac2010-05-14 17:59:53 +02001980 vty->index_sub = &trx->description;
Harald Welte59b04682009-06-10 05:40:52 +08001981 vty->node = TRX_NODE;
1982
1983 return CMD_SUCCESS;
1984}
1985
1986DEFUN(cfg_trx_arfcn,
1987 cfg_trx_arfcn_cmd,
Harald Welte00044592010-05-14 19:00:52 +02001988 "arfcn <0-1024>",
Harald Welte59b04682009-06-10 05:40:52 +08001989 "Set the ARFCN for this TRX\n")
1990{
1991 int arfcn = atoi(argv[0]);
1992 struct gsm_bts_trx *trx = vty->index;
1993
1994 /* FIXME: check if this ARFCN is supported by this TRX */
1995
1996 trx->arfcn = arfcn;
1997
1998 /* FIXME: patch ARFCN into SYSTEM INFORMATION */
1999 /* FIXME: use OML layer to update the ARFCN */
2000 /* FIXME: use RSL layer to update SYSTEM INFORMATION */
2001
2002 return CMD_SUCCESS;
2003}
2004
Harald Welte (local)b709bfe2009-12-27 20:56:38 +01002005DEFUN(cfg_trx_nominal_power,
2006 cfg_trx_nominal_power_cmd,
2007 "nominal power <0-100>",
2008 "Nominal TRX RF Power in dB\n")
2009{
2010 struct gsm_bts_trx *trx = vty->index;
2011
2012 trx->nominal_power = atoi(argv[0]);
2013
2014 return CMD_SUCCESS;
2015}
2016
Harald Welte91afe4c2009-06-20 18:15:19 +02002017DEFUN(cfg_trx_max_power_red,
2018 cfg_trx_max_power_red_cmd,
2019 "max_power_red <0-100>",
2020 "Reduction of maximum BS RF Power in dB\n")
2021{
2022 int maxpwr_r = atoi(argv[0]);
2023 struct gsm_bts_trx *trx = vty->index;
Harald Welte01acd742009-11-18 09:20:22 +01002024 int upper_limit = 24; /* default 12.21 max power red. */
Harald Welte91afe4c2009-06-20 18:15:19 +02002025
2026 /* FIXME: check if our BTS type supports more than 12 */
2027 if (maxpwr_r < 0 || maxpwr_r > upper_limit) {
2028 vty_out(vty, "%% Power %d dB is not in the valid range%s",
2029 maxpwr_r, VTY_NEWLINE);
2030 return CMD_WARNING;
2031 }
2032 if (maxpwr_r & 1) {
2033 vty_out(vty, "%% Power %d dB is not an even value%s",
2034 maxpwr_r, VTY_NEWLINE);
2035 return CMD_WARNING;
2036 }
2037
2038 trx->max_power_red = maxpwr_r;
2039
2040 /* FIXME: make sure we update this using OML */
2041
2042 return CMD_SUCCESS;
2043}
2044
Harald Welte62868882009-08-08 16:12:58 +02002045DEFUN(cfg_trx_rsl_e1,
2046 cfg_trx_rsl_e1_cmd,
2047 "rsl e1 line E1_LINE timeslot <1-31> sub-slot (0|1|2|3|full)",
2048 "E1 interface to be used for RSL\n")
2049{
2050 struct gsm_bts_trx *trx = vty->index;
2051
2052 parse_e1_link(&trx->rsl_e1_link, argv[0], argv[1], argv[2]);
2053
2054 return CMD_SUCCESS;
2055}
2056
2057DEFUN(cfg_trx_rsl_e1_tei,
2058 cfg_trx_rsl_e1_tei_cmd,
2059 "rsl e1 tei <0-63>",
2060 "Set the TEI to be used for RSL")
2061{
2062 struct gsm_bts_trx *trx = vty->index;
2063
2064 trx->rsl_tei = atoi(argv[0]);
2065
2066 return CMD_SUCCESS;
2067}
2068
Holger Hans Peter Freyther1c8b4802009-11-11 11:54:24 +01002069DEFUN(cfg_trx_rf_locked,
2070 cfg_trx_rf_locked_cmd,
2071 "rf_locked (0|1)",
2072 "Turn off RF of the TRX.\n")
2073{
2074 int locked = atoi(argv[0]);
2075 struct gsm_bts_trx *trx = vty->index;
2076
2077 gsm_trx_lock_rf(trx, locked);
2078 return CMD_SUCCESS;
2079}
Harald Welte62868882009-08-08 16:12:58 +02002080
Harald Welte59b04682009-06-10 05:40:52 +08002081/* per TS configuration */
2082DEFUN(cfg_ts,
2083 cfg_ts_cmd,
Harald Welte62868882009-08-08 16:12:58 +02002084 "timeslot <0-7>",
Harald Welte59b04682009-06-10 05:40:52 +08002085 "Select a Timeslot to configure")
2086{
2087 int ts_nr = atoi(argv[0]);
2088 struct gsm_bts_trx *trx = vty->index;
2089 struct gsm_bts_trx_ts *ts;
2090
2091 if (ts_nr >= TRX_NR_TS) {
2092 vty_out(vty, "%% A GSM TRX only has %u Timeslots per TRX%s",
2093 TRX_NR_TS, VTY_NEWLINE);
2094 return CMD_WARNING;
2095 }
2096
2097 ts = &trx->ts[ts_nr];
2098
2099 vty->index = ts;
2100 vty->node = TS_NODE;
2101
2102 return CMD_SUCCESS;
2103}
2104
Harald Welte3ffe1b32009-08-07 00:25:23 +02002105DEFUN(cfg_ts_pchan,
2106 cfg_ts_pchan_cmd,
2107 "phys_chan_config PCHAN",
2108 "Physical Channel configuration (TCH/SDCCH/...)")
2109{
2110 struct gsm_bts_trx_ts *ts = vty->index;
2111 int pchanc;
2112
2113 pchanc = gsm_pchan_parse(argv[0]);
2114 if (pchanc < 0)
2115 return CMD_WARNING;
2116
2117 ts->pchan = pchanc;
2118
2119 return CMD_SUCCESS;
2120}
2121
Harald Weltea42a93f2010-06-14 22:26:10 +02002122#define HOPPING_STR "Configure frequency hopping\n"
2123
2124DEFUN(cfg_ts_hopping,
2125 cfg_ts_hopping_cmd,
2126 "hopping enabled (0|1)",
2127 HOPPING_STR "Enable or disable frequency hopping\n"
2128 "Disable frequency hopping\n" "Enable frequency hopping\n")
2129{
2130 struct gsm_bts_trx_ts *ts = vty->index;
Harald Welte059c1ef2010-06-14 22:47:37 +02002131 int enabled = atoi(argv[0]);
Harald Weltea42a93f2010-06-14 22:26:10 +02002132
Harald Welte059c1ef2010-06-14 22:47:37 +02002133 if (enabled && !gsm_bts_has_feature(ts->trx->bts, BTS_FEAT_HOPPING)) {
2134 vty_out(vty, "BTS model does not support hopping%s",
2135 VTY_NEWLINE);
2136 return CMD_WARNING;
2137 }
2138
2139 ts->hopping.enabled = enabled;
Harald Weltea42a93f2010-06-14 22:26:10 +02002140
2141 return CMD_SUCCESS;
2142}
2143
Harald Welte67104d12009-09-12 13:05:33 +02002144DEFUN(cfg_ts_hsn,
2145 cfg_ts_hsn_cmd,
Harald Weltea42a93f2010-06-14 22:26:10 +02002146 "hopping sequence-number <0-63>",
2147 HOPPING_STR
Harald Welte67104d12009-09-12 13:05:33 +02002148 "Which hopping sequence to use for this channel")
2149{
2150 struct gsm_bts_trx_ts *ts = vty->index;
2151
2152 ts->hopping.hsn = atoi(argv[0]);
2153
2154 return CMD_SUCCESS;
2155}
2156
2157DEFUN(cfg_ts_maio,
2158 cfg_ts_maio_cmd,
2159 "hopping maio <0-63>",
Harald Weltea42a93f2010-06-14 22:26:10 +02002160 HOPPING_STR
Harald Welte67104d12009-09-12 13:05:33 +02002161 "Which hopping MAIO to use for this channel")
2162{
2163 struct gsm_bts_trx_ts *ts = vty->index;
2164
2165 ts->hopping.maio = atoi(argv[0]);
2166
2167 return CMD_SUCCESS;
2168}
2169
2170DEFUN(cfg_ts_arfcn_add,
2171 cfg_ts_arfcn_add_cmd,
2172 "hopping arfcn add <0-1023>",
Harald Weltea42a93f2010-06-14 22:26:10 +02002173 HOPPING_STR "Configure hopping ARFCN list\n"
2174 "Add an entry to the hopping ARFCN list\n" "ARFCN\n")
Harald Welte67104d12009-09-12 13:05:33 +02002175{
2176 struct gsm_bts_trx_ts *ts = vty->index;
2177 int arfcn = atoi(argv[0]);
2178
Harald Weltea42a93f2010-06-14 22:26:10 +02002179 bitvec_set_bit_pos(&ts->hopping.arfcns, arfcn, 1);
2180
Harald Welte67104d12009-09-12 13:05:33 +02002181 return CMD_SUCCESS;
2182}
2183
2184DEFUN(cfg_ts_arfcn_del,
2185 cfg_ts_arfcn_del_cmd,
2186 "hopping arfcn del <0-1023>",
Harald Weltea42a93f2010-06-14 22:26:10 +02002187 HOPPING_STR "Configure hopping ARFCN list\n"
2188 "Delete an entry to the hopping ARFCN list\n" "ARFCN\n")
Harald Welte67104d12009-09-12 13:05:33 +02002189{
2190 struct gsm_bts_trx_ts *ts = vty->index;
2191 int arfcn = atoi(argv[0]);
2192
Harald Weltea42a93f2010-06-14 22:26:10 +02002193 bitvec_set_bit_pos(&ts->hopping.arfcns, arfcn, 0);
2194
Harald Welte67104d12009-09-12 13:05:33 +02002195 return CMD_SUCCESS;
2196}
2197
Harald Welte3ffe1b32009-08-07 00:25:23 +02002198DEFUN(cfg_ts_e1_subslot,
2199 cfg_ts_e1_subslot_cmd,
Harald Welte62868882009-08-08 16:12:58 +02002200 "e1 line E1_LINE timeslot <1-31> sub-slot (0|1|2|3|full)",
Harald Welte3ffe1b32009-08-07 00:25:23 +02002201 "E1 sub-slot connected to this on-air timeslot")
2202{
2203 struct gsm_bts_trx_ts *ts = vty->index;
2204
Harald Welte62868882009-08-08 16:12:58 +02002205 parse_e1_link(&ts->e1_link, argv[0], argv[1], argv[2]);
Harald Welte3ffe1b32009-08-07 00:25:23 +02002206
2207 return CMD_SUCCESS;
2208}
Harald Welte59b04682009-06-10 05:40:52 +08002209
Harald Weltea5b1dae2010-05-16 21:47:13 +02002210void openbsc_vty_print_statistics(struct vty *vty, struct gsm_network *net)
2211{
2212 vty_out(vty, "Channel Requests : %lu total, %lu no channel%s",
2213 counter_get(net->stats.chreq.total),
2214 counter_get(net->stats.chreq.no_channel), VTY_NEWLINE);
2215 vty_out(vty, "Channel Failures : %lu rf_failures, %lu rll failures%s",
2216 counter_get(net->stats.chan.rf_fail),
2217 counter_get(net->stats.chan.rll_err), VTY_NEWLINE);
2218 vty_out(vty, "Paging : %lu attempted, %lu complete, %lu expired%s",
2219 counter_get(net->stats.paging.attempted),
2220 counter_get(net->stats.paging.completed),
2221 counter_get(net->stats.paging.expired), VTY_NEWLINE);
2222 vty_out(vty, "BTS failures : %lu OML, %lu RSL%s",
2223 counter_get(net->stats.bts.oml_fail),
2224 counter_get(net->stats.bts.rsl_fail), VTY_NEWLINE);
2225}
2226
Harald Welte682ee5f2010-05-16 22:02:16 +02002227DEFUN(logging_fltr_imsi,
2228 logging_fltr_imsi_cmd,
2229 "logging filter imsi IMSI",
2230 LOGGING_STR FILTER_STR
2231 "Filter log messages by IMSI\n" "IMSI to be used as filter\n")
2232{
2233 struct telnet_connection *conn;
2234
2235 conn = (struct telnet_connection *) vty->priv;
2236 if (!conn->dbg) {
2237 vty_out(vty, "Logging was not enabled.%s", VTY_NEWLINE);
2238 return CMD_WARNING;
2239 }
2240
2241 log_set_imsi_filter(conn->dbg, argv[0]);
2242 return CMD_SUCCESS;
2243}
2244
Harald Welte40152872010-05-16 20:52:23 +02002245extern int bsc_vty_init_extra(void);
Harald Welte10c29f62010-05-16 19:20:24 +02002246extern const char *openbsc_copyright;
Holger Hans Peter Freytherc48a2a12010-04-10 00:08:28 +02002247
Harald Welte40152872010-05-16 20:52:23 +02002248int bsc_vty_init(void)
Harald Welte59b04682009-06-10 05:40:52 +08002249{
Harald Welte7bc28f62010-05-12 16:10:35 +00002250 install_element_ve(&show_net_cmd);
2251 install_element_ve(&show_bts_cmd);
2252 install_element_ve(&show_trx_cmd);
2253 install_element_ve(&show_ts_cmd);
2254 install_element_ve(&show_lchan_cmd);
Holger Hans Peter Freythere959b4e2010-05-14 02:08:49 +08002255 install_element_ve(&show_lchan_summary_cmd);
Harald Welte682ee5f2010-05-16 22:02:16 +02002256 install_element_ve(&logging_fltr_imsi_cmd);
Harald Welte59b04682009-06-10 05:40:52 +08002257
Harald Welte7bc28f62010-05-12 16:10:35 +00002258 install_element_ve(&show_e1drv_cmd);
2259 install_element_ve(&show_e1line_cmd);
2260 install_element_ve(&show_e1ts_cmd);
Harald Welte59b04682009-06-10 05:40:52 +08002261
Harald Welte7bc28f62010-05-12 16:10:35 +00002262 install_element_ve(&show_paging_cmd);
Harald Welte59b04682009-06-10 05:40:52 +08002263
Harald Welte682ee5f2010-05-16 22:02:16 +02002264 logging_vty_add_cmds();
Holger Hans Peter Freytherc8d862e2009-12-22 22:32:51 +01002265
Harald Weltee87eb462009-08-07 13:29:14 +02002266 install_element(CONFIG_NODE, &cfg_net_cmd);
2267 install_node(&net_node, config_write_net);
2268 install_default(GSMNET_NODE);
Harald Welte58ed1cb2010-05-14 18:59:17 +02002269 install_element(GSMNET_NODE, &ournode_exit_cmd);
Harald Weltedc82b9b2010-05-14 19:11:04 +02002270 install_element(GSMNET_NODE, &ournode_end_cmd);
Harald Welte62868882009-08-08 16:12:58 +02002271 install_element(GSMNET_NODE, &cfg_net_ncc_cmd);
Harald Weltee87eb462009-08-07 13:29:14 +02002272 install_element(GSMNET_NODE, &cfg_net_mnc_cmd);
2273 install_element(GSMNET_NODE, &cfg_net_name_short_cmd);
2274 install_element(GSMNET_NODE, &cfg_net_name_long_cmd);
Harald Welte (local)a59a27e2009-08-12 14:42:23 +02002275 install_element(GSMNET_NODE, &cfg_net_auth_policy_cmd);
Harald Welte59936d72009-11-18 20:33:19 +01002276 install_element(GSMNET_NODE, &cfg_net_reject_cause_cmd);
Harald Weltecca253a2009-08-30 15:47:06 +09002277 install_element(GSMNET_NODE, &cfg_net_encryption_cmd);
Holger Hans Peter Freyther96c89822009-11-16 17:12:38 +01002278 install_element(GSMNET_NODE, &cfg_net_neci_cmd);
Harald Welte52af1952009-12-13 10:53:12 +01002279 install_element(GSMNET_NODE, &cfg_net_rrlp_mode_cmd);
Harald Welte284ddba2009-12-14 17:49:15 +01002280 install_element(GSMNET_NODE, &cfg_net_mm_info_cmd);
Harald Welte0af9c9f2009-12-19 21:41:52 +01002281 install_element(GSMNET_NODE, &cfg_net_handover_cmd);
Harald Weltea8062f12009-12-21 16:51:50 +01002282 install_element(GSMNET_NODE, &cfg_net_ho_win_rxlev_avg_cmd);
2283 install_element(GSMNET_NODE, &cfg_net_ho_win_rxqual_avg_cmd);
2284 install_element(GSMNET_NODE, &cfg_net_ho_win_rxlev_avg_neigh_cmd);
2285 install_element(GSMNET_NODE, &cfg_net_ho_pwr_interval_cmd);
2286 install_element(GSMNET_NODE, &cfg_net_ho_pwr_hysteresis_cmd);
2287 install_element(GSMNET_NODE, &cfg_net_ho_max_distance_cmd);
Holger Hans Peter Freyther26ba2e72009-11-21 21:18:38 +01002288 install_element(GSMNET_NODE, &cfg_net_T3101_cmd);
Holger Hans Peter Freyther89733862009-11-21 21:42:26 +01002289 install_element(GSMNET_NODE, &cfg_net_T3103_cmd);
2290 install_element(GSMNET_NODE, &cfg_net_T3105_cmd);
2291 install_element(GSMNET_NODE, &cfg_net_T3107_cmd);
2292 install_element(GSMNET_NODE, &cfg_net_T3109_cmd);
2293 install_element(GSMNET_NODE, &cfg_net_T3111_cmd);
2294 install_element(GSMNET_NODE, &cfg_net_T3113_cmd);
2295 install_element(GSMNET_NODE, &cfg_net_T3115_cmd);
2296 install_element(GSMNET_NODE, &cfg_net_T3117_cmd);
2297 install_element(GSMNET_NODE, &cfg_net_T3119_cmd);
2298 install_element(GSMNET_NODE, &cfg_net_T3141_cmd);
Holger Hans Peter Freyther21d63ff2010-09-06 09:25:48 +08002299 install_element(GSMNET_NODE, &cfg_net_dtx_cmd);
Harald Weltee87eb462009-08-07 13:29:14 +02002300
2301 install_element(GSMNET_NODE, &cfg_bts_cmd);
Harald Welte97ceef92009-08-06 19:06:46 +02002302 install_node(&bts_node, config_write_bts);
Harald Welte59b04682009-06-10 05:40:52 +08002303 install_default(BTS_NODE);
Harald Welte58ed1cb2010-05-14 18:59:17 +02002304 install_element(BTS_NODE, &ournode_exit_cmd);
Harald Weltedc82b9b2010-05-14 19:11:04 +02002305 install_element(BTS_NODE, &ournode_end_cmd);
Harald Welte59b04682009-06-10 05:40:52 +08002306 install_element(BTS_NODE, &cfg_bts_type_cmd);
Harald Welte8791dac2010-05-14 17:59:53 +02002307 install_element(BTS_NODE, &cfg_description_cmd);
2308 install_element(BTS_NODE, &cfg_no_description_cmd);
Harald Welte91afe4c2009-06-20 18:15:19 +02002309 install_element(BTS_NODE, &cfg_bts_band_cmd);
Holger Hans Peter Freythera098dfb2009-08-21 14:44:12 +02002310 install_element(BTS_NODE, &cfg_bts_ci_cmd);
Harald Welte59b04682009-06-10 05:40:52 +08002311 install_element(BTS_NODE, &cfg_bts_lac_cmd);
2312 install_element(BTS_NODE, &cfg_bts_tsc_cmd);
Harald Welte62868882009-08-08 16:12:58 +02002313 install_element(BTS_NODE, &cfg_bts_bsic_cmd);
Harald Welte59b04682009-06-10 05:40:52 +08002314 install_element(BTS_NODE, &cfg_bts_unit_id_cmd);
Harald Welte25572872009-10-20 00:22:00 +02002315 install_element(BTS_NODE, &cfg_bts_stream_id_cmd);
Harald Welte62868882009-08-08 16:12:58 +02002316 install_element(BTS_NODE, &cfg_bts_oml_e1_cmd);
2317 install_element(BTS_NODE, &cfg_bts_oml_e1_tei_cmd);
Harald Welte3e774612009-08-10 13:48:16 +02002318 install_element(BTS_NODE, &cfg_bts_challoc_cmd);
Sylvain Munaut8e2d8de2009-12-22 13:43:26 +01002319 install_element(BTS_NODE, &cfg_bts_rach_tx_integer_cmd);
2320 install_element(BTS_NODE, &cfg_bts_rach_max_trans_cmd);
Holger Hans Peter Freyther697ed2b2010-04-25 23:08:39 +08002321 install_element(BTS_NODE, &cfg_bts_rach_nm_b_thresh_cmd);
2322 install_element(BTS_NODE, &cfg_bts_rach_nm_ldavg_cmd);
Harald Welte (local)e19be3f2009-08-12 13:28:23 +02002323 install_element(BTS_NODE, &cfg_bts_cell_barred_cmd);
Holger Hans Peter Freyther440984b2010-05-14 00:39:19 +08002324 install_element(BTS_NODE, &cfg_bts_rach_ec_allowed_cmd);
Harald Welte (local)cbd46102009-08-13 10:14:26 +02002325 install_element(BTS_NODE, &cfg_bts_ms_max_power_cmd);
Harald Welte (local)b6ea7f72009-08-14 23:09:25 +02002326 install_element(BTS_NODE, &cfg_bts_per_loc_upd_cmd);
Harald Welteb761bf82009-12-12 18:17:25 +01002327 install_element(BTS_NODE, &cfg_bts_cell_resel_hyst_cmd);
2328 install_element(BTS_NODE, &cfg_bts_rxlev_acc_min_cmd);
Harald Weltecb20b7a2010-04-18 15:51:20 +02002329 install_element(BTS_NODE, &cfg_bts_gprs_mode_cmd);
Harald Weltea9251762010-05-11 23:50:21 +02002330 install_element(BTS_NODE, &cfg_bts_gprs_ns_timer_cmd);
Harald Welte3055e332010-03-14 15:37:43 +08002331 install_element(BTS_NODE, &cfg_bts_gprs_rac_cmd);
2332 install_element(BTS_NODE, &cfg_bts_gprs_bvci_cmd);
Harald Weltea9251762010-05-11 23:50:21 +02002333 install_element(BTS_NODE, &cfg_bts_gprs_cell_timer_cmd);
Harald Welte4a048c52010-03-22 11:48:36 +08002334 install_element(BTS_NODE, &cfg_bts_gprs_nsei_cmd);
Harald Welte3055e332010-03-14 15:37:43 +08002335 install_element(BTS_NODE, &cfg_bts_gprs_nsvci_cmd);
Harald Welte410575a2010-03-14 23:30:30 +08002336 install_element(BTS_NODE, &cfg_bts_gprs_nsvc_lport_cmd);
2337 install_element(BTS_NODE, &cfg_bts_gprs_nsvc_rport_cmd);
2338 install_element(BTS_NODE, &cfg_bts_gprs_nsvc_rip_cmd);
Harald Welted8acf142010-07-30 11:50:09 +02002339 install_element(BTS_NODE, &cfg_bts_si_mode_cmd);
2340 install_element(BTS_NODE, &cfg_bts_si_static_cmd);
Harald Welte59b04682009-06-10 05:40:52 +08002341
2342 install_element(BTS_NODE, &cfg_trx_cmd);
2343 install_node(&trx_node, dummy_config_write);
2344 install_default(TRX_NODE);
Harald Welte58ed1cb2010-05-14 18:59:17 +02002345 install_element(TRX_NODE, &ournode_exit_cmd);
Harald Weltedc82b9b2010-05-14 19:11:04 +02002346 install_element(TRX_NODE, &ournode_end_cmd);
Harald Welte59b04682009-06-10 05:40:52 +08002347 install_element(TRX_NODE, &cfg_trx_arfcn_cmd);
Harald Welte8791dac2010-05-14 17:59:53 +02002348 install_element(TRX_NODE, &cfg_description_cmd);
2349 install_element(TRX_NODE, &cfg_no_description_cmd);
Harald Welte (local)b709bfe2009-12-27 20:56:38 +01002350 install_element(TRX_NODE, &cfg_trx_nominal_power_cmd);
Harald Welte7f597bc2009-06-20 22:36:12 +02002351 install_element(TRX_NODE, &cfg_trx_max_power_red_cmd);
Harald Welte62868882009-08-08 16:12:58 +02002352 install_element(TRX_NODE, &cfg_trx_rsl_e1_cmd);
2353 install_element(TRX_NODE, &cfg_trx_rsl_e1_tei_cmd);
Holger Hans Peter Freyther1c8b4802009-11-11 11:54:24 +01002354 install_element(TRX_NODE, &cfg_trx_rf_locked_cmd);
Harald Welte59b04682009-06-10 05:40:52 +08002355
2356 install_element(TRX_NODE, &cfg_ts_cmd);
2357 install_node(&ts_node, dummy_config_write);
2358 install_default(TS_NODE);
Harald Welte58ed1cb2010-05-14 18:59:17 +02002359 install_element(TS_NODE, &ournode_exit_cmd);
Harald Weltedc82b9b2010-05-14 19:11:04 +02002360 install_element(TS_NODE, &ournode_end_cmd);
Harald Welte3ffe1b32009-08-07 00:25:23 +02002361 install_element(TS_NODE, &cfg_ts_pchan_cmd);
Harald Weltea42a93f2010-06-14 22:26:10 +02002362 install_element(TS_NODE, &cfg_ts_hopping_cmd);
Harald Welte67104d12009-09-12 13:05:33 +02002363 install_element(TS_NODE, &cfg_ts_hsn_cmd);
2364 install_element(TS_NODE, &cfg_ts_maio_cmd);
2365 install_element(TS_NODE, &cfg_ts_arfcn_add_cmd);
2366 install_element(TS_NODE, &cfg_ts_arfcn_del_cmd);
Harald Welte3ffe1b32009-08-07 00:25:23 +02002367 install_element(TS_NODE, &cfg_ts_e1_subslot_cmd);
Harald Welte59b04682009-06-10 05:40:52 +08002368
Harald Welte63b964e2010-05-31 16:40:40 +02002369 abis_nm_vty_init();
2370
Harald Welte40152872010-05-16 20:52:23 +02002371 bsc_vty_init_extra();
Harald Welte59b04682009-06-10 05:40:52 +08002372
2373 return 0;
2374}