blob: e2ff43996501bc34ff758cdd5a22f58eb4707314 [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>
Harald Welte59b04682009-06-10 05:40:52 +080022
Harald Weltebd9591f2010-05-19 19:45:32 +020023#include <osmocom/vty/command.h>
24#include <osmocom/vty/buffer.h>
25#include <osmocom/vty/vty.h>
26#include <osmocom/vty/logging.h>
27#include <osmocom/vty/telnet_interface.h>
Harald Welte59b04682009-06-10 05:40:52 +080028
29#include <arpa/inet.h>
30
Pablo Neira Ayusodd5fff42011-03-22 16:47:59 +010031#include <osmocom/core/linuxlist.h>
Harald Welte59b04682009-06-10 05:40:52 +080032#include <openbsc/gsm_data.h>
Pablo Neira Ayuso42e41df2011-08-17 22:44:07 +020033#include <osmocom/abis/e1_input.h>
Harald Welte59b04682009-06-10 05:40:52 +080034#include <openbsc/abis_nm.h>
Harald Welte30f93fb2011-02-19 16:48:17 +010035#include <openbsc/abis_om2000.h>
Pablo Neira Ayusodd5fff42011-03-22 16:47:59 +010036#include <osmocom/core/utils.h>
37#include <osmocom/gsm/gsm_utils.h>
Harald Welte73e69942011-05-23 20:42:26 +020038#include <osmocom/gsm/abis_nm.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>
Pablo Neira Ayusodd5fff42011-03-22 16:47:59 +010042#include <osmocom/core/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>
Harald Welte64fcd772011-08-20 18:25:02 +020048#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 Welted9dea592011-03-04 13:53:51 +010053#include "../../bscconfig.h"
Harald Welte10c29f62010-05-16 19:20:24 +020054
Holger Hans Peter Freythere8127042011-10-03 23:42:06 +020055
56#define NETWORK_STR "Configure the GSM network\n"
57#define CODE_CMD_STR "Code commands\n"
58#define NAME_CMD_STR "Name Commands\n"
59#define NAME_STR "Name to use\n"
60#define LCHAN_NR_STR "Logical Channel Number\n"
61
62
Harald Welted6b62e32010-05-12 17:19:53 +000063/* FIXME: this should go to some common file */
64static const struct value_string gprs_ns_timer_strs[] = {
Harald Weltea9251762010-05-11 23:50:21 +020065 { 0, "tns-block" },
66 { 1, "tns-block-retries" },
67 { 2, "tns-reset" },
68 { 3, "tns-reset-retries" },
69 { 4, "tns-test" },
70 { 5, "tns-alive" },
71 { 6, "tns-alive-retries" },
72 { 0, NULL }
73};
74
Harald Welted6b62e32010-05-12 17:19:53 +000075static const struct value_string gprs_bssgp_cfg_strs[] = {
Harald Weltea9251762010-05-11 23:50:21 +020076 { 0, "blocking-timer" },
77 { 1, "blocking-retries" },
78 { 2, "unblocking-retries" },
79 { 3, "reset-timer" },
80 { 4, "reset-retries" },
81 { 5, "suspend-timer" },
82 { 6, "suspend-retries" },
83 { 7, "resume-timer" },
84 { 8, "resume-retries" },
85 { 9, "capability-update-timer" },
86 { 10, "capability-update-retries" },
87 { 0, NULL }
88};
89
Harald Weltef989b782011-02-15 11:43:27 +010090static const struct value_string bts_neigh_mode_strs[] = {
91 { NL_MODE_AUTOMATIC, "automatic" },
92 { NL_MODE_MANUAL, "manual" },
93 { NL_MODE_MANUAL_SI5SEP, "manual-si5" },
94 { 0, NULL }
95};
96
Harald Weltee87eb462009-08-07 13:29:14 +020097struct cmd_node net_node = {
98 GSMNET_NODE,
99 "%s(network)#",
100 1,
101};
102
Harald Welte59b04682009-06-10 05:40:52 +0800103struct cmd_node bts_node = {
104 BTS_NODE,
105 "%s(bts)#",
106 1,
107};
108
109struct cmd_node trx_node = {
110 TRX_NODE,
111 "%s(trx)#",
112 1,
113};
114
115struct cmd_node ts_node = {
116 TS_NODE,
117 "%s(ts)#",
118 1,
119};
120
Harald Welte61daf6d2010-05-27 13:39:40 +0200121extern struct gsm_network *bsc_gsmnet;
122
Harald Welte40152872010-05-16 20:52:23 +0200123struct gsm_network *gsmnet_from_vty(struct vty *v)
124{
Harald Welte61daf6d2010-05-27 13:39:40 +0200125 /* In case we read from the config file, the vty->priv cannot
126 * point to a struct telnet_connection, and thus conn->priv
127 * will not point to the gsm_network structure */
128#if 0
Harald Welte40152872010-05-16 20:52:23 +0200129 struct telnet_connection *conn = v->priv;
130 return (struct gsm_network *) conn->priv;
Harald Welte61daf6d2010-05-27 13:39:40 +0200131#else
132 return bsc_gsmnet;
133#endif
Harald Welte40152872010-05-16 20:52:23 +0200134}
135
Harald Welte59b04682009-06-10 05:40:52 +0800136static int dummy_config_write(struct vty *v)
137{
138 return CMD_SUCCESS;
139}
140
141static void net_dump_nmstate(struct vty *vty, struct gsm_nm_state *nms)
142{
143 vty_out(vty,"Oper '%s', Admin %u, Avail '%s'%s",
Harald Welte306a8892011-05-23 20:30:39 +0200144 abis_nm_opstate_name(nms->operational), nms->administrative,
145 abis_nm_avail_name(nms->availability), VTY_NEWLINE);
Harald Welte59b04682009-06-10 05:40:52 +0800146}
147
Harald Weltefe96f382009-12-22 13:09:29 +0100148static void dump_pchan_load_vty(struct vty *vty, char *prefix,
149 const struct pchan_load *pl)
150{
151 int i;
152
153 for (i = 0; i < ARRAY_SIZE(pl->pchan); i++) {
154 const struct load_counter *lc = &pl->pchan[i];
155 unsigned int percent;
156
157 if (lc->total == 0)
158 continue;
159
160 percent = (lc->used * 100) / lc->total;
161
162 vty_out(vty, "%s%20s: %3u%% (%u/%u)%s", prefix,
163 gsm_pchan_name(i), percent, lc->used, lc->total,
164 VTY_NEWLINE);
165 }
166}
167
Harald Welte59b04682009-06-10 05:40:52 +0800168static void net_dump_vty(struct vty *vty, struct gsm_network *net)
169{
Harald Weltefe96f382009-12-22 13:09:29 +0100170 struct pchan_load pl;
171
Harald Welte59b04682009-06-10 05:40:52 +0800172 vty_out(vty, "BSC is on Country Code %u, Network Code %u "
173 "and has %u BTS%s", net->country_code, net->network_code,
174 net->num_bts, VTY_NEWLINE);
175 vty_out(vty, " Long network name: '%s'%s",
176 net->name_long, VTY_NEWLINE);
177 vty_out(vty, " Short network name: '%s'%s",
178 net->name_short, VTY_NEWLINE);
Harald Welte (local)a59a27e2009-08-12 14:42:23 +0200179 vty_out(vty, " Authentication policy: %s%s",
180 gsm_auth_policy_name(net->auth_policy), VTY_NEWLINE);
Harald Welte59936d72009-11-18 20:33:19 +0100181 vty_out(vty, " Location updating reject cause: %u%s",
182 net->reject_cause, VTY_NEWLINE);
Harald Weltecca253a2009-08-30 15:47:06 +0900183 vty_out(vty, " Encryption: A5/%u%s", net->a5_encryption,
184 VTY_NEWLINE);
Holger Hans Peter Freyther96c89822009-11-16 17:12:38 +0100185 vty_out(vty, " NECI (TCH/H): %u%s", net->neci,
186 VTY_NEWLINE);
Holger Hans Peter Freytherb6b9d702010-09-06 09:41:50 +0800187 vty_out(vty, " Use TCH for Paging any: %d%s", net->pag_any_tch,
188 VTY_NEWLINE);
Harald Welte52af1952009-12-13 10:53:12 +0100189 vty_out(vty, " RRLP Mode: %s%s", rrlp_mode_name(net->rrlp.mode),
190 VTY_NEWLINE);
Harald Weltea310f3e2009-12-14 09:00:24 +0100191 vty_out(vty, " MM Info: %s%s", net->send_mm_info ? "On" : "Off",
192 VTY_NEWLINE);
Harald Welte0af9c9f2009-12-19 21:41:52 +0100193 vty_out(vty, " Handover: %s%s", net->handover.active ? "On" : "Off",
194 VTY_NEWLINE);
Harald Weltefe96f382009-12-22 13:09:29 +0100195 network_chan_load(&pl, net);
196 vty_out(vty, " Current Channel Load:%s", VTY_NEWLINE);
197 dump_pchan_load_vty(vty, " ", &pl);
Holger Hans Peter Freytherd0146922011-02-24 14:19:14 +0100198
199 /* show rf */
Holger Hans Peter Freyther410ee272011-06-04 09:32:35 +0200200 if (net->msc_data && net->msc_data->rf_ctrl)
Holger Hans Peter Freytherd0146922011-02-24 14:19:14 +0100201 vty_out(vty, " Last RF Command: %s%s",
Holger Hans Peter Freyther410ee272011-06-04 09:32:35 +0200202 net->msc_data->rf_ctrl->last_state_command,
Holger Hans Peter Freytherd0146922011-02-24 14:19:14 +0100203 VTY_NEWLINE);
Harald Welte59b04682009-06-10 05:40:52 +0800204}
205
206DEFUN(show_net, show_net_cmd, "show network",
207 SHOW_STR "Display information about a GSM NETWORK\n")
208{
Harald Welte40152872010-05-16 20:52:23 +0200209 struct gsm_network *net = gsmnet_from_vty(vty);
Harald Welte59b04682009-06-10 05:40:52 +0800210 net_dump_vty(vty, net);
211
212 return CMD_SUCCESS;
213}
214
215static void e1isl_dump_vty(struct vty *vty, struct e1inp_sign_link *e1l)
216{
217 struct e1inp_line *line;
218
219 if (!e1l) {
220 vty_out(vty, " None%s", VTY_NEWLINE);
221 return;
222 }
223
224 line = e1l->ts->line;
225
226 vty_out(vty, " E1 Line %u, Type %s: Timeslot %u, Mode %s%s",
227 line->num, line->driver->name, e1l->ts->num,
228 e1inp_signtype_name(e1l->type), VTY_NEWLINE);
229 vty_out(vty, " E1 TEI %u, SAPI %u%s",
230 e1l->tei, e1l->sapi, VTY_NEWLINE);
231}
232
233static void bts_dump_vty(struct vty *vty, struct gsm_bts *bts)
234{
Harald Weltefe96f382009-12-22 13:09:29 +0100235 struct pchan_load pl;
236
Holger Hans Peter Freythera098dfb2009-08-21 14:44:12 +0200237 vty_out(vty, "BTS %u is of %s type in band %s, has CI %u LAC %u, "
Harald Welte91afe4c2009-06-20 18:15:19 +0200238 "BSIC %u, TSC %u and %u TRX%s",
239 bts->nr, btstype2str(bts->type), gsm_band_name(bts->band),
Holger Hans Peter Freythera098dfb2009-08-21 14:44:12 +0200240 bts->cell_identity,
Holger Hans Peter Freyther71135142010-03-29 08:47:44 +0200241 bts->location_area_code, bts->bsic, bts->tsc,
Harald Welte91afe4c2009-06-20 18:15:19 +0200242 bts->num_trx, VTY_NEWLINE);
Harald Welte8791dac2010-05-14 17:59:53 +0200243 vty_out(vty, "Description: %s%s",
244 bts->description ? bts->description : "(null)", VTY_NEWLINE);
Harald Welte8e9d1792009-12-12 15:38:16 +0100245 vty_out(vty, "MS Max power: %u dBm%s", bts->ms_max_power, VTY_NEWLINE);
Harald Welteb761bf82009-12-12 18:17:25 +0100246 vty_out(vty, "Minimum Rx Level for Access: %i dBm%s",
Harald Welte8e9d1792009-12-12 15:38:16 +0100247 rxlev2dbm(bts->si_common.cell_sel_par.rxlev_acc_min),
248 VTY_NEWLINE);
249 vty_out(vty, "Cell Reselection Hysteresis: %u dBm%s",
Harald Welteb761bf82009-12-12 18:17:25 +0100250 bts->si_common.cell_sel_par.cell_resel_hyst*2, VTY_NEWLINE);
Sylvain Munaut8e2d8de2009-12-22 13:43:26 +0100251 vty_out(vty, "RACH TX-Integer: %u%s", bts->si_common.rach_control.tx_integer,
252 VTY_NEWLINE);
253 vty_out(vty, "RACH Max transmissions: %u%s",
254 rach_max_trans_raw2val(bts->si_common.rach_control.max_trans),
255 VTY_NEWLINE);
Harald Welte8c973ba2009-12-21 23:08:18 +0100256 if (bts->si_common.rach_control.cell_bar)
Harald Welte (local)e19be3f2009-08-12 13:28:23 +0200257 vty_out(vty, " CELL IS BARRED%s", VTY_NEWLINE);
Harald Welted8acf142010-07-30 11:50:09 +0200258 vty_out(vty, "System Information present: 0x%08x, static: 0x%08x%s",
259 bts->si_valid, bts->si_mode_static, VTY_NEWLINE);
Harald Welte59b04682009-06-10 05:40:52 +0800260 if (is_ipaccess_bts(bts))
Harald Welte25572872009-10-20 00:22:00 +0200261 vty_out(vty, " Unit ID: %u/%u/0, OML Stream ID 0x%02x%s",
Harald Welte59b04682009-06-10 05:40:52 +0800262 bts->ip_access.site_id, bts->ip_access.bts_id,
Harald Welte25572872009-10-20 00:22:00 +0200263 bts->oml_tei, VTY_NEWLINE);
Harald Welte08011e22011-03-04 13:41:31 +0100264 else if (bts->type == GSM_BTS_TYPE_HSL_FEMTO)
265 vty_out(vty, " Serial Number: %lu%s", bts->hsl.serno, VTY_NEWLINE);
Harald Welte59b04682009-06-10 05:40:52 +0800266 vty_out(vty, " NM State: ");
Harald Welte69f6f812011-05-30 12:07:53 +0200267 net_dump_nmstate(vty, &bts->mo.nm_state);
Harald Welte59b04682009-06-10 05:40:52 +0800268 vty_out(vty, " Site Mgr NM State: ");
Harald Welte69f6f812011-05-30 12:07:53 +0200269 net_dump_nmstate(vty, &bts->site_mgr.mo.nm_state);
Holger Hans Peter Freyther914ff192011-04-26 15:52:34 +0200270 vty_out(vty, " Paging: %u pending requests, %u free slots%s",
271 paging_pending_requests_nr(bts),
Harald Welte59b04682009-06-10 05:40:52 +0800272 bts->paging.available_slots, VTY_NEWLINE);
Holger Hans Peter Freytherb5c79c92010-11-25 16:28:45 +0100273 if (is_ipaccess_bts(bts)) {
274 vty_out(vty, " OML Link state: %s.%s",
275 bts->oml_link ? "connected" : "disconnected", VTY_NEWLINE);
276 } else {
Harald Welte25572872009-10-20 00:22:00 +0200277 vty_out(vty, " E1 Signalling Link:%s", VTY_NEWLINE);
278 e1isl_dump_vty(vty, bts->oml_link);
279 }
Holger Hans Peter Freytherb5c79c92010-11-25 16:28:45 +0100280
281 /* FIXME: chan_desc */
Harald Weltefe96f382009-12-22 13:09:29 +0100282 memset(&pl, 0, sizeof(pl));
283 bts_chan_load(&pl, bts);
284 vty_out(vty, " Current Channel Load:%s", VTY_NEWLINE);
285 dump_pchan_load_vty(vty, " ", &pl);
Harald Welte59b04682009-06-10 05:40:52 +0800286}
287
288DEFUN(show_bts, show_bts_cmd, "show bts [number]",
289 SHOW_STR "Display information about a BTS\n"
290 "BTS number")
291{
Harald Welte40152872010-05-16 20:52:23 +0200292 struct gsm_network *net = gsmnet_from_vty(vty);
Harald Welte59b04682009-06-10 05:40:52 +0800293 int bts_nr;
294
295 if (argc != 0) {
296 /* use the BTS number that the user has specified */
297 bts_nr = atoi(argv[0]);
Harald Welteda5db862010-12-24 12:24:03 +0100298 if (bts_nr >= net->num_bts) {
Harald Welte59b04682009-06-10 05:40:52 +0800299 vty_out(vty, "%% can't find BTS '%s'%s", argv[0],
300 VTY_NEWLINE);
301 return CMD_WARNING;
302 }
Harald Weltee712a5f2009-06-21 16:17:15 +0200303 bts_dump_vty(vty, gsm_bts_num(net, bts_nr));
Harald Welte59b04682009-06-10 05:40:52 +0800304 return CMD_SUCCESS;
305 }
306 /* print all BTS's */
307 for (bts_nr = 0; bts_nr < net->num_bts; bts_nr++)
Harald Weltee712a5f2009-06-21 16:17:15 +0200308 bts_dump_vty(vty, gsm_bts_num(net, bts_nr));
Harald Welte59b04682009-06-10 05:40:52 +0800309
310 return CMD_SUCCESS;
311}
312
Harald Welte62868882009-08-08 16:12:58 +0200313/* utility functions */
314static void parse_e1_link(struct gsm_e1_subslot *e1_link, const char *line,
315 const char *ts, const char *ss)
316{
317 e1_link->e1_nr = atoi(line);
318 e1_link->e1_ts = atoi(ts);
319 if (!strcmp(ss, "full"))
320 e1_link->e1_ts_ss = 255;
321 else
322 e1_link->e1_ts_ss = atoi(ss);
323}
324
325static void config_write_e1_link(struct vty *vty, struct gsm_e1_subslot *e1_link,
326 const char *prefix)
327{
328 if (!e1_link->e1_ts)
329 return;
330
331 if (e1_link->e1_ts_ss == 255)
332 vty_out(vty, "%se1 line %u timeslot %u sub-slot full%s",
333 prefix, e1_link->e1_nr, e1_link->e1_ts, VTY_NEWLINE);
334 else
335 vty_out(vty, "%se1 line %u timeslot %u sub-slot %u%s",
336 prefix, e1_link->e1_nr, e1_link->e1_ts,
337 e1_link->e1_ts_ss, VTY_NEWLINE);
338}
339
340
Harald Welte97ceef92009-08-06 19:06:46 +0200341static void config_write_ts_single(struct vty *vty, struct gsm_bts_trx_ts *ts)
342{
Harald Welte62868882009-08-08 16:12:58 +0200343 vty_out(vty, " timeslot %u%s", ts->nr, VTY_NEWLINE);
Harald Welte85771a42011-05-30 12:09:13 +0200344 if (ts->tsc != -1 && ts->tsc != ts->trx->bts->tsc)
345 vty_out(vty, " training_sequence_code %u%s", ts->tsc, VTY_NEWLINE);
Harald Welte62868882009-08-08 16:12:58 +0200346 if (ts->pchan != GSM_PCHAN_NONE)
347 vty_out(vty, " phys_chan_config %s%s",
348 gsm_pchan_name(ts->pchan), VTY_NEWLINE);
Harald Weltea42a93f2010-06-14 22:26:10 +0200349 vty_out(vty, " hopping enabled %u%s",
350 ts->hopping.enabled, VTY_NEWLINE);
351 if (ts->hopping.enabled) {
352 unsigned int i;
353 vty_out(vty, " hopping sequence-number %u%s",
Harald Welte67104d12009-09-12 13:05:33 +0200354 ts->hopping.hsn, VTY_NEWLINE);
Harald Weltea42a93f2010-06-14 22:26:10 +0200355 vty_out(vty, " hopping maio %u%s",
Harald Welte67104d12009-09-12 13:05:33 +0200356 ts->hopping.maio, VTY_NEWLINE);
Harald Weltea42a93f2010-06-14 22:26:10 +0200357 for (i = 0; i < ts->hopping.arfcns.data_len*8; i++) {
358 if (!bitvec_get_bit_pos(&ts->hopping.arfcns, i))
359 continue;
360 vty_out(vty, " hopping arfcn add %u%s",
361 i, VTY_NEWLINE);
362 }
Harald Welteff598092010-12-24 12:07:07 +0100363 }
Harald Welte62868882009-08-08 16:12:58 +0200364 config_write_e1_link(vty, &ts->e1_link, " ");
Harald Weltec02789e2011-02-14 16:15:21 +0100365
366 if (ts->trx->bts->model->config_write_ts)
367 ts->trx->bts->model->config_write_ts(vty, ts);
Harald Welte97ceef92009-08-06 19:06:46 +0200368}
369
370static void config_write_trx_single(struct vty *vty, struct gsm_bts_trx *trx)
371{
372 int i;
373
Harald Weltee87eb462009-08-07 13:29:14 +0200374 vty_out(vty, " trx %u%s", trx->nr, VTY_NEWLINE);
Harald Welte8791dac2010-05-14 17:59:53 +0200375 if (trx->description)
376 vty_out(vty, " description %s%s", trx->description,
377 VTY_NEWLINE);
Holger Hans Peter Freyther32be2aa2010-04-17 06:42:07 +0200378 vty_out(vty, " rf_locked %u%s",
Harald Welte69f6f812011-05-30 12:07:53 +0200379 trx->mo.nm_state.administrative == NM_STATE_LOCKED ? 1 : 0,
Holger Hans Peter Freyther32be2aa2010-04-17 06:42:07 +0200380 VTY_NEWLINE);
Harald Weltee87eb462009-08-07 13:29:14 +0200381 vty_out(vty, " arfcn %u%s", trx->arfcn, VTY_NEWLINE);
Harald Welte (local)b709bfe2009-12-27 20:56:38 +0100382 vty_out(vty, " nominal power %u%s", trx->nominal_power, VTY_NEWLINE);
Harald Weltee87eb462009-08-07 13:29:14 +0200383 vty_out(vty, " max_power_red %u%s", trx->max_power_red, VTY_NEWLINE);
Harald Welte62868882009-08-08 16:12:58 +0200384 config_write_e1_link(vty, &trx->rsl_e1_link, " rsl ");
385 vty_out(vty, " rsl e1 tei %u%s", trx->rsl_tei, VTY_NEWLINE);
Harald Welte97ceef92009-08-06 19:06:46 +0200386
Harald Weltec02789e2011-02-14 16:15:21 +0100387 if (trx->bts->model->config_write_trx)
388 trx->bts->model->config_write_trx(vty, trx);
389
Harald Welte97ceef92009-08-06 19:06:46 +0200390 for (i = 0; i < TRX_NR_TS; i++)
391 config_write_ts_single(vty, &trx->ts[i]);
392}
393
Harald Weltea9251762010-05-11 23:50:21 +0200394static void config_write_bts_gprs(struct vty *vty, struct gsm_bts *bts)
395{
396 unsigned int i;
397 vty_out(vty, " gprs mode %s%s", bts_gprs_mode_name(bts->gprs.mode),
398 VTY_NEWLINE);
399 if (bts->gprs.mode == BTS_GPRS_NONE)
400 return;
401
402 vty_out(vty, " gprs routing area %u%s", bts->gprs.rac,
403 VTY_NEWLINE);
404 vty_out(vty, " gprs cell bvci %u%s", bts->gprs.cell.bvci,
405 VTY_NEWLINE);
406 for (i = 0; i < ARRAY_SIZE(bts->gprs.cell.timer); i++)
407 vty_out(vty, " gprs cell timer %s %u%s",
408 get_value_string(gprs_bssgp_cfg_strs, i),
409 bts->gprs.cell.timer[i], VTY_NEWLINE);
410 vty_out(vty, " gprs nsei %u%s", bts->gprs.nse.nsei,
411 VTY_NEWLINE);
412 for (i = 0; i < ARRAY_SIZE(bts->gprs.nse.timer); i++)
413 vty_out(vty, " gprs ns timer %s %u%s",
414 get_value_string(gprs_ns_timer_strs, i),
415 bts->gprs.nse.timer[i], VTY_NEWLINE);
416 for (i = 0; i < ARRAY_SIZE(bts->gprs.nsvc); i++) {
417 struct gsm_bts_gprs_nsvc *nsvc =
418 &bts->gprs.nsvc[i];
419 struct in_addr ia;
420
421 ia.s_addr = htonl(nsvc->remote_ip);
422 vty_out(vty, " gprs nsvc %u nsvci %u%s", i,
423 nsvc->nsvci, VTY_NEWLINE);
424 vty_out(vty, " gprs nsvc %u local udp port %u%s", i,
425 nsvc->local_port, VTY_NEWLINE);
426 vty_out(vty, " gprs nsvc %u remote udp port %u%s", i,
427 nsvc->remote_port, VTY_NEWLINE);
428 vty_out(vty, " gprs nsvc %u remote ip %s%s", i,
429 inet_ntoa(ia), VTY_NEWLINE);
430 }
431}
432
Harald Welte97ceef92009-08-06 19:06:46 +0200433static void config_write_bts_single(struct vty *vty, struct gsm_bts *bts)
434{
435 struct gsm_bts_trx *trx;
Harald Welted8acf142010-07-30 11:50:09 +0200436 int i;
Harald Welte97ceef92009-08-06 19:06:46 +0200437
Harald Weltee87eb462009-08-07 13:29:14 +0200438 vty_out(vty, " bts %u%s", bts->nr, VTY_NEWLINE);
439 vty_out(vty, " type %s%s", btstype2str(bts->type), VTY_NEWLINE);
Harald Welte8791dac2010-05-14 17:59:53 +0200440 if (bts->description)
441 vty_out(vty, " description %s%s", bts->description, VTY_NEWLINE);
Harald Weltee87eb462009-08-07 13:29:14 +0200442 vty_out(vty, " band %s%s", gsm_band_name(bts->band), VTY_NEWLINE);
Holger Hans Peter Freyther6d82b7c2009-11-19 16:38:49 +0100443 vty_out(vty, " cell_identity %u%s", bts->cell_identity, VTY_NEWLINE);
Harald Weltee87eb462009-08-07 13:29:14 +0200444 vty_out(vty, " location_area_code %u%s", bts->location_area_code,
Harald Welte97ceef92009-08-06 19:06:46 +0200445 VTY_NEWLINE);
Harald Weltee87eb462009-08-07 13:29:14 +0200446 vty_out(vty, " training_sequence_code %u%s", bts->tsc, VTY_NEWLINE);
447 vty_out(vty, " base_station_id_code %u%s", bts->bsic, VTY_NEWLINE);
Harald Welte (local)cbd46102009-08-13 10:14:26 +0200448 vty_out(vty, " ms max power %u%s", bts->ms_max_power, VTY_NEWLINE);
Harald Welteb761bf82009-12-12 18:17:25 +0100449 vty_out(vty, " cell reselection hysteresis %u%s",
450 bts->si_common.cell_sel_par.cell_resel_hyst*2, VTY_NEWLINE);
451 vty_out(vty, " rxlev access min %u%s",
452 bts->si_common.cell_sel_par.rxlev_acc_min, VTY_NEWLINE);
Sylvain Munaut00d71462010-11-28 18:17:28 +0100453
454 if (bts->si_common.cell_ro_sel_par.present) {
455 struct gsm48_si_selection_params *sp;
456 sp = &bts->si_common.cell_ro_sel_par;
457
458 if (sp->cbq)
459 vty_out(vty, " cell bar qualify %u%s",
460 sp->cbq, VTY_NEWLINE);
461
462 if (sp->cell_resel_off)
463 vty_out(vty, " cell reselection offset %u%s",
464 sp->cell_resel_off*2, VTY_NEWLINE);
465
466 if (sp->temp_offs == 7)
467 vty_out(vty, " temporary offset infinite%s",
468 VTY_NEWLINE);
469 else if (sp->temp_offs)
470 vty_out(vty, " temporary offset %u%s",
471 sp->temp_offs*10, VTY_NEWLINE);
472
473 if (sp->penalty_time == 31)
474 vty_out(vty, " penalty time reserved%s",
475 VTY_NEWLINE);
476 else if (sp->penalty_time)
477 vty_out(vty, " penalty time %u%s",
478 (sp->penalty_time*20)+20, VTY_NEWLINE);
479 }
480
Harald Weltea54a2bb2009-12-01 18:04:30 +0530481 if (bts->si_common.chan_desc.t3212)
Harald Welte (local)b6ea7f72009-08-14 23:09:25 +0200482 vty_out(vty, " periodic location update %u%s",
Dieter Spaarb0f746d2010-10-05 21:10:55 +0200483 bts->si_common.chan_desc.t3212 * 6, VTY_NEWLINE);
Harald Welte3e774612009-08-10 13:48:16 +0200484 vty_out(vty, " channel allocator %s%s",
485 bts->chan_alloc_reverse ? "descending" : "ascending",
486 VTY_NEWLINE);
Sylvain Munaut8e2d8de2009-12-22 13:43:26 +0100487 vty_out(vty, " rach tx integer %u%s",
488 bts->si_common.rach_control.tx_integer, VTY_NEWLINE);
489 vty_out(vty, " rach max transmission %u%s",
490 rach_max_trans_raw2val(bts->si_common.rach_control.max_trans),
491 VTY_NEWLINE);
Holger Hans Peter Freyther697ed2b2010-04-25 23:08:39 +0800492
493 if (bts->rach_b_thresh != -1)
494 vty_out(vty, " rach nm busy threshold %u%s",
495 bts->rach_b_thresh, VTY_NEWLINE);
496 if (bts->rach_ldavg_slots != -1)
497 vty_out(vty, " rach nm load average %u%s",
498 bts->rach_ldavg_slots, VTY_NEWLINE);
Harald Welte8c973ba2009-12-21 23:08:18 +0100499 if (bts->si_common.rach_control.cell_bar)
Harald Welte (local)e19be3f2009-08-12 13:28:23 +0200500 vty_out(vty, " cell barred 1%s", VTY_NEWLINE);
Holger Hans Peter Freyther440984b2010-05-14 00:39:19 +0800501 if ((bts->si_common.rach_control.t2 & 0x4) == 0)
502 vty_out(vty, " rach emergency call allowed 1%s", VTY_NEWLINE);
Harald Welted8acf142010-07-30 11:50:09 +0200503 for (i = SYSINFO_TYPE_1; i < _MAX_SYSINFO_TYPE; i++) {
504 if (bts->si_mode_static & (1 << i)) {
505 vty_out(vty, " system-information %s mode static%s",
506 get_value_string(osmo_sitype_strs, i), VTY_NEWLINE);
507 vty_out(vty, " system-information %s static %s%s",
508 get_value_string(osmo_sitype_strs, i),
Pablo Neira Ayusob1d5a692011-05-07 12:12:48 +0200509 osmo_osmo_hexdump_nospc(bts->si_buf[i], sizeof(bts->si_buf[i])),
Harald Welted8acf142010-07-30 11:50:09 +0200510 VTY_NEWLINE);
511 }
512 }
Harald Welte08011e22011-03-04 13:41:31 +0100513 switch (bts->type) {
514 case GSM_BTS_TYPE_NANOBTS:
Harald Weltee87eb462009-08-07 13:29:14 +0200515 vty_out(vty, " ip.access unit_id %u %u%s",
Harald Welte3ffe1b32009-08-07 00:25:23 +0200516 bts->ip_access.site_id, bts->ip_access.bts_id, VTY_NEWLINE);
Pablo Neira Ayuso42e41df2011-08-17 22:44:07 +0200517 vty_out(vty, " oml ip.access stream_id %u line %u%s",
518 bts->oml_tei, bts->oml_e1_link.e1_nr, VTY_NEWLINE);
Harald Welte08011e22011-03-04 13:41:31 +0100519 break;
520 case GSM_BTS_TYPE_HSL_FEMTO:
521 vty_out(vty, " hsl serial-number %lu%s", bts->hsl.serno, VTY_NEWLINE);
Pablo Neira Ayuso42e41df2011-08-17 22:44:07 +0200522 vty_out(vty, " oml hsl line %u%s",
523 bts->oml_e1_link.e1_nr, VTY_NEWLINE);
Harald Welte08011e22011-03-04 13:41:31 +0100524 break;
525 default:
Harald Welte62868882009-08-08 16:12:58 +0200526 config_write_e1_link(vty, &bts->oml_e1_link, " oml ");
527 vty_out(vty, " oml e1 tei %u%s", bts->oml_tei, VTY_NEWLINE);
Harald Welte08011e22011-03-04 13:41:31 +0100528 break;
Harald Welte62868882009-08-08 16:12:58 +0200529 }
Holger Hans Peter Freyther3112f672010-09-06 10:11:25 +0800530
531 /* if we have a limit, write it */
532 if (bts->paging.free_chans_need >= 0)
533 vty_out(vty, " paging free %d%s", bts->paging.free_chans_need, VTY_NEWLINE);
534
Harald Welteca46eff2011-01-11 23:44:56 +0100535 vty_out(vty, " neighbor-list mode %s%s",
Harald Weltef989b782011-02-15 11:43:27 +0100536 get_value_string(bts_neigh_mode_strs, bts->neigh_list_manual_mode), VTY_NEWLINE);
537 if (bts->neigh_list_manual_mode != NL_MODE_AUTOMATIC) {
Harald Welteca46eff2011-01-11 23:44:56 +0100538 for (i = 0; i < 1024; i++) {
539 if (bitvec_get_bit_pos(&bts->si_common.neigh_list, i))
540 vty_out(vty, " neighbor-list add arfcn %u%s",
541 i, VTY_NEWLINE);
542 }
543 }
Harald Weltef989b782011-02-15 11:43:27 +0100544 if (bts->neigh_list_manual_mode == NL_MODE_MANUAL_SI5SEP) {
545 for (i = 0; i < 1024; i++) {
546 if (bitvec_get_bit_pos(&bts->si_common.si5_neigh_list, i))
547 vty_out(vty, " si5 neighbor-list add arfcn %u%s",
548 i, VTY_NEWLINE);
549 }
550 }
Harald Welteca46eff2011-01-11 23:44:56 +0100551
Harald Weltea9251762010-05-11 23:50:21 +0200552 config_write_bts_gprs(vty, bts);
Harald Welte97ceef92009-08-06 19:06:46 +0200553
Harald Weltec02789e2011-02-14 16:15:21 +0100554 if (bts->model->config_write_bts)
555 bts->model->config_write_bts(vty, bts);
556
Harald Welte97ceef92009-08-06 19:06:46 +0200557 llist_for_each_entry(trx, &bts->trx_list, list)
558 config_write_trx_single(vty, trx);
559}
560
561static int config_write_bts(struct vty *v)
562{
Harald Welte40152872010-05-16 20:52:23 +0200563 struct gsm_network *gsmnet = gsmnet_from_vty(v);
Harald Welte97ceef92009-08-06 19:06:46 +0200564 struct gsm_bts *bts;
565
566 llist_for_each_entry(bts, &gsmnet->bts_list, list)
567 config_write_bts_single(v, bts);
568
569 return CMD_SUCCESS;
570}
571
Harald Weltee87eb462009-08-07 13:29:14 +0200572static int config_write_net(struct vty *vty)
573{
Harald Welte40152872010-05-16 20:52:23 +0200574 struct gsm_network *gsmnet = gsmnet_from_vty(vty);
575
Harald Weltee87eb462009-08-07 13:29:14 +0200576 vty_out(vty, "network%s", VTY_NEWLINE);
Harald Welte62868882009-08-08 16:12:58 +0200577 vty_out(vty, " network country code %u%s", gsmnet->country_code, VTY_NEWLINE);
Harald Weltee87eb462009-08-07 13:29:14 +0200578 vty_out(vty, " mobile network code %u%s", gsmnet->network_code, VTY_NEWLINE);
Harald Welte62868882009-08-08 16:12:58 +0200579 vty_out(vty, " short name %s%s", gsmnet->name_short, VTY_NEWLINE);
580 vty_out(vty, " long name %s%s", gsmnet->name_long, VTY_NEWLINE);
Harald Welte (local)a59a27e2009-08-12 14:42:23 +0200581 vty_out(vty, " auth policy %s%s", gsm_auth_policy_name(gsmnet->auth_policy), VTY_NEWLINE);
Harald Welte59936d72009-11-18 20:33:19 +0100582 vty_out(vty, " location updating reject cause %u%s",
583 gsmnet->reject_cause, VTY_NEWLINE);
Harald Weltecca253a2009-08-30 15:47:06 +0900584 vty_out(vty, " encryption a5 %u%s", gsmnet->a5_encryption, VTY_NEWLINE);
Holger Hans Peter Freyther6b4f5462009-11-19 16:37:48 +0100585 vty_out(vty, " neci %u%s", gsmnet->neci, VTY_NEWLINE);
Holger Hans Peter Freytherb6b9d702010-09-06 09:41:50 +0800586 vty_out(vty, " paging any use tch %d%s", gsmnet->pag_any_tch, VTY_NEWLINE);
Harald Welte52af1952009-12-13 10:53:12 +0100587 vty_out(vty, " rrlp mode %s%s", rrlp_mode_name(gsmnet->rrlp.mode),
588 VTY_NEWLINE);
Harald Weltea310f3e2009-12-14 09:00:24 +0100589 vty_out(vty, " mm info %u%s", gsmnet->send_mm_info, VTY_NEWLINE);
Harald Welte0af9c9f2009-12-19 21:41:52 +0100590 vty_out(vty, " handover %u%s", gsmnet->handover.active, VTY_NEWLINE);
Harald Weltea8062f12009-12-21 16:51:50 +0100591 vty_out(vty, " handover window rxlev averaging %u%s",
592 gsmnet->handover.win_rxlev_avg, VTY_NEWLINE);
593 vty_out(vty, " handover window rxqual averaging %u%s",
594 gsmnet->handover.win_rxqual_avg, VTY_NEWLINE);
595 vty_out(vty, " handover window rxlev neighbor averaging %u%s",
596 gsmnet->handover.win_rxlev_avg_neigh, VTY_NEWLINE);
597 vty_out(vty, " handover power budget interval %u%s",
598 gsmnet->handover.pwr_interval, VTY_NEWLINE);
599 vty_out(vty, " handover power budget hysteresis %u%s",
600 gsmnet->handover.pwr_hysteresis, VTY_NEWLINE);
601 vty_out(vty, " handover maximum distance %u%s",
602 gsmnet->handover.max_distance, VTY_NEWLINE);
Holger Hans Peter Freyther26ba2e72009-11-21 21:18:38 +0100603 vty_out(vty, " timer t3101 %u%s", gsmnet->T3101, VTY_NEWLINE);
Holger Hans Peter Freyther89733862009-11-21 21:42:26 +0100604 vty_out(vty, " timer t3103 %u%s", gsmnet->T3103, VTY_NEWLINE);
605 vty_out(vty, " timer t3105 %u%s", gsmnet->T3105, VTY_NEWLINE);
606 vty_out(vty, " timer t3107 %u%s", gsmnet->T3107, VTY_NEWLINE);
607 vty_out(vty, " timer t3109 %u%s", gsmnet->T3109, VTY_NEWLINE);
608 vty_out(vty, " timer t3111 %u%s", gsmnet->T3111, VTY_NEWLINE);
609 vty_out(vty, " timer t3113 %u%s", gsmnet->T3113, VTY_NEWLINE);
610 vty_out(vty, " timer t3115 %u%s", gsmnet->T3115, VTY_NEWLINE);
611 vty_out(vty, " timer t3117 %u%s", gsmnet->T3117, VTY_NEWLINE);
612 vty_out(vty, " timer t3119 %u%s", gsmnet->T3119, VTY_NEWLINE);
Harald Weltea00fdd72010-12-23 14:39:29 +0100613 vty_out(vty, " timer t3122 %u%s", gsmnet->T3122, VTY_NEWLINE);
Holger Hans Peter Freyther89733862009-11-21 21:42:26 +0100614 vty_out(vty, " timer t3141 %u%s", gsmnet->T3141, VTY_NEWLINE);
Harald Weltef41bfd52010-12-15 15:34:23 +0100615 vty_out(vty, " dtx-used %u%s", gsmnet->dtx_enabled, VTY_NEWLINE);
Holger Hans Peter Freyther68b21e12010-12-22 16:26:04 +0100616 vty_out(vty, " subscriber-keep-in-ram %d%s",
617 gsmnet->keep_subscr, VTY_NEWLINE);
Harald Weltee87eb462009-08-07 13:29:14 +0200618
619 return CMD_SUCCESS;
620}
Harald Welte97ceef92009-08-06 19:06:46 +0200621
Harald Welte59b04682009-06-10 05:40:52 +0800622static void trx_dump_vty(struct vty *vty, struct gsm_bts_trx *trx)
623{
624 vty_out(vty, "TRX %u of BTS %u is on ARFCN %u%s",
625 trx->nr, trx->bts->nr, trx->arfcn, VTY_NEWLINE);
Harald Welte8791dac2010-05-14 17:59:53 +0200626 vty_out(vty, "Description: %s%s",
627 trx->description ? trx->description : "(null)", VTY_NEWLINE);
Harald Welte91afe4c2009-06-20 18:15:19 +0200628 vty_out(vty, " RF Nominal Power: %d dBm, reduced by %u dB, "
Harald Welte62868882009-08-08 16:12:58 +0200629 "resulting BS power: %d dBm%s",
Harald Welte91afe4c2009-06-20 18:15:19 +0200630 trx->nominal_power, trx->max_power_red,
Harald Welte62868882009-08-08 16:12:58 +0200631 trx->nominal_power - trx->max_power_red, VTY_NEWLINE);
Harald Welte59b04682009-06-10 05:40:52 +0800632 vty_out(vty, " NM State: ");
Harald Welte69f6f812011-05-30 12:07:53 +0200633 net_dump_nmstate(vty, &trx->mo.nm_state);
Harald Welte59b04682009-06-10 05:40:52 +0800634 vty_out(vty, " Baseband Transceiver NM State: ");
Harald Welte69f6f812011-05-30 12:07:53 +0200635 net_dump_nmstate(vty, &trx->bb_transc.mo.nm_state);
Harald Welte25572872009-10-20 00:22:00 +0200636 if (is_ipaccess_bts(trx->bts)) {
637 vty_out(vty, " ip.access stream ID: 0x%02x%s",
638 trx->rsl_tei, VTY_NEWLINE);
639 } else {
640 vty_out(vty, " E1 Signalling Link:%s", VTY_NEWLINE);
641 e1isl_dump_vty(vty, trx->rsl_link);
642 }
Harald Welte59b04682009-06-10 05:40:52 +0800643}
644
645DEFUN(show_trx,
646 show_trx_cmd,
647 "show trx [bts_nr] [trx_nr]",
Harald Welte9e002452010-05-11 21:53:49 +0200648 SHOW_STR "Display information about a TRX\n"
649 "BTS Number\n"
650 "TRX Number\n")
Harald Welte59b04682009-06-10 05:40:52 +0800651{
Harald Welte40152872010-05-16 20:52:23 +0200652 struct gsm_network *net = gsmnet_from_vty(vty);
Harald Welte59b04682009-06-10 05:40:52 +0800653 struct gsm_bts *bts = NULL;
654 struct gsm_bts_trx *trx;
655 int bts_nr, trx_nr;
656
657 if (argc >= 1) {
658 /* use the BTS number that the user has specified */
659 bts_nr = atoi(argv[0]);
660 if (bts_nr >= net->num_bts) {
661 vty_out(vty, "%% can't find BTS '%s'%s", argv[0],
662 VTY_NEWLINE);
663 return CMD_WARNING;
664 }
Harald Weltee712a5f2009-06-21 16:17:15 +0200665 bts = gsm_bts_num(net, bts_nr);
Harald Welte59b04682009-06-10 05:40:52 +0800666 }
667 if (argc >= 2) {
668 trx_nr = atoi(argv[1]);
669 if (trx_nr >= bts->num_trx) {
670 vty_out(vty, "%% can't find TRX '%s'%s", argv[1],
671 VTY_NEWLINE);
672 return CMD_WARNING;
673 }
Harald Weltee712a5f2009-06-21 16:17:15 +0200674 trx = gsm_bts_trx_num(bts, trx_nr);
Harald Welte59b04682009-06-10 05:40:52 +0800675 trx_dump_vty(vty, trx);
676 return CMD_SUCCESS;
677 }
678 if (bts) {
679 /* print all TRX in this BTS */
680 for (trx_nr = 0; trx_nr < bts->num_trx; trx_nr++) {
Harald Weltee712a5f2009-06-21 16:17:15 +0200681 trx = gsm_bts_trx_num(bts, trx_nr);
Harald Welte59b04682009-06-10 05:40:52 +0800682 trx_dump_vty(vty, trx);
683 }
684 return CMD_SUCCESS;
685 }
686
687 for (bts_nr = 0; bts_nr < net->num_bts; bts_nr++) {
Harald Weltee712a5f2009-06-21 16:17:15 +0200688 bts = gsm_bts_num(net, bts_nr);
Harald Welte59b04682009-06-10 05:40:52 +0800689 for (trx_nr = 0; trx_nr < bts->num_trx; trx_nr++) {
Harald Weltee712a5f2009-06-21 16:17:15 +0200690 trx = gsm_bts_trx_num(bts, trx_nr);
Harald Welte59b04682009-06-10 05:40:52 +0800691 trx_dump_vty(vty, trx);
692 }
693 }
694
695 return CMD_SUCCESS;
696}
697
Harald Welte97ceef92009-08-06 19:06:46 +0200698
Harald Welte59b04682009-06-10 05:40:52 +0800699static void ts_dump_vty(struct vty *vty, struct gsm_bts_trx_ts *ts)
700{
Harald Welte85771a42011-05-30 12:09:13 +0200701 vty_out(vty, "BTS %u, TRX %u, Timeslot %u, phys cfg %s, TSC %u",
Harald Weltee3bd0c02010-12-24 12:12:10 +0100702 ts->trx->bts->nr, ts->trx->nr, ts->nr,
Harald Welte85771a42011-05-30 12:09:13 +0200703 gsm_pchan_name(ts->pchan), ts->tsc);
Harald Welte98d2bb82010-12-24 12:14:52 +0100704 if (ts->pchan == GSM_PCHAN_TCH_F_PDCH)
Harald Welte81c2ed32010-12-24 12:26:13 +0100705 vty_out(vty, " (%s mode)",
Harald Welte98d2bb82010-12-24 12:14:52 +0100706 ts->flags & TS_F_PDCH_MODE ? "PDCH" : "TCH/F");
707 vty_out(vty, "%s", VTY_NEWLINE);
Harald Welte59b04682009-06-10 05:40:52 +0800708 vty_out(vty, " NM State: ");
Harald Welte69f6f812011-05-30 12:07:53 +0200709 net_dump_nmstate(vty, &ts->mo.nm_state);
Harald Welte87504212009-12-02 01:56:49 +0530710 if (!is_ipaccess_bts(ts->trx->bts))
Harald Welte59b04682009-06-10 05:40:52 +0800711 vty_out(vty, " E1 Line %u, Timeslot %u, Subslot %u%s",
712 ts->e1_link.e1_nr, ts->e1_link.e1_ts,
713 ts->e1_link.e1_ts_ss, VTY_NEWLINE);
Harald Welte59b04682009-06-10 05:40:52 +0800714}
715
716DEFUN(show_ts,
717 show_ts_cmd,
718 "show timeslot [bts_nr] [trx_nr] [ts_nr]",
Harald Welte9e002452010-05-11 21:53:49 +0200719 SHOW_STR "Display information about a TS\n"
720 "BTS Number\n" "TRX Number\n" "Timeslot Number\n")
Harald Welte59b04682009-06-10 05:40:52 +0800721{
Harald Welte40152872010-05-16 20:52:23 +0200722 struct gsm_network *net = gsmnet_from_vty(vty);
Harald Welte06868382010-12-24 12:05:03 +0100723 struct gsm_bts *bts = NULL;
724 struct gsm_bts_trx *trx = NULL;
725 struct gsm_bts_trx_ts *ts = NULL;
Harald Welte59b04682009-06-10 05:40:52 +0800726 int bts_nr, trx_nr, ts_nr;
727
728 if (argc >= 1) {
729 /* use the BTS number that the user has specified */
730 bts_nr = atoi(argv[0]);
731 if (bts_nr >= net->num_bts) {
732 vty_out(vty, "%% can't find BTS '%s'%s", argv[0],
733 VTY_NEWLINE);
734 return CMD_WARNING;
735 }
Harald Weltee712a5f2009-06-21 16:17:15 +0200736 bts = gsm_bts_num(net, bts_nr);
Harald Welte59b04682009-06-10 05:40:52 +0800737 }
738 if (argc >= 2) {
739 trx_nr = atoi(argv[1]);
740 if (trx_nr >= bts->num_trx) {
741 vty_out(vty, "%% can't find TRX '%s'%s", argv[1],
742 VTY_NEWLINE);
743 return CMD_WARNING;
744 }
Harald Weltee712a5f2009-06-21 16:17:15 +0200745 trx = gsm_bts_trx_num(bts, trx_nr);
Harald Welte59b04682009-06-10 05:40:52 +0800746 }
747 if (argc >= 3) {
748 ts_nr = atoi(argv[2]);
749 if (ts_nr >= TRX_NR_TS) {
750 vty_out(vty, "%% can't find TS '%s'%s", argv[2],
751 VTY_NEWLINE);
752 return CMD_WARNING;
753 }
Harald Welte06868382010-12-24 12:05:03 +0100754 /* Fully Specified: print and exit */
Harald Welte59b04682009-06-10 05:40:52 +0800755 ts = &trx->ts[ts_nr];
756 ts_dump_vty(vty, ts);
757 return CMD_SUCCESS;
758 }
Harald Welte06868382010-12-24 12:05:03 +0100759
760 if (bts && trx) {
761 /* Iterate over all TS in this TRX */
762 for (ts_nr = 0; ts_nr < TRX_NR_TS; ts_nr++) {
763 ts = &trx->ts[ts_nr];
764 ts_dump_vty(vty, ts);
765 }
766 } else if (bts) {
767 /* Iterate over all TRX in this BTS, TS in each TRX */
Harald Welte59b04682009-06-10 05:40:52 +0800768 for (trx_nr = 0; trx_nr < bts->num_trx; trx_nr++) {
Harald Weltee712a5f2009-06-21 16:17:15 +0200769 trx = gsm_bts_trx_num(bts, trx_nr);
Harald Welte59b04682009-06-10 05:40:52 +0800770 for (ts_nr = 0; ts_nr < TRX_NR_TS; ts_nr++) {
771 ts = &trx->ts[ts_nr];
772 ts_dump_vty(vty, ts);
773 }
774 }
Harald Welte06868382010-12-24 12:05:03 +0100775 } else {
776 /* Iterate over all BTS, TRX in each BTS, TS in each TRX */
777 for (bts_nr = 0; bts_nr < net->num_bts; bts_nr++) {
778 bts = gsm_bts_num(net, bts_nr);
779 for (trx_nr = 0; trx_nr < bts->num_trx; trx_nr++) {
780 trx = gsm_bts_trx_num(bts, trx_nr);
781 for (ts_nr = 0; ts_nr < TRX_NR_TS; ts_nr++) {
782 ts = &trx->ts[ts_nr];
783 ts_dump_vty(vty, ts);
784 }
785 }
786 }
Harald Welte59b04682009-06-10 05:40:52 +0800787 }
788
789 return CMD_SUCCESS;
790}
791
Holger Hans Peter Freyther1dd0a1b2010-01-06 06:00:40 +0100792static void subscr_dump_vty(struct vty *vty, struct gsm_subscriber *subscr)
Harald Welte59b04682009-06-10 05:40:52 +0800793{
Harald Welte91afe4c2009-06-20 18:15:19 +0200794 vty_out(vty, " ID: %llu, Authorized: %d%s", subscr->id,
Harald Welte59b04682009-06-10 05:40:52 +0800795 subscr->authorized, VTY_NEWLINE);
796 if (subscr->name)
797 vty_out(vty, " Name: '%s'%s", subscr->name, VTY_NEWLINE);
798 if (subscr->extension)
799 vty_out(vty, " Extension: %s%s", subscr->extension,
800 VTY_NEWLINE);
801 if (subscr->imsi)
802 vty_out(vty, " IMSI: %s%s", subscr->imsi, VTY_NEWLINE);
Holger Hans Peter Freythercd8bacf2009-08-19 12:53:57 +0200803 if (subscr->tmsi != GSM_RESERVED_TMSI)
804 vty_out(vty, " TMSI: %08X%s", subscr->tmsi,
Harald Welte270c06c2009-08-15 03:24:51 +0200805 VTY_NEWLINE);
Sylvain Munaute5863a22009-12-27 19:29:28 +0100806
Harald Welte (local)02d5efa2009-08-14 20:27:16 +0200807 vty_out(vty, " Use count: %u%s", subscr->use_count, VTY_NEWLINE);
Harald Welte59b04682009-06-10 05:40:52 +0800808}
809
Harald Welte44007742009-12-22 21:43:14 +0100810static void meas_rep_dump_uni_vty(struct vty *vty,
811 struct gsm_meas_rep_unidir *mru,
812 const char *prefix,
813 const char *dir)
814{
815 vty_out(vty, "%s RXL-FULL-%s: %4d dBm, RXL-SUB-%s: %4d dBm ",
816 prefix, dir, rxlev2dbm(mru->full.rx_lev),
817 dir, rxlev2dbm(mru->sub.rx_lev));
818 vty_out(vty, "RXQ-FULL-%s: %d, RXQ-SUB-%s: %d%s",
819 dir, mru->full.rx_qual, dir, mru->sub.rx_qual,
820 VTY_NEWLINE);
821}
822
823static void meas_rep_dump_vty(struct vty *vty, struct gsm_meas_rep *mr,
824 const char *prefix)
825{
826 vty_out(vty, "%sMeasurement Report:%s", prefix, VTY_NEWLINE);
827 vty_out(vty, "%s Flags: %s%s%s%s%s", prefix,
828 mr->flags & MEAS_REP_F_UL_DTX ? "DTXu " : "",
829 mr->flags & MEAS_REP_F_DL_DTX ? "DTXd " : "",
830 mr->flags & MEAS_REP_F_FPC ? "FPC " : "",
831 mr->flags & MEAS_REP_F_DL_VALID ? " " : "DLinval ",
832 VTY_NEWLINE);
833 if (mr->flags & MEAS_REP_F_MS_TO)
834 vty_out(vty, "%s MS Timing Offset: %u%s", prefix,
835 mr->ms_timing_offset, VTY_NEWLINE);
836 if (mr->flags & MEAS_REP_F_MS_L1)
837 vty_out(vty, "%s L1 MS Power: %u dBm, Timing Advance: %u%s",
838 prefix, mr->ms_l1.pwr, mr->ms_l1.ta, VTY_NEWLINE);
839 if (mr->flags & MEAS_REP_F_DL_VALID)
840 meas_rep_dump_uni_vty(vty, &mr->dl, prefix, "dl");
841 meas_rep_dump_uni_vty(vty, &mr->ul, prefix, "ul");
842}
843
Holger Hans Peter Freyther5424e022010-05-14 02:03:16 +0800844static void lchan_dump_full_vty(struct vty *vty, struct gsm_lchan *lchan)
Harald Welte59b04682009-06-10 05:40:52 +0800845{
Harald Welte44007742009-12-22 21:43:14 +0100846 int idx;
847
Harald Weltef62dad62010-12-24 12:22:34 +0100848 vty_out(vty, "BTS %u, TRX %u, Timeslot %u, Lchan %u: Type %s%s",
849 lchan->ts->trx->bts->nr, lchan->ts->trx->nr, lchan->ts->nr,
850 lchan->nr, gsm_lchant_name(lchan->type), VTY_NEWLINE);
Holger Hans Peter Freyther6e5c50f2010-06-28 17:09:29 +0800851 vty_out(vty, " Connection: %u, State: %s%s",
852 lchan->conn ? 1: 0,
Harald Welteab2534c2009-12-29 10:52:38 +0100853 gsm_lchans_name(lchan->state), VTY_NEWLINE);
Harald Welteb761bf82009-12-12 18:17:25 +0100854 vty_out(vty, " BS Power: %u dBm, MS Power: %u dBm%s",
855 lchan->ts->trx->nominal_power - lchan->ts->trx->max_power_red
856 - lchan->bs_power*2,
857 ms_pwr_dbm(lchan->ts->trx->bts->band, lchan->ms_power),
858 VTY_NEWLINE);
Holger Hans Peter Freyther1a95fa82010-06-28 15:47:12 +0800859 if (lchan->conn && lchan->conn->subscr) {
Harald Welte59b04682009-06-10 05:40:52 +0800860 vty_out(vty, " Subscriber:%s", VTY_NEWLINE);
Holger Hans Peter Freyther1a95fa82010-06-28 15:47:12 +0800861 subscr_dump_vty(vty, lchan->conn->subscr);
Harald Welte59b04682009-06-10 05:40:52 +0800862 } else
863 vty_out(vty, " No Subscriber%s", VTY_NEWLINE);
Harald Welte87504212009-12-02 01:56:49 +0530864 if (is_ipaccess_bts(lchan->ts->trx->bts)) {
865 struct in_addr ia;
Holger Hans Peter Freythercec1ec52010-04-07 15:39:16 +0200866 ia.s_addr = htonl(lchan->abis_ip.bound_ip);
Harald Welte87504212009-12-02 01:56:49 +0530867 vty_out(vty, " Bound IP: %s Port %u RTP_TYPE2=%u CONN_ID=%u%s",
868 inet_ntoa(ia), lchan->abis_ip.bound_port,
869 lchan->abis_ip.rtp_payload2, lchan->abis_ip.conn_id,
870 VTY_NEWLINE);
871 }
Harald Welte44007742009-12-22 21:43:14 +0100872
873 /* we want to report the last measurement report */
874 idx = calc_initial_idx(ARRAY_SIZE(lchan->meas_rep),
875 lchan->meas_rep_idx, 1);
876 meas_rep_dump_vty(vty, &lchan->meas_rep[idx], " ");
Harald Welte59b04682009-06-10 05:40:52 +0800877}
878
Holger Hans Peter Freythere959b4e2010-05-14 02:08:49 +0800879static void lchan_dump_short_vty(struct vty *vty, struct gsm_lchan *lchan)
880{
Holger Hans Peter Freythercf13a922010-05-14 01:57:02 +0800881 struct gsm_meas_rep *mr;
882 int idx;
883
884 /* we want to report the last measurement report */
885 idx = calc_initial_idx(ARRAY_SIZE(lchan->meas_rep),
886 lchan->meas_rep_idx, 1);
887 mr = &lchan->meas_rep[idx];
888
Harald Weltef62dad62010-12-24 12:22:34 +0100889 vty_out(vty, "BTS %u, TRX %u, Timeslot %u, Lchan %u, Type %s - "
890 "L1 MS Power: %u dBm RXL-FULL-dl: %4d dBm RXL-FULL-ul: %4d dBm%s",
891 lchan->ts->trx->bts->nr, lchan->ts->trx->nr, lchan->ts->nr,
Harald Welte81c2ed32010-12-24 12:26:13 +0100892 lchan->nr, gsm_lchant_name(lchan->type), mr->ms_l1.pwr,
Holger Hans Peter Freythercf13a922010-05-14 01:57:02 +0800893 rxlev2dbm(mr->dl.full.rx_lev),
894 rxlev2dbm(mr->ul.full.rx_lev),
Holger Hans Peter Freythere959b4e2010-05-14 02:08:49 +0800895 VTY_NEWLINE);
896}
897
Holger Hans Peter Freyther5424e022010-05-14 02:03:16 +0800898static int lchan_summary(struct vty *vty, int argc, const char **argv,
899 void (*dump_cb)(struct vty *, struct gsm_lchan *))
Harald Welte59b04682009-06-10 05:40:52 +0800900{
Harald Welte40152872010-05-16 20:52:23 +0200901 struct gsm_network *net = gsmnet_from_vty(vty);
Harald Welte59b04682009-06-10 05:40:52 +0800902 struct gsm_bts *bts;
903 struct gsm_bts_trx *trx;
904 struct gsm_bts_trx_ts *ts;
905 struct gsm_lchan *lchan;
906 int bts_nr, trx_nr, ts_nr, lchan_nr;
907
908 if (argc >= 1) {
909 /* use the BTS number that the user has specified */
910 bts_nr = atoi(argv[0]);
911 if (bts_nr >= net->num_bts) {
912 vty_out(vty, "%% can't find BTS %s%s", argv[0],
913 VTY_NEWLINE);
914 return CMD_WARNING;
915 }
Harald Weltee712a5f2009-06-21 16:17:15 +0200916 bts = gsm_bts_num(net, bts_nr);
Harald Welte59b04682009-06-10 05:40:52 +0800917 }
918 if (argc >= 2) {
919 trx_nr = atoi(argv[1]);
920 if (trx_nr >= bts->num_trx) {
921 vty_out(vty, "%% can't find TRX %s%s", argv[1],
922 VTY_NEWLINE);
923 return CMD_WARNING;
924 }
Harald Weltee712a5f2009-06-21 16:17:15 +0200925 trx = gsm_bts_trx_num(bts, trx_nr);
Harald Welte59b04682009-06-10 05:40:52 +0800926 }
927 if (argc >= 3) {
928 ts_nr = atoi(argv[2]);
929 if (ts_nr >= TRX_NR_TS) {
930 vty_out(vty, "%% can't find TS %s%s", argv[2],
931 VTY_NEWLINE);
932 return CMD_WARNING;
933 }
934 ts = &trx->ts[ts_nr];
935 }
936 if (argc >= 4) {
937 lchan_nr = atoi(argv[3]);
938 if (lchan_nr >= TS_MAX_LCHAN) {
939 vty_out(vty, "%% can't find LCHAN %s%s", argv[3],
940 VTY_NEWLINE);
941 return CMD_WARNING;
942 }
943 lchan = &ts->lchan[lchan_nr];
Holger Hans Peter Freyther5424e022010-05-14 02:03:16 +0800944 dump_cb(vty, lchan);
Harald Welte59b04682009-06-10 05:40:52 +0800945 return CMD_SUCCESS;
946 }
947 for (bts_nr = 0; bts_nr < net->num_bts; bts_nr++) {
Harald Weltee712a5f2009-06-21 16:17:15 +0200948 bts = gsm_bts_num(net, bts_nr);
Harald Welte59b04682009-06-10 05:40:52 +0800949 for (trx_nr = 0; trx_nr < bts->num_trx; trx_nr++) {
Harald Weltee712a5f2009-06-21 16:17:15 +0200950 trx = gsm_bts_trx_num(bts, trx_nr);
Harald Welte59b04682009-06-10 05:40:52 +0800951 for (ts_nr = 0; ts_nr < TRX_NR_TS; ts_nr++) {
952 ts = &trx->ts[ts_nr];
953 for (lchan_nr = 0; lchan_nr < TS_MAX_LCHAN;
954 lchan_nr++) {
955 lchan = &ts->lchan[lchan_nr];
Jan Luebbed18d8f02011-08-11 04:40:00 +0200956 if ((lchan->type == GSM_LCHAN_NONE) && (lchan->state == LCHAN_S_NONE))
Harald Welte59b04682009-06-10 05:40:52 +0800957 continue;
Holger Hans Peter Freyther5424e022010-05-14 02:03:16 +0800958 dump_cb(vty, lchan);
Harald Welte59b04682009-06-10 05:40:52 +0800959 }
960 }
961 }
962 }
963
964 return CMD_SUCCESS;
965}
966
Holger Hans Peter Freyther5424e022010-05-14 02:03:16 +0800967
968DEFUN(show_lchan,
969 show_lchan_cmd,
970 "show lchan [bts_nr] [trx_nr] [ts_nr] [lchan_nr]",
971 SHOW_STR "Display information about a logical channel\n"
972 "BTS Number\n" "TRX Number\n" "Timeslot Number\n"
Holger Hans Peter Freythere8127042011-10-03 23:42:06 +0200973 LCHAN_NR_STR)
Holger Hans Peter Freyther5424e022010-05-14 02:03:16 +0800974
975{
976 return lchan_summary(vty, argc, argv, lchan_dump_full_vty);
977}
978
Holger Hans Peter Freythere959b4e2010-05-14 02:08:49 +0800979DEFUN(show_lchan_summary,
980 show_lchan_summary_cmd,
981 "show lchan summary [bts_nr] [trx_nr] [ts_nr] [lchan_nr]",
982 SHOW_STR "Display information about a logical channel\n"
Holger Hans Peter Freythere8127042011-10-03 23:42:06 +0200983 "Short summary\n"
Holger Hans Peter Freythere959b4e2010-05-14 02:08:49 +0800984 "BTS Number\n" "TRX Number\n" "Timeslot Number\n"
Holger Hans Peter Freythere8127042011-10-03 23:42:06 +0200985 LCHAN_NR_STR)
Holger Hans Peter Freythere959b4e2010-05-14 02:08:49 +0800986{
987 return lchan_summary(vty, argc, argv, lchan_dump_short_vty);
988}
989
Harald Welte59b04682009-06-10 05:40:52 +0800990static void paging_dump_vty(struct vty *vty, struct gsm_paging_request *pag)
991{
992 vty_out(vty, "Paging on BTS %u%s", pag->bts->nr, VTY_NEWLINE);
993 subscr_dump_vty(vty, pag->subscr);
994}
995
996static void bts_paging_dump_vty(struct vty *vty, struct gsm_bts *bts)
997{
998 struct gsm_paging_request *pag;
999
1000 llist_for_each_entry(pag, &bts->paging.pending_requests, entry)
1001 paging_dump_vty(vty, pag);
1002}
1003
1004DEFUN(show_paging,
1005 show_paging_cmd,
1006 "show paging [bts_nr]",
Harald Welte9e002452010-05-11 21:53:49 +02001007 SHOW_STR "Display information about paging reuqests of a BTS\n"
1008 "BTS Number\n")
Harald Welte59b04682009-06-10 05:40:52 +08001009{
Harald Welte40152872010-05-16 20:52:23 +02001010 struct gsm_network *net = gsmnet_from_vty(vty);
Harald Welte59b04682009-06-10 05:40:52 +08001011 struct gsm_bts *bts;
1012 int bts_nr;
1013
1014 if (argc >= 1) {
1015 /* use the BTS number that the user has specified */
1016 bts_nr = atoi(argv[0]);
1017 if (bts_nr >= net->num_bts) {
1018 vty_out(vty, "%% can't find BTS %s%s", argv[0],
1019 VTY_NEWLINE);
1020 return CMD_WARNING;
1021 }
Harald Weltee712a5f2009-06-21 16:17:15 +02001022 bts = gsm_bts_num(net, bts_nr);
Harald Welte59b04682009-06-10 05:40:52 +08001023 bts_paging_dump_vty(vty, bts);
1024
1025 return CMD_SUCCESS;
1026 }
1027 for (bts_nr = 0; bts_nr < net->num_bts; bts_nr++) {
Harald Weltee712a5f2009-06-21 16:17:15 +02001028 bts = gsm_bts_num(net, bts_nr);
Harald Welte59b04682009-06-10 05:40:52 +08001029 bts_paging_dump_vty(vty, bts);
1030 }
1031
1032 return CMD_SUCCESS;
1033}
1034
Harald Weltee87eb462009-08-07 13:29:14 +02001035DEFUN(cfg_net,
1036 cfg_net_cmd,
Harald Welte9e002452010-05-11 21:53:49 +02001037 "network", NETWORK_STR)
Harald Weltee87eb462009-08-07 13:29:14 +02001038{
Harald Welte40152872010-05-16 20:52:23 +02001039 vty->index = gsmnet_from_vty(vty);
Harald Weltee87eb462009-08-07 13:29:14 +02001040 vty->node = GSMNET_NODE;
1041
1042 return CMD_SUCCESS;
1043}
1044
Harald Weltee87eb462009-08-07 13:29:14 +02001045DEFUN(cfg_net_ncc,
1046 cfg_net_ncc_cmd,
1047 "network country code <1-999>",
Holger Hans Peter Freythere8127042011-10-03 23:42:06 +02001048 "Set the GSM network country code\n"
1049 "Country commands\n"
1050 CODE_CMD_STR
1051 "Network Country Code to use\n")
Harald Weltee87eb462009-08-07 13:29:14 +02001052{
Harald Welte40152872010-05-16 20:52:23 +02001053 struct gsm_network *gsmnet = gsmnet_from_vty(vty);
1054
Harald Weltee87eb462009-08-07 13:29:14 +02001055 gsmnet->country_code = atoi(argv[0]);
1056
1057 return CMD_SUCCESS;
1058}
1059
1060DEFUN(cfg_net_mnc,
1061 cfg_net_mnc_cmd,
Dieter Spaarf1295252011-07-27 23:43:56 +02001062 "mobile network code <0-999>",
Holger Hans Peter Freythere8127042011-10-03 23:42:06 +02001063 "Set the GSM mobile network code\n"
1064 "Network Commands\n"
1065 CODE_CMD_STR
1066 "Mobile Network Code to use\n")
Harald Weltee87eb462009-08-07 13:29:14 +02001067{
Harald Welte40152872010-05-16 20:52:23 +02001068 struct gsm_network *gsmnet = gsmnet_from_vty(vty);
1069
Harald Weltee87eb462009-08-07 13:29:14 +02001070 gsmnet->network_code = atoi(argv[0]);
1071
1072 return CMD_SUCCESS;
1073}
1074
1075DEFUN(cfg_net_name_short,
1076 cfg_net_name_short_cmd,
1077 "short name NAME",
Holger Hans Peter Freythere8127042011-10-03 23:42:06 +02001078 "Set the short GSM network name\n" NAME_CMD_STR NAME_STR)
Harald Weltee87eb462009-08-07 13:29:14 +02001079{
Harald Welte40152872010-05-16 20:52:23 +02001080 struct gsm_network *gsmnet = gsmnet_from_vty(vty);
1081
Holger Hans Peter Freyther7c831f62010-10-12 23:21:54 +02001082 bsc_replace_string(gsmnet, &gsmnet->name_short, argv[0]);
Harald Weltee87eb462009-08-07 13:29:14 +02001083 return CMD_SUCCESS;
1084}
1085
1086DEFUN(cfg_net_name_long,
1087 cfg_net_name_long_cmd,
1088 "long name NAME",
Holger Hans Peter Freythere8127042011-10-03 23:42:06 +02001089 "Set the long GSM network name\n" NAME_CMD_STR NAME_STR)
Harald Weltee87eb462009-08-07 13:29:14 +02001090{
Harald Welte40152872010-05-16 20:52:23 +02001091 struct gsm_network *gsmnet = gsmnet_from_vty(vty);
1092
Holger Hans Peter Freyther7c831f62010-10-12 23:21:54 +02001093 bsc_replace_string(gsmnet, &gsmnet->name_long, argv[0]);
Harald Weltee87eb462009-08-07 13:29:14 +02001094 return CMD_SUCCESS;
1095}
Harald Welte59b04682009-06-10 05:40:52 +08001096
Harald Welte (local)a59a27e2009-08-12 14:42:23 +02001097DEFUN(cfg_net_auth_policy,
1098 cfg_net_auth_policy_cmd,
1099 "auth policy (closed|accept-all|token)",
Harald Welte9e002452010-05-11 21:53:49 +02001100 "Authentication (not cryptographic)\n"
1101 "Set the GSM network authentication policy\n"
1102 "Require the MS to be activated in HLR\n"
1103 "Accept all MS, whether in HLR or not\n"
1104 "Use SMS-token based authentication\n")
Harald Welte (local)a59a27e2009-08-12 14:42:23 +02001105{
1106 enum gsm_auth_policy policy = gsm_auth_policy_parse(argv[0]);
Harald Welte40152872010-05-16 20:52:23 +02001107 struct gsm_network *gsmnet = gsmnet_from_vty(vty);
Harald Welte (local)a59a27e2009-08-12 14:42:23 +02001108
1109 gsmnet->auth_policy = policy;
1110
1111 return CMD_SUCCESS;
1112}
1113
Harald Welte59936d72009-11-18 20:33:19 +01001114DEFUN(cfg_net_reject_cause,
1115 cfg_net_reject_cause_cmd,
1116 "location updating reject cause <2-111>",
1117 "Set the reject cause of location updating reject\n")
1118{
Harald Welte40152872010-05-16 20:52:23 +02001119 struct gsm_network *gsmnet = gsmnet_from_vty(vty);
1120
Harald Welte59936d72009-11-18 20:33:19 +01001121 gsmnet->reject_cause = atoi(argv[0]);
1122
1123 return CMD_SUCCESS;
1124}
1125
Harald Weltecca253a2009-08-30 15:47:06 +09001126DEFUN(cfg_net_encryption,
1127 cfg_net_encryption_cmd,
1128 "encryption a5 (0|1|2)",
Harald Welte18ce31c2010-05-14 20:05:17 +02001129 "Encryption options\n"
1130 "A5 encryption\n" "A5/0: No encryption\n"
1131 "A5/1: Encryption\n" "A5/2: Export-grade Encryption\n")
Harald Weltecca253a2009-08-30 15:47:06 +09001132{
Harald Welte40152872010-05-16 20:52:23 +02001133 struct gsm_network *gsmnet = gsmnet_from_vty(vty);
1134
Andreas.Eversberg53293292009-11-17 09:55:26 +01001135 gsmnet->a5_encryption= atoi(argv[0]);
Harald Weltecca253a2009-08-30 15:47:06 +09001136
1137 return CMD_SUCCESS;
1138}
1139
Holger Hans Peter Freyther96c89822009-11-16 17:12:38 +01001140DEFUN(cfg_net_neci,
1141 cfg_net_neci_cmd,
1142 "neci (0|1)",
Harald Welte18ce31c2010-05-14 20:05:17 +02001143 "New Establish Cause Indication\n"
1144 "Don't set the NECI bit\n" "Set the NECI bit\n")
Holger Hans Peter Freyther96c89822009-11-16 17:12:38 +01001145{
Harald Welte40152872010-05-16 20:52:23 +02001146 struct gsm_network *gsmnet = gsmnet_from_vty(vty);
1147
Holger Hans Peter Freyther96c89822009-11-16 17:12:38 +01001148 gsmnet->neci = atoi(argv[0]);
Holger Hans Peter Freytherf0f37f12010-09-06 09:36:02 +08001149 gsm_net_update_ctype(gsmnet);
Holger Hans Peter Freyther96c89822009-11-16 17:12:38 +01001150 return CMD_SUCCESS;
1151}
1152
Harald Welte52af1952009-12-13 10:53:12 +01001153DEFUN(cfg_net_rrlp_mode, cfg_net_rrlp_mode_cmd,
1154 "rrlp mode (none|ms-based|ms-preferred|ass-preferred)",
Harald Welte9e002452010-05-11 21:53:49 +02001155 "Radio Resource Location Protocol\n"
1156 "Set the Radio Resource Location Protocol Mode\n"
1157 "Don't send RRLP request\n"
1158 "Request MS-based location\n"
1159 "Request any location, prefer MS-based\n"
1160 "Request any location, prefer MS-assisted\n")
Harald Welte52af1952009-12-13 10:53:12 +01001161{
Harald Welte40152872010-05-16 20:52:23 +02001162 struct gsm_network *gsmnet = gsmnet_from_vty(vty);
1163
Harald Welte52af1952009-12-13 10:53:12 +01001164 gsmnet->rrlp.mode = rrlp_mode_parse(argv[0]);
1165
1166 return CMD_SUCCESS;
1167}
1168
Harald Weltea310f3e2009-12-14 09:00:24 +01001169DEFUN(cfg_net_mm_info, cfg_net_mm_info_cmd,
1170 "mm info (0|1)",
1171 "Whether to send MM INFO after LOC UPD ACCEPT")
1172{
Harald Welte40152872010-05-16 20:52:23 +02001173 struct gsm_network *gsmnet = gsmnet_from_vty(vty);
1174
Harald Weltea310f3e2009-12-14 09:00:24 +01001175 gsmnet->send_mm_info = atoi(argv[0]);
1176
1177 return CMD_SUCCESS;
1178}
1179
Harald Welte9e002452010-05-11 21:53:49 +02001180#define HANDOVER_STR "Handover Options\n"
1181
Harald Welte0af9c9f2009-12-19 21:41:52 +01001182DEFUN(cfg_net_handover, cfg_net_handover_cmd,
1183 "handover (0|1)",
Harald Welte9e002452010-05-11 21:53:49 +02001184 HANDOVER_STR
1185 "Don't perform in-call handover\n"
1186 "Perform in-call handover\n")
Harald Welte0af9c9f2009-12-19 21:41:52 +01001187{
Holger Hans Peter Freyther3524d4b2010-01-07 16:14:38 +01001188 int enable = atoi(argv[0]);
Harald Welte40152872010-05-16 20:52:23 +02001189 struct gsm_network *gsmnet = gsmnet_from_vty(vty);
Holger Hans Peter Freyther3524d4b2010-01-07 16:14:38 +01001190
1191 if (enable && ipacc_rtp_direct) {
Harald Welteaa2c3032009-12-20 13:51:01 +01001192 vty_out(vty, "%% Cannot enable handover unless RTP Proxy mode "
1193 "is enabled by using the -P command line option%s",
1194 VTY_NEWLINE);
1195 return CMD_WARNING;
1196 }
Holger Hans Peter Freyther3524d4b2010-01-07 16:14:38 +01001197 gsmnet->handover.active = enable;
Harald Welte0af9c9f2009-12-19 21:41:52 +01001198
1199 return CMD_SUCCESS;
1200}
1201
Harald Welte9e002452010-05-11 21:53:49 +02001202#define HO_WIN_STR HANDOVER_STR "Measurement Window\n"
1203#define HO_WIN_RXLEV_STR HO_WIN_STR "Received Level Averaging\n"
1204#define HO_WIN_RXQUAL_STR HO_WIN_STR "Received Quality Averaging\n"
1205#define HO_PBUDGET_STR HANDOVER_STR "Power Budget\n"
Holger Hans Peter Freythere8127042011-10-03 23:42:06 +02001206#define HO_AVG_COUNT_STR "Amount to use for Averaging\n"
Harald Welte9e002452010-05-11 21:53:49 +02001207
Harald Weltea8062f12009-12-21 16:51:50 +01001208DEFUN(cfg_net_ho_win_rxlev_avg, cfg_net_ho_win_rxlev_avg_cmd,
1209 "handover window rxlev averaging <1-10>",
Harald Welte9e002452010-05-11 21:53:49 +02001210 HO_WIN_RXLEV_STR
Holger Hans Peter Freythere8127042011-10-03 23:42:06 +02001211 "How many RxLev measurements are used for averaging\n"
1212 HO_AVG_COUNT_STR)
Harald Weltea8062f12009-12-21 16:51:50 +01001213{
Harald Welte40152872010-05-16 20:52:23 +02001214 struct gsm_network *gsmnet = gsmnet_from_vty(vty);
Harald Weltea8062f12009-12-21 16:51:50 +01001215 gsmnet->handover.win_rxlev_avg = atoi(argv[0]);
1216 return CMD_SUCCESS;
1217}
1218
1219DEFUN(cfg_net_ho_win_rxqual_avg, cfg_net_ho_win_rxqual_avg_cmd,
1220 "handover window rxqual averaging <1-10>",
Harald Welte9e002452010-05-11 21:53:49 +02001221 HO_WIN_RXQUAL_STR
Holger Hans Peter Freythere8127042011-10-03 23:42:06 +02001222 "How many RxQual measurements are used for averaging\n"
1223 HO_AVG_COUNT_STR)
Harald Weltea8062f12009-12-21 16:51:50 +01001224{
Harald Welte40152872010-05-16 20:52:23 +02001225 struct gsm_network *gsmnet = gsmnet_from_vty(vty);
Harald Weltea8062f12009-12-21 16:51:50 +01001226 gsmnet->handover.win_rxqual_avg = atoi(argv[0]);
1227 return CMD_SUCCESS;
1228}
1229
1230DEFUN(cfg_net_ho_win_rxlev_neigh_avg, cfg_net_ho_win_rxlev_avg_neigh_cmd,
1231 "handover window rxlev neighbor averaging <1-10>",
Holger Hans Peter Freythere8127042011-10-03 23:42:06 +02001232 HO_WIN_RXLEV_STR "Neighbor\n"
1233 "How many RxQual measurements are used for averaging\n"
1234 HO_AVG_COUNT_STR)
Harald Weltea8062f12009-12-21 16:51:50 +01001235{
Harald Welte40152872010-05-16 20:52:23 +02001236 struct gsm_network *gsmnet = gsmnet_from_vty(vty);
Harald Weltea8062f12009-12-21 16:51:50 +01001237 gsmnet->handover.win_rxlev_avg_neigh = atoi(argv[0]);
1238 return CMD_SUCCESS;
1239}
1240
1241DEFUN(cfg_net_ho_pwr_interval, cfg_net_ho_pwr_interval_cmd,
1242 "handover power budget interval <1-99>",
Harald Welte9e002452010-05-11 21:53:49 +02001243 HO_PBUDGET_STR
Holger Hans Peter Freythere8127042011-10-03 23:42:06 +02001244 "How often to check if we have a better cell (SACCH frames)\n"
1245 "Interval\n" "Number\n")
Harald Weltea8062f12009-12-21 16:51:50 +01001246{
Harald Welte40152872010-05-16 20:52:23 +02001247 struct gsm_network *gsmnet = gsmnet_from_vty(vty);
Harald Weltea8062f12009-12-21 16:51:50 +01001248 gsmnet->handover.pwr_interval = atoi(argv[0]);
1249 return CMD_SUCCESS;
1250}
1251
1252DEFUN(cfg_net_ho_pwr_hysteresis, cfg_net_ho_pwr_hysteresis_cmd,
1253 "handover power budget hysteresis <0-999>",
Harald Welte9e002452010-05-11 21:53:49 +02001254 HO_PBUDGET_STR
Holger Hans Peter Freythere8127042011-10-03 23:42:06 +02001255 "How many dB does a neighbor to be stronger to become a HO candidate\n"
1256 "Hysteresis\n" "Number\n")
Harald Weltea8062f12009-12-21 16:51:50 +01001257{
Harald Welte40152872010-05-16 20:52:23 +02001258 struct gsm_network *gsmnet = gsmnet_from_vty(vty);
Harald Weltea8062f12009-12-21 16:51:50 +01001259 gsmnet->handover.pwr_hysteresis = atoi(argv[0]);
1260 return CMD_SUCCESS;
1261}
1262
1263DEFUN(cfg_net_ho_max_distance, cfg_net_ho_max_distance_cmd,
1264 "handover maximum distance <0-9999>",
Harald Welte9e002452010-05-11 21:53:49 +02001265 HANDOVER_STR
Holger Hans Peter Freythere8127042011-10-03 23:42:06 +02001266 "How big is the maximum timing advance before HO is forced\n"
1267 "Distance\n" "Number\n")
Harald Weltea8062f12009-12-21 16:51:50 +01001268{
Harald Welte40152872010-05-16 20:52:23 +02001269 struct gsm_network *gsmnet = gsmnet_from_vty(vty);
Harald Weltea8062f12009-12-21 16:51:50 +01001270 gsmnet->handover.max_distance = atoi(argv[0]);
1271 return CMD_SUCCESS;
1272}
Harald Welte0af9c9f2009-12-19 21:41:52 +01001273
Holger Hans Peter Freytherb6b9d702010-09-06 09:41:50 +08001274DEFUN(cfg_net_pag_any_tch,
1275 cfg_net_pag_any_tch_cmd,
1276 "paging any use tch (0|1)",
Holger Hans Peter Freythere8127042011-10-03 23:42:06 +02001277 "Assign a TCH when receiving a Paging Any request\n"
1278 "Any Channel\n" "Use\n" "TCH\n"
1279 "Do not use TCH for Paging Request Any\n"
1280 "Do use TCH for Paging Request Any\n")
Holger Hans Peter Freytherb6b9d702010-09-06 09:41:50 +08001281{
Holger Hans Peter Freytherc5628882010-09-06 10:09:19 +08001282 struct gsm_network *gsmnet = gsmnet_from_vty(vty);
Holger Hans Peter Freytherb6b9d702010-09-06 09:41:50 +08001283 gsmnet->pag_any_tch = atoi(argv[0]);
1284 gsm_net_update_ctype(gsmnet);
1285 return CMD_SUCCESS;
1286}
1287
Holger Hans Peter Freyther13ae9802009-12-22 08:27:21 +01001288#define DECLARE_TIMER(number, doc) \
Holger Hans Peter Freyther26ba2e72009-11-21 21:18:38 +01001289 DEFUN(cfg_net_T##number, \
1290 cfg_net_T##number##_cmd, \
1291 "timer t" #number " <0-65535>", \
Harald Welte9e002452010-05-11 21:53:49 +02001292 "Configure GSM Timers\n" \
Holger Hans Peter Freythere8127042011-10-03 23:42:06 +02001293 doc "Timer Value\n") \
Holger Hans Peter Freyther26ba2e72009-11-21 21:18:38 +01001294{ \
Harald Welte40152872010-05-16 20:52:23 +02001295 struct gsm_network *gsmnet = gsmnet_from_vty(vty); \
Holger Hans Peter Freyther26ba2e72009-11-21 21:18:38 +01001296 int value = atoi(argv[0]); \
1297 \
1298 if (value < 0 || value > 65535) { \
1299 vty_out(vty, "Timer value %s out of range.%s", \
1300 argv[0], VTY_NEWLINE); \
1301 return CMD_WARNING; \
1302 } \
1303 \
1304 gsmnet->T##number = value; \
1305 return CMD_SUCCESS; \
1306}
1307
Holger Hans Peter Freythere8127042011-10-03 23:42:06 +02001308DECLARE_TIMER(3101, "Set the timeout value for IMMEDIATE ASSIGNMENT.\n")
1309DECLARE_TIMER(3103, "Set the timeout value for HANDOVER.\n")
1310DECLARE_TIMER(3105, "Currently not used.\n")
1311DECLARE_TIMER(3107, "Currently not used.\n")
1312DECLARE_TIMER(3109, "Currently not used.\n")
1313DECLARE_TIMER(3111, "Set the RSL timeout to wait before releasing the RF Channel.\n")
1314DECLARE_TIMER(3113, "Set the time to try paging a subscriber.\n")
1315DECLARE_TIMER(3115, "Currently not used.\n")
1316DECLARE_TIMER(3117, "Currently not used.\n")
1317DECLARE_TIMER(3119, "Currently not used.\n")
1318DECLARE_TIMER(3122, "Waiting time (seconds) after IMM ASS REJECT\n")
1319DECLARE_TIMER(3141, "Currently not used.\n")
Holger Hans Peter Freyther26ba2e72009-11-21 21:18:38 +01001320
Holger Hans Peter Freyther21d63ff2010-09-06 09:25:48 +08001321DEFUN(cfg_net_dtx,
1322 cfg_net_dtx_cmd,
1323 "dtx-used (0|1)",
1324 "Enable the usage of DTX.\n"
Holger Hans Peter Freythere8127042011-10-03 23:42:06 +02001325 "DTX is disabled\n" "DTX is enabled\n")
Holger Hans Peter Freyther21d63ff2010-09-06 09:25:48 +08001326{
1327 struct gsm_network *gsmnet = gsmnet_from_vty(vty);
1328 gsmnet->dtx_enabled = atoi(argv[0]);
1329 return CMD_SUCCESS;
1330}
Holger Hans Peter Freyther26ba2e72009-11-21 21:18:38 +01001331
Holger Hans Peter Freyther68b21e12010-12-22 16:26:04 +01001332DEFUN(cfg_net_subscr_keep,
1333 cfg_net_subscr_keep_cmd,
1334 "subscriber-keep-in-ram (0|1)",
1335 "Keep unused subscribers in RAM.\n"
1336 "Delete unused subscribers\n" "Keep unused subscribers\n")
1337{
1338 struct gsm_network *gsmnet = gsmnet_from_vty(vty);
1339 gsmnet->keep_subscr = atoi(argv[0]);
1340 return CMD_SUCCESS;
1341}
1342
Harald Welte59b04682009-06-10 05:40:52 +08001343/* per-BTS configuration */
1344DEFUN(cfg_bts,
1345 cfg_bts_cmd,
1346 "bts BTS_NR",
Harald Welte9e002452010-05-11 21:53:49 +02001347 "Select a BTS to configure\n"
1348 "BTS Number\n")
Harald Welte59b04682009-06-10 05:40:52 +08001349{
Harald Welte40152872010-05-16 20:52:23 +02001350 struct gsm_network *gsmnet = gsmnet_from_vty(vty);
Harald Welte59b04682009-06-10 05:40:52 +08001351 int bts_nr = atoi(argv[0]);
1352 struct gsm_bts *bts;
1353
Harald Weltee712a5f2009-06-21 16:17:15 +02001354 if (bts_nr > gsmnet->num_bts) {
1355 vty_out(vty, "%% The next unused BTS number is %u%s",
1356 gsmnet->num_bts, VTY_NEWLINE);
Harald Welte59b04682009-06-10 05:40:52 +08001357 return CMD_WARNING;
Harald Weltee712a5f2009-06-21 16:17:15 +02001358 } else if (bts_nr == gsmnet->num_bts) {
1359 /* allocate a new one */
Harald Weltec7881282011-06-05 13:31:33 +02001360 bts = gsm_bts_alloc_register(gsmnet, GSM_BTS_TYPE_UNKNOWN,
1361 HARDCODED_TSC, HARDCODED_BSIC);
Holger Hans Peter Freyther71135142010-03-29 08:47:44 +02001362 } else
Harald Weltee712a5f2009-06-21 16:17:15 +02001363 bts = gsm_bts_num(gsmnet, bts_nr);
1364
Daniel Willmann580085f2010-01-11 13:43:07 +01001365 if (!bts) {
1366 vty_out(vty, "%% Unable to allocate BTS %u%s",
1367 gsmnet->num_bts, VTY_NEWLINE);
Harald Weltee712a5f2009-06-21 16:17:15 +02001368 return CMD_WARNING;
Daniel Willmann580085f2010-01-11 13:43:07 +01001369 }
Harald Welte59b04682009-06-10 05:40:52 +08001370
1371 vty->index = bts;
Harald Welte8791dac2010-05-14 17:59:53 +02001372 vty->index_sub = &bts->description;
Harald Welte59b04682009-06-10 05:40:52 +08001373 vty->node = BTS_NODE;
1374
1375 return CMD_SUCCESS;
1376}
1377
1378DEFUN(cfg_bts_type,
1379 cfg_bts_type_cmd,
1380 "type TYPE",
Holger Hans Peter Freythere8127042011-10-03 23:42:06 +02001381 "Set the BTS type\n" "Type\n")
Harald Welte59b04682009-06-10 05:40:52 +08001382{
1383 struct gsm_bts *bts = vty->index;
Harald Welte59698fb2010-01-10 18:01:52 +01001384 int rc;
Harald Welte59b04682009-06-10 05:40:52 +08001385
Harald Welte59698fb2010-01-10 18:01:52 +01001386 rc = gsm_set_bts_type(bts, parse_btstype(argv[0]));
1387 if (rc < 0)
1388 return CMD_WARNING;
Harald Welte25572872009-10-20 00:22:00 +02001389
Harald Welte59b04682009-06-10 05:40:52 +08001390 return CMD_SUCCESS;
1391}
1392
Harald Welte91afe4c2009-06-20 18:15:19 +02001393DEFUN(cfg_bts_band,
1394 cfg_bts_band_cmd,
1395 "band BAND",
Holger Hans Peter Freythere8127042011-10-03 23:42:06 +02001396 "Set the frequency band of this BTS\n" "Frequency band\n")
Harald Welte91afe4c2009-06-20 18:15:19 +02001397{
1398 struct gsm_bts *bts = vty->index;
Harald Welte62868882009-08-08 16:12:58 +02001399 int band = gsm_band_parse(argv[0]);
Harald Welte91afe4c2009-06-20 18:15:19 +02001400
1401 if (band < 0) {
1402 vty_out(vty, "%% BAND %d is not a valid GSM band%s",
1403 band, VTY_NEWLINE);
1404 return CMD_WARNING;
1405 }
1406
1407 bts->band = band;
1408
1409 return CMD_SUCCESS;
1410}
1411
Holger Hans Peter Freythera098dfb2009-08-21 14:44:12 +02001412DEFUN(cfg_bts_ci,
1413 cfg_bts_ci_cmd,
1414 "cell_identity <0-65535>",
1415 "Set the Cell identity of this BTS\n")
1416{
1417 struct gsm_bts *bts = vty->index;
1418 int ci = atoi(argv[0]);
1419
1420 if (ci < 0 || ci > 0xffff) {
1421 vty_out(vty, "%% CI %d is not in the valid range (0-65535)%s",
1422 ci, VTY_NEWLINE);
1423 return CMD_WARNING;
1424 }
1425 bts->cell_identity = ci;
1426
1427 return CMD_SUCCESS;
1428}
1429
Harald Welte59b04682009-06-10 05:40:52 +08001430DEFUN(cfg_bts_lac,
1431 cfg_bts_lac_cmd,
Holger Hans Peter Freyther54a22832009-09-29 14:02:33 +02001432 "location_area_code <0-65535>",
Harald Welte59b04682009-06-10 05:40:52 +08001433 "Set the Location Area Code (LAC) of this BTS\n")
1434{
1435 struct gsm_bts *bts = vty->index;
1436 int lac = atoi(argv[0]);
1437
Holger Hans Peter Freyther54a22832009-09-29 14:02:33 +02001438 if (lac < 0 || lac > 0xffff) {
1439 vty_out(vty, "%% LAC %d is not in the valid range (0-65535)%s",
Harald Welte59b04682009-06-10 05:40:52 +08001440 lac, VTY_NEWLINE);
1441 return CMD_WARNING;
1442 }
Holger Hans Peter Freyther6c6ab862009-10-01 04:07:15 +02001443
1444 if (lac == GSM_LAC_RESERVED_DETACHED || lac == GSM_LAC_RESERVED_ALL_BTS) {
1445 vty_out(vty, "%% LAC %d is reserved by GSM 04.08%s",
1446 lac, VTY_NEWLINE);
1447 return CMD_WARNING;
1448 }
1449
Harald Welte59b04682009-06-10 05:40:52 +08001450 bts->location_area_code = lac;
1451
1452 return CMD_SUCCESS;
1453}
1454
Harald Weltea54a2bb2009-12-01 18:04:30 +05301455
Harald Welte59b04682009-06-10 05:40:52 +08001456DEFUN(cfg_bts_tsc,
1457 cfg_bts_tsc_cmd,
1458 "training_sequence_code <0-255>",
1459 "Set the Training Sequence Code (TSC) of this BTS\n")
1460{
1461 struct gsm_bts *bts = vty->index;
1462 int tsc = atoi(argv[0]);
1463
1464 if (tsc < 0 || tsc > 0xff) {
1465 vty_out(vty, "%% TSC %d is not in the valid range (0-255)%s",
1466 tsc, VTY_NEWLINE);
1467 return CMD_WARNING;
1468 }
1469 bts->tsc = tsc;
1470
1471 return CMD_SUCCESS;
1472}
1473
1474DEFUN(cfg_bts_bsic,
1475 cfg_bts_bsic_cmd,
1476 "base_station_id_code <0-63>",
1477 "Set the Base Station Identity Code (BSIC) of this BTS\n")
1478{
1479 struct gsm_bts *bts = vty->index;
1480 int bsic = atoi(argv[0]);
1481
1482 if (bsic < 0 || bsic > 0x3f) {
Harald Welte62868882009-08-08 16:12:58 +02001483 vty_out(vty, "%% BSIC %d is not in the valid range (0-255)%s",
Harald Welte59b04682009-06-10 05:40:52 +08001484 bsic, VTY_NEWLINE);
1485 return CMD_WARNING;
1486 }
1487 bts->bsic = bsic;
1488
1489 return CMD_SUCCESS;
1490}
1491
1492
1493DEFUN(cfg_bts_unit_id,
1494 cfg_bts_unit_id_cmd,
Harald Weltef515aa02009-08-07 13:27:09 +02001495 "ip.access unit_id <0-65534> <0-255>",
1496 "Set the ip.access BTS Unit ID of this BTS\n")
Harald Welte59b04682009-06-10 05:40:52 +08001497{
1498 struct gsm_bts *bts = vty->index;
1499 int site_id = atoi(argv[0]);
1500 int bts_id = atoi(argv[1]);
1501
Harald Weltef515aa02009-08-07 13:27:09 +02001502 if (!is_ipaccess_bts(bts)) {
1503 vty_out(vty, "%% BTS is not of ip.access type%s", VTY_NEWLINE);
1504 return CMD_WARNING;
1505 }
1506
Harald Welte59b04682009-06-10 05:40:52 +08001507 bts->ip_access.site_id = site_id;
1508 bts->ip_access.bts_id = bts_id;
1509
1510 return CMD_SUCCESS;
1511}
1512
Harald Welte08011e22011-03-04 13:41:31 +01001513DEFUN(cfg_bts_serno,
1514 cfg_bts_serno_cmd,
1515 "hsl serial-number STRING",
1516 "Set the HSL Serial Number of this BTS\n")
1517{
1518 struct gsm_bts *bts = vty->index;
1519
1520 if (bts->type != GSM_BTS_TYPE_HSL_FEMTO) {
1521 vty_out(vty, "%% BTS is not of HSL type%s", VTY_NEWLINE);
1522 return CMD_WARNING;
1523 }
1524
1525 bts->hsl.serno = strtoul(argv[0], NULL, 10);
1526
1527 return CMD_SUCCESS;
1528}
1529
Harald Welte9e002452010-05-11 21:53:49 +02001530#define OML_STR "Organization & Maintenance Link\n"
1531#define IPA_STR "ip.access Specific Options\n"
1532
Harald Welte25572872009-10-20 00:22:00 +02001533DEFUN(cfg_bts_stream_id,
1534 cfg_bts_stream_id_cmd,
Pablo Neira Ayuso42e41df2011-08-17 22:44:07 +02001535 "oml ip.access stream_id <0-255> line E1_LINE",
Harald Welte9e002452010-05-11 21:53:49 +02001536 OML_STR IPA_STR
Harald Welte25572872009-10-20 00:22:00 +02001537 "Set the ip.access Stream ID of the OML link of this BTS\n")
1538{
1539 struct gsm_bts *bts = vty->index;
Pablo Neira Ayuso42e41df2011-08-17 22:44:07 +02001540 int stream_id = atoi(argv[0]), linenr = atoi(argv[1]);
Harald Welte25572872009-10-20 00:22:00 +02001541
1542 if (!is_ipaccess_bts(bts)) {
1543 vty_out(vty, "%% BTS is not of ip.access type%s", VTY_NEWLINE);
1544 return CMD_WARNING;
1545 }
1546
1547 bts->oml_tei = stream_id;
Pablo Neira Ayuso42e41df2011-08-17 22:44:07 +02001548 /* This is used by e1inp_bind_ops callback for each BTS model. */
1549 bts->oml_e1_link.e1_nr = linenr;
1550
1551 return CMD_SUCCESS;
1552}
1553
1554DEFUN(cfg_bts_hsl_oml,
1555 cfg_bts_hsl_oml_cmd,
1556 "oml hsl line E1_LINE",
1557 OML_STR "HSL femto Specific Options"
1558 "Set OML link of this HSL femto BTS\n")
1559{
1560 struct gsm_bts *bts = vty->index;
1561 int linenr = atoi(argv[0]);
1562
1563 if (!(bts->type == GSM_BTS_TYPE_HSL_FEMTO)) {
1564 vty_out(vty, "%% BTS is not of HSL type%s", VTY_NEWLINE);
1565 return CMD_WARNING;
1566 }
1567
1568 bts->oml_e1_link.e1_nr = linenr;
Harald Welte25572872009-10-20 00:22:00 +02001569
1570 return CMD_SUCCESS;
1571}
1572
Harald Welte9e002452010-05-11 21:53:49 +02001573#define OML_E1_STR OML_STR "E1 Line\n"
Harald Welte25572872009-10-20 00:22:00 +02001574
Harald Welte62868882009-08-08 16:12:58 +02001575DEFUN(cfg_bts_oml_e1,
1576 cfg_bts_oml_e1_cmd,
1577 "oml e1 line E1_LINE timeslot <1-31> sub-slot (0|1|2|3|full)",
Harald Welte9e002452010-05-11 21:53:49 +02001578 OML_E1_STR
Harald Welte62868882009-08-08 16:12:58 +02001579 "E1 interface to be used for OML\n")
1580{
1581 struct gsm_bts *bts = vty->index;
1582
1583 parse_e1_link(&bts->oml_e1_link, argv[0], argv[1], argv[2]);
1584
1585 return CMD_SUCCESS;
1586}
1587
1588
1589DEFUN(cfg_bts_oml_e1_tei,
1590 cfg_bts_oml_e1_tei_cmd,
1591 "oml e1 tei <0-63>",
Harald Welte9e002452010-05-11 21:53:49 +02001592 OML_E1_STR
Harald Welte62868882009-08-08 16:12:58 +02001593 "Set the TEI to be used for OML")
1594{
1595 struct gsm_bts *bts = vty->index;
1596
1597 bts->oml_tei = atoi(argv[0]);
1598
1599 return CMD_SUCCESS;
1600}
1601
Harald Welte3e774612009-08-10 13:48:16 +02001602DEFUN(cfg_bts_challoc, cfg_bts_challoc_cmd,
1603 "channel allocator (ascending|descending)",
Harald Welte9e002452010-05-11 21:53:49 +02001604 "Channnel Allocator\n" "Channel Allocator\n"
1605 "Allocate Timeslots and Transceivers in ascending order\n"
1606 "Allocate Timeslots and Transceivers in descending order\n")
Harald Welte3e774612009-08-10 13:48:16 +02001607{
1608 struct gsm_bts *bts = vty->index;
1609
1610 if (!strcmp(argv[0], "ascending"))
1611 bts->chan_alloc_reverse = 0;
1612 else
1613 bts->chan_alloc_reverse = 1;
1614
1615 return CMD_SUCCESS;
1616}
1617
Harald Welte9e002452010-05-11 21:53:49 +02001618#define RACH_STR "Random Access Control Channel\n"
1619
Sylvain Munaut8e2d8de2009-12-22 13:43:26 +01001620DEFUN(cfg_bts_rach_tx_integer,
1621 cfg_bts_rach_tx_integer_cmd,
1622 "rach tx integer <0-15>",
Harald Welte9e002452010-05-11 21:53:49 +02001623 RACH_STR
Sylvain Munaut8e2d8de2009-12-22 13:43:26 +01001624 "Set the raw tx integer value in RACH Control parameters IE")
1625{
1626 struct gsm_bts *bts = vty->index;
1627 bts->si_common.rach_control.tx_integer = atoi(argv[0]) & 0xf;
1628 return CMD_SUCCESS;
1629}
1630
1631DEFUN(cfg_bts_rach_max_trans,
1632 cfg_bts_rach_max_trans_cmd,
1633 "rach max transmission (1|2|4|7)",
Harald Welte9e002452010-05-11 21:53:49 +02001634 RACH_STR
Sylvain Munaut8e2d8de2009-12-22 13:43:26 +01001635 "Set the maximum number of RACH burst transmissions")
1636{
1637 struct gsm_bts *bts = vty->index;
1638 bts->si_common.rach_control.max_trans = rach_max_trans_val2raw(atoi(argv[0]));
1639 return CMD_SUCCESS;
1640}
1641
Harald Welte9e002452010-05-11 21:53:49 +02001642#define NM_STR "Network Management\n"
1643
Holger Hans Peter Freyther697ed2b2010-04-25 23:08:39 +08001644DEFUN(cfg_bts_rach_nm_b_thresh,
1645 cfg_bts_rach_nm_b_thresh_cmd,
1646 "rach nm busy threshold <0-255>",
Harald Welte9e002452010-05-11 21:53:49 +02001647 RACH_STR NM_STR
1648 "Set the NM Busy Threshold in dB")
Holger Hans Peter Freyther697ed2b2010-04-25 23:08:39 +08001649{
1650 struct gsm_bts *bts = vty->index;
1651 bts->rach_b_thresh = atoi(argv[0]);
1652 return CMD_SUCCESS;
1653}
1654
1655DEFUN(cfg_bts_rach_nm_ldavg,
1656 cfg_bts_rach_nm_ldavg_cmd,
1657 "rach nm load average <0-65535>",
Harald Welte9e002452010-05-11 21:53:49 +02001658 RACH_STR NM_STR
1659 "Set the NM Loadaverage Slots value")
Holger Hans Peter Freyther697ed2b2010-04-25 23:08:39 +08001660{
1661 struct gsm_bts *bts = vty->index;
1662 bts->rach_ldavg_slots = atoi(argv[0]);
1663 return CMD_SUCCESS;
1664}
1665
Harald Welte (local)e19be3f2009-08-12 13:28:23 +02001666DEFUN(cfg_bts_cell_barred, cfg_bts_cell_barred_cmd,
1667 "cell barred (0|1)",
1668 "Should this cell be barred from access?")
1669{
1670 struct gsm_bts *bts = vty->index;
1671
Harald Welte8c973ba2009-12-21 23:08:18 +01001672 bts->si_common.rach_control.cell_bar = atoi(argv[0]);
Harald Welte (local)e19be3f2009-08-12 13:28:23 +02001673
1674 return CMD_SUCCESS;
1675}
1676
Holger Hans Peter Freyther440984b2010-05-14 00:39:19 +08001677DEFUN(cfg_bts_rach_ec_allowed, cfg_bts_rach_ec_allowed_cmd,
1678 "rach emergency call allowed (0|1)",
1679 "Should this cell allow emergency calls?")
1680{
1681 struct gsm_bts *bts = vty->index;
1682
1683 if (atoi(argv[0]) == 0)
1684 bts->si_common.rach_control.t2 |= 0x4;
1685 else
1686 bts->si_common.rach_control.t2 &= ~0x4;
1687
1688 return CMD_SUCCESS;
1689}
1690
Harald Welte (local)cbd46102009-08-13 10:14:26 +02001691DEFUN(cfg_bts_ms_max_power, cfg_bts_ms_max_power_cmd,
1692 "ms max power <0-40>",
1693 "Maximum transmit power of the MS")
1694{
1695 struct gsm_bts *bts = vty->index;
1696
1697 bts->ms_max_power = atoi(argv[0]);
1698
1699 return CMD_SUCCESS;
1700}
1701
Harald Welteb761bf82009-12-12 18:17:25 +01001702DEFUN(cfg_bts_cell_resel_hyst, cfg_bts_cell_resel_hyst_cmd,
1703 "cell reselection hysteresis <0-14>",
1704 "Cell Re-Selection Hysteresis in dB")
1705{
1706 struct gsm_bts *bts = vty->index;
1707
1708 bts->si_common.cell_sel_par.cell_resel_hyst = atoi(argv[0])/2;
1709
1710 return CMD_SUCCESS;
1711}
1712
1713DEFUN(cfg_bts_rxlev_acc_min, cfg_bts_rxlev_acc_min_cmd,
1714 "rxlev access min <0-63>",
1715 "Minimum RxLev needed for cell access (better than -110dBm)")
1716{
1717 struct gsm_bts *bts = vty->index;
1718
1719 bts->si_common.cell_sel_par.rxlev_acc_min = atoi(argv[0]);
1720
1721 return CMD_SUCCESS;
1722}
1723
Sylvain Munaut00d71462010-11-28 18:17:28 +01001724DEFUN(cfg_bts_cell_bar_qualify, cfg_bts_cell_bar_qualify_cmd,
1725 "cell bar qualify (0|1)",
1726 "Cell Bar Qualify")
1727{
1728 struct gsm_bts *bts = vty->index;
1729
1730 bts->si_common.cell_ro_sel_par.present = 1;
1731 bts->si_common.cell_ro_sel_par.cbq = atoi(argv[0]);
1732
1733 return CMD_SUCCESS;
1734}
1735
1736DEFUN(cfg_bts_cell_resel_ofs, cfg_bts_cell_resel_ofs_cmd,
1737 "cell reselection offset <0-126>",
1738 "Cell Re-Selection Offset in dB")
1739{
1740 struct gsm_bts *bts = vty->index;
1741
1742 bts->si_common.cell_ro_sel_par.present = 1;
1743 bts->si_common.cell_ro_sel_par.cell_resel_off = atoi(argv[0])/2;
1744
1745 return CMD_SUCCESS;
1746}
1747
1748DEFUN(cfg_bts_temp_ofs, cfg_bts_temp_ofs_cmd,
1749 "temporary offset <0-60>",
1750 "Cell selection temporary negative offset in dB")
1751{
1752 struct gsm_bts *bts = vty->index;
1753
1754 bts->si_common.cell_ro_sel_par.present = 1;
1755 bts->si_common.cell_ro_sel_par.temp_offs = atoi(argv[0])/10;
1756
1757 return CMD_SUCCESS;
1758}
1759
1760DEFUN(cfg_bts_temp_ofs_inf, cfg_bts_temp_ofs_inf_cmd,
1761 "temporary offset infinite",
1762 "Sets cell selection temporary negative offset to infinity")
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.temp_offs = 7;
1768
1769 return CMD_SUCCESS;
1770}
1771
1772DEFUN(cfg_bts_penalty_time, cfg_bts_penalty_time_cmd,
1773 "penalty time <20-620>",
1774 "Cell selection penalty time in seconds (by 20s increments)")
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.penalty_time = (atoi(argv[0])-20)/20;
1780
1781 return CMD_SUCCESS;
1782}
1783
1784DEFUN(cfg_bts_penalty_time_rsvd, cfg_bts_penalty_time_rsvd_cmd,
1785 "penalty time reserved",
1786 "Set cell selection penalty time to reserved value 31\n"
1787 "(indicate that CELL_RESELECT_OFFSET is subtracted from C2 "
1788 "and TEMPORARY_OFFSET is ignored)")
1789{
1790 struct gsm_bts *bts = vty->index;
1791
1792 bts->si_common.cell_ro_sel_par.present = 1;
1793 bts->si_common.cell_ro_sel_par.penalty_time = 31;
1794
1795 return CMD_SUCCESS;
1796}
1797
Harald Welte (local)b6ea7f72009-08-14 23:09:25 +02001798DEFUN(cfg_bts_per_loc_upd, cfg_bts_per_loc_upd_cmd,
1799 "periodic location update <0-1530>",
1800 "Periodic Location Updating Interval in Minutes")
1801{
1802 struct gsm_bts *bts = vty->index;
1803
Dieter Spaarb0f746d2010-10-05 21:10:55 +02001804 bts->si_common.chan_desc.t3212 = atoi(argv[0]) / 6;
Harald Welte (local)b6ea7f72009-08-14 23:09:25 +02001805
1806 return CMD_SUCCESS;
1807}
1808
Harald Welte9e002452010-05-11 21:53:49 +02001809#define GPRS_TEXT "GPRS Packet Network\n"
1810
Harald Welte410575a2010-03-14 23:30:30 +08001811DEFUN(cfg_bts_prs_bvci, cfg_bts_gprs_bvci_cmd,
Harald Welteb42fe342010-04-18 14:00:26 +02001812 "gprs cell bvci <2-65535>",
Harald Welte9e002452010-05-11 21:53:49 +02001813 GPRS_TEXT
1814 "GPRS Cell Settings\n"
Harald Welte3055e332010-03-14 15:37:43 +08001815 "GPRS BSSGP VC Identifier")
1816{
1817 struct gsm_bts *bts = vty->index;
1818
Harald Weltecb20b7a2010-04-18 15:51:20 +02001819 if (bts->gprs.mode == BTS_GPRS_NONE) {
Harald Weltec05a4b12010-03-14 23:56:56 +08001820 vty_out(vty, "%% GPRS not enabled on this BTS%s", VTY_NEWLINE);
1821 return CMD_WARNING;
1822 }
1823
Harald Welte3055e332010-03-14 15:37:43 +08001824 bts->gprs.cell.bvci = atoi(argv[0]);
1825
1826 return CMD_SUCCESS;
1827}
1828
Harald Welte4a048c52010-03-22 11:48:36 +08001829DEFUN(cfg_bts_gprs_nsei, cfg_bts_gprs_nsei_cmd,
1830 "gprs nsei <0-65535>",
Harald Welte9e002452010-05-11 21:53:49 +02001831 GPRS_TEXT
Harald Welte4a048c52010-03-22 11:48:36 +08001832 "GPRS NS Entity Identifier")
1833{
1834 struct gsm_bts *bts = vty->index;
1835
Harald Weltecb20b7a2010-04-18 15:51:20 +02001836 if (bts->gprs.mode == BTS_GPRS_NONE) {
Harald Welte4a048c52010-03-22 11:48:36 +08001837 vty_out(vty, "%% GPRS not enabled on this BTS%s", VTY_NEWLINE);
1838 return CMD_WARNING;
1839 }
1840
1841 bts->gprs.nse.nsei = atoi(argv[0]);
1842
1843 return CMD_SUCCESS;
1844}
1845
Harald Welte9e002452010-05-11 21:53:49 +02001846#define NSVC_TEXT "Network Service Virtual Connection (NS-VC)\n" \
1847 "NSVC Logical Number\n"
Harald Welte4a048c52010-03-22 11:48:36 +08001848
Harald Welte3055e332010-03-14 15:37:43 +08001849DEFUN(cfg_bts_gprs_nsvci, cfg_bts_gprs_nsvci_cmd,
1850 "gprs nsvc <0-1> nsvci <0-65535>",
Harald Welte9e002452010-05-11 21:53:49 +02001851 GPRS_TEXT NSVC_TEXT
1852 "NS Virtual Connection Identifier\n"
Harald Welte3055e332010-03-14 15:37:43 +08001853 "GPRS NS VC Identifier")
1854{
1855 struct gsm_bts *bts = vty->index;
1856 int idx = atoi(argv[0]);
1857
Harald Weltecb20b7a2010-04-18 15:51:20 +02001858 if (bts->gprs.mode == BTS_GPRS_NONE) {
Harald Weltec05a4b12010-03-14 23:56:56 +08001859 vty_out(vty, "%% GPRS not enabled on this BTS%s", VTY_NEWLINE);
1860 return CMD_WARNING;
1861 }
1862
Harald Welte3055e332010-03-14 15:37:43 +08001863 bts->gprs.nsvc[idx].nsvci = atoi(argv[1]);
1864
1865 return CMD_SUCCESS;
1866}
1867
Harald Welte410575a2010-03-14 23:30:30 +08001868DEFUN(cfg_bts_gprs_nsvc_lport, cfg_bts_gprs_nsvc_lport_cmd,
1869 "gprs nsvc <0-1> local udp port <0-65535>",
Harald Welte9e002452010-05-11 21:53:49 +02001870 GPRS_TEXT NSVC_TEXT
Harald Welte410575a2010-03-14 23:30:30 +08001871 "GPRS NS Local UDP Port")
1872{
1873 struct gsm_bts *bts = vty->index;
1874 int idx = atoi(argv[0]);
1875
Harald Weltecb20b7a2010-04-18 15:51:20 +02001876 if (bts->gprs.mode == BTS_GPRS_NONE) {
Harald Weltec05a4b12010-03-14 23:56:56 +08001877 vty_out(vty, "%% GPRS not enabled on this BTS%s", VTY_NEWLINE);
1878 return CMD_WARNING;
1879 }
1880
Harald Welte410575a2010-03-14 23:30:30 +08001881 bts->gprs.nsvc[idx].local_port = atoi(argv[1]);
1882
1883 return CMD_SUCCESS;
1884}
1885
1886DEFUN(cfg_bts_gprs_nsvc_rport, cfg_bts_gprs_nsvc_rport_cmd,
1887 "gprs nsvc <0-1> remote udp port <0-65535>",
Harald Welte9e002452010-05-11 21:53:49 +02001888 GPRS_TEXT NSVC_TEXT
Harald Welte410575a2010-03-14 23:30:30 +08001889 "GPRS NS Remote UDP Port")
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 Welte410575a2010-03-14 23:30:30 +08001899 bts->gprs.nsvc[idx].remote_port = atoi(argv[1]);
1900
1901 return CMD_SUCCESS;
1902}
1903
1904DEFUN(cfg_bts_gprs_nsvc_rip, cfg_bts_gprs_nsvc_rip_cmd,
1905 "gprs nsvc <0-1> remote ip A.B.C.D",
Harald Welte9e002452010-05-11 21:53:49 +02001906 GPRS_TEXT NSVC_TEXT
Harald Welte410575a2010-03-14 23:30:30 +08001907 "GPRS NS Remote IP Address")
1908{
1909 struct gsm_bts *bts = vty->index;
1910 int idx = atoi(argv[0]);
1911 struct in_addr ia;
1912
Harald Weltecb20b7a2010-04-18 15:51:20 +02001913 if (bts->gprs.mode == BTS_GPRS_NONE) {
Harald Weltec05a4b12010-03-14 23:56:56 +08001914 vty_out(vty, "%% GPRS not enabled on this BTS%s", VTY_NEWLINE);
1915 return CMD_WARNING;
1916 }
1917
Harald Welte410575a2010-03-14 23:30:30 +08001918 inet_aton(argv[1], &ia);
1919 bts->gprs.nsvc[idx].remote_ip = ntohl(ia.s_addr);
1920
1921 return CMD_SUCCESS;
1922}
1923
Holger Hans Peter Freyther3112f672010-09-06 10:11:25 +08001924DEFUN(cfg_bts_pag_free, cfg_bts_pag_free_cmd,
1925 "paging free FREE_NR",
1926 "Only page when having a certain amount of free slots. -1 to disable")
1927{
1928 struct gsm_bts *bts = vty->index;
1929
1930 bts->paging.free_chans_need = atoi(argv[0]);
1931 return CMD_SUCCESS;
1932}
1933
Harald Weltea9251762010-05-11 23:50:21 +02001934DEFUN(cfg_bts_gprs_ns_timer, cfg_bts_gprs_ns_timer_cmd,
1935 "gprs ns timer " NS_TIMERS " <0-255>",
1936 GPRS_TEXT "Network Service\n"
1937 "Network Service Timer\n"
1938 NS_TIMERS_HELP "Timer Value\n")
1939{
1940 struct gsm_bts *bts = vty->index;
1941 int idx = get_string_value(gprs_ns_timer_strs, argv[0]);
1942 int val = atoi(argv[1]);
1943
1944 if (bts->gprs.mode == BTS_GPRS_NONE) {
1945 vty_out(vty, "%% GPRS not enabled on this BTS%s", VTY_NEWLINE);
1946 return CMD_WARNING;
1947 }
1948
1949 if (idx < 0 || idx >= ARRAY_SIZE(bts->gprs.nse.timer))
1950 return CMD_WARNING;
1951
1952 bts->gprs.nse.timer[idx] = val;
1953
1954 return CMD_SUCCESS;
1955}
1956
1957#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 +02001958#define BSSGP_TIMERS_HELP \
1959 "Tbvc-block timeout\n" \
1960 "Tbvc-block retries\n" \
1961 "Tbvc-unblock retries\n" \
1962 "Tbvcc-reset timeout\n" \
1963 "Tbvc-reset retries\n" \
1964 "Tbvc-suspend timeout\n" \
1965 "Tbvc-suspend retries\n" \
1966 "Tbvc-resume timeout\n" \
1967 "Tbvc-resume retries\n" \
1968 "Tbvc-capa-update timeout\n" \
1969 "Tbvc-capa-update retries\n"
Harald Weltea9251762010-05-11 23:50:21 +02001970
1971DEFUN(cfg_bts_gprs_cell_timer, cfg_bts_gprs_cell_timer_cmd,
1972 "gprs cell timer " BSSGP_TIMERS " <0-255>",
1973 GPRS_TEXT "Cell / BSSGP\n"
1974 "Cell/BSSGP Timer\n"
1975 BSSGP_TIMERS_HELP "Timer Value\n")
1976{
1977 struct gsm_bts *bts = vty->index;
1978 int idx = get_string_value(gprs_bssgp_cfg_strs, argv[0]);
1979 int val = atoi(argv[1]);
1980
1981 if (bts->gprs.mode == BTS_GPRS_NONE) {
1982 vty_out(vty, "%% GPRS not enabled on this BTS%s", VTY_NEWLINE);
1983 return CMD_WARNING;
1984 }
1985
1986 if (idx < 0 || idx >= ARRAY_SIZE(bts->gprs.cell.timer))
1987 return CMD_WARNING;
1988
1989 bts->gprs.cell.timer[idx] = val;
1990
1991 return CMD_SUCCESS;
1992}
1993
Harald Welte3055e332010-03-14 15:37:43 +08001994DEFUN(cfg_bts_gprs_rac, cfg_bts_gprs_rac_cmd,
1995 "gprs routing area <0-255>",
Harald Welte9e002452010-05-11 21:53:49 +02001996 GPRS_TEXT
Harald Welte3055e332010-03-14 15:37:43 +08001997 "GPRS Routing Area Code")
1998{
1999 struct gsm_bts *bts = vty->index;
2000
Harald Weltecb20b7a2010-04-18 15:51:20 +02002001 if (bts->gprs.mode == BTS_GPRS_NONE) {
Harald Weltec05a4b12010-03-14 23:56:56 +08002002 vty_out(vty, "%% GPRS not enabled on this BTS%s", VTY_NEWLINE);
2003 return CMD_WARNING;
2004 }
2005
Harald Welte3055e332010-03-14 15:37:43 +08002006 bts->gprs.rac = atoi(argv[0]);
2007
2008 return CMD_SUCCESS;
2009}
2010
Harald Weltecb20b7a2010-04-18 15:51:20 +02002011DEFUN(cfg_bts_gprs_mode, cfg_bts_gprs_mode_cmd,
2012 "gprs mode (none|gprs|egprs)",
Harald Welte9e002452010-05-11 21:53:49 +02002013 GPRS_TEXT
2014 "GPRS Mode for this BTS\n"
2015 "GPRS Disabled on this BTS\n"
2016 "GPRS Enabled on this BTS\n"
2017 "EGPRS (EDGE) Enabled on this BTS\n")
Harald Welte410575a2010-03-14 23:30:30 +08002018{
2019 struct gsm_bts *bts = vty->index;
Harald Welte20e275a2010-06-14 22:44:42 +02002020 enum bts_gprs_mode mode = bts_gprs_mode_parse(argv[0]);
Harald Welte410575a2010-03-14 23:30:30 +08002021
Harald Welte20e275a2010-06-14 22:44:42 +02002022 if (mode != BTS_GPRS_NONE &&
2023 !gsm_bts_has_feature(bts, BTS_FEAT_GPRS)) {
2024 vty_out(vty, "This BTS type does not support %s%s", argv[0],
2025 VTY_NEWLINE);
2026 return CMD_WARNING;
2027 }
2028 if (mode == BTS_GPRS_EGPRS &&
2029 !gsm_bts_has_feature(bts, BTS_FEAT_EGPRS)) {
2030 vty_out(vty, "This BTS type does not support %s%s", argv[0],
2031 VTY_NEWLINE);
2032 return CMD_WARNING;
2033 }
2034
2035 bts->gprs.mode = mode;
Harald Welte410575a2010-03-14 23:30:30 +08002036
2037 return CMD_SUCCESS;
2038}
2039
Harald Welted8acf142010-07-30 11:50:09 +02002040#define SI_TEXT "System Information Messages\n"
2041#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)"
2042#define SI_TYPE_HELP "System Information Type 1\n" \
2043 "System Information Type 2\n" \
2044 "System Information Type 3\n" \
2045 "System Information Type 4\n" \
2046 "System Information Type 5\n" \
2047 "System Information Type 6\n" \
2048 "System Information Type 7\n" \
2049 "System Information Type 8\n" \
2050 "System Information Type 9\n" \
2051 "System Information Type 10\n" \
2052 "System Information Type 13\n" \
2053 "System Information Type 16\n" \
2054 "System Information Type 17\n" \
2055 "System Information Type 18\n" \
2056 "System Information Type 19\n" \
2057 "System Information Type 20\n" \
2058 "System Information Type 2bis\n" \
2059 "System Information Type 2ter\n" \
2060 "System Information Type 2quater\n" \
2061 "System Information Type 5bis\n" \
2062 "System Information Type 5ter\n"
2063
2064DEFUN(cfg_bts_si_mode, cfg_bts_si_mode_cmd,
2065 "system-information " SI_TYPE_TEXT " mode (static|computed)",
2066 SI_TEXT SI_TYPE_HELP
2067 "System Information Mode\n"
2068 "Static user-specified\n"
2069 "Dynamic, BSC-computed\n")
2070{
2071 struct gsm_bts *bts = vty->index;
2072 int type;
2073
2074 type = get_string_value(osmo_sitype_strs, argv[0]);
2075 if (type < 0) {
2076 vty_out(vty, "Error SI Type%s", VTY_NEWLINE);
2077 return CMD_WARNING;
2078 }
2079
2080 if (!strcmp(argv[1], "static"))
2081 bts->si_mode_static |= (1 << type);
2082 else
2083 bts->si_mode_static &= ~(1 << type);
2084
2085 return CMD_SUCCESS;
2086}
2087
2088DEFUN(cfg_bts_si_static, cfg_bts_si_static_cmd,
2089 "system-information " SI_TYPE_TEXT " static HEXSTRING",
2090 SI_TEXT SI_TYPE_HELP
2091 "Static System Information filling\n"
2092 "Static user-specified SI content in HEX notation\n")
2093{
2094 struct gsm_bts *bts = vty->index;
2095 int rc, type;
2096
2097 type = get_string_value(osmo_sitype_strs, argv[0]);
2098 if (type < 0) {
2099 vty_out(vty, "Error SI Type%s", VTY_NEWLINE);
2100 return CMD_WARNING;
2101 }
2102
2103 if (!(bts->si_mode_static & (1 << type))) {
2104 vty_out(vty, "SI Type %s is not configured in static mode%s",
2105 get_value_string(osmo_sitype_strs, type), VTY_NEWLINE);
2106 return CMD_WARNING;
2107 }
2108
Harald Welte9f09ac32010-07-30 11:53:18 +02002109 /* Fill buffer with padding pattern */
2110 memset(bts->si_buf[type], 0x2b, sizeof(bts->si_buf[type]));
2111
2112 /* Parse the user-specified SI in hex format, [partially] overwriting padding */
Pablo Neira Ayusob1d5a692011-05-07 12:12:48 +02002113 rc = osmo_hexparse(argv[1], bts->si_buf[type], sizeof(bts->si_buf[0]));
Harald Welted8acf142010-07-30 11:50:09 +02002114 if (rc < 0 || rc > sizeof(bts->si_buf[0])) {
2115 vty_out(vty, "Error parsing HEXSTRING%s", VTY_NEWLINE);
2116 return CMD_WARNING;
2117 }
2118
2119 /* Mark this SI as present */
2120 bts->si_valid |= (1 << type);
2121
2122 return CMD_SUCCESS;
2123}
2124
Harald Welteca46eff2011-01-11 23:44:56 +01002125DEFUN(cfg_bts_neigh_mode, cfg_bts_neigh_mode_cmd,
Harald Weltef989b782011-02-15 11:43:27 +01002126 "neighbor-list mode (automatic|manual|manual-si5)",
Harald Welteca46eff2011-01-11 23:44:56 +01002127 "Neighbor List\n" "Mode of Neighbor List generation\n"
Harald Weltef989b782011-02-15 11:43:27 +01002128 "Automatically from all BTS in this OpenBSC\n" "Manual\n"
2129 "Manual with different lists for SI2 and SI5\n")
Harald Welteca46eff2011-01-11 23:44:56 +01002130{
2131 struct gsm_bts *bts = vty->index;
Harald Weltef989b782011-02-15 11:43:27 +01002132 int mode = get_string_value(bts_neigh_mode_strs, argv[0]);
Harald Welteca46eff2011-01-11 23:44:56 +01002133
Harald Weltef989b782011-02-15 11:43:27 +01002134 switch (mode) {
2135 case NL_MODE_MANUAL_SI5SEP:
2136 case NL_MODE_MANUAL:
Harald Welteca46eff2011-01-11 23:44:56 +01002137 /* make sure we clear the current list when switching to
2138 * manual mode */
2139 if (bts->neigh_list_manual_mode == 0)
2140 memset(&bts->si_common.data.neigh_list, 0,
2141 sizeof(bts->si_common.data.neigh_list));
Harald Weltef989b782011-02-15 11:43:27 +01002142 break;
2143 default:
2144 break;
2145 }
2146
2147 bts->neigh_list_manual_mode = mode;
Harald Welteca46eff2011-01-11 23:44:56 +01002148
2149 return CMD_SUCCESS;
2150}
2151
2152DEFUN(cfg_bts_neigh, cfg_bts_neigh_cmd,
2153 "neighbor-list (add|del) arfcn <0-1024>",
2154 "Neighbor List\n" "Add to manual neighbor list\n"
2155 "Delete from manual neighbor list\n" "ARFCN of neighbor\n"
2156 "ARFCN of neighbor\n")
2157{
2158 struct gsm_bts *bts = vty->index;
2159 struct bitvec *bv = &bts->si_common.neigh_list;
2160 uint16_t arfcn = atoi(argv[1]);
2161
2162 if (!bts->neigh_list_manual_mode) {
2163 vty_out(vty, "%% Cannot configure neighbor list in "
2164 "automatic mode%s", VTY_NEWLINE);
2165 return CMD_WARNING;
2166 }
2167
2168 if (!strcmp(argv[0], "add"))
2169 bitvec_set_bit_pos(bv, arfcn, 1);
2170 else
2171 bitvec_set_bit_pos(bv, arfcn, 0);
2172
2173 return CMD_SUCCESS;
2174}
2175
Harald Weltef989b782011-02-15 11:43:27 +01002176DEFUN(cfg_bts_si5_neigh, cfg_bts_si5_neigh_cmd,
2177 "si5 neighbor-list (add|del) arfcn <0-1024>",
2178 "SI5 Neighbor List\n" "Add to manual SI5 neighbor list\n"
2179 "Delete from SI5 manual neighbor list\n" "ARFCN of neighbor\n"
2180 "ARFCN of neighbor\n")
2181{
2182 struct gsm_bts *bts = vty->index;
2183 struct bitvec *bv = &bts->si_common.si5_neigh_list;
2184 uint16_t arfcn = atoi(argv[1]);
2185
2186 if (!bts->neigh_list_manual_mode) {
2187 vty_out(vty, "%% Cannot configure neighbor list in "
2188 "automatic mode%s", VTY_NEWLINE);
2189 return CMD_WARNING;
2190 }
2191
2192 if (!strcmp(argv[0], "add"))
2193 bitvec_set_bit_pos(bv, arfcn, 1);
2194 else
2195 bitvec_set_bit_pos(bv, arfcn, 0);
2196
2197 return CMD_SUCCESS;
2198}
Harald Welted8acf142010-07-30 11:50:09 +02002199
Harald Welte9e002452010-05-11 21:53:49 +02002200#define TRX_TEXT "Radio Transceiver\n"
Harald Welte3e774612009-08-10 13:48:16 +02002201
Harald Welte59b04682009-06-10 05:40:52 +08002202/* per TRX configuration */
2203DEFUN(cfg_trx,
2204 cfg_trx_cmd,
2205 "trx TRX_NR",
Harald Welte9e002452010-05-11 21:53:49 +02002206 TRX_TEXT
Harald Welte59b04682009-06-10 05:40:52 +08002207 "Select a TRX to configure")
2208{
2209 int trx_nr = atoi(argv[0]);
2210 struct gsm_bts *bts = vty->index;
2211 struct gsm_bts_trx *trx;
2212
Harald Weltee712a5f2009-06-21 16:17:15 +02002213 if (trx_nr > bts->num_trx) {
2214 vty_out(vty, "%% The next unused TRX number in this BTS is %u%s",
2215 bts->num_trx, VTY_NEWLINE);
Harald Welte59b04682009-06-10 05:40:52 +08002216 return CMD_WARNING;
Harald Weltee712a5f2009-06-21 16:17:15 +02002217 } else if (trx_nr == bts->num_trx) {
2218 /* we need to allocate a new one */
2219 trx = gsm_bts_trx_alloc(bts);
Holger Hans Peter Freyther71135142010-03-29 08:47:44 +02002220 } else
Harald Weltee712a5f2009-06-21 16:17:15 +02002221 trx = gsm_bts_trx_num(bts, trx_nr);
Holger Hans Peter Freyther71135142010-03-29 08:47:44 +02002222
Harald Weltee712a5f2009-06-21 16:17:15 +02002223 if (!trx)
2224 return CMD_WARNING;
Harald Welte59b04682009-06-10 05:40:52 +08002225
2226 vty->index = trx;
Harald Welte8791dac2010-05-14 17:59:53 +02002227 vty->index_sub = &trx->description;
Harald Welte59b04682009-06-10 05:40:52 +08002228 vty->node = TRX_NODE;
2229
2230 return CMD_SUCCESS;
2231}
2232
2233DEFUN(cfg_trx_arfcn,
2234 cfg_trx_arfcn_cmd,
Harald Welte00044592010-05-14 19:00:52 +02002235 "arfcn <0-1024>",
Harald Welte59b04682009-06-10 05:40:52 +08002236 "Set the ARFCN for this TRX\n")
2237{
2238 int arfcn = atoi(argv[0]);
2239 struct gsm_bts_trx *trx = vty->index;
2240
2241 /* FIXME: check if this ARFCN is supported by this TRX */
2242
2243 trx->arfcn = arfcn;
2244
2245 /* FIXME: patch ARFCN into SYSTEM INFORMATION */
2246 /* FIXME: use OML layer to update the ARFCN */
2247 /* FIXME: use RSL layer to update SYSTEM INFORMATION */
2248
2249 return CMD_SUCCESS;
2250}
2251
Harald Welte (local)b709bfe2009-12-27 20:56:38 +01002252DEFUN(cfg_trx_nominal_power,
2253 cfg_trx_nominal_power_cmd,
2254 "nominal power <0-100>",
2255 "Nominal TRX RF Power in dB\n")
2256{
2257 struct gsm_bts_trx *trx = vty->index;
2258
2259 trx->nominal_power = atoi(argv[0]);
2260
2261 return CMD_SUCCESS;
2262}
2263
Harald Welte91afe4c2009-06-20 18:15:19 +02002264DEFUN(cfg_trx_max_power_red,
2265 cfg_trx_max_power_red_cmd,
2266 "max_power_red <0-100>",
2267 "Reduction of maximum BS RF Power in dB\n")
2268{
2269 int maxpwr_r = atoi(argv[0]);
2270 struct gsm_bts_trx *trx = vty->index;
Harald Welte01acd742009-11-18 09:20:22 +01002271 int upper_limit = 24; /* default 12.21 max power red. */
Harald Welte91afe4c2009-06-20 18:15:19 +02002272
2273 /* FIXME: check if our BTS type supports more than 12 */
2274 if (maxpwr_r < 0 || maxpwr_r > upper_limit) {
2275 vty_out(vty, "%% Power %d dB is not in the valid range%s",
2276 maxpwr_r, VTY_NEWLINE);
2277 return CMD_WARNING;
2278 }
2279 if (maxpwr_r & 1) {
2280 vty_out(vty, "%% Power %d dB is not an even value%s",
2281 maxpwr_r, VTY_NEWLINE);
2282 return CMD_WARNING;
2283 }
2284
2285 trx->max_power_red = maxpwr_r;
2286
2287 /* FIXME: make sure we update this using OML */
2288
2289 return CMD_SUCCESS;
2290}
2291
Harald Welte62868882009-08-08 16:12:58 +02002292DEFUN(cfg_trx_rsl_e1,
2293 cfg_trx_rsl_e1_cmd,
2294 "rsl e1 line E1_LINE timeslot <1-31> sub-slot (0|1|2|3|full)",
2295 "E1 interface to be used for RSL\n")
2296{
2297 struct gsm_bts_trx *trx = vty->index;
2298
2299 parse_e1_link(&trx->rsl_e1_link, argv[0], argv[1], argv[2]);
2300
2301 return CMD_SUCCESS;
2302}
2303
2304DEFUN(cfg_trx_rsl_e1_tei,
2305 cfg_trx_rsl_e1_tei_cmd,
2306 "rsl e1 tei <0-63>",
2307 "Set the TEI to be used for RSL")
2308{
2309 struct gsm_bts_trx *trx = vty->index;
2310
2311 trx->rsl_tei = atoi(argv[0]);
2312
2313 return CMD_SUCCESS;
2314}
2315
Holger Hans Peter Freyther1c8b4802009-11-11 11:54:24 +01002316DEFUN(cfg_trx_rf_locked,
2317 cfg_trx_rf_locked_cmd,
2318 "rf_locked (0|1)",
2319 "Turn off RF of the TRX.\n")
2320{
2321 int locked = atoi(argv[0]);
2322 struct gsm_bts_trx *trx = vty->index;
2323
2324 gsm_trx_lock_rf(trx, locked);
2325 return CMD_SUCCESS;
2326}
Harald Welte62868882009-08-08 16:12:58 +02002327
Harald Welte59b04682009-06-10 05:40:52 +08002328/* per TS configuration */
2329DEFUN(cfg_ts,
2330 cfg_ts_cmd,
Harald Welte62868882009-08-08 16:12:58 +02002331 "timeslot <0-7>",
Harald Welte59b04682009-06-10 05:40:52 +08002332 "Select a Timeslot to configure")
2333{
2334 int ts_nr = atoi(argv[0]);
2335 struct gsm_bts_trx *trx = vty->index;
2336 struct gsm_bts_trx_ts *ts;
2337
2338 if (ts_nr >= TRX_NR_TS) {
2339 vty_out(vty, "%% A GSM TRX only has %u Timeslots per TRX%s",
2340 TRX_NR_TS, VTY_NEWLINE);
2341 return CMD_WARNING;
2342 }
2343
2344 ts = &trx->ts[ts_nr];
2345
2346 vty->index = ts;
2347 vty->node = TS_NODE;
2348
2349 return CMD_SUCCESS;
2350}
2351
Harald Welte3ffe1b32009-08-07 00:25:23 +02002352DEFUN(cfg_ts_pchan,
2353 cfg_ts_pchan_cmd,
2354 "phys_chan_config PCHAN",
2355 "Physical Channel configuration (TCH/SDCCH/...)")
2356{
2357 struct gsm_bts_trx_ts *ts = vty->index;
2358 int pchanc;
2359
2360 pchanc = gsm_pchan_parse(argv[0]);
2361 if (pchanc < 0)
2362 return CMD_WARNING;
2363
2364 ts->pchan = pchanc;
2365
2366 return CMD_SUCCESS;
2367}
2368
Harald Welte85771a42011-05-30 12:09:13 +02002369DEFUN(cfg_ts_tsc,
2370 cfg_ts_tsc_cmd,
2371 "training_sequence_code <0-7>",
2372 "Training Sequence Code")
2373{
2374 struct gsm_bts_trx_ts *ts = vty->index;
2375
2376 ts->tsc = atoi(argv[0]);
2377
2378 return CMD_SUCCESS;
2379}
2380
Harald Weltea42a93f2010-06-14 22:26:10 +02002381#define HOPPING_STR "Configure frequency hopping\n"
2382
2383DEFUN(cfg_ts_hopping,
2384 cfg_ts_hopping_cmd,
2385 "hopping enabled (0|1)",
2386 HOPPING_STR "Enable or disable frequency hopping\n"
2387 "Disable frequency hopping\n" "Enable frequency hopping\n")
2388{
2389 struct gsm_bts_trx_ts *ts = vty->index;
Harald Welte059c1ef2010-06-14 22:47:37 +02002390 int enabled = atoi(argv[0]);
Harald Weltea42a93f2010-06-14 22:26:10 +02002391
Harald Welte059c1ef2010-06-14 22:47:37 +02002392 if (enabled && !gsm_bts_has_feature(ts->trx->bts, BTS_FEAT_HOPPING)) {
2393 vty_out(vty, "BTS model does not support hopping%s",
2394 VTY_NEWLINE);
2395 return CMD_WARNING;
2396 }
2397
2398 ts->hopping.enabled = enabled;
Harald Weltea42a93f2010-06-14 22:26:10 +02002399
2400 return CMD_SUCCESS;
2401}
2402
Harald Welte67104d12009-09-12 13:05:33 +02002403DEFUN(cfg_ts_hsn,
2404 cfg_ts_hsn_cmd,
Harald Weltea42a93f2010-06-14 22:26:10 +02002405 "hopping sequence-number <0-63>",
2406 HOPPING_STR
Harald Welte67104d12009-09-12 13:05:33 +02002407 "Which hopping sequence to use for this channel")
2408{
2409 struct gsm_bts_trx_ts *ts = vty->index;
2410
2411 ts->hopping.hsn = atoi(argv[0]);
2412
2413 return CMD_SUCCESS;
2414}
2415
2416DEFUN(cfg_ts_maio,
2417 cfg_ts_maio_cmd,
2418 "hopping maio <0-63>",
Harald Weltea42a93f2010-06-14 22:26:10 +02002419 HOPPING_STR
Harald Welte67104d12009-09-12 13:05:33 +02002420 "Which hopping MAIO to use for this channel")
2421{
2422 struct gsm_bts_trx_ts *ts = vty->index;
2423
2424 ts->hopping.maio = atoi(argv[0]);
2425
2426 return CMD_SUCCESS;
2427}
2428
2429DEFUN(cfg_ts_arfcn_add,
2430 cfg_ts_arfcn_add_cmd,
2431 "hopping arfcn add <0-1023>",
Harald Weltea42a93f2010-06-14 22:26:10 +02002432 HOPPING_STR "Configure hopping ARFCN list\n"
2433 "Add an entry to the hopping ARFCN list\n" "ARFCN\n")
Harald Welte67104d12009-09-12 13:05:33 +02002434{
2435 struct gsm_bts_trx_ts *ts = vty->index;
2436 int arfcn = atoi(argv[0]);
2437
Harald Weltea42a93f2010-06-14 22:26:10 +02002438 bitvec_set_bit_pos(&ts->hopping.arfcns, arfcn, 1);
2439
Harald Welte67104d12009-09-12 13:05:33 +02002440 return CMD_SUCCESS;
2441}
2442
2443DEFUN(cfg_ts_arfcn_del,
2444 cfg_ts_arfcn_del_cmd,
2445 "hopping arfcn del <0-1023>",
Harald Weltea42a93f2010-06-14 22:26:10 +02002446 HOPPING_STR "Configure hopping ARFCN list\n"
2447 "Delete an entry to the hopping ARFCN list\n" "ARFCN\n")
Harald Welte67104d12009-09-12 13:05:33 +02002448{
2449 struct gsm_bts_trx_ts *ts = vty->index;
2450 int arfcn = atoi(argv[0]);
2451
Harald Weltea42a93f2010-06-14 22:26:10 +02002452 bitvec_set_bit_pos(&ts->hopping.arfcns, arfcn, 0);
2453
Harald Welte67104d12009-09-12 13:05:33 +02002454 return CMD_SUCCESS;
2455}
2456
Harald Welte3ffe1b32009-08-07 00:25:23 +02002457DEFUN(cfg_ts_e1_subslot,
2458 cfg_ts_e1_subslot_cmd,
Harald Welte62868882009-08-08 16:12:58 +02002459 "e1 line E1_LINE timeslot <1-31> sub-slot (0|1|2|3|full)",
Harald Welte3ffe1b32009-08-07 00:25:23 +02002460 "E1 sub-slot connected to this on-air timeslot")
2461{
2462 struct gsm_bts_trx_ts *ts = vty->index;
2463
Harald Welte62868882009-08-08 16:12:58 +02002464 parse_e1_link(&ts->e1_link, argv[0], argv[1], argv[2]);
Harald Welte3ffe1b32009-08-07 00:25:23 +02002465
2466 return CMD_SUCCESS;
2467}
Harald Welte59b04682009-06-10 05:40:52 +08002468
Harald Weltea5b1dae2010-05-16 21:47:13 +02002469void openbsc_vty_print_statistics(struct vty *vty, struct gsm_network *net)
2470{
2471 vty_out(vty, "Channel Requests : %lu total, %lu no channel%s",
Pablo Neira Ayuso1c450742011-05-06 12:13:10 +02002472 osmo_counter_get(net->stats.chreq.total),
2473 osmo_counter_get(net->stats.chreq.no_channel), VTY_NEWLINE);
Harald Weltea5b1dae2010-05-16 21:47:13 +02002474 vty_out(vty, "Channel Failures : %lu rf_failures, %lu rll failures%s",
Pablo Neira Ayuso1c450742011-05-06 12:13:10 +02002475 osmo_counter_get(net->stats.chan.rf_fail),
2476 osmo_counter_get(net->stats.chan.rll_err), VTY_NEWLINE);
Harald Weltea5b1dae2010-05-16 21:47:13 +02002477 vty_out(vty, "Paging : %lu attempted, %lu complete, %lu expired%s",
Pablo Neira Ayuso1c450742011-05-06 12:13:10 +02002478 osmo_counter_get(net->stats.paging.attempted),
2479 osmo_counter_get(net->stats.paging.completed),
2480 osmo_counter_get(net->stats.paging.expired), VTY_NEWLINE);
Harald Weltea5b1dae2010-05-16 21:47:13 +02002481 vty_out(vty, "BTS failures : %lu OML, %lu RSL%s",
Pablo Neira Ayuso1c450742011-05-06 12:13:10 +02002482 osmo_counter_get(net->stats.bts.oml_fail),
2483 osmo_counter_get(net->stats.bts.rsl_fail), VTY_NEWLINE);
Harald Weltea5b1dae2010-05-16 21:47:13 +02002484}
2485
Harald Welte682ee5f2010-05-16 22:02:16 +02002486DEFUN(logging_fltr_imsi,
2487 logging_fltr_imsi_cmd,
2488 "logging filter imsi IMSI",
2489 LOGGING_STR FILTER_STR
2490 "Filter log messages by IMSI\n" "IMSI to be used as filter\n")
2491{
Harald Welte58bef962011-02-18 21:10:05 +01002492 struct log_target *tgt = osmo_log_vty2tgt(vty);
Harald Welte682ee5f2010-05-16 22:02:16 +02002493
Harald Welte58bef962011-02-18 21:10:05 +01002494 if (!tgt)
Harald Welte682ee5f2010-05-16 22:02:16 +02002495 return CMD_WARNING;
Harald Welte682ee5f2010-05-16 22:02:16 +02002496
Harald Welte58bef962011-02-18 21:10:05 +01002497 log_set_imsi_filter(tgt, argv[0]);
Harald Welte682ee5f2010-05-16 22:02:16 +02002498 return CMD_SUCCESS;
2499}
2500
Harald Welte58bef962011-02-18 21:10:05 +01002501
Holger Hans Peter Freyther07ff1c32010-10-26 09:40:13 +02002502DEFUN(drop_bts,
2503 drop_bts_cmd,
Holger Hans Peter Freythere4ac0e42010-04-11 12:46:45 +02002504 "drop bts connection <0-65535> (oml|rsl)",
2505 "Debug/Simulation command to drop ipaccess BTS\n"
2506 "BTS NR\n" "Connection Type\n")
Holger Hans Peter Freyther07ff1c32010-10-26 09:40:13 +02002507{
2508 struct gsm_network *gsmnet;
2509 struct gsm_bts_trx *trx;
2510 struct gsm_bts *bts;
2511 unsigned int bts_nr;
2512
2513 gsmnet = gsmnet_from_vty(vty);
2514
2515 bts_nr = atoi(argv[0]);
2516 if (bts_nr >= gsmnet->num_bts) {
2517 vty_out(vty, "BTS number must be between 0 and %d. It was %d.%s",
2518 gsmnet->num_bts, bts_nr, VTY_NEWLINE);
2519 return CMD_WARNING;
2520 }
2521
2522 bts = gsm_bts_num(gsmnet, bts_nr);
2523 if (!bts) {
2524 vty_out(vty, "BTS Nr. %d could not be found.%s", bts_nr, VTY_NEWLINE);
2525 return CMD_WARNING;
2526 }
2527
2528 if (!is_ipaccess_bts(bts)) {
2529 vty_out(vty, "This command only works for ipaccess.%s", VTY_NEWLINE);
2530 return CMD_WARNING;
2531 }
2532
2533
2534 /* close all connections */
2535 if (strcmp(argv[1], "oml") == 0) {
Holger Hans Peter Freyther03f17d02010-11-15 20:29:46 +01002536 ipaccess_drop_oml(bts);
Holger Hans Peter Freyther07ff1c32010-10-26 09:40:13 +02002537 } else if (strcmp(argv[1], "rsl") == 0) {
2538 /* close all rsl connections */
2539 llist_for_each_entry(trx, &bts->trx_list, list) {
Holger Hans Peter Freyther03f17d02010-11-15 20:29:46 +01002540 ipaccess_drop_rsl(trx);
Holger Hans Peter Freyther07ff1c32010-10-26 09:40:13 +02002541 }
2542 } else {
2543 vty_out(vty, "Argument must be 'oml# or 'rsl'.%s", VTY_NEWLINE);
2544 return CMD_WARNING;
2545 }
2546
2547 return CMD_SUCCESS;
2548}
2549
Harald Welte5213e992010-12-23 13:18:07 +01002550DEFUN(pdch_act, pdch_act_cmd,
2551 "bts <0-255> trx <0-255> timeslot <0-7> pdch (activate|deactivate)",
2552 "BTS related commands\n" "BTS Number\n" "Transceiver\n" "Transceiver Number\n"
2553 "TRX Timeslot\n" "Timeslot Number\n" "Packet Data Channel\n"
2554 "Activate Dynamic PDCH/TCH (-> PDCH mode)\n"
2555 "Deactivate Dynamic PDCH/TCH (-> TCH mode)\n")
2556{
2557 struct gsm_bts *bts;
2558 struct gsm_bts_trx *trx;
2559 struct gsm_bts_trx_ts *ts;
2560 int bts_nr = atoi(argv[0]);
2561 int trx_nr = atoi(argv[1]);
2562 int ts_nr = atoi(argv[2]);
2563 int activate;
2564
2565 bts = gsm_bts_num(bsc_gsmnet, bts_nr);
2566 if (!bts) {
2567 vty_out(vty, "%% No such BTS (%d)%s", bts_nr, VTY_NEWLINE);
2568 return CMD_WARNING;
2569 }
2570
2571 if (!is_ipaccess_bts(bts)) {
2572 vty_out(vty, "%% This command only works for ipaccess BTS%s",
2573 VTY_NEWLINE);
2574 return CMD_WARNING;
2575 }
2576
2577 trx = gsm_bts_trx_num(bts, trx_nr);
2578 if (!trx) {
2579 vty_out(vty, "%% No such TRX (%d)%s", trx_nr, VTY_NEWLINE);
2580 return CMD_WARNING;
2581 }
2582
2583 ts = &trx->ts[ts_nr];
2584 if (ts->pchan != GSM_PCHAN_TCH_F_PDCH) {
2585 vty_out(vty, "%% Timeslot %u is not in dynamic TCH_F/PDCH "
2586 "mode%s", ts_nr, VTY_NEWLINE);
2587 return CMD_WARNING;
2588 }
2589
2590 if (!strcmp(argv[3], "activate"))
2591 activate = 1;
2592 else
2593 activate = 0;
2594
2595 rsl_ipacc_pdch_activate(ts, activate);
2596
2597 return CMD_SUCCESS;
2598
2599}
Holger Hans Peter Freyther07ff1c32010-10-26 09:40:13 +02002600
Harald Welte40152872010-05-16 20:52:23 +02002601extern int bsc_vty_init_extra(void);
Harald Welte10c29f62010-05-16 19:20:24 +02002602extern const char *openbsc_copyright;
Holger Hans Peter Freytherc48a2a12010-04-10 00:08:28 +02002603
Pablo Neira Ayuso36ad9a42011-03-09 13:36:32 +01002604int bsc_vty_init(const struct log_info *cat)
Harald Welte59b04682009-06-10 05:40:52 +08002605{
Harald Welte7bc28f62010-05-12 16:10:35 +00002606 install_element_ve(&show_net_cmd);
2607 install_element_ve(&show_bts_cmd);
2608 install_element_ve(&show_trx_cmd);
2609 install_element_ve(&show_ts_cmd);
2610 install_element_ve(&show_lchan_cmd);
Holger Hans Peter Freythere959b4e2010-05-14 02:08:49 +08002611 install_element_ve(&show_lchan_summary_cmd);
Harald Welte682ee5f2010-05-16 22:02:16 +02002612 install_element_ve(&logging_fltr_imsi_cmd);
Harald Welte59b04682009-06-10 05:40:52 +08002613
Harald Welte7bc28f62010-05-12 16:10:35 +00002614 install_element_ve(&show_paging_cmd);
Harald Welte59b04682009-06-10 05:40:52 +08002615
Pablo Neira Ayuso36ad9a42011-03-09 13:36:32 +01002616 logging_vty_add_cmds(cat);
Harald Welte58bef962011-02-18 21:10:05 +01002617 install_element(CFG_LOG_NODE, &logging_fltr_imsi_cmd);
Holger Hans Peter Freytherc8d862e2009-12-22 22:32:51 +01002618
Harald Weltee87eb462009-08-07 13:29:14 +02002619 install_element(CONFIG_NODE, &cfg_net_cmd);
2620 install_node(&net_node, config_write_net);
2621 install_default(GSMNET_NODE);
Harald Welte58ed1cb2010-05-14 18:59:17 +02002622 install_element(GSMNET_NODE, &ournode_exit_cmd);
Harald Weltedc82b9b2010-05-14 19:11:04 +02002623 install_element(GSMNET_NODE, &ournode_end_cmd);
Harald Welte62868882009-08-08 16:12:58 +02002624 install_element(GSMNET_NODE, &cfg_net_ncc_cmd);
Harald Weltee87eb462009-08-07 13:29:14 +02002625 install_element(GSMNET_NODE, &cfg_net_mnc_cmd);
2626 install_element(GSMNET_NODE, &cfg_net_name_short_cmd);
2627 install_element(GSMNET_NODE, &cfg_net_name_long_cmd);
Harald Welte (local)a59a27e2009-08-12 14:42:23 +02002628 install_element(GSMNET_NODE, &cfg_net_auth_policy_cmd);
Harald Welte59936d72009-11-18 20:33:19 +01002629 install_element(GSMNET_NODE, &cfg_net_reject_cause_cmd);
Harald Weltecca253a2009-08-30 15:47:06 +09002630 install_element(GSMNET_NODE, &cfg_net_encryption_cmd);
Holger Hans Peter Freyther96c89822009-11-16 17:12:38 +01002631 install_element(GSMNET_NODE, &cfg_net_neci_cmd);
Harald Welte52af1952009-12-13 10:53:12 +01002632 install_element(GSMNET_NODE, &cfg_net_rrlp_mode_cmd);
Harald Welte284ddba2009-12-14 17:49:15 +01002633 install_element(GSMNET_NODE, &cfg_net_mm_info_cmd);
Harald Welte0af9c9f2009-12-19 21:41:52 +01002634 install_element(GSMNET_NODE, &cfg_net_handover_cmd);
Harald Weltea8062f12009-12-21 16:51:50 +01002635 install_element(GSMNET_NODE, &cfg_net_ho_win_rxlev_avg_cmd);
2636 install_element(GSMNET_NODE, &cfg_net_ho_win_rxqual_avg_cmd);
2637 install_element(GSMNET_NODE, &cfg_net_ho_win_rxlev_avg_neigh_cmd);
2638 install_element(GSMNET_NODE, &cfg_net_ho_pwr_interval_cmd);
2639 install_element(GSMNET_NODE, &cfg_net_ho_pwr_hysteresis_cmd);
2640 install_element(GSMNET_NODE, &cfg_net_ho_max_distance_cmd);
Holger Hans Peter Freyther26ba2e72009-11-21 21:18:38 +01002641 install_element(GSMNET_NODE, &cfg_net_T3101_cmd);
Holger Hans Peter Freyther89733862009-11-21 21:42:26 +01002642 install_element(GSMNET_NODE, &cfg_net_T3103_cmd);
2643 install_element(GSMNET_NODE, &cfg_net_T3105_cmd);
2644 install_element(GSMNET_NODE, &cfg_net_T3107_cmd);
2645 install_element(GSMNET_NODE, &cfg_net_T3109_cmd);
2646 install_element(GSMNET_NODE, &cfg_net_T3111_cmd);
2647 install_element(GSMNET_NODE, &cfg_net_T3113_cmd);
2648 install_element(GSMNET_NODE, &cfg_net_T3115_cmd);
2649 install_element(GSMNET_NODE, &cfg_net_T3117_cmd);
2650 install_element(GSMNET_NODE, &cfg_net_T3119_cmd);
Harald Weltee2aaf442010-12-23 22:53:50 +01002651 install_element(GSMNET_NODE, &cfg_net_T3122_cmd);
Holger Hans Peter Freyther89733862009-11-21 21:42:26 +01002652 install_element(GSMNET_NODE, &cfg_net_T3141_cmd);
Holger Hans Peter Freyther21d63ff2010-09-06 09:25:48 +08002653 install_element(GSMNET_NODE, &cfg_net_dtx_cmd);
Holger Hans Peter Freyther68b21e12010-12-22 16:26:04 +01002654 install_element(GSMNET_NODE, &cfg_net_subscr_keep_cmd);
Holger Hans Peter Freytherb6b9d702010-09-06 09:41:50 +08002655 install_element(GSMNET_NODE, &cfg_net_pag_any_tch_cmd);
Harald Weltee87eb462009-08-07 13:29:14 +02002656
2657 install_element(GSMNET_NODE, &cfg_bts_cmd);
Harald Welte97ceef92009-08-06 19:06:46 +02002658 install_node(&bts_node, config_write_bts);
Harald Welte59b04682009-06-10 05:40:52 +08002659 install_default(BTS_NODE);
Harald Welte58ed1cb2010-05-14 18:59:17 +02002660 install_element(BTS_NODE, &ournode_exit_cmd);
Harald Weltedc82b9b2010-05-14 19:11:04 +02002661 install_element(BTS_NODE, &ournode_end_cmd);
Harald Welte59b04682009-06-10 05:40:52 +08002662 install_element(BTS_NODE, &cfg_bts_type_cmd);
Harald Welte8791dac2010-05-14 17:59:53 +02002663 install_element(BTS_NODE, &cfg_description_cmd);
2664 install_element(BTS_NODE, &cfg_no_description_cmd);
Harald Welte91afe4c2009-06-20 18:15:19 +02002665 install_element(BTS_NODE, &cfg_bts_band_cmd);
Holger Hans Peter Freythera098dfb2009-08-21 14:44:12 +02002666 install_element(BTS_NODE, &cfg_bts_ci_cmd);
Harald Welte59b04682009-06-10 05:40:52 +08002667 install_element(BTS_NODE, &cfg_bts_lac_cmd);
2668 install_element(BTS_NODE, &cfg_bts_tsc_cmd);
Harald Welte62868882009-08-08 16:12:58 +02002669 install_element(BTS_NODE, &cfg_bts_bsic_cmd);
Harald Welte59b04682009-06-10 05:40:52 +08002670 install_element(BTS_NODE, &cfg_bts_unit_id_cmd);
Harald Welte08011e22011-03-04 13:41:31 +01002671 install_element(BTS_NODE, &cfg_bts_serno_cmd);
Harald Welte25572872009-10-20 00:22:00 +02002672 install_element(BTS_NODE, &cfg_bts_stream_id_cmd);
Pablo Neira Ayuso42e41df2011-08-17 22:44:07 +02002673 install_element(BTS_NODE, &cfg_bts_hsl_oml_cmd);
Harald Welte62868882009-08-08 16:12:58 +02002674 install_element(BTS_NODE, &cfg_bts_oml_e1_cmd);
2675 install_element(BTS_NODE, &cfg_bts_oml_e1_tei_cmd);
Harald Welte3e774612009-08-10 13:48:16 +02002676 install_element(BTS_NODE, &cfg_bts_challoc_cmd);
Sylvain Munaut8e2d8de2009-12-22 13:43:26 +01002677 install_element(BTS_NODE, &cfg_bts_rach_tx_integer_cmd);
2678 install_element(BTS_NODE, &cfg_bts_rach_max_trans_cmd);
Holger Hans Peter Freyther697ed2b2010-04-25 23:08:39 +08002679 install_element(BTS_NODE, &cfg_bts_rach_nm_b_thresh_cmd);
2680 install_element(BTS_NODE, &cfg_bts_rach_nm_ldavg_cmd);
Harald Welte (local)e19be3f2009-08-12 13:28:23 +02002681 install_element(BTS_NODE, &cfg_bts_cell_barred_cmd);
Holger Hans Peter Freyther440984b2010-05-14 00:39:19 +08002682 install_element(BTS_NODE, &cfg_bts_rach_ec_allowed_cmd);
Harald Welte (local)cbd46102009-08-13 10:14:26 +02002683 install_element(BTS_NODE, &cfg_bts_ms_max_power_cmd);
Harald Welte (local)b6ea7f72009-08-14 23:09:25 +02002684 install_element(BTS_NODE, &cfg_bts_per_loc_upd_cmd);
Harald Welteb761bf82009-12-12 18:17:25 +01002685 install_element(BTS_NODE, &cfg_bts_cell_resel_hyst_cmd);
2686 install_element(BTS_NODE, &cfg_bts_rxlev_acc_min_cmd);
Sylvain Munaut00d71462010-11-28 18:17:28 +01002687 install_element(BTS_NODE, &cfg_bts_cell_bar_qualify_cmd);
2688 install_element(BTS_NODE, &cfg_bts_cell_resel_ofs_cmd);
2689 install_element(BTS_NODE, &cfg_bts_temp_ofs_cmd);
2690 install_element(BTS_NODE, &cfg_bts_temp_ofs_inf_cmd);
2691 install_element(BTS_NODE, &cfg_bts_penalty_time_cmd);
2692 install_element(BTS_NODE, &cfg_bts_penalty_time_rsvd_cmd);
Harald Weltecb20b7a2010-04-18 15:51:20 +02002693 install_element(BTS_NODE, &cfg_bts_gprs_mode_cmd);
Harald Weltea9251762010-05-11 23:50:21 +02002694 install_element(BTS_NODE, &cfg_bts_gprs_ns_timer_cmd);
Harald Welte3055e332010-03-14 15:37:43 +08002695 install_element(BTS_NODE, &cfg_bts_gprs_rac_cmd);
2696 install_element(BTS_NODE, &cfg_bts_gprs_bvci_cmd);
Harald Weltea9251762010-05-11 23:50:21 +02002697 install_element(BTS_NODE, &cfg_bts_gprs_cell_timer_cmd);
Harald Welte4a048c52010-03-22 11:48:36 +08002698 install_element(BTS_NODE, &cfg_bts_gprs_nsei_cmd);
Harald Welte3055e332010-03-14 15:37:43 +08002699 install_element(BTS_NODE, &cfg_bts_gprs_nsvci_cmd);
Harald Welte410575a2010-03-14 23:30:30 +08002700 install_element(BTS_NODE, &cfg_bts_gprs_nsvc_lport_cmd);
2701 install_element(BTS_NODE, &cfg_bts_gprs_nsvc_rport_cmd);
2702 install_element(BTS_NODE, &cfg_bts_gprs_nsvc_rip_cmd);
Holger Hans Peter Freyther3112f672010-09-06 10:11:25 +08002703 install_element(BTS_NODE, &cfg_bts_pag_free_cmd);
Harald Welted8acf142010-07-30 11:50:09 +02002704 install_element(BTS_NODE, &cfg_bts_si_mode_cmd);
2705 install_element(BTS_NODE, &cfg_bts_si_static_cmd);
Harald Welteca46eff2011-01-11 23:44:56 +01002706 install_element(BTS_NODE, &cfg_bts_neigh_mode_cmd);
2707 install_element(BTS_NODE, &cfg_bts_neigh_cmd);
Harald Weltef989b782011-02-15 11:43:27 +01002708 install_element(BTS_NODE, &cfg_bts_si5_neigh_cmd);
Harald Welte59b04682009-06-10 05:40:52 +08002709
2710 install_element(BTS_NODE, &cfg_trx_cmd);
2711 install_node(&trx_node, dummy_config_write);
2712 install_default(TRX_NODE);
Harald Welte58ed1cb2010-05-14 18:59:17 +02002713 install_element(TRX_NODE, &ournode_exit_cmd);
Harald Weltedc82b9b2010-05-14 19:11:04 +02002714 install_element(TRX_NODE, &ournode_end_cmd);
Harald Welte59b04682009-06-10 05:40:52 +08002715 install_element(TRX_NODE, &cfg_trx_arfcn_cmd);
Harald Welte8791dac2010-05-14 17:59:53 +02002716 install_element(TRX_NODE, &cfg_description_cmd);
2717 install_element(TRX_NODE, &cfg_no_description_cmd);
Harald Welte (local)b709bfe2009-12-27 20:56:38 +01002718 install_element(TRX_NODE, &cfg_trx_nominal_power_cmd);
Harald Welte7f597bc2009-06-20 22:36:12 +02002719 install_element(TRX_NODE, &cfg_trx_max_power_red_cmd);
Harald Welte62868882009-08-08 16:12:58 +02002720 install_element(TRX_NODE, &cfg_trx_rsl_e1_cmd);
2721 install_element(TRX_NODE, &cfg_trx_rsl_e1_tei_cmd);
Holger Hans Peter Freyther1c8b4802009-11-11 11:54:24 +01002722 install_element(TRX_NODE, &cfg_trx_rf_locked_cmd);
Harald Welte59b04682009-06-10 05:40:52 +08002723
2724 install_element(TRX_NODE, &cfg_ts_cmd);
2725 install_node(&ts_node, dummy_config_write);
2726 install_default(TS_NODE);
Harald Welte58ed1cb2010-05-14 18:59:17 +02002727 install_element(TS_NODE, &ournode_exit_cmd);
Harald Weltedc82b9b2010-05-14 19:11:04 +02002728 install_element(TS_NODE, &ournode_end_cmd);
Harald Welte3ffe1b32009-08-07 00:25:23 +02002729 install_element(TS_NODE, &cfg_ts_pchan_cmd);
Harald Welte85771a42011-05-30 12:09:13 +02002730 install_element(TS_NODE, &cfg_ts_tsc_cmd);
Harald Weltea42a93f2010-06-14 22:26:10 +02002731 install_element(TS_NODE, &cfg_ts_hopping_cmd);
Harald Welte67104d12009-09-12 13:05:33 +02002732 install_element(TS_NODE, &cfg_ts_hsn_cmd);
2733 install_element(TS_NODE, &cfg_ts_maio_cmd);
2734 install_element(TS_NODE, &cfg_ts_arfcn_add_cmd);
2735 install_element(TS_NODE, &cfg_ts_arfcn_del_cmd);
Harald Welte3ffe1b32009-08-07 00:25:23 +02002736 install_element(TS_NODE, &cfg_ts_e1_subslot_cmd);
Harald Welte59b04682009-06-10 05:40:52 +08002737
Holger Hans Peter Freyther07ff1c32010-10-26 09:40:13 +02002738 install_element(ENABLE_NODE, &drop_bts_cmd);
Harald Welte5213e992010-12-23 13:18:07 +01002739 install_element(ENABLE_NODE, &pdch_act_cmd);
Holger Hans Peter Freyther07ff1c32010-10-26 09:40:13 +02002740
Harald Welte63b964e2010-05-31 16:40:40 +02002741 abis_nm_vty_init();
Harald Welte1d5a2062011-02-12 14:42:59 +01002742 abis_om2k_vty_init();
Harald Weltee76bea02011-02-05 13:54:41 +01002743 e1inp_vty_init();
Harald Welte63b964e2010-05-31 16:40:40 +02002744
Harald Welte40152872010-05-16 20:52:23 +02002745 bsc_vty_init_extra();
Harald Welte59b04682009-06-10 05:40:52 +08002746
2747 return 0;
2748}