blob: 077e1d03f28d7d60b6ea62eeed0083ba8c1b79a8 [file] [log] [blame]
Harald Welte68628e82009-03-10 12:17:57 +00001/* OpenBSC interface to quagga VTY */
2/* (C) 2009 by Harald Welte <laforge@gnumonks.org>
3 * All Rights Reserved
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 */
20
21#include <stdlib.h>
22#include <unistd.h>
23#include <sys/types.h>
24
25#include <vty/command.h>
Harald Weltef9daefd2009-08-09 15:13:54 +020026#include <vty/buffer.h>
Harald Welte68628e82009-03-10 12:17:57 +000027#include <vty/vty.h>
28
29#include <arpa/inet.h>
30
Harald Welte1bc77352009-03-10 19:47:51 +000031#include <openbsc/linuxlist.h>
Harald Welte68628e82009-03-10 12:17:57 +000032#include <openbsc/gsm_data.h>
Harald Welte68628e82009-03-10 12:17:57 +000033#include <openbsc/e1_input.h>
Harald Welte1bc77352009-03-10 19:47:51 +000034#include <openbsc/abis_nm.h>
Harald Weltef9daefd2009-08-09 15:13:54 +020035#include <openbsc/gsm_utils.h>
Harald Welteb908cb72009-12-22 13:09:29 +010036#include <openbsc/chan_alloc.h>
Harald Welte40f82892009-05-23 17:31:39 +000037#include <openbsc/db.h>
Harald Welte5013b2a2009-08-07 13:29:14 +020038#include <openbsc/talloc.h>
Harald Welte68628e82009-03-10 12:17:57 +000039
40static struct gsm_network *gsmnet;
41
Harald Welte5013b2a2009-08-07 13:29:14 +020042struct cmd_node net_node = {
43 GSMNET_NODE,
44 "%s(network)#",
45 1,
46};
47
Harald Welte68628e82009-03-10 12:17:57 +000048struct cmd_node bts_node = {
49 BTS_NODE,
50 "%s(bts)#",
51 1,
52};
53
54struct cmd_node trx_node = {
55 TRX_NODE,
56 "%s(trx)#",
57 1,
58};
59
60struct cmd_node ts_node = {
61 TS_NODE,
62 "%s(ts)#",
63 1,
64};
65
66static int dummy_config_write(struct vty *v)
67{
68 return CMD_SUCCESS;
69}
70
71static void net_dump_nmstate(struct vty *vty, struct gsm_nm_state *nms)
72{
Harald Welte1bc77352009-03-10 19:47:51 +000073 vty_out(vty,"Oper '%s', Admin %u, Avail '%s'%s",
74 nm_opstate_name(nms->operational), nms->administrative,
75 nm_avail_name(nms->availability), VTY_NEWLINE);
Harald Welte68628e82009-03-10 12:17:57 +000076}
77
Harald Welteb908cb72009-12-22 13:09:29 +010078static void dump_pchan_load_vty(struct vty *vty, char *prefix,
79 const struct pchan_load *pl)
80{
81 int i;
82
83 for (i = 0; i < ARRAY_SIZE(pl->pchan); i++) {
84 const struct load_counter *lc = &pl->pchan[i];
85 unsigned int percent;
86
87 if (lc->total == 0)
88 continue;
89
90 percent = (lc->used * 100) / lc->total;
91
92 vty_out(vty, "%s%20s: %3u%% (%u/%u)%s", prefix,
93 gsm_pchan_name(i), percent, lc->used, lc->total,
94 VTY_NEWLINE);
95 }
96}
97
Harald Welte68628e82009-03-10 12:17:57 +000098static void net_dump_vty(struct vty *vty, struct gsm_network *net)
99{
Harald Welteb908cb72009-12-22 13:09:29 +0100100 struct pchan_load pl;
101
Harald Welteef235b52009-03-10 12:34:02 +0000102 vty_out(vty, "BSC is on Country Code %u, Network Code %u "
103 "and has %u BTS%s", net->country_code, net->network_code,
104 net->num_bts, VTY_NEWLINE);
Harald Welte1bc77352009-03-10 19:47:51 +0000105 vty_out(vty, " Long network name: '%s'%s",
Harald Welte68628e82009-03-10 12:17:57 +0000106 net->name_long, VTY_NEWLINE);
Harald Welte1bc77352009-03-10 19:47:51 +0000107 vty_out(vty, " Short network name: '%s'%s",
Harald Welte68628e82009-03-10 12:17:57 +0000108 net->name_short, VTY_NEWLINE);
Harald Welte (local)69de3972009-08-12 14:42:23 +0200109 vty_out(vty, " Authentication policy: %s%s",
110 gsm_auth_policy_name(net->auth_policy), VTY_NEWLINE);
Harald Welte1085c092009-11-18 20:33:19 +0100111 vty_out(vty, " Location updating reject cause: %u%s",
112 net->reject_cause, VTY_NEWLINE);
Harald Welte4381cfe2009-08-30 15:47:06 +0900113 vty_out(vty, " Encryption: A5/%u%s", net->a5_encryption,
114 VTY_NEWLINE);
Holger Hans Peter Freytherf7d752f2009-11-16 17:12:38 +0100115 vty_out(vty, " NECI (TCH/H): %u%s", net->neci,
116 VTY_NEWLINE);
Harald Welteeab84a12009-12-13 10:53:12 +0100117 vty_out(vty, " RRLP Mode: %s%s", rrlp_mode_name(net->rrlp.mode),
118 VTY_NEWLINE);
Harald Welte648b6ce2009-12-14 09:00:24 +0100119 vty_out(vty, " MM Info: %s%s", net->send_mm_info ? "On" : "Off",
120 VTY_NEWLINE);
Harald Weltebc814502009-12-19 21:41:52 +0100121 vty_out(vty, " Handover: %s%s", net->handover.active ? "On" : "Off",
122 VTY_NEWLINE);
Harald Welteb908cb72009-12-22 13:09:29 +0100123 network_chan_load(&pl, net);
124 vty_out(vty, " Current Channel Load:%s", VTY_NEWLINE);
125 dump_pchan_load_vty(vty, " ", &pl);
Harald Welte68628e82009-03-10 12:17:57 +0000126}
127
128DEFUN(show_net, show_net_cmd, "show network",
129 SHOW_STR "Display information about a GSM NETWORK\n")
130{
131 struct gsm_network *net = gsmnet;
132 net_dump_vty(vty, net);
133
134 return CMD_SUCCESS;
135}
136
137static void e1isl_dump_vty(struct vty *vty, struct e1inp_sign_link *e1l)
138{
Harald Welteedb37782009-05-01 14:59:07 +0000139 struct e1inp_line *line;
140
141 if (!e1l) {
142 vty_out(vty, " None%s", VTY_NEWLINE);
143 return;
144 }
145
146 line = e1l->ts->line;
147
148 vty_out(vty, " E1 Line %u, Type %s: Timeslot %u, Mode %s%s",
149 line->num, line->driver->name, e1l->ts->num,
Harald Welte1bc77352009-03-10 19:47:51 +0000150 e1inp_signtype_name(e1l->type), VTY_NEWLINE);
Harald Welteedb37782009-05-01 14:59:07 +0000151 vty_out(vty, " E1 TEI %u, SAPI %u%s",
Harald Welte68628e82009-03-10 12:17:57 +0000152 e1l->tei, e1l->sapi, VTY_NEWLINE);
153}
154
155static void bts_dump_vty(struct vty *vty, struct gsm_bts *bts)
156{
Harald Welteb908cb72009-12-22 13:09:29 +0100157 struct pchan_load pl;
158
Holger Hans Peter Freytherc4a49e32009-08-21 14:44:12 +0200159 vty_out(vty, "BTS %u is of %s type in band %s, has CI %u LAC %u, "
Harald Weltefcd24452009-06-20 18:15:19 +0200160 "BSIC %u, TSC %u and %u TRX%s",
161 bts->nr, btstype2str(bts->type), gsm_band_name(bts->band),
Holger Hans Peter Freytherc4a49e32009-08-21 14:44:12 +0200162 bts->cell_identity,
Harald Weltefcd24452009-06-20 18:15:19 +0200163 bts->location_area_code, bts->bsic, bts->tsc,
164 bts->num_trx, VTY_NEWLINE);
Harald Welte1d8dbc42009-12-12 15:38:16 +0100165 vty_out(vty, "MS Max power: %u dBm%s", bts->ms_max_power, VTY_NEWLINE);
Harald Welte73225282009-12-12 18:17:25 +0100166 vty_out(vty, "Minimum Rx Level for Access: %i dBm%s",
Harald Welte1d8dbc42009-12-12 15:38:16 +0100167 rxlev2dbm(bts->si_common.cell_sel_par.rxlev_acc_min),
168 VTY_NEWLINE);
169 vty_out(vty, "Cell Reselection Hysteresis: %u dBm%s",
Harald Welte73225282009-12-12 18:17:25 +0100170 bts->si_common.cell_sel_par.cell_resel_hyst*2, VTY_NEWLINE);
Harald Welte71355012009-12-21 23:08:18 +0100171 if (bts->si_common.rach_control.cell_bar)
Harald Welte (local)5dececf2009-08-12 13:28:23 +0200172 vty_out(vty, " CELL IS BARRED%s", VTY_NEWLINE);
Harald Welte4cc34222009-05-01 15:12:31 +0000173 if (is_ipaccess_bts(bts))
Harald Welte8175e952009-10-20 00:22:00 +0200174 vty_out(vty, " Unit ID: %u/%u/0, OML Stream ID 0x%02x%s",
Harald Welte4cc34222009-05-01 15:12:31 +0000175 bts->ip_access.site_id, bts->ip_access.bts_id,
Harald Welte8175e952009-10-20 00:22:00 +0200176 bts->oml_tei, VTY_NEWLINE);
Harald Welte68628e82009-03-10 12:17:57 +0000177 vty_out(vty, " NM State: ");
178 net_dump_nmstate(vty, &bts->nm_state);
179 vty_out(vty, " Site Mgr NM State: ");
180 net_dump_nmstate(vty, &bts->site_mgr.nm_state);
181 vty_out(vty, " Paging: FIXME pending requests, %u free slots%s",
182 bts->paging.available_slots, VTY_NEWLINE);
Harald Welte8175e952009-10-20 00:22:00 +0200183 if (!is_ipaccess_bts(bts)) {
184 vty_out(vty, " E1 Signalling Link:%s", VTY_NEWLINE);
185 e1isl_dump_vty(vty, bts->oml_link);
186 }
Harald Welte68628e82009-03-10 12:17:57 +0000187 /* FIXME: oml_link, chan_desc */
Harald Welteb908cb72009-12-22 13:09:29 +0100188 memset(&pl, 0, sizeof(pl));
189 bts_chan_load(&pl, bts);
190 vty_out(vty, " Current Channel Load:%s", VTY_NEWLINE);
191 dump_pchan_load_vty(vty, " ", &pl);
Harald Welte68628e82009-03-10 12:17:57 +0000192}
193
194DEFUN(show_bts, show_bts_cmd, "show bts [number]",
195 SHOW_STR "Display information about a BTS\n"
196 "BTS number")
197{
198 struct gsm_network *net = gsmnet;
199 int bts_nr;
200
201 if (argc != 0) {
202 /* use the BTS number that the user has specified */
203 bts_nr = atoi(argv[0]);
204 if (bts_nr > net->num_bts) {
Harald Welte1bc77352009-03-10 19:47:51 +0000205 vty_out(vty, "%% can't find BTS '%s'%s", argv[0],
Harald Welte68628e82009-03-10 12:17:57 +0000206 VTY_NEWLINE);
207 return CMD_WARNING;
208 }
Harald Weltee441d9c2009-06-21 16:17:15 +0200209 bts_dump_vty(vty, gsm_bts_num(net, bts_nr));
Harald Welte68628e82009-03-10 12:17:57 +0000210 return CMD_SUCCESS;
211 }
212 /* print all BTS's */
213 for (bts_nr = 0; bts_nr < net->num_bts; bts_nr++)
Harald Weltee441d9c2009-06-21 16:17:15 +0200214 bts_dump_vty(vty, gsm_bts_num(net, bts_nr));
Harald Welte68628e82009-03-10 12:17:57 +0000215
216 return CMD_SUCCESS;
217}
218
Harald Welte42581822009-08-08 16:12:58 +0200219/* utility functions */
220static void parse_e1_link(struct gsm_e1_subslot *e1_link, const char *line,
221 const char *ts, const char *ss)
222{
223 e1_link->e1_nr = atoi(line);
224 e1_link->e1_ts = atoi(ts);
225 if (!strcmp(ss, "full"))
226 e1_link->e1_ts_ss = 255;
227 else
228 e1_link->e1_ts_ss = atoi(ss);
229}
230
231static void config_write_e1_link(struct vty *vty, struct gsm_e1_subslot *e1_link,
232 const char *prefix)
233{
234 if (!e1_link->e1_ts)
235 return;
236
237 if (e1_link->e1_ts_ss == 255)
238 vty_out(vty, "%se1 line %u timeslot %u sub-slot full%s",
239 prefix, e1_link->e1_nr, e1_link->e1_ts, VTY_NEWLINE);
240 else
241 vty_out(vty, "%se1 line %u timeslot %u sub-slot %u%s",
242 prefix, e1_link->e1_nr, e1_link->e1_ts,
243 e1_link->e1_ts_ss, VTY_NEWLINE);
244}
245
246
Harald Welte67ce0732009-08-06 19:06:46 +0200247static void config_write_ts_single(struct vty *vty, struct gsm_bts_trx_ts *ts)
248{
Harald Welte42581822009-08-08 16:12:58 +0200249 vty_out(vty, " timeslot %u%s", ts->nr, VTY_NEWLINE);
250 if (ts->pchan != GSM_PCHAN_NONE)
251 vty_out(vty, " phys_chan_config %s%s",
252 gsm_pchan_name(ts->pchan), VTY_NEWLINE);
253 config_write_e1_link(vty, &ts->e1_link, " ");
Harald Welte67ce0732009-08-06 19:06:46 +0200254}
255
256static void config_write_trx_single(struct vty *vty, struct gsm_bts_trx *trx)
257{
258 int i;
259
Harald Welte5013b2a2009-08-07 13:29:14 +0200260 vty_out(vty, " trx %u%s", trx->nr, VTY_NEWLINE);
261 vty_out(vty, " arfcn %u%s", trx->arfcn, VTY_NEWLINE);
262 vty_out(vty, " max_power_red %u%s", trx->max_power_red, VTY_NEWLINE);
Harald Welte42581822009-08-08 16:12:58 +0200263 config_write_e1_link(vty, &trx->rsl_e1_link, " rsl ");
264 vty_out(vty, " rsl e1 tei %u%s", trx->rsl_tei, VTY_NEWLINE);
Harald Welte67ce0732009-08-06 19:06:46 +0200265
266 for (i = 0; i < TRX_NR_TS; i++)
267 config_write_ts_single(vty, &trx->ts[i]);
268}
269
270static void config_write_bts_single(struct vty *vty, struct gsm_bts *bts)
271{
272 struct gsm_bts_trx *trx;
273
Harald Welte5013b2a2009-08-07 13:29:14 +0200274 vty_out(vty, " bts %u%s", bts->nr, VTY_NEWLINE);
275 vty_out(vty, " type %s%s", btstype2str(bts->type), VTY_NEWLINE);
276 vty_out(vty, " band %s%s", gsm_band_name(bts->band), VTY_NEWLINE);
Holger Hans Peter Freytherf926ed62009-11-19 16:38:49 +0100277 vty_out(vty, " cell_identity %u%s", bts->cell_identity, VTY_NEWLINE);
Harald Welte5013b2a2009-08-07 13:29:14 +0200278 vty_out(vty, " location_area_code %u%s", bts->location_area_code,
Harald Welte67ce0732009-08-06 19:06:46 +0200279 VTY_NEWLINE);
Harald Welte5013b2a2009-08-07 13:29:14 +0200280 vty_out(vty, " training_sequence_code %u%s", bts->tsc, VTY_NEWLINE);
281 vty_out(vty, " base_station_id_code %u%s", bts->bsic, VTY_NEWLINE);
Harald Welte (local)0e451d02009-08-13 10:14:26 +0200282 vty_out(vty, " ms max power %u%s", bts->ms_max_power, VTY_NEWLINE);
Harald Welte73225282009-12-12 18:17:25 +0100283 vty_out(vty, " cell reselection hysteresis %u%s",
284 bts->si_common.cell_sel_par.cell_resel_hyst*2, VTY_NEWLINE);
285 vty_out(vty, " rxlev access min %u%s",
286 bts->si_common.cell_sel_par.rxlev_acc_min, VTY_NEWLINE);
Harald Weltea43f7892009-12-01 18:04:30 +0530287 if (bts->si_common.chan_desc.t3212)
Harald Welte (local)efc92312009-08-14 23:09:25 +0200288 vty_out(vty, " periodic location update %u%s",
Harald Weltea43f7892009-12-01 18:04:30 +0530289 bts->si_common.chan_desc.t3212 * 10, VTY_NEWLINE);
Harald Welte7a8fa412009-08-10 13:48:16 +0200290 vty_out(vty, " channel allocator %s%s",
291 bts->chan_alloc_reverse ? "descending" : "ascending",
292 VTY_NEWLINE);
Harald Welte71355012009-12-21 23:08:18 +0100293 if (bts->si_common.rach_control.cell_bar)
Harald Welte (local)5dececf2009-08-12 13:28:23 +0200294 vty_out(vty, " cell barred 1%s", VTY_NEWLINE);
Harald Welte8175e952009-10-20 00:22:00 +0200295 if (is_ipaccess_bts(bts)) {
Harald Welte5013b2a2009-08-07 13:29:14 +0200296 vty_out(vty, " ip.access unit_id %u %u%s",
Harald Weltea6fd58e2009-08-07 00:25:23 +0200297 bts->ip_access.site_id, bts->ip_access.bts_id, VTY_NEWLINE);
Harald Welte8175e952009-10-20 00:22:00 +0200298 vty_out(vty, " oml ip.access stream_id %u%s", bts->oml_tei, VTY_NEWLINE);
299 } else {
Harald Welte42581822009-08-08 16:12:58 +0200300 config_write_e1_link(vty, &bts->oml_e1_link, " oml ");
301 vty_out(vty, " oml e1 tei %u%s", bts->oml_tei, VTY_NEWLINE);
302 }
Harald Welte67ce0732009-08-06 19:06:46 +0200303
304 llist_for_each_entry(trx, &bts->trx_list, list)
305 config_write_trx_single(vty, trx);
306}
307
308static int config_write_bts(struct vty *v)
309{
310 struct gsm_bts *bts;
311
312 llist_for_each_entry(bts, &gsmnet->bts_list, list)
313 config_write_bts_single(v, bts);
314
315 return CMD_SUCCESS;
316}
317
Harald Welte5013b2a2009-08-07 13:29:14 +0200318static int config_write_net(struct vty *vty)
319{
320 vty_out(vty, "network%s", VTY_NEWLINE);
Harald Welte42581822009-08-08 16:12:58 +0200321 vty_out(vty, " network country code %u%s", gsmnet->country_code, VTY_NEWLINE);
Harald Welte5013b2a2009-08-07 13:29:14 +0200322 vty_out(vty, " mobile network code %u%s", gsmnet->network_code, VTY_NEWLINE);
Harald Welte42581822009-08-08 16:12:58 +0200323 vty_out(vty, " short name %s%s", gsmnet->name_short, VTY_NEWLINE);
324 vty_out(vty, " long name %s%s", gsmnet->name_long, VTY_NEWLINE);
Harald Welte (local)69de3972009-08-12 14:42:23 +0200325 vty_out(vty, " auth policy %s%s", gsm_auth_policy_name(gsmnet->auth_policy), VTY_NEWLINE);
Harald Welte1085c092009-11-18 20:33:19 +0100326 vty_out(vty, " location updating reject cause %u%s",
327 gsmnet->reject_cause, VTY_NEWLINE);
Harald Welte4381cfe2009-08-30 15:47:06 +0900328 vty_out(vty, " encryption a5 %u%s", gsmnet->a5_encryption, VTY_NEWLINE);
Holger Hans Peter Freytherd54c3372009-11-19 16:37:48 +0100329 vty_out(vty, " neci %u%s", gsmnet->neci, VTY_NEWLINE);
Harald Welteeab84a12009-12-13 10:53:12 +0100330 vty_out(vty, " rrlp mode %s%s", rrlp_mode_name(gsmnet->rrlp.mode),
331 VTY_NEWLINE);
Harald Welte648b6ce2009-12-14 09:00:24 +0100332 vty_out(vty, " mm info %u%s", gsmnet->send_mm_info, VTY_NEWLINE);
Harald Weltebc814502009-12-19 21:41:52 +0100333 vty_out(vty, " handover %u%s", gsmnet->handover.active, VTY_NEWLINE);
Harald Welteb720bd32009-12-21 16:51:50 +0100334 vty_out(vty, " handover window rxlev averaging %u%s",
335 gsmnet->handover.win_rxlev_avg, VTY_NEWLINE);
336 vty_out(vty, " handover window rxqual averaging %u%s",
337 gsmnet->handover.win_rxqual_avg, VTY_NEWLINE);
338 vty_out(vty, " handover window rxlev neighbor averaging %u%s",
339 gsmnet->handover.win_rxlev_avg_neigh, VTY_NEWLINE);
340 vty_out(vty, " handover power budget interval %u%s",
341 gsmnet->handover.pwr_interval, VTY_NEWLINE);
342 vty_out(vty, " handover power budget hysteresis %u%s",
343 gsmnet->handover.pwr_hysteresis, VTY_NEWLINE);
344 vty_out(vty, " handover maximum distance %u%s",
345 gsmnet->handover.max_distance, VTY_NEWLINE);
Holger Hans Peter Freytherc4d88ad2009-11-21 21:18:38 +0100346 vty_out(vty, " timer t3101 %u%s", gsmnet->T3101, VTY_NEWLINE);
Holger Hans Peter Freyther23975e72009-11-21 21:42:26 +0100347 vty_out(vty, " timer t3103 %u%s", gsmnet->T3103, VTY_NEWLINE);
348 vty_out(vty, " timer t3105 %u%s", gsmnet->T3105, VTY_NEWLINE);
349 vty_out(vty, " timer t3107 %u%s", gsmnet->T3107, VTY_NEWLINE);
350 vty_out(vty, " timer t3109 %u%s", gsmnet->T3109, VTY_NEWLINE);
351 vty_out(vty, " timer t3111 %u%s", gsmnet->T3111, VTY_NEWLINE);
352 vty_out(vty, " timer t3113 %u%s", gsmnet->T3113, VTY_NEWLINE);
353 vty_out(vty, " timer t3115 %u%s", gsmnet->T3115, VTY_NEWLINE);
354 vty_out(vty, " timer t3117 %u%s", gsmnet->T3117, VTY_NEWLINE);
355 vty_out(vty, " timer t3119 %u%s", gsmnet->T3119, VTY_NEWLINE);
356 vty_out(vty, " timer t3141 %u%s", gsmnet->T3141, VTY_NEWLINE);
Harald Welte5013b2a2009-08-07 13:29:14 +0200357
358 return CMD_SUCCESS;
359}
Harald Welte67ce0732009-08-06 19:06:46 +0200360
Harald Welte68628e82009-03-10 12:17:57 +0000361static void trx_dump_vty(struct vty *vty, struct gsm_bts_trx *trx)
362{
363 vty_out(vty, "TRX %u of BTS %u is on ARFCN %u%s",
364 trx->nr, trx->bts->nr, trx->arfcn, VTY_NEWLINE);
Harald Weltefcd24452009-06-20 18:15:19 +0200365 vty_out(vty, " RF Nominal Power: %d dBm, reduced by %u dB, "
Harald Welte42581822009-08-08 16:12:58 +0200366 "resulting BS power: %d dBm%s",
Harald Weltefcd24452009-06-20 18:15:19 +0200367 trx->nominal_power, trx->max_power_red,
Harald Welte42581822009-08-08 16:12:58 +0200368 trx->nominal_power - trx->max_power_red, VTY_NEWLINE);
Harald Welte68628e82009-03-10 12:17:57 +0000369 vty_out(vty, " NM State: ");
370 net_dump_nmstate(vty, &trx->nm_state);
371 vty_out(vty, " Baseband Transceiver NM State: ");
372 net_dump_nmstate(vty, &trx->bb_transc.nm_state);
Harald Welte8175e952009-10-20 00:22:00 +0200373 if (is_ipaccess_bts(trx->bts)) {
374 vty_out(vty, " ip.access stream ID: 0x%02x%s",
375 trx->rsl_tei, VTY_NEWLINE);
376 } else {
377 vty_out(vty, " E1 Signalling Link:%s", VTY_NEWLINE);
378 e1isl_dump_vty(vty, trx->rsl_link);
379 }
Harald Welte68628e82009-03-10 12:17:57 +0000380}
381
382DEFUN(show_trx,
383 show_trx_cmd,
384 "show trx [bts_nr] [trx_nr]",
385 SHOW_STR "Display information about a TRX\n")
386{
387 struct gsm_network *net = gsmnet;
388 struct gsm_bts *bts = NULL;
389 struct gsm_bts_trx *trx;
390 int bts_nr, trx_nr;
391
392 if (argc >= 1) {
393 /* use the BTS number that the user has specified */
394 bts_nr = atoi(argv[0]);
395 if (bts_nr >= net->num_bts) {
Harald Welte1bc77352009-03-10 19:47:51 +0000396 vty_out(vty, "%% can't find BTS '%s'%s", argv[0],
Harald Welte68628e82009-03-10 12:17:57 +0000397 VTY_NEWLINE);
398 return CMD_WARNING;
399 }
Harald Weltee441d9c2009-06-21 16:17:15 +0200400 bts = gsm_bts_num(net, bts_nr);
Harald Welte68628e82009-03-10 12:17:57 +0000401 }
402 if (argc >= 2) {
403 trx_nr = atoi(argv[1]);
404 if (trx_nr >= bts->num_trx) {
Harald Welte1bc77352009-03-10 19:47:51 +0000405 vty_out(vty, "%% can't find TRX '%s'%s", argv[1],
Harald Welte68628e82009-03-10 12:17:57 +0000406 VTY_NEWLINE);
407 return CMD_WARNING;
408 }
Harald Weltee441d9c2009-06-21 16:17:15 +0200409 trx = gsm_bts_trx_num(bts, trx_nr);
Harald Welte68628e82009-03-10 12:17:57 +0000410 trx_dump_vty(vty, trx);
411 return CMD_SUCCESS;
412 }
413 if (bts) {
414 /* print all TRX in this BTS */
415 for (trx_nr = 0; trx_nr < bts->num_trx; trx_nr++) {
Harald Weltee441d9c2009-06-21 16:17:15 +0200416 trx = gsm_bts_trx_num(bts, trx_nr);
Harald Welte68628e82009-03-10 12:17:57 +0000417 trx_dump_vty(vty, trx);
418 }
419 return CMD_SUCCESS;
420 }
421
422 for (bts_nr = 0; bts_nr < net->num_bts; bts_nr++) {
Harald Weltee441d9c2009-06-21 16:17:15 +0200423 bts = gsm_bts_num(net, bts_nr);
Harald Welte68628e82009-03-10 12:17:57 +0000424 for (trx_nr = 0; trx_nr < bts->num_trx; trx_nr++) {
Harald Weltee441d9c2009-06-21 16:17:15 +0200425 trx = gsm_bts_trx_num(bts, trx_nr);
Harald Welte68628e82009-03-10 12:17:57 +0000426 trx_dump_vty(vty, trx);
427 }
428 }
429
430 return CMD_SUCCESS;
431}
432
Harald Welte67ce0732009-08-06 19:06:46 +0200433
Harald Welte68628e82009-03-10 12:17:57 +0000434static void ts_dump_vty(struct vty *vty, struct gsm_bts_trx_ts *ts)
435{
Harald Welte68628e82009-03-10 12:17:57 +0000436 vty_out(vty, "Timeslot %u of TRX %u in BTS %u, phys cfg %s%s",
437 ts->nr, ts->trx->nr, ts->trx->bts->nr,
438 gsm_pchan_name(ts->pchan), VTY_NEWLINE);
439 vty_out(vty, " NM State: ");
440 net_dump_nmstate(vty, &ts->nm_state);
Harald Welte2c828992009-12-02 01:56:49 +0530441 if (!is_ipaccess_bts(ts->trx->bts))
Harald Welteef235b52009-03-10 12:34:02 +0000442 vty_out(vty, " E1 Line %u, Timeslot %u, Subslot %u%s",
443 ts->e1_link.e1_nr, ts->e1_link.e1_ts,
444 ts->e1_link.e1_ts_ss, VTY_NEWLINE);
Harald Welte68628e82009-03-10 12:17:57 +0000445}
446
447DEFUN(show_ts,
448 show_ts_cmd,
Harald Welte1bc77352009-03-10 19:47:51 +0000449 "show timeslot [bts_nr] [trx_nr] [ts_nr]",
Harald Welte68628e82009-03-10 12:17:57 +0000450 SHOW_STR "Display information about a TS\n")
451{
452 struct gsm_network *net = gsmnet;
453 struct gsm_bts *bts;
454 struct gsm_bts_trx *trx;
455 struct gsm_bts_trx_ts *ts;
456 int bts_nr, trx_nr, ts_nr;
457
458 if (argc >= 1) {
459 /* use the BTS number that the user has specified */
460 bts_nr = atoi(argv[0]);
461 if (bts_nr >= net->num_bts) {
Harald Welte1bc77352009-03-10 19:47:51 +0000462 vty_out(vty, "%% can't find BTS '%s'%s", argv[0],
Harald Welte68628e82009-03-10 12:17:57 +0000463 VTY_NEWLINE);
464 return CMD_WARNING;
465 }
Harald Weltee441d9c2009-06-21 16:17:15 +0200466 bts = gsm_bts_num(net, bts_nr);
Harald Welte68628e82009-03-10 12:17:57 +0000467 }
468 if (argc >= 2) {
469 trx_nr = atoi(argv[1]);
470 if (trx_nr >= bts->num_trx) {
Harald Welte1bc77352009-03-10 19:47:51 +0000471 vty_out(vty, "%% can't find TRX '%s'%s", argv[1],
Harald Welte68628e82009-03-10 12:17:57 +0000472 VTY_NEWLINE);
473 return CMD_WARNING;
474 }
Harald Weltee441d9c2009-06-21 16:17:15 +0200475 trx = gsm_bts_trx_num(bts, trx_nr);
Harald Welte68628e82009-03-10 12:17:57 +0000476 }
477 if (argc >= 3) {
478 ts_nr = atoi(argv[2]);
479 if (ts_nr >= TRX_NR_TS) {
Harald Welte1bc77352009-03-10 19:47:51 +0000480 vty_out(vty, "%% can't find TS '%s'%s", argv[2],
Harald Welte68628e82009-03-10 12:17:57 +0000481 VTY_NEWLINE);
482 return CMD_WARNING;
483 }
484 ts = &trx->ts[ts_nr];
485 ts_dump_vty(vty, ts);
486 return CMD_SUCCESS;
487 }
488 for (bts_nr = 0; bts_nr < net->num_bts; bts_nr++) {
Harald Weltee441d9c2009-06-21 16:17:15 +0200489 bts = gsm_bts_num(net, bts_nr);
Harald Welte68628e82009-03-10 12:17:57 +0000490 for (trx_nr = 0; trx_nr < bts->num_trx; trx_nr++) {
Harald Weltee441d9c2009-06-21 16:17:15 +0200491 trx = gsm_bts_trx_num(bts, trx_nr);
Harald Welte68628e82009-03-10 12:17:57 +0000492 for (ts_nr = 0; ts_nr < TRX_NR_TS; ts_nr++) {
493 ts = &trx->ts[ts_nr];
494 ts_dump_vty(vty, ts);
495 }
496 }
497 }
498
499 return CMD_SUCCESS;
500}
501
Holger Hans Peter Freythercfa90d42009-08-10 10:17:50 +0200502void subscr_dump_vty(struct vty *vty, struct gsm_subscriber *subscr)
Harald Welte68628e82009-03-10 12:17:57 +0000503{
Harald Weltefcd24452009-06-20 18:15:19 +0200504 vty_out(vty, " ID: %llu, Authorized: %d%s", subscr->id,
Harald Welte40f82892009-05-23 17:31:39 +0000505 subscr->authorized, VTY_NEWLINE);
Harald Welte68628e82009-03-10 12:17:57 +0000506 if (subscr->name)
Harald Welte1bc77352009-03-10 19:47:51 +0000507 vty_out(vty, " Name: '%s'%s", subscr->name, VTY_NEWLINE);
Harald Welte68628e82009-03-10 12:17:57 +0000508 if (subscr->extension)
509 vty_out(vty, " Extension: %s%s", subscr->extension,
510 VTY_NEWLINE);
511 if (subscr->imsi)
512 vty_out(vty, " IMSI: %s%s", subscr->imsi, VTY_NEWLINE);
Holger Hans Peter Freyther22230252009-08-19 12:53:57 +0200513 if (subscr->tmsi != GSM_RESERVED_TMSI)
514 vty_out(vty, " TMSI: %08X%s", subscr->tmsi,
Harald Welte731fd912009-08-15 03:24:51 +0200515 VTY_NEWLINE);
Harald Welte (local)15920de2009-08-14 20:27:16 +0200516 vty_out(vty, " Use count: %u%s", subscr->use_count, VTY_NEWLINE);
Harald Welte68628e82009-03-10 12:17:57 +0000517}
518
519static void lchan_dump_vty(struct vty *vty, struct gsm_lchan *lchan)
520{
521 vty_out(vty, "Lchan %u in Timeslot %u of TRX %u in BTS %u, Type %s%s",
522 lchan->nr, lchan->ts->nr, lchan->ts->trx->nr,
523 lchan->ts->trx->bts->nr, gsm_lchan_name(lchan->type),
524 VTY_NEWLINE);
525 vty_out(vty, " Use Count: %u%s", lchan->use_count, VTY_NEWLINE);
Harald Welte73225282009-12-12 18:17:25 +0100526 vty_out(vty, " BS Power: %u dBm, MS Power: %u dBm%s",
527 lchan->ts->trx->nominal_power - lchan->ts->trx->max_power_red
528 - lchan->bs_power*2,
529 ms_pwr_dbm(lchan->ts->trx->bts->band, lchan->ms_power),
530 VTY_NEWLINE);
Harald Welte68628e82009-03-10 12:17:57 +0000531 if (lchan->subscr) {
532 vty_out(vty, " Subscriber:%s", VTY_NEWLINE);
533 subscr_dump_vty(vty, lchan->subscr);
534 } else
535 vty_out(vty, " No Subscriber%s", VTY_NEWLINE);
Harald Welte2c828992009-12-02 01:56:49 +0530536 if (is_ipaccess_bts(lchan->ts->trx->bts)) {
537 struct in_addr ia;
538 ia.s_addr = lchan->abis_ip.bound_ip;
539 vty_out(vty, " Bound IP: %s Port %u RTP_TYPE2=%u CONN_ID=%u%s",
540 inet_ntoa(ia), lchan->abis_ip.bound_port,
541 lchan->abis_ip.rtp_payload2, lchan->abis_ip.conn_id,
542 VTY_NEWLINE);
543 }
Harald Welte68628e82009-03-10 12:17:57 +0000544}
545
Harald Welte4bfdfe72009-06-10 23:11:52 +0800546#if 0
547TODO: callref and remote callref of call must be resolved to get gsm_trans object
Harald Welte68628e82009-03-10 12:17:57 +0000548static void call_dump_vty(struct vty *vty, struct gsm_call *call)
549{
550 vty_out(vty, "Call Type %u, State %u, Transaction ID %u%s",
551 call->type, call->state, call->transaction_id, VTY_NEWLINE);
552
553 if (call->local_lchan) {
554 vty_out(vty, "Call Local Channel:%s", VTY_NEWLINE);
555 lchan_dump_vty(vty, call->local_lchan);
556 } else
557 vty_out(vty, "Call has no Local Channel%s", VTY_NEWLINE);
558
559 if (call->remote_lchan) {
560 vty_out(vty, "Call Remote Channel:%s", VTY_NEWLINE);
561 lchan_dump_vty(vty, call->remote_lchan);
562 } else
563 vty_out(vty, "Call has no Remote Channel%s", VTY_NEWLINE);
564
565 if (call->called_subscr) {
566 vty_out(vty, "Called Subscriber:%s", VTY_NEWLINE);
567 subscr_dump_vty(vty, call->called_subscr);
568 } else
569 vty_out(vty, "Call has no Called Subscriber%s", VTY_NEWLINE);
570}
Harald Welte4bfdfe72009-06-10 23:11:52 +0800571#endif
Harald Welte68628e82009-03-10 12:17:57 +0000572
573DEFUN(show_lchan,
574 show_lchan_cmd,
575 "show lchan [bts_nr] [trx_nr] [ts_nr] [lchan_nr]",
576 SHOW_STR "Display information about a logical channel\n")
577{
578 struct gsm_network *net = gsmnet;
579 struct gsm_bts *bts;
580 struct gsm_bts_trx *trx;
581 struct gsm_bts_trx_ts *ts;
582 struct gsm_lchan *lchan;
583 int bts_nr, trx_nr, ts_nr, lchan_nr;
584
585 if (argc >= 1) {
586 /* use the BTS number that the user has specified */
587 bts_nr = atoi(argv[0]);
588 if (bts_nr >= net->num_bts) {
589 vty_out(vty, "%% can't find BTS %s%s", argv[0],
590 VTY_NEWLINE);
591 return CMD_WARNING;
592 }
Harald Weltee441d9c2009-06-21 16:17:15 +0200593 bts = gsm_bts_num(net, bts_nr);
Harald Welte68628e82009-03-10 12:17:57 +0000594 }
595 if (argc >= 2) {
596 trx_nr = atoi(argv[1]);
597 if (trx_nr >= bts->num_trx) {
598 vty_out(vty, "%% can't find TRX %s%s", argv[1],
599 VTY_NEWLINE);
600 return CMD_WARNING;
601 }
Harald Weltee441d9c2009-06-21 16:17:15 +0200602 trx = gsm_bts_trx_num(bts, trx_nr);
Harald Welte68628e82009-03-10 12:17:57 +0000603 }
604 if (argc >= 3) {
605 ts_nr = atoi(argv[2]);
606 if (ts_nr >= TRX_NR_TS) {
607 vty_out(vty, "%% can't find TS %s%s", argv[2],
608 VTY_NEWLINE);
609 return CMD_WARNING;
610 }
611 ts = &trx->ts[ts_nr];
612 }
613 if (argc >= 4) {
614 lchan_nr = atoi(argv[3]);
615 if (lchan_nr >= TS_MAX_LCHAN) {
616 vty_out(vty, "%% can't find LCHAN %s%s", argv[3],
617 VTY_NEWLINE);
618 return CMD_WARNING;
619 }
620 lchan = &ts->lchan[lchan_nr];
621 lchan_dump_vty(vty, lchan);
622 return CMD_SUCCESS;
623 }
624 for (bts_nr = 0; bts_nr < net->num_bts; bts_nr++) {
Harald Weltee441d9c2009-06-21 16:17:15 +0200625 bts = gsm_bts_num(net, bts_nr);
Harald Welte68628e82009-03-10 12:17:57 +0000626 for (trx_nr = 0; trx_nr < bts->num_trx; trx_nr++) {
Harald Weltee441d9c2009-06-21 16:17:15 +0200627 trx = gsm_bts_trx_num(bts, trx_nr);
Harald Welte68628e82009-03-10 12:17:57 +0000628 for (ts_nr = 0; ts_nr < TRX_NR_TS; ts_nr++) {
629 ts = &trx->ts[ts_nr];
630 for (lchan_nr = 0; lchan_nr < TS_MAX_LCHAN;
631 lchan_nr++) {
632 lchan = &ts->lchan[lchan_nr];
Harald Welteef235b52009-03-10 12:34:02 +0000633 if (lchan->type == GSM_LCHAN_NONE)
634 continue;
Harald Welte68628e82009-03-10 12:17:57 +0000635 lchan_dump_vty(vty, lchan);
636 }
637 }
638 }
639 }
640
641 return CMD_SUCCESS;
642}
643
Harald Welte1bc77352009-03-10 19:47:51 +0000644static void e1drv_dump_vty(struct vty *vty, struct e1inp_driver *drv)
645{
646 vty_out(vty, "E1 Input Driver %s%s", drv->name, VTY_NEWLINE);
647}
648
649DEFUN(show_e1drv,
650 show_e1drv_cmd,
651 "show e1_driver",
652 SHOW_STR "Display information about available E1 drivers\n")
653{
654 struct e1inp_driver *drv;
655
656 llist_for_each_entry(drv, &e1inp_driver_list, list)
657 e1drv_dump_vty(vty, drv);
658
659 return CMD_SUCCESS;
660}
661
Harald Welte68628e82009-03-10 12:17:57 +0000662static void e1line_dump_vty(struct vty *vty, struct e1inp_line *line)
663{
664 vty_out(vty, "E1 Line Number %u, Name %s, Driver %s%s",
665 line->num, line->name ? line->name : "",
666 line->driver->name, VTY_NEWLINE);
667}
668
669DEFUN(show_e1line,
670 show_e1line_cmd,
671 "show e1_line [line_nr]",
672 SHOW_STR "Display information about a E1 line\n")
673{
Harald Welte1bc77352009-03-10 19:47:51 +0000674 struct e1inp_line *line;
675
676 if (argc >= 1) {
677 int num = atoi(argv[0]);
678 llist_for_each_entry(line, &e1inp_line_list, list) {
679 if (line->num == num) {
680 e1line_dump_vty(vty, line);
681 return CMD_SUCCESS;
682 }
683 }
684 return CMD_WARNING;
685 }
686
687 llist_for_each_entry(line, &e1inp_line_list, list)
688 e1line_dump_vty(vty, line);
689
690 return CMD_SUCCESS;
Harald Welte68628e82009-03-10 12:17:57 +0000691}
692
693static void e1ts_dump_vty(struct vty *vty, struct e1inp_ts *ts)
694{
Harald Welte42581822009-08-08 16:12:58 +0200695 if (ts->type == E1INP_TS_TYPE_NONE)
696 return;
Harald Welte1bc77352009-03-10 19:47:51 +0000697 vty_out(vty, "E1 Timeslot %2u of Line %u is Type %s%s",
698 ts->num, ts->line->num, e1inp_tstype_name(ts->type),
699 VTY_NEWLINE);
Harald Welte68628e82009-03-10 12:17:57 +0000700}
701
702DEFUN(show_e1ts,
703 show_e1ts_cmd,
704 "show e1_timeslot [line_nr] [ts_nr]",
705 SHOW_STR "Display information about a E1 timeslot\n")
706{
Harald Welte986c3d72009-11-17 06:12:16 +0100707 struct e1inp_line *line = NULL;
Harald Welte1bc77352009-03-10 19:47:51 +0000708 struct e1inp_ts *ts;
709 int ts_nr;
Harald Welte68628e82009-03-10 12:17:57 +0000710
Harald Welte1bc77352009-03-10 19:47:51 +0000711 if (argc == 0) {
712 llist_for_each_entry(line, &e1inp_line_list, list) {
713 for (ts_nr = 0; ts_nr < NUM_E1_TS; ts_nr++) {
714 ts = &line->ts[ts_nr];
715 e1ts_dump_vty(vty, ts);
716 }
717 }
718 return CMD_SUCCESS;
719 }
720 if (argc >= 1) {
721 int num = atoi(argv[0]);
722 llist_for_each_entry(line, &e1inp_line_list, list) {
723 if (line->num == num)
724 break;
725 }
726 if (!line || line->num != num) {
727 vty_out(vty, "E1 line %s is invalid%s",
728 argv[0], VTY_NEWLINE);
729 return CMD_WARNING;
730 }
731 }
732 if (argc >= 2) {
733 ts_nr = atoi(argv[1]);
734 if (ts_nr > NUM_E1_TS) {
735 vty_out(vty, "E1 timeslot %s is invalid%s",
736 argv[1], VTY_NEWLINE);
737 return CMD_WARNING;
738 }
739 ts = &line->ts[ts_nr];
740 e1ts_dump_vty(vty, ts);
741 return CMD_SUCCESS;
742 } else {
743 for (ts_nr = 0; ts_nr < NUM_E1_TS; ts_nr++) {
744 ts = &line->ts[ts_nr];
745 e1ts_dump_vty(vty, ts);
746 }
747 return CMD_SUCCESS;
748 }
749 return CMD_SUCCESS;
Harald Welte68628e82009-03-10 12:17:57 +0000750}
751
Harald Weltebe4b7302009-05-23 16:59:33 +0000752static void paging_dump_vty(struct vty *vty, struct gsm_paging_request *pag)
Harald Weltef5025b62009-03-28 16:55:11 +0000753{
754 vty_out(vty, "Paging on BTS %u%s", pag->bts->nr, VTY_NEWLINE);
755 subscr_dump_vty(vty, pag->subscr);
756}
757
Harald Weltebe4b7302009-05-23 16:59:33 +0000758static void bts_paging_dump_vty(struct vty *vty, struct gsm_bts *bts)
Harald Weltef5025b62009-03-28 16:55:11 +0000759{
760 struct gsm_paging_request *pag;
761
762 llist_for_each_entry(pag, &bts->paging.pending_requests, entry)
763 paging_dump_vty(vty, pag);
764}
765
766DEFUN(show_paging,
767 show_paging_cmd,
768 "show paging [bts_nr]",
Harald Weltebe4b7302009-05-23 16:59:33 +0000769 SHOW_STR "Display information about paging reuqests of a BTS\n")
Harald Weltef5025b62009-03-28 16:55:11 +0000770{
771 struct gsm_network *net = gsmnet;
772 struct gsm_bts *bts;
773 int bts_nr;
774
775 if (argc >= 1) {
776 /* use the BTS number that the user has specified */
777 bts_nr = atoi(argv[0]);
778 if (bts_nr >= net->num_bts) {
779 vty_out(vty, "%% can't find BTS %s%s", argv[0],
780 VTY_NEWLINE);
781 return CMD_WARNING;
782 }
Harald Weltee441d9c2009-06-21 16:17:15 +0200783 bts = gsm_bts_num(net, bts_nr);
Harald Weltef5025b62009-03-28 16:55:11 +0000784 bts_paging_dump_vty(vty, bts);
785
786 return CMD_SUCCESS;
787 }
788 for (bts_nr = 0; bts_nr < net->num_bts; bts_nr++) {
Harald Weltee441d9c2009-06-21 16:17:15 +0200789 bts = gsm_bts_num(net, bts_nr);
Harald Weltef5025b62009-03-28 16:55:11 +0000790 bts_paging_dump_vty(vty, bts);
791 }
792
793 return CMD_SUCCESS;
794}
795
Harald Welte24ff6ee2009-12-22 00:41:05 +0100796DEFUN(show_stats,
797 show_stats_cmd,
798 "show statistics",
799 SHOW_STR "Display network statistics\n")
800{
801 struct gsm_network *net = gsmnet;
802
803 vty_out(vty, "Channel Requests: %lu total, %lu no channel%s",
804 net->stats.chreq.total, net->stats.chreq.no_channel,
805 VTY_NEWLINE);
806 vty_out(vty, "Location Update: %lu attach, %lu normal, %lu periodic%s",
807 net->stats.loc_upd_type.attach, net->stats.loc_upd_type.normal,
808 net->stats.loc_upd_type.periodic, VTY_NEWLINE);
809 vty_out(vty, "IMSI Detach Indications: %lu%s\n",
810 net->stats.loc_upd_type.detach, VTY_NEWLINE);
811 vty_out(vty, "Location Update Response: %lu accept, %lu reject%s",
812 net->stats.loc_upd_resp.accept,
813 net->stats.loc_upd_resp.reject, VTY_NEWLINE);
814 vty_out(vty, "Paging: %lu attempted, %lu complete, %lu expired%s",
815 net->stats.paging.attempted, net->stats.paging.completed,
816 net->stats.paging.expired, VTY_NEWLINE);
817 vty_out(vty, "Handover: %lu attempted, %lu no_channel, %lu timeout, "
818 "%lu completed, %lu failed%s", net->stats.handover.attempted,
819 net->stats.handover.no_channel, net->stats.handover.timeout,
820 net->stats.handover.completed, net->stats.handover.failed,
821 VTY_NEWLINE);
822 vty_out(vty, "SMS MO: %lu submitted, %lu no receiver%s",
823 net->stats.sms.submitted, net->stats.sms.no_receiver,
824 VTY_NEWLINE);
825 vty_out(vty, "SMS MT: %lu delivered, %lu no memory, %lu other error%s",
826 net->stats.sms.delivered, net->stats.sms.rp_err_mem,
827 net->stats.sms.rp_err_other, VTY_NEWLINE);
828 return CMD_SUCCESS;
829}
830
Harald Welte5013b2a2009-08-07 13:29:14 +0200831DEFUN(cfg_net,
832 cfg_net_cmd,
833 "network",
834 "Configure the GSM network")
835{
836 vty->index = gsmnet;
837 vty->node = GSMNET_NODE;
838
839 return CMD_SUCCESS;
840}
841
842
843DEFUN(cfg_net_ncc,
844 cfg_net_ncc_cmd,
845 "network country code <1-999>",
846 "Set the GSM network country code")
847{
848 gsmnet->country_code = atoi(argv[0]);
849
850 return CMD_SUCCESS;
851}
852
853DEFUN(cfg_net_mnc,
854 cfg_net_mnc_cmd,
855 "mobile network code <1-999>",
856 "Set the GSM mobile network code")
857{
858 gsmnet->network_code = atoi(argv[0]);
859
860 return CMD_SUCCESS;
861}
862
863DEFUN(cfg_net_name_short,
864 cfg_net_name_short_cmd,
865 "short name NAME",
866 "Set the short GSM network name")
867{
868 if (gsmnet->name_short)
869 talloc_free(gsmnet->name_short);
870
871 gsmnet->name_short = talloc_strdup(gsmnet, argv[0]);
872
873 return CMD_SUCCESS;
874}
875
876DEFUN(cfg_net_name_long,
877 cfg_net_name_long_cmd,
878 "long name NAME",
879 "Set the long GSM network name")
880{
881 if (gsmnet->name_long)
882 talloc_free(gsmnet->name_long);
883
884 gsmnet->name_long = talloc_strdup(gsmnet, argv[0]);
885
886 return CMD_SUCCESS;
887}
Harald Welte40f82892009-05-23 17:31:39 +0000888
Harald Welte (local)69de3972009-08-12 14:42:23 +0200889DEFUN(cfg_net_auth_policy,
890 cfg_net_auth_policy_cmd,
891 "auth policy (closed|accept-all|token)",
892 "Set the GSM network authentication policy\n")
893{
894 enum gsm_auth_policy policy = gsm_auth_policy_parse(argv[0]);
895
896 gsmnet->auth_policy = policy;
897
898 return CMD_SUCCESS;
899}
900
Harald Welte1085c092009-11-18 20:33:19 +0100901DEFUN(cfg_net_reject_cause,
902 cfg_net_reject_cause_cmd,
903 "location updating reject cause <2-111>",
904 "Set the reject cause of location updating reject\n")
905{
906 gsmnet->reject_cause = atoi(argv[0]);
907
908 return CMD_SUCCESS;
909}
910
Harald Welte4381cfe2009-08-30 15:47:06 +0900911DEFUN(cfg_net_encryption,
912 cfg_net_encryption_cmd,
913 "encryption a5 (0|1|2)",
914 "Enable or disable encryption (A5) for this network\n")
915{
Andreas.Eversberg1059deb2009-11-17 09:55:26 +0100916 gsmnet->a5_encryption= atoi(argv[0]);
Harald Welte4381cfe2009-08-30 15:47:06 +0900917
918 return CMD_SUCCESS;
919}
920
Holger Hans Peter Freytherf7d752f2009-11-16 17:12:38 +0100921DEFUN(cfg_net_neci,
922 cfg_net_neci_cmd,
923 "neci (0|1)",
924 "Set if NECI of cell selection is to be set")
925{
926 gsmnet->neci = atoi(argv[0]);
927 return CMD_SUCCESS;
928}
929
Harald Welteeab84a12009-12-13 10:53:12 +0100930DEFUN(cfg_net_rrlp_mode, cfg_net_rrlp_mode_cmd,
931 "rrlp mode (none|ms-based|ms-preferred|ass-preferred)",
932 "Set the Radio Resource Location Protocol Mode")
933{
934 gsmnet->rrlp.mode = rrlp_mode_parse(argv[0]);
935
936 return CMD_SUCCESS;
937}
938
Harald Welte648b6ce2009-12-14 09:00:24 +0100939DEFUN(cfg_net_mm_info, cfg_net_mm_info_cmd,
940 "mm info (0|1)",
941 "Whether to send MM INFO after LOC UPD ACCEPT")
942{
943 gsmnet->send_mm_info = atoi(argv[0]);
944
945 return CMD_SUCCESS;
946}
947
Harald Weltebc814502009-12-19 21:41:52 +0100948DEFUN(cfg_net_handover, cfg_net_handover_cmd,
949 "handover (0|1)",
950 "Whether or not to use in-call handover")
951{
Harald Weltefe03f0d2009-12-20 13:51:01 +0100952 if (ipacc_rtp_direct) {
953 vty_out(vty, "%% Cannot enable handover unless RTP Proxy mode "
954 "is enabled by using the -P command line option%s",
955 VTY_NEWLINE);
956 return CMD_WARNING;
957 }
Harald Weltebc814502009-12-19 21:41:52 +0100958 gsmnet->handover.active = atoi(argv[0]);
959
960 return CMD_SUCCESS;
961}
962
Harald Welteb720bd32009-12-21 16:51:50 +0100963DEFUN(cfg_net_ho_win_rxlev_avg, cfg_net_ho_win_rxlev_avg_cmd,
964 "handover window rxlev averaging <1-10>",
965 "How many RxLev measurements are used for averaging")
966{
967 gsmnet->handover.win_rxlev_avg = atoi(argv[0]);
968 return CMD_SUCCESS;
969}
970
971DEFUN(cfg_net_ho_win_rxqual_avg, cfg_net_ho_win_rxqual_avg_cmd,
972 "handover window rxqual averaging <1-10>",
973 "How many RxQual measurements are used for averaging")
974{
975 gsmnet->handover.win_rxqual_avg = atoi(argv[0]);
976 return CMD_SUCCESS;
977}
978
979DEFUN(cfg_net_ho_win_rxlev_neigh_avg, cfg_net_ho_win_rxlev_avg_neigh_cmd,
980 "handover window rxlev neighbor averaging <1-10>",
981 "How many RxQual measurements are used for averaging")
982{
983 gsmnet->handover.win_rxlev_avg_neigh = atoi(argv[0]);
984 return CMD_SUCCESS;
985}
986
987DEFUN(cfg_net_ho_pwr_interval, cfg_net_ho_pwr_interval_cmd,
988 "handover power budget interval <1-99>",
989 "How often to check if we have a better cell (SACCH frames)")
990{
991 gsmnet->handover.pwr_interval = atoi(argv[0]);
992 return CMD_SUCCESS;
993}
994
995DEFUN(cfg_net_ho_pwr_hysteresis, cfg_net_ho_pwr_hysteresis_cmd,
996 "handover power budget hysteresis <0-999>",
997 "How many dB does a neighbor to be stronger to become a HO candidate")
998{
999 gsmnet->handover.pwr_hysteresis = atoi(argv[0]);
1000 return CMD_SUCCESS;
1001}
1002
1003DEFUN(cfg_net_ho_max_distance, cfg_net_ho_max_distance_cmd,
1004 "handover maximum distance <0-9999>",
1005 "How big is the maximum timing advance before HO is forced")
1006{
1007 gsmnet->handover.max_distance = atoi(argv[0]);
1008 return CMD_SUCCESS;
1009}
Harald Weltebc814502009-12-19 21:41:52 +01001010
Holger Hans Peter Freytherc8021062009-12-22 08:27:21 +01001011#define DECLARE_TIMER(number, doc) \
Holger Hans Peter Freytherc4d88ad2009-11-21 21:18:38 +01001012 DEFUN(cfg_net_T##number, \
1013 cfg_net_T##number##_cmd, \
1014 "timer t" #number " <0-65535>", \
Holger Hans Peter Freytherc8021062009-12-22 08:27:21 +01001015 doc) \
Holger Hans Peter Freytherc4d88ad2009-11-21 21:18:38 +01001016{ \
1017 int value = atoi(argv[0]); \
1018 \
1019 if (value < 0 || value > 65535) { \
1020 vty_out(vty, "Timer value %s out of range.%s", \
1021 argv[0], VTY_NEWLINE); \
1022 return CMD_WARNING; \
1023 } \
1024 \
1025 gsmnet->T##number = value; \
1026 return CMD_SUCCESS; \
1027}
1028
Holger Hans Peter Freytherc8021062009-12-22 08:27:21 +01001029DECLARE_TIMER(3101, "Set the timeout value for IMMEDIATE ASSIGNMENT.")
1030DECLARE_TIMER(3103, "Set the timeout value for HANDOVER.")
1031DECLARE_TIMER(3105, "Currently not used.")
1032DECLARE_TIMER(3107, "Currently not used.")
1033DECLARE_TIMER(3109, "Currently not used.")
1034DECLARE_TIMER(3111, "Currently not used.")
1035DECLARE_TIMER(3113, "Set the time to try paging a subscriber.")
1036DECLARE_TIMER(3115, "Currently not used.")
1037DECLARE_TIMER(3117, "Currently not used.")
1038DECLARE_TIMER(3119, "Currently not used.")
1039DECLARE_TIMER(3141, "Currently not used.")
Holger Hans Peter Freytherc4d88ad2009-11-21 21:18:38 +01001040
1041
Harald Welte5258fc42009-03-28 19:07:53 +00001042/* per-BTS configuration */
1043DEFUN(cfg_bts,
1044 cfg_bts_cmd,
1045 "bts BTS_NR",
1046 "Select a BTS to configure\n")
1047{
1048 int bts_nr = atoi(argv[0]);
1049 struct gsm_bts *bts;
1050
Harald Weltee441d9c2009-06-21 16:17:15 +02001051 if (bts_nr > gsmnet->num_bts) {
1052 vty_out(vty, "%% The next unused BTS number is %u%s",
1053 gsmnet->num_bts, VTY_NEWLINE);
Harald Welte5258fc42009-03-28 19:07:53 +00001054 return CMD_WARNING;
Harald Weltee441d9c2009-06-21 16:17:15 +02001055 } else if (bts_nr == gsmnet->num_bts) {
1056 /* allocate a new one */
1057 bts = gsm_bts_alloc(gsmnet, GSM_BTS_TYPE_UNKNOWN,
1058 HARDCODED_TSC, HARDCODED_BSIC);
1059 } else
1060 bts = gsm_bts_num(gsmnet, bts_nr);
1061
1062 if (!bts)
1063 return CMD_WARNING;
Harald Welte5258fc42009-03-28 19:07:53 +00001064
1065 vty->index = bts;
1066 vty->node = BTS_NODE;
1067
1068 return CMD_SUCCESS;
1069}
1070
1071DEFUN(cfg_bts_type,
1072 cfg_bts_type_cmd,
1073 "type TYPE",
1074 "Set the BTS type\n")
1075{
1076 struct gsm_bts *bts = vty->index;
1077
Harald Weltea6fd58e2009-08-07 00:25:23 +02001078 bts->type = parse_btstype(argv[0]);
1079
Harald Welte8175e952009-10-20 00:22:00 +02001080 if (is_ipaccess_bts(bts)) {
1081 /* Set the default OML Stream ID to 0xff */
1082 bts->oml_tei = 0xff;
1083 }
1084
Harald Welte5258fc42009-03-28 19:07:53 +00001085 return CMD_SUCCESS;
1086}
1087
Harald Weltefcd24452009-06-20 18:15:19 +02001088DEFUN(cfg_bts_band,
1089 cfg_bts_band_cmd,
1090 "band BAND",
1091 "Set the frequency band of this BTS\n")
1092{
1093 struct gsm_bts *bts = vty->index;
Harald Welte42581822009-08-08 16:12:58 +02001094 int band = gsm_band_parse(argv[0]);
Harald Weltefcd24452009-06-20 18:15:19 +02001095
1096 if (band < 0) {
1097 vty_out(vty, "%% BAND %d is not a valid GSM band%s",
1098 band, VTY_NEWLINE);
1099 return CMD_WARNING;
1100 }
1101
1102 bts->band = band;
1103
1104 return CMD_SUCCESS;
1105}
1106
Holger Hans Peter Freytherc4a49e32009-08-21 14:44:12 +02001107DEFUN(cfg_bts_ci,
1108 cfg_bts_ci_cmd,
1109 "cell_identity <0-65535>",
1110 "Set the Cell identity of this BTS\n")
1111{
1112 struct gsm_bts *bts = vty->index;
1113 int ci = atoi(argv[0]);
1114
1115 if (ci < 0 || ci > 0xffff) {
1116 vty_out(vty, "%% CI %d is not in the valid range (0-65535)%s",
1117 ci, VTY_NEWLINE);
1118 return CMD_WARNING;
1119 }
1120 bts->cell_identity = ci;
1121
1122 return CMD_SUCCESS;
1123}
1124
Harald Welte5258fc42009-03-28 19:07:53 +00001125DEFUN(cfg_bts_lac,
1126 cfg_bts_lac_cmd,
Holger Hans Peter Freyther0b7f4b32009-09-29 14:02:33 +02001127 "location_area_code <0-65535>",
Harald Welte5258fc42009-03-28 19:07:53 +00001128 "Set the Location Area Code (LAC) of this BTS\n")
1129{
1130 struct gsm_bts *bts = vty->index;
1131 int lac = atoi(argv[0]);
1132
Holger Hans Peter Freyther0b7f4b32009-09-29 14:02:33 +02001133 if (lac < 0 || lac > 0xffff) {
1134 vty_out(vty, "%% LAC %d is not in the valid range (0-65535)%s",
Harald Welte5258fc42009-03-28 19:07:53 +00001135 lac, VTY_NEWLINE);
1136 return CMD_WARNING;
1137 }
Holger Hans Peter Freythere48b9562009-10-01 04:07:15 +02001138
1139 if (lac == GSM_LAC_RESERVED_DETACHED || lac == GSM_LAC_RESERVED_ALL_BTS) {
1140 vty_out(vty, "%% LAC %d is reserved by GSM 04.08%s",
1141 lac, VTY_NEWLINE);
1142 return CMD_WARNING;
1143 }
1144
Harald Welte5258fc42009-03-28 19:07:53 +00001145 bts->location_area_code = lac;
1146
1147 return CMD_SUCCESS;
1148}
1149
Harald Weltea43f7892009-12-01 18:04:30 +05301150
Harald Welte5258fc42009-03-28 19:07:53 +00001151DEFUN(cfg_bts_tsc,
1152 cfg_bts_tsc_cmd,
1153 "training_sequence_code <0-255>",
1154 "Set the Training Sequence Code (TSC) of this BTS\n")
1155{
1156 struct gsm_bts *bts = vty->index;
1157 int tsc = atoi(argv[0]);
1158
1159 if (tsc < 0 || tsc > 0xff) {
1160 vty_out(vty, "%% TSC %d is not in the valid range (0-255)%s",
1161 tsc, VTY_NEWLINE);
1162 return CMD_WARNING;
1163 }
1164 bts->tsc = tsc;
1165
1166 return CMD_SUCCESS;
1167}
1168
Harald Welte78f2f502009-05-23 16:56:52 +00001169DEFUN(cfg_bts_bsic,
1170 cfg_bts_bsic_cmd,
1171 "base_station_id_code <0-63>",
1172 "Set the Base Station Identity Code (BSIC) of this BTS\n")
1173{
1174 struct gsm_bts *bts = vty->index;
1175 int bsic = atoi(argv[0]);
1176
1177 if (bsic < 0 || bsic > 0x3f) {
Harald Welte42581822009-08-08 16:12:58 +02001178 vty_out(vty, "%% BSIC %d is not in the valid range (0-255)%s",
Harald Welte78f2f502009-05-23 16:56:52 +00001179 bsic, VTY_NEWLINE);
1180 return CMD_WARNING;
1181 }
1182 bts->bsic = bsic;
1183
1184 return CMD_SUCCESS;
1185}
1186
1187
Harald Welte4cc34222009-05-01 15:12:31 +00001188DEFUN(cfg_bts_unit_id,
1189 cfg_bts_unit_id_cmd,
Harald Welte07dc73d2009-08-07 13:27:09 +02001190 "ip.access unit_id <0-65534> <0-255>",
1191 "Set the ip.access BTS Unit ID of this BTS\n")
Harald Welte4cc34222009-05-01 15:12:31 +00001192{
1193 struct gsm_bts *bts = vty->index;
1194 int site_id = atoi(argv[0]);
1195 int bts_id = atoi(argv[1]);
1196
Harald Welte07dc73d2009-08-07 13:27:09 +02001197 if (!is_ipaccess_bts(bts)) {
1198 vty_out(vty, "%% BTS is not of ip.access type%s", VTY_NEWLINE);
1199 return CMD_WARNING;
1200 }
1201
Harald Welte4cc34222009-05-01 15:12:31 +00001202 bts->ip_access.site_id = site_id;
1203 bts->ip_access.bts_id = bts_id;
1204
1205 return CMD_SUCCESS;
1206}
1207
Harald Welte8175e952009-10-20 00:22:00 +02001208DEFUN(cfg_bts_stream_id,
1209 cfg_bts_stream_id_cmd,
1210 "oml ip.access stream_id <0-255>",
1211 "Set the ip.access Stream ID of the OML link of this BTS\n")
1212{
1213 struct gsm_bts *bts = vty->index;
1214 int stream_id = atoi(argv[0]);
1215
1216 if (!is_ipaccess_bts(bts)) {
1217 vty_out(vty, "%% BTS is not of ip.access type%s", VTY_NEWLINE);
1218 return CMD_WARNING;
1219 }
1220
1221 bts->oml_tei = stream_id;
1222
1223 return CMD_SUCCESS;
1224}
1225
1226
Harald Welte42581822009-08-08 16:12:58 +02001227DEFUN(cfg_bts_oml_e1,
1228 cfg_bts_oml_e1_cmd,
1229 "oml e1 line E1_LINE timeslot <1-31> sub-slot (0|1|2|3|full)",
1230 "E1 interface to be used for OML\n")
1231{
1232 struct gsm_bts *bts = vty->index;
1233
1234 parse_e1_link(&bts->oml_e1_link, argv[0], argv[1], argv[2]);
1235
1236 return CMD_SUCCESS;
1237}
1238
1239
1240DEFUN(cfg_bts_oml_e1_tei,
1241 cfg_bts_oml_e1_tei_cmd,
1242 "oml e1 tei <0-63>",
1243 "Set the TEI to be used for OML")
1244{
1245 struct gsm_bts *bts = vty->index;
1246
1247 bts->oml_tei = atoi(argv[0]);
1248
1249 return CMD_SUCCESS;
1250}
1251
Harald Welte7a8fa412009-08-10 13:48:16 +02001252DEFUN(cfg_bts_challoc, cfg_bts_challoc_cmd,
1253 "channel allocator (ascending|descending)",
1254 "Should the channel allocator allocate in reverse TRX order?")
1255{
1256 struct gsm_bts *bts = vty->index;
1257
1258 if (!strcmp(argv[0], "ascending"))
1259 bts->chan_alloc_reverse = 0;
1260 else
1261 bts->chan_alloc_reverse = 1;
1262
1263 return CMD_SUCCESS;
1264}
1265
Harald Welte (local)5dececf2009-08-12 13:28:23 +02001266DEFUN(cfg_bts_cell_barred, cfg_bts_cell_barred_cmd,
1267 "cell barred (0|1)",
1268 "Should this cell be barred from access?")
1269{
1270 struct gsm_bts *bts = vty->index;
1271
Harald Welte71355012009-12-21 23:08:18 +01001272 bts->si_common.rach_control.cell_bar = atoi(argv[0]);
Harald Welte (local)5dececf2009-08-12 13:28:23 +02001273
1274 return CMD_SUCCESS;
1275}
1276
Harald Welte (local)0e451d02009-08-13 10:14:26 +02001277DEFUN(cfg_bts_ms_max_power, cfg_bts_ms_max_power_cmd,
1278 "ms max power <0-40>",
1279 "Maximum transmit power of the MS")
1280{
1281 struct gsm_bts *bts = vty->index;
1282
1283 bts->ms_max_power = atoi(argv[0]);
1284
1285 return CMD_SUCCESS;
1286}
1287
Harald Welte73225282009-12-12 18:17:25 +01001288DEFUN(cfg_bts_cell_resel_hyst, cfg_bts_cell_resel_hyst_cmd,
1289 "cell reselection hysteresis <0-14>",
1290 "Cell Re-Selection Hysteresis in dB")
1291{
1292 struct gsm_bts *bts = vty->index;
1293
1294 bts->si_common.cell_sel_par.cell_resel_hyst = atoi(argv[0])/2;
1295
1296 return CMD_SUCCESS;
1297}
1298
1299DEFUN(cfg_bts_rxlev_acc_min, cfg_bts_rxlev_acc_min_cmd,
1300 "rxlev access min <0-63>",
1301 "Minimum RxLev needed for cell access (better than -110dBm)")
1302{
1303 struct gsm_bts *bts = vty->index;
1304
1305 bts->si_common.cell_sel_par.rxlev_acc_min = atoi(argv[0]);
1306
1307 return CMD_SUCCESS;
1308}
1309
Harald Welte (local)efc92312009-08-14 23:09:25 +02001310DEFUN(cfg_bts_per_loc_upd, cfg_bts_per_loc_upd_cmd,
1311 "periodic location update <0-1530>",
1312 "Periodic Location Updating Interval in Minutes")
1313{
1314 struct gsm_bts *bts = vty->index;
1315
Harald Weltea43f7892009-12-01 18:04:30 +05301316 bts->si_common.chan_desc.t3212 = atoi(argv[0]) / 10;
Harald Welte (local)efc92312009-08-14 23:09:25 +02001317
1318 return CMD_SUCCESS;
1319}
1320
Harald Welte7a8fa412009-08-10 13:48:16 +02001321
Harald Welte5258fc42009-03-28 19:07:53 +00001322/* per TRX configuration */
1323DEFUN(cfg_trx,
1324 cfg_trx_cmd,
1325 "trx TRX_NR",
1326 "Select a TRX to configure")
1327{
1328 int trx_nr = atoi(argv[0]);
1329 struct gsm_bts *bts = vty->index;
1330 struct gsm_bts_trx *trx;
1331
Harald Weltee441d9c2009-06-21 16:17:15 +02001332 if (trx_nr > bts->num_trx) {
1333 vty_out(vty, "%% The next unused TRX number in this BTS is %u%s",
1334 bts->num_trx, VTY_NEWLINE);
Harald Welte5258fc42009-03-28 19:07:53 +00001335 return CMD_WARNING;
Harald Weltee441d9c2009-06-21 16:17:15 +02001336 } else if (trx_nr == bts->num_trx) {
1337 /* we need to allocate a new one */
1338 trx = gsm_bts_trx_alloc(bts);
1339 } else
1340 trx = gsm_bts_trx_num(bts, trx_nr);
1341
1342 if (!trx)
1343 return CMD_WARNING;
Harald Welte5258fc42009-03-28 19:07:53 +00001344
1345 vty->index = trx;
1346 vty->node = TRX_NODE;
1347
1348 return CMD_SUCCESS;
1349}
1350
1351DEFUN(cfg_trx_arfcn,
1352 cfg_trx_arfcn_cmd,
1353 "arfcn <1-1024>",
1354 "Set the ARFCN for this TRX\n")
1355{
1356 int arfcn = atoi(argv[0]);
1357 struct gsm_bts_trx *trx = vty->index;
1358
1359 /* FIXME: check if this ARFCN is supported by this TRX */
1360
1361 trx->arfcn = arfcn;
1362
1363 /* FIXME: patch ARFCN into SYSTEM INFORMATION */
1364 /* FIXME: use OML layer to update the ARFCN */
1365 /* FIXME: use RSL layer to update SYSTEM INFORMATION */
1366
1367 return CMD_SUCCESS;
1368}
1369
Harald Weltefcd24452009-06-20 18:15:19 +02001370DEFUN(cfg_trx_max_power_red,
1371 cfg_trx_max_power_red_cmd,
1372 "max_power_red <0-100>",
1373 "Reduction of maximum BS RF Power in dB\n")
1374{
1375 int maxpwr_r = atoi(argv[0]);
1376 struct gsm_bts_trx *trx = vty->index;
Harald Welte61a83b22009-11-18 09:20:22 +01001377 int upper_limit = 24; /* default 12.21 max power red. */
Harald Weltefcd24452009-06-20 18:15:19 +02001378
1379 /* FIXME: check if our BTS type supports more than 12 */
1380 if (maxpwr_r < 0 || maxpwr_r > upper_limit) {
1381 vty_out(vty, "%% Power %d dB is not in the valid range%s",
1382 maxpwr_r, VTY_NEWLINE);
1383 return CMD_WARNING;
1384 }
1385 if (maxpwr_r & 1) {
1386 vty_out(vty, "%% Power %d dB is not an even value%s",
1387 maxpwr_r, VTY_NEWLINE);
1388 return CMD_WARNING;
1389 }
1390
1391 trx->max_power_red = maxpwr_r;
1392
1393 /* FIXME: make sure we update this using OML */
1394
1395 return CMD_SUCCESS;
1396}
1397
Harald Welte42581822009-08-08 16:12:58 +02001398DEFUN(cfg_trx_rsl_e1,
1399 cfg_trx_rsl_e1_cmd,
1400 "rsl e1 line E1_LINE timeslot <1-31> sub-slot (0|1|2|3|full)",
1401 "E1 interface to be used for RSL\n")
1402{
1403 struct gsm_bts_trx *trx = vty->index;
1404
1405 parse_e1_link(&trx->rsl_e1_link, argv[0], argv[1], argv[2]);
1406
1407 return CMD_SUCCESS;
1408}
1409
1410DEFUN(cfg_trx_rsl_e1_tei,
1411 cfg_trx_rsl_e1_tei_cmd,
1412 "rsl e1 tei <0-63>",
1413 "Set the TEI to be used for RSL")
1414{
1415 struct gsm_bts_trx *trx = vty->index;
1416
1417 trx->rsl_tei = atoi(argv[0]);
1418
1419 return CMD_SUCCESS;
1420}
1421
Holger Hans Peter Freyther2d501ea2009-11-11 11:54:24 +01001422DEFUN(cfg_trx_rf_locked,
1423 cfg_trx_rf_locked_cmd,
1424 "rf_locked (0|1)",
1425 "Turn off RF of the TRX.\n")
1426{
1427 int locked = atoi(argv[0]);
1428 struct gsm_bts_trx *trx = vty->index;
1429
1430 gsm_trx_lock_rf(trx, locked);
1431 return CMD_SUCCESS;
1432}
Harald Welte42581822009-08-08 16:12:58 +02001433
Harald Welte5258fc42009-03-28 19:07:53 +00001434/* per TS configuration */
1435DEFUN(cfg_ts,
1436 cfg_ts_cmd,
Harald Welte42581822009-08-08 16:12:58 +02001437 "timeslot <0-7>",
Harald Welte5258fc42009-03-28 19:07:53 +00001438 "Select a Timeslot to configure")
1439{
1440 int ts_nr = atoi(argv[0]);
1441 struct gsm_bts_trx *trx = vty->index;
1442 struct gsm_bts_trx_ts *ts;
1443
1444 if (ts_nr >= TRX_NR_TS) {
1445 vty_out(vty, "%% A GSM TRX only has %u Timeslots per TRX%s",
1446 TRX_NR_TS, VTY_NEWLINE);
1447 return CMD_WARNING;
1448 }
1449
1450 ts = &trx->ts[ts_nr];
1451
1452 vty->index = ts;
1453 vty->node = TS_NODE;
1454
1455 return CMD_SUCCESS;
1456}
1457
Harald Weltea6fd58e2009-08-07 00:25:23 +02001458DEFUN(cfg_ts_pchan,
1459 cfg_ts_pchan_cmd,
1460 "phys_chan_config PCHAN",
1461 "Physical Channel configuration (TCH/SDCCH/...)")
1462{
1463 struct gsm_bts_trx_ts *ts = vty->index;
1464 int pchanc;
1465
1466 pchanc = gsm_pchan_parse(argv[0]);
1467 if (pchanc < 0)
1468 return CMD_WARNING;
1469
1470 ts->pchan = pchanc;
1471
1472 return CMD_SUCCESS;
1473}
1474
1475DEFUN(cfg_ts_e1_subslot,
1476 cfg_ts_e1_subslot_cmd,
Harald Welte42581822009-08-08 16:12:58 +02001477 "e1 line E1_LINE timeslot <1-31> sub-slot (0|1|2|3|full)",
Harald Weltea6fd58e2009-08-07 00:25:23 +02001478 "E1 sub-slot connected to this on-air timeslot")
1479{
1480 struct gsm_bts_trx_ts *ts = vty->index;
1481
Harald Welte42581822009-08-08 16:12:58 +02001482 parse_e1_link(&ts->e1_link, argv[0], argv[1], argv[2]);
Harald Weltea6fd58e2009-08-07 00:25:23 +02001483
1484 return CMD_SUCCESS;
1485}
Harald Welte5258fc42009-03-28 19:07:53 +00001486
Harald Welte68628e82009-03-10 12:17:57 +00001487int bsc_vty_init(struct gsm_network *net)
1488{
1489 gsmnet = net;
1490
1491 cmd_init(1);
1492 vty_init();
1493
1494 install_element(VIEW_NODE, &show_net_cmd);
1495 install_element(VIEW_NODE, &show_bts_cmd);
1496 install_element(VIEW_NODE, &show_trx_cmd);
1497 install_element(VIEW_NODE, &show_ts_cmd);
1498 install_element(VIEW_NODE, &show_lchan_cmd);
Harald Welte1bc77352009-03-10 19:47:51 +00001499
1500 install_element(VIEW_NODE, &show_e1drv_cmd);
Harald Welte68628e82009-03-10 12:17:57 +00001501 install_element(VIEW_NODE, &show_e1line_cmd);
1502 install_element(VIEW_NODE, &show_e1ts_cmd);
1503
Harald Weltef5025b62009-03-28 16:55:11 +00001504 install_element(VIEW_NODE, &show_paging_cmd);
Harald Welte24ff6ee2009-12-22 00:41:05 +01001505 install_element(VIEW_NODE, &show_stats_cmd);
Harald Welte5258fc42009-03-28 19:07:53 +00001506
Harald Welte5013b2a2009-08-07 13:29:14 +02001507 install_element(CONFIG_NODE, &cfg_net_cmd);
1508 install_node(&net_node, config_write_net);
1509 install_default(GSMNET_NODE);
Harald Welte42581822009-08-08 16:12:58 +02001510 install_element(GSMNET_NODE, &cfg_net_ncc_cmd);
Harald Welte5013b2a2009-08-07 13:29:14 +02001511 install_element(GSMNET_NODE, &cfg_net_mnc_cmd);
1512 install_element(GSMNET_NODE, &cfg_net_name_short_cmd);
1513 install_element(GSMNET_NODE, &cfg_net_name_long_cmd);
Harald Welte (local)69de3972009-08-12 14:42:23 +02001514 install_element(GSMNET_NODE, &cfg_net_auth_policy_cmd);
Harald Welte1085c092009-11-18 20:33:19 +01001515 install_element(GSMNET_NODE, &cfg_net_reject_cause_cmd);
Harald Welte4381cfe2009-08-30 15:47:06 +09001516 install_element(GSMNET_NODE, &cfg_net_encryption_cmd);
Holger Hans Peter Freytherf7d752f2009-11-16 17:12:38 +01001517 install_element(GSMNET_NODE, &cfg_net_neci_cmd);
Harald Welteeab84a12009-12-13 10:53:12 +01001518 install_element(GSMNET_NODE, &cfg_net_rrlp_mode_cmd);
Harald Welte3d23db42009-12-14 17:49:15 +01001519 install_element(GSMNET_NODE, &cfg_net_mm_info_cmd);
Harald Weltebc814502009-12-19 21:41:52 +01001520 install_element(GSMNET_NODE, &cfg_net_handover_cmd);
Harald Welteb720bd32009-12-21 16:51:50 +01001521 install_element(GSMNET_NODE, &cfg_net_ho_win_rxlev_avg_cmd);
1522 install_element(GSMNET_NODE, &cfg_net_ho_win_rxqual_avg_cmd);
1523 install_element(GSMNET_NODE, &cfg_net_ho_win_rxlev_avg_neigh_cmd);
1524 install_element(GSMNET_NODE, &cfg_net_ho_pwr_interval_cmd);
1525 install_element(GSMNET_NODE, &cfg_net_ho_pwr_hysteresis_cmd);
1526 install_element(GSMNET_NODE, &cfg_net_ho_max_distance_cmd);
Holger Hans Peter Freytherc4d88ad2009-11-21 21:18:38 +01001527 install_element(GSMNET_NODE, &cfg_net_T3101_cmd);
Holger Hans Peter Freyther23975e72009-11-21 21:42:26 +01001528 install_element(GSMNET_NODE, &cfg_net_T3103_cmd);
1529 install_element(GSMNET_NODE, &cfg_net_T3105_cmd);
1530 install_element(GSMNET_NODE, &cfg_net_T3107_cmd);
1531 install_element(GSMNET_NODE, &cfg_net_T3109_cmd);
1532 install_element(GSMNET_NODE, &cfg_net_T3111_cmd);
1533 install_element(GSMNET_NODE, &cfg_net_T3113_cmd);
1534 install_element(GSMNET_NODE, &cfg_net_T3115_cmd);
1535 install_element(GSMNET_NODE, &cfg_net_T3117_cmd);
1536 install_element(GSMNET_NODE, &cfg_net_T3119_cmd);
1537 install_element(GSMNET_NODE, &cfg_net_T3141_cmd);
Harald Welte5013b2a2009-08-07 13:29:14 +02001538
1539 install_element(GSMNET_NODE, &cfg_bts_cmd);
Harald Welte67ce0732009-08-06 19:06:46 +02001540 install_node(&bts_node, config_write_bts);
Harald Welte68628e82009-03-10 12:17:57 +00001541 install_default(BTS_NODE);
Harald Welte5258fc42009-03-28 19:07:53 +00001542 install_element(BTS_NODE, &cfg_bts_type_cmd);
Harald Weltefcd24452009-06-20 18:15:19 +02001543 install_element(BTS_NODE, &cfg_bts_band_cmd);
Holger Hans Peter Freytherc4a49e32009-08-21 14:44:12 +02001544 install_element(BTS_NODE, &cfg_bts_ci_cmd);
Harald Welte5258fc42009-03-28 19:07:53 +00001545 install_element(BTS_NODE, &cfg_bts_lac_cmd);
1546 install_element(BTS_NODE, &cfg_bts_tsc_cmd);
Harald Welte42581822009-08-08 16:12:58 +02001547 install_element(BTS_NODE, &cfg_bts_bsic_cmd);
Harald Welte4cc34222009-05-01 15:12:31 +00001548 install_element(BTS_NODE, &cfg_bts_unit_id_cmd);
Harald Welte8175e952009-10-20 00:22:00 +02001549 install_element(BTS_NODE, &cfg_bts_stream_id_cmd);
Harald Welte42581822009-08-08 16:12:58 +02001550 install_element(BTS_NODE, &cfg_bts_oml_e1_cmd);
1551 install_element(BTS_NODE, &cfg_bts_oml_e1_tei_cmd);
Harald Welte7a8fa412009-08-10 13:48:16 +02001552 install_element(BTS_NODE, &cfg_bts_challoc_cmd);
Harald Welte (local)5dececf2009-08-12 13:28:23 +02001553 install_element(BTS_NODE, &cfg_bts_cell_barred_cmd);
Harald Welte (local)0e451d02009-08-13 10:14:26 +02001554 install_element(BTS_NODE, &cfg_bts_ms_max_power_cmd);
Harald Welte (local)efc92312009-08-14 23:09:25 +02001555 install_element(BTS_NODE, &cfg_bts_per_loc_upd_cmd);
Harald Welte73225282009-12-12 18:17:25 +01001556 install_element(BTS_NODE, &cfg_bts_cell_resel_hyst_cmd);
1557 install_element(BTS_NODE, &cfg_bts_rxlev_acc_min_cmd);
Harald Welte7a8fa412009-08-10 13:48:16 +02001558
Harald Welte68628e82009-03-10 12:17:57 +00001559
Harald Welte5258fc42009-03-28 19:07:53 +00001560 install_element(BTS_NODE, &cfg_trx_cmd);
Harald Welte68628e82009-03-10 12:17:57 +00001561 install_node(&trx_node, dummy_config_write);
Harald Welte68628e82009-03-10 12:17:57 +00001562 install_default(TRX_NODE);
Harald Welte5258fc42009-03-28 19:07:53 +00001563 install_element(TRX_NODE, &cfg_trx_arfcn_cmd);
Harald Welte879dc972009-06-20 22:36:12 +02001564 install_element(TRX_NODE, &cfg_trx_max_power_red_cmd);
Harald Welte42581822009-08-08 16:12:58 +02001565 install_element(TRX_NODE, &cfg_trx_rsl_e1_cmd);
1566 install_element(TRX_NODE, &cfg_trx_rsl_e1_tei_cmd);
Holger Hans Peter Freyther2d501ea2009-11-11 11:54:24 +01001567 install_element(TRX_NODE, &cfg_trx_rf_locked_cmd);
Harald Welte68628e82009-03-10 12:17:57 +00001568
Harald Welte5258fc42009-03-28 19:07:53 +00001569 install_element(TRX_NODE, &cfg_ts_cmd);
Harald Welte68628e82009-03-10 12:17:57 +00001570 install_node(&ts_node, dummy_config_write);
Harald Welte68628e82009-03-10 12:17:57 +00001571 install_default(TS_NODE);
Harald Weltea6fd58e2009-08-07 00:25:23 +02001572 install_element(TS_NODE, &cfg_ts_pchan_cmd);
1573 install_element(TS_NODE, &cfg_ts_e1_subslot_cmd);
Harald Welte68628e82009-03-10 12:17:57 +00001574
Holger Hans Peter Freythercfa90d42009-08-10 10:17:50 +02001575 bsc_vty_init_extra(net);
Harald Welte40f82892009-05-23 17:31:39 +00001576
Harald Welte68628e82009-03-10 12:17:57 +00001577 return 0;
1578}