blob: 3eb91d8cff5ecc2d39425ca8b91c6301df43cdb7 [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);
Holger Hans Peter Freytherb6b9d702010-09-06 09:41:50 +0800167 vty_out(vty, " Use TCH for Paging any: %d%s", net->pag_any_tch,
168 VTY_NEWLINE);
Harald Welte52af1952009-12-13 10:53:12 +0100169 vty_out(vty, " RRLP Mode: %s%s", rrlp_mode_name(net->rrlp.mode),
170 VTY_NEWLINE);
Harald Weltea310f3e2009-12-14 09:00:24 +0100171 vty_out(vty, " MM Info: %s%s", net->send_mm_info ? "On" : "Off",
172 VTY_NEWLINE);
Harald Welte0af9c9f2009-12-19 21:41:52 +0100173 vty_out(vty, " Handover: %s%s", net->handover.active ? "On" : "Off",
174 VTY_NEWLINE);
Harald Weltefe96f382009-12-22 13:09:29 +0100175 network_chan_load(&pl, net);
176 vty_out(vty, " Current Channel Load:%s", VTY_NEWLINE);
177 dump_pchan_load_vty(vty, " ", &pl);
Harald Welte59b04682009-06-10 05:40:52 +0800178}
179
180DEFUN(show_net, show_net_cmd, "show network",
181 SHOW_STR "Display information about a GSM NETWORK\n")
182{
Harald Welte40152872010-05-16 20:52:23 +0200183 struct gsm_network *net = gsmnet_from_vty(vty);
Harald Welte59b04682009-06-10 05:40:52 +0800184 net_dump_vty(vty, net);
185
186 return CMD_SUCCESS;
187}
188
189static void e1isl_dump_vty(struct vty *vty, struct e1inp_sign_link *e1l)
190{
191 struct e1inp_line *line;
192
193 if (!e1l) {
194 vty_out(vty, " None%s", VTY_NEWLINE);
195 return;
196 }
197
198 line = e1l->ts->line;
199
200 vty_out(vty, " E1 Line %u, Type %s: Timeslot %u, Mode %s%s",
201 line->num, line->driver->name, e1l->ts->num,
202 e1inp_signtype_name(e1l->type), VTY_NEWLINE);
203 vty_out(vty, " E1 TEI %u, SAPI %u%s",
204 e1l->tei, e1l->sapi, VTY_NEWLINE);
205}
206
207static void bts_dump_vty(struct vty *vty, struct gsm_bts *bts)
208{
Harald Weltefe96f382009-12-22 13:09:29 +0100209 struct pchan_load pl;
210
Holger Hans Peter Freythera098dfb2009-08-21 14:44:12 +0200211 vty_out(vty, "BTS %u is of %s type in band %s, has CI %u LAC %u, "
Harald Welte91afe4c2009-06-20 18:15:19 +0200212 "BSIC %u, TSC %u and %u TRX%s",
213 bts->nr, btstype2str(bts->type), gsm_band_name(bts->band),
Holger Hans Peter Freythera098dfb2009-08-21 14:44:12 +0200214 bts->cell_identity,
Holger Hans Peter Freyther71135142010-03-29 08:47:44 +0200215 bts->location_area_code, bts->bsic, bts->tsc,
Harald Welte91afe4c2009-06-20 18:15:19 +0200216 bts->num_trx, VTY_NEWLINE);
Harald Welte8791dac2010-05-14 17:59:53 +0200217 vty_out(vty, "Description: %s%s",
218 bts->description ? bts->description : "(null)", VTY_NEWLINE);
Harald Welte8e9d1792009-12-12 15:38:16 +0100219 vty_out(vty, "MS Max power: %u dBm%s", bts->ms_max_power, VTY_NEWLINE);
Harald Welteb761bf82009-12-12 18:17:25 +0100220 vty_out(vty, "Minimum Rx Level for Access: %i dBm%s",
Harald Welte8e9d1792009-12-12 15:38:16 +0100221 rxlev2dbm(bts->si_common.cell_sel_par.rxlev_acc_min),
222 VTY_NEWLINE);
223 vty_out(vty, "Cell Reselection Hysteresis: %u dBm%s",
Harald Welteb761bf82009-12-12 18:17:25 +0100224 bts->si_common.cell_sel_par.cell_resel_hyst*2, VTY_NEWLINE);
Sylvain Munaut8e2d8de2009-12-22 13:43:26 +0100225 vty_out(vty, "RACH TX-Integer: %u%s", bts->si_common.rach_control.tx_integer,
226 VTY_NEWLINE);
227 vty_out(vty, "RACH Max transmissions: %u%s",
228 rach_max_trans_raw2val(bts->si_common.rach_control.max_trans),
229 VTY_NEWLINE);
Harald Welte8c973ba2009-12-21 23:08:18 +0100230 if (bts->si_common.rach_control.cell_bar)
Harald Welte (local)e19be3f2009-08-12 13:28:23 +0200231 vty_out(vty, " CELL IS BARRED%s", VTY_NEWLINE);
Harald Welted8acf142010-07-30 11:50:09 +0200232 vty_out(vty, "System Information present: 0x%08x, static: 0x%08x%s",
233 bts->si_valid, bts->si_mode_static, VTY_NEWLINE);
Harald Welte59b04682009-06-10 05:40:52 +0800234 if (is_ipaccess_bts(bts))
Harald Welte25572872009-10-20 00:22:00 +0200235 vty_out(vty, " Unit ID: %u/%u/0, OML Stream ID 0x%02x%s",
Harald Welte59b04682009-06-10 05:40:52 +0800236 bts->ip_access.site_id, bts->ip_access.bts_id,
Harald Welte25572872009-10-20 00:22:00 +0200237 bts->oml_tei, VTY_NEWLINE);
Harald Welte59b04682009-06-10 05:40:52 +0800238 vty_out(vty, " NM State: ");
239 net_dump_nmstate(vty, &bts->nm_state);
240 vty_out(vty, " Site Mgr NM State: ");
241 net_dump_nmstate(vty, &bts->site_mgr.nm_state);
242 vty_out(vty, " Paging: FIXME pending requests, %u free slots%s",
243 bts->paging.available_slots, VTY_NEWLINE);
Harald Welte25572872009-10-20 00:22:00 +0200244 if (!is_ipaccess_bts(bts)) {
245 vty_out(vty, " E1 Signalling Link:%s", VTY_NEWLINE);
246 e1isl_dump_vty(vty, bts->oml_link);
247 }
Harald Welte59b04682009-06-10 05:40:52 +0800248 /* FIXME: oml_link, chan_desc */
Harald Weltefe96f382009-12-22 13:09:29 +0100249 memset(&pl, 0, sizeof(pl));
250 bts_chan_load(&pl, bts);
251 vty_out(vty, " Current Channel Load:%s", VTY_NEWLINE);
252 dump_pchan_load_vty(vty, " ", &pl);
Harald Welte59b04682009-06-10 05:40:52 +0800253}
254
255DEFUN(show_bts, show_bts_cmd, "show bts [number]",
256 SHOW_STR "Display information about a BTS\n"
257 "BTS number")
258{
Harald Welte40152872010-05-16 20:52:23 +0200259 struct gsm_network *net = gsmnet_from_vty(vty);
Harald Welte59b04682009-06-10 05:40:52 +0800260 int bts_nr;
261
262 if (argc != 0) {
263 /* use the BTS number that the user has specified */
264 bts_nr = atoi(argv[0]);
265 if (bts_nr > net->num_bts) {
266 vty_out(vty, "%% can't find BTS '%s'%s", argv[0],
267 VTY_NEWLINE);
268 return CMD_WARNING;
269 }
Harald Weltee712a5f2009-06-21 16:17:15 +0200270 bts_dump_vty(vty, gsm_bts_num(net, bts_nr));
Harald Welte59b04682009-06-10 05:40:52 +0800271 return CMD_SUCCESS;
272 }
273 /* print all BTS's */
274 for (bts_nr = 0; bts_nr < net->num_bts; bts_nr++)
Harald Weltee712a5f2009-06-21 16:17:15 +0200275 bts_dump_vty(vty, gsm_bts_num(net, bts_nr));
Harald Welte59b04682009-06-10 05:40:52 +0800276
277 return CMD_SUCCESS;
278}
279
Harald Welte62868882009-08-08 16:12:58 +0200280/* utility functions */
281static void parse_e1_link(struct gsm_e1_subslot *e1_link, const char *line,
282 const char *ts, const char *ss)
283{
284 e1_link->e1_nr = atoi(line);
285 e1_link->e1_ts = atoi(ts);
286 if (!strcmp(ss, "full"))
287 e1_link->e1_ts_ss = 255;
288 else
289 e1_link->e1_ts_ss = atoi(ss);
290}
291
292static void config_write_e1_link(struct vty *vty, struct gsm_e1_subslot *e1_link,
293 const char *prefix)
294{
295 if (!e1_link->e1_ts)
296 return;
297
298 if (e1_link->e1_ts_ss == 255)
299 vty_out(vty, "%se1 line %u timeslot %u sub-slot full%s",
300 prefix, e1_link->e1_nr, e1_link->e1_ts, VTY_NEWLINE);
301 else
302 vty_out(vty, "%se1 line %u timeslot %u sub-slot %u%s",
303 prefix, e1_link->e1_nr, e1_link->e1_ts,
304 e1_link->e1_ts_ss, VTY_NEWLINE);
305}
306
307
Harald Welte97ceef92009-08-06 19:06:46 +0200308static void config_write_ts_single(struct vty *vty, struct gsm_bts_trx_ts *ts)
309{
Harald Welte62868882009-08-08 16:12:58 +0200310 vty_out(vty, " timeslot %u%s", ts->nr, VTY_NEWLINE);
311 if (ts->pchan != GSM_PCHAN_NONE)
312 vty_out(vty, " phys_chan_config %s%s",
313 gsm_pchan_name(ts->pchan), VTY_NEWLINE);
Harald Weltea42a93f2010-06-14 22:26:10 +0200314 vty_out(vty, " hopping enabled %u%s",
315 ts->hopping.enabled, VTY_NEWLINE);
316 if (ts->hopping.enabled) {
317 unsigned int i;
318 vty_out(vty, " hopping sequence-number %u%s",
Harald Welte67104d12009-09-12 13:05:33 +0200319 ts->hopping.hsn, VTY_NEWLINE);
Harald Weltea42a93f2010-06-14 22:26:10 +0200320 vty_out(vty, " hopping maio %u%s",
Harald Welte67104d12009-09-12 13:05:33 +0200321 ts->hopping.maio, VTY_NEWLINE);
Harald Weltea42a93f2010-06-14 22:26:10 +0200322 for (i = 0; i < ts->hopping.arfcns.data_len*8; i++) {
323 if (!bitvec_get_bit_pos(&ts->hopping.arfcns, i))
324 continue;
325 vty_out(vty, " hopping arfcn add %u%s",
326 i, VTY_NEWLINE);
327 }
328 } else
Harald Welte62868882009-08-08 16:12:58 +0200329 config_write_e1_link(vty, &ts->e1_link, " ");
Harald Welte97ceef92009-08-06 19:06:46 +0200330}
331
332static void config_write_trx_single(struct vty *vty, struct gsm_bts_trx *trx)
333{
334 int i;
335
Harald Weltee87eb462009-08-07 13:29:14 +0200336 vty_out(vty, " trx %u%s", trx->nr, VTY_NEWLINE);
Harald Welte8791dac2010-05-14 17:59:53 +0200337 if (trx->description)
338 vty_out(vty, " description %s%s", trx->description,
339 VTY_NEWLINE);
Holger Hans Peter Freyther32be2aa2010-04-17 06:42:07 +0200340 vty_out(vty, " rf_locked %u%s",
341 trx->nm_state.administrative == NM_STATE_LOCKED ? 1 : 0,
342 VTY_NEWLINE);
Harald Weltee87eb462009-08-07 13:29:14 +0200343 vty_out(vty, " arfcn %u%s", trx->arfcn, VTY_NEWLINE);
Harald Welte (local)b709bfe2009-12-27 20:56:38 +0100344 vty_out(vty, " nominal power %u%s", trx->nominal_power, VTY_NEWLINE);
Harald Weltee87eb462009-08-07 13:29:14 +0200345 vty_out(vty, " max_power_red %u%s", trx->max_power_red, VTY_NEWLINE);
Harald Welte62868882009-08-08 16:12:58 +0200346 config_write_e1_link(vty, &trx->rsl_e1_link, " rsl ");
347 vty_out(vty, " rsl e1 tei %u%s", trx->rsl_tei, VTY_NEWLINE);
Harald Welte97ceef92009-08-06 19:06:46 +0200348
349 for (i = 0; i < TRX_NR_TS; i++)
350 config_write_ts_single(vty, &trx->ts[i]);
351}
352
Harald Weltea9251762010-05-11 23:50:21 +0200353static void config_write_bts_gprs(struct vty *vty, struct gsm_bts *bts)
354{
355 unsigned int i;
356 vty_out(vty, " gprs mode %s%s", bts_gprs_mode_name(bts->gprs.mode),
357 VTY_NEWLINE);
358 if (bts->gprs.mode == BTS_GPRS_NONE)
359 return;
360
361 vty_out(vty, " gprs routing area %u%s", bts->gprs.rac,
362 VTY_NEWLINE);
363 vty_out(vty, " gprs cell bvci %u%s", bts->gprs.cell.bvci,
364 VTY_NEWLINE);
365 for (i = 0; i < ARRAY_SIZE(bts->gprs.cell.timer); i++)
366 vty_out(vty, " gprs cell timer %s %u%s",
367 get_value_string(gprs_bssgp_cfg_strs, i),
368 bts->gprs.cell.timer[i], VTY_NEWLINE);
369 vty_out(vty, " gprs nsei %u%s", bts->gprs.nse.nsei,
370 VTY_NEWLINE);
371 for (i = 0; i < ARRAY_SIZE(bts->gprs.nse.timer); i++)
372 vty_out(vty, " gprs ns timer %s %u%s",
373 get_value_string(gprs_ns_timer_strs, i),
374 bts->gprs.nse.timer[i], VTY_NEWLINE);
375 for (i = 0; i < ARRAY_SIZE(bts->gprs.nsvc); i++) {
376 struct gsm_bts_gprs_nsvc *nsvc =
377 &bts->gprs.nsvc[i];
378 struct in_addr ia;
379
380 ia.s_addr = htonl(nsvc->remote_ip);
381 vty_out(vty, " gprs nsvc %u nsvci %u%s", i,
382 nsvc->nsvci, VTY_NEWLINE);
383 vty_out(vty, " gprs nsvc %u local udp port %u%s", i,
384 nsvc->local_port, VTY_NEWLINE);
385 vty_out(vty, " gprs nsvc %u remote udp port %u%s", i,
386 nsvc->remote_port, VTY_NEWLINE);
387 vty_out(vty, " gprs nsvc %u remote ip %s%s", i,
388 inet_ntoa(ia), VTY_NEWLINE);
389 }
390}
391
Harald Welte97ceef92009-08-06 19:06:46 +0200392static void config_write_bts_single(struct vty *vty, struct gsm_bts *bts)
393{
394 struct gsm_bts_trx *trx;
Harald Welted8acf142010-07-30 11:50:09 +0200395 int i;
Harald Welte97ceef92009-08-06 19:06:46 +0200396
Harald Weltee87eb462009-08-07 13:29:14 +0200397 vty_out(vty, " bts %u%s", bts->nr, VTY_NEWLINE);
398 vty_out(vty, " type %s%s", btstype2str(bts->type), VTY_NEWLINE);
Harald Welte8791dac2010-05-14 17:59:53 +0200399 if (bts->description)
400 vty_out(vty, " description %s%s", bts->description, VTY_NEWLINE);
Harald Weltee87eb462009-08-07 13:29:14 +0200401 vty_out(vty, " band %s%s", gsm_band_name(bts->band), VTY_NEWLINE);
Holger Hans Peter Freyther6d82b7c2009-11-19 16:38:49 +0100402 vty_out(vty, " cell_identity %u%s", bts->cell_identity, VTY_NEWLINE);
Harald Weltee87eb462009-08-07 13:29:14 +0200403 vty_out(vty, " location_area_code %u%s", bts->location_area_code,
Harald Welte97ceef92009-08-06 19:06:46 +0200404 VTY_NEWLINE);
Harald Weltee87eb462009-08-07 13:29:14 +0200405 vty_out(vty, " training_sequence_code %u%s", bts->tsc, VTY_NEWLINE);
406 vty_out(vty, " base_station_id_code %u%s", bts->bsic, VTY_NEWLINE);
Harald Welte (local)cbd46102009-08-13 10:14:26 +0200407 vty_out(vty, " ms max power %u%s", bts->ms_max_power, VTY_NEWLINE);
Harald Welteb761bf82009-12-12 18:17:25 +0100408 vty_out(vty, " cell reselection hysteresis %u%s",
409 bts->si_common.cell_sel_par.cell_resel_hyst*2, VTY_NEWLINE);
410 vty_out(vty, " rxlev access min %u%s",
411 bts->si_common.cell_sel_par.rxlev_acc_min, VTY_NEWLINE);
Harald Weltea54a2bb2009-12-01 18:04:30 +0530412 if (bts->si_common.chan_desc.t3212)
Harald Welte (local)b6ea7f72009-08-14 23:09:25 +0200413 vty_out(vty, " periodic location update %u%s",
Harald Weltea54a2bb2009-12-01 18:04:30 +0530414 bts->si_common.chan_desc.t3212 * 10, VTY_NEWLINE);
Harald Welte3e774612009-08-10 13:48:16 +0200415 vty_out(vty, " channel allocator %s%s",
416 bts->chan_alloc_reverse ? "descending" : "ascending",
417 VTY_NEWLINE);
Sylvain Munaut8e2d8de2009-12-22 13:43:26 +0100418 vty_out(vty, " rach tx integer %u%s",
419 bts->si_common.rach_control.tx_integer, VTY_NEWLINE);
420 vty_out(vty, " rach max transmission %u%s",
421 rach_max_trans_raw2val(bts->si_common.rach_control.max_trans),
422 VTY_NEWLINE);
Holger Hans Peter Freyther697ed2b2010-04-25 23:08:39 +0800423
424 if (bts->rach_b_thresh != -1)
425 vty_out(vty, " rach nm busy threshold %u%s",
426 bts->rach_b_thresh, VTY_NEWLINE);
427 if (bts->rach_ldavg_slots != -1)
428 vty_out(vty, " rach nm load average %u%s",
429 bts->rach_ldavg_slots, VTY_NEWLINE);
Harald Welte8c973ba2009-12-21 23:08:18 +0100430 if (bts->si_common.rach_control.cell_bar)
Harald Welte (local)e19be3f2009-08-12 13:28:23 +0200431 vty_out(vty, " cell barred 1%s", VTY_NEWLINE);
Holger Hans Peter Freyther440984b2010-05-14 00:39:19 +0800432 if ((bts->si_common.rach_control.t2 & 0x4) == 0)
433 vty_out(vty, " rach emergency call allowed 1%s", VTY_NEWLINE);
Harald Welted8acf142010-07-30 11:50:09 +0200434 for (i = SYSINFO_TYPE_1; i < _MAX_SYSINFO_TYPE; i++) {
435 if (bts->si_mode_static & (1 << i)) {
436 vty_out(vty, " system-information %s mode static%s",
437 get_value_string(osmo_sitype_strs, i), VTY_NEWLINE);
438 vty_out(vty, " system-information %s static %s%s",
439 get_value_string(osmo_sitype_strs, i),
440 hexdump_nospc(bts->si_buf[i], sizeof(bts->si_buf[i])),
441 VTY_NEWLINE);
442 }
443 }
Harald Welte25572872009-10-20 00:22:00 +0200444 if (is_ipaccess_bts(bts)) {
Harald Weltee87eb462009-08-07 13:29:14 +0200445 vty_out(vty, " ip.access unit_id %u %u%s",
Harald Welte3ffe1b32009-08-07 00:25:23 +0200446 bts->ip_access.site_id, bts->ip_access.bts_id, VTY_NEWLINE);
Harald Welte25572872009-10-20 00:22:00 +0200447 vty_out(vty, " oml ip.access stream_id %u%s", bts->oml_tei, VTY_NEWLINE);
448 } else {
Harald Welte62868882009-08-08 16:12:58 +0200449 config_write_e1_link(vty, &bts->oml_e1_link, " oml ");
450 vty_out(vty, " oml e1 tei %u%s", bts->oml_tei, VTY_NEWLINE);
451 }
Harald Weltea9251762010-05-11 23:50:21 +0200452 config_write_bts_gprs(vty, bts);
Harald Welte97ceef92009-08-06 19:06:46 +0200453
454 llist_for_each_entry(trx, &bts->trx_list, list)
455 config_write_trx_single(vty, trx);
456}
457
458static int config_write_bts(struct vty *v)
459{
Harald Welte40152872010-05-16 20:52:23 +0200460 struct gsm_network *gsmnet = gsmnet_from_vty(v);
Harald Welte97ceef92009-08-06 19:06:46 +0200461 struct gsm_bts *bts;
462
463 llist_for_each_entry(bts, &gsmnet->bts_list, list)
464 config_write_bts_single(v, bts);
465
466 return CMD_SUCCESS;
467}
468
Harald Weltee87eb462009-08-07 13:29:14 +0200469static int config_write_net(struct vty *vty)
470{
Harald Welte40152872010-05-16 20:52:23 +0200471 struct gsm_network *gsmnet = gsmnet_from_vty(vty);
472
Harald Weltee87eb462009-08-07 13:29:14 +0200473 vty_out(vty, "network%s", VTY_NEWLINE);
Harald Welte62868882009-08-08 16:12:58 +0200474 vty_out(vty, " network country code %u%s", gsmnet->country_code, VTY_NEWLINE);
Harald Weltee87eb462009-08-07 13:29:14 +0200475 vty_out(vty, " mobile network code %u%s", gsmnet->network_code, VTY_NEWLINE);
Harald Welte62868882009-08-08 16:12:58 +0200476 vty_out(vty, " short name %s%s", gsmnet->name_short, VTY_NEWLINE);
477 vty_out(vty, " long name %s%s", gsmnet->name_long, VTY_NEWLINE);
Harald Welte (local)a59a27e2009-08-12 14:42:23 +0200478 vty_out(vty, " auth policy %s%s", gsm_auth_policy_name(gsmnet->auth_policy), VTY_NEWLINE);
Harald Welte59936d72009-11-18 20:33:19 +0100479 vty_out(vty, " location updating reject cause %u%s",
480 gsmnet->reject_cause, VTY_NEWLINE);
Harald Weltecca253a2009-08-30 15:47:06 +0900481 vty_out(vty, " encryption a5 %u%s", gsmnet->a5_encryption, VTY_NEWLINE);
Holger Hans Peter Freyther6b4f5462009-11-19 16:37:48 +0100482 vty_out(vty, " neci %u%s", gsmnet->neci, VTY_NEWLINE);
Holger Hans Peter Freytherb6b9d702010-09-06 09:41:50 +0800483 vty_out(vty, " paging any use tch %d%s", gsmnet->pag_any_tch, VTY_NEWLINE);
Harald Welte52af1952009-12-13 10:53:12 +0100484 vty_out(vty, " rrlp mode %s%s", rrlp_mode_name(gsmnet->rrlp.mode),
485 VTY_NEWLINE);
Harald Weltea310f3e2009-12-14 09:00:24 +0100486 vty_out(vty, " mm info %u%s", gsmnet->send_mm_info, VTY_NEWLINE);
Harald Welte0af9c9f2009-12-19 21:41:52 +0100487 vty_out(vty, " handover %u%s", gsmnet->handover.active, VTY_NEWLINE);
Harald Weltea8062f12009-12-21 16:51:50 +0100488 vty_out(vty, " handover window rxlev averaging %u%s",
489 gsmnet->handover.win_rxlev_avg, VTY_NEWLINE);
490 vty_out(vty, " handover window rxqual averaging %u%s",
491 gsmnet->handover.win_rxqual_avg, VTY_NEWLINE);
492 vty_out(vty, " handover window rxlev neighbor averaging %u%s",
493 gsmnet->handover.win_rxlev_avg_neigh, VTY_NEWLINE);
494 vty_out(vty, " handover power budget interval %u%s",
495 gsmnet->handover.pwr_interval, VTY_NEWLINE);
496 vty_out(vty, " handover power budget hysteresis %u%s",
497 gsmnet->handover.pwr_hysteresis, VTY_NEWLINE);
498 vty_out(vty, " handover maximum distance %u%s",
499 gsmnet->handover.max_distance, VTY_NEWLINE);
Holger Hans Peter Freyther26ba2e72009-11-21 21:18:38 +0100500 vty_out(vty, " timer t3101 %u%s", gsmnet->T3101, VTY_NEWLINE);
Holger Hans Peter Freyther89733862009-11-21 21:42:26 +0100501 vty_out(vty, " timer t3103 %u%s", gsmnet->T3103, VTY_NEWLINE);
502 vty_out(vty, " timer t3105 %u%s", gsmnet->T3105, VTY_NEWLINE);
503 vty_out(vty, " timer t3107 %u%s", gsmnet->T3107, VTY_NEWLINE);
504 vty_out(vty, " timer t3109 %u%s", gsmnet->T3109, VTY_NEWLINE);
505 vty_out(vty, " timer t3111 %u%s", gsmnet->T3111, VTY_NEWLINE);
506 vty_out(vty, " timer t3113 %u%s", gsmnet->T3113, VTY_NEWLINE);
507 vty_out(vty, " timer t3115 %u%s", gsmnet->T3115, VTY_NEWLINE);
508 vty_out(vty, " timer t3117 %u%s", gsmnet->T3117, VTY_NEWLINE);
509 vty_out(vty, " timer t3119 %u%s", gsmnet->T3119, VTY_NEWLINE);
510 vty_out(vty, " timer t3141 %u%s", gsmnet->T3141, VTY_NEWLINE);
Holger Hans Peter Freyther21d63ff2010-09-06 09:25:48 +0800511 vty_out(vty, " use-dtx %u%s", gsmnet->dtx_enabled, VTY_NEWLINE);
Harald Weltee87eb462009-08-07 13:29:14 +0200512
513 return CMD_SUCCESS;
514}
Harald Welte97ceef92009-08-06 19:06:46 +0200515
Harald Welte59b04682009-06-10 05:40:52 +0800516static void trx_dump_vty(struct vty *vty, struct gsm_bts_trx *trx)
517{
518 vty_out(vty, "TRX %u of BTS %u is on ARFCN %u%s",
519 trx->nr, trx->bts->nr, trx->arfcn, VTY_NEWLINE);
Harald Welte8791dac2010-05-14 17:59:53 +0200520 vty_out(vty, "Description: %s%s",
521 trx->description ? trx->description : "(null)", VTY_NEWLINE);
Harald Welte91afe4c2009-06-20 18:15:19 +0200522 vty_out(vty, " RF Nominal Power: %d dBm, reduced by %u dB, "
Harald Welte62868882009-08-08 16:12:58 +0200523 "resulting BS power: %d dBm%s",
Harald Welte91afe4c2009-06-20 18:15:19 +0200524 trx->nominal_power, trx->max_power_red,
Harald Welte62868882009-08-08 16:12:58 +0200525 trx->nominal_power - trx->max_power_red, VTY_NEWLINE);
Harald Welte59b04682009-06-10 05:40:52 +0800526 vty_out(vty, " NM State: ");
527 net_dump_nmstate(vty, &trx->nm_state);
528 vty_out(vty, " Baseband Transceiver NM State: ");
529 net_dump_nmstate(vty, &trx->bb_transc.nm_state);
Harald Welte25572872009-10-20 00:22:00 +0200530 if (is_ipaccess_bts(trx->bts)) {
531 vty_out(vty, " ip.access stream ID: 0x%02x%s",
532 trx->rsl_tei, VTY_NEWLINE);
533 } else {
534 vty_out(vty, " E1 Signalling Link:%s", VTY_NEWLINE);
535 e1isl_dump_vty(vty, trx->rsl_link);
536 }
Harald Welte59b04682009-06-10 05:40:52 +0800537}
538
539DEFUN(show_trx,
540 show_trx_cmd,
541 "show trx [bts_nr] [trx_nr]",
Harald Welte9e002452010-05-11 21:53:49 +0200542 SHOW_STR "Display information about a TRX\n"
543 "BTS Number\n"
544 "TRX Number\n")
Harald Welte59b04682009-06-10 05:40:52 +0800545{
Harald Welte40152872010-05-16 20:52:23 +0200546 struct gsm_network *net = gsmnet_from_vty(vty);
Harald Welte59b04682009-06-10 05:40:52 +0800547 struct gsm_bts *bts = NULL;
548 struct gsm_bts_trx *trx;
549 int bts_nr, trx_nr;
550
551 if (argc >= 1) {
552 /* use the BTS number that the user has specified */
553 bts_nr = atoi(argv[0]);
554 if (bts_nr >= net->num_bts) {
555 vty_out(vty, "%% can't find BTS '%s'%s", argv[0],
556 VTY_NEWLINE);
557 return CMD_WARNING;
558 }
Harald Weltee712a5f2009-06-21 16:17:15 +0200559 bts = gsm_bts_num(net, bts_nr);
Harald Welte59b04682009-06-10 05:40:52 +0800560 }
561 if (argc >= 2) {
562 trx_nr = atoi(argv[1]);
563 if (trx_nr >= bts->num_trx) {
564 vty_out(vty, "%% can't find TRX '%s'%s", argv[1],
565 VTY_NEWLINE);
566 return CMD_WARNING;
567 }
Harald Weltee712a5f2009-06-21 16:17:15 +0200568 trx = gsm_bts_trx_num(bts, trx_nr);
Harald Welte59b04682009-06-10 05:40:52 +0800569 trx_dump_vty(vty, trx);
570 return CMD_SUCCESS;
571 }
572 if (bts) {
573 /* print all TRX in this BTS */
574 for (trx_nr = 0; trx_nr < bts->num_trx; trx_nr++) {
Harald Weltee712a5f2009-06-21 16:17:15 +0200575 trx = gsm_bts_trx_num(bts, trx_nr);
Harald Welte59b04682009-06-10 05:40:52 +0800576 trx_dump_vty(vty, trx);
577 }
578 return CMD_SUCCESS;
579 }
580
581 for (bts_nr = 0; bts_nr < net->num_bts; bts_nr++) {
Harald Weltee712a5f2009-06-21 16:17:15 +0200582 bts = gsm_bts_num(net, bts_nr);
Harald Welte59b04682009-06-10 05:40:52 +0800583 for (trx_nr = 0; trx_nr < bts->num_trx; trx_nr++) {
Harald Weltee712a5f2009-06-21 16:17:15 +0200584 trx = gsm_bts_trx_num(bts, trx_nr);
Harald Welte59b04682009-06-10 05:40:52 +0800585 trx_dump_vty(vty, trx);
586 }
587 }
588
589 return CMD_SUCCESS;
590}
591
Harald Welte97ceef92009-08-06 19:06:46 +0200592
Harald Welte59b04682009-06-10 05:40:52 +0800593static void ts_dump_vty(struct vty *vty, struct gsm_bts_trx_ts *ts)
594{
Harald Welte59b04682009-06-10 05:40:52 +0800595 vty_out(vty, "Timeslot %u of TRX %u in BTS %u, phys cfg %s%s",
596 ts->nr, ts->trx->nr, ts->trx->bts->nr,
597 gsm_pchan_name(ts->pchan), VTY_NEWLINE);
598 vty_out(vty, " NM State: ");
599 net_dump_nmstate(vty, &ts->nm_state);
Harald Welte87504212009-12-02 01:56:49 +0530600 if (!is_ipaccess_bts(ts->trx->bts))
Harald Welte59b04682009-06-10 05:40:52 +0800601 vty_out(vty, " E1 Line %u, Timeslot %u, Subslot %u%s",
602 ts->e1_link.e1_nr, ts->e1_link.e1_ts,
603 ts->e1_link.e1_ts_ss, VTY_NEWLINE);
Harald Welte59b04682009-06-10 05:40:52 +0800604}
605
606DEFUN(show_ts,
607 show_ts_cmd,
608 "show timeslot [bts_nr] [trx_nr] [ts_nr]",
Harald Welte9e002452010-05-11 21:53:49 +0200609 SHOW_STR "Display information about a TS\n"
610 "BTS Number\n" "TRX Number\n" "Timeslot Number\n")
Harald Welte59b04682009-06-10 05:40:52 +0800611{
Harald Welte40152872010-05-16 20:52:23 +0200612 struct gsm_network *net = gsmnet_from_vty(vty);
Harald Welte59b04682009-06-10 05:40:52 +0800613 struct gsm_bts *bts;
614 struct gsm_bts_trx *trx;
615 struct gsm_bts_trx_ts *ts;
616 int bts_nr, trx_nr, ts_nr;
617
618 if (argc >= 1) {
619 /* use the BTS number that the user has specified */
620 bts_nr = atoi(argv[0]);
621 if (bts_nr >= net->num_bts) {
622 vty_out(vty, "%% can't find BTS '%s'%s", argv[0],
623 VTY_NEWLINE);
624 return CMD_WARNING;
625 }
Harald Weltee712a5f2009-06-21 16:17:15 +0200626 bts = gsm_bts_num(net, bts_nr);
Harald Welte59b04682009-06-10 05:40:52 +0800627 }
628 if (argc >= 2) {
629 trx_nr = atoi(argv[1]);
630 if (trx_nr >= bts->num_trx) {
631 vty_out(vty, "%% can't find TRX '%s'%s", argv[1],
632 VTY_NEWLINE);
633 return CMD_WARNING;
634 }
Harald Weltee712a5f2009-06-21 16:17:15 +0200635 trx = gsm_bts_trx_num(bts, trx_nr);
Harald Welte59b04682009-06-10 05:40:52 +0800636 }
637 if (argc >= 3) {
638 ts_nr = atoi(argv[2]);
639 if (ts_nr >= TRX_NR_TS) {
640 vty_out(vty, "%% can't find TS '%s'%s", argv[2],
641 VTY_NEWLINE);
642 return CMD_WARNING;
643 }
644 ts = &trx->ts[ts_nr];
645 ts_dump_vty(vty, ts);
646 return CMD_SUCCESS;
647 }
648 for (bts_nr = 0; bts_nr < net->num_bts; bts_nr++) {
Harald Weltee712a5f2009-06-21 16:17:15 +0200649 bts = gsm_bts_num(net, bts_nr);
Harald Welte59b04682009-06-10 05:40:52 +0800650 for (trx_nr = 0; trx_nr < bts->num_trx; trx_nr++) {
Harald Weltee712a5f2009-06-21 16:17:15 +0200651 trx = gsm_bts_trx_num(bts, trx_nr);
Harald Welte59b04682009-06-10 05:40:52 +0800652 for (ts_nr = 0; ts_nr < TRX_NR_TS; ts_nr++) {
653 ts = &trx->ts[ts_nr];
654 ts_dump_vty(vty, ts);
655 }
656 }
657 }
658
659 return CMD_SUCCESS;
660}
661
Holger Hans Peter Freyther1dd0a1b2010-01-06 06:00:40 +0100662static void subscr_dump_vty(struct vty *vty, struct gsm_subscriber *subscr)
Harald Welte59b04682009-06-10 05:40:52 +0800663{
Harald Welte91afe4c2009-06-20 18:15:19 +0200664 vty_out(vty, " ID: %llu, Authorized: %d%s", subscr->id,
Harald Welte59b04682009-06-10 05:40:52 +0800665 subscr->authorized, VTY_NEWLINE);
666 if (subscr->name)
667 vty_out(vty, " Name: '%s'%s", subscr->name, VTY_NEWLINE);
668 if (subscr->extension)
669 vty_out(vty, " Extension: %s%s", subscr->extension,
670 VTY_NEWLINE);
671 if (subscr->imsi)
672 vty_out(vty, " IMSI: %s%s", subscr->imsi, VTY_NEWLINE);
Holger Hans Peter Freythercd8bacf2009-08-19 12:53:57 +0200673 if (subscr->tmsi != GSM_RESERVED_TMSI)
674 vty_out(vty, " TMSI: %08X%s", subscr->tmsi,
Harald Welte270c06c2009-08-15 03:24:51 +0200675 VTY_NEWLINE);
Sylvain Munaute5863a22009-12-27 19:29:28 +0100676
Harald Welte (local)02d5efa2009-08-14 20:27:16 +0200677 vty_out(vty, " Use count: %u%s", subscr->use_count, VTY_NEWLINE);
Harald Welte59b04682009-06-10 05:40:52 +0800678}
679
Harald Welte44007742009-12-22 21:43:14 +0100680static void meas_rep_dump_uni_vty(struct vty *vty,
681 struct gsm_meas_rep_unidir *mru,
682 const char *prefix,
683 const char *dir)
684{
685 vty_out(vty, "%s RXL-FULL-%s: %4d dBm, RXL-SUB-%s: %4d dBm ",
686 prefix, dir, rxlev2dbm(mru->full.rx_lev),
687 dir, rxlev2dbm(mru->sub.rx_lev));
688 vty_out(vty, "RXQ-FULL-%s: %d, RXQ-SUB-%s: %d%s",
689 dir, mru->full.rx_qual, dir, mru->sub.rx_qual,
690 VTY_NEWLINE);
691}
692
693static void meas_rep_dump_vty(struct vty *vty, struct gsm_meas_rep *mr,
694 const char *prefix)
695{
696 vty_out(vty, "%sMeasurement Report:%s", prefix, VTY_NEWLINE);
697 vty_out(vty, "%s Flags: %s%s%s%s%s", prefix,
698 mr->flags & MEAS_REP_F_UL_DTX ? "DTXu " : "",
699 mr->flags & MEAS_REP_F_DL_DTX ? "DTXd " : "",
700 mr->flags & MEAS_REP_F_FPC ? "FPC " : "",
701 mr->flags & MEAS_REP_F_DL_VALID ? " " : "DLinval ",
702 VTY_NEWLINE);
703 if (mr->flags & MEAS_REP_F_MS_TO)
704 vty_out(vty, "%s MS Timing Offset: %u%s", prefix,
705 mr->ms_timing_offset, VTY_NEWLINE);
706 if (mr->flags & MEAS_REP_F_MS_L1)
707 vty_out(vty, "%s L1 MS Power: %u dBm, Timing Advance: %u%s",
708 prefix, mr->ms_l1.pwr, mr->ms_l1.ta, VTY_NEWLINE);
709 if (mr->flags & MEAS_REP_F_DL_VALID)
710 meas_rep_dump_uni_vty(vty, &mr->dl, prefix, "dl");
711 meas_rep_dump_uni_vty(vty, &mr->ul, prefix, "ul");
712}
713
Holger Hans Peter Freyther5424e022010-05-14 02:03:16 +0800714static void lchan_dump_full_vty(struct vty *vty, struct gsm_lchan *lchan)
Harald Welte59b04682009-06-10 05:40:52 +0800715{
Harald Welte44007742009-12-22 21:43:14 +0100716 int idx;
717
Harald Welte59b04682009-06-10 05:40:52 +0800718 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 +0200719 lchan->nr, lchan->ts->nr, lchan->ts->trx->nr,
Harald Welte (local)02204d02009-12-27 18:05:25 +0100720 lchan->ts->trx->bts->nr, gsm_lchant_name(lchan->type),
Harald Welte59b04682009-06-10 05:40:52 +0800721 VTY_NEWLINE);
Holger Hans Peter Freyther6e5c50f2010-06-28 17:09:29 +0800722 vty_out(vty, " Connection: %u, State: %s%s",
723 lchan->conn ? 1: 0,
Harald Welteab2534c2009-12-29 10:52:38 +0100724 gsm_lchans_name(lchan->state), VTY_NEWLINE);
Harald Welteb761bf82009-12-12 18:17:25 +0100725 vty_out(vty, " BS Power: %u dBm, MS Power: %u dBm%s",
726 lchan->ts->trx->nominal_power - lchan->ts->trx->max_power_red
727 - lchan->bs_power*2,
728 ms_pwr_dbm(lchan->ts->trx->bts->band, lchan->ms_power),
729 VTY_NEWLINE);
Holger Hans Peter Freyther1a95fa82010-06-28 15:47:12 +0800730 if (lchan->conn && lchan->conn->subscr) {
Harald Welte59b04682009-06-10 05:40:52 +0800731 vty_out(vty, " Subscriber:%s", VTY_NEWLINE);
Holger Hans Peter Freyther1a95fa82010-06-28 15:47:12 +0800732 subscr_dump_vty(vty, lchan->conn->subscr);
Harald Welte59b04682009-06-10 05:40:52 +0800733 } else
734 vty_out(vty, " No Subscriber%s", VTY_NEWLINE);
Harald Welte87504212009-12-02 01:56:49 +0530735 if (is_ipaccess_bts(lchan->ts->trx->bts)) {
736 struct in_addr ia;
Holger Hans Peter Freythercec1ec52010-04-07 15:39:16 +0200737 ia.s_addr = htonl(lchan->abis_ip.bound_ip);
Harald Welte87504212009-12-02 01:56:49 +0530738 vty_out(vty, " Bound IP: %s Port %u RTP_TYPE2=%u CONN_ID=%u%s",
739 inet_ntoa(ia), lchan->abis_ip.bound_port,
740 lchan->abis_ip.rtp_payload2, lchan->abis_ip.conn_id,
741 VTY_NEWLINE);
742 }
Harald Welte44007742009-12-22 21:43:14 +0100743
744 /* we want to report the last measurement report */
745 idx = calc_initial_idx(ARRAY_SIZE(lchan->meas_rep),
746 lchan->meas_rep_idx, 1);
747 meas_rep_dump_vty(vty, &lchan->meas_rep[idx], " ");
Harald Welte59b04682009-06-10 05:40:52 +0800748}
749
Holger Hans Peter Freythere959b4e2010-05-14 02:08:49 +0800750static void lchan_dump_short_vty(struct vty *vty, struct gsm_lchan *lchan)
751{
Holger Hans Peter Freythercf13a922010-05-14 01:57:02 +0800752 struct gsm_meas_rep *mr;
753 int idx;
754
755 /* we want to report the last measurement report */
756 idx = calc_initial_idx(ARRAY_SIZE(lchan->meas_rep),
757 lchan->meas_rep_idx, 1);
758 mr = &lchan->meas_rep[idx];
759
760 vty_out(vty, "Lchan: %u Timeslot: %u TRX: %u BTS: %u Type: %s - L1 MS Power: %u dBm "
761 "RXL-FULL-dl: %4d dBm RXL-FULL-ul: %4d dBm%s",
Holger Hans Peter Freythere959b4e2010-05-14 02:08:49 +0800762 lchan->nr, lchan->ts->nr, lchan->ts->trx->nr,
763 lchan->ts->trx->bts->nr, gsm_lchant_name(lchan->type),
Holger Hans Peter Freythercf13a922010-05-14 01:57:02 +0800764 mr->ms_l1.pwr,
765 rxlev2dbm(mr->dl.full.rx_lev),
766 rxlev2dbm(mr->ul.full.rx_lev),
Holger Hans Peter Freythere959b4e2010-05-14 02:08:49 +0800767 VTY_NEWLINE);
768}
769
Holger Hans Peter Freyther5424e022010-05-14 02:03:16 +0800770static int lchan_summary(struct vty *vty, int argc, const char **argv,
771 void (*dump_cb)(struct vty *, struct gsm_lchan *))
Harald Welte59b04682009-06-10 05:40:52 +0800772{
Harald Welte40152872010-05-16 20:52:23 +0200773 struct gsm_network *net = gsmnet_from_vty(vty);
Harald Welte59b04682009-06-10 05:40:52 +0800774 struct gsm_bts *bts;
775 struct gsm_bts_trx *trx;
776 struct gsm_bts_trx_ts *ts;
777 struct gsm_lchan *lchan;
778 int bts_nr, trx_nr, ts_nr, lchan_nr;
779
780 if (argc >= 1) {
781 /* use the BTS number that the user has specified */
782 bts_nr = atoi(argv[0]);
783 if (bts_nr >= net->num_bts) {
784 vty_out(vty, "%% can't find BTS %s%s", argv[0],
785 VTY_NEWLINE);
786 return CMD_WARNING;
787 }
Harald Weltee712a5f2009-06-21 16:17:15 +0200788 bts = gsm_bts_num(net, bts_nr);
Harald Welte59b04682009-06-10 05:40:52 +0800789 }
790 if (argc >= 2) {
791 trx_nr = atoi(argv[1]);
792 if (trx_nr >= bts->num_trx) {
793 vty_out(vty, "%% can't find TRX %s%s", argv[1],
794 VTY_NEWLINE);
795 return CMD_WARNING;
796 }
Harald Weltee712a5f2009-06-21 16:17:15 +0200797 trx = gsm_bts_trx_num(bts, trx_nr);
Harald Welte59b04682009-06-10 05:40:52 +0800798 }
799 if (argc >= 3) {
800 ts_nr = atoi(argv[2]);
801 if (ts_nr >= TRX_NR_TS) {
802 vty_out(vty, "%% can't find TS %s%s", argv[2],
803 VTY_NEWLINE);
804 return CMD_WARNING;
805 }
806 ts = &trx->ts[ts_nr];
807 }
808 if (argc >= 4) {
809 lchan_nr = atoi(argv[3]);
810 if (lchan_nr >= TS_MAX_LCHAN) {
811 vty_out(vty, "%% can't find LCHAN %s%s", argv[3],
812 VTY_NEWLINE);
813 return CMD_WARNING;
814 }
815 lchan = &ts->lchan[lchan_nr];
Holger Hans Peter Freyther5424e022010-05-14 02:03:16 +0800816 dump_cb(vty, lchan);
Harald Welte59b04682009-06-10 05:40:52 +0800817 return CMD_SUCCESS;
818 }
819 for (bts_nr = 0; bts_nr < net->num_bts; bts_nr++) {
Harald Weltee712a5f2009-06-21 16:17:15 +0200820 bts = gsm_bts_num(net, bts_nr);
Harald Welte59b04682009-06-10 05:40:52 +0800821 for (trx_nr = 0; trx_nr < bts->num_trx; trx_nr++) {
Harald Weltee712a5f2009-06-21 16:17:15 +0200822 trx = gsm_bts_trx_num(bts, trx_nr);
Harald Welte59b04682009-06-10 05:40:52 +0800823 for (ts_nr = 0; ts_nr < TRX_NR_TS; ts_nr++) {
824 ts = &trx->ts[ts_nr];
825 for (lchan_nr = 0; lchan_nr < TS_MAX_LCHAN;
826 lchan_nr++) {
827 lchan = &ts->lchan[lchan_nr];
828 if (lchan->type == GSM_LCHAN_NONE)
829 continue;
Holger Hans Peter Freyther5424e022010-05-14 02:03:16 +0800830 dump_cb(vty, lchan);
Harald Welte59b04682009-06-10 05:40:52 +0800831 }
832 }
833 }
834 }
835
836 return CMD_SUCCESS;
837}
838
Holger Hans Peter Freyther5424e022010-05-14 02:03:16 +0800839
840DEFUN(show_lchan,
841 show_lchan_cmd,
842 "show lchan [bts_nr] [trx_nr] [ts_nr] [lchan_nr]",
843 SHOW_STR "Display information about a logical channel\n"
844 "BTS Number\n" "TRX Number\n" "Timeslot Number\n"
845 "Logical Channel Number\n")
846
847{
848 return lchan_summary(vty, argc, argv, lchan_dump_full_vty);
849}
850
Holger Hans Peter Freythere959b4e2010-05-14 02:08:49 +0800851DEFUN(show_lchan_summary,
852 show_lchan_summary_cmd,
853 "show lchan summary [bts_nr] [trx_nr] [ts_nr] [lchan_nr]",
854 SHOW_STR "Display information about a logical channel\n"
855 "BTS Number\n" "TRX Number\n" "Timeslot Number\n"
856 "Logical Channel Number\n")
857{
858 return lchan_summary(vty, argc, argv, lchan_dump_short_vty);
859}
860
Harald Welte59b04682009-06-10 05:40:52 +0800861static void e1drv_dump_vty(struct vty *vty, struct e1inp_driver *drv)
862{
863 vty_out(vty, "E1 Input Driver %s%s", drv->name, VTY_NEWLINE);
864}
865
866DEFUN(show_e1drv,
867 show_e1drv_cmd,
868 "show e1_driver",
869 SHOW_STR "Display information about available E1 drivers\n")
870{
871 struct e1inp_driver *drv;
872
873 llist_for_each_entry(drv, &e1inp_driver_list, list)
874 e1drv_dump_vty(vty, drv);
875
876 return CMD_SUCCESS;
877}
878
879static void e1line_dump_vty(struct vty *vty, struct e1inp_line *line)
880{
881 vty_out(vty, "E1 Line Number %u, Name %s, Driver %s%s",
882 line->num, line->name ? line->name : "",
883 line->driver->name, VTY_NEWLINE);
884}
885
886DEFUN(show_e1line,
887 show_e1line_cmd,
888 "show e1_line [line_nr]",
Harald Welte9e002452010-05-11 21:53:49 +0200889 SHOW_STR "Display information about a E1 line\n"
890 "E1 Line Number\n")
Harald Welte59b04682009-06-10 05:40:52 +0800891{
892 struct e1inp_line *line;
893
894 if (argc >= 1) {
895 int num = atoi(argv[0]);
896 llist_for_each_entry(line, &e1inp_line_list, list) {
897 if (line->num == num) {
898 e1line_dump_vty(vty, line);
899 return CMD_SUCCESS;
900 }
901 }
902 return CMD_WARNING;
903 }
904
905 llist_for_each_entry(line, &e1inp_line_list, list)
906 e1line_dump_vty(vty, line);
907
908 return CMD_SUCCESS;
909}
910
911static void e1ts_dump_vty(struct vty *vty, struct e1inp_ts *ts)
912{
Harald Welte62868882009-08-08 16:12:58 +0200913 if (ts->type == E1INP_TS_TYPE_NONE)
914 return;
Harald Welte59b04682009-06-10 05:40:52 +0800915 vty_out(vty, "E1 Timeslot %2u of Line %u is Type %s%s",
916 ts->num, ts->line->num, e1inp_tstype_name(ts->type),
917 VTY_NEWLINE);
918}
919
920DEFUN(show_e1ts,
921 show_e1ts_cmd,
922 "show e1_timeslot [line_nr] [ts_nr]",
Harald Welte9e002452010-05-11 21:53:49 +0200923 SHOW_STR "Display information about a E1 timeslot\n"
924 "E1 Line Number\n" "E1 Timeslot Number\n")
Harald Welte59b04682009-06-10 05:40:52 +0800925{
Harald Welte49c79562009-11-17 06:12:16 +0100926 struct e1inp_line *line = NULL;
Harald Welte59b04682009-06-10 05:40:52 +0800927 struct e1inp_ts *ts;
928 int ts_nr;
929
930 if (argc == 0) {
931 llist_for_each_entry(line, &e1inp_line_list, list) {
932 for (ts_nr = 0; ts_nr < NUM_E1_TS; ts_nr++) {
933 ts = &line->ts[ts_nr];
934 e1ts_dump_vty(vty, ts);
935 }
936 }
937 return CMD_SUCCESS;
938 }
939 if (argc >= 1) {
940 int num = atoi(argv[0]);
941 llist_for_each_entry(line, &e1inp_line_list, list) {
942 if (line->num == num)
943 break;
944 }
945 if (!line || line->num != num) {
946 vty_out(vty, "E1 line %s is invalid%s",
947 argv[0], VTY_NEWLINE);
948 return CMD_WARNING;
949 }
950 }
951 if (argc >= 2) {
952 ts_nr = atoi(argv[1]);
953 if (ts_nr > NUM_E1_TS) {
954 vty_out(vty, "E1 timeslot %s is invalid%s",
955 argv[1], VTY_NEWLINE);
956 return CMD_WARNING;
957 }
958 ts = &line->ts[ts_nr];
959 e1ts_dump_vty(vty, ts);
960 return CMD_SUCCESS;
961 } else {
962 for (ts_nr = 0; ts_nr < NUM_E1_TS; ts_nr++) {
963 ts = &line->ts[ts_nr];
964 e1ts_dump_vty(vty, ts);
965 }
966 return CMD_SUCCESS;
967 }
968 return CMD_SUCCESS;
969}
970
971static void paging_dump_vty(struct vty *vty, struct gsm_paging_request *pag)
972{
973 vty_out(vty, "Paging on BTS %u%s", pag->bts->nr, VTY_NEWLINE);
974 subscr_dump_vty(vty, pag->subscr);
975}
976
977static void bts_paging_dump_vty(struct vty *vty, struct gsm_bts *bts)
978{
979 struct gsm_paging_request *pag;
980
981 llist_for_each_entry(pag, &bts->paging.pending_requests, entry)
982 paging_dump_vty(vty, pag);
983}
984
985DEFUN(show_paging,
986 show_paging_cmd,
987 "show paging [bts_nr]",
Harald Welte9e002452010-05-11 21:53:49 +0200988 SHOW_STR "Display information about paging reuqests of a BTS\n"
989 "BTS Number\n")
Harald Welte59b04682009-06-10 05:40:52 +0800990{
Harald Welte40152872010-05-16 20:52:23 +0200991 struct gsm_network *net = gsmnet_from_vty(vty);
Harald Welte59b04682009-06-10 05:40:52 +0800992 struct gsm_bts *bts;
993 int bts_nr;
994
995 if (argc >= 1) {
996 /* use the BTS number that the user has specified */
997 bts_nr = atoi(argv[0]);
998 if (bts_nr >= net->num_bts) {
999 vty_out(vty, "%% can't find BTS %s%s", argv[0],
1000 VTY_NEWLINE);
1001 return CMD_WARNING;
1002 }
Harald Weltee712a5f2009-06-21 16:17:15 +02001003 bts = gsm_bts_num(net, bts_nr);
Harald Welte59b04682009-06-10 05:40:52 +08001004 bts_paging_dump_vty(vty, bts);
1005
1006 return CMD_SUCCESS;
1007 }
1008 for (bts_nr = 0; bts_nr < net->num_bts; bts_nr++) {
Harald Weltee712a5f2009-06-21 16:17:15 +02001009 bts = gsm_bts_num(net, bts_nr);
Harald Welte59b04682009-06-10 05:40:52 +08001010 bts_paging_dump_vty(vty, bts);
1011 }
1012
1013 return CMD_SUCCESS;
1014}
1015
Harald Welte9e002452010-05-11 21:53:49 +02001016#define NETWORK_STR "Configure the GSM network\n"
1017
Harald Weltee87eb462009-08-07 13:29:14 +02001018DEFUN(cfg_net,
1019 cfg_net_cmd,
Harald Welte9e002452010-05-11 21:53:49 +02001020 "network", NETWORK_STR)
Harald Weltee87eb462009-08-07 13:29:14 +02001021{
Harald Welte40152872010-05-16 20:52:23 +02001022 vty->index = gsmnet_from_vty(vty);
Harald Weltee87eb462009-08-07 13:29:14 +02001023 vty->node = GSMNET_NODE;
1024
1025 return CMD_SUCCESS;
1026}
1027
1028
1029DEFUN(cfg_net_ncc,
1030 cfg_net_ncc_cmd,
1031 "network country code <1-999>",
1032 "Set the GSM network country code")
1033{
Harald Welte40152872010-05-16 20:52:23 +02001034 struct gsm_network *gsmnet = gsmnet_from_vty(vty);
1035
Harald Weltee87eb462009-08-07 13:29:14 +02001036 gsmnet->country_code = atoi(argv[0]);
1037
1038 return CMD_SUCCESS;
1039}
1040
1041DEFUN(cfg_net_mnc,
1042 cfg_net_mnc_cmd,
1043 "mobile network code <1-999>",
1044 "Set the GSM mobile network code")
1045{
Harald Welte40152872010-05-16 20:52:23 +02001046 struct gsm_network *gsmnet = gsmnet_from_vty(vty);
1047
Harald Weltee87eb462009-08-07 13:29:14 +02001048 gsmnet->network_code = atoi(argv[0]);
1049
1050 return CMD_SUCCESS;
1051}
1052
1053DEFUN(cfg_net_name_short,
1054 cfg_net_name_short_cmd,
1055 "short name NAME",
1056 "Set the short GSM network name")
1057{
Harald Welte40152872010-05-16 20:52:23 +02001058 struct gsm_network *gsmnet = gsmnet_from_vty(vty);
1059
Harald Weltee87eb462009-08-07 13:29:14 +02001060 if (gsmnet->name_short)
1061 talloc_free(gsmnet->name_short);
1062
1063 gsmnet->name_short = talloc_strdup(gsmnet, argv[0]);
1064
1065 return CMD_SUCCESS;
1066}
1067
1068DEFUN(cfg_net_name_long,
1069 cfg_net_name_long_cmd,
1070 "long name NAME",
1071 "Set the long GSM network name")
1072{
Harald Welte40152872010-05-16 20:52:23 +02001073 struct gsm_network *gsmnet = gsmnet_from_vty(vty);
1074
Harald Weltee87eb462009-08-07 13:29:14 +02001075 if (gsmnet->name_long)
1076 talloc_free(gsmnet->name_long);
1077
1078 gsmnet->name_long = talloc_strdup(gsmnet, argv[0]);
1079
1080 return CMD_SUCCESS;
1081}
Harald Welte59b04682009-06-10 05:40:52 +08001082
Harald Welte (local)a59a27e2009-08-12 14:42:23 +02001083DEFUN(cfg_net_auth_policy,
1084 cfg_net_auth_policy_cmd,
1085 "auth policy (closed|accept-all|token)",
Harald Welte9e002452010-05-11 21:53:49 +02001086 "Authentication (not cryptographic)\n"
1087 "Set the GSM network authentication policy\n"
1088 "Require the MS to be activated in HLR\n"
1089 "Accept all MS, whether in HLR or not\n"
1090 "Use SMS-token based authentication\n")
Harald Welte (local)a59a27e2009-08-12 14:42:23 +02001091{
1092 enum gsm_auth_policy policy = gsm_auth_policy_parse(argv[0]);
Harald Welte40152872010-05-16 20:52:23 +02001093 struct gsm_network *gsmnet = gsmnet_from_vty(vty);
Harald Welte (local)a59a27e2009-08-12 14:42:23 +02001094
1095 gsmnet->auth_policy = policy;
1096
1097 return CMD_SUCCESS;
1098}
1099
Harald Welte59936d72009-11-18 20:33:19 +01001100DEFUN(cfg_net_reject_cause,
1101 cfg_net_reject_cause_cmd,
1102 "location updating reject cause <2-111>",
1103 "Set the reject cause of location updating reject\n")
1104{
Harald Welte40152872010-05-16 20:52:23 +02001105 struct gsm_network *gsmnet = gsmnet_from_vty(vty);
1106
Harald Welte59936d72009-11-18 20:33:19 +01001107 gsmnet->reject_cause = atoi(argv[0]);
1108
1109 return CMD_SUCCESS;
1110}
1111
Harald Weltecca253a2009-08-30 15:47:06 +09001112DEFUN(cfg_net_encryption,
1113 cfg_net_encryption_cmd,
1114 "encryption a5 (0|1|2)",
Harald Welte18ce31c2010-05-14 20:05:17 +02001115 "Encryption options\n"
1116 "A5 encryption\n" "A5/0: No encryption\n"
1117 "A5/1: Encryption\n" "A5/2: Export-grade Encryption\n")
Harald Weltecca253a2009-08-30 15:47:06 +09001118{
Harald Welte40152872010-05-16 20:52:23 +02001119 struct gsm_network *gsmnet = gsmnet_from_vty(vty);
1120
Andreas.Eversberg53293292009-11-17 09:55:26 +01001121 gsmnet->a5_encryption= atoi(argv[0]);
Harald Weltecca253a2009-08-30 15:47:06 +09001122
1123 return CMD_SUCCESS;
1124}
1125
Holger Hans Peter Freyther96c89822009-11-16 17:12:38 +01001126DEFUN(cfg_net_neci,
1127 cfg_net_neci_cmd,
1128 "neci (0|1)",
Harald Welte18ce31c2010-05-14 20:05:17 +02001129 "New Establish Cause Indication\n"
1130 "Don't set the NECI bit\n" "Set the NECI bit\n")
Holger Hans Peter Freyther96c89822009-11-16 17:12:38 +01001131{
Harald Welte40152872010-05-16 20:52:23 +02001132 struct gsm_network *gsmnet = gsmnet_from_vty(vty);
1133
Holger Hans Peter Freyther96c89822009-11-16 17:12:38 +01001134 gsmnet->neci = atoi(argv[0]);
Holger Hans Peter Freytherf0f37f12010-09-06 09:36:02 +08001135 gsm_net_update_ctype(gsmnet);
Holger Hans Peter Freyther96c89822009-11-16 17:12:38 +01001136 return CMD_SUCCESS;
1137}
1138
Harald Welte52af1952009-12-13 10:53:12 +01001139DEFUN(cfg_net_rrlp_mode, cfg_net_rrlp_mode_cmd,
1140 "rrlp mode (none|ms-based|ms-preferred|ass-preferred)",
Harald Welte9e002452010-05-11 21:53:49 +02001141 "Radio Resource Location Protocol\n"
1142 "Set the Radio Resource Location Protocol Mode\n"
1143 "Don't send RRLP request\n"
1144 "Request MS-based location\n"
1145 "Request any location, prefer MS-based\n"
1146 "Request any location, prefer MS-assisted\n")
Harald Welte52af1952009-12-13 10:53:12 +01001147{
Harald Welte40152872010-05-16 20:52:23 +02001148 struct gsm_network *gsmnet = gsmnet_from_vty(vty);
1149
Harald Welte52af1952009-12-13 10:53:12 +01001150 gsmnet->rrlp.mode = rrlp_mode_parse(argv[0]);
1151
1152 return CMD_SUCCESS;
1153}
1154
Harald Weltea310f3e2009-12-14 09:00:24 +01001155DEFUN(cfg_net_mm_info, cfg_net_mm_info_cmd,
1156 "mm info (0|1)",
1157 "Whether to send MM INFO after LOC UPD ACCEPT")
1158{
Harald Welte40152872010-05-16 20:52:23 +02001159 struct gsm_network *gsmnet = gsmnet_from_vty(vty);
1160
Harald Weltea310f3e2009-12-14 09:00:24 +01001161 gsmnet->send_mm_info = atoi(argv[0]);
1162
1163 return CMD_SUCCESS;
1164}
1165
Harald Welte9e002452010-05-11 21:53:49 +02001166#define HANDOVER_STR "Handover Options\n"
1167
Harald Welte0af9c9f2009-12-19 21:41:52 +01001168DEFUN(cfg_net_handover, cfg_net_handover_cmd,
1169 "handover (0|1)",
Harald Welte9e002452010-05-11 21:53:49 +02001170 HANDOVER_STR
1171 "Don't perform in-call handover\n"
1172 "Perform in-call handover\n")
Harald Welte0af9c9f2009-12-19 21:41:52 +01001173{
Holger Hans Peter Freyther3524d4b2010-01-07 16:14:38 +01001174 int enable = atoi(argv[0]);
Harald Welte40152872010-05-16 20:52:23 +02001175 struct gsm_network *gsmnet = gsmnet_from_vty(vty);
Holger Hans Peter Freyther3524d4b2010-01-07 16:14:38 +01001176
1177 if (enable && ipacc_rtp_direct) {
Harald Welteaa2c3032009-12-20 13:51:01 +01001178 vty_out(vty, "%% Cannot enable handover unless RTP Proxy mode "
1179 "is enabled by using the -P command line option%s",
1180 VTY_NEWLINE);
1181 return CMD_WARNING;
1182 }
Holger Hans Peter Freyther3524d4b2010-01-07 16:14:38 +01001183 gsmnet->handover.active = enable;
Harald Welte0af9c9f2009-12-19 21:41:52 +01001184
1185 return CMD_SUCCESS;
1186}
1187
Harald Welte9e002452010-05-11 21:53:49 +02001188#define HO_WIN_STR HANDOVER_STR "Measurement Window\n"
1189#define HO_WIN_RXLEV_STR HO_WIN_STR "Received Level Averaging\n"
1190#define HO_WIN_RXQUAL_STR HO_WIN_STR "Received Quality Averaging\n"
1191#define HO_PBUDGET_STR HANDOVER_STR "Power Budget\n"
1192
Harald Weltea8062f12009-12-21 16:51:50 +01001193DEFUN(cfg_net_ho_win_rxlev_avg, cfg_net_ho_win_rxlev_avg_cmd,
1194 "handover window rxlev averaging <1-10>",
Harald Welte9e002452010-05-11 21:53:49 +02001195 HO_WIN_RXLEV_STR
Harald Weltea8062f12009-12-21 16:51:50 +01001196 "How many RxLev measurements are used for averaging")
1197{
Harald Welte40152872010-05-16 20:52:23 +02001198 struct gsm_network *gsmnet = gsmnet_from_vty(vty);
Harald Weltea8062f12009-12-21 16:51:50 +01001199 gsmnet->handover.win_rxlev_avg = atoi(argv[0]);
1200 return CMD_SUCCESS;
1201}
1202
1203DEFUN(cfg_net_ho_win_rxqual_avg, cfg_net_ho_win_rxqual_avg_cmd,
1204 "handover window rxqual averaging <1-10>",
Harald Welte9e002452010-05-11 21:53:49 +02001205 HO_WIN_RXQUAL_STR
Harald Weltea8062f12009-12-21 16:51:50 +01001206 "How many RxQual measurements are used for averaging")
1207{
Harald Welte40152872010-05-16 20:52:23 +02001208 struct gsm_network *gsmnet = gsmnet_from_vty(vty);
Harald Weltea8062f12009-12-21 16:51:50 +01001209 gsmnet->handover.win_rxqual_avg = atoi(argv[0]);
1210 return CMD_SUCCESS;
1211}
1212
1213DEFUN(cfg_net_ho_win_rxlev_neigh_avg, cfg_net_ho_win_rxlev_avg_neigh_cmd,
1214 "handover window rxlev neighbor averaging <1-10>",
Harald Welte9e002452010-05-11 21:53:49 +02001215 HO_WIN_RXLEV_STR
Harald Weltea8062f12009-12-21 16:51:50 +01001216 "How many RxQual measurements are used for averaging")
1217{
Harald Welte40152872010-05-16 20:52:23 +02001218 struct gsm_network *gsmnet = gsmnet_from_vty(vty);
Harald Weltea8062f12009-12-21 16:51:50 +01001219 gsmnet->handover.win_rxlev_avg_neigh = atoi(argv[0]);
1220 return CMD_SUCCESS;
1221}
1222
1223DEFUN(cfg_net_ho_pwr_interval, cfg_net_ho_pwr_interval_cmd,
1224 "handover power budget interval <1-99>",
Harald Welte9e002452010-05-11 21:53:49 +02001225 HO_PBUDGET_STR
Harald Weltea8062f12009-12-21 16:51:50 +01001226 "How often to check if we have a better cell (SACCH frames)")
1227{
Harald Welte40152872010-05-16 20:52:23 +02001228 struct gsm_network *gsmnet = gsmnet_from_vty(vty);
Harald Weltea8062f12009-12-21 16:51:50 +01001229 gsmnet->handover.pwr_interval = atoi(argv[0]);
1230 return CMD_SUCCESS;
1231}
1232
1233DEFUN(cfg_net_ho_pwr_hysteresis, cfg_net_ho_pwr_hysteresis_cmd,
1234 "handover power budget hysteresis <0-999>",
Harald Welte9e002452010-05-11 21:53:49 +02001235 HO_PBUDGET_STR
Harald Weltea8062f12009-12-21 16:51:50 +01001236 "How many dB does a neighbor to be stronger to become a HO candidate")
1237{
Harald Welte40152872010-05-16 20:52:23 +02001238 struct gsm_network *gsmnet = gsmnet_from_vty(vty);
Harald Weltea8062f12009-12-21 16:51:50 +01001239 gsmnet->handover.pwr_hysteresis = atoi(argv[0]);
1240 return CMD_SUCCESS;
1241}
1242
1243DEFUN(cfg_net_ho_max_distance, cfg_net_ho_max_distance_cmd,
1244 "handover maximum distance <0-9999>",
Harald Welte9e002452010-05-11 21:53:49 +02001245 HANDOVER_STR
Harald Weltea8062f12009-12-21 16:51:50 +01001246 "How big is the maximum timing advance before HO is forced")
1247{
Harald Welte40152872010-05-16 20:52:23 +02001248 struct gsm_network *gsmnet = gsmnet_from_vty(vty);
Harald Weltea8062f12009-12-21 16:51:50 +01001249 gsmnet->handover.max_distance = atoi(argv[0]);
1250 return CMD_SUCCESS;
1251}
Harald Welte0af9c9f2009-12-19 21:41:52 +01001252
Holger Hans Peter Freytherb6b9d702010-09-06 09:41:50 +08001253DEFUN(cfg_net_pag_any_tch,
1254 cfg_net_pag_any_tch_cmd,
1255 "paging any use tch (0|1)",
1256 "Assign a TCH when receiving a Paging Any request")
1257{
Holger Hans Peter Freytherc5628882010-09-06 10:09:19 +08001258 struct gsm_network *gsmnet = gsmnet_from_vty(vty);
Holger Hans Peter Freytherb6b9d702010-09-06 09:41:50 +08001259 gsmnet->pag_any_tch = atoi(argv[0]);
1260 gsm_net_update_ctype(gsmnet);
1261 return CMD_SUCCESS;
1262}
1263
Holger Hans Peter Freyther13ae9802009-12-22 08:27:21 +01001264#define DECLARE_TIMER(number, doc) \
Holger Hans Peter Freyther26ba2e72009-11-21 21:18:38 +01001265 DEFUN(cfg_net_T##number, \
1266 cfg_net_T##number##_cmd, \
1267 "timer t" #number " <0-65535>", \
Harald Welte9e002452010-05-11 21:53:49 +02001268 "Configure GSM Timers\n" \
Holger Hans Peter Freyther13ae9802009-12-22 08:27:21 +01001269 doc) \
Holger Hans Peter Freyther26ba2e72009-11-21 21:18:38 +01001270{ \
Harald Welte40152872010-05-16 20:52:23 +02001271 struct gsm_network *gsmnet = gsmnet_from_vty(vty); \
Holger Hans Peter Freyther26ba2e72009-11-21 21:18:38 +01001272 int value = atoi(argv[0]); \
1273 \
1274 if (value < 0 || value > 65535) { \
1275 vty_out(vty, "Timer value %s out of range.%s", \
1276 argv[0], VTY_NEWLINE); \
1277 return CMD_WARNING; \
1278 } \
1279 \
1280 gsmnet->T##number = value; \
1281 return CMD_SUCCESS; \
1282}
1283
Holger Hans Peter Freyther13ae9802009-12-22 08:27:21 +01001284DECLARE_TIMER(3101, "Set the timeout value for IMMEDIATE ASSIGNMENT.")
1285DECLARE_TIMER(3103, "Set the timeout value for HANDOVER.")
1286DECLARE_TIMER(3105, "Currently not used.")
1287DECLARE_TIMER(3107, "Currently not used.")
1288DECLARE_TIMER(3109, "Currently not used.")
Holger Hans Peter Freyther4a00c062010-05-31 21:33:15 +08001289DECLARE_TIMER(3111, "Set the RSL timeout to wait before releasing the RF Channel.")
Holger Hans Peter Freyther13ae9802009-12-22 08:27:21 +01001290DECLARE_TIMER(3113, "Set the time to try paging a subscriber.")
1291DECLARE_TIMER(3115, "Currently not used.")
1292DECLARE_TIMER(3117, "Currently not used.")
1293DECLARE_TIMER(3119, "Currently not used.")
1294DECLARE_TIMER(3141, "Currently not used.")
Holger Hans Peter Freyther26ba2e72009-11-21 21:18:38 +01001295
Holger Hans Peter Freyther21d63ff2010-09-06 09:25:48 +08001296DEFUN(cfg_net_dtx,
1297 cfg_net_dtx_cmd,
1298 "dtx-used (0|1)",
1299 "Enable the usage of DTX.\n"
1300 "DTX is enabled/disabled")
1301{
1302 struct gsm_network *gsmnet = gsmnet_from_vty(vty);
1303 gsmnet->dtx_enabled = atoi(argv[0]);
1304 return CMD_SUCCESS;
1305}
Holger Hans Peter Freyther26ba2e72009-11-21 21:18:38 +01001306
Harald Welte59b04682009-06-10 05:40:52 +08001307/* per-BTS configuration */
1308DEFUN(cfg_bts,
1309 cfg_bts_cmd,
1310 "bts BTS_NR",
Harald Welte9e002452010-05-11 21:53:49 +02001311 "Select a BTS to configure\n"
1312 "BTS Number\n")
Harald Welte59b04682009-06-10 05:40:52 +08001313{
Harald Welte40152872010-05-16 20:52:23 +02001314 struct gsm_network *gsmnet = gsmnet_from_vty(vty);
Harald Welte59b04682009-06-10 05:40:52 +08001315 int bts_nr = atoi(argv[0]);
1316 struct gsm_bts *bts;
1317
Harald Weltee712a5f2009-06-21 16:17:15 +02001318 if (bts_nr > gsmnet->num_bts) {
1319 vty_out(vty, "%% The next unused BTS number is %u%s",
1320 gsmnet->num_bts, VTY_NEWLINE);
Harald Welte59b04682009-06-10 05:40:52 +08001321 return CMD_WARNING;
Harald Weltee712a5f2009-06-21 16:17:15 +02001322 } else if (bts_nr == gsmnet->num_bts) {
1323 /* allocate a new one */
1324 bts = gsm_bts_alloc(gsmnet, GSM_BTS_TYPE_UNKNOWN,
1325 HARDCODED_TSC, HARDCODED_BSIC);
Holger Hans Peter Freyther71135142010-03-29 08:47:44 +02001326 } else
Harald Weltee712a5f2009-06-21 16:17:15 +02001327 bts = gsm_bts_num(gsmnet, bts_nr);
1328
Daniel Willmann580085f2010-01-11 13:43:07 +01001329 if (!bts) {
1330 vty_out(vty, "%% Unable to allocate BTS %u%s",
1331 gsmnet->num_bts, VTY_NEWLINE);
Harald Weltee712a5f2009-06-21 16:17:15 +02001332 return CMD_WARNING;
Daniel Willmann580085f2010-01-11 13:43:07 +01001333 }
Harald Welte59b04682009-06-10 05:40:52 +08001334
1335 vty->index = bts;
Harald Welte8791dac2010-05-14 17:59:53 +02001336 vty->index_sub = &bts->description;
Harald Welte59b04682009-06-10 05:40:52 +08001337 vty->node = BTS_NODE;
1338
1339 return CMD_SUCCESS;
1340}
1341
1342DEFUN(cfg_bts_type,
1343 cfg_bts_type_cmd,
1344 "type TYPE",
1345 "Set the BTS type\n")
1346{
1347 struct gsm_bts *bts = vty->index;
Harald Welte59698fb2010-01-10 18:01:52 +01001348 int rc;
Harald Welte59b04682009-06-10 05:40:52 +08001349
Harald Welte59698fb2010-01-10 18:01:52 +01001350 rc = gsm_set_bts_type(bts, parse_btstype(argv[0]));
1351 if (rc < 0)
1352 return CMD_WARNING;
Harald Welte25572872009-10-20 00:22:00 +02001353
Harald Welte59b04682009-06-10 05:40:52 +08001354 return CMD_SUCCESS;
1355}
1356
Harald Welte91afe4c2009-06-20 18:15:19 +02001357DEFUN(cfg_bts_band,
1358 cfg_bts_band_cmd,
1359 "band BAND",
1360 "Set the frequency band of this BTS\n")
1361{
1362 struct gsm_bts *bts = vty->index;
Harald Welte62868882009-08-08 16:12:58 +02001363 int band = gsm_band_parse(argv[0]);
Harald Welte91afe4c2009-06-20 18:15:19 +02001364
1365 if (band < 0) {
1366 vty_out(vty, "%% BAND %d is not a valid GSM band%s",
1367 band, VTY_NEWLINE);
1368 return CMD_WARNING;
1369 }
1370
1371 bts->band = band;
1372
1373 return CMD_SUCCESS;
1374}
1375
Holger Hans Peter Freythera098dfb2009-08-21 14:44:12 +02001376DEFUN(cfg_bts_ci,
1377 cfg_bts_ci_cmd,
1378 "cell_identity <0-65535>",
1379 "Set the Cell identity of this BTS\n")
1380{
1381 struct gsm_bts *bts = vty->index;
1382 int ci = atoi(argv[0]);
1383
1384 if (ci < 0 || ci > 0xffff) {
1385 vty_out(vty, "%% CI %d is not in the valid range (0-65535)%s",
1386 ci, VTY_NEWLINE);
1387 return CMD_WARNING;
1388 }
1389 bts->cell_identity = ci;
1390
1391 return CMD_SUCCESS;
1392}
1393
Harald Welte59b04682009-06-10 05:40:52 +08001394DEFUN(cfg_bts_lac,
1395 cfg_bts_lac_cmd,
Holger Hans Peter Freyther54a22832009-09-29 14:02:33 +02001396 "location_area_code <0-65535>",
Harald Welte59b04682009-06-10 05:40:52 +08001397 "Set the Location Area Code (LAC) of this BTS\n")
1398{
1399 struct gsm_bts *bts = vty->index;
1400 int lac = atoi(argv[0]);
1401
Holger Hans Peter Freyther54a22832009-09-29 14:02:33 +02001402 if (lac < 0 || lac > 0xffff) {
1403 vty_out(vty, "%% LAC %d is not in the valid range (0-65535)%s",
Harald Welte59b04682009-06-10 05:40:52 +08001404 lac, VTY_NEWLINE);
1405 return CMD_WARNING;
1406 }
Holger Hans Peter Freyther6c6ab862009-10-01 04:07:15 +02001407
1408 if (lac == GSM_LAC_RESERVED_DETACHED || lac == GSM_LAC_RESERVED_ALL_BTS) {
1409 vty_out(vty, "%% LAC %d is reserved by GSM 04.08%s",
1410 lac, VTY_NEWLINE);
1411 return CMD_WARNING;
1412 }
1413
Harald Welte59b04682009-06-10 05:40:52 +08001414 bts->location_area_code = lac;
1415
1416 return CMD_SUCCESS;
1417}
1418
Harald Weltea54a2bb2009-12-01 18:04:30 +05301419
Harald Welte59b04682009-06-10 05:40:52 +08001420DEFUN(cfg_bts_tsc,
1421 cfg_bts_tsc_cmd,
1422 "training_sequence_code <0-255>",
1423 "Set the Training Sequence Code (TSC) of this BTS\n")
1424{
1425 struct gsm_bts *bts = vty->index;
1426 int tsc = atoi(argv[0]);
1427
1428 if (tsc < 0 || tsc > 0xff) {
1429 vty_out(vty, "%% TSC %d is not in the valid range (0-255)%s",
1430 tsc, VTY_NEWLINE);
1431 return CMD_WARNING;
1432 }
1433 bts->tsc = tsc;
1434
1435 return CMD_SUCCESS;
1436}
1437
1438DEFUN(cfg_bts_bsic,
1439 cfg_bts_bsic_cmd,
1440 "base_station_id_code <0-63>",
1441 "Set the Base Station Identity Code (BSIC) of this BTS\n")
1442{
1443 struct gsm_bts *bts = vty->index;
1444 int bsic = atoi(argv[0]);
1445
1446 if (bsic < 0 || bsic > 0x3f) {
Harald Welte62868882009-08-08 16:12:58 +02001447 vty_out(vty, "%% BSIC %d is not in the valid range (0-255)%s",
Harald Welte59b04682009-06-10 05:40:52 +08001448 bsic, VTY_NEWLINE);
1449 return CMD_WARNING;
1450 }
1451 bts->bsic = bsic;
1452
1453 return CMD_SUCCESS;
1454}
1455
1456
1457DEFUN(cfg_bts_unit_id,
1458 cfg_bts_unit_id_cmd,
Harald Weltef515aa02009-08-07 13:27:09 +02001459 "ip.access unit_id <0-65534> <0-255>",
1460 "Set the ip.access BTS Unit ID of this BTS\n")
Harald Welte59b04682009-06-10 05:40:52 +08001461{
1462 struct gsm_bts *bts = vty->index;
1463 int site_id = atoi(argv[0]);
1464 int bts_id = atoi(argv[1]);
1465
Harald Weltef515aa02009-08-07 13:27:09 +02001466 if (!is_ipaccess_bts(bts)) {
1467 vty_out(vty, "%% BTS is not of ip.access type%s", VTY_NEWLINE);
1468 return CMD_WARNING;
1469 }
1470
Harald Welte59b04682009-06-10 05:40:52 +08001471 bts->ip_access.site_id = site_id;
1472 bts->ip_access.bts_id = bts_id;
1473
1474 return CMD_SUCCESS;
1475}
1476
Harald Welte9e002452010-05-11 21:53:49 +02001477#define OML_STR "Organization & Maintenance Link\n"
1478#define IPA_STR "ip.access Specific Options\n"
1479
Harald Welte25572872009-10-20 00:22:00 +02001480DEFUN(cfg_bts_stream_id,
1481 cfg_bts_stream_id_cmd,
1482 "oml ip.access stream_id <0-255>",
Harald Welte9e002452010-05-11 21:53:49 +02001483 OML_STR IPA_STR
Harald Welte25572872009-10-20 00:22:00 +02001484 "Set the ip.access Stream ID of the OML link of this BTS\n")
1485{
1486 struct gsm_bts *bts = vty->index;
1487 int stream_id = atoi(argv[0]);
1488
1489 if (!is_ipaccess_bts(bts)) {
1490 vty_out(vty, "%% BTS is not of ip.access type%s", VTY_NEWLINE);
1491 return CMD_WARNING;
1492 }
1493
1494 bts->oml_tei = stream_id;
1495
1496 return CMD_SUCCESS;
1497}
1498
Harald Welte9e002452010-05-11 21:53:49 +02001499#define OML_E1_STR OML_STR "E1 Line\n"
Harald Welte25572872009-10-20 00:22:00 +02001500
Harald Welte62868882009-08-08 16:12:58 +02001501DEFUN(cfg_bts_oml_e1,
1502 cfg_bts_oml_e1_cmd,
1503 "oml e1 line E1_LINE timeslot <1-31> sub-slot (0|1|2|3|full)",
Harald Welte9e002452010-05-11 21:53:49 +02001504 OML_E1_STR
Harald Welte62868882009-08-08 16:12:58 +02001505 "E1 interface to be used for OML\n")
1506{
1507 struct gsm_bts *bts = vty->index;
1508
1509 parse_e1_link(&bts->oml_e1_link, argv[0], argv[1], argv[2]);
1510
1511 return CMD_SUCCESS;
1512}
1513
1514
1515DEFUN(cfg_bts_oml_e1_tei,
1516 cfg_bts_oml_e1_tei_cmd,
1517 "oml e1 tei <0-63>",
Harald Welte9e002452010-05-11 21:53:49 +02001518 OML_E1_STR
Harald Welte62868882009-08-08 16:12:58 +02001519 "Set the TEI to be used for OML")
1520{
1521 struct gsm_bts *bts = vty->index;
1522
1523 bts->oml_tei = atoi(argv[0]);
1524
1525 return CMD_SUCCESS;
1526}
1527
Harald Welte3e774612009-08-10 13:48:16 +02001528DEFUN(cfg_bts_challoc, cfg_bts_challoc_cmd,
1529 "channel allocator (ascending|descending)",
Harald Welte9e002452010-05-11 21:53:49 +02001530 "Channnel Allocator\n" "Channel Allocator\n"
1531 "Allocate Timeslots and Transceivers in ascending order\n"
1532 "Allocate Timeslots and Transceivers in descending order\n")
Harald Welte3e774612009-08-10 13:48:16 +02001533{
1534 struct gsm_bts *bts = vty->index;
1535
1536 if (!strcmp(argv[0], "ascending"))
1537 bts->chan_alloc_reverse = 0;
1538 else
1539 bts->chan_alloc_reverse = 1;
1540
1541 return CMD_SUCCESS;
1542}
1543
Harald Welte9e002452010-05-11 21:53:49 +02001544#define RACH_STR "Random Access Control Channel\n"
1545
Sylvain Munaut8e2d8de2009-12-22 13:43:26 +01001546DEFUN(cfg_bts_rach_tx_integer,
1547 cfg_bts_rach_tx_integer_cmd,
1548 "rach tx integer <0-15>",
Harald Welte9e002452010-05-11 21:53:49 +02001549 RACH_STR
Sylvain Munaut8e2d8de2009-12-22 13:43:26 +01001550 "Set the raw tx integer value in RACH Control parameters IE")
1551{
1552 struct gsm_bts *bts = vty->index;
1553 bts->si_common.rach_control.tx_integer = atoi(argv[0]) & 0xf;
1554 return CMD_SUCCESS;
1555}
1556
1557DEFUN(cfg_bts_rach_max_trans,
1558 cfg_bts_rach_max_trans_cmd,
1559 "rach max transmission (1|2|4|7)",
Harald Welte9e002452010-05-11 21:53:49 +02001560 RACH_STR
Sylvain Munaut8e2d8de2009-12-22 13:43:26 +01001561 "Set the maximum number of RACH burst transmissions")
1562{
1563 struct gsm_bts *bts = vty->index;
1564 bts->si_common.rach_control.max_trans = rach_max_trans_val2raw(atoi(argv[0]));
1565 return CMD_SUCCESS;
1566}
1567
Harald Welte9e002452010-05-11 21:53:49 +02001568#define NM_STR "Network Management\n"
1569
Holger Hans Peter Freyther697ed2b2010-04-25 23:08:39 +08001570DEFUN(cfg_bts_rach_nm_b_thresh,
1571 cfg_bts_rach_nm_b_thresh_cmd,
1572 "rach nm busy threshold <0-255>",
Harald Welte9e002452010-05-11 21:53:49 +02001573 RACH_STR NM_STR
1574 "Set the NM Busy Threshold in dB")
Holger Hans Peter Freyther697ed2b2010-04-25 23:08:39 +08001575{
1576 struct gsm_bts *bts = vty->index;
1577 bts->rach_b_thresh = atoi(argv[0]);
1578 return CMD_SUCCESS;
1579}
1580
1581DEFUN(cfg_bts_rach_nm_ldavg,
1582 cfg_bts_rach_nm_ldavg_cmd,
1583 "rach nm load average <0-65535>",
Harald Welte9e002452010-05-11 21:53:49 +02001584 RACH_STR NM_STR
1585 "Set the NM Loadaverage Slots value")
Holger Hans Peter Freyther697ed2b2010-04-25 23:08:39 +08001586{
1587 struct gsm_bts *bts = vty->index;
1588 bts->rach_ldavg_slots = atoi(argv[0]);
1589 return CMD_SUCCESS;
1590}
1591
Harald Welte (local)e19be3f2009-08-12 13:28:23 +02001592DEFUN(cfg_bts_cell_barred, cfg_bts_cell_barred_cmd,
1593 "cell barred (0|1)",
1594 "Should this cell be barred from access?")
1595{
1596 struct gsm_bts *bts = vty->index;
1597
Harald Welte8c973ba2009-12-21 23:08:18 +01001598 bts->si_common.rach_control.cell_bar = atoi(argv[0]);
Harald Welte (local)e19be3f2009-08-12 13:28:23 +02001599
1600 return CMD_SUCCESS;
1601}
1602
Holger Hans Peter Freyther440984b2010-05-14 00:39:19 +08001603DEFUN(cfg_bts_rach_ec_allowed, cfg_bts_rach_ec_allowed_cmd,
1604 "rach emergency call allowed (0|1)",
1605 "Should this cell allow emergency calls?")
1606{
1607 struct gsm_bts *bts = vty->index;
1608
1609 if (atoi(argv[0]) == 0)
1610 bts->si_common.rach_control.t2 |= 0x4;
1611 else
1612 bts->si_common.rach_control.t2 &= ~0x4;
1613
1614 return CMD_SUCCESS;
1615}
1616
Harald Welte (local)cbd46102009-08-13 10:14:26 +02001617DEFUN(cfg_bts_ms_max_power, cfg_bts_ms_max_power_cmd,
1618 "ms max power <0-40>",
1619 "Maximum transmit power of the MS")
1620{
1621 struct gsm_bts *bts = vty->index;
1622
1623 bts->ms_max_power = atoi(argv[0]);
1624
1625 return CMD_SUCCESS;
1626}
1627
Harald Welteb761bf82009-12-12 18:17:25 +01001628DEFUN(cfg_bts_cell_resel_hyst, cfg_bts_cell_resel_hyst_cmd,
1629 "cell reselection hysteresis <0-14>",
1630 "Cell Re-Selection Hysteresis in dB")
1631{
1632 struct gsm_bts *bts = vty->index;
1633
1634 bts->si_common.cell_sel_par.cell_resel_hyst = atoi(argv[0])/2;
1635
1636 return CMD_SUCCESS;
1637}
1638
1639DEFUN(cfg_bts_rxlev_acc_min, cfg_bts_rxlev_acc_min_cmd,
1640 "rxlev access min <0-63>",
1641 "Minimum RxLev needed for cell access (better than -110dBm)")
1642{
1643 struct gsm_bts *bts = vty->index;
1644
1645 bts->si_common.cell_sel_par.rxlev_acc_min = atoi(argv[0]);
1646
1647 return CMD_SUCCESS;
1648}
1649
Harald Welte (local)b6ea7f72009-08-14 23:09:25 +02001650DEFUN(cfg_bts_per_loc_upd, cfg_bts_per_loc_upd_cmd,
1651 "periodic location update <0-1530>",
1652 "Periodic Location Updating Interval in Minutes")
1653{
1654 struct gsm_bts *bts = vty->index;
1655
Harald Weltea54a2bb2009-12-01 18:04:30 +05301656 bts->si_common.chan_desc.t3212 = atoi(argv[0]) / 10;
Harald Welte (local)b6ea7f72009-08-14 23:09:25 +02001657
1658 return CMD_SUCCESS;
1659}
1660
Harald Welte9e002452010-05-11 21:53:49 +02001661#define GPRS_TEXT "GPRS Packet Network\n"
1662
Harald Welte410575a2010-03-14 23:30:30 +08001663DEFUN(cfg_bts_prs_bvci, cfg_bts_gprs_bvci_cmd,
Harald Welteb42fe342010-04-18 14:00:26 +02001664 "gprs cell bvci <2-65535>",
Harald Welte9e002452010-05-11 21:53:49 +02001665 GPRS_TEXT
1666 "GPRS Cell Settings\n"
Harald Welte3055e332010-03-14 15:37:43 +08001667 "GPRS BSSGP VC Identifier")
1668{
1669 struct gsm_bts *bts = vty->index;
1670
Harald Weltecb20b7a2010-04-18 15:51:20 +02001671 if (bts->gprs.mode == BTS_GPRS_NONE) {
Harald Weltec05a4b12010-03-14 23:56:56 +08001672 vty_out(vty, "%% GPRS not enabled on this BTS%s", VTY_NEWLINE);
1673 return CMD_WARNING;
1674 }
1675
Harald Welte3055e332010-03-14 15:37:43 +08001676 bts->gprs.cell.bvci = atoi(argv[0]);
1677
1678 return CMD_SUCCESS;
1679}
1680
Harald Welte4a048c52010-03-22 11:48:36 +08001681DEFUN(cfg_bts_gprs_nsei, cfg_bts_gprs_nsei_cmd,
1682 "gprs nsei <0-65535>",
Harald Welte9e002452010-05-11 21:53:49 +02001683 GPRS_TEXT
Harald Welte4a048c52010-03-22 11:48:36 +08001684 "GPRS NS Entity Identifier")
1685{
1686 struct gsm_bts *bts = vty->index;
1687
Harald Weltecb20b7a2010-04-18 15:51:20 +02001688 if (bts->gprs.mode == BTS_GPRS_NONE) {
Harald Welte4a048c52010-03-22 11:48:36 +08001689 vty_out(vty, "%% GPRS not enabled on this BTS%s", VTY_NEWLINE);
1690 return CMD_WARNING;
1691 }
1692
1693 bts->gprs.nse.nsei = atoi(argv[0]);
1694
1695 return CMD_SUCCESS;
1696}
1697
Harald Welte9e002452010-05-11 21:53:49 +02001698#define NSVC_TEXT "Network Service Virtual Connection (NS-VC)\n" \
1699 "NSVC Logical Number\n"
Harald Welte4a048c52010-03-22 11:48:36 +08001700
Harald Welte3055e332010-03-14 15:37:43 +08001701DEFUN(cfg_bts_gprs_nsvci, cfg_bts_gprs_nsvci_cmd,
1702 "gprs nsvc <0-1> nsvci <0-65535>",
Harald Welte9e002452010-05-11 21:53:49 +02001703 GPRS_TEXT NSVC_TEXT
1704 "NS Virtual Connection Identifier\n"
Harald Welte3055e332010-03-14 15:37:43 +08001705 "GPRS NS VC Identifier")
1706{
1707 struct gsm_bts *bts = vty->index;
1708 int idx = atoi(argv[0]);
1709
Harald Weltecb20b7a2010-04-18 15:51:20 +02001710 if (bts->gprs.mode == BTS_GPRS_NONE) {
Harald Weltec05a4b12010-03-14 23:56:56 +08001711 vty_out(vty, "%% GPRS not enabled on this BTS%s", VTY_NEWLINE);
1712 return CMD_WARNING;
1713 }
1714
Harald Welte3055e332010-03-14 15:37:43 +08001715 bts->gprs.nsvc[idx].nsvci = atoi(argv[1]);
1716
1717 return CMD_SUCCESS;
1718}
1719
Harald Welte410575a2010-03-14 23:30:30 +08001720DEFUN(cfg_bts_gprs_nsvc_lport, cfg_bts_gprs_nsvc_lport_cmd,
1721 "gprs nsvc <0-1> local udp port <0-65535>",
Harald Welte9e002452010-05-11 21:53:49 +02001722 GPRS_TEXT NSVC_TEXT
Harald Welte410575a2010-03-14 23:30:30 +08001723 "GPRS NS Local UDP Port")
1724{
1725 struct gsm_bts *bts = vty->index;
1726 int idx = atoi(argv[0]);
1727
Harald Weltecb20b7a2010-04-18 15:51:20 +02001728 if (bts->gprs.mode == BTS_GPRS_NONE) {
Harald Weltec05a4b12010-03-14 23:56:56 +08001729 vty_out(vty, "%% GPRS not enabled on this BTS%s", VTY_NEWLINE);
1730 return CMD_WARNING;
1731 }
1732
Harald Welte410575a2010-03-14 23:30:30 +08001733 bts->gprs.nsvc[idx].local_port = atoi(argv[1]);
1734
1735 return CMD_SUCCESS;
1736}
1737
1738DEFUN(cfg_bts_gprs_nsvc_rport, cfg_bts_gprs_nsvc_rport_cmd,
1739 "gprs nsvc <0-1> remote udp port <0-65535>",
Harald Welte9e002452010-05-11 21:53:49 +02001740 GPRS_TEXT NSVC_TEXT
Harald Welte410575a2010-03-14 23:30:30 +08001741 "GPRS NS Remote UDP Port")
1742{
1743 struct gsm_bts *bts = vty->index;
1744 int idx = atoi(argv[0]);
1745
Harald Weltecb20b7a2010-04-18 15:51:20 +02001746 if (bts->gprs.mode == BTS_GPRS_NONE) {
Harald Weltec05a4b12010-03-14 23:56:56 +08001747 vty_out(vty, "%% GPRS not enabled on this BTS%s", VTY_NEWLINE);
1748 return CMD_WARNING;
1749 }
1750
Harald Welte410575a2010-03-14 23:30:30 +08001751 bts->gprs.nsvc[idx].remote_port = atoi(argv[1]);
1752
1753 return CMD_SUCCESS;
1754}
1755
1756DEFUN(cfg_bts_gprs_nsvc_rip, cfg_bts_gprs_nsvc_rip_cmd,
1757 "gprs nsvc <0-1> remote ip A.B.C.D",
Harald Welte9e002452010-05-11 21:53:49 +02001758 GPRS_TEXT NSVC_TEXT
Harald Welte410575a2010-03-14 23:30:30 +08001759 "GPRS NS Remote IP Address")
1760{
1761 struct gsm_bts *bts = vty->index;
1762 int idx = atoi(argv[0]);
1763 struct in_addr ia;
1764
Harald Weltecb20b7a2010-04-18 15:51:20 +02001765 if (bts->gprs.mode == BTS_GPRS_NONE) {
Harald Weltec05a4b12010-03-14 23:56:56 +08001766 vty_out(vty, "%% GPRS not enabled on this BTS%s", VTY_NEWLINE);
1767 return CMD_WARNING;
1768 }
1769
Harald Welte410575a2010-03-14 23:30:30 +08001770 inet_aton(argv[1], &ia);
1771 bts->gprs.nsvc[idx].remote_ip = ntohl(ia.s_addr);
1772
1773 return CMD_SUCCESS;
1774}
1775
Harald Weltea9251762010-05-11 23:50:21 +02001776DEFUN(cfg_bts_gprs_ns_timer, cfg_bts_gprs_ns_timer_cmd,
1777 "gprs ns timer " NS_TIMERS " <0-255>",
1778 GPRS_TEXT "Network Service\n"
1779 "Network Service Timer\n"
1780 NS_TIMERS_HELP "Timer Value\n")
1781{
1782 struct gsm_bts *bts = vty->index;
1783 int idx = get_string_value(gprs_ns_timer_strs, argv[0]);
1784 int val = atoi(argv[1]);
1785
1786 if (bts->gprs.mode == BTS_GPRS_NONE) {
1787 vty_out(vty, "%% GPRS not enabled on this BTS%s", VTY_NEWLINE);
1788 return CMD_WARNING;
1789 }
1790
1791 if (idx < 0 || idx >= ARRAY_SIZE(bts->gprs.nse.timer))
1792 return CMD_WARNING;
1793
1794 bts->gprs.nse.timer[idx] = val;
1795
1796 return CMD_SUCCESS;
1797}
1798
1799#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 +02001800#define BSSGP_TIMERS_HELP \
1801 "Tbvc-block timeout\n" \
1802 "Tbvc-block retries\n" \
1803 "Tbvc-unblock retries\n" \
1804 "Tbvcc-reset timeout\n" \
1805 "Tbvc-reset retries\n" \
1806 "Tbvc-suspend timeout\n" \
1807 "Tbvc-suspend retries\n" \
1808 "Tbvc-resume timeout\n" \
1809 "Tbvc-resume retries\n" \
1810 "Tbvc-capa-update timeout\n" \
1811 "Tbvc-capa-update retries\n"
Harald Weltea9251762010-05-11 23:50:21 +02001812
1813DEFUN(cfg_bts_gprs_cell_timer, cfg_bts_gprs_cell_timer_cmd,
1814 "gprs cell timer " BSSGP_TIMERS " <0-255>",
1815 GPRS_TEXT "Cell / BSSGP\n"
1816 "Cell/BSSGP Timer\n"
1817 BSSGP_TIMERS_HELP "Timer Value\n")
1818{
1819 struct gsm_bts *bts = vty->index;
1820 int idx = get_string_value(gprs_bssgp_cfg_strs, argv[0]);
1821 int val = atoi(argv[1]);
1822
1823 if (bts->gprs.mode == BTS_GPRS_NONE) {
1824 vty_out(vty, "%% GPRS not enabled on this BTS%s", VTY_NEWLINE);
1825 return CMD_WARNING;
1826 }
1827
1828 if (idx < 0 || idx >= ARRAY_SIZE(bts->gprs.cell.timer))
1829 return CMD_WARNING;
1830
1831 bts->gprs.cell.timer[idx] = val;
1832
1833 return CMD_SUCCESS;
1834}
1835
Harald Welte3055e332010-03-14 15:37:43 +08001836DEFUN(cfg_bts_gprs_rac, cfg_bts_gprs_rac_cmd,
1837 "gprs routing area <0-255>",
Harald Welte9e002452010-05-11 21:53:49 +02001838 GPRS_TEXT
Harald Welte3055e332010-03-14 15:37:43 +08001839 "GPRS Routing Area Code")
1840{
1841 struct gsm_bts *bts = vty->index;
1842
Harald Weltecb20b7a2010-04-18 15:51:20 +02001843 if (bts->gprs.mode == BTS_GPRS_NONE) {
Harald Weltec05a4b12010-03-14 23:56:56 +08001844 vty_out(vty, "%% GPRS not enabled on this BTS%s", VTY_NEWLINE);
1845 return CMD_WARNING;
1846 }
1847
Harald Welte3055e332010-03-14 15:37:43 +08001848 bts->gprs.rac = atoi(argv[0]);
1849
1850 return CMD_SUCCESS;
1851}
1852
Harald Weltecb20b7a2010-04-18 15:51:20 +02001853DEFUN(cfg_bts_gprs_mode, cfg_bts_gprs_mode_cmd,
1854 "gprs mode (none|gprs|egprs)",
Harald Welte9e002452010-05-11 21:53:49 +02001855 GPRS_TEXT
1856 "GPRS Mode for this BTS\n"
1857 "GPRS Disabled on this BTS\n"
1858 "GPRS Enabled on this BTS\n"
1859 "EGPRS (EDGE) Enabled on this BTS\n")
Harald Welte410575a2010-03-14 23:30:30 +08001860{
1861 struct gsm_bts *bts = vty->index;
Harald Welte20e275a2010-06-14 22:44:42 +02001862 enum bts_gprs_mode mode = bts_gprs_mode_parse(argv[0]);
Harald Welte410575a2010-03-14 23:30:30 +08001863
Harald Welte20e275a2010-06-14 22:44:42 +02001864 if (mode != BTS_GPRS_NONE &&
1865 !gsm_bts_has_feature(bts, BTS_FEAT_GPRS)) {
1866 vty_out(vty, "This BTS type does not support %s%s", argv[0],
1867 VTY_NEWLINE);
1868 return CMD_WARNING;
1869 }
1870 if (mode == BTS_GPRS_EGPRS &&
1871 !gsm_bts_has_feature(bts, BTS_FEAT_EGPRS)) {
1872 vty_out(vty, "This BTS type does not support %s%s", argv[0],
1873 VTY_NEWLINE);
1874 return CMD_WARNING;
1875 }
1876
1877 bts->gprs.mode = mode;
Harald Welte410575a2010-03-14 23:30:30 +08001878
1879 return CMD_SUCCESS;
1880}
1881
Harald Welted8acf142010-07-30 11:50:09 +02001882#define SI_TEXT "System Information Messages\n"
1883#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)"
1884#define SI_TYPE_HELP "System Information Type 1\n" \
1885 "System Information Type 2\n" \
1886 "System Information Type 3\n" \
1887 "System Information Type 4\n" \
1888 "System Information Type 5\n" \
1889 "System Information Type 6\n" \
1890 "System Information Type 7\n" \
1891 "System Information Type 8\n" \
1892 "System Information Type 9\n" \
1893 "System Information Type 10\n" \
1894 "System Information Type 13\n" \
1895 "System Information Type 16\n" \
1896 "System Information Type 17\n" \
1897 "System Information Type 18\n" \
1898 "System Information Type 19\n" \
1899 "System Information Type 20\n" \
1900 "System Information Type 2bis\n" \
1901 "System Information Type 2ter\n" \
1902 "System Information Type 2quater\n" \
1903 "System Information Type 5bis\n" \
1904 "System Information Type 5ter\n"
1905
1906DEFUN(cfg_bts_si_mode, cfg_bts_si_mode_cmd,
1907 "system-information " SI_TYPE_TEXT " mode (static|computed)",
1908 SI_TEXT SI_TYPE_HELP
1909 "System Information Mode\n"
1910 "Static user-specified\n"
1911 "Dynamic, BSC-computed\n")
1912{
1913 struct gsm_bts *bts = vty->index;
1914 int type;
1915
1916 type = get_string_value(osmo_sitype_strs, argv[0]);
1917 if (type < 0) {
1918 vty_out(vty, "Error SI Type%s", VTY_NEWLINE);
1919 return CMD_WARNING;
1920 }
1921
1922 if (!strcmp(argv[1], "static"))
1923 bts->si_mode_static |= (1 << type);
1924 else
1925 bts->si_mode_static &= ~(1 << type);
1926
1927 return CMD_SUCCESS;
1928}
1929
1930DEFUN(cfg_bts_si_static, cfg_bts_si_static_cmd,
1931 "system-information " SI_TYPE_TEXT " static HEXSTRING",
1932 SI_TEXT SI_TYPE_HELP
1933 "Static System Information filling\n"
1934 "Static user-specified SI content in HEX notation\n")
1935{
1936 struct gsm_bts *bts = vty->index;
1937 int rc, type;
1938
1939 type = get_string_value(osmo_sitype_strs, argv[0]);
1940 if (type < 0) {
1941 vty_out(vty, "Error SI Type%s", VTY_NEWLINE);
1942 return CMD_WARNING;
1943 }
1944
1945 if (!(bts->si_mode_static & (1 << type))) {
1946 vty_out(vty, "SI Type %s is not configured in static mode%s",
1947 get_value_string(osmo_sitype_strs, type), VTY_NEWLINE);
1948 return CMD_WARNING;
1949 }
1950
Harald Welte9f09ac32010-07-30 11:53:18 +02001951 /* Fill buffer with padding pattern */
1952 memset(bts->si_buf[type], 0x2b, sizeof(bts->si_buf[type]));
1953
1954 /* Parse the user-specified SI in hex format, [partially] overwriting padding */
Harald Welted8acf142010-07-30 11:50:09 +02001955 rc = hexparse(argv[1], bts->si_buf[type], sizeof(bts->si_buf[0]));
1956 if (rc < 0 || rc > sizeof(bts->si_buf[0])) {
1957 vty_out(vty, "Error parsing HEXSTRING%s", VTY_NEWLINE);
1958 return CMD_WARNING;
1959 }
1960
1961 /* Mark this SI as present */
1962 bts->si_valid |= (1 << type);
1963
1964 return CMD_SUCCESS;
1965}
1966
1967
Harald Welte9e002452010-05-11 21:53:49 +02001968#define TRX_TEXT "Radio Transceiver\n"
Harald Welte3e774612009-08-10 13:48:16 +02001969
Harald Welte59b04682009-06-10 05:40:52 +08001970/* per TRX configuration */
1971DEFUN(cfg_trx,
1972 cfg_trx_cmd,
1973 "trx TRX_NR",
Harald Welte9e002452010-05-11 21:53:49 +02001974 TRX_TEXT
Harald Welte59b04682009-06-10 05:40:52 +08001975 "Select a TRX to configure")
1976{
1977 int trx_nr = atoi(argv[0]);
1978 struct gsm_bts *bts = vty->index;
1979 struct gsm_bts_trx *trx;
1980
Harald Weltee712a5f2009-06-21 16:17:15 +02001981 if (trx_nr > bts->num_trx) {
1982 vty_out(vty, "%% The next unused TRX number in this BTS is %u%s",
1983 bts->num_trx, VTY_NEWLINE);
Harald Welte59b04682009-06-10 05:40:52 +08001984 return CMD_WARNING;
Harald Weltee712a5f2009-06-21 16:17:15 +02001985 } else if (trx_nr == bts->num_trx) {
1986 /* we need to allocate a new one */
1987 trx = gsm_bts_trx_alloc(bts);
Holger Hans Peter Freyther71135142010-03-29 08:47:44 +02001988 } else
Harald Weltee712a5f2009-06-21 16:17:15 +02001989 trx = gsm_bts_trx_num(bts, trx_nr);
Holger Hans Peter Freyther71135142010-03-29 08:47:44 +02001990
Harald Weltee712a5f2009-06-21 16:17:15 +02001991 if (!trx)
1992 return CMD_WARNING;
Harald Welte59b04682009-06-10 05:40:52 +08001993
1994 vty->index = trx;
Harald Welte8791dac2010-05-14 17:59:53 +02001995 vty->index_sub = &trx->description;
Harald Welte59b04682009-06-10 05:40:52 +08001996 vty->node = TRX_NODE;
1997
1998 return CMD_SUCCESS;
1999}
2000
2001DEFUN(cfg_trx_arfcn,
2002 cfg_trx_arfcn_cmd,
Harald Welte00044592010-05-14 19:00:52 +02002003 "arfcn <0-1024>",
Harald Welte59b04682009-06-10 05:40:52 +08002004 "Set the ARFCN for this TRX\n")
2005{
2006 int arfcn = atoi(argv[0]);
2007 struct gsm_bts_trx *trx = vty->index;
2008
2009 /* FIXME: check if this ARFCN is supported by this TRX */
2010
2011 trx->arfcn = arfcn;
2012
2013 /* FIXME: patch ARFCN into SYSTEM INFORMATION */
2014 /* FIXME: use OML layer to update the ARFCN */
2015 /* FIXME: use RSL layer to update SYSTEM INFORMATION */
2016
2017 return CMD_SUCCESS;
2018}
2019
Harald Welte (local)b709bfe2009-12-27 20:56:38 +01002020DEFUN(cfg_trx_nominal_power,
2021 cfg_trx_nominal_power_cmd,
2022 "nominal power <0-100>",
2023 "Nominal TRX RF Power in dB\n")
2024{
2025 struct gsm_bts_trx *trx = vty->index;
2026
2027 trx->nominal_power = atoi(argv[0]);
2028
2029 return CMD_SUCCESS;
2030}
2031
Harald Welte91afe4c2009-06-20 18:15:19 +02002032DEFUN(cfg_trx_max_power_red,
2033 cfg_trx_max_power_red_cmd,
2034 "max_power_red <0-100>",
2035 "Reduction of maximum BS RF Power in dB\n")
2036{
2037 int maxpwr_r = atoi(argv[0]);
2038 struct gsm_bts_trx *trx = vty->index;
Harald Welte01acd742009-11-18 09:20:22 +01002039 int upper_limit = 24; /* default 12.21 max power red. */
Harald Welte91afe4c2009-06-20 18:15:19 +02002040
2041 /* FIXME: check if our BTS type supports more than 12 */
2042 if (maxpwr_r < 0 || maxpwr_r > upper_limit) {
2043 vty_out(vty, "%% Power %d dB is not in the valid range%s",
2044 maxpwr_r, VTY_NEWLINE);
2045 return CMD_WARNING;
2046 }
2047 if (maxpwr_r & 1) {
2048 vty_out(vty, "%% Power %d dB is not an even value%s",
2049 maxpwr_r, VTY_NEWLINE);
2050 return CMD_WARNING;
2051 }
2052
2053 trx->max_power_red = maxpwr_r;
2054
2055 /* FIXME: make sure we update this using OML */
2056
2057 return CMD_SUCCESS;
2058}
2059
Harald Welte62868882009-08-08 16:12:58 +02002060DEFUN(cfg_trx_rsl_e1,
2061 cfg_trx_rsl_e1_cmd,
2062 "rsl e1 line E1_LINE timeslot <1-31> sub-slot (0|1|2|3|full)",
2063 "E1 interface to be used for RSL\n")
2064{
2065 struct gsm_bts_trx *trx = vty->index;
2066
2067 parse_e1_link(&trx->rsl_e1_link, argv[0], argv[1], argv[2]);
2068
2069 return CMD_SUCCESS;
2070}
2071
2072DEFUN(cfg_trx_rsl_e1_tei,
2073 cfg_trx_rsl_e1_tei_cmd,
2074 "rsl e1 tei <0-63>",
2075 "Set the TEI to be used for RSL")
2076{
2077 struct gsm_bts_trx *trx = vty->index;
2078
2079 trx->rsl_tei = atoi(argv[0]);
2080
2081 return CMD_SUCCESS;
2082}
2083
Holger Hans Peter Freyther1c8b4802009-11-11 11:54:24 +01002084DEFUN(cfg_trx_rf_locked,
2085 cfg_trx_rf_locked_cmd,
2086 "rf_locked (0|1)",
2087 "Turn off RF of the TRX.\n")
2088{
2089 int locked = atoi(argv[0]);
2090 struct gsm_bts_trx *trx = vty->index;
2091
2092 gsm_trx_lock_rf(trx, locked);
2093 return CMD_SUCCESS;
2094}
Harald Welte62868882009-08-08 16:12:58 +02002095
Harald Welte59b04682009-06-10 05:40:52 +08002096/* per TS configuration */
2097DEFUN(cfg_ts,
2098 cfg_ts_cmd,
Harald Welte62868882009-08-08 16:12:58 +02002099 "timeslot <0-7>",
Harald Welte59b04682009-06-10 05:40:52 +08002100 "Select a Timeslot to configure")
2101{
2102 int ts_nr = atoi(argv[0]);
2103 struct gsm_bts_trx *trx = vty->index;
2104 struct gsm_bts_trx_ts *ts;
2105
2106 if (ts_nr >= TRX_NR_TS) {
2107 vty_out(vty, "%% A GSM TRX only has %u Timeslots per TRX%s",
2108 TRX_NR_TS, VTY_NEWLINE);
2109 return CMD_WARNING;
2110 }
2111
2112 ts = &trx->ts[ts_nr];
2113
2114 vty->index = ts;
2115 vty->node = TS_NODE;
2116
2117 return CMD_SUCCESS;
2118}
2119
Harald Welte3ffe1b32009-08-07 00:25:23 +02002120DEFUN(cfg_ts_pchan,
2121 cfg_ts_pchan_cmd,
2122 "phys_chan_config PCHAN",
2123 "Physical Channel configuration (TCH/SDCCH/...)")
2124{
2125 struct gsm_bts_trx_ts *ts = vty->index;
2126 int pchanc;
2127
2128 pchanc = gsm_pchan_parse(argv[0]);
2129 if (pchanc < 0)
2130 return CMD_WARNING;
2131
2132 ts->pchan = pchanc;
2133
2134 return CMD_SUCCESS;
2135}
2136
Harald Weltea42a93f2010-06-14 22:26:10 +02002137#define HOPPING_STR "Configure frequency hopping\n"
2138
2139DEFUN(cfg_ts_hopping,
2140 cfg_ts_hopping_cmd,
2141 "hopping enabled (0|1)",
2142 HOPPING_STR "Enable or disable frequency hopping\n"
2143 "Disable frequency hopping\n" "Enable frequency hopping\n")
2144{
2145 struct gsm_bts_trx_ts *ts = vty->index;
Harald Welte059c1ef2010-06-14 22:47:37 +02002146 int enabled = atoi(argv[0]);
Harald Weltea42a93f2010-06-14 22:26:10 +02002147
Harald Welte059c1ef2010-06-14 22:47:37 +02002148 if (enabled && !gsm_bts_has_feature(ts->trx->bts, BTS_FEAT_HOPPING)) {
2149 vty_out(vty, "BTS model does not support hopping%s",
2150 VTY_NEWLINE);
2151 return CMD_WARNING;
2152 }
2153
2154 ts->hopping.enabled = enabled;
Harald Weltea42a93f2010-06-14 22:26:10 +02002155
2156 return CMD_SUCCESS;
2157}
2158
Harald Welte67104d12009-09-12 13:05:33 +02002159DEFUN(cfg_ts_hsn,
2160 cfg_ts_hsn_cmd,
Harald Weltea42a93f2010-06-14 22:26:10 +02002161 "hopping sequence-number <0-63>",
2162 HOPPING_STR
Harald Welte67104d12009-09-12 13:05:33 +02002163 "Which hopping sequence to use for this channel")
2164{
2165 struct gsm_bts_trx_ts *ts = vty->index;
2166
2167 ts->hopping.hsn = atoi(argv[0]);
2168
2169 return CMD_SUCCESS;
2170}
2171
2172DEFUN(cfg_ts_maio,
2173 cfg_ts_maio_cmd,
2174 "hopping maio <0-63>",
Harald Weltea42a93f2010-06-14 22:26:10 +02002175 HOPPING_STR
Harald Welte67104d12009-09-12 13:05:33 +02002176 "Which hopping MAIO to use for this channel")
2177{
2178 struct gsm_bts_trx_ts *ts = vty->index;
2179
2180 ts->hopping.maio = atoi(argv[0]);
2181
2182 return CMD_SUCCESS;
2183}
2184
2185DEFUN(cfg_ts_arfcn_add,
2186 cfg_ts_arfcn_add_cmd,
2187 "hopping arfcn add <0-1023>",
Harald Weltea42a93f2010-06-14 22:26:10 +02002188 HOPPING_STR "Configure hopping ARFCN list\n"
2189 "Add an entry to the hopping ARFCN list\n" "ARFCN\n")
Harald Welte67104d12009-09-12 13:05:33 +02002190{
2191 struct gsm_bts_trx_ts *ts = vty->index;
2192 int arfcn = atoi(argv[0]);
2193
Harald Weltea42a93f2010-06-14 22:26:10 +02002194 bitvec_set_bit_pos(&ts->hopping.arfcns, arfcn, 1);
2195
Harald Welte67104d12009-09-12 13:05:33 +02002196 return CMD_SUCCESS;
2197}
2198
2199DEFUN(cfg_ts_arfcn_del,
2200 cfg_ts_arfcn_del_cmd,
2201 "hopping arfcn del <0-1023>",
Harald Weltea42a93f2010-06-14 22:26:10 +02002202 HOPPING_STR "Configure hopping ARFCN list\n"
2203 "Delete an entry to the hopping ARFCN list\n" "ARFCN\n")
Harald Welte67104d12009-09-12 13:05:33 +02002204{
2205 struct gsm_bts_trx_ts *ts = vty->index;
2206 int arfcn = atoi(argv[0]);
2207
Harald Weltea42a93f2010-06-14 22:26:10 +02002208 bitvec_set_bit_pos(&ts->hopping.arfcns, arfcn, 0);
2209
Harald Welte67104d12009-09-12 13:05:33 +02002210 return CMD_SUCCESS;
2211}
2212
Harald Welte3ffe1b32009-08-07 00:25:23 +02002213DEFUN(cfg_ts_e1_subslot,
2214 cfg_ts_e1_subslot_cmd,
Harald Welte62868882009-08-08 16:12:58 +02002215 "e1 line E1_LINE timeslot <1-31> sub-slot (0|1|2|3|full)",
Harald Welte3ffe1b32009-08-07 00:25:23 +02002216 "E1 sub-slot connected to this on-air timeslot")
2217{
2218 struct gsm_bts_trx_ts *ts = vty->index;
2219
Harald Welte62868882009-08-08 16:12:58 +02002220 parse_e1_link(&ts->e1_link, argv[0], argv[1], argv[2]);
Harald Welte3ffe1b32009-08-07 00:25:23 +02002221
2222 return CMD_SUCCESS;
2223}
Harald Welte59b04682009-06-10 05:40:52 +08002224
Harald Weltea5b1dae2010-05-16 21:47:13 +02002225void openbsc_vty_print_statistics(struct vty *vty, struct gsm_network *net)
2226{
2227 vty_out(vty, "Channel Requests : %lu total, %lu no channel%s",
2228 counter_get(net->stats.chreq.total),
2229 counter_get(net->stats.chreq.no_channel), VTY_NEWLINE);
2230 vty_out(vty, "Channel Failures : %lu rf_failures, %lu rll failures%s",
2231 counter_get(net->stats.chan.rf_fail),
2232 counter_get(net->stats.chan.rll_err), VTY_NEWLINE);
2233 vty_out(vty, "Paging : %lu attempted, %lu complete, %lu expired%s",
2234 counter_get(net->stats.paging.attempted),
2235 counter_get(net->stats.paging.completed),
2236 counter_get(net->stats.paging.expired), VTY_NEWLINE);
2237 vty_out(vty, "BTS failures : %lu OML, %lu RSL%s",
2238 counter_get(net->stats.bts.oml_fail),
2239 counter_get(net->stats.bts.rsl_fail), VTY_NEWLINE);
2240}
2241
Harald Welte682ee5f2010-05-16 22:02:16 +02002242DEFUN(logging_fltr_imsi,
2243 logging_fltr_imsi_cmd,
2244 "logging filter imsi IMSI",
2245 LOGGING_STR FILTER_STR
2246 "Filter log messages by IMSI\n" "IMSI to be used as filter\n")
2247{
2248 struct telnet_connection *conn;
2249
2250 conn = (struct telnet_connection *) vty->priv;
2251 if (!conn->dbg) {
2252 vty_out(vty, "Logging was not enabled.%s", VTY_NEWLINE);
2253 return CMD_WARNING;
2254 }
2255
2256 log_set_imsi_filter(conn->dbg, argv[0]);
2257 return CMD_SUCCESS;
2258}
2259
Harald Welte40152872010-05-16 20:52:23 +02002260extern int bsc_vty_init_extra(void);
Harald Welte10c29f62010-05-16 19:20:24 +02002261extern const char *openbsc_copyright;
Holger Hans Peter Freytherc48a2a12010-04-10 00:08:28 +02002262
Harald Welte40152872010-05-16 20:52:23 +02002263int bsc_vty_init(void)
Harald Welte59b04682009-06-10 05:40:52 +08002264{
Harald Welte7bc28f62010-05-12 16:10:35 +00002265 install_element_ve(&show_net_cmd);
2266 install_element_ve(&show_bts_cmd);
2267 install_element_ve(&show_trx_cmd);
2268 install_element_ve(&show_ts_cmd);
2269 install_element_ve(&show_lchan_cmd);
Holger Hans Peter Freythere959b4e2010-05-14 02:08:49 +08002270 install_element_ve(&show_lchan_summary_cmd);
Harald Welte682ee5f2010-05-16 22:02:16 +02002271 install_element_ve(&logging_fltr_imsi_cmd);
Harald Welte59b04682009-06-10 05:40:52 +08002272
Harald Welte7bc28f62010-05-12 16:10:35 +00002273 install_element_ve(&show_e1drv_cmd);
2274 install_element_ve(&show_e1line_cmd);
2275 install_element_ve(&show_e1ts_cmd);
Harald Welte59b04682009-06-10 05:40:52 +08002276
Harald Welte7bc28f62010-05-12 16:10:35 +00002277 install_element_ve(&show_paging_cmd);
Harald Welte59b04682009-06-10 05:40:52 +08002278
Harald Welte682ee5f2010-05-16 22:02:16 +02002279 logging_vty_add_cmds();
Holger Hans Peter Freytherc8d862e2009-12-22 22:32:51 +01002280
Harald Weltee87eb462009-08-07 13:29:14 +02002281 install_element(CONFIG_NODE, &cfg_net_cmd);
2282 install_node(&net_node, config_write_net);
2283 install_default(GSMNET_NODE);
Harald Welte58ed1cb2010-05-14 18:59:17 +02002284 install_element(GSMNET_NODE, &ournode_exit_cmd);
Harald Weltedc82b9b2010-05-14 19:11:04 +02002285 install_element(GSMNET_NODE, &ournode_end_cmd);
Harald Welte62868882009-08-08 16:12:58 +02002286 install_element(GSMNET_NODE, &cfg_net_ncc_cmd);
Harald Weltee87eb462009-08-07 13:29:14 +02002287 install_element(GSMNET_NODE, &cfg_net_mnc_cmd);
2288 install_element(GSMNET_NODE, &cfg_net_name_short_cmd);
2289 install_element(GSMNET_NODE, &cfg_net_name_long_cmd);
Harald Welte (local)a59a27e2009-08-12 14:42:23 +02002290 install_element(GSMNET_NODE, &cfg_net_auth_policy_cmd);
Harald Welte59936d72009-11-18 20:33:19 +01002291 install_element(GSMNET_NODE, &cfg_net_reject_cause_cmd);
Harald Weltecca253a2009-08-30 15:47:06 +09002292 install_element(GSMNET_NODE, &cfg_net_encryption_cmd);
Holger Hans Peter Freyther96c89822009-11-16 17:12:38 +01002293 install_element(GSMNET_NODE, &cfg_net_neci_cmd);
Harald Welte52af1952009-12-13 10:53:12 +01002294 install_element(GSMNET_NODE, &cfg_net_rrlp_mode_cmd);
Harald Welte284ddba2009-12-14 17:49:15 +01002295 install_element(GSMNET_NODE, &cfg_net_mm_info_cmd);
Harald Welte0af9c9f2009-12-19 21:41:52 +01002296 install_element(GSMNET_NODE, &cfg_net_handover_cmd);
Harald Weltea8062f12009-12-21 16:51:50 +01002297 install_element(GSMNET_NODE, &cfg_net_ho_win_rxlev_avg_cmd);
2298 install_element(GSMNET_NODE, &cfg_net_ho_win_rxqual_avg_cmd);
2299 install_element(GSMNET_NODE, &cfg_net_ho_win_rxlev_avg_neigh_cmd);
2300 install_element(GSMNET_NODE, &cfg_net_ho_pwr_interval_cmd);
2301 install_element(GSMNET_NODE, &cfg_net_ho_pwr_hysteresis_cmd);
2302 install_element(GSMNET_NODE, &cfg_net_ho_max_distance_cmd);
Holger Hans Peter Freyther26ba2e72009-11-21 21:18:38 +01002303 install_element(GSMNET_NODE, &cfg_net_T3101_cmd);
Holger Hans Peter Freyther89733862009-11-21 21:42:26 +01002304 install_element(GSMNET_NODE, &cfg_net_T3103_cmd);
2305 install_element(GSMNET_NODE, &cfg_net_T3105_cmd);
2306 install_element(GSMNET_NODE, &cfg_net_T3107_cmd);
2307 install_element(GSMNET_NODE, &cfg_net_T3109_cmd);
2308 install_element(GSMNET_NODE, &cfg_net_T3111_cmd);
2309 install_element(GSMNET_NODE, &cfg_net_T3113_cmd);
2310 install_element(GSMNET_NODE, &cfg_net_T3115_cmd);
2311 install_element(GSMNET_NODE, &cfg_net_T3117_cmd);
2312 install_element(GSMNET_NODE, &cfg_net_T3119_cmd);
2313 install_element(GSMNET_NODE, &cfg_net_T3141_cmd);
Holger Hans Peter Freyther21d63ff2010-09-06 09:25:48 +08002314 install_element(GSMNET_NODE, &cfg_net_dtx_cmd);
Holger Hans Peter Freytherb6b9d702010-09-06 09:41:50 +08002315 install_element(GSMNET_NODE, &cfg_net_pag_any_tch_cmd);
Harald Weltee87eb462009-08-07 13:29:14 +02002316
2317 install_element(GSMNET_NODE, &cfg_bts_cmd);
Harald Welte97ceef92009-08-06 19:06:46 +02002318 install_node(&bts_node, config_write_bts);
Harald Welte59b04682009-06-10 05:40:52 +08002319 install_default(BTS_NODE);
Harald Welte58ed1cb2010-05-14 18:59:17 +02002320 install_element(BTS_NODE, &ournode_exit_cmd);
Harald Weltedc82b9b2010-05-14 19:11:04 +02002321 install_element(BTS_NODE, &ournode_end_cmd);
Harald Welte59b04682009-06-10 05:40:52 +08002322 install_element(BTS_NODE, &cfg_bts_type_cmd);
Harald Welte8791dac2010-05-14 17:59:53 +02002323 install_element(BTS_NODE, &cfg_description_cmd);
2324 install_element(BTS_NODE, &cfg_no_description_cmd);
Harald Welte91afe4c2009-06-20 18:15:19 +02002325 install_element(BTS_NODE, &cfg_bts_band_cmd);
Holger Hans Peter Freythera098dfb2009-08-21 14:44:12 +02002326 install_element(BTS_NODE, &cfg_bts_ci_cmd);
Harald Welte59b04682009-06-10 05:40:52 +08002327 install_element(BTS_NODE, &cfg_bts_lac_cmd);
2328 install_element(BTS_NODE, &cfg_bts_tsc_cmd);
Harald Welte62868882009-08-08 16:12:58 +02002329 install_element(BTS_NODE, &cfg_bts_bsic_cmd);
Harald Welte59b04682009-06-10 05:40:52 +08002330 install_element(BTS_NODE, &cfg_bts_unit_id_cmd);
Harald Welte25572872009-10-20 00:22:00 +02002331 install_element(BTS_NODE, &cfg_bts_stream_id_cmd);
Harald Welte62868882009-08-08 16:12:58 +02002332 install_element(BTS_NODE, &cfg_bts_oml_e1_cmd);
2333 install_element(BTS_NODE, &cfg_bts_oml_e1_tei_cmd);
Harald Welte3e774612009-08-10 13:48:16 +02002334 install_element(BTS_NODE, &cfg_bts_challoc_cmd);
Sylvain Munaut8e2d8de2009-12-22 13:43:26 +01002335 install_element(BTS_NODE, &cfg_bts_rach_tx_integer_cmd);
2336 install_element(BTS_NODE, &cfg_bts_rach_max_trans_cmd);
Holger Hans Peter Freyther697ed2b2010-04-25 23:08:39 +08002337 install_element(BTS_NODE, &cfg_bts_rach_nm_b_thresh_cmd);
2338 install_element(BTS_NODE, &cfg_bts_rach_nm_ldavg_cmd);
Harald Welte (local)e19be3f2009-08-12 13:28:23 +02002339 install_element(BTS_NODE, &cfg_bts_cell_barred_cmd);
Holger Hans Peter Freyther440984b2010-05-14 00:39:19 +08002340 install_element(BTS_NODE, &cfg_bts_rach_ec_allowed_cmd);
Harald Welte (local)cbd46102009-08-13 10:14:26 +02002341 install_element(BTS_NODE, &cfg_bts_ms_max_power_cmd);
Harald Welte (local)b6ea7f72009-08-14 23:09:25 +02002342 install_element(BTS_NODE, &cfg_bts_per_loc_upd_cmd);
Harald Welteb761bf82009-12-12 18:17:25 +01002343 install_element(BTS_NODE, &cfg_bts_cell_resel_hyst_cmd);
2344 install_element(BTS_NODE, &cfg_bts_rxlev_acc_min_cmd);
Harald Weltecb20b7a2010-04-18 15:51:20 +02002345 install_element(BTS_NODE, &cfg_bts_gprs_mode_cmd);
Harald Weltea9251762010-05-11 23:50:21 +02002346 install_element(BTS_NODE, &cfg_bts_gprs_ns_timer_cmd);
Harald Welte3055e332010-03-14 15:37:43 +08002347 install_element(BTS_NODE, &cfg_bts_gprs_rac_cmd);
2348 install_element(BTS_NODE, &cfg_bts_gprs_bvci_cmd);
Harald Weltea9251762010-05-11 23:50:21 +02002349 install_element(BTS_NODE, &cfg_bts_gprs_cell_timer_cmd);
Harald Welte4a048c52010-03-22 11:48:36 +08002350 install_element(BTS_NODE, &cfg_bts_gprs_nsei_cmd);
Harald Welte3055e332010-03-14 15:37:43 +08002351 install_element(BTS_NODE, &cfg_bts_gprs_nsvci_cmd);
Harald Welte410575a2010-03-14 23:30:30 +08002352 install_element(BTS_NODE, &cfg_bts_gprs_nsvc_lport_cmd);
2353 install_element(BTS_NODE, &cfg_bts_gprs_nsvc_rport_cmd);
2354 install_element(BTS_NODE, &cfg_bts_gprs_nsvc_rip_cmd);
Harald Welted8acf142010-07-30 11:50:09 +02002355 install_element(BTS_NODE, &cfg_bts_si_mode_cmd);
2356 install_element(BTS_NODE, &cfg_bts_si_static_cmd);
Harald Welte59b04682009-06-10 05:40:52 +08002357
2358 install_element(BTS_NODE, &cfg_trx_cmd);
2359 install_node(&trx_node, dummy_config_write);
2360 install_default(TRX_NODE);
Harald Welte58ed1cb2010-05-14 18:59:17 +02002361 install_element(TRX_NODE, &ournode_exit_cmd);
Harald Weltedc82b9b2010-05-14 19:11:04 +02002362 install_element(TRX_NODE, &ournode_end_cmd);
Harald Welte59b04682009-06-10 05:40:52 +08002363 install_element(TRX_NODE, &cfg_trx_arfcn_cmd);
Harald Welte8791dac2010-05-14 17:59:53 +02002364 install_element(TRX_NODE, &cfg_description_cmd);
2365 install_element(TRX_NODE, &cfg_no_description_cmd);
Harald Welte (local)b709bfe2009-12-27 20:56:38 +01002366 install_element(TRX_NODE, &cfg_trx_nominal_power_cmd);
Harald Welte7f597bc2009-06-20 22:36:12 +02002367 install_element(TRX_NODE, &cfg_trx_max_power_red_cmd);
Harald Welte62868882009-08-08 16:12:58 +02002368 install_element(TRX_NODE, &cfg_trx_rsl_e1_cmd);
2369 install_element(TRX_NODE, &cfg_trx_rsl_e1_tei_cmd);
Holger Hans Peter Freyther1c8b4802009-11-11 11:54:24 +01002370 install_element(TRX_NODE, &cfg_trx_rf_locked_cmd);
Harald Welte59b04682009-06-10 05:40:52 +08002371
2372 install_element(TRX_NODE, &cfg_ts_cmd);
2373 install_node(&ts_node, dummy_config_write);
2374 install_default(TS_NODE);
Harald Welte58ed1cb2010-05-14 18:59:17 +02002375 install_element(TS_NODE, &ournode_exit_cmd);
Harald Weltedc82b9b2010-05-14 19:11:04 +02002376 install_element(TS_NODE, &ournode_end_cmd);
Harald Welte3ffe1b32009-08-07 00:25:23 +02002377 install_element(TS_NODE, &cfg_ts_pchan_cmd);
Harald Weltea42a93f2010-06-14 22:26:10 +02002378 install_element(TS_NODE, &cfg_ts_hopping_cmd);
Harald Welte67104d12009-09-12 13:05:33 +02002379 install_element(TS_NODE, &cfg_ts_hsn_cmd);
2380 install_element(TS_NODE, &cfg_ts_maio_cmd);
2381 install_element(TS_NODE, &cfg_ts_arfcn_add_cmd);
2382 install_element(TS_NODE, &cfg_ts_arfcn_del_cmd);
Harald Welte3ffe1b32009-08-07 00:25:23 +02002383 install_element(TS_NODE, &cfg_ts_e1_subslot_cmd);
Harald Welte59b04682009-06-10 05:40:52 +08002384
Harald Welte63b964e2010-05-31 16:40:40 +02002385 abis_nm_vty_init();
2386
Harald Welte40152872010-05-16 20:52:23 +02002387 bsc_vty_init_extra();
Harald Welte59b04682009-06-10 05:40:52 +08002388
2389 return 0;
2390}