blob: ed45afd4d132227810aaa2c09f30609d131cc7cc [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
Harald Welte0e3e88e2011-01-01 15:25:50 +01006 * it under the terms of the GNU Affero General Public License as published by
7 * the Free Software Foundation; either version 3 of the License, or
Harald Welte59b04682009-06-10 05:40:52 +08008 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
Harald Welte0e3e88e2011-01-01 15:25:50 +010013 * GNU Affero General Public License for more details.
Harald Welte59b04682009-06-10 05:40:52 +080014 *
Harald Welte0e3e88e2011-01-01 15:25:50 +010015 * You should have received a copy of the GNU Affero General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
Harald Welte59b04682009-06-10 05:40:52 +080017 *
18 */
19
20#include <stdlib.h>
21#include <unistd.h>
22#include <sys/types.h>
23
Harald Weltebd9591f2010-05-19 19:45:32 +020024#include <osmocom/vty/command.h>
25#include <osmocom/vty/buffer.h>
26#include <osmocom/vty/vty.h>
27#include <osmocom/vty/logging.h>
28#include <osmocom/vty/telnet_interface.h>
Harald Welte59b04682009-06-10 05:40:52 +080029
30#include <arpa/inet.h>
31
Harald Weltef4625b12010-02-20 16:24:02 +010032#include <osmocore/linuxlist.h>
Harald Welte59b04682009-06-10 05:40:52 +080033#include <openbsc/gsm_data.h>
Harald Welte59b04682009-06-10 05:40:52 +080034#include <openbsc/e1_input.h>
35#include <openbsc/abis_nm.h>
Harald Welte30f93fb2011-02-19 16:48:17 +010036#include <openbsc/abis_om2000.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>
Holger Hans Peter Freyther25176f12010-11-09 17:00:42 +010047#include <openbsc/paging.h>
Holger Hans Peter Freyther03f17d02010-11-15 20:29:46 +010048#include <openbsc/ipaccess.h>
Harald Welte5213e992010-12-23 13:18:07 +010049#include <openbsc/abis_rsl.h>
Holger Hans Peter Freytherd0146922011-02-24 14:19:14 +010050#include <openbsc/osmo_msc_data.h>
51#include <openbsc/osmo_bsc_rf.h>
Harald Welte59b04682009-06-10 05:40:52 +080052
Harald Welte10c29f62010-05-16 19:20:24 +020053#include "../bscconfig.h"
54
Harald Welted6b62e32010-05-12 17:19:53 +000055/* FIXME: this should go to some common file */
56static const struct value_string gprs_ns_timer_strs[] = {
Harald Weltea9251762010-05-11 23:50:21 +020057 { 0, "tns-block" },
58 { 1, "tns-block-retries" },
59 { 2, "tns-reset" },
60 { 3, "tns-reset-retries" },
61 { 4, "tns-test" },
62 { 5, "tns-alive" },
63 { 6, "tns-alive-retries" },
64 { 0, NULL }
65};
66
Harald Welted6b62e32010-05-12 17:19:53 +000067static const struct value_string gprs_bssgp_cfg_strs[] = {
Harald Weltea9251762010-05-11 23:50:21 +020068 { 0, "blocking-timer" },
69 { 1, "blocking-retries" },
70 { 2, "unblocking-retries" },
71 { 3, "reset-timer" },
72 { 4, "reset-retries" },
73 { 5, "suspend-timer" },
74 { 6, "suspend-retries" },
75 { 7, "resume-timer" },
76 { 8, "resume-retries" },
77 { 9, "capability-update-timer" },
78 { 10, "capability-update-retries" },
79 { 0, NULL }
80};
81
Harald Weltef989b782011-02-15 11:43:27 +010082static const struct value_string bts_neigh_mode_strs[] = {
83 { NL_MODE_AUTOMATIC, "automatic" },
84 { NL_MODE_MANUAL, "manual" },
85 { NL_MODE_MANUAL_SI5SEP, "manual-si5" },
86 { 0, NULL }
87};
88
Harald Weltee87eb462009-08-07 13:29:14 +020089struct cmd_node net_node = {
90 GSMNET_NODE,
91 "%s(network)#",
92 1,
93};
94
Harald Welte59b04682009-06-10 05:40:52 +080095struct cmd_node bts_node = {
96 BTS_NODE,
97 "%s(bts)#",
98 1,
99};
100
101struct cmd_node trx_node = {
102 TRX_NODE,
103 "%s(trx)#",
104 1,
105};
106
107struct cmd_node ts_node = {
108 TS_NODE,
109 "%s(ts)#",
110 1,
111};
112
Harald Welte61daf6d2010-05-27 13:39:40 +0200113extern struct gsm_network *bsc_gsmnet;
114
Harald Welte40152872010-05-16 20:52:23 +0200115struct gsm_network *gsmnet_from_vty(struct vty *v)
116{
Harald Welte61daf6d2010-05-27 13:39:40 +0200117 /* In case we read from the config file, the vty->priv cannot
118 * point to a struct telnet_connection, and thus conn->priv
119 * will not point to the gsm_network structure */
120#if 0
Harald Welte40152872010-05-16 20:52:23 +0200121 struct telnet_connection *conn = v->priv;
122 return (struct gsm_network *) conn->priv;
Harald Welte61daf6d2010-05-27 13:39:40 +0200123#else
124 return bsc_gsmnet;
125#endif
Harald Welte40152872010-05-16 20:52:23 +0200126}
127
Harald Welte59b04682009-06-10 05:40:52 +0800128static int dummy_config_write(struct vty *v)
129{
130 return CMD_SUCCESS;
131}
132
133static void net_dump_nmstate(struct vty *vty, struct gsm_nm_state *nms)
134{
135 vty_out(vty,"Oper '%s', Admin %u, Avail '%s'%s",
136 nm_opstate_name(nms->operational), nms->administrative,
137 nm_avail_name(nms->availability), VTY_NEWLINE);
138}
139
Harald Weltefe96f382009-12-22 13:09:29 +0100140static void dump_pchan_load_vty(struct vty *vty, char *prefix,
141 const struct pchan_load *pl)
142{
143 int i;
144
145 for (i = 0; i < ARRAY_SIZE(pl->pchan); i++) {
146 const struct load_counter *lc = &pl->pchan[i];
147 unsigned int percent;
148
149 if (lc->total == 0)
150 continue;
151
152 percent = (lc->used * 100) / lc->total;
153
154 vty_out(vty, "%s%20s: %3u%% (%u/%u)%s", prefix,
155 gsm_pchan_name(i), percent, lc->used, lc->total,
156 VTY_NEWLINE);
157 }
158}
159
Harald Welte59b04682009-06-10 05:40:52 +0800160static void net_dump_vty(struct vty *vty, struct gsm_network *net)
161{
Harald Weltefe96f382009-12-22 13:09:29 +0100162 struct pchan_load pl;
163
Harald Welte59b04682009-06-10 05:40:52 +0800164 vty_out(vty, "BSC is on Country Code %u, Network Code %u "
165 "and has %u BTS%s", net->country_code, net->network_code,
166 net->num_bts, VTY_NEWLINE);
167 vty_out(vty, " Long network name: '%s'%s",
168 net->name_long, VTY_NEWLINE);
169 vty_out(vty, " Short network name: '%s'%s",
170 net->name_short, VTY_NEWLINE);
Harald Welte (local)a59a27e2009-08-12 14:42:23 +0200171 vty_out(vty, " Authentication policy: %s%s",
172 gsm_auth_policy_name(net->auth_policy), VTY_NEWLINE);
Harald Welte59936d72009-11-18 20:33:19 +0100173 vty_out(vty, " Location updating reject cause: %u%s",
174 net->reject_cause, VTY_NEWLINE);
Harald Weltecca253a2009-08-30 15:47:06 +0900175 vty_out(vty, " Encryption: A5/%u%s", net->a5_encryption,
176 VTY_NEWLINE);
Holger Hans Peter Freyther96c89822009-11-16 17:12:38 +0100177 vty_out(vty, " NECI (TCH/H): %u%s", net->neci,
178 VTY_NEWLINE);
Holger Hans Peter Freytherb6b9d702010-09-06 09:41:50 +0800179 vty_out(vty, " Use TCH for Paging any: %d%s", net->pag_any_tch,
180 VTY_NEWLINE);
Harald Welte52af1952009-12-13 10:53:12 +0100181 vty_out(vty, " RRLP Mode: %s%s", rrlp_mode_name(net->rrlp.mode),
182 VTY_NEWLINE);
Harald Weltea310f3e2009-12-14 09:00:24 +0100183 vty_out(vty, " MM Info: %s%s", net->send_mm_info ? "On" : "Off",
184 VTY_NEWLINE);
Harald Welte0af9c9f2009-12-19 21:41:52 +0100185 vty_out(vty, " Handover: %s%s", net->handover.active ? "On" : "Off",
186 VTY_NEWLINE);
Harald Weltefe96f382009-12-22 13:09:29 +0100187 network_chan_load(&pl, net);
188 vty_out(vty, " Current Channel Load:%s", VTY_NEWLINE);
189 dump_pchan_load_vty(vty, " ", &pl);
Holger Hans Peter Freytherd0146922011-02-24 14:19:14 +0100190
191 /* show rf */
192 if (net->msc_data)
193 vty_out(vty, " Last RF Command: %s%s",
194 net->msc_data->rf_ctl->last_state_command,
195 VTY_NEWLINE);
Harald Welte59b04682009-06-10 05:40:52 +0800196}
197
198DEFUN(show_net, show_net_cmd, "show network",
199 SHOW_STR "Display information about a GSM NETWORK\n")
200{
Harald Welte40152872010-05-16 20:52:23 +0200201 struct gsm_network *net = gsmnet_from_vty(vty);
Harald Welte59b04682009-06-10 05:40:52 +0800202 net_dump_vty(vty, net);
203
204 return CMD_SUCCESS;
205}
206
207static void e1isl_dump_vty(struct vty *vty, struct e1inp_sign_link *e1l)
208{
209 struct e1inp_line *line;
210
211 if (!e1l) {
212 vty_out(vty, " None%s", VTY_NEWLINE);
213 return;
214 }
215
216 line = e1l->ts->line;
217
218 vty_out(vty, " E1 Line %u, Type %s: Timeslot %u, Mode %s%s",
219 line->num, line->driver->name, e1l->ts->num,
220 e1inp_signtype_name(e1l->type), VTY_NEWLINE);
221 vty_out(vty, " E1 TEI %u, SAPI %u%s",
222 e1l->tei, e1l->sapi, VTY_NEWLINE);
223}
224
225static void bts_dump_vty(struct vty *vty, struct gsm_bts *bts)
226{
Harald Weltefe96f382009-12-22 13:09:29 +0100227 struct pchan_load pl;
228
Holger Hans Peter Freythera098dfb2009-08-21 14:44:12 +0200229 vty_out(vty, "BTS %u is of %s type in band %s, has CI %u LAC %u, "
Harald Welte91afe4c2009-06-20 18:15:19 +0200230 "BSIC %u, TSC %u and %u TRX%s",
231 bts->nr, btstype2str(bts->type), gsm_band_name(bts->band),
Holger Hans Peter Freythera098dfb2009-08-21 14:44:12 +0200232 bts->cell_identity,
Holger Hans Peter Freyther71135142010-03-29 08:47:44 +0200233 bts->location_area_code, bts->bsic, bts->tsc,
Harald Welte91afe4c2009-06-20 18:15:19 +0200234 bts->num_trx, VTY_NEWLINE);
Harald Welte8791dac2010-05-14 17:59:53 +0200235 vty_out(vty, "Description: %s%s",
236 bts->description ? bts->description : "(null)", VTY_NEWLINE);
Harald Welte8e9d1792009-12-12 15:38:16 +0100237 vty_out(vty, "MS Max power: %u dBm%s", bts->ms_max_power, VTY_NEWLINE);
Harald Welteb761bf82009-12-12 18:17:25 +0100238 vty_out(vty, "Minimum Rx Level for Access: %i dBm%s",
Harald Welte8e9d1792009-12-12 15:38:16 +0100239 rxlev2dbm(bts->si_common.cell_sel_par.rxlev_acc_min),
240 VTY_NEWLINE);
241 vty_out(vty, "Cell Reselection Hysteresis: %u dBm%s",
Harald Welteb761bf82009-12-12 18:17:25 +0100242 bts->si_common.cell_sel_par.cell_resel_hyst*2, VTY_NEWLINE);
Sylvain Munaut8e2d8de2009-12-22 13:43:26 +0100243 vty_out(vty, "RACH TX-Integer: %u%s", bts->si_common.rach_control.tx_integer,
244 VTY_NEWLINE);
245 vty_out(vty, "RACH Max transmissions: %u%s",
246 rach_max_trans_raw2val(bts->si_common.rach_control.max_trans),
247 VTY_NEWLINE);
Harald Welte8c973ba2009-12-21 23:08:18 +0100248 if (bts->si_common.rach_control.cell_bar)
Harald Welte (local)e19be3f2009-08-12 13:28:23 +0200249 vty_out(vty, " CELL IS BARRED%s", VTY_NEWLINE);
Harald Welted8acf142010-07-30 11:50:09 +0200250 vty_out(vty, "System Information present: 0x%08x, static: 0x%08x%s",
251 bts->si_valid, bts->si_mode_static, VTY_NEWLINE);
Harald Welte59b04682009-06-10 05:40:52 +0800252 if (is_ipaccess_bts(bts))
Harald Welte25572872009-10-20 00:22:00 +0200253 vty_out(vty, " Unit ID: %u/%u/0, OML Stream ID 0x%02x%s",
Harald Welte59b04682009-06-10 05:40:52 +0800254 bts->ip_access.site_id, bts->ip_access.bts_id,
Harald Welte25572872009-10-20 00:22:00 +0200255 bts->oml_tei, VTY_NEWLINE);
Harald Welte59b04682009-06-10 05:40:52 +0800256 vty_out(vty, " NM State: ");
257 net_dump_nmstate(vty, &bts->nm_state);
258 vty_out(vty, " Site Mgr NM State: ");
259 net_dump_nmstate(vty, &bts->site_mgr.nm_state);
260 vty_out(vty, " Paging: FIXME pending requests, %u free slots%s",
261 bts->paging.available_slots, VTY_NEWLINE);
Holger Hans Peter Freytherb5c79c92010-11-25 16:28:45 +0100262 if (is_ipaccess_bts(bts)) {
263 vty_out(vty, " OML Link state: %s.%s",
264 bts->oml_link ? "connected" : "disconnected", VTY_NEWLINE);
265 } else {
Harald Welte25572872009-10-20 00:22:00 +0200266 vty_out(vty, " E1 Signalling Link:%s", VTY_NEWLINE);
267 e1isl_dump_vty(vty, bts->oml_link);
268 }
Holger Hans Peter Freytherb5c79c92010-11-25 16:28:45 +0100269
270 /* FIXME: chan_desc */
Harald Weltefe96f382009-12-22 13:09:29 +0100271 memset(&pl, 0, sizeof(pl));
272 bts_chan_load(&pl, bts);
273 vty_out(vty, " Current Channel Load:%s", VTY_NEWLINE);
274 dump_pchan_load_vty(vty, " ", &pl);
Harald Welte59b04682009-06-10 05:40:52 +0800275}
276
277DEFUN(show_bts, show_bts_cmd, "show bts [number]",
278 SHOW_STR "Display information about a BTS\n"
279 "BTS number")
280{
Harald Welte40152872010-05-16 20:52:23 +0200281 struct gsm_network *net = gsmnet_from_vty(vty);
Harald Welte59b04682009-06-10 05:40:52 +0800282 int bts_nr;
283
284 if (argc != 0) {
285 /* use the BTS number that the user has specified */
286 bts_nr = atoi(argv[0]);
Harald Welteda5db862010-12-24 12:24:03 +0100287 if (bts_nr >= net->num_bts) {
Harald Welte59b04682009-06-10 05:40:52 +0800288 vty_out(vty, "%% can't find BTS '%s'%s", argv[0],
289 VTY_NEWLINE);
290 return CMD_WARNING;
291 }
Harald Weltee712a5f2009-06-21 16:17:15 +0200292 bts_dump_vty(vty, gsm_bts_num(net, bts_nr));
Harald Welte59b04682009-06-10 05:40:52 +0800293 return CMD_SUCCESS;
294 }
295 /* print all BTS's */
296 for (bts_nr = 0; bts_nr < net->num_bts; bts_nr++)
Harald Weltee712a5f2009-06-21 16:17:15 +0200297 bts_dump_vty(vty, gsm_bts_num(net, bts_nr));
Harald Welte59b04682009-06-10 05:40:52 +0800298
299 return CMD_SUCCESS;
300}
301
Harald Welte62868882009-08-08 16:12:58 +0200302/* utility functions */
303static void parse_e1_link(struct gsm_e1_subslot *e1_link, const char *line,
304 const char *ts, const char *ss)
305{
306 e1_link->e1_nr = atoi(line);
307 e1_link->e1_ts = atoi(ts);
308 if (!strcmp(ss, "full"))
309 e1_link->e1_ts_ss = 255;
310 else
311 e1_link->e1_ts_ss = atoi(ss);
312}
313
314static void config_write_e1_link(struct vty *vty, struct gsm_e1_subslot *e1_link,
315 const char *prefix)
316{
317 if (!e1_link->e1_ts)
318 return;
319
320 if (e1_link->e1_ts_ss == 255)
321 vty_out(vty, "%se1 line %u timeslot %u sub-slot full%s",
322 prefix, e1_link->e1_nr, e1_link->e1_ts, VTY_NEWLINE);
323 else
324 vty_out(vty, "%se1 line %u timeslot %u sub-slot %u%s",
325 prefix, e1_link->e1_nr, e1_link->e1_ts,
326 e1_link->e1_ts_ss, VTY_NEWLINE);
327}
328
329
Harald Welte97ceef92009-08-06 19:06:46 +0200330static void config_write_ts_single(struct vty *vty, struct gsm_bts_trx_ts *ts)
331{
Harald Welte62868882009-08-08 16:12:58 +0200332 vty_out(vty, " timeslot %u%s", ts->nr, VTY_NEWLINE);
333 if (ts->pchan != GSM_PCHAN_NONE)
334 vty_out(vty, " phys_chan_config %s%s",
335 gsm_pchan_name(ts->pchan), VTY_NEWLINE);
Harald Weltea42a93f2010-06-14 22:26:10 +0200336 vty_out(vty, " hopping enabled %u%s",
337 ts->hopping.enabled, VTY_NEWLINE);
338 if (ts->hopping.enabled) {
339 unsigned int i;
340 vty_out(vty, " hopping sequence-number %u%s",
Harald Welte67104d12009-09-12 13:05:33 +0200341 ts->hopping.hsn, VTY_NEWLINE);
Harald Weltea42a93f2010-06-14 22:26:10 +0200342 vty_out(vty, " hopping maio %u%s",
Harald Welte67104d12009-09-12 13:05:33 +0200343 ts->hopping.maio, VTY_NEWLINE);
Harald Weltea42a93f2010-06-14 22:26:10 +0200344 for (i = 0; i < ts->hopping.arfcns.data_len*8; i++) {
345 if (!bitvec_get_bit_pos(&ts->hopping.arfcns, i))
346 continue;
347 vty_out(vty, " hopping arfcn add %u%s",
348 i, VTY_NEWLINE);
349 }
Harald Welteff598092010-12-24 12:07:07 +0100350 }
Harald Welte62868882009-08-08 16:12:58 +0200351 config_write_e1_link(vty, &ts->e1_link, " ");
Harald Weltec02789e2011-02-14 16:15:21 +0100352
353 if (ts->trx->bts->model->config_write_ts)
354 ts->trx->bts->model->config_write_ts(vty, ts);
Harald Welte97ceef92009-08-06 19:06:46 +0200355}
356
357static void config_write_trx_single(struct vty *vty, struct gsm_bts_trx *trx)
358{
359 int i;
360
Harald Weltee87eb462009-08-07 13:29:14 +0200361 vty_out(vty, " trx %u%s", trx->nr, VTY_NEWLINE);
Harald Welte8791dac2010-05-14 17:59:53 +0200362 if (trx->description)
363 vty_out(vty, " description %s%s", trx->description,
364 VTY_NEWLINE);
Holger Hans Peter Freyther32be2aa2010-04-17 06:42:07 +0200365 vty_out(vty, " rf_locked %u%s",
366 trx->nm_state.administrative == NM_STATE_LOCKED ? 1 : 0,
367 VTY_NEWLINE);
Harald Weltee87eb462009-08-07 13:29:14 +0200368 vty_out(vty, " arfcn %u%s", trx->arfcn, VTY_NEWLINE);
Harald Welte (local)b709bfe2009-12-27 20:56:38 +0100369 vty_out(vty, " nominal power %u%s", trx->nominal_power, VTY_NEWLINE);
Harald Weltee87eb462009-08-07 13:29:14 +0200370 vty_out(vty, " max_power_red %u%s", trx->max_power_red, VTY_NEWLINE);
Harald Welte62868882009-08-08 16:12:58 +0200371 config_write_e1_link(vty, &trx->rsl_e1_link, " rsl ");
372 vty_out(vty, " rsl e1 tei %u%s", trx->rsl_tei, VTY_NEWLINE);
Harald Welte97ceef92009-08-06 19:06:46 +0200373
Harald Weltec02789e2011-02-14 16:15:21 +0100374 if (trx->bts->model->config_write_trx)
375 trx->bts->model->config_write_trx(vty, trx);
376
Harald Welte97ceef92009-08-06 19:06:46 +0200377 for (i = 0; i < TRX_NR_TS; i++)
378 config_write_ts_single(vty, &trx->ts[i]);
379}
380
Harald Weltea9251762010-05-11 23:50:21 +0200381static void config_write_bts_gprs(struct vty *vty, struct gsm_bts *bts)
382{
383 unsigned int i;
384 vty_out(vty, " gprs mode %s%s", bts_gprs_mode_name(bts->gprs.mode),
385 VTY_NEWLINE);
386 if (bts->gprs.mode == BTS_GPRS_NONE)
387 return;
388
389 vty_out(vty, " gprs routing area %u%s", bts->gprs.rac,
390 VTY_NEWLINE);
391 vty_out(vty, " gprs cell bvci %u%s", bts->gprs.cell.bvci,
392 VTY_NEWLINE);
393 for (i = 0; i < ARRAY_SIZE(bts->gprs.cell.timer); i++)
394 vty_out(vty, " gprs cell timer %s %u%s",
395 get_value_string(gprs_bssgp_cfg_strs, i),
396 bts->gprs.cell.timer[i], VTY_NEWLINE);
397 vty_out(vty, " gprs nsei %u%s", bts->gprs.nse.nsei,
398 VTY_NEWLINE);
399 for (i = 0; i < ARRAY_SIZE(bts->gprs.nse.timer); i++)
400 vty_out(vty, " gprs ns timer %s %u%s",
401 get_value_string(gprs_ns_timer_strs, i),
402 bts->gprs.nse.timer[i], VTY_NEWLINE);
403 for (i = 0; i < ARRAY_SIZE(bts->gprs.nsvc); i++) {
404 struct gsm_bts_gprs_nsvc *nsvc =
405 &bts->gprs.nsvc[i];
406 struct in_addr ia;
407
408 ia.s_addr = htonl(nsvc->remote_ip);
409 vty_out(vty, " gprs nsvc %u nsvci %u%s", i,
410 nsvc->nsvci, VTY_NEWLINE);
411 vty_out(vty, " gprs nsvc %u local udp port %u%s", i,
412 nsvc->local_port, VTY_NEWLINE);
413 vty_out(vty, " gprs nsvc %u remote udp port %u%s", i,
414 nsvc->remote_port, VTY_NEWLINE);
415 vty_out(vty, " gprs nsvc %u remote ip %s%s", i,
416 inet_ntoa(ia), VTY_NEWLINE);
417 }
418}
419
Harald Welte97ceef92009-08-06 19:06:46 +0200420static void config_write_bts_single(struct vty *vty, struct gsm_bts *bts)
421{
422 struct gsm_bts_trx *trx;
Harald Welted8acf142010-07-30 11:50:09 +0200423 int i;
Harald Welte97ceef92009-08-06 19:06:46 +0200424
Harald Weltee87eb462009-08-07 13:29:14 +0200425 vty_out(vty, " bts %u%s", bts->nr, VTY_NEWLINE);
426 vty_out(vty, " type %s%s", btstype2str(bts->type), VTY_NEWLINE);
Harald Welte8791dac2010-05-14 17:59:53 +0200427 if (bts->description)
428 vty_out(vty, " description %s%s", bts->description, VTY_NEWLINE);
Harald Weltee87eb462009-08-07 13:29:14 +0200429 vty_out(vty, " band %s%s", gsm_band_name(bts->band), VTY_NEWLINE);
Holger Hans Peter Freyther6d82b7c2009-11-19 16:38:49 +0100430 vty_out(vty, " cell_identity %u%s", bts->cell_identity, VTY_NEWLINE);
Harald Weltee87eb462009-08-07 13:29:14 +0200431 vty_out(vty, " location_area_code %u%s", bts->location_area_code,
Harald Welte97ceef92009-08-06 19:06:46 +0200432 VTY_NEWLINE);
Harald Weltee87eb462009-08-07 13:29:14 +0200433 vty_out(vty, " training_sequence_code %u%s", bts->tsc, VTY_NEWLINE);
434 vty_out(vty, " base_station_id_code %u%s", bts->bsic, VTY_NEWLINE);
Harald Welte (local)cbd46102009-08-13 10:14:26 +0200435 vty_out(vty, " ms max power %u%s", bts->ms_max_power, VTY_NEWLINE);
Harald Welteb761bf82009-12-12 18:17:25 +0100436 vty_out(vty, " cell reselection hysteresis %u%s",
437 bts->si_common.cell_sel_par.cell_resel_hyst*2, VTY_NEWLINE);
438 vty_out(vty, " rxlev access min %u%s",
439 bts->si_common.cell_sel_par.rxlev_acc_min, VTY_NEWLINE);
Sylvain Munaut00d71462010-11-28 18:17:28 +0100440
441 if (bts->si_common.cell_ro_sel_par.present) {
442 struct gsm48_si_selection_params *sp;
443 sp = &bts->si_common.cell_ro_sel_par;
444
445 if (sp->cbq)
446 vty_out(vty, " cell bar qualify %u%s",
447 sp->cbq, VTY_NEWLINE);
448
449 if (sp->cell_resel_off)
450 vty_out(vty, " cell reselection offset %u%s",
451 sp->cell_resel_off*2, VTY_NEWLINE);
452
453 if (sp->temp_offs == 7)
454 vty_out(vty, " temporary offset infinite%s",
455 VTY_NEWLINE);
456 else if (sp->temp_offs)
457 vty_out(vty, " temporary offset %u%s",
458 sp->temp_offs*10, VTY_NEWLINE);
459
460 if (sp->penalty_time == 31)
461 vty_out(vty, " penalty time reserved%s",
462 VTY_NEWLINE);
463 else if (sp->penalty_time)
464 vty_out(vty, " penalty time %u%s",
465 (sp->penalty_time*20)+20, VTY_NEWLINE);
466 }
467
Harald Weltea54a2bb2009-12-01 18:04:30 +0530468 if (bts->si_common.chan_desc.t3212)
Harald Welte (local)b6ea7f72009-08-14 23:09:25 +0200469 vty_out(vty, " periodic location update %u%s",
Dieter Spaarb0f746d2010-10-05 21:10:55 +0200470 bts->si_common.chan_desc.t3212 * 6, VTY_NEWLINE);
Harald Welte3e774612009-08-10 13:48:16 +0200471 vty_out(vty, " channel allocator %s%s",
472 bts->chan_alloc_reverse ? "descending" : "ascending",
473 VTY_NEWLINE);
Sylvain Munaut8e2d8de2009-12-22 13:43:26 +0100474 vty_out(vty, " rach tx integer %u%s",
475 bts->si_common.rach_control.tx_integer, VTY_NEWLINE);
476 vty_out(vty, " rach max transmission %u%s",
477 rach_max_trans_raw2val(bts->si_common.rach_control.max_trans),
478 VTY_NEWLINE);
Holger Hans Peter Freyther697ed2b2010-04-25 23:08:39 +0800479
480 if (bts->rach_b_thresh != -1)
481 vty_out(vty, " rach nm busy threshold %u%s",
482 bts->rach_b_thresh, VTY_NEWLINE);
483 if (bts->rach_ldavg_slots != -1)
484 vty_out(vty, " rach nm load average %u%s",
485 bts->rach_ldavg_slots, VTY_NEWLINE);
Harald Welte8c973ba2009-12-21 23:08:18 +0100486 if (bts->si_common.rach_control.cell_bar)
Harald Welte (local)e19be3f2009-08-12 13:28:23 +0200487 vty_out(vty, " cell barred 1%s", VTY_NEWLINE);
Holger Hans Peter Freyther440984b2010-05-14 00:39:19 +0800488 if ((bts->si_common.rach_control.t2 & 0x4) == 0)
489 vty_out(vty, " rach emergency call allowed 1%s", VTY_NEWLINE);
Harald Welted8acf142010-07-30 11:50:09 +0200490 for (i = SYSINFO_TYPE_1; i < _MAX_SYSINFO_TYPE; i++) {
491 if (bts->si_mode_static & (1 << i)) {
492 vty_out(vty, " system-information %s mode static%s",
493 get_value_string(osmo_sitype_strs, i), VTY_NEWLINE);
494 vty_out(vty, " system-information %s static %s%s",
495 get_value_string(osmo_sitype_strs, i),
496 hexdump_nospc(bts->si_buf[i], sizeof(bts->si_buf[i])),
497 VTY_NEWLINE);
498 }
499 }
Harald Welte25572872009-10-20 00:22:00 +0200500 if (is_ipaccess_bts(bts)) {
Harald Weltee87eb462009-08-07 13:29:14 +0200501 vty_out(vty, " ip.access unit_id %u %u%s",
Harald Welte3ffe1b32009-08-07 00:25:23 +0200502 bts->ip_access.site_id, bts->ip_access.bts_id, VTY_NEWLINE);
Harald Welte25572872009-10-20 00:22:00 +0200503 vty_out(vty, " oml ip.access stream_id %u%s", bts->oml_tei, VTY_NEWLINE);
504 } else {
Harald Welte62868882009-08-08 16:12:58 +0200505 config_write_e1_link(vty, &bts->oml_e1_link, " oml ");
506 vty_out(vty, " oml e1 tei %u%s", bts->oml_tei, VTY_NEWLINE);
507 }
Holger Hans Peter Freyther3112f672010-09-06 10:11:25 +0800508
509 /* if we have a limit, write it */
510 if (bts->paging.free_chans_need >= 0)
511 vty_out(vty, " paging free %d%s", bts->paging.free_chans_need, VTY_NEWLINE);
512
Harald Welteca46eff2011-01-11 23:44:56 +0100513 vty_out(vty, " neighbor-list mode %s%s",
Harald Weltef989b782011-02-15 11:43:27 +0100514 get_value_string(bts_neigh_mode_strs, bts->neigh_list_manual_mode), VTY_NEWLINE);
515 if (bts->neigh_list_manual_mode != NL_MODE_AUTOMATIC) {
Harald Welteca46eff2011-01-11 23:44:56 +0100516 for (i = 0; i < 1024; i++) {
517 if (bitvec_get_bit_pos(&bts->si_common.neigh_list, i))
518 vty_out(vty, " neighbor-list add arfcn %u%s",
519 i, VTY_NEWLINE);
520 }
521 }
Harald Weltef989b782011-02-15 11:43:27 +0100522 if (bts->neigh_list_manual_mode == NL_MODE_MANUAL_SI5SEP) {
523 for (i = 0; i < 1024; i++) {
524 if (bitvec_get_bit_pos(&bts->si_common.si5_neigh_list, i))
525 vty_out(vty, " si5 neighbor-list add arfcn %u%s",
526 i, VTY_NEWLINE);
527 }
528 }
Harald Welteca46eff2011-01-11 23:44:56 +0100529
Harald Weltea9251762010-05-11 23:50:21 +0200530 config_write_bts_gprs(vty, bts);
Harald Welte97ceef92009-08-06 19:06:46 +0200531
Harald Weltec02789e2011-02-14 16:15:21 +0100532 if (bts->model->config_write_bts)
533 bts->model->config_write_bts(vty, bts);
534
Harald Welte97ceef92009-08-06 19:06:46 +0200535 llist_for_each_entry(trx, &bts->trx_list, list)
536 config_write_trx_single(vty, trx);
537}
538
539static int config_write_bts(struct vty *v)
540{
Harald Welte40152872010-05-16 20:52:23 +0200541 struct gsm_network *gsmnet = gsmnet_from_vty(v);
Harald Welte97ceef92009-08-06 19:06:46 +0200542 struct gsm_bts *bts;
543
544 llist_for_each_entry(bts, &gsmnet->bts_list, list)
545 config_write_bts_single(v, bts);
546
547 return CMD_SUCCESS;
548}
549
Harald Weltee87eb462009-08-07 13:29:14 +0200550static int config_write_net(struct vty *vty)
551{
Harald Welte40152872010-05-16 20:52:23 +0200552 struct gsm_network *gsmnet = gsmnet_from_vty(vty);
553
Harald Weltee87eb462009-08-07 13:29:14 +0200554 vty_out(vty, "network%s", VTY_NEWLINE);
Harald Welte62868882009-08-08 16:12:58 +0200555 vty_out(vty, " network country code %u%s", gsmnet->country_code, VTY_NEWLINE);
Harald Weltee87eb462009-08-07 13:29:14 +0200556 vty_out(vty, " mobile network code %u%s", gsmnet->network_code, VTY_NEWLINE);
Harald Welte62868882009-08-08 16:12:58 +0200557 vty_out(vty, " short name %s%s", gsmnet->name_short, VTY_NEWLINE);
558 vty_out(vty, " long name %s%s", gsmnet->name_long, VTY_NEWLINE);
Harald Welte (local)a59a27e2009-08-12 14:42:23 +0200559 vty_out(vty, " auth policy %s%s", gsm_auth_policy_name(gsmnet->auth_policy), VTY_NEWLINE);
Harald Welte59936d72009-11-18 20:33:19 +0100560 vty_out(vty, " location updating reject cause %u%s",
561 gsmnet->reject_cause, VTY_NEWLINE);
Harald Weltecca253a2009-08-30 15:47:06 +0900562 vty_out(vty, " encryption a5 %u%s", gsmnet->a5_encryption, VTY_NEWLINE);
Holger Hans Peter Freyther6b4f5462009-11-19 16:37:48 +0100563 vty_out(vty, " neci %u%s", gsmnet->neci, VTY_NEWLINE);
Holger Hans Peter Freytherb6b9d702010-09-06 09:41:50 +0800564 vty_out(vty, " paging any use tch %d%s", gsmnet->pag_any_tch, VTY_NEWLINE);
Harald Welte52af1952009-12-13 10:53:12 +0100565 vty_out(vty, " rrlp mode %s%s", rrlp_mode_name(gsmnet->rrlp.mode),
566 VTY_NEWLINE);
Harald Weltea310f3e2009-12-14 09:00:24 +0100567 vty_out(vty, " mm info %u%s", gsmnet->send_mm_info, VTY_NEWLINE);
Harald Welte0af9c9f2009-12-19 21:41:52 +0100568 vty_out(vty, " handover %u%s", gsmnet->handover.active, VTY_NEWLINE);
Harald Weltea8062f12009-12-21 16:51:50 +0100569 vty_out(vty, " handover window rxlev averaging %u%s",
570 gsmnet->handover.win_rxlev_avg, VTY_NEWLINE);
571 vty_out(vty, " handover window rxqual averaging %u%s",
572 gsmnet->handover.win_rxqual_avg, VTY_NEWLINE);
573 vty_out(vty, " handover window rxlev neighbor averaging %u%s",
574 gsmnet->handover.win_rxlev_avg_neigh, VTY_NEWLINE);
575 vty_out(vty, " handover power budget interval %u%s",
576 gsmnet->handover.pwr_interval, VTY_NEWLINE);
577 vty_out(vty, " handover power budget hysteresis %u%s",
578 gsmnet->handover.pwr_hysteresis, VTY_NEWLINE);
579 vty_out(vty, " handover maximum distance %u%s",
580 gsmnet->handover.max_distance, VTY_NEWLINE);
Holger Hans Peter Freyther26ba2e72009-11-21 21:18:38 +0100581 vty_out(vty, " timer t3101 %u%s", gsmnet->T3101, VTY_NEWLINE);
Holger Hans Peter Freyther89733862009-11-21 21:42:26 +0100582 vty_out(vty, " timer t3103 %u%s", gsmnet->T3103, VTY_NEWLINE);
583 vty_out(vty, " timer t3105 %u%s", gsmnet->T3105, VTY_NEWLINE);
584 vty_out(vty, " timer t3107 %u%s", gsmnet->T3107, VTY_NEWLINE);
585 vty_out(vty, " timer t3109 %u%s", gsmnet->T3109, VTY_NEWLINE);
586 vty_out(vty, " timer t3111 %u%s", gsmnet->T3111, VTY_NEWLINE);
587 vty_out(vty, " timer t3113 %u%s", gsmnet->T3113, VTY_NEWLINE);
588 vty_out(vty, " timer t3115 %u%s", gsmnet->T3115, VTY_NEWLINE);
589 vty_out(vty, " timer t3117 %u%s", gsmnet->T3117, VTY_NEWLINE);
590 vty_out(vty, " timer t3119 %u%s", gsmnet->T3119, VTY_NEWLINE);
Harald Weltea00fdd72010-12-23 14:39:29 +0100591 vty_out(vty, " timer t3122 %u%s", gsmnet->T3122, VTY_NEWLINE);
Holger Hans Peter Freyther89733862009-11-21 21:42:26 +0100592 vty_out(vty, " timer t3141 %u%s", gsmnet->T3141, VTY_NEWLINE);
Harald Weltef41bfd52010-12-15 15:34:23 +0100593 vty_out(vty, " dtx-used %u%s", gsmnet->dtx_enabled, VTY_NEWLINE);
Holger Hans Peter Freyther68b21e12010-12-22 16:26:04 +0100594 vty_out(vty, " subscriber-keep-in-ram %d%s",
595 gsmnet->keep_subscr, VTY_NEWLINE);
Harald Weltee87eb462009-08-07 13:29:14 +0200596
597 return CMD_SUCCESS;
598}
Harald Welte97ceef92009-08-06 19:06:46 +0200599
Harald Welte59b04682009-06-10 05:40:52 +0800600static void trx_dump_vty(struct vty *vty, struct gsm_bts_trx *trx)
601{
602 vty_out(vty, "TRX %u of BTS %u is on ARFCN %u%s",
603 trx->nr, trx->bts->nr, trx->arfcn, VTY_NEWLINE);
Harald Welte8791dac2010-05-14 17:59:53 +0200604 vty_out(vty, "Description: %s%s",
605 trx->description ? trx->description : "(null)", VTY_NEWLINE);
Harald Welte91afe4c2009-06-20 18:15:19 +0200606 vty_out(vty, " RF Nominal Power: %d dBm, reduced by %u dB, "
Harald Welte62868882009-08-08 16:12:58 +0200607 "resulting BS power: %d dBm%s",
Harald Welte91afe4c2009-06-20 18:15:19 +0200608 trx->nominal_power, trx->max_power_red,
Harald Welte62868882009-08-08 16:12:58 +0200609 trx->nominal_power - trx->max_power_red, VTY_NEWLINE);
Harald Welte59b04682009-06-10 05:40:52 +0800610 vty_out(vty, " NM State: ");
611 net_dump_nmstate(vty, &trx->nm_state);
612 vty_out(vty, " Baseband Transceiver NM State: ");
613 net_dump_nmstate(vty, &trx->bb_transc.nm_state);
Harald Welte25572872009-10-20 00:22:00 +0200614 if (is_ipaccess_bts(trx->bts)) {
615 vty_out(vty, " ip.access stream ID: 0x%02x%s",
616 trx->rsl_tei, VTY_NEWLINE);
617 } else {
618 vty_out(vty, " E1 Signalling Link:%s", VTY_NEWLINE);
619 e1isl_dump_vty(vty, trx->rsl_link);
620 }
Harald Welte59b04682009-06-10 05:40:52 +0800621}
622
623DEFUN(show_trx,
624 show_trx_cmd,
625 "show trx [bts_nr] [trx_nr]",
Harald Welte9e002452010-05-11 21:53:49 +0200626 SHOW_STR "Display information about a TRX\n"
627 "BTS Number\n"
628 "TRX Number\n")
Harald Welte59b04682009-06-10 05:40:52 +0800629{
Harald Welte40152872010-05-16 20:52:23 +0200630 struct gsm_network *net = gsmnet_from_vty(vty);
Harald Welte59b04682009-06-10 05:40:52 +0800631 struct gsm_bts *bts = NULL;
632 struct gsm_bts_trx *trx;
633 int bts_nr, trx_nr;
634
635 if (argc >= 1) {
636 /* use the BTS number that the user has specified */
637 bts_nr = atoi(argv[0]);
638 if (bts_nr >= net->num_bts) {
639 vty_out(vty, "%% can't find BTS '%s'%s", argv[0],
640 VTY_NEWLINE);
641 return CMD_WARNING;
642 }
Harald Weltee712a5f2009-06-21 16:17:15 +0200643 bts = gsm_bts_num(net, bts_nr);
Harald Welte59b04682009-06-10 05:40:52 +0800644 }
645 if (argc >= 2) {
646 trx_nr = atoi(argv[1]);
647 if (trx_nr >= bts->num_trx) {
648 vty_out(vty, "%% can't find TRX '%s'%s", argv[1],
649 VTY_NEWLINE);
650 return CMD_WARNING;
651 }
Harald Weltee712a5f2009-06-21 16:17:15 +0200652 trx = gsm_bts_trx_num(bts, trx_nr);
Harald Welte59b04682009-06-10 05:40:52 +0800653 trx_dump_vty(vty, trx);
654 return CMD_SUCCESS;
655 }
656 if (bts) {
657 /* print all TRX in this BTS */
658 for (trx_nr = 0; trx_nr < bts->num_trx; trx_nr++) {
Harald Weltee712a5f2009-06-21 16:17:15 +0200659 trx = gsm_bts_trx_num(bts, trx_nr);
Harald Welte59b04682009-06-10 05:40:52 +0800660 trx_dump_vty(vty, trx);
661 }
662 return CMD_SUCCESS;
663 }
664
665 for (bts_nr = 0; bts_nr < net->num_bts; bts_nr++) {
Harald Weltee712a5f2009-06-21 16:17:15 +0200666 bts = gsm_bts_num(net, bts_nr);
Harald Welte59b04682009-06-10 05:40:52 +0800667 for (trx_nr = 0; trx_nr < bts->num_trx; trx_nr++) {
Harald Weltee712a5f2009-06-21 16:17:15 +0200668 trx = gsm_bts_trx_num(bts, trx_nr);
Harald Welte59b04682009-06-10 05:40:52 +0800669 trx_dump_vty(vty, trx);
670 }
671 }
672
673 return CMD_SUCCESS;
674}
675
Harald Welte97ceef92009-08-06 19:06:46 +0200676
Harald Welte59b04682009-06-10 05:40:52 +0800677static void ts_dump_vty(struct vty *vty, struct gsm_bts_trx_ts *ts)
678{
Harald Welte98d2bb82010-12-24 12:14:52 +0100679 vty_out(vty, "BTS %u, TRX %u, Timeslot %u, phys cfg %s",
Harald Weltee3bd0c02010-12-24 12:12:10 +0100680 ts->trx->bts->nr, ts->trx->nr, ts->nr,
Harald Welte98d2bb82010-12-24 12:14:52 +0100681 gsm_pchan_name(ts->pchan));
682 if (ts->pchan == GSM_PCHAN_TCH_F_PDCH)
Harald Welte81c2ed32010-12-24 12:26:13 +0100683 vty_out(vty, " (%s mode)",
Harald Welte98d2bb82010-12-24 12:14:52 +0100684 ts->flags & TS_F_PDCH_MODE ? "PDCH" : "TCH/F");
685 vty_out(vty, "%s", VTY_NEWLINE);
Harald Welte59b04682009-06-10 05:40:52 +0800686 vty_out(vty, " NM State: ");
687 net_dump_nmstate(vty, &ts->nm_state);
Harald Welte87504212009-12-02 01:56:49 +0530688 if (!is_ipaccess_bts(ts->trx->bts))
Harald Welte59b04682009-06-10 05:40:52 +0800689 vty_out(vty, " E1 Line %u, Timeslot %u, Subslot %u%s",
690 ts->e1_link.e1_nr, ts->e1_link.e1_ts,
691 ts->e1_link.e1_ts_ss, VTY_NEWLINE);
Harald Welte59b04682009-06-10 05:40:52 +0800692}
693
694DEFUN(show_ts,
695 show_ts_cmd,
696 "show timeslot [bts_nr] [trx_nr] [ts_nr]",
Harald Welte9e002452010-05-11 21:53:49 +0200697 SHOW_STR "Display information about a TS\n"
698 "BTS Number\n" "TRX Number\n" "Timeslot Number\n")
Harald Welte59b04682009-06-10 05:40:52 +0800699{
Harald Welte40152872010-05-16 20:52:23 +0200700 struct gsm_network *net = gsmnet_from_vty(vty);
Harald Welte06868382010-12-24 12:05:03 +0100701 struct gsm_bts *bts = NULL;
702 struct gsm_bts_trx *trx = NULL;
703 struct gsm_bts_trx_ts *ts = NULL;
Harald Welte59b04682009-06-10 05:40:52 +0800704 int bts_nr, trx_nr, ts_nr;
705
706 if (argc >= 1) {
707 /* use the BTS number that the user has specified */
708 bts_nr = atoi(argv[0]);
709 if (bts_nr >= net->num_bts) {
710 vty_out(vty, "%% can't find BTS '%s'%s", argv[0],
711 VTY_NEWLINE);
712 return CMD_WARNING;
713 }
Harald Weltee712a5f2009-06-21 16:17:15 +0200714 bts = gsm_bts_num(net, bts_nr);
Harald Welte59b04682009-06-10 05:40:52 +0800715 }
716 if (argc >= 2) {
717 trx_nr = atoi(argv[1]);
718 if (trx_nr >= bts->num_trx) {
719 vty_out(vty, "%% can't find TRX '%s'%s", argv[1],
720 VTY_NEWLINE);
721 return CMD_WARNING;
722 }
Harald Weltee712a5f2009-06-21 16:17:15 +0200723 trx = gsm_bts_trx_num(bts, trx_nr);
Harald Welte59b04682009-06-10 05:40:52 +0800724 }
725 if (argc >= 3) {
726 ts_nr = atoi(argv[2]);
727 if (ts_nr >= TRX_NR_TS) {
728 vty_out(vty, "%% can't find TS '%s'%s", argv[2],
729 VTY_NEWLINE);
730 return CMD_WARNING;
731 }
Harald Welte06868382010-12-24 12:05:03 +0100732 /* Fully Specified: print and exit */
Harald Welte59b04682009-06-10 05:40:52 +0800733 ts = &trx->ts[ts_nr];
734 ts_dump_vty(vty, ts);
735 return CMD_SUCCESS;
736 }
Harald Welte06868382010-12-24 12:05:03 +0100737
738 if (bts && trx) {
739 /* Iterate over all TS in this TRX */
740 for (ts_nr = 0; ts_nr < TRX_NR_TS; ts_nr++) {
741 ts = &trx->ts[ts_nr];
742 ts_dump_vty(vty, ts);
743 }
744 } else if (bts) {
745 /* Iterate over all TRX in this BTS, TS in each TRX */
Harald Welte59b04682009-06-10 05:40:52 +0800746 for (trx_nr = 0; trx_nr < bts->num_trx; trx_nr++) {
Harald Weltee712a5f2009-06-21 16:17:15 +0200747 trx = gsm_bts_trx_num(bts, trx_nr);
Harald Welte59b04682009-06-10 05:40:52 +0800748 for (ts_nr = 0; ts_nr < TRX_NR_TS; ts_nr++) {
749 ts = &trx->ts[ts_nr];
750 ts_dump_vty(vty, ts);
751 }
752 }
Harald Welte06868382010-12-24 12:05:03 +0100753 } else {
754 /* Iterate over all BTS, TRX in each BTS, TS in each TRX */
755 for (bts_nr = 0; bts_nr < net->num_bts; bts_nr++) {
756 bts = gsm_bts_num(net, bts_nr);
757 for (trx_nr = 0; trx_nr < bts->num_trx; trx_nr++) {
758 trx = gsm_bts_trx_num(bts, trx_nr);
759 for (ts_nr = 0; ts_nr < TRX_NR_TS; ts_nr++) {
760 ts = &trx->ts[ts_nr];
761 ts_dump_vty(vty, ts);
762 }
763 }
764 }
Harald Welte59b04682009-06-10 05:40:52 +0800765 }
766
767 return CMD_SUCCESS;
768}
769
Holger Hans Peter Freyther1dd0a1b2010-01-06 06:00:40 +0100770static void subscr_dump_vty(struct vty *vty, struct gsm_subscriber *subscr)
Harald Welte59b04682009-06-10 05:40:52 +0800771{
Harald Welte91afe4c2009-06-20 18:15:19 +0200772 vty_out(vty, " ID: %llu, Authorized: %d%s", subscr->id,
Harald Welte59b04682009-06-10 05:40:52 +0800773 subscr->authorized, VTY_NEWLINE);
774 if (subscr->name)
775 vty_out(vty, " Name: '%s'%s", subscr->name, VTY_NEWLINE);
776 if (subscr->extension)
777 vty_out(vty, " Extension: %s%s", subscr->extension,
778 VTY_NEWLINE);
779 if (subscr->imsi)
780 vty_out(vty, " IMSI: %s%s", subscr->imsi, VTY_NEWLINE);
Holger Hans Peter Freythercd8bacf2009-08-19 12:53:57 +0200781 if (subscr->tmsi != GSM_RESERVED_TMSI)
782 vty_out(vty, " TMSI: %08X%s", subscr->tmsi,
Harald Welte270c06c2009-08-15 03:24:51 +0200783 VTY_NEWLINE);
Sylvain Munaute5863a22009-12-27 19:29:28 +0100784
Harald Welte (local)02d5efa2009-08-14 20:27:16 +0200785 vty_out(vty, " Use count: %u%s", subscr->use_count, VTY_NEWLINE);
Harald Welte59b04682009-06-10 05:40:52 +0800786}
787
Harald Welte44007742009-12-22 21:43:14 +0100788static void meas_rep_dump_uni_vty(struct vty *vty,
789 struct gsm_meas_rep_unidir *mru,
790 const char *prefix,
791 const char *dir)
792{
793 vty_out(vty, "%s RXL-FULL-%s: %4d dBm, RXL-SUB-%s: %4d dBm ",
794 prefix, dir, rxlev2dbm(mru->full.rx_lev),
795 dir, rxlev2dbm(mru->sub.rx_lev));
796 vty_out(vty, "RXQ-FULL-%s: %d, RXQ-SUB-%s: %d%s",
797 dir, mru->full.rx_qual, dir, mru->sub.rx_qual,
798 VTY_NEWLINE);
799}
800
801static void meas_rep_dump_vty(struct vty *vty, struct gsm_meas_rep *mr,
802 const char *prefix)
803{
804 vty_out(vty, "%sMeasurement Report:%s", prefix, VTY_NEWLINE);
805 vty_out(vty, "%s Flags: %s%s%s%s%s", prefix,
806 mr->flags & MEAS_REP_F_UL_DTX ? "DTXu " : "",
807 mr->flags & MEAS_REP_F_DL_DTX ? "DTXd " : "",
808 mr->flags & MEAS_REP_F_FPC ? "FPC " : "",
809 mr->flags & MEAS_REP_F_DL_VALID ? " " : "DLinval ",
810 VTY_NEWLINE);
811 if (mr->flags & MEAS_REP_F_MS_TO)
812 vty_out(vty, "%s MS Timing Offset: %u%s", prefix,
813 mr->ms_timing_offset, VTY_NEWLINE);
814 if (mr->flags & MEAS_REP_F_MS_L1)
815 vty_out(vty, "%s L1 MS Power: %u dBm, Timing Advance: %u%s",
816 prefix, mr->ms_l1.pwr, mr->ms_l1.ta, VTY_NEWLINE);
817 if (mr->flags & MEAS_REP_F_DL_VALID)
818 meas_rep_dump_uni_vty(vty, &mr->dl, prefix, "dl");
819 meas_rep_dump_uni_vty(vty, &mr->ul, prefix, "ul");
820}
821
Holger Hans Peter Freyther5424e022010-05-14 02:03:16 +0800822static void lchan_dump_full_vty(struct vty *vty, struct gsm_lchan *lchan)
Harald Welte59b04682009-06-10 05:40:52 +0800823{
Harald Welte44007742009-12-22 21:43:14 +0100824 int idx;
825
Harald Weltef62dad62010-12-24 12:22:34 +0100826 vty_out(vty, "BTS %u, TRX %u, Timeslot %u, Lchan %u: Type %s%s",
827 lchan->ts->trx->bts->nr, lchan->ts->trx->nr, lchan->ts->nr,
828 lchan->nr, gsm_lchant_name(lchan->type), VTY_NEWLINE);
Holger Hans Peter Freyther6e5c50f2010-06-28 17:09:29 +0800829 vty_out(vty, " Connection: %u, State: %s%s",
830 lchan->conn ? 1: 0,
Harald Welteab2534c2009-12-29 10:52:38 +0100831 gsm_lchans_name(lchan->state), VTY_NEWLINE);
Harald Welteb761bf82009-12-12 18:17:25 +0100832 vty_out(vty, " BS Power: %u dBm, MS Power: %u dBm%s",
833 lchan->ts->trx->nominal_power - lchan->ts->trx->max_power_red
834 - lchan->bs_power*2,
835 ms_pwr_dbm(lchan->ts->trx->bts->band, lchan->ms_power),
836 VTY_NEWLINE);
Holger Hans Peter Freyther1a95fa82010-06-28 15:47:12 +0800837 if (lchan->conn && lchan->conn->subscr) {
Harald Welte59b04682009-06-10 05:40:52 +0800838 vty_out(vty, " Subscriber:%s", VTY_NEWLINE);
Holger Hans Peter Freyther1a95fa82010-06-28 15:47:12 +0800839 subscr_dump_vty(vty, lchan->conn->subscr);
Harald Welte59b04682009-06-10 05:40:52 +0800840 } else
841 vty_out(vty, " No Subscriber%s", VTY_NEWLINE);
Harald Welte87504212009-12-02 01:56:49 +0530842 if (is_ipaccess_bts(lchan->ts->trx->bts)) {
843 struct in_addr ia;
Holger Hans Peter Freythercec1ec52010-04-07 15:39:16 +0200844 ia.s_addr = htonl(lchan->abis_ip.bound_ip);
Harald Welte87504212009-12-02 01:56:49 +0530845 vty_out(vty, " Bound IP: %s Port %u RTP_TYPE2=%u CONN_ID=%u%s",
846 inet_ntoa(ia), lchan->abis_ip.bound_port,
847 lchan->abis_ip.rtp_payload2, lchan->abis_ip.conn_id,
848 VTY_NEWLINE);
849 }
Harald Welte44007742009-12-22 21:43:14 +0100850
851 /* we want to report the last measurement report */
852 idx = calc_initial_idx(ARRAY_SIZE(lchan->meas_rep),
853 lchan->meas_rep_idx, 1);
854 meas_rep_dump_vty(vty, &lchan->meas_rep[idx], " ");
Harald Welte59b04682009-06-10 05:40:52 +0800855}
856
Holger Hans Peter Freythere959b4e2010-05-14 02:08:49 +0800857static void lchan_dump_short_vty(struct vty *vty, struct gsm_lchan *lchan)
858{
Holger Hans Peter Freythercf13a922010-05-14 01:57:02 +0800859 struct gsm_meas_rep *mr;
860 int idx;
861
862 /* we want to report the last measurement report */
863 idx = calc_initial_idx(ARRAY_SIZE(lchan->meas_rep),
864 lchan->meas_rep_idx, 1);
865 mr = &lchan->meas_rep[idx];
866
Harald Weltef62dad62010-12-24 12:22:34 +0100867 vty_out(vty, "BTS %u, TRX %u, Timeslot %u, Lchan %u, Type %s - "
868 "L1 MS Power: %u dBm RXL-FULL-dl: %4d dBm RXL-FULL-ul: %4d dBm%s",
869 lchan->ts->trx->bts->nr, lchan->ts->trx->nr, lchan->ts->nr,
Harald Welte81c2ed32010-12-24 12:26:13 +0100870 lchan->nr, gsm_lchant_name(lchan->type), mr->ms_l1.pwr,
Holger Hans Peter Freythercf13a922010-05-14 01:57:02 +0800871 rxlev2dbm(mr->dl.full.rx_lev),
872 rxlev2dbm(mr->ul.full.rx_lev),
Holger Hans Peter Freythere959b4e2010-05-14 02:08:49 +0800873 VTY_NEWLINE);
874}
875
Holger Hans Peter Freyther5424e022010-05-14 02:03:16 +0800876static int lchan_summary(struct vty *vty, int argc, const char **argv,
877 void (*dump_cb)(struct vty *, struct gsm_lchan *))
Harald Welte59b04682009-06-10 05:40:52 +0800878{
Harald Welte40152872010-05-16 20:52:23 +0200879 struct gsm_network *net = gsmnet_from_vty(vty);
Harald Welte59b04682009-06-10 05:40:52 +0800880 struct gsm_bts *bts;
881 struct gsm_bts_trx *trx;
882 struct gsm_bts_trx_ts *ts;
883 struct gsm_lchan *lchan;
884 int bts_nr, trx_nr, ts_nr, lchan_nr;
885
886 if (argc >= 1) {
887 /* use the BTS number that the user has specified */
888 bts_nr = atoi(argv[0]);
889 if (bts_nr >= net->num_bts) {
890 vty_out(vty, "%% can't find BTS %s%s", argv[0],
891 VTY_NEWLINE);
892 return CMD_WARNING;
893 }
Harald Weltee712a5f2009-06-21 16:17:15 +0200894 bts = gsm_bts_num(net, bts_nr);
Harald Welte59b04682009-06-10 05:40:52 +0800895 }
896 if (argc >= 2) {
897 trx_nr = atoi(argv[1]);
898 if (trx_nr >= bts->num_trx) {
899 vty_out(vty, "%% can't find TRX %s%s", argv[1],
900 VTY_NEWLINE);
901 return CMD_WARNING;
902 }
Harald Weltee712a5f2009-06-21 16:17:15 +0200903 trx = gsm_bts_trx_num(bts, trx_nr);
Harald Welte59b04682009-06-10 05:40:52 +0800904 }
905 if (argc >= 3) {
906 ts_nr = atoi(argv[2]);
907 if (ts_nr >= TRX_NR_TS) {
908 vty_out(vty, "%% can't find TS %s%s", argv[2],
909 VTY_NEWLINE);
910 return CMD_WARNING;
911 }
912 ts = &trx->ts[ts_nr];
913 }
914 if (argc >= 4) {
915 lchan_nr = atoi(argv[3]);
916 if (lchan_nr >= TS_MAX_LCHAN) {
917 vty_out(vty, "%% can't find LCHAN %s%s", argv[3],
918 VTY_NEWLINE);
919 return CMD_WARNING;
920 }
921 lchan = &ts->lchan[lchan_nr];
Holger Hans Peter Freyther5424e022010-05-14 02:03:16 +0800922 dump_cb(vty, lchan);
Harald Welte59b04682009-06-10 05:40:52 +0800923 return CMD_SUCCESS;
924 }
925 for (bts_nr = 0; bts_nr < net->num_bts; bts_nr++) {
Harald Weltee712a5f2009-06-21 16:17:15 +0200926 bts = gsm_bts_num(net, bts_nr);
Harald Welte59b04682009-06-10 05:40:52 +0800927 for (trx_nr = 0; trx_nr < bts->num_trx; trx_nr++) {
Harald Weltee712a5f2009-06-21 16:17:15 +0200928 trx = gsm_bts_trx_num(bts, trx_nr);
Harald Welte59b04682009-06-10 05:40:52 +0800929 for (ts_nr = 0; ts_nr < TRX_NR_TS; ts_nr++) {
930 ts = &trx->ts[ts_nr];
931 for (lchan_nr = 0; lchan_nr < TS_MAX_LCHAN;
932 lchan_nr++) {
933 lchan = &ts->lchan[lchan_nr];
934 if (lchan->type == GSM_LCHAN_NONE)
935 continue;
Holger Hans Peter Freyther5424e022010-05-14 02:03:16 +0800936 dump_cb(vty, lchan);
Harald Welte59b04682009-06-10 05:40:52 +0800937 }
938 }
939 }
940 }
941
942 return CMD_SUCCESS;
943}
944
Holger Hans Peter Freyther5424e022010-05-14 02:03:16 +0800945
946DEFUN(show_lchan,
947 show_lchan_cmd,
948 "show lchan [bts_nr] [trx_nr] [ts_nr] [lchan_nr]",
949 SHOW_STR "Display information about a logical channel\n"
950 "BTS Number\n" "TRX Number\n" "Timeslot Number\n"
951 "Logical Channel Number\n")
952
953{
954 return lchan_summary(vty, argc, argv, lchan_dump_full_vty);
955}
956
Holger Hans Peter Freythere959b4e2010-05-14 02:08:49 +0800957DEFUN(show_lchan_summary,
958 show_lchan_summary_cmd,
959 "show lchan summary [bts_nr] [trx_nr] [ts_nr] [lchan_nr]",
960 SHOW_STR "Display information about a logical channel\n"
961 "BTS Number\n" "TRX Number\n" "Timeslot Number\n"
962 "Logical Channel Number\n")
963{
964 return lchan_summary(vty, argc, argv, lchan_dump_short_vty);
965}
966
Harald Welte59b04682009-06-10 05:40:52 +0800967static void e1drv_dump_vty(struct vty *vty, struct e1inp_driver *drv)
968{
969 vty_out(vty, "E1 Input Driver %s%s", drv->name, VTY_NEWLINE);
970}
971
972DEFUN(show_e1drv,
973 show_e1drv_cmd,
974 "show e1_driver",
975 SHOW_STR "Display information about available E1 drivers\n")
976{
977 struct e1inp_driver *drv;
978
979 llist_for_each_entry(drv, &e1inp_driver_list, list)
980 e1drv_dump_vty(vty, drv);
981
982 return CMD_SUCCESS;
983}
984
985static void e1line_dump_vty(struct vty *vty, struct e1inp_line *line)
986{
987 vty_out(vty, "E1 Line Number %u, Name %s, Driver %s%s",
988 line->num, line->name ? line->name : "",
989 line->driver->name, VTY_NEWLINE);
990}
991
992DEFUN(show_e1line,
993 show_e1line_cmd,
994 "show e1_line [line_nr]",
Harald Welte9e002452010-05-11 21:53:49 +0200995 SHOW_STR "Display information about a E1 line\n"
996 "E1 Line Number\n")
Harald Welte59b04682009-06-10 05:40:52 +0800997{
998 struct e1inp_line *line;
999
1000 if (argc >= 1) {
1001 int num = atoi(argv[0]);
1002 llist_for_each_entry(line, &e1inp_line_list, list) {
1003 if (line->num == num) {
1004 e1line_dump_vty(vty, line);
1005 return CMD_SUCCESS;
1006 }
1007 }
1008 return CMD_WARNING;
1009 }
1010
1011 llist_for_each_entry(line, &e1inp_line_list, list)
1012 e1line_dump_vty(vty, line);
1013
1014 return CMD_SUCCESS;
1015}
1016
1017static void e1ts_dump_vty(struct vty *vty, struct e1inp_ts *ts)
1018{
Harald Welte62868882009-08-08 16:12:58 +02001019 if (ts->type == E1INP_TS_TYPE_NONE)
1020 return;
Harald Welte59b04682009-06-10 05:40:52 +08001021 vty_out(vty, "E1 Timeslot %2u of Line %u is Type %s%s",
1022 ts->num, ts->line->num, e1inp_tstype_name(ts->type),
1023 VTY_NEWLINE);
1024}
1025
1026DEFUN(show_e1ts,
1027 show_e1ts_cmd,
1028 "show e1_timeslot [line_nr] [ts_nr]",
Harald Welte9e002452010-05-11 21:53:49 +02001029 SHOW_STR "Display information about a E1 timeslot\n"
1030 "E1 Line Number\n" "E1 Timeslot Number\n")
Harald Welte59b04682009-06-10 05:40:52 +08001031{
Harald Welte49c79562009-11-17 06:12:16 +01001032 struct e1inp_line *line = NULL;
Harald Welte59b04682009-06-10 05:40:52 +08001033 struct e1inp_ts *ts;
1034 int ts_nr;
1035
1036 if (argc == 0) {
1037 llist_for_each_entry(line, &e1inp_line_list, list) {
1038 for (ts_nr = 0; ts_nr < NUM_E1_TS; ts_nr++) {
1039 ts = &line->ts[ts_nr];
1040 e1ts_dump_vty(vty, ts);
1041 }
1042 }
1043 return CMD_SUCCESS;
1044 }
1045 if (argc >= 1) {
1046 int num = atoi(argv[0]);
1047 llist_for_each_entry(line, &e1inp_line_list, list) {
1048 if (line->num == num)
1049 break;
1050 }
1051 if (!line || line->num != num) {
1052 vty_out(vty, "E1 line %s is invalid%s",
1053 argv[0], VTY_NEWLINE);
1054 return CMD_WARNING;
1055 }
1056 }
1057 if (argc >= 2) {
1058 ts_nr = atoi(argv[1]);
1059 if (ts_nr > NUM_E1_TS) {
1060 vty_out(vty, "E1 timeslot %s is invalid%s",
1061 argv[1], VTY_NEWLINE);
1062 return CMD_WARNING;
1063 }
1064 ts = &line->ts[ts_nr];
1065 e1ts_dump_vty(vty, ts);
1066 return CMD_SUCCESS;
1067 } else {
1068 for (ts_nr = 0; ts_nr < NUM_E1_TS; ts_nr++) {
1069 ts = &line->ts[ts_nr];
1070 e1ts_dump_vty(vty, ts);
1071 }
1072 return CMD_SUCCESS;
1073 }
1074 return CMD_SUCCESS;
1075}
1076
1077static void paging_dump_vty(struct vty *vty, struct gsm_paging_request *pag)
1078{
1079 vty_out(vty, "Paging on BTS %u%s", pag->bts->nr, VTY_NEWLINE);
1080 subscr_dump_vty(vty, pag->subscr);
1081}
1082
1083static void bts_paging_dump_vty(struct vty *vty, struct gsm_bts *bts)
1084{
1085 struct gsm_paging_request *pag;
1086
1087 llist_for_each_entry(pag, &bts->paging.pending_requests, entry)
1088 paging_dump_vty(vty, pag);
1089}
1090
1091DEFUN(show_paging,
1092 show_paging_cmd,
1093 "show paging [bts_nr]",
Harald Welte9e002452010-05-11 21:53:49 +02001094 SHOW_STR "Display information about paging reuqests of a BTS\n"
1095 "BTS Number\n")
Harald Welte59b04682009-06-10 05:40:52 +08001096{
Harald Welte40152872010-05-16 20:52:23 +02001097 struct gsm_network *net = gsmnet_from_vty(vty);
Harald Welte59b04682009-06-10 05:40:52 +08001098 struct gsm_bts *bts;
1099 int bts_nr;
1100
1101 if (argc >= 1) {
1102 /* use the BTS number that the user has specified */
1103 bts_nr = atoi(argv[0]);
1104 if (bts_nr >= net->num_bts) {
1105 vty_out(vty, "%% can't find BTS %s%s", argv[0],
1106 VTY_NEWLINE);
1107 return CMD_WARNING;
1108 }
Harald Weltee712a5f2009-06-21 16:17:15 +02001109 bts = gsm_bts_num(net, bts_nr);
Harald Welte59b04682009-06-10 05:40:52 +08001110 bts_paging_dump_vty(vty, bts);
1111
1112 return CMD_SUCCESS;
1113 }
1114 for (bts_nr = 0; bts_nr < net->num_bts; bts_nr++) {
Harald Weltee712a5f2009-06-21 16:17:15 +02001115 bts = gsm_bts_num(net, bts_nr);
Harald Welte59b04682009-06-10 05:40:52 +08001116 bts_paging_dump_vty(vty, bts);
1117 }
1118
1119 return CMD_SUCCESS;
1120}
1121
Harald Welte9e002452010-05-11 21:53:49 +02001122#define NETWORK_STR "Configure the GSM network\n"
1123
Harald Weltee87eb462009-08-07 13:29:14 +02001124DEFUN(cfg_net,
1125 cfg_net_cmd,
Harald Welte9e002452010-05-11 21:53:49 +02001126 "network", NETWORK_STR)
Harald Weltee87eb462009-08-07 13:29:14 +02001127{
Harald Welte40152872010-05-16 20:52:23 +02001128 vty->index = gsmnet_from_vty(vty);
Harald Weltee87eb462009-08-07 13:29:14 +02001129 vty->node = GSMNET_NODE;
1130
1131 return CMD_SUCCESS;
1132}
1133
1134
1135DEFUN(cfg_net_ncc,
1136 cfg_net_ncc_cmd,
1137 "network country code <1-999>",
1138 "Set the GSM network country code")
1139{
Harald Welte40152872010-05-16 20:52:23 +02001140 struct gsm_network *gsmnet = gsmnet_from_vty(vty);
1141
Harald Weltee87eb462009-08-07 13:29:14 +02001142 gsmnet->country_code = atoi(argv[0]);
1143
1144 return CMD_SUCCESS;
1145}
1146
1147DEFUN(cfg_net_mnc,
1148 cfg_net_mnc_cmd,
1149 "mobile network code <1-999>",
1150 "Set the GSM mobile network code")
1151{
Harald Welte40152872010-05-16 20:52:23 +02001152 struct gsm_network *gsmnet = gsmnet_from_vty(vty);
1153
Harald Weltee87eb462009-08-07 13:29:14 +02001154 gsmnet->network_code = atoi(argv[0]);
1155
1156 return CMD_SUCCESS;
1157}
1158
1159DEFUN(cfg_net_name_short,
1160 cfg_net_name_short_cmd,
1161 "short name NAME",
1162 "Set the short GSM network name")
1163{
Harald Welte40152872010-05-16 20:52:23 +02001164 struct gsm_network *gsmnet = gsmnet_from_vty(vty);
1165
Holger Hans Peter Freyther7c831f62010-10-12 23:21:54 +02001166 bsc_replace_string(gsmnet, &gsmnet->name_short, argv[0]);
Harald Weltee87eb462009-08-07 13:29:14 +02001167 return CMD_SUCCESS;
1168}
1169
1170DEFUN(cfg_net_name_long,
1171 cfg_net_name_long_cmd,
1172 "long name NAME",
1173 "Set the long GSM network name")
1174{
Harald Welte40152872010-05-16 20:52:23 +02001175 struct gsm_network *gsmnet = gsmnet_from_vty(vty);
1176
Holger Hans Peter Freyther7c831f62010-10-12 23:21:54 +02001177 bsc_replace_string(gsmnet, &gsmnet->name_long, argv[0]);
Harald Weltee87eb462009-08-07 13:29:14 +02001178 return CMD_SUCCESS;
1179}
Harald Welte59b04682009-06-10 05:40:52 +08001180
Harald Welte (local)a59a27e2009-08-12 14:42:23 +02001181DEFUN(cfg_net_auth_policy,
1182 cfg_net_auth_policy_cmd,
1183 "auth policy (closed|accept-all|token)",
Harald Welte9e002452010-05-11 21:53:49 +02001184 "Authentication (not cryptographic)\n"
1185 "Set the GSM network authentication policy\n"
1186 "Require the MS to be activated in HLR\n"
1187 "Accept all MS, whether in HLR or not\n"
1188 "Use SMS-token based authentication\n")
Harald Welte (local)a59a27e2009-08-12 14:42:23 +02001189{
1190 enum gsm_auth_policy policy = gsm_auth_policy_parse(argv[0]);
Harald Welte40152872010-05-16 20:52:23 +02001191 struct gsm_network *gsmnet = gsmnet_from_vty(vty);
Harald Welte (local)a59a27e2009-08-12 14:42:23 +02001192
1193 gsmnet->auth_policy = policy;
1194
1195 return CMD_SUCCESS;
1196}
1197
Harald Welte59936d72009-11-18 20:33:19 +01001198DEFUN(cfg_net_reject_cause,
1199 cfg_net_reject_cause_cmd,
1200 "location updating reject cause <2-111>",
1201 "Set the reject cause of location updating reject\n")
1202{
Harald Welte40152872010-05-16 20:52:23 +02001203 struct gsm_network *gsmnet = gsmnet_from_vty(vty);
1204
Harald Welte59936d72009-11-18 20:33:19 +01001205 gsmnet->reject_cause = atoi(argv[0]);
1206
1207 return CMD_SUCCESS;
1208}
1209
Harald Weltecca253a2009-08-30 15:47:06 +09001210DEFUN(cfg_net_encryption,
1211 cfg_net_encryption_cmd,
1212 "encryption a5 (0|1|2)",
Harald Welte18ce31c2010-05-14 20:05:17 +02001213 "Encryption options\n"
1214 "A5 encryption\n" "A5/0: No encryption\n"
1215 "A5/1: Encryption\n" "A5/2: Export-grade Encryption\n")
Harald Weltecca253a2009-08-30 15:47:06 +09001216{
Harald Welte40152872010-05-16 20:52:23 +02001217 struct gsm_network *gsmnet = gsmnet_from_vty(vty);
1218
Andreas.Eversberg53293292009-11-17 09:55:26 +01001219 gsmnet->a5_encryption= atoi(argv[0]);
Harald Weltecca253a2009-08-30 15:47:06 +09001220
1221 return CMD_SUCCESS;
1222}
1223
Holger Hans Peter Freyther96c89822009-11-16 17:12:38 +01001224DEFUN(cfg_net_neci,
1225 cfg_net_neci_cmd,
1226 "neci (0|1)",
Harald Welte18ce31c2010-05-14 20:05:17 +02001227 "New Establish Cause Indication\n"
1228 "Don't set the NECI bit\n" "Set the NECI bit\n")
Holger Hans Peter Freyther96c89822009-11-16 17:12:38 +01001229{
Harald Welte40152872010-05-16 20:52:23 +02001230 struct gsm_network *gsmnet = gsmnet_from_vty(vty);
1231
Holger Hans Peter Freyther96c89822009-11-16 17:12:38 +01001232 gsmnet->neci = atoi(argv[0]);
Holger Hans Peter Freytherf0f37f12010-09-06 09:36:02 +08001233 gsm_net_update_ctype(gsmnet);
Holger Hans Peter Freyther96c89822009-11-16 17:12:38 +01001234 return CMD_SUCCESS;
1235}
1236
Harald Welte52af1952009-12-13 10:53:12 +01001237DEFUN(cfg_net_rrlp_mode, cfg_net_rrlp_mode_cmd,
1238 "rrlp mode (none|ms-based|ms-preferred|ass-preferred)",
Harald Welte9e002452010-05-11 21:53:49 +02001239 "Radio Resource Location Protocol\n"
1240 "Set the Radio Resource Location Protocol Mode\n"
1241 "Don't send RRLP request\n"
1242 "Request MS-based location\n"
1243 "Request any location, prefer MS-based\n"
1244 "Request any location, prefer MS-assisted\n")
Harald Welte52af1952009-12-13 10:53:12 +01001245{
Harald Welte40152872010-05-16 20:52:23 +02001246 struct gsm_network *gsmnet = gsmnet_from_vty(vty);
1247
Harald Welte52af1952009-12-13 10:53:12 +01001248 gsmnet->rrlp.mode = rrlp_mode_parse(argv[0]);
1249
1250 return CMD_SUCCESS;
1251}
1252
Harald Weltea310f3e2009-12-14 09:00:24 +01001253DEFUN(cfg_net_mm_info, cfg_net_mm_info_cmd,
1254 "mm info (0|1)",
1255 "Whether to send MM INFO after LOC UPD ACCEPT")
1256{
Harald Welte40152872010-05-16 20:52:23 +02001257 struct gsm_network *gsmnet = gsmnet_from_vty(vty);
1258
Harald Weltea310f3e2009-12-14 09:00:24 +01001259 gsmnet->send_mm_info = atoi(argv[0]);
1260
1261 return CMD_SUCCESS;
1262}
1263
Harald Welte9e002452010-05-11 21:53:49 +02001264#define HANDOVER_STR "Handover Options\n"
1265
Harald Welte0af9c9f2009-12-19 21:41:52 +01001266DEFUN(cfg_net_handover, cfg_net_handover_cmd,
1267 "handover (0|1)",
Harald Welte9e002452010-05-11 21:53:49 +02001268 HANDOVER_STR
1269 "Don't perform in-call handover\n"
1270 "Perform in-call handover\n")
Harald Welte0af9c9f2009-12-19 21:41:52 +01001271{
Holger Hans Peter Freyther3524d4b2010-01-07 16:14:38 +01001272 int enable = atoi(argv[0]);
Harald Welte40152872010-05-16 20:52:23 +02001273 struct gsm_network *gsmnet = gsmnet_from_vty(vty);
Holger Hans Peter Freyther3524d4b2010-01-07 16:14:38 +01001274
1275 if (enable && ipacc_rtp_direct) {
Harald Welteaa2c3032009-12-20 13:51:01 +01001276 vty_out(vty, "%% Cannot enable handover unless RTP Proxy mode "
1277 "is enabled by using the -P command line option%s",
1278 VTY_NEWLINE);
1279 return CMD_WARNING;
1280 }
Holger Hans Peter Freyther3524d4b2010-01-07 16:14:38 +01001281 gsmnet->handover.active = enable;
Harald Welte0af9c9f2009-12-19 21:41:52 +01001282
1283 return CMD_SUCCESS;
1284}
1285
Harald Welte9e002452010-05-11 21:53:49 +02001286#define HO_WIN_STR HANDOVER_STR "Measurement Window\n"
1287#define HO_WIN_RXLEV_STR HO_WIN_STR "Received Level Averaging\n"
1288#define HO_WIN_RXQUAL_STR HO_WIN_STR "Received Quality Averaging\n"
1289#define HO_PBUDGET_STR HANDOVER_STR "Power Budget\n"
1290
Harald Weltea8062f12009-12-21 16:51:50 +01001291DEFUN(cfg_net_ho_win_rxlev_avg, cfg_net_ho_win_rxlev_avg_cmd,
1292 "handover window rxlev averaging <1-10>",
Harald Welte9e002452010-05-11 21:53:49 +02001293 HO_WIN_RXLEV_STR
Harald Weltea8062f12009-12-21 16:51:50 +01001294 "How many RxLev measurements are used for averaging")
1295{
Harald Welte40152872010-05-16 20:52:23 +02001296 struct gsm_network *gsmnet = gsmnet_from_vty(vty);
Harald Weltea8062f12009-12-21 16:51:50 +01001297 gsmnet->handover.win_rxlev_avg = atoi(argv[0]);
1298 return CMD_SUCCESS;
1299}
1300
1301DEFUN(cfg_net_ho_win_rxqual_avg, cfg_net_ho_win_rxqual_avg_cmd,
1302 "handover window rxqual averaging <1-10>",
Harald Welte9e002452010-05-11 21:53:49 +02001303 HO_WIN_RXQUAL_STR
Harald Weltea8062f12009-12-21 16:51:50 +01001304 "How many RxQual measurements are used for averaging")
1305{
Harald Welte40152872010-05-16 20:52:23 +02001306 struct gsm_network *gsmnet = gsmnet_from_vty(vty);
Harald Weltea8062f12009-12-21 16:51:50 +01001307 gsmnet->handover.win_rxqual_avg = atoi(argv[0]);
1308 return CMD_SUCCESS;
1309}
1310
1311DEFUN(cfg_net_ho_win_rxlev_neigh_avg, cfg_net_ho_win_rxlev_avg_neigh_cmd,
1312 "handover window rxlev neighbor averaging <1-10>",
Harald Welte9e002452010-05-11 21:53:49 +02001313 HO_WIN_RXLEV_STR
Harald Weltea8062f12009-12-21 16:51:50 +01001314 "How many RxQual measurements are used for averaging")
1315{
Harald Welte40152872010-05-16 20:52:23 +02001316 struct gsm_network *gsmnet = gsmnet_from_vty(vty);
Harald Weltea8062f12009-12-21 16:51:50 +01001317 gsmnet->handover.win_rxlev_avg_neigh = atoi(argv[0]);
1318 return CMD_SUCCESS;
1319}
1320
1321DEFUN(cfg_net_ho_pwr_interval, cfg_net_ho_pwr_interval_cmd,
1322 "handover power budget interval <1-99>",
Harald Welte9e002452010-05-11 21:53:49 +02001323 HO_PBUDGET_STR
Harald Weltea8062f12009-12-21 16:51:50 +01001324 "How often to check if we have a better cell (SACCH frames)")
1325{
Harald Welte40152872010-05-16 20:52:23 +02001326 struct gsm_network *gsmnet = gsmnet_from_vty(vty);
Harald Weltea8062f12009-12-21 16:51:50 +01001327 gsmnet->handover.pwr_interval = atoi(argv[0]);
1328 return CMD_SUCCESS;
1329}
1330
1331DEFUN(cfg_net_ho_pwr_hysteresis, cfg_net_ho_pwr_hysteresis_cmd,
1332 "handover power budget hysteresis <0-999>",
Harald Welte9e002452010-05-11 21:53:49 +02001333 HO_PBUDGET_STR
Harald Weltea8062f12009-12-21 16:51:50 +01001334 "How many dB does a neighbor to be stronger to become a HO candidate")
1335{
Harald Welte40152872010-05-16 20:52:23 +02001336 struct gsm_network *gsmnet = gsmnet_from_vty(vty);
Harald Weltea8062f12009-12-21 16:51:50 +01001337 gsmnet->handover.pwr_hysteresis = atoi(argv[0]);
1338 return CMD_SUCCESS;
1339}
1340
1341DEFUN(cfg_net_ho_max_distance, cfg_net_ho_max_distance_cmd,
1342 "handover maximum distance <0-9999>",
Harald Welte9e002452010-05-11 21:53:49 +02001343 HANDOVER_STR
Harald Weltea8062f12009-12-21 16:51:50 +01001344 "How big is the maximum timing advance before HO is forced")
1345{
Harald Welte40152872010-05-16 20:52:23 +02001346 struct gsm_network *gsmnet = gsmnet_from_vty(vty);
Harald Weltea8062f12009-12-21 16:51:50 +01001347 gsmnet->handover.max_distance = atoi(argv[0]);
1348 return CMD_SUCCESS;
1349}
Harald Welte0af9c9f2009-12-19 21:41:52 +01001350
Holger Hans Peter Freytherb6b9d702010-09-06 09:41:50 +08001351DEFUN(cfg_net_pag_any_tch,
1352 cfg_net_pag_any_tch_cmd,
1353 "paging any use tch (0|1)",
1354 "Assign a TCH when receiving a Paging Any request")
1355{
Holger Hans Peter Freytherc5628882010-09-06 10:09:19 +08001356 struct gsm_network *gsmnet = gsmnet_from_vty(vty);
Holger Hans Peter Freytherb6b9d702010-09-06 09:41:50 +08001357 gsmnet->pag_any_tch = atoi(argv[0]);
1358 gsm_net_update_ctype(gsmnet);
1359 return CMD_SUCCESS;
1360}
1361
Holger Hans Peter Freyther13ae9802009-12-22 08:27:21 +01001362#define DECLARE_TIMER(number, doc) \
Holger Hans Peter Freyther26ba2e72009-11-21 21:18:38 +01001363 DEFUN(cfg_net_T##number, \
1364 cfg_net_T##number##_cmd, \
1365 "timer t" #number " <0-65535>", \
Harald Welte9e002452010-05-11 21:53:49 +02001366 "Configure GSM Timers\n" \
Holger Hans Peter Freyther13ae9802009-12-22 08:27:21 +01001367 doc) \
Holger Hans Peter Freyther26ba2e72009-11-21 21:18:38 +01001368{ \
Harald Welte40152872010-05-16 20:52:23 +02001369 struct gsm_network *gsmnet = gsmnet_from_vty(vty); \
Holger Hans Peter Freyther26ba2e72009-11-21 21:18:38 +01001370 int value = atoi(argv[0]); \
1371 \
1372 if (value < 0 || value > 65535) { \
1373 vty_out(vty, "Timer value %s out of range.%s", \
1374 argv[0], VTY_NEWLINE); \
1375 return CMD_WARNING; \
1376 } \
1377 \
1378 gsmnet->T##number = value; \
1379 return CMD_SUCCESS; \
1380}
1381
Holger Hans Peter Freyther13ae9802009-12-22 08:27:21 +01001382DECLARE_TIMER(3101, "Set the timeout value for IMMEDIATE ASSIGNMENT.")
1383DECLARE_TIMER(3103, "Set the timeout value for HANDOVER.")
1384DECLARE_TIMER(3105, "Currently not used.")
1385DECLARE_TIMER(3107, "Currently not used.")
1386DECLARE_TIMER(3109, "Currently not used.")
Holger Hans Peter Freyther4a00c062010-05-31 21:33:15 +08001387DECLARE_TIMER(3111, "Set the RSL timeout to wait before releasing the RF Channel.")
Holger Hans Peter Freyther13ae9802009-12-22 08:27:21 +01001388DECLARE_TIMER(3113, "Set the time to try paging a subscriber.")
1389DECLARE_TIMER(3115, "Currently not used.")
1390DECLARE_TIMER(3117, "Currently not used.")
1391DECLARE_TIMER(3119, "Currently not used.")
Harald Weltea00fdd72010-12-23 14:39:29 +01001392DECLARE_TIMER(3122, "Waiting time (seconds) after IMM ASS REJECT")
Holger Hans Peter Freyther13ae9802009-12-22 08:27:21 +01001393DECLARE_TIMER(3141, "Currently not used.")
Holger Hans Peter Freyther26ba2e72009-11-21 21:18:38 +01001394
Holger Hans Peter Freyther21d63ff2010-09-06 09:25:48 +08001395DEFUN(cfg_net_dtx,
1396 cfg_net_dtx_cmd,
1397 "dtx-used (0|1)",
1398 "Enable the usage of DTX.\n"
1399 "DTX is enabled/disabled")
1400{
1401 struct gsm_network *gsmnet = gsmnet_from_vty(vty);
1402 gsmnet->dtx_enabled = atoi(argv[0]);
1403 return CMD_SUCCESS;
1404}
Holger Hans Peter Freyther26ba2e72009-11-21 21:18:38 +01001405
Holger Hans Peter Freyther68b21e12010-12-22 16:26:04 +01001406DEFUN(cfg_net_subscr_keep,
1407 cfg_net_subscr_keep_cmd,
1408 "subscriber-keep-in-ram (0|1)",
1409 "Keep unused subscribers in RAM.\n"
1410 "Delete unused subscribers\n" "Keep unused subscribers\n")
1411{
1412 struct gsm_network *gsmnet = gsmnet_from_vty(vty);
1413 gsmnet->keep_subscr = atoi(argv[0]);
1414 return CMD_SUCCESS;
1415}
1416
Harald Welte59b04682009-06-10 05:40:52 +08001417/* per-BTS configuration */
1418DEFUN(cfg_bts,
1419 cfg_bts_cmd,
1420 "bts BTS_NR",
Harald Welte9e002452010-05-11 21:53:49 +02001421 "Select a BTS to configure\n"
1422 "BTS Number\n")
Harald Welte59b04682009-06-10 05:40:52 +08001423{
Harald Welte40152872010-05-16 20:52:23 +02001424 struct gsm_network *gsmnet = gsmnet_from_vty(vty);
Harald Welte59b04682009-06-10 05:40:52 +08001425 int bts_nr = atoi(argv[0]);
1426 struct gsm_bts *bts;
1427
Harald Weltee712a5f2009-06-21 16:17:15 +02001428 if (bts_nr > gsmnet->num_bts) {
1429 vty_out(vty, "%% The next unused BTS number is %u%s",
1430 gsmnet->num_bts, VTY_NEWLINE);
Harald Welte59b04682009-06-10 05:40:52 +08001431 return CMD_WARNING;
Harald Weltee712a5f2009-06-21 16:17:15 +02001432 } else if (bts_nr == gsmnet->num_bts) {
1433 /* allocate a new one */
1434 bts = gsm_bts_alloc(gsmnet, GSM_BTS_TYPE_UNKNOWN,
1435 HARDCODED_TSC, HARDCODED_BSIC);
Holger Hans Peter Freyther71135142010-03-29 08:47:44 +02001436 } else
Harald Weltee712a5f2009-06-21 16:17:15 +02001437 bts = gsm_bts_num(gsmnet, bts_nr);
1438
Daniel Willmann580085f2010-01-11 13:43:07 +01001439 if (!bts) {
1440 vty_out(vty, "%% Unable to allocate BTS %u%s",
1441 gsmnet->num_bts, VTY_NEWLINE);
Harald Weltee712a5f2009-06-21 16:17:15 +02001442 return CMD_WARNING;
Daniel Willmann580085f2010-01-11 13:43:07 +01001443 }
Harald Welte59b04682009-06-10 05:40:52 +08001444
1445 vty->index = bts;
Harald Welte8791dac2010-05-14 17:59:53 +02001446 vty->index_sub = &bts->description;
Harald Welte59b04682009-06-10 05:40:52 +08001447 vty->node = BTS_NODE;
1448
1449 return CMD_SUCCESS;
1450}
1451
1452DEFUN(cfg_bts_type,
1453 cfg_bts_type_cmd,
1454 "type TYPE",
1455 "Set the BTS type\n")
1456{
1457 struct gsm_bts *bts = vty->index;
Harald Welte59698fb2010-01-10 18:01:52 +01001458 int rc;
Harald Welte59b04682009-06-10 05:40:52 +08001459
Harald Welte59698fb2010-01-10 18:01:52 +01001460 rc = gsm_set_bts_type(bts, parse_btstype(argv[0]));
1461 if (rc < 0)
1462 return CMD_WARNING;
Harald Welte25572872009-10-20 00:22:00 +02001463
Harald Welte59b04682009-06-10 05:40:52 +08001464 return CMD_SUCCESS;
1465}
1466
Harald Welte91afe4c2009-06-20 18:15:19 +02001467DEFUN(cfg_bts_band,
1468 cfg_bts_band_cmd,
1469 "band BAND",
1470 "Set the frequency band of this BTS\n")
1471{
1472 struct gsm_bts *bts = vty->index;
Harald Welte62868882009-08-08 16:12:58 +02001473 int band = gsm_band_parse(argv[0]);
Harald Welte91afe4c2009-06-20 18:15:19 +02001474
1475 if (band < 0) {
1476 vty_out(vty, "%% BAND %d is not a valid GSM band%s",
1477 band, VTY_NEWLINE);
1478 return CMD_WARNING;
1479 }
1480
1481 bts->band = band;
1482
1483 return CMD_SUCCESS;
1484}
1485
Holger Hans Peter Freythera098dfb2009-08-21 14:44:12 +02001486DEFUN(cfg_bts_ci,
1487 cfg_bts_ci_cmd,
1488 "cell_identity <0-65535>",
1489 "Set the Cell identity of this BTS\n")
1490{
1491 struct gsm_bts *bts = vty->index;
1492 int ci = atoi(argv[0]);
1493
1494 if (ci < 0 || ci > 0xffff) {
1495 vty_out(vty, "%% CI %d is not in the valid range (0-65535)%s",
1496 ci, VTY_NEWLINE);
1497 return CMD_WARNING;
1498 }
1499 bts->cell_identity = ci;
1500
1501 return CMD_SUCCESS;
1502}
1503
Harald Welte59b04682009-06-10 05:40:52 +08001504DEFUN(cfg_bts_lac,
1505 cfg_bts_lac_cmd,
Holger Hans Peter Freyther54a22832009-09-29 14:02:33 +02001506 "location_area_code <0-65535>",
Harald Welte59b04682009-06-10 05:40:52 +08001507 "Set the Location Area Code (LAC) of this BTS\n")
1508{
1509 struct gsm_bts *bts = vty->index;
1510 int lac = atoi(argv[0]);
1511
Holger Hans Peter Freyther54a22832009-09-29 14:02:33 +02001512 if (lac < 0 || lac > 0xffff) {
1513 vty_out(vty, "%% LAC %d is not in the valid range (0-65535)%s",
Harald Welte59b04682009-06-10 05:40:52 +08001514 lac, VTY_NEWLINE);
1515 return CMD_WARNING;
1516 }
Holger Hans Peter Freyther6c6ab862009-10-01 04:07:15 +02001517
1518 if (lac == GSM_LAC_RESERVED_DETACHED || lac == GSM_LAC_RESERVED_ALL_BTS) {
1519 vty_out(vty, "%% LAC %d is reserved by GSM 04.08%s",
1520 lac, VTY_NEWLINE);
1521 return CMD_WARNING;
1522 }
1523
Harald Welte59b04682009-06-10 05:40:52 +08001524 bts->location_area_code = lac;
1525
1526 return CMD_SUCCESS;
1527}
1528
Harald Weltea54a2bb2009-12-01 18:04:30 +05301529
Harald Welte59b04682009-06-10 05:40:52 +08001530DEFUN(cfg_bts_tsc,
1531 cfg_bts_tsc_cmd,
1532 "training_sequence_code <0-255>",
1533 "Set the Training Sequence Code (TSC) of this BTS\n")
1534{
1535 struct gsm_bts *bts = vty->index;
1536 int tsc = atoi(argv[0]);
1537
1538 if (tsc < 0 || tsc > 0xff) {
1539 vty_out(vty, "%% TSC %d is not in the valid range (0-255)%s",
1540 tsc, VTY_NEWLINE);
1541 return CMD_WARNING;
1542 }
1543 bts->tsc = tsc;
1544
1545 return CMD_SUCCESS;
1546}
1547
1548DEFUN(cfg_bts_bsic,
1549 cfg_bts_bsic_cmd,
1550 "base_station_id_code <0-63>",
1551 "Set the Base Station Identity Code (BSIC) of this BTS\n")
1552{
1553 struct gsm_bts *bts = vty->index;
1554 int bsic = atoi(argv[0]);
1555
1556 if (bsic < 0 || bsic > 0x3f) {
Harald Welte62868882009-08-08 16:12:58 +02001557 vty_out(vty, "%% BSIC %d is not in the valid range (0-255)%s",
Harald Welte59b04682009-06-10 05:40:52 +08001558 bsic, VTY_NEWLINE);
1559 return CMD_WARNING;
1560 }
1561 bts->bsic = bsic;
1562
1563 return CMD_SUCCESS;
1564}
1565
1566
1567DEFUN(cfg_bts_unit_id,
1568 cfg_bts_unit_id_cmd,
Harald Weltef515aa02009-08-07 13:27:09 +02001569 "ip.access unit_id <0-65534> <0-255>",
1570 "Set the ip.access BTS Unit ID of this BTS\n")
Harald Welte59b04682009-06-10 05:40:52 +08001571{
1572 struct gsm_bts *bts = vty->index;
1573 int site_id = atoi(argv[0]);
1574 int bts_id = atoi(argv[1]);
1575
Harald Weltef515aa02009-08-07 13:27:09 +02001576 if (!is_ipaccess_bts(bts)) {
1577 vty_out(vty, "%% BTS is not of ip.access type%s", VTY_NEWLINE);
1578 return CMD_WARNING;
1579 }
1580
Harald Welte59b04682009-06-10 05:40:52 +08001581 bts->ip_access.site_id = site_id;
1582 bts->ip_access.bts_id = bts_id;
1583
1584 return CMD_SUCCESS;
1585}
1586
Harald Welte9e002452010-05-11 21:53:49 +02001587#define OML_STR "Organization & Maintenance Link\n"
1588#define IPA_STR "ip.access Specific Options\n"
1589
Harald Welte25572872009-10-20 00:22:00 +02001590DEFUN(cfg_bts_stream_id,
1591 cfg_bts_stream_id_cmd,
1592 "oml ip.access stream_id <0-255>",
Harald Welte9e002452010-05-11 21:53:49 +02001593 OML_STR IPA_STR
Harald Welte25572872009-10-20 00:22:00 +02001594 "Set the ip.access Stream ID of the OML link of this BTS\n")
1595{
1596 struct gsm_bts *bts = vty->index;
1597 int stream_id = atoi(argv[0]);
1598
1599 if (!is_ipaccess_bts(bts)) {
1600 vty_out(vty, "%% BTS is not of ip.access type%s", VTY_NEWLINE);
1601 return CMD_WARNING;
1602 }
1603
1604 bts->oml_tei = stream_id;
1605
1606 return CMD_SUCCESS;
1607}
1608
Harald Welte9e002452010-05-11 21:53:49 +02001609#define OML_E1_STR OML_STR "E1 Line\n"
Harald Welte25572872009-10-20 00:22:00 +02001610
Harald Welte62868882009-08-08 16:12:58 +02001611DEFUN(cfg_bts_oml_e1,
1612 cfg_bts_oml_e1_cmd,
1613 "oml e1 line E1_LINE timeslot <1-31> sub-slot (0|1|2|3|full)",
Harald Welte9e002452010-05-11 21:53:49 +02001614 OML_E1_STR
Harald Welte62868882009-08-08 16:12:58 +02001615 "E1 interface to be used for OML\n")
1616{
1617 struct gsm_bts *bts = vty->index;
1618
1619 parse_e1_link(&bts->oml_e1_link, argv[0], argv[1], argv[2]);
1620
1621 return CMD_SUCCESS;
1622}
1623
1624
1625DEFUN(cfg_bts_oml_e1_tei,
1626 cfg_bts_oml_e1_tei_cmd,
1627 "oml e1 tei <0-63>",
Harald Welte9e002452010-05-11 21:53:49 +02001628 OML_E1_STR
Harald Welte62868882009-08-08 16:12:58 +02001629 "Set the TEI to be used for OML")
1630{
1631 struct gsm_bts *bts = vty->index;
1632
1633 bts->oml_tei = atoi(argv[0]);
1634
1635 return CMD_SUCCESS;
1636}
1637
Harald Welte3e774612009-08-10 13:48:16 +02001638DEFUN(cfg_bts_challoc, cfg_bts_challoc_cmd,
1639 "channel allocator (ascending|descending)",
Harald Welte9e002452010-05-11 21:53:49 +02001640 "Channnel Allocator\n" "Channel Allocator\n"
1641 "Allocate Timeslots and Transceivers in ascending order\n"
1642 "Allocate Timeslots and Transceivers in descending order\n")
Harald Welte3e774612009-08-10 13:48:16 +02001643{
1644 struct gsm_bts *bts = vty->index;
1645
1646 if (!strcmp(argv[0], "ascending"))
1647 bts->chan_alloc_reverse = 0;
1648 else
1649 bts->chan_alloc_reverse = 1;
1650
1651 return CMD_SUCCESS;
1652}
1653
Harald Welte9e002452010-05-11 21:53:49 +02001654#define RACH_STR "Random Access Control Channel\n"
1655
Sylvain Munaut8e2d8de2009-12-22 13:43:26 +01001656DEFUN(cfg_bts_rach_tx_integer,
1657 cfg_bts_rach_tx_integer_cmd,
1658 "rach tx integer <0-15>",
Harald Welte9e002452010-05-11 21:53:49 +02001659 RACH_STR
Sylvain Munaut8e2d8de2009-12-22 13:43:26 +01001660 "Set the raw tx integer value in RACH Control parameters IE")
1661{
1662 struct gsm_bts *bts = vty->index;
1663 bts->si_common.rach_control.tx_integer = atoi(argv[0]) & 0xf;
1664 return CMD_SUCCESS;
1665}
1666
1667DEFUN(cfg_bts_rach_max_trans,
1668 cfg_bts_rach_max_trans_cmd,
1669 "rach max transmission (1|2|4|7)",
Harald Welte9e002452010-05-11 21:53:49 +02001670 RACH_STR
Sylvain Munaut8e2d8de2009-12-22 13:43:26 +01001671 "Set the maximum number of RACH burst transmissions")
1672{
1673 struct gsm_bts *bts = vty->index;
1674 bts->si_common.rach_control.max_trans = rach_max_trans_val2raw(atoi(argv[0]));
1675 return CMD_SUCCESS;
1676}
1677
Harald Welte9e002452010-05-11 21:53:49 +02001678#define NM_STR "Network Management\n"
1679
Holger Hans Peter Freyther697ed2b2010-04-25 23:08:39 +08001680DEFUN(cfg_bts_rach_nm_b_thresh,
1681 cfg_bts_rach_nm_b_thresh_cmd,
1682 "rach nm busy threshold <0-255>",
Harald Welte9e002452010-05-11 21:53:49 +02001683 RACH_STR NM_STR
1684 "Set the NM Busy Threshold in dB")
Holger Hans Peter Freyther697ed2b2010-04-25 23:08:39 +08001685{
1686 struct gsm_bts *bts = vty->index;
1687 bts->rach_b_thresh = atoi(argv[0]);
1688 return CMD_SUCCESS;
1689}
1690
1691DEFUN(cfg_bts_rach_nm_ldavg,
1692 cfg_bts_rach_nm_ldavg_cmd,
1693 "rach nm load average <0-65535>",
Harald Welte9e002452010-05-11 21:53:49 +02001694 RACH_STR NM_STR
1695 "Set the NM Loadaverage Slots value")
Holger Hans Peter Freyther697ed2b2010-04-25 23:08:39 +08001696{
1697 struct gsm_bts *bts = vty->index;
1698 bts->rach_ldavg_slots = atoi(argv[0]);
1699 return CMD_SUCCESS;
1700}
1701
Harald Welte (local)e19be3f2009-08-12 13:28:23 +02001702DEFUN(cfg_bts_cell_barred, cfg_bts_cell_barred_cmd,
1703 "cell barred (0|1)",
1704 "Should this cell be barred from access?")
1705{
1706 struct gsm_bts *bts = vty->index;
1707
Harald Welte8c973ba2009-12-21 23:08:18 +01001708 bts->si_common.rach_control.cell_bar = atoi(argv[0]);
Harald Welte (local)e19be3f2009-08-12 13:28:23 +02001709
1710 return CMD_SUCCESS;
1711}
1712
Holger Hans Peter Freyther440984b2010-05-14 00:39:19 +08001713DEFUN(cfg_bts_rach_ec_allowed, cfg_bts_rach_ec_allowed_cmd,
1714 "rach emergency call allowed (0|1)",
1715 "Should this cell allow emergency calls?")
1716{
1717 struct gsm_bts *bts = vty->index;
1718
1719 if (atoi(argv[0]) == 0)
1720 bts->si_common.rach_control.t2 |= 0x4;
1721 else
1722 bts->si_common.rach_control.t2 &= ~0x4;
1723
1724 return CMD_SUCCESS;
1725}
1726
Harald Welte (local)cbd46102009-08-13 10:14:26 +02001727DEFUN(cfg_bts_ms_max_power, cfg_bts_ms_max_power_cmd,
1728 "ms max power <0-40>",
1729 "Maximum transmit power of the MS")
1730{
1731 struct gsm_bts *bts = vty->index;
1732
1733 bts->ms_max_power = atoi(argv[0]);
1734
1735 return CMD_SUCCESS;
1736}
1737
Harald Welteb761bf82009-12-12 18:17:25 +01001738DEFUN(cfg_bts_cell_resel_hyst, cfg_bts_cell_resel_hyst_cmd,
1739 "cell reselection hysteresis <0-14>",
1740 "Cell Re-Selection Hysteresis in dB")
1741{
1742 struct gsm_bts *bts = vty->index;
1743
1744 bts->si_common.cell_sel_par.cell_resel_hyst = atoi(argv[0])/2;
1745
1746 return CMD_SUCCESS;
1747}
1748
1749DEFUN(cfg_bts_rxlev_acc_min, cfg_bts_rxlev_acc_min_cmd,
1750 "rxlev access min <0-63>",
1751 "Minimum RxLev needed for cell access (better than -110dBm)")
1752{
1753 struct gsm_bts *bts = vty->index;
1754
1755 bts->si_common.cell_sel_par.rxlev_acc_min = atoi(argv[0]);
1756
1757 return CMD_SUCCESS;
1758}
1759
Sylvain Munaut00d71462010-11-28 18:17:28 +01001760DEFUN(cfg_bts_cell_bar_qualify, cfg_bts_cell_bar_qualify_cmd,
1761 "cell bar qualify (0|1)",
1762 "Cell Bar Qualify")
1763{
1764 struct gsm_bts *bts = vty->index;
1765
1766 bts->si_common.cell_ro_sel_par.present = 1;
1767 bts->si_common.cell_ro_sel_par.cbq = atoi(argv[0]);
1768
1769 return CMD_SUCCESS;
1770}
1771
1772DEFUN(cfg_bts_cell_resel_ofs, cfg_bts_cell_resel_ofs_cmd,
1773 "cell reselection offset <0-126>",
1774 "Cell Re-Selection Offset in dB")
1775{
1776 struct gsm_bts *bts = vty->index;
1777
1778 bts->si_common.cell_ro_sel_par.present = 1;
1779 bts->si_common.cell_ro_sel_par.cell_resel_off = atoi(argv[0])/2;
1780
1781 return CMD_SUCCESS;
1782}
1783
1784DEFUN(cfg_bts_temp_ofs, cfg_bts_temp_ofs_cmd,
1785 "temporary offset <0-60>",
1786 "Cell selection temporary negative offset in dB")
1787{
1788 struct gsm_bts *bts = vty->index;
1789
1790 bts->si_common.cell_ro_sel_par.present = 1;
1791 bts->si_common.cell_ro_sel_par.temp_offs = atoi(argv[0])/10;
1792
1793 return CMD_SUCCESS;
1794}
1795
1796DEFUN(cfg_bts_temp_ofs_inf, cfg_bts_temp_ofs_inf_cmd,
1797 "temporary offset infinite",
1798 "Sets cell selection temporary negative offset to infinity")
1799{
1800 struct gsm_bts *bts = vty->index;
1801
1802 bts->si_common.cell_ro_sel_par.present = 1;
1803 bts->si_common.cell_ro_sel_par.temp_offs = 7;
1804
1805 return CMD_SUCCESS;
1806}
1807
1808DEFUN(cfg_bts_penalty_time, cfg_bts_penalty_time_cmd,
1809 "penalty time <20-620>",
1810 "Cell selection penalty time in seconds (by 20s increments)")
1811{
1812 struct gsm_bts *bts = vty->index;
1813
1814 bts->si_common.cell_ro_sel_par.present = 1;
1815 bts->si_common.cell_ro_sel_par.penalty_time = (atoi(argv[0])-20)/20;
1816
1817 return CMD_SUCCESS;
1818}
1819
1820DEFUN(cfg_bts_penalty_time_rsvd, cfg_bts_penalty_time_rsvd_cmd,
1821 "penalty time reserved",
1822 "Set cell selection penalty time to reserved value 31\n"
1823 "(indicate that CELL_RESELECT_OFFSET is subtracted from C2 "
1824 "and TEMPORARY_OFFSET is ignored)")
1825{
1826 struct gsm_bts *bts = vty->index;
1827
1828 bts->si_common.cell_ro_sel_par.present = 1;
1829 bts->si_common.cell_ro_sel_par.penalty_time = 31;
1830
1831 return CMD_SUCCESS;
1832}
1833
Harald Welte (local)b6ea7f72009-08-14 23:09:25 +02001834DEFUN(cfg_bts_per_loc_upd, cfg_bts_per_loc_upd_cmd,
1835 "periodic location update <0-1530>",
1836 "Periodic Location Updating Interval in Minutes")
1837{
1838 struct gsm_bts *bts = vty->index;
1839
Dieter Spaarb0f746d2010-10-05 21:10:55 +02001840 bts->si_common.chan_desc.t3212 = atoi(argv[0]) / 6;
Harald Welte (local)b6ea7f72009-08-14 23:09:25 +02001841
1842 return CMD_SUCCESS;
1843}
1844
Harald Welte9e002452010-05-11 21:53:49 +02001845#define GPRS_TEXT "GPRS Packet Network\n"
1846
Harald Welte410575a2010-03-14 23:30:30 +08001847DEFUN(cfg_bts_prs_bvci, cfg_bts_gprs_bvci_cmd,
Harald Welteb42fe342010-04-18 14:00:26 +02001848 "gprs cell bvci <2-65535>",
Harald Welte9e002452010-05-11 21:53:49 +02001849 GPRS_TEXT
1850 "GPRS Cell Settings\n"
Harald Welte3055e332010-03-14 15:37:43 +08001851 "GPRS BSSGP VC Identifier")
1852{
1853 struct gsm_bts *bts = vty->index;
1854
Harald Weltecb20b7a2010-04-18 15:51:20 +02001855 if (bts->gprs.mode == BTS_GPRS_NONE) {
Harald Weltec05a4b12010-03-14 23:56:56 +08001856 vty_out(vty, "%% GPRS not enabled on this BTS%s", VTY_NEWLINE);
1857 return CMD_WARNING;
1858 }
1859
Harald Welte3055e332010-03-14 15:37:43 +08001860 bts->gprs.cell.bvci = atoi(argv[0]);
1861
1862 return CMD_SUCCESS;
1863}
1864
Harald Welte4a048c52010-03-22 11:48:36 +08001865DEFUN(cfg_bts_gprs_nsei, cfg_bts_gprs_nsei_cmd,
1866 "gprs nsei <0-65535>",
Harald Welte9e002452010-05-11 21:53:49 +02001867 GPRS_TEXT
Harald Welte4a048c52010-03-22 11:48:36 +08001868 "GPRS NS Entity Identifier")
1869{
1870 struct gsm_bts *bts = vty->index;
1871
Harald Weltecb20b7a2010-04-18 15:51:20 +02001872 if (bts->gprs.mode == BTS_GPRS_NONE) {
Harald Welte4a048c52010-03-22 11:48:36 +08001873 vty_out(vty, "%% GPRS not enabled on this BTS%s", VTY_NEWLINE);
1874 return CMD_WARNING;
1875 }
1876
1877 bts->gprs.nse.nsei = atoi(argv[0]);
1878
1879 return CMD_SUCCESS;
1880}
1881
Harald Welte9e002452010-05-11 21:53:49 +02001882#define NSVC_TEXT "Network Service Virtual Connection (NS-VC)\n" \
1883 "NSVC Logical Number\n"
Harald Welte4a048c52010-03-22 11:48:36 +08001884
Harald Welte3055e332010-03-14 15:37:43 +08001885DEFUN(cfg_bts_gprs_nsvci, cfg_bts_gprs_nsvci_cmd,
1886 "gprs nsvc <0-1> nsvci <0-65535>",
Harald Welte9e002452010-05-11 21:53:49 +02001887 GPRS_TEXT NSVC_TEXT
1888 "NS Virtual Connection Identifier\n"
Harald Welte3055e332010-03-14 15:37:43 +08001889 "GPRS NS VC Identifier")
1890{
1891 struct gsm_bts *bts = vty->index;
1892 int idx = atoi(argv[0]);
1893
Harald Weltecb20b7a2010-04-18 15:51:20 +02001894 if (bts->gprs.mode == BTS_GPRS_NONE) {
Harald Weltec05a4b12010-03-14 23:56:56 +08001895 vty_out(vty, "%% GPRS not enabled on this BTS%s", VTY_NEWLINE);
1896 return CMD_WARNING;
1897 }
1898
Harald Welte3055e332010-03-14 15:37:43 +08001899 bts->gprs.nsvc[idx].nsvci = atoi(argv[1]);
1900
1901 return CMD_SUCCESS;
1902}
1903
Harald Welte410575a2010-03-14 23:30:30 +08001904DEFUN(cfg_bts_gprs_nsvc_lport, cfg_bts_gprs_nsvc_lport_cmd,
1905 "gprs nsvc <0-1> local udp port <0-65535>",
Harald Welte9e002452010-05-11 21:53:49 +02001906 GPRS_TEXT NSVC_TEXT
Harald Welte410575a2010-03-14 23:30:30 +08001907 "GPRS NS Local UDP Port")
1908{
1909 struct gsm_bts *bts = vty->index;
1910 int idx = atoi(argv[0]);
1911
Harald Weltecb20b7a2010-04-18 15:51:20 +02001912 if (bts->gprs.mode == BTS_GPRS_NONE) {
Harald Weltec05a4b12010-03-14 23:56:56 +08001913 vty_out(vty, "%% GPRS not enabled on this BTS%s", VTY_NEWLINE);
1914 return CMD_WARNING;
1915 }
1916
Harald Welte410575a2010-03-14 23:30:30 +08001917 bts->gprs.nsvc[idx].local_port = atoi(argv[1]);
1918
1919 return CMD_SUCCESS;
1920}
1921
1922DEFUN(cfg_bts_gprs_nsvc_rport, cfg_bts_gprs_nsvc_rport_cmd,
1923 "gprs nsvc <0-1> remote udp port <0-65535>",
Harald Welte9e002452010-05-11 21:53:49 +02001924 GPRS_TEXT NSVC_TEXT
Harald Welte410575a2010-03-14 23:30:30 +08001925 "GPRS NS Remote UDP Port")
1926{
1927 struct gsm_bts *bts = vty->index;
1928 int idx = atoi(argv[0]);
1929
Harald Weltecb20b7a2010-04-18 15:51:20 +02001930 if (bts->gprs.mode == BTS_GPRS_NONE) {
Harald Weltec05a4b12010-03-14 23:56:56 +08001931 vty_out(vty, "%% GPRS not enabled on this BTS%s", VTY_NEWLINE);
1932 return CMD_WARNING;
1933 }
1934
Harald Welte410575a2010-03-14 23:30:30 +08001935 bts->gprs.nsvc[idx].remote_port = atoi(argv[1]);
1936
1937 return CMD_SUCCESS;
1938}
1939
1940DEFUN(cfg_bts_gprs_nsvc_rip, cfg_bts_gprs_nsvc_rip_cmd,
1941 "gprs nsvc <0-1> remote ip A.B.C.D",
Harald Welte9e002452010-05-11 21:53:49 +02001942 GPRS_TEXT NSVC_TEXT
Harald Welte410575a2010-03-14 23:30:30 +08001943 "GPRS NS Remote IP Address")
1944{
1945 struct gsm_bts *bts = vty->index;
1946 int idx = atoi(argv[0]);
1947 struct in_addr ia;
1948
Harald Weltecb20b7a2010-04-18 15:51:20 +02001949 if (bts->gprs.mode == BTS_GPRS_NONE) {
Harald Weltec05a4b12010-03-14 23:56:56 +08001950 vty_out(vty, "%% GPRS not enabled on this BTS%s", VTY_NEWLINE);
1951 return CMD_WARNING;
1952 }
1953
Harald Welte410575a2010-03-14 23:30:30 +08001954 inet_aton(argv[1], &ia);
1955 bts->gprs.nsvc[idx].remote_ip = ntohl(ia.s_addr);
1956
1957 return CMD_SUCCESS;
1958}
1959
Holger Hans Peter Freyther3112f672010-09-06 10:11:25 +08001960DEFUN(cfg_bts_pag_free, cfg_bts_pag_free_cmd,
1961 "paging free FREE_NR",
1962 "Only page when having a certain amount of free slots. -1 to disable")
1963{
1964 struct gsm_bts *bts = vty->index;
1965
1966 bts->paging.free_chans_need = atoi(argv[0]);
1967 return CMD_SUCCESS;
1968}
1969
Harald Weltea9251762010-05-11 23:50:21 +02001970DEFUN(cfg_bts_gprs_ns_timer, cfg_bts_gprs_ns_timer_cmd,
1971 "gprs ns timer " NS_TIMERS " <0-255>",
1972 GPRS_TEXT "Network Service\n"
1973 "Network Service Timer\n"
1974 NS_TIMERS_HELP "Timer Value\n")
1975{
1976 struct gsm_bts *bts = vty->index;
1977 int idx = get_string_value(gprs_ns_timer_strs, argv[0]);
1978 int val = atoi(argv[1]);
1979
1980 if (bts->gprs.mode == BTS_GPRS_NONE) {
1981 vty_out(vty, "%% GPRS not enabled on this BTS%s", VTY_NEWLINE);
1982 return CMD_WARNING;
1983 }
1984
1985 if (idx < 0 || idx >= ARRAY_SIZE(bts->gprs.nse.timer))
1986 return CMD_WARNING;
1987
1988 bts->gprs.nse.timer[idx] = val;
1989
1990 return CMD_SUCCESS;
1991}
1992
1993#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 +02001994#define BSSGP_TIMERS_HELP \
1995 "Tbvc-block timeout\n" \
1996 "Tbvc-block retries\n" \
1997 "Tbvc-unblock retries\n" \
1998 "Tbvcc-reset timeout\n" \
1999 "Tbvc-reset retries\n" \
2000 "Tbvc-suspend timeout\n" \
2001 "Tbvc-suspend retries\n" \
2002 "Tbvc-resume timeout\n" \
2003 "Tbvc-resume retries\n" \
2004 "Tbvc-capa-update timeout\n" \
2005 "Tbvc-capa-update retries\n"
Harald Weltea9251762010-05-11 23:50:21 +02002006
2007DEFUN(cfg_bts_gprs_cell_timer, cfg_bts_gprs_cell_timer_cmd,
2008 "gprs cell timer " BSSGP_TIMERS " <0-255>",
2009 GPRS_TEXT "Cell / BSSGP\n"
2010 "Cell/BSSGP Timer\n"
2011 BSSGP_TIMERS_HELP "Timer Value\n")
2012{
2013 struct gsm_bts *bts = vty->index;
2014 int idx = get_string_value(gprs_bssgp_cfg_strs, argv[0]);
2015 int val = atoi(argv[1]);
2016
2017 if (bts->gprs.mode == BTS_GPRS_NONE) {
2018 vty_out(vty, "%% GPRS not enabled on this BTS%s", VTY_NEWLINE);
2019 return CMD_WARNING;
2020 }
2021
2022 if (idx < 0 || idx >= ARRAY_SIZE(bts->gprs.cell.timer))
2023 return CMD_WARNING;
2024
2025 bts->gprs.cell.timer[idx] = val;
2026
2027 return CMD_SUCCESS;
2028}
2029
Harald Welte3055e332010-03-14 15:37:43 +08002030DEFUN(cfg_bts_gprs_rac, cfg_bts_gprs_rac_cmd,
2031 "gprs routing area <0-255>",
Harald Welte9e002452010-05-11 21:53:49 +02002032 GPRS_TEXT
Harald Welte3055e332010-03-14 15:37:43 +08002033 "GPRS Routing Area Code")
2034{
2035 struct gsm_bts *bts = vty->index;
2036
Harald Weltecb20b7a2010-04-18 15:51:20 +02002037 if (bts->gprs.mode == BTS_GPRS_NONE) {
Harald Weltec05a4b12010-03-14 23:56:56 +08002038 vty_out(vty, "%% GPRS not enabled on this BTS%s", VTY_NEWLINE);
2039 return CMD_WARNING;
2040 }
2041
Harald Welte3055e332010-03-14 15:37:43 +08002042 bts->gprs.rac = atoi(argv[0]);
2043
2044 return CMD_SUCCESS;
2045}
2046
Harald Weltecb20b7a2010-04-18 15:51:20 +02002047DEFUN(cfg_bts_gprs_mode, cfg_bts_gprs_mode_cmd,
2048 "gprs mode (none|gprs|egprs)",
Harald Welte9e002452010-05-11 21:53:49 +02002049 GPRS_TEXT
2050 "GPRS Mode for this BTS\n"
2051 "GPRS Disabled on this BTS\n"
2052 "GPRS Enabled on this BTS\n"
2053 "EGPRS (EDGE) Enabled on this BTS\n")
Harald Welte410575a2010-03-14 23:30:30 +08002054{
2055 struct gsm_bts *bts = vty->index;
Harald Welte20e275a2010-06-14 22:44:42 +02002056 enum bts_gprs_mode mode = bts_gprs_mode_parse(argv[0]);
Harald Welte410575a2010-03-14 23:30:30 +08002057
Harald Welte20e275a2010-06-14 22:44:42 +02002058 if (mode != BTS_GPRS_NONE &&
2059 !gsm_bts_has_feature(bts, BTS_FEAT_GPRS)) {
2060 vty_out(vty, "This BTS type does not support %s%s", argv[0],
2061 VTY_NEWLINE);
2062 return CMD_WARNING;
2063 }
2064 if (mode == BTS_GPRS_EGPRS &&
2065 !gsm_bts_has_feature(bts, BTS_FEAT_EGPRS)) {
2066 vty_out(vty, "This BTS type does not support %s%s", argv[0],
2067 VTY_NEWLINE);
2068 return CMD_WARNING;
2069 }
2070
2071 bts->gprs.mode = mode;
Harald Welte410575a2010-03-14 23:30:30 +08002072
2073 return CMD_SUCCESS;
2074}
2075
Harald Welted8acf142010-07-30 11:50:09 +02002076#define SI_TEXT "System Information Messages\n"
2077#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)"
2078#define SI_TYPE_HELP "System Information Type 1\n" \
2079 "System Information Type 2\n" \
2080 "System Information Type 3\n" \
2081 "System Information Type 4\n" \
2082 "System Information Type 5\n" \
2083 "System Information Type 6\n" \
2084 "System Information Type 7\n" \
2085 "System Information Type 8\n" \
2086 "System Information Type 9\n" \
2087 "System Information Type 10\n" \
2088 "System Information Type 13\n" \
2089 "System Information Type 16\n" \
2090 "System Information Type 17\n" \
2091 "System Information Type 18\n" \
2092 "System Information Type 19\n" \
2093 "System Information Type 20\n" \
2094 "System Information Type 2bis\n" \
2095 "System Information Type 2ter\n" \
2096 "System Information Type 2quater\n" \
2097 "System Information Type 5bis\n" \
2098 "System Information Type 5ter\n"
2099
2100DEFUN(cfg_bts_si_mode, cfg_bts_si_mode_cmd,
2101 "system-information " SI_TYPE_TEXT " mode (static|computed)",
2102 SI_TEXT SI_TYPE_HELP
2103 "System Information Mode\n"
2104 "Static user-specified\n"
2105 "Dynamic, BSC-computed\n")
2106{
2107 struct gsm_bts *bts = vty->index;
2108 int type;
2109
2110 type = get_string_value(osmo_sitype_strs, argv[0]);
2111 if (type < 0) {
2112 vty_out(vty, "Error SI Type%s", VTY_NEWLINE);
2113 return CMD_WARNING;
2114 }
2115
2116 if (!strcmp(argv[1], "static"))
2117 bts->si_mode_static |= (1 << type);
2118 else
2119 bts->si_mode_static &= ~(1 << type);
2120
2121 return CMD_SUCCESS;
2122}
2123
2124DEFUN(cfg_bts_si_static, cfg_bts_si_static_cmd,
2125 "system-information " SI_TYPE_TEXT " static HEXSTRING",
2126 SI_TEXT SI_TYPE_HELP
2127 "Static System Information filling\n"
2128 "Static user-specified SI content in HEX notation\n")
2129{
2130 struct gsm_bts *bts = vty->index;
2131 int rc, type;
2132
2133 type = get_string_value(osmo_sitype_strs, argv[0]);
2134 if (type < 0) {
2135 vty_out(vty, "Error SI Type%s", VTY_NEWLINE);
2136 return CMD_WARNING;
2137 }
2138
2139 if (!(bts->si_mode_static & (1 << type))) {
2140 vty_out(vty, "SI Type %s is not configured in static mode%s",
2141 get_value_string(osmo_sitype_strs, type), VTY_NEWLINE);
2142 return CMD_WARNING;
2143 }
2144
Harald Welte9f09ac32010-07-30 11:53:18 +02002145 /* Fill buffer with padding pattern */
2146 memset(bts->si_buf[type], 0x2b, sizeof(bts->si_buf[type]));
2147
2148 /* Parse the user-specified SI in hex format, [partially] overwriting padding */
Harald Welted8acf142010-07-30 11:50:09 +02002149 rc = hexparse(argv[1], bts->si_buf[type], sizeof(bts->si_buf[0]));
2150 if (rc < 0 || rc > sizeof(bts->si_buf[0])) {
2151 vty_out(vty, "Error parsing HEXSTRING%s", VTY_NEWLINE);
2152 return CMD_WARNING;
2153 }
2154
2155 /* Mark this SI as present */
2156 bts->si_valid |= (1 << type);
2157
2158 return CMD_SUCCESS;
2159}
2160
Harald Welteca46eff2011-01-11 23:44:56 +01002161DEFUN(cfg_bts_neigh_mode, cfg_bts_neigh_mode_cmd,
Harald Weltef989b782011-02-15 11:43:27 +01002162 "neighbor-list mode (automatic|manual|manual-si5)",
Harald Welteca46eff2011-01-11 23:44:56 +01002163 "Neighbor List\n" "Mode of Neighbor List generation\n"
Harald Weltef989b782011-02-15 11:43:27 +01002164 "Automatically from all BTS in this OpenBSC\n" "Manual\n"
2165 "Manual with different lists for SI2 and SI5\n")
Harald Welteca46eff2011-01-11 23:44:56 +01002166{
2167 struct gsm_bts *bts = vty->index;
Harald Weltef989b782011-02-15 11:43:27 +01002168 int mode = get_string_value(bts_neigh_mode_strs, argv[0]);
Harald Welteca46eff2011-01-11 23:44:56 +01002169
Harald Weltef989b782011-02-15 11:43:27 +01002170 switch (mode) {
2171 case NL_MODE_MANUAL_SI5SEP:
2172 case NL_MODE_MANUAL:
Harald Welteca46eff2011-01-11 23:44:56 +01002173 /* make sure we clear the current list when switching to
2174 * manual mode */
2175 if (bts->neigh_list_manual_mode == 0)
2176 memset(&bts->si_common.data.neigh_list, 0,
2177 sizeof(bts->si_common.data.neigh_list));
Harald Weltef989b782011-02-15 11:43:27 +01002178 break;
2179 default:
2180 break;
2181 }
2182
2183 bts->neigh_list_manual_mode = mode;
Harald Welteca46eff2011-01-11 23:44:56 +01002184
2185 return CMD_SUCCESS;
2186}
2187
2188DEFUN(cfg_bts_neigh, cfg_bts_neigh_cmd,
2189 "neighbor-list (add|del) arfcn <0-1024>",
2190 "Neighbor List\n" "Add to manual neighbor list\n"
2191 "Delete from manual neighbor list\n" "ARFCN of neighbor\n"
2192 "ARFCN of neighbor\n")
2193{
2194 struct gsm_bts *bts = vty->index;
2195 struct bitvec *bv = &bts->si_common.neigh_list;
2196 uint16_t arfcn = atoi(argv[1]);
2197
2198 if (!bts->neigh_list_manual_mode) {
2199 vty_out(vty, "%% Cannot configure neighbor list in "
2200 "automatic mode%s", VTY_NEWLINE);
2201 return CMD_WARNING;
2202 }
2203
2204 if (!strcmp(argv[0], "add"))
2205 bitvec_set_bit_pos(bv, arfcn, 1);
2206 else
2207 bitvec_set_bit_pos(bv, arfcn, 0);
2208
2209 return CMD_SUCCESS;
2210}
2211
Harald Weltef989b782011-02-15 11:43:27 +01002212DEFUN(cfg_bts_si5_neigh, cfg_bts_si5_neigh_cmd,
2213 "si5 neighbor-list (add|del) arfcn <0-1024>",
2214 "SI5 Neighbor List\n" "Add to manual SI5 neighbor list\n"
2215 "Delete from SI5 manual neighbor list\n" "ARFCN of neighbor\n"
2216 "ARFCN of neighbor\n")
2217{
2218 struct gsm_bts *bts = vty->index;
2219 struct bitvec *bv = &bts->si_common.si5_neigh_list;
2220 uint16_t arfcn = atoi(argv[1]);
2221
2222 if (!bts->neigh_list_manual_mode) {
2223 vty_out(vty, "%% Cannot configure neighbor list in "
2224 "automatic mode%s", VTY_NEWLINE);
2225 return CMD_WARNING;
2226 }
2227
2228 if (!strcmp(argv[0], "add"))
2229 bitvec_set_bit_pos(bv, arfcn, 1);
2230 else
2231 bitvec_set_bit_pos(bv, arfcn, 0);
2232
2233 return CMD_SUCCESS;
2234}
Harald Welted8acf142010-07-30 11:50:09 +02002235
Harald Welte9e002452010-05-11 21:53:49 +02002236#define TRX_TEXT "Radio Transceiver\n"
Harald Welte3e774612009-08-10 13:48:16 +02002237
Harald Welte59b04682009-06-10 05:40:52 +08002238/* per TRX configuration */
2239DEFUN(cfg_trx,
2240 cfg_trx_cmd,
2241 "trx TRX_NR",
Harald Welte9e002452010-05-11 21:53:49 +02002242 TRX_TEXT
Harald Welte59b04682009-06-10 05:40:52 +08002243 "Select a TRX to configure")
2244{
2245 int trx_nr = atoi(argv[0]);
2246 struct gsm_bts *bts = vty->index;
2247 struct gsm_bts_trx *trx;
2248
Harald Weltee712a5f2009-06-21 16:17:15 +02002249 if (trx_nr > bts->num_trx) {
2250 vty_out(vty, "%% The next unused TRX number in this BTS is %u%s",
2251 bts->num_trx, VTY_NEWLINE);
Harald Welte59b04682009-06-10 05:40:52 +08002252 return CMD_WARNING;
Harald Weltee712a5f2009-06-21 16:17:15 +02002253 } else if (trx_nr == bts->num_trx) {
2254 /* we need to allocate a new one */
2255 trx = gsm_bts_trx_alloc(bts);
Holger Hans Peter Freyther71135142010-03-29 08:47:44 +02002256 } else
Harald Weltee712a5f2009-06-21 16:17:15 +02002257 trx = gsm_bts_trx_num(bts, trx_nr);
Holger Hans Peter Freyther71135142010-03-29 08:47:44 +02002258
Harald Weltee712a5f2009-06-21 16:17:15 +02002259 if (!trx)
2260 return CMD_WARNING;
Harald Welte59b04682009-06-10 05:40:52 +08002261
2262 vty->index = trx;
Harald Welte8791dac2010-05-14 17:59:53 +02002263 vty->index_sub = &trx->description;
Harald Welte59b04682009-06-10 05:40:52 +08002264 vty->node = TRX_NODE;
2265
2266 return CMD_SUCCESS;
2267}
2268
2269DEFUN(cfg_trx_arfcn,
2270 cfg_trx_arfcn_cmd,
Harald Welte00044592010-05-14 19:00:52 +02002271 "arfcn <0-1024>",
Harald Welte59b04682009-06-10 05:40:52 +08002272 "Set the ARFCN for this TRX\n")
2273{
2274 int arfcn = atoi(argv[0]);
2275 struct gsm_bts_trx *trx = vty->index;
2276
2277 /* FIXME: check if this ARFCN is supported by this TRX */
2278
2279 trx->arfcn = arfcn;
2280
2281 /* FIXME: patch ARFCN into SYSTEM INFORMATION */
2282 /* FIXME: use OML layer to update the ARFCN */
2283 /* FIXME: use RSL layer to update SYSTEM INFORMATION */
2284
2285 return CMD_SUCCESS;
2286}
2287
Harald Welte (local)b709bfe2009-12-27 20:56:38 +01002288DEFUN(cfg_trx_nominal_power,
2289 cfg_trx_nominal_power_cmd,
2290 "nominal power <0-100>",
2291 "Nominal TRX RF Power in dB\n")
2292{
2293 struct gsm_bts_trx *trx = vty->index;
2294
2295 trx->nominal_power = atoi(argv[0]);
2296
2297 return CMD_SUCCESS;
2298}
2299
Harald Welte91afe4c2009-06-20 18:15:19 +02002300DEFUN(cfg_trx_max_power_red,
2301 cfg_trx_max_power_red_cmd,
2302 "max_power_red <0-100>",
2303 "Reduction of maximum BS RF Power in dB\n")
2304{
2305 int maxpwr_r = atoi(argv[0]);
2306 struct gsm_bts_trx *trx = vty->index;
Harald Welte01acd742009-11-18 09:20:22 +01002307 int upper_limit = 24; /* default 12.21 max power red. */
Harald Welte91afe4c2009-06-20 18:15:19 +02002308
2309 /* FIXME: check if our BTS type supports more than 12 */
2310 if (maxpwr_r < 0 || maxpwr_r > upper_limit) {
2311 vty_out(vty, "%% Power %d dB is not in the valid range%s",
2312 maxpwr_r, VTY_NEWLINE);
2313 return CMD_WARNING;
2314 }
2315 if (maxpwr_r & 1) {
2316 vty_out(vty, "%% Power %d dB is not an even value%s",
2317 maxpwr_r, VTY_NEWLINE);
2318 return CMD_WARNING;
2319 }
2320
2321 trx->max_power_red = maxpwr_r;
2322
2323 /* FIXME: make sure we update this using OML */
2324
2325 return CMD_SUCCESS;
2326}
2327
Harald Welte62868882009-08-08 16:12:58 +02002328DEFUN(cfg_trx_rsl_e1,
2329 cfg_trx_rsl_e1_cmd,
2330 "rsl e1 line E1_LINE timeslot <1-31> sub-slot (0|1|2|3|full)",
2331 "E1 interface to be used for RSL\n")
2332{
2333 struct gsm_bts_trx *trx = vty->index;
2334
2335 parse_e1_link(&trx->rsl_e1_link, argv[0], argv[1], argv[2]);
2336
2337 return CMD_SUCCESS;
2338}
2339
2340DEFUN(cfg_trx_rsl_e1_tei,
2341 cfg_trx_rsl_e1_tei_cmd,
2342 "rsl e1 tei <0-63>",
2343 "Set the TEI to be used for RSL")
2344{
2345 struct gsm_bts_trx *trx = vty->index;
2346
2347 trx->rsl_tei = atoi(argv[0]);
2348
2349 return CMD_SUCCESS;
2350}
2351
Holger Hans Peter Freyther1c8b4802009-11-11 11:54:24 +01002352DEFUN(cfg_trx_rf_locked,
2353 cfg_trx_rf_locked_cmd,
2354 "rf_locked (0|1)",
2355 "Turn off RF of the TRX.\n")
2356{
2357 int locked = atoi(argv[0]);
2358 struct gsm_bts_trx *trx = vty->index;
2359
2360 gsm_trx_lock_rf(trx, locked);
2361 return CMD_SUCCESS;
2362}
Harald Welte62868882009-08-08 16:12:58 +02002363
Harald Welte59b04682009-06-10 05:40:52 +08002364/* per TS configuration */
2365DEFUN(cfg_ts,
2366 cfg_ts_cmd,
Harald Welte62868882009-08-08 16:12:58 +02002367 "timeslot <0-7>",
Harald Welte59b04682009-06-10 05:40:52 +08002368 "Select a Timeslot to configure")
2369{
2370 int ts_nr = atoi(argv[0]);
2371 struct gsm_bts_trx *trx = vty->index;
2372 struct gsm_bts_trx_ts *ts;
2373
2374 if (ts_nr >= TRX_NR_TS) {
2375 vty_out(vty, "%% A GSM TRX only has %u Timeslots per TRX%s",
2376 TRX_NR_TS, VTY_NEWLINE);
2377 return CMD_WARNING;
2378 }
2379
2380 ts = &trx->ts[ts_nr];
2381
2382 vty->index = ts;
2383 vty->node = TS_NODE;
2384
2385 return CMD_SUCCESS;
2386}
2387
Harald Welte3ffe1b32009-08-07 00:25:23 +02002388DEFUN(cfg_ts_pchan,
2389 cfg_ts_pchan_cmd,
2390 "phys_chan_config PCHAN",
2391 "Physical Channel configuration (TCH/SDCCH/...)")
2392{
2393 struct gsm_bts_trx_ts *ts = vty->index;
2394 int pchanc;
2395
2396 pchanc = gsm_pchan_parse(argv[0]);
2397 if (pchanc < 0)
2398 return CMD_WARNING;
2399
2400 ts->pchan = pchanc;
2401
2402 return CMD_SUCCESS;
2403}
2404
Harald Weltea42a93f2010-06-14 22:26:10 +02002405#define HOPPING_STR "Configure frequency hopping\n"
2406
2407DEFUN(cfg_ts_hopping,
2408 cfg_ts_hopping_cmd,
2409 "hopping enabled (0|1)",
2410 HOPPING_STR "Enable or disable frequency hopping\n"
2411 "Disable frequency hopping\n" "Enable frequency hopping\n")
2412{
2413 struct gsm_bts_trx_ts *ts = vty->index;
Harald Welte059c1ef2010-06-14 22:47:37 +02002414 int enabled = atoi(argv[0]);
Harald Weltea42a93f2010-06-14 22:26:10 +02002415
Harald Welte059c1ef2010-06-14 22:47:37 +02002416 if (enabled && !gsm_bts_has_feature(ts->trx->bts, BTS_FEAT_HOPPING)) {
2417 vty_out(vty, "BTS model does not support hopping%s",
2418 VTY_NEWLINE);
2419 return CMD_WARNING;
2420 }
2421
2422 ts->hopping.enabled = enabled;
Harald Weltea42a93f2010-06-14 22:26:10 +02002423
2424 return CMD_SUCCESS;
2425}
2426
Harald Welte67104d12009-09-12 13:05:33 +02002427DEFUN(cfg_ts_hsn,
2428 cfg_ts_hsn_cmd,
Harald Weltea42a93f2010-06-14 22:26:10 +02002429 "hopping sequence-number <0-63>",
2430 HOPPING_STR
Harald Welte67104d12009-09-12 13:05:33 +02002431 "Which hopping sequence to use for this channel")
2432{
2433 struct gsm_bts_trx_ts *ts = vty->index;
2434
2435 ts->hopping.hsn = atoi(argv[0]);
2436
2437 return CMD_SUCCESS;
2438}
2439
2440DEFUN(cfg_ts_maio,
2441 cfg_ts_maio_cmd,
2442 "hopping maio <0-63>",
Harald Weltea42a93f2010-06-14 22:26:10 +02002443 HOPPING_STR
Harald Welte67104d12009-09-12 13:05:33 +02002444 "Which hopping MAIO to use for this channel")
2445{
2446 struct gsm_bts_trx_ts *ts = vty->index;
2447
2448 ts->hopping.maio = atoi(argv[0]);
2449
2450 return CMD_SUCCESS;
2451}
2452
2453DEFUN(cfg_ts_arfcn_add,
2454 cfg_ts_arfcn_add_cmd,
2455 "hopping arfcn add <0-1023>",
Harald Weltea42a93f2010-06-14 22:26:10 +02002456 HOPPING_STR "Configure hopping ARFCN list\n"
2457 "Add an entry to the hopping ARFCN list\n" "ARFCN\n")
Harald Welte67104d12009-09-12 13:05:33 +02002458{
2459 struct gsm_bts_trx_ts *ts = vty->index;
2460 int arfcn = atoi(argv[0]);
2461
Harald Weltea42a93f2010-06-14 22:26:10 +02002462 bitvec_set_bit_pos(&ts->hopping.arfcns, arfcn, 1);
2463
Harald Welte67104d12009-09-12 13:05:33 +02002464 return CMD_SUCCESS;
2465}
2466
2467DEFUN(cfg_ts_arfcn_del,
2468 cfg_ts_arfcn_del_cmd,
2469 "hopping arfcn del <0-1023>",
Harald Weltea42a93f2010-06-14 22:26:10 +02002470 HOPPING_STR "Configure hopping ARFCN list\n"
2471 "Delete an entry to the hopping ARFCN list\n" "ARFCN\n")
Harald Welte67104d12009-09-12 13:05:33 +02002472{
2473 struct gsm_bts_trx_ts *ts = vty->index;
2474 int arfcn = atoi(argv[0]);
2475
Harald Weltea42a93f2010-06-14 22:26:10 +02002476 bitvec_set_bit_pos(&ts->hopping.arfcns, arfcn, 0);
2477
Harald Welte67104d12009-09-12 13:05:33 +02002478 return CMD_SUCCESS;
2479}
2480
Harald Welte3ffe1b32009-08-07 00:25:23 +02002481DEFUN(cfg_ts_e1_subslot,
2482 cfg_ts_e1_subslot_cmd,
Harald Welte62868882009-08-08 16:12:58 +02002483 "e1 line E1_LINE timeslot <1-31> sub-slot (0|1|2|3|full)",
Harald Welte3ffe1b32009-08-07 00:25:23 +02002484 "E1 sub-slot connected to this on-air timeslot")
2485{
2486 struct gsm_bts_trx_ts *ts = vty->index;
2487
Harald Welte62868882009-08-08 16:12:58 +02002488 parse_e1_link(&ts->e1_link, argv[0], argv[1], argv[2]);
Harald Welte3ffe1b32009-08-07 00:25:23 +02002489
2490 return CMD_SUCCESS;
2491}
Harald Welte59b04682009-06-10 05:40:52 +08002492
Harald Weltea5b1dae2010-05-16 21:47:13 +02002493void openbsc_vty_print_statistics(struct vty *vty, struct gsm_network *net)
2494{
2495 vty_out(vty, "Channel Requests : %lu total, %lu no channel%s",
2496 counter_get(net->stats.chreq.total),
2497 counter_get(net->stats.chreq.no_channel), VTY_NEWLINE);
2498 vty_out(vty, "Channel Failures : %lu rf_failures, %lu rll failures%s",
2499 counter_get(net->stats.chan.rf_fail),
2500 counter_get(net->stats.chan.rll_err), VTY_NEWLINE);
2501 vty_out(vty, "Paging : %lu attempted, %lu complete, %lu expired%s",
2502 counter_get(net->stats.paging.attempted),
2503 counter_get(net->stats.paging.completed),
2504 counter_get(net->stats.paging.expired), VTY_NEWLINE);
2505 vty_out(vty, "BTS failures : %lu OML, %lu RSL%s",
2506 counter_get(net->stats.bts.oml_fail),
2507 counter_get(net->stats.bts.rsl_fail), VTY_NEWLINE);
2508}
2509
Harald Welte682ee5f2010-05-16 22:02:16 +02002510DEFUN(logging_fltr_imsi,
2511 logging_fltr_imsi_cmd,
2512 "logging filter imsi IMSI",
2513 LOGGING_STR FILTER_STR
2514 "Filter log messages by IMSI\n" "IMSI to be used as filter\n")
2515{
Harald Welte58bef962011-02-18 21:10:05 +01002516 struct log_target *tgt = osmo_log_vty2tgt(vty);
Harald Welte682ee5f2010-05-16 22:02:16 +02002517
Harald Welte58bef962011-02-18 21:10:05 +01002518 if (!tgt)
Harald Welte682ee5f2010-05-16 22:02:16 +02002519 return CMD_WARNING;
Harald Welte682ee5f2010-05-16 22:02:16 +02002520
Harald Welte58bef962011-02-18 21:10:05 +01002521 log_set_imsi_filter(tgt, argv[0]);
Harald Welte682ee5f2010-05-16 22:02:16 +02002522 return CMD_SUCCESS;
2523}
2524
Harald Welte58bef962011-02-18 21:10:05 +01002525
Holger Hans Peter Freyther07ff1c32010-10-26 09:40:13 +02002526DEFUN(drop_bts,
2527 drop_bts_cmd,
Holger Hans Peter Freythere4ac0e42010-04-11 12:46:45 +02002528 "drop bts connection <0-65535> (oml|rsl)",
2529 "Debug/Simulation command to drop ipaccess BTS\n"
2530 "BTS NR\n" "Connection Type\n")
Holger Hans Peter Freyther07ff1c32010-10-26 09:40:13 +02002531{
2532 struct gsm_network *gsmnet;
2533 struct gsm_bts_trx *trx;
2534 struct gsm_bts *bts;
2535 unsigned int bts_nr;
2536
2537 gsmnet = gsmnet_from_vty(vty);
2538
2539 bts_nr = atoi(argv[0]);
2540 if (bts_nr >= gsmnet->num_bts) {
2541 vty_out(vty, "BTS number must be between 0 and %d. It was %d.%s",
2542 gsmnet->num_bts, bts_nr, VTY_NEWLINE);
2543 return CMD_WARNING;
2544 }
2545
2546 bts = gsm_bts_num(gsmnet, bts_nr);
2547 if (!bts) {
2548 vty_out(vty, "BTS Nr. %d could not be found.%s", bts_nr, VTY_NEWLINE);
2549 return CMD_WARNING;
2550 }
2551
2552 if (!is_ipaccess_bts(bts)) {
2553 vty_out(vty, "This command only works for ipaccess.%s", VTY_NEWLINE);
2554 return CMD_WARNING;
2555 }
2556
2557
2558 /* close all connections */
2559 if (strcmp(argv[1], "oml") == 0) {
Holger Hans Peter Freyther03f17d02010-11-15 20:29:46 +01002560 ipaccess_drop_oml(bts);
Holger Hans Peter Freyther07ff1c32010-10-26 09:40:13 +02002561 } else if (strcmp(argv[1], "rsl") == 0) {
2562 /* close all rsl connections */
2563 llist_for_each_entry(trx, &bts->trx_list, list) {
Holger Hans Peter Freyther03f17d02010-11-15 20:29:46 +01002564 ipaccess_drop_rsl(trx);
Holger Hans Peter Freyther07ff1c32010-10-26 09:40:13 +02002565 }
2566 } else {
2567 vty_out(vty, "Argument must be 'oml# or 'rsl'.%s", VTY_NEWLINE);
2568 return CMD_WARNING;
2569 }
2570
2571 return CMD_SUCCESS;
2572}
2573
Harald Welte5213e992010-12-23 13:18:07 +01002574DEFUN(pdch_act, pdch_act_cmd,
2575 "bts <0-255> trx <0-255> timeslot <0-7> pdch (activate|deactivate)",
2576 "BTS related commands\n" "BTS Number\n" "Transceiver\n" "Transceiver Number\n"
2577 "TRX Timeslot\n" "Timeslot Number\n" "Packet Data Channel\n"
2578 "Activate Dynamic PDCH/TCH (-> PDCH mode)\n"
2579 "Deactivate Dynamic PDCH/TCH (-> TCH mode)\n")
2580{
2581 struct gsm_bts *bts;
2582 struct gsm_bts_trx *trx;
2583 struct gsm_bts_trx_ts *ts;
2584 int bts_nr = atoi(argv[0]);
2585 int trx_nr = atoi(argv[1]);
2586 int ts_nr = atoi(argv[2]);
2587 int activate;
2588
2589 bts = gsm_bts_num(bsc_gsmnet, bts_nr);
2590 if (!bts) {
2591 vty_out(vty, "%% No such BTS (%d)%s", bts_nr, VTY_NEWLINE);
2592 return CMD_WARNING;
2593 }
2594
2595 if (!is_ipaccess_bts(bts)) {
2596 vty_out(vty, "%% This command only works for ipaccess BTS%s",
2597 VTY_NEWLINE);
2598 return CMD_WARNING;
2599 }
2600
2601 trx = gsm_bts_trx_num(bts, trx_nr);
2602 if (!trx) {
2603 vty_out(vty, "%% No such TRX (%d)%s", trx_nr, VTY_NEWLINE);
2604 return CMD_WARNING;
2605 }
2606
2607 ts = &trx->ts[ts_nr];
2608 if (ts->pchan != GSM_PCHAN_TCH_F_PDCH) {
2609 vty_out(vty, "%% Timeslot %u is not in dynamic TCH_F/PDCH "
2610 "mode%s", ts_nr, VTY_NEWLINE);
2611 return CMD_WARNING;
2612 }
2613
2614 if (!strcmp(argv[3], "activate"))
2615 activate = 1;
2616 else
2617 activate = 0;
2618
2619 rsl_ipacc_pdch_activate(ts, activate);
2620
2621 return CMD_SUCCESS;
2622
2623}
Holger Hans Peter Freyther07ff1c32010-10-26 09:40:13 +02002624
Harald Welte40152872010-05-16 20:52:23 +02002625extern int bsc_vty_init_extra(void);
Harald Welte10c29f62010-05-16 19:20:24 +02002626extern const char *openbsc_copyright;
Holger Hans Peter Freytherc48a2a12010-04-10 00:08:28 +02002627
Harald Welte40152872010-05-16 20:52:23 +02002628int bsc_vty_init(void)
Harald Welte59b04682009-06-10 05:40:52 +08002629{
Harald Welte7bc28f62010-05-12 16:10:35 +00002630 install_element_ve(&show_net_cmd);
2631 install_element_ve(&show_bts_cmd);
2632 install_element_ve(&show_trx_cmd);
2633 install_element_ve(&show_ts_cmd);
2634 install_element_ve(&show_lchan_cmd);
Holger Hans Peter Freythere959b4e2010-05-14 02:08:49 +08002635 install_element_ve(&show_lchan_summary_cmd);
Harald Welte682ee5f2010-05-16 22:02:16 +02002636 install_element_ve(&logging_fltr_imsi_cmd);
Harald Welte59b04682009-06-10 05:40:52 +08002637
Harald Welte7bc28f62010-05-12 16:10:35 +00002638 install_element_ve(&show_e1drv_cmd);
2639 install_element_ve(&show_e1line_cmd);
2640 install_element_ve(&show_e1ts_cmd);
Harald Welte59b04682009-06-10 05:40:52 +08002641
Harald Welte7bc28f62010-05-12 16:10:35 +00002642 install_element_ve(&show_paging_cmd);
Harald Welte59b04682009-06-10 05:40:52 +08002643
Harald Welte682ee5f2010-05-16 22:02:16 +02002644 logging_vty_add_cmds();
Harald Welte58bef962011-02-18 21:10:05 +01002645 install_element(CFG_LOG_NODE, &logging_fltr_imsi_cmd);
Holger Hans Peter Freytherc8d862e2009-12-22 22:32:51 +01002646
Harald Weltee87eb462009-08-07 13:29:14 +02002647 install_element(CONFIG_NODE, &cfg_net_cmd);
2648 install_node(&net_node, config_write_net);
2649 install_default(GSMNET_NODE);
Harald Welte58ed1cb2010-05-14 18:59:17 +02002650 install_element(GSMNET_NODE, &ournode_exit_cmd);
Harald Weltedc82b9b2010-05-14 19:11:04 +02002651 install_element(GSMNET_NODE, &ournode_end_cmd);
Harald Welte62868882009-08-08 16:12:58 +02002652 install_element(GSMNET_NODE, &cfg_net_ncc_cmd);
Harald Weltee87eb462009-08-07 13:29:14 +02002653 install_element(GSMNET_NODE, &cfg_net_mnc_cmd);
2654 install_element(GSMNET_NODE, &cfg_net_name_short_cmd);
2655 install_element(GSMNET_NODE, &cfg_net_name_long_cmd);
Harald Welte (local)a59a27e2009-08-12 14:42:23 +02002656 install_element(GSMNET_NODE, &cfg_net_auth_policy_cmd);
Harald Welte59936d72009-11-18 20:33:19 +01002657 install_element(GSMNET_NODE, &cfg_net_reject_cause_cmd);
Harald Weltecca253a2009-08-30 15:47:06 +09002658 install_element(GSMNET_NODE, &cfg_net_encryption_cmd);
Holger Hans Peter Freyther96c89822009-11-16 17:12:38 +01002659 install_element(GSMNET_NODE, &cfg_net_neci_cmd);
Harald Welte52af1952009-12-13 10:53:12 +01002660 install_element(GSMNET_NODE, &cfg_net_rrlp_mode_cmd);
Harald Welte284ddba2009-12-14 17:49:15 +01002661 install_element(GSMNET_NODE, &cfg_net_mm_info_cmd);
Harald Welte0af9c9f2009-12-19 21:41:52 +01002662 install_element(GSMNET_NODE, &cfg_net_handover_cmd);
Harald Weltea8062f12009-12-21 16:51:50 +01002663 install_element(GSMNET_NODE, &cfg_net_ho_win_rxlev_avg_cmd);
2664 install_element(GSMNET_NODE, &cfg_net_ho_win_rxqual_avg_cmd);
2665 install_element(GSMNET_NODE, &cfg_net_ho_win_rxlev_avg_neigh_cmd);
2666 install_element(GSMNET_NODE, &cfg_net_ho_pwr_interval_cmd);
2667 install_element(GSMNET_NODE, &cfg_net_ho_pwr_hysteresis_cmd);
2668 install_element(GSMNET_NODE, &cfg_net_ho_max_distance_cmd);
Holger Hans Peter Freyther26ba2e72009-11-21 21:18:38 +01002669 install_element(GSMNET_NODE, &cfg_net_T3101_cmd);
Holger Hans Peter Freyther89733862009-11-21 21:42:26 +01002670 install_element(GSMNET_NODE, &cfg_net_T3103_cmd);
2671 install_element(GSMNET_NODE, &cfg_net_T3105_cmd);
2672 install_element(GSMNET_NODE, &cfg_net_T3107_cmd);
2673 install_element(GSMNET_NODE, &cfg_net_T3109_cmd);
2674 install_element(GSMNET_NODE, &cfg_net_T3111_cmd);
2675 install_element(GSMNET_NODE, &cfg_net_T3113_cmd);
2676 install_element(GSMNET_NODE, &cfg_net_T3115_cmd);
2677 install_element(GSMNET_NODE, &cfg_net_T3117_cmd);
2678 install_element(GSMNET_NODE, &cfg_net_T3119_cmd);
Harald Weltee2aaf442010-12-23 22:53:50 +01002679 install_element(GSMNET_NODE, &cfg_net_T3122_cmd);
Holger Hans Peter Freyther89733862009-11-21 21:42:26 +01002680 install_element(GSMNET_NODE, &cfg_net_T3141_cmd);
Holger Hans Peter Freyther21d63ff2010-09-06 09:25:48 +08002681 install_element(GSMNET_NODE, &cfg_net_dtx_cmd);
Holger Hans Peter Freyther68b21e12010-12-22 16:26:04 +01002682 install_element(GSMNET_NODE, &cfg_net_subscr_keep_cmd);
Holger Hans Peter Freytherb6b9d702010-09-06 09:41:50 +08002683 install_element(GSMNET_NODE, &cfg_net_pag_any_tch_cmd);
Harald Weltee87eb462009-08-07 13:29:14 +02002684
2685 install_element(GSMNET_NODE, &cfg_bts_cmd);
Harald Welte97ceef92009-08-06 19:06:46 +02002686 install_node(&bts_node, config_write_bts);
Harald Welte59b04682009-06-10 05:40:52 +08002687 install_default(BTS_NODE);
Harald Welte58ed1cb2010-05-14 18:59:17 +02002688 install_element(BTS_NODE, &ournode_exit_cmd);
Harald Weltedc82b9b2010-05-14 19:11:04 +02002689 install_element(BTS_NODE, &ournode_end_cmd);
Harald Welte59b04682009-06-10 05:40:52 +08002690 install_element(BTS_NODE, &cfg_bts_type_cmd);
Harald Welte8791dac2010-05-14 17:59:53 +02002691 install_element(BTS_NODE, &cfg_description_cmd);
2692 install_element(BTS_NODE, &cfg_no_description_cmd);
Harald Welte91afe4c2009-06-20 18:15:19 +02002693 install_element(BTS_NODE, &cfg_bts_band_cmd);
Holger Hans Peter Freythera098dfb2009-08-21 14:44:12 +02002694 install_element(BTS_NODE, &cfg_bts_ci_cmd);
Harald Welte59b04682009-06-10 05:40:52 +08002695 install_element(BTS_NODE, &cfg_bts_lac_cmd);
2696 install_element(BTS_NODE, &cfg_bts_tsc_cmd);
Harald Welte62868882009-08-08 16:12:58 +02002697 install_element(BTS_NODE, &cfg_bts_bsic_cmd);
Harald Welte59b04682009-06-10 05:40:52 +08002698 install_element(BTS_NODE, &cfg_bts_unit_id_cmd);
Harald Welte25572872009-10-20 00:22:00 +02002699 install_element(BTS_NODE, &cfg_bts_stream_id_cmd);
Harald Welte62868882009-08-08 16:12:58 +02002700 install_element(BTS_NODE, &cfg_bts_oml_e1_cmd);
2701 install_element(BTS_NODE, &cfg_bts_oml_e1_tei_cmd);
Harald Welte3e774612009-08-10 13:48:16 +02002702 install_element(BTS_NODE, &cfg_bts_challoc_cmd);
Sylvain Munaut8e2d8de2009-12-22 13:43:26 +01002703 install_element(BTS_NODE, &cfg_bts_rach_tx_integer_cmd);
2704 install_element(BTS_NODE, &cfg_bts_rach_max_trans_cmd);
Holger Hans Peter Freyther697ed2b2010-04-25 23:08:39 +08002705 install_element(BTS_NODE, &cfg_bts_rach_nm_b_thresh_cmd);
2706 install_element(BTS_NODE, &cfg_bts_rach_nm_ldavg_cmd);
Harald Welte (local)e19be3f2009-08-12 13:28:23 +02002707 install_element(BTS_NODE, &cfg_bts_cell_barred_cmd);
Holger Hans Peter Freyther440984b2010-05-14 00:39:19 +08002708 install_element(BTS_NODE, &cfg_bts_rach_ec_allowed_cmd);
Harald Welte (local)cbd46102009-08-13 10:14:26 +02002709 install_element(BTS_NODE, &cfg_bts_ms_max_power_cmd);
Harald Welte (local)b6ea7f72009-08-14 23:09:25 +02002710 install_element(BTS_NODE, &cfg_bts_per_loc_upd_cmd);
Harald Welteb761bf82009-12-12 18:17:25 +01002711 install_element(BTS_NODE, &cfg_bts_cell_resel_hyst_cmd);
2712 install_element(BTS_NODE, &cfg_bts_rxlev_acc_min_cmd);
Sylvain Munaut00d71462010-11-28 18:17:28 +01002713 install_element(BTS_NODE, &cfg_bts_cell_bar_qualify_cmd);
2714 install_element(BTS_NODE, &cfg_bts_cell_resel_ofs_cmd);
2715 install_element(BTS_NODE, &cfg_bts_temp_ofs_cmd);
2716 install_element(BTS_NODE, &cfg_bts_temp_ofs_inf_cmd);
2717 install_element(BTS_NODE, &cfg_bts_penalty_time_cmd);
2718 install_element(BTS_NODE, &cfg_bts_penalty_time_rsvd_cmd);
Harald Weltecb20b7a2010-04-18 15:51:20 +02002719 install_element(BTS_NODE, &cfg_bts_gprs_mode_cmd);
Harald Weltea9251762010-05-11 23:50:21 +02002720 install_element(BTS_NODE, &cfg_bts_gprs_ns_timer_cmd);
Harald Welte3055e332010-03-14 15:37:43 +08002721 install_element(BTS_NODE, &cfg_bts_gprs_rac_cmd);
2722 install_element(BTS_NODE, &cfg_bts_gprs_bvci_cmd);
Harald Weltea9251762010-05-11 23:50:21 +02002723 install_element(BTS_NODE, &cfg_bts_gprs_cell_timer_cmd);
Harald Welte4a048c52010-03-22 11:48:36 +08002724 install_element(BTS_NODE, &cfg_bts_gprs_nsei_cmd);
Harald Welte3055e332010-03-14 15:37:43 +08002725 install_element(BTS_NODE, &cfg_bts_gprs_nsvci_cmd);
Harald Welte410575a2010-03-14 23:30:30 +08002726 install_element(BTS_NODE, &cfg_bts_gprs_nsvc_lport_cmd);
2727 install_element(BTS_NODE, &cfg_bts_gprs_nsvc_rport_cmd);
2728 install_element(BTS_NODE, &cfg_bts_gprs_nsvc_rip_cmd);
Holger Hans Peter Freyther3112f672010-09-06 10:11:25 +08002729 install_element(BTS_NODE, &cfg_bts_pag_free_cmd);
Harald Welted8acf142010-07-30 11:50:09 +02002730 install_element(BTS_NODE, &cfg_bts_si_mode_cmd);
2731 install_element(BTS_NODE, &cfg_bts_si_static_cmd);
Harald Welteca46eff2011-01-11 23:44:56 +01002732 install_element(BTS_NODE, &cfg_bts_neigh_mode_cmd);
2733 install_element(BTS_NODE, &cfg_bts_neigh_cmd);
Harald Weltef989b782011-02-15 11:43:27 +01002734 install_element(BTS_NODE, &cfg_bts_si5_neigh_cmd);
Harald Welte59b04682009-06-10 05:40:52 +08002735
2736 install_element(BTS_NODE, &cfg_trx_cmd);
2737 install_node(&trx_node, dummy_config_write);
2738 install_default(TRX_NODE);
Harald Welte58ed1cb2010-05-14 18:59:17 +02002739 install_element(TRX_NODE, &ournode_exit_cmd);
Harald Weltedc82b9b2010-05-14 19:11:04 +02002740 install_element(TRX_NODE, &ournode_end_cmd);
Harald Welte59b04682009-06-10 05:40:52 +08002741 install_element(TRX_NODE, &cfg_trx_arfcn_cmd);
Harald Welte8791dac2010-05-14 17:59:53 +02002742 install_element(TRX_NODE, &cfg_description_cmd);
2743 install_element(TRX_NODE, &cfg_no_description_cmd);
Harald Welte (local)b709bfe2009-12-27 20:56:38 +01002744 install_element(TRX_NODE, &cfg_trx_nominal_power_cmd);
Harald Welte7f597bc2009-06-20 22:36:12 +02002745 install_element(TRX_NODE, &cfg_trx_max_power_red_cmd);
Harald Welte62868882009-08-08 16:12:58 +02002746 install_element(TRX_NODE, &cfg_trx_rsl_e1_cmd);
2747 install_element(TRX_NODE, &cfg_trx_rsl_e1_tei_cmd);
Holger Hans Peter Freyther1c8b4802009-11-11 11:54:24 +01002748 install_element(TRX_NODE, &cfg_trx_rf_locked_cmd);
Harald Welte59b04682009-06-10 05:40:52 +08002749
2750 install_element(TRX_NODE, &cfg_ts_cmd);
2751 install_node(&ts_node, dummy_config_write);
2752 install_default(TS_NODE);
Harald Welte58ed1cb2010-05-14 18:59:17 +02002753 install_element(TS_NODE, &ournode_exit_cmd);
Harald Weltedc82b9b2010-05-14 19:11:04 +02002754 install_element(TS_NODE, &ournode_end_cmd);
Harald Welte3ffe1b32009-08-07 00:25:23 +02002755 install_element(TS_NODE, &cfg_ts_pchan_cmd);
Harald Weltea42a93f2010-06-14 22:26:10 +02002756 install_element(TS_NODE, &cfg_ts_hopping_cmd);
Harald Welte67104d12009-09-12 13:05:33 +02002757 install_element(TS_NODE, &cfg_ts_hsn_cmd);
2758 install_element(TS_NODE, &cfg_ts_maio_cmd);
2759 install_element(TS_NODE, &cfg_ts_arfcn_add_cmd);
2760 install_element(TS_NODE, &cfg_ts_arfcn_del_cmd);
Harald Welte3ffe1b32009-08-07 00:25:23 +02002761 install_element(TS_NODE, &cfg_ts_e1_subslot_cmd);
Harald Welte59b04682009-06-10 05:40:52 +08002762
Holger Hans Peter Freyther07ff1c32010-10-26 09:40:13 +02002763 install_element(ENABLE_NODE, &drop_bts_cmd);
Harald Welte5213e992010-12-23 13:18:07 +01002764 install_element(ENABLE_NODE, &pdch_act_cmd);
Holger Hans Peter Freyther07ff1c32010-10-26 09:40:13 +02002765
Harald Welte63b964e2010-05-31 16:40:40 +02002766 abis_nm_vty_init();
Harald Welte1d5a2062011-02-12 14:42:59 +01002767 abis_om2k_vty_init();
Harald Weltee76bea02011-02-05 13:54:41 +01002768 e1inp_vty_init();
Harald Welte63b964e2010-05-31 16:40:40 +02002769
Harald Welte40152872010-05-16 20:52:23 +02002770 bsc_vty_init_extra();
Harald Welte59b04682009-06-10 05:40:52 +08002771
2772 return 0;
2773}