blob: 7213edfa87dfdd1cbf00f55889fe2403d2c99cf9 [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>
26#include <vty/vty.h>
27
28#include <arpa/inet.h>
29
Harald Welte1bc77352009-03-10 19:47:51 +000030#include <openbsc/linuxlist.h>
Harald Welte68628e82009-03-10 12:17:57 +000031#include <openbsc/gsm_data.h>
32#include <openbsc/gsm_subscriber.h>
33#include <openbsc/e1_input.h>
Harald Welte1bc77352009-03-10 19:47:51 +000034#include <openbsc/abis_nm.h>
Harald Welte40f82892009-05-23 17:31:39 +000035#include <openbsc/db.h>
Harald Welte5013b2a2009-08-07 13:29:14 +020036#include <openbsc/talloc.h>
Harald Welte68628e82009-03-10 12:17:57 +000037
38static struct gsm_network *gsmnet;
39
Harald Welte5013b2a2009-08-07 13:29:14 +020040struct cmd_node net_node = {
41 GSMNET_NODE,
42 "%s(network)#",
43 1,
44};
45
Harald Welte68628e82009-03-10 12:17:57 +000046struct cmd_node bts_node = {
47 BTS_NODE,
48 "%s(bts)#",
49 1,
50};
51
52struct cmd_node trx_node = {
53 TRX_NODE,
54 "%s(trx)#",
55 1,
56};
57
58struct cmd_node ts_node = {
59 TS_NODE,
60 "%s(ts)#",
61 1,
62};
63
Harald Welte40f82892009-05-23 17:31:39 +000064struct cmd_node subscr_node = {
65 SUBSCR_NODE,
66 "%s(subscriber)#",
67 1,
68};
69
Harald Welte68628e82009-03-10 12:17:57 +000070static int dummy_config_write(struct vty *v)
71{
72 return CMD_SUCCESS;
73}
74
75static void net_dump_nmstate(struct vty *vty, struct gsm_nm_state *nms)
76{
Harald Welte1bc77352009-03-10 19:47:51 +000077 vty_out(vty,"Oper '%s', Admin %u, Avail '%s'%s",
78 nm_opstate_name(nms->operational), nms->administrative,
79 nm_avail_name(nms->availability), VTY_NEWLINE);
Harald Welte68628e82009-03-10 12:17:57 +000080}
81
82static void net_dump_vty(struct vty *vty, struct gsm_network *net)
83{
Harald Welteef235b52009-03-10 12:34:02 +000084 vty_out(vty, "BSC is on Country Code %u, Network Code %u "
85 "and has %u BTS%s", net->country_code, net->network_code,
86 net->num_bts, VTY_NEWLINE);
Harald Welte1bc77352009-03-10 19:47:51 +000087 vty_out(vty, " Long network name: '%s'%s",
Harald Welte68628e82009-03-10 12:17:57 +000088 net->name_long, VTY_NEWLINE);
Harald Welte1bc77352009-03-10 19:47:51 +000089 vty_out(vty, " Short network name: '%s'%s",
Harald Welte68628e82009-03-10 12:17:57 +000090 net->name_short, VTY_NEWLINE);
91}
92
93DEFUN(show_net, show_net_cmd, "show network",
94 SHOW_STR "Display information about a GSM NETWORK\n")
95{
96 struct gsm_network *net = gsmnet;
97 net_dump_vty(vty, net);
98
99 return CMD_SUCCESS;
100}
101
102static void e1isl_dump_vty(struct vty *vty, struct e1inp_sign_link *e1l)
103{
Harald Welteedb37782009-05-01 14:59:07 +0000104 struct e1inp_line *line;
105
106 if (!e1l) {
107 vty_out(vty, " None%s", VTY_NEWLINE);
108 return;
109 }
110
111 line = e1l->ts->line;
112
113 vty_out(vty, " E1 Line %u, Type %s: Timeslot %u, Mode %s%s",
114 line->num, line->driver->name, e1l->ts->num,
Harald Welte1bc77352009-03-10 19:47:51 +0000115 e1inp_signtype_name(e1l->type), VTY_NEWLINE);
Harald Welteedb37782009-05-01 14:59:07 +0000116 vty_out(vty, " E1 TEI %u, SAPI %u%s",
Harald Welte68628e82009-03-10 12:17:57 +0000117 e1l->tei, e1l->sapi, VTY_NEWLINE);
118}
119
120static void bts_dump_vty(struct vty *vty, struct gsm_bts *bts)
121{
Harald Weltefcd24452009-06-20 18:15:19 +0200122 vty_out(vty, "BTS %u is of %s type in band %s, has LAC %u, "
123 "BSIC %u, TSC %u and %u TRX%s",
124 bts->nr, btstype2str(bts->type), gsm_band_name(bts->band),
125 bts->location_area_code, bts->bsic, bts->tsc,
126 bts->num_trx, VTY_NEWLINE);
Harald Welte4cc34222009-05-01 15:12:31 +0000127 if (is_ipaccess_bts(bts))
128 vty_out(vty, " Unit ID: %u/%u/0%s",
129 bts->ip_access.site_id, bts->ip_access.bts_id,
130 VTY_NEWLINE);
Harald Welte68628e82009-03-10 12:17:57 +0000131 vty_out(vty, " NM State: ");
132 net_dump_nmstate(vty, &bts->nm_state);
133 vty_out(vty, " Site Mgr NM State: ");
134 net_dump_nmstate(vty, &bts->site_mgr.nm_state);
135 vty_out(vty, " Paging: FIXME pending requests, %u free slots%s",
136 bts->paging.available_slots, VTY_NEWLINE);
137 vty_out(vty, " E1 Signalling Link:%s", VTY_NEWLINE);
138 e1isl_dump_vty(vty, bts->oml_link);
139 /* FIXME: oml_link, chan_desc */
140}
141
142DEFUN(show_bts, show_bts_cmd, "show bts [number]",
143 SHOW_STR "Display information about a BTS\n"
144 "BTS number")
145{
146 struct gsm_network *net = gsmnet;
147 int bts_nr;
148
149 if (argc != 0) {
150 /* use the BTS number that the user has specified */
151 bts_nr = atoi(argv[0]);
152 if (bts_nr > net->num_bts) {
Harald Welte1bc77352009-03-10 19:47:51 +0000153 vty_out(vty, "%% can't find BTS '%s'%s", argv[0],
Harald Welte68628e82009-03-10 12:17:57 +0000154 VTY_NEWLINE);
155 return CMD_WARNING;
156 }
Harald Weltee441d9c2009-06-21 16:17:15 +0200157 bts_dump_vty(vty, gsm_bts_num(net, bts_nr));
Harald Welte68628e82009-03-10 12:17:57 +0000158 return CMD_SUCCESS;
159 }
160 /* print all BTS's */
161 for (bts_nr = 0; bts_nr < net->num_bts; bts_nr++)
Harald Weltee441d9c2009-06-21 16:17:15 +0200162 bts_dump_vty(vty, gsm_bts_num(net, bts_nr));
Harald Welte68628e82009-03-10 12:17:57 +0000163
164 return CMD_SUCCESS;
165}
166
Harald Welte67ce0732009-08-06 19:06:46 +0200167static void config_write_ts_single(struct vty *vty, struct gsm_bts_trx_ts *ts)
168{
Harald Welte5013b2a2009-08-07 13:29:14 +0200169 vty_out(vty, " ts %u%s", ts->nr, VTY_NEWLINE);
170 vty_out(vty, " phys_chan_config %s%s", gsm_pchan_name(ts->pchan),
Harald Welte67ce0732009-08-06 19:06:46 +0200171 VTY_NEWLINE);
Harald Welte5013b2a2009-08-07 13:29:14 +0200172 vty_out(vty, " e1_subslot %u %u %u%s", ts->e1_link.e1_nr,
Harald Welte67ce0732009-08-06 19:06:46 +0200173 ts->e1_link.e1_ts, ts->e1_link.e1_ts_ss, VTY_NEWLINE);
174}
175
176static void config_write_trx_single(struct vty *vty, struct gsm_bts_trx *trx)
177{
178 int i;
179
Harald Welte5013b2a2009-08-07 13:29:14 +0200180 vty_out(vty, " trx %u%s", trx->nr, VTY_NEWLINE);
181 vty_out(vty, " arfcn %u%s", trx->arfcn, VTY_NEWLINE);
182 vty_out(vty, " max_power_red %u%s", trx->max_power_red, VTY_NEWLINE);
Harald Welte67ce0732009-08-06 19:06:46 +0200183
184 for (i = 0; i < TRX_NR_TS; i++)
185 config_write_ts_single(vty, &trx->ts[i]);
186}
187
188static void config_write_bts_single(struct vty *vty, struct gsm_bts *bts)
189{
190 struct gsm_bts_trx *trx;
191
Harald Welte5013b2a2009-08-07 13:29:14 +0200192 vty_out(vty, " bts %u%s", bts->nr, VTY_NEWLINE);
193 vty_out(vty, " type %s%s", btstype2str(bts->type), VTY_NEWLINE);
194 vty_out(vty, " band %s%s", gsm_band_name(bts->band), VTY_NEWLINE);
195 vty_out(vty, " location_area_code %u%s", bts->location_area_code,
Harald Welte67ce0732009-08-06 19:06:46 +0200196 VTY_NEWLINE);
Harald Welte5013b2a2009-08-07 13:29:14 +0200197 vty_out(vty, " training_sequence_code %u%s", bts->tsc, VTY_NEWLINE);
198 vty_out(vty, " base_station_id_code %u%s", bts->bsic, VTY_NEWLINE);
Harald Weltea6fd58e2009-08-07 00:25:23 +0200199 if (is_ipaccess_bts(bts))
Harald Welte5013b2a2009-08-07 13:29:14 +0200200 vty_out(vty, " ip.access unit_id %u %u%s",
Harald Weltea6fd58e2009-08-07 00:25:23 +0200201 bts->ip_access.site_id, bts->ip_access.bts_id, VTY_NEWLINE);
Harald Welte67ce0732009-08-06 19:06:46 +0200202
203 llist_for_each_entry(trx, &bts->trx_list, list)
204 config_write_trx_single(vty, trx);
205}
206
207static int config_write_bts(struct vty *v)
208{
209 struct gsm_bts *bts;
210
211 llist_for_each_entry(bts, &gsmnet->bts_list, list)
212 config_write_bts_single(v, bts);
213
214 return CMD_SUCCESS;
215}
216
Harald Welte5013b2a2009-08-07 13:29:14 +0200217static int config_write_net(struct vty *vty)
218{
219 vty_out(vty, "network%s", VTY_NEWLINE);
220 vty_out(vty, " country code %u%s", gsmnet->country_code, VTY_NEWLINE);
221 vty_out(vty, " mobile network code %u%s", gsmnet->network_code, VTY_NEWLINE);
222 vty_out(vty, " short name '%s'%s", gsmnet->name_short, VTY_NEWLINE);
223 vty_out(vty, " long name '%s'%s", gsmnet->name_long, VTY_NEWLINE);
224
225 return CMD_SUCCESS;
226}
Harald Welte67ce0732009-08-06 19:06:46 +0200227
Harald Welte68628e82009-03-10 12:17:57 +0000228static void trx_dump_vty(struct vty *vty, struct gsm_bts_trx *trx)
229{
230 vty_out(vty, "TRX %u of BTS %u is on ARFCN %u%s",
231 trx->nr, trx->bts->nr, trx->arfcn, VTY_NEWLINE);
Harald Weltefcd24452009-06-20 18:15:19 +0200232 vty_out(vty, " RF Nominal Power: %d dBm, reduced by %u dB, "
233 "resulting BS power: %d dBm\n",
234 trx->nominal_power, trx->max_power_red,
235 trx->nominal_power - trx->max_power_red);
Harald Welte68628e82009-03-10 12:17:57 +0000236 vty_out(vty, " NM State: ");
237 net_dump_nmstate(vty, &trx->nm_state);
238 vty_out(vty, " Baseband Transceiver NM State: ");
239 net_dump_nmstate(vty, &trx->bb_transc.nm_state);
240 vty_out(vty, " E1 Signalling Link:%s", VTY_NEWLINE);
241 e1isl_dump_vty(vty, trx->rsl_link);
242}
243
244DEFUN(show_trx,
245 show_trx_cmd,
246 "show trx [bts_nr] [trx_nr]",
247 SHOW_STR "Display information about a TRX\n")
248{
249 struct gsm_network *net = gsmnet;
250 struct gsm_bts *bts = NULL;
251 struct gsm_bts_trx *trx;
252 int bts_nr, trx_nr;
253
254 if (argc >= 1) {
255 /* use the BTS number that the user has specified */
256 bts_nr = atoi(argv[0]);
257 if (bts_nr >= net->num_bts) {
Harald Welte1bc77352009-03-10 19:47:51 +0000258 vty_out(vty, "%% can't find BTS '%s'%s", argv[0],
Harald Welte68628e82009-03-10 12:17:57 +0000259 VTY_NEWLINE);
260 return CMD_WARNING;
261 }
Harald Weltee441d9c2009-06-21 16:17:15 +0200262 bts = gsm_bts_num(net, bts_nr);
Harald Welte68628e82009-03-10 12:17:57 +0000263 }
264 if (argc >= 2) {
265 trx_nr = atoi(argv[1]);
266 if (trx_nr >= bts->num_trx) {
Harald Welte1bc77352009-03-10 19:47:51 +0000267 vty_out(vty, "%% can't find TRX '%s'%s", argv[1],
Harald Welte68628e82009-03-10 12:17:57 +0000268 VTY_NEWLINE);
269 return CMD_WARNING;
270 }
Harald Weltee441d9c2009-06-21 16:17:15 +0200271 trx = gsm_bts_trx_num(bts, trx_nr);
Harald Welte68628e82009-03-10 12:17:57 +0000272 trx_dump_vty(vty, trx);
273 return CMD_SUCCESS;
274 }
275 if (bts) {
276 /* print all TRX in this BTS */
277 for (trx_nr = 0; trx_nr < bts->num_trx; trx_nr++) {
Harald Weltee441d9c2009-06-21 16:17:15 +0200278 trx = gsm_bts_trx_num(bts, trx_nr);
Harald Welte68628e82009-03-10 12:17:57 +0000279 trx_dump_vty(vty, trx);
280 }
281 return CMD_SUCCESS;
282 }
283
284 for (bts_nr = 0; bts_nr < net->num_bts; bts_nr++) {
Harald Weltee441d9c2009-06-21 16:17:15 +0200285 bts = gsm_bts_num(net, bts_nr);
Harald Welte68628e82009-03-10 12:17:57 +0000286 for (trx_nr = 0; trx_nr < bts->num_trx; trx_nr++) {
Harald Weltee441d9c2009-06-21 16:17:15 +0200287 trx = gsm_bts_trx_num(bts, trx_nr);
Harald Welte68628e82009-03-10 12:17:57 +0000288 trx_dump_vty(vty, trx);
289 }
290 }
291
292 return CMD_SUCCESS;
293}
294
Harald Welte67ce0732009-08-06 19:06:46 +0200295
Harald Welte68628e82009-03-10 12:17:57 +0000296static void ts_dump_vty(struct vty *vty, struct gsm_bts_trx_ts *ts)
297{
298 struct in_addr ia;
299
300 vty_out(vty, "Timeslot %u of TRX %u in BTS %u, phys cfg %s%s",
301 ts->nr, ts->trx->nr, ts->trx->bts->nr,
302 gsm_pchan_name(ts->pchan), VTY_NEWLINE);
303 vty_out(vty, " NM State: ");
304 net_dump_nmstate(vty, &ts->nm_state);
Harald Welte68628e82009-03-10 12:17:57 +0000305 if (is_ipaccess_bts(ts->trx->bts)) {
306 ia.s_addr = ts->abis_ip.bound_ip;
Harald Welte20855542009-07-12 09:50:35 +0200307 vty_out(vty, " Bound IP: %s Port %u RTP_TYPE2=%u CONN_ID=%u%s",
Harald Welte68628e82009-03-10 12:17:57 +0000308 inet_ntoa(ia), ts->abis_ip.bound_port,
Harald Welte20855542009-07-12 09:50:35 +0200309 ts->abis_ip.rtp_payload2, ts->abis_ip.conn_id,
Harald Welte68628e82009-03-10 12:17:57 +0000310 VTY_NEWLINE);
Harald Welteef235b52009-03-10 12:34:02 +0000311 } else {
312 vty_out(vty, " E1 Line %u, Timeslot %u, Subslot %u%s",
313 ts->e1_link.e1_nr, ts->e1_link.e1_ts,
314 ts->e1_link.e1_ts_ss, VTY_NEWLINE);
Harald Welte68628e82009-03-10 12:17:57 +0000315 }
316}
317
318DEFUN(show_ts,
319 show_ts_cmd,
Harald Welte1bc77352009-03-10 19:47:51 +0000320 "show timeslot [bts_nr] [trx_nr] [ts_nr]",
Harald Welte68628e82009-03-10 12:17:57 +0000321 SHOW_STR "Display information about a TS\n")
322{
323 struct gsm_network *net = gsmnet;
324 struct gsm_bts *bts;
325 struct gsm_bts_trx *trx;
326 struct gsm_bts_trx_ts *ts;
327 int bts_nr, trx_nr, ts_nr;
328
329 if (argc >= 1) {
330 /* use the BTS number that the user has specified */
331 bts_nr = atoi(argv[0]);
332 if (bts_nr >= net->num_bts) {
Harald Welte1bc77352009-03-10 19:47:51 +0000333 vty_out(vty, "%% can't find BTS '%s'%s", argv[0],
Harald Welte68628e82009-03-10 12:17:57 +0000334 VTY_NEWLINE);
335 return CMD_WARNING;
336 }
Harald Weltee441d9c2009-06-21 16:17:15 +0200337 bts = gsm_bts_num(net, bts_nr);
Harald Welte68628e82009-03-10 12:17:57 +0000338 }
339 if (argc >= 2) {
340 trx_nr = atoi(argv[1]);
341 if (trx_nr >= bts->num_trx) {
Harald Welte1bc77352009-03-10 19:47:51 +0000342 vty_out(vty, "%% can't find TRX '%s'%s", argv[1],
Harald Welte68628e82009-03-10 12:17:57 +0000343 VTY_NEWLINE);
344 return CMD_WARNING;
345 }
Harald Weltee441d9c2009-06-21 16:17:15 +0200346 trx = gsm_bts_trx_num(bts, trx_nr);
Harald Welte68628e82009-03-10 12:17:57 +0000347 }
348 if (argc >= 3) {
349 ts_nr = atoi(argv[2]);
350 if (ts_nr >= TRX_NR_TS) {
Harald Welte1bc77352009-03-10 19:47:51 +0000351 vty_out(vty, "%% can't find TS '%s'%s", argv[2],
Harald Welte68628e82009-03-10 12:17:57 +0000352 VTY_NEWLINE);
353 return CMD_WARNING;
354 }
355 ts = &trx->ts[ts_nr];
356 ts_dump_vty(vty, ts);
357 return CMD_SUCCESS;
358 }
359 for (bts_nr = 0; bts_nr < net->num_bts; bts_nr++) {
Harald Weltee441d9c2009-06-21 16:17:15 +0200360 bts = gsm_bts_num(net, bts_nr);
Harald Welte68628e82009-03-10 12:17:57 +0000361 for (trx_nr = 0; trx_nr < bts->num_trx; trx_nr++) {
Harald Weltee441d9c2009-06-21 16:17:15 +0200362 trx = gsm_bts_trx_num(bts, trx_nr);
Harald Welte68628e82009-03-10 12:17:57 +0000363 for (ts_nr = 0; ts_nr < TRX_NR_TS; ts_nr++) {
364 ts = &trx->ts[ts_nr];
365 ts_dump_vty(vty, ts);
366 }
367 }
368 }
369
370 return CMD_SUCCESS;
371}
372
373static void subscr_dump_vty(struct vty *vty, struct gsm_subscriber *subscr)
374{
Harald Weltefcd24452009-06-20 18:15:19 +0200375 vty_out(vty, " ID: %llu, Authorized: %d%s", subscr->id,
Harald Welte40f82892009-05-23 17:31:39 +0000376 subscr->authorized, VTY_NEWLINE);
Harald Welte68628e82009-03-10 12:17:57 +0000377 if (subscr->name)
Harald Welte1bc77352009-03-10 19:47:51 +0000378 vty_out(vty, " Name: '%s'%s", subscr->name, VTY_NEWLINE);
Harald Welte68628e82009-03-10 12:17:57 +0000379 if (subscr->extension)
380 vty_out(vty, " Extension: %s%s", subscr->extension,
381 VTY_NEWLINE);
382 if (subscr->imsi)
383 vty_out(vty, " IMSI: %s%s", subscr->imsi, VTY_NEWLINE);
384 if (subscr->tmsi)
385 vty_out(vty, " TMSI: %s%s", subscr->tmsi, VTY_NEWLINE);
386}
387
388static void lchan_dump_vty(struct vty *vty, struct gsm_lchan *lchan)
389{
390 vty_out(vty, "Lchan %u in Timeslot %u of TRX %u in BTS %u, Type %s%s",
391 lchan->nr, lchan->ts->nr, lchan->ts->trx->nr,
392 lchan->ts->trx->bts->nr, gsm_lchan_name(lchan->type),
393 VTY_NEWLINE);
394 vty_out(vty, " Use Count: %u%s", lchan->use_count, VTY_NEWLINE);
395 vty_out(vty, " BS Power %u, MS Power %u%s", lchan->bs_power,
396 lchan->ms_power, VTY_NEWLINE);
397 if (lchan->subscr) {
398 vty_out(vty, " Subscriber:%s", VTY_NEWLINE);
399 subscr_dump_vty(vty, lchan->subscr);
400 } else
401 vty_out(vty, " No Subscriber%s", VTY_NEWLINE);
402}
403
Harald Welte4bfdfe72009-06-10 23:11:52 +0800404#if 0
405TODO: callref and remote callref of call must be resolved to get gsm_trans object
Harald Welte68628e82009-03-10 12:17:57 +0000406static void call_dump_vty(struct vty *vty, struct gsm_call *call)
407{
408 vty_out(vty, "Call Type %u, State %u, Transaction ID %u%s",
409 call->type, call->state, call->transaction_id, VTY_NEWLINE);
410
411 if (call->local_lchan) {
412 vty_out(vty, "Call Local Channel:%s", VTY_NEWLINE);
413 lchan_dump_vty(vty, call->local_lchan);
414 } else
415 vty_out(vty, "Call has no Local Channel%s", VTY_NEWLINE);
416
417 if (call->remote_lchan) {
418 vty_out(vty, "Call Remote Channel:%s", VTY_NEWLINE);
419 lchan_dump_vty(vty, call->remote_lchan);
420 } else
421 vty_out(vty, "Call has no Remote Channel%s", VTY_NEWLINE);
422
423 if (call->called_subscr) {
424 vty_out(vty, "Called Subscriber:%s", VTY_NEWLINE);
425 subscr_dump_vty(vty, call->called_subscr);
426 } else
427 vty_out(vty, "Call has no Called Subscriber%s", VTY_NEWLINE);
428}
Harald Welte4bfdfe72009-06-10 23:11:52 +0800429#endif
Harald Welte68628e82009-03-10 12:17:57 +0000430
431DEFUN(show_lchan,
432 show_lchan_cmd,
433 "show lchan [bts_nr] [trx_nr] [ts_nr] [lchan_nr]",
434 SHOW_STR "Display information about a logical channel\n")
435{
436 struct gsm_network *net = gsmnet;
437 struct gsm_bts *bts;
438 struct gsm_bts_trx *trx;
439 struct gsm_bts_trx_ts *ts;
440 struct gsm_lchan *lchan;
441 int bts_nr, trx_nr, ts_nr, lchan_nr;
442
443 if (argc >= 1) {
444 /* use the BTS number that the user has specified */
445 bts_nr = atoi(argv[0]);
446 if (bts_nr >= net->num_bts) {
447 vty_out(vty, "%% can't find BTS %s%s", argv[0],
448 VTY_NEWLINE);
449 return CMD_WARNING;
450 }
Harald Weltee441d9c2009-06-21 16:17:15 +0200451 bts = gsm_bts_num(net, bts_nr);
Harald Welte68628e82009-03-10 12:17:57 +0000452 }
453 if (argc >= 2) {
454 trx_nr = atoi(argv[1]);
455 if (trx_nr >= bts->num_trx) {
456 vty_out(vty, "%% can't find TRX %s%s", argv[1],
457 VTY_NEWLINE);
458 return CMD_WARNING;
459 }
Harald Weltee441d9c2009-06-21 16:17:15 +0200460 trx = gsm_bts_trx_num(bts, trx_nr);
Harald Welte68628e82009-03-10 12:17:57 +0000461 }
462 if (argc >= 3) {
463 ts_nr = atoi(argv[2]);
464 if (ts_nr >= TRX_NR_TS) {
465 vty_out(vty, "%% can't find TS %s%s", argv[2],
466 VTY_NEWLINE);
467 return CMD_WARNING;
468 }
469 ts = &trx->ts[ts_nr];
470 }
471 if (argc >= 4) {
472 lchan_nr = atoi(argv[3]);
473 if (lchan_nr >= TS_MAX_LCHAN) {
474 vty_out(vty, "%% can't find LCHAN %s%s", argv[3],
475 VTY_NEWLINE);
476 return CMD_WARNING;
477 }
478 lchan = &ts->lchan[lchan_nr];
479 lchan_dump_vty(vty, lchan);
480 return CMD_SUCCESS;
481 }
482 for (bts_nr = 0; bts_nr < net->num_bts; bts_nr++) {
Harald Weltee441d9c2009-06-21 16:17:15 +0200483 bts = gsm_bts_num(net, bts_nr);
Harald Welte68628e82009-03-10 12:17:57 +0000484 for (trx_nr = 0; trx_nr < bts->num_trx; trx_nr++) {
Harald Weltee441d9c2009-06-21 16:17:15 +0200485 trx = gsm_bts_trx_num(bts, trx_nr);
Harald Welte68628e82009-03-10 12:17:57 +0000486 for (ts_nr = 0; ts_nr < TRX_NR_TS; ts_nr++) {
487 ts = &trx->ts[ts_nr];
488 for (lchan_nr = 0; lchan_nr < TS_MAX_LCHAN;
489 lchan_nr++) {
490 lchan = &ts->lchan[lchan_nr];
Harald Welteef235b52009-03-10 12:34:02 +0000491 if (lchan->type == GSM_LCHAN_NONE)
492 continue;
Harald Welte68628e82009-03-10 12:17:57 +0000493 lchan_dump_vty(vty, lchan);
494 }
495 }
496 }
497 }
498
499 return CMD_SUCCESS;
500}
501
Harald Welte1bc77352009-03-10 19:47:51 +0000502static void e1drv_dump_vty(struct vty *vty, struct e1inp_driver *drv)
503{
504 vty_out(vty, "E1 Input Driver %s%s", drv->name, VTY_NEWLINE);
505}
506
507DEFUN(show_e1drv,
508 show_e1drv_cmd,
509 "show e1_driver",
510 SHOW_STR "Display information about available E1 drivers\n")
511{
512 struct e1inp_driver *drv;
513
514 llist_for_each_entry(drv, &e1inp_driver_list, list)
515 e1drv_dump_vty(vty, drv);
516
517 return CMD_SUCCESS;
518}
519
Harald Welte68628e82009-03-10 12:17:57 +0000520static void e1line_dump_vty(struct vty *vty, struct e1inp_line *line)
521{
522 vty_out(vty, "E1 Line Number %u, Name %s, Driver %s%s",
523 line->num, line->name ? line->name : "",
524 line->driver->name, VTY_NEWLINE);
525}
526
527DEFUN(show_e1line,
528 show_e1line_cmd,
529 "show e1_line [line_nr]",
530 SHOW_STR "Display information about a E1 line\n")
531{
Harald Welte1bc77352009-03-10 19:47:51 +0000532 struct e1inp_line *line;
533
534 if (argc >= 1) {
535 int num = atoi(argv[0]);
536 llist_for_each_entry(line, &e1inp_line_list, list) {
537 if (line->num == num) {
538 e1line_dump_vty(vty, line);
539 return CMD_SUCCESS;
540 }
541 }
542 return CMD_WARNING;
543 }
544
545 llist_for_each_entry(line, &e1inp_line_list, list)
546 e1line_dump_vty(vty, line);
547
548 return CMD_SUCCESS;
Harald Welte68628e82009-03-10 12:17:57 +0000549}
550
551static void e1ts_dump_vty(struct vty *vty, struct e1inp_ts *ts)
552{
Harald Welte1bc77352009-03-10 19:47:51 +0000553 vty_out(vty, "E1 Timeslot %2u of Line %u is Type %s%s",
554 ts->num, ts->line->num, e1inp_tstype_name(ts->type),
555 VTY_NEWLINE);
Harald Welte68628e82009-03-10 12:17:57 +0000556}
557
558DEFUN(show_e1ts,
559 show_e1ts_cmd,
560 "show e1_timeslot [line_nr] [ts_nr]",
561 SHOW_STR "Display information about a E1 timeslot\n")
562{
Harald Welte1bc77352009-03-10 19:47:51 +0000563 struct e1inp_line *line;
564 struct e1inp_ts *ts;
565 int ts_nr;
Harald Welte68628e82009-03-10 12:17:57 +0000566
Harald Welte1bc77352009-03-10 19:47:51 +0000567 if (argc == 0) {
568 llist_for_each_entry(line, &e1inp_line_list, list) {
569 for (ts_nr = 0; ts_nr < NUM_E1_TS; ts_nr++) {
570 ts = &line->ts[ts_nr];
571 e1ts_dump_vty(vty, ts);
572 }
573 }
574 return CMD_SUCCESS;
575 }
576 if (argc >= 1) {
577 int num = atoi(argv[0]);
578 llist_for_each_entry(line, &e1inp_line_list, list) {
579 if (line->num == num)
580 break;
581 }
582 if (!line || line->num != num) {
583 vty_out(vty, "E1 line %s is invalid%s",
584 argv[0], VTY_NEWLINE);
585 return CMD_WARNING;
586 }
587 }
588 if (argc >= 2) {
589 ts_nr = atoi(argv[1]);
590 if (ts_nr > NUM_E1_TS) {
591 vty_out(vty, "E1 timeslot %s is invalid%s",
592 argv[1], VTY_NEWLINE);
593 return CMD_WARNING;
594 }
595 ts = &line->ts[ts_nr];
596 e1ts_dump_vty(vty, ts);
597 return CMD_SUCCESS;
598 } else {
599 for (ts_nr = 0; ts_nr < NUM_E1_TS; ts_nr++) {
600 ts = &line->ts[ts_nr];
601 e1ts_dump_vty(vty, ts);
602 }
603 return CMD_SUCCESS;
604 }
605 return CMD_SUCCESS;
Harald Welte68628e82009-03-10 12:17:57 +0000606}
607
Harald Weltebe4b7302009-05-23 16:59:33 +0000608static void paging_dump_vty(struct vty *vty, struct gsm_paging_request *pag)
Harald Weltef5025b62009-03-28 16:55:11 +0000609{
610 vty_out(vty, "Paging on BTS %u%s", pag->bts->nr, VTY_NEWLINE);
611 subscr_dump_vty(vty, pag->subscr);
612}
613
Harald Weltebe4b7302009-05-23 16:59:33 +0000614static void bts_paging_dump_vty(struct vty *vty, struct gsm_bts *bts)
Harald Weltef5025b62009-03-28 16:55:11 +0000615{
616 struct gsm_paging_request *pag;
617
618 llist_for_each_entry(pag, &bts->paging.pending_requests, entry)
619 paging_dump_vty(vty, pag);
620}
621
622DEFUN(show_paging,
623 show_paging_cmd,
624 "show paging [bts_nr]",
Harald Weltebe4b7302009-05-23 16:59:33 +0000625 SHOW_STR "Display information about paging reuqests of a BTS\n")
Harald Weltef5025b62009-03-28 16:55:11 +0000626{
627 struct gsm_network *net = gsmnet;
628 struct gsm_bts *bts;
629 int bts_nr;
630
631 if (argc >= 1) {
632 /* use the BTS number that the user has specified */
633 bts_nr = atoi(argv[0]);
634 if (bts_nr >= net->num_bts) {
635 vty_out(vty, "%% can't find BTS %s%s", argv[0],
636 VTY_NEWLINE);
637 return CMD_WARNING;
638 }
Harald Weltee441d9c2009-06-21 16:17:15 +0200639 bts = gsm_bts_num(net, bts_nr);
Harald Weltef5025b62009-03-28 16:55:11 +0000640 bts_paging_dump_vty(vty, bts);
641
642 return CMD_SUCCESS;
643 }
644 for (bts_nr = 0; bts_nr < net->num_bts; bts_nr++) {
Harald Weltee441d9c2009-06-21 16:17:15 +0200645 bts = gsm_bts_num(net, bts_nr);
Harald Weltef5025b62009-03-28 16:55:11 +0000646 bts_paging_dump_vty(vty, bts);
647 }
648
649 return CMD_SUCCESS;
650}
651
Harald Welte40f82892009-05-23 17:31:39 +0000652/* per-subscriber configuration */
653DEFUN(cfg_subscr,
654 cfg_subscr_cmd,
655 "subscriber IMSI",
656 "Select a Subscriber to configure\n")
657{
658 const char *imsi = argv[0];
659 struct gsm_subscriber *subscr;
660
Harald Welte761e9442009-07-23 19:21:02 +0200661 subscr = subscr_get_by_imsi(gsmnet, imsi);
Harald Welte40f82892009-05-23 17:31:39 +0000662 if (!subscr) {
663 vty_out(vty, "%% No subscriber for IMSI %s%s",
664 imsi, VTY_NEWLINE);
665 return CMD_WARNING;
666 }
667
668 vty->index = subscr;
669 vty->node = SUBSCR_NODE;
670
671 return CMD_SUCCESS;
672}
673
Harald Welte5013b2a2009-08-07 13:29:14 +0200674DEFUN(cfg_net,
675 cfg_net_cmd,
676 "network",
677 "Configure the GSM network")
678{
679 vty->index = gsmnet;
680 vty->node = GSMNET_NODE;
681
682 return CMD_SUCCESS;
683}
684
685
686DEFUN(cfg_net_ncc,
687 cfg_net_ncc_cmd,
688 "network country code <1-999>",
689 "Set the GSM network country code")
690{
691 gsmnet->country_code = atoi(argv[0]);
692
693 return CMD_SUCCESS;
694}
695
696DEFUN(cfg_net_mnc,
697 cfg_net_mnc_cmd,
698 "mobile network code <1-999>",
699 "Set the GSM mobile network code")
700{
701 gsmnet->network_code = atoi(argv[0]);
702
703 return CMD_SUCCESS;
704}
705
706DEFUN(cfg_net_name_short,
707 cfg_net_name_short_cmd,
708 "short name NAME",
709 "Set the short GSM network name")
710{
711 if (gsmnet->name_short)
712 talloc_free(gsmnet->name_short);
713
714 gsmnet->name_short = talloc_strdup(gsmnet, argv[0]);
715
716 return CMD_SUCCESS;
717}
718
719DEFUN(cfg_net_name_long,
720 cfg_net_name_long_cmd,
721 "long name NAME",
722 "Set the long GSM network name")
723{
724 if (gsmnet->name_long)
725 talloc_free(gsmnet->name_long);
726
727 gsmnet->name_long = talloc_strdup(gsmnet, argv[0]);
728
729 return CMD_SUCCESS;
730}
Harald Welte40f82892009-05-23 17:31:39 +0000731
Harald Welte5258fc42009-03-28 19:07:53 +0000732/* per-BTS configuration */
733DEFUN(cfg_bts,
734 cfg_bts_cmd,
735 "bts BTS_NR",
736 "Select a BTS to configure\n")
737{
738 int bts_nr = atoi(argv[0]);
739 struct gsm_bts *bts;
740
Harald Weltee441d9c2009-06-21 16:17:15 +0200741 if (bts_nr > gsmnet->num_bts) {
742 vty_out(vty, "%% The next unused BTS number is %u%s",
743 gsmnet->num_bts, VTY_NEWLINE);
Harald Welte5258fc42009-03-28 19:07:53 +0000744 return CMD_WARNING;
Harald Weltee441d9c2009-06-21 16:17:15 +0200745 } else if (bts_nr == gsmnet->num_bts) {
746 /* allocate a new one */
747 bts = gsm_bts_alloc(gsmnet, GSM_BTS_TYPE_UNKNOWN,
748 HARDCODED_TSC, HARDCODED_BSIC);
749 } else
750 bts = gsm_bts_num(gsmnet, bts_nr);
751
752 if (!bts)
753 return CMD_WARNING;
Harald Welte5258fc42009-03-28 19:07:53 +0000754
755 vty->index = bts;
756 vty->node = BTS_NODE;
757
758 return CMD_SUCCESS;
759}
760
761DEFUN(cfg_bts_type,
762 cfg_bts_type_cmd,
763 "type TYPE",
764 "Set the BTS type\n")
765{
766 struct gsm_bts *bts = vty->index;
767
Harald Weltea6fd58e2009-08-07 00:25:23 +0200768 bts->type = parse_btstype(argv[0]);
769
Harald Welte5258fc42009-03-28 19:07:53 +0000770 return CMD_SUCCESS;
771}
772
Harald Weltefcd24452009-06-20 18:15:19 +0200773DEFUN(cfg_bts_band,
774 cfg_bts_band_cmd,
775 "band BAND",
776 "Set the frequency band of this BTS\n")
777{
778 struct gsm_bts *bts = vty->index;
779 int band = gsm_band_parse(atoi(argv[0]));
780
781 if (band < 0) {
782 vty_out(vty, "%% BAND %d is not a valid GSM band%s",
783 band, VTY_NEWLINE);
784 return CMD_WARNING;
785 }
786
787 bts->band = band;
788
789 return CMD_SUCCESS;
790}
791
Harald Welte5258fc42009-03-28 19:07:53 +0000792DEFUN(cfg_bts_lac,
793 cfg_bts_lac_cmd,
794 "location_area_code <0-255>",
795 "Set the Location Area Code (LAC) of this BTS\n")
796{
797 struct gsm_bts *bts = vty->index;
798 int lac = atoi(argv[0]);
799
800 if (lac < 0 || lac > 0xff) {
801 vty_out(vty, "%% LAC %d is not in the valid range (0-255)%s",
802 lac, VTY_NEWLINE);
803 return CMD_WARNING;
804 }
805 bts->location_area_code = lac;
806
807 return CMD_SUCCESS;
808}
809
810DEFUN(cfg_bts_tsc,
811 cfg_bts_tsc_cmd,
812 "training_sequence_code <0-255>",
813 "Set the Training Sequence Code (TSC) of this BTS\n")
814{
815 struct gsm_bts *bts = vty->index;
816 int tsc = atoi(argv[0]);
817
818 if (tsc < 0 || tsc > 0xff) {
819 vty_out(vty, "%% TSC %d is not in the valid range (0-255)%s",
820 tsc, VTY_NEWLINE);
821 return CMD_WARNING;
822 }
823 bts->tsc = tsc;
824
825 return CMD_SUCCESS;
826}
827
Harald Welte78f2f502009-05-23 16:56:52 +0000828DEFUN(cfg_bts_bsic,
829 cfg_bts_bsic_cmd,
830 "base_station_id_code <0-63>",
831 "Set the Base Station Identity Code (BSIC) of this BTS\n")
832{
833 struct gsm_bts *bts = vty->index;
834 int bsic = atoi(argv[0]);
835
836 if (bsic < 0 || bsic > 0x3f) {
837 vty_out(vty, "%% TSC %d is not in the valid range (0-255)%s",
838 bsic, VTY_NEWLINE);
839 return CMD_WARNING;
840 }
841 bts->bsic = bsic;
842
843 return CMD_SUCCESS;
844}
845
846
Harald Welte4cc34222009-05-01 15:12:31 +0000847DEFUN(cfg_bts_unit_id,
848 cfg_bts_unit_id_cmd,
Harald Welte07dc73d2009-08-07 13:27:09 +0200849 "ip.access unit_id <0-65534> <0-255>",
850 "Set the ip.access BTS Unit ID of this BTS\n")
Harald Welte4cc34222009-05-01 15:12:31 +0000851{
852 struct gsm_bts *bts = vty->index;
853 int site_id = atoi(argv[0]);
854 int bts_id = atoi(argv[1]);
855
856 if (site_id < 0 || site_id > 65534) {
857 vty_out(vty, "%% Site ID %d is not in the valid range%s",
858 site_id, VTY_NEWLINE);
859 return CMD_WARNING;
860 }
861 if (site_id < 0 || site_id > 255) {
862 vty_out(vty, "%% BTS ID %d is not in the valid range%s",
863 bts_id, VTY_NEWLINE);
864 return CMD_WARNING;
865 }
Harald Welte07dc73d2009-08-07 13:27:09 +0200866
867 if (!is_ipaccess_bts(bts)) {
868 vty_out(vty, "%% BTS is not of ip.access type%s", VTY_NEWLINE);
869 return CMD_WARNING;
870 }
871
Harald Welte4cc34222009-05-01 15:12:31 +0000872 bts->ip_access.site_id = site_id;
873 bts->ip_access.bts_id = bts_id;
874
875 return CMD_SUCCESS;
876}
877
Harald Welte5258fc42009-03-28 19:07:53 +0000878/* per TRX configuration */
879DEFUN(cfg_trx,
880 cfg_trx_cmd,
881 "trx TRX_NR",
882 "Select a TRX to configure")
883{
884 int trx_nr = atoi(argv[0]);
885 struct gsm_bts *bts = vty->index;
886 struct gsm_bts_trx *trx;
887
Harald Weltee441d9c2009-06-21 16:17:15 +0200888 if (trx_nr > bts->num_trx) {
889 vty_out(vty, "%% The next unused TRX number in this BTS is %u%s",
890 bts->num_trx, VTY_NEWLINE);
Harald Welte5258fc42009-03-28 19:07:53 +0000891 return CMD_WARNING;
Harald Weltee441d9c2009-06-21 16:17:15 +0200892 } else if (trx_nr == bts->num_trx) {
893 /* we need to allocate a new one */
894 trx = gsm_bts_trx_alloc(bts);
895 } else
896 trx = gsm_bts_trx_num(bts, trx_nr);
897
898 if (!trx)
899 return CMD_WARNING;
Harald Welte5258fc42009-03-28 19:07:53 +0000900
901 vty->index = trx;
902 vty->node = TRX_NODE;
903
904 return CMD_SUCCESS;
905}
906
907DEFUN(cfg_trx_arfcn,
908 cfg_trx_arfcn_cmd,
909 "arfcn <1-1024>",
910 "Set the ARFCN for this TRX\n")
911{
912 int arfcn = atoi(argv[0]);
913 struct gsm_bts_trx *trx = vty->index;
914
915 /* FIXME: check if this ARFCN is supported by this TRX */
916
917 trx->arfcn = arfcn;
918
919 /* FIXME: patch ARFCN into SYSTEM INFORMATION */
920 /* FIXME: use OML layer to update the ARFCN */
921 /* FIXME: use RSL layer to update SYSTEM INFORMATION */
922
923 return CMD_SUCCESS;
924}
925
Harald Weltefcd24452009-06-20 18:15:19 +0200926DEFUN(cfg_trx_max_power_red,
927 cfg_trx_max_power_red_cmd,
928 "max_power_red <0-100>",
929 "Reduction of maximum BS RF Power in dB\n")
930{
931 int maxpwr_r = atoi(argv[0]);
932 struct gsm_bts_trx *trx = vty->index;
933 int upper_limit = 12; /* default 12.21 max power red. */
934
935 /* FIXME: check if our BTS type supports more than 12 */
936 if (maxpwr_r < 0 || maxpwr_r > upper_limit) {
937 vty_out(vty, "%% Power %d dB is not in the valid range%s",
938 maxpwr_r, VTY_NEWLINE);
939 return CMD_WARNING;
940 }
941 if (maxpwr_r & 1) {
942 vty_out(vty, "%% Power %d dB is not an even value%s",
943 maxpwr_r, VTY_NEWLINE);
944 return CMD_WARNING;
945 }
946
947 trx->max_power_red = maxpwr_r;
948
949 /* FIXME: make sure we update this using OML */
950
951 return CMD_SUCCESS;
952}
953
Harald Welte5258fc42009-03-28 19:07:53 +0000954/* per TS configuration */
955DEFUN(cfg_ts,
956 cfg_ts_cmd,
957 "timeslot TS_NR",
958 "Select a Timeslot to configure")
959{
960 int ts_nr = atoi(argv[0]);
961 struct gsm_bts_trx *trx = vty->index;
962 struct gsm_bts_trx_ts *ts;
963
964 if (ts_nr >= TRX_NR_TS) {
965 vty_out(vty, "%% A GSM TRX only has %u Timeslots per TRX%s",
966 TRX_NR_TS, VTY_NEWLINE);
967 return CMD_WARNING;
968 }
969
970 ts = &trx->ts[ts_nr];
971
972 vty->index = ts;
973 vty->node = TS_NODE;
974
975 return CMD_SUCCESS;
976}
977
Harald Weltea6fd58e2009-08-07 00:25:23 +0200978DEFUN(cfg_ts_pchan,
979 cfg_ts_pchan_cmd,
980 "phys_chan_config PCHAN",
981 "Physical Channel configuration (TCH/SDCCH/...)")
982{
983 struct gsm_bts_trx_ts *ts = vty->index;
984 int pchanc;
985
986 pchanc = gsm_pchan_parse(argv[0]);
987 if (pchanc < 0)
988 return CMD_WARNING;
989
990 ts->pchan = pchanc;
991
992 return CMD_SUCCESS;
993}
994
995DEFUN(cfg_ts_e1_subslot,
996 cfg_ts_e1_subslot_cmd,
997 "e1_subslot E1_IF <1-31> <0-4>",
998 "E1 sub-slot connected to this on-air timeslot")
999{
1000 struct gsm_bts_trx_ts *ts = vty->index;
1001
1002 ts->e1_link.e1_nr = atoi(argv[0]);
1003 ts->e1_link.e1_ts = atoi(argv[1]);
1004 ts->e1_link.e1_ts_ss = atoi(argv[2]);
1005
1006 return CMD_SUCCESS;
1007}
Harald Welte5258fc42009-03-28 19:07:53 +00001008
Harald Welte40f82892009-05-23 17:31:39 +00001009/* Subscriber */
1010DEFUN(show_subscr,
1011 show_subscr_cmd,
1012 "show subscriber [IMSI]",
1013 SHOW_STR "Display information about a subscriber\n")
1014{
1015 const char *imsi;
1016 struct gsm_subscriber *subscr;
1017
1018 if (argc >= 1) {
1019 imsi = argv[0];
Harald Welte761e9442009-07-23 19:21:02 +02001020 subscr = subscr_get_by_imsi(gsmnet, imsi);
Harald Welte40f82892009-05-23 17:31:39 +00001021 if (!subscr) {
1022 vty_out(vty, "%% unknown subscriber%s",
1023 VTY_NEWLINE);
1024 return CMD_WARNING;
1025 }
1026 subscr_dump_vty(vty, subscr);
1027
1028 return CMD_SUCCESS;
1029 }
1030
1031 /* FIXME: iterate over all subscribers ? */
1032 return CMD_WARNING;
1033
1034 return CMD_SUCCESS;
1035}
1036
1037DEFUN(cfg_subscr_name,
1038 cfg_subscr_name_cmd,
1039 "name NAME",
1040 "Set the name of the subscriber")
1041{
1042 const char *name = argv[0];
1043 struct gsm_subscriber *subscr = vty->index;
1044
1045 strncpy(subscr->name, name, sizeof(subscr->name));
1046
1047 db_sync_subscriber(subscr);
1048
1049 return CMD_SUCCESS;
1050}
1051
1052DEFUN(cfg_subscr_extension,
1053 cfg_subscr_extension_cmd,
1054 "extension EXTENSION",
1055 "Set the extension of the subscriber")
1056{
1057 const char *name = argv[0];
1058 struct gsm_subscriber *subscr = vty->index;
1059
1060 strncpy(subscr->extension, name, sizeof(subscr->extension));
1061
1062 db_sync_subscriber(subscr);
1063
1064 return CMD_SUCCESS;
1065}
1066
1067DEFUN(cfg_subscr_authorized,
1068 cfg_subscr_authorized_cmd,
1069 "auth <0-1>",
1070 "Set the authorization status of the subscriber")
1071{
1072 int auth = atoi(argv[0]);
1073 struct gsm_subscriber *subscr = vty->index;
1074
1075 if (auth)
1076 subscr->authorized = 1;
1077 else
1078 subscr->authorized = 0;
1079
1080 db_sync_subscriber(subscr);
1081
1082 return CMD_SUCCESS;
1083}
1084
Harald Welte68628e82009-03-10 12:17:57 +00001085int bsc_vty_init(struct gsm_network *net)
1086{
1087 gsmnet = net;
1088
1089 cmd_init(1);
1090 vty_init();
1091
1092 install_element(VIEW_NODE, &show_net_cmd);
1093 install_element(VIEW_NODE, &show_bts_cmd);
1094 install_element(VIEW_NODE, &show_trx_cmd);
1095 install_element(VIEW_NODE, &show_ts_cmd);
1096 install_element(VIEW_NODE, &show_lchan_cmd);
Harald Welte1bc77352009-03-10 19:47:51 +00001097
1098 install_element(VIEW_NODE, &show_e1drv_cmd);
Harald Welte68628e82009-03-10 12:17:57 +00001099 install_element(VIEW_NODE, &show_e1line_cmd);
1100 install_element(VIEW_NODE, &show_e1ts_cmd);
1101
Harald Weltef5025b62009-03-28 16:55:11 +00001102 install_element(VIEW_NODE, &show_paging_cmd);
Harald Welte5258fc42009-03-28 19:07:53 +00001103
Harald Welte40f82892009-05-23 17:31:39 +00001104 install_element(VIEW_NODE, &show_subscr_cmd);
1105
Harald Welte5013b2a2009-08-07 13:29:14 +02001106 install_element(CONFIG_NODE, &cfg_net_cmd);
1107 install_node(&net_node, config_write_net);
1108 install_default(GSMNET_NODE);
1109 install_element(GSMNET_NODE, &cfg_net_mnc_cmd);
1110 install_element(GSMNET_NODE, &cfg_net_name_short_cmd);
1111 install_element(GSMNET_NODE, &cfg_net_name_long_cmd);
1112
1113 install_element(GSMNET_NODE, &cfg_bts_cmd);
Harald Welte67ce0732009-08-06 19:06:46 +02001114 install_node(&bts_node, config_write_bts);
Harald Welte68628e82009-03-10 12:17:57 +00001115 install_default(BTS_NODE);
Harald Welte5258fc42009-03-28 19:07:53 +00001116 install_element(BTS_NODE, &cfg_bts_type_cmd);
Harald Weltefcd24452009-06-20 18:15:19 +02001117 install_element(BTS_NODE, &cfg_bts_band_cmd);
Harald Welte5258fc42009-03-28 19:07:53 +00001118 install_element(BTS_NODE, &cfg_bts_lac_cmd);
1119 install_element(BTS_NODE, &cfg_bts_tsc_cmd);
Harald Welte4cc34222009-05-01 15:12:31 +00001120 install_element(BTS_NODE, &cfg_bts_unit_id_cmd);
Harald Welte68628e82009-03-10 12:17:57 +00001121
Harald Welte5258fc42009-03-28 19:07:53 +00001122 install_element(BTS_NODE, &cfg_trx_cmd);
Harald Welte68628e82009-03-10 12:17:57 +00001123 install_node(&trx_node, dummy_config_write);
Harald Welte68628e82009-03-10 12:17:57 +00001124 install_default(TRX_NODE);
Harald Welte5258fc42009-03-28 19:07:53 +00001125 install_element(TRX_NODE, &cfg_trx_arfcn_cmd);
Harald Welte879dc972009-06-20 22:36:12 +02001126 install_element(TRX_NODE, &cfg_trx_max_power_red_cmd);
Harald Welte68628e82009-03-10 12:17:57 +00001127
Harald Welte5258fc42009-03-28 19:07:53 +00001128 install_element(TRX_NODE, &cfg_ts_cmd);
Harald Welte68628e82009-03-10 12:17:57 +00001129 install_node(&ts_node, dummy_config_write);
Harald Welte68628e82009-03-10 12:17:57 +00001130 install_default(TS_NODE);
Harald Weltea6fd58e2009-08-07 00:25:23 +02001131 install_element(TS_NODE, &cfg_ts_pchan_cmd);
1132 install_element(TS_NODE, &cfg_ts_e1_subslot_cmd);
Harald Welte68628e82009-03-10 12:17:57 +00001133
Harald Welte40f82892009-05-23 17:31:39 +00001134 install_element(CONFIG_NODE, &cfg_subscr_cmd);
1135 install_node(&subscr_node, dummy_config_write);
1136 install_default(SUBSCR_NODE);
1137 install_element(SUBSCR_NODE, &cfg_subscr_name_cmd);
1138 install_element(SUBSCR_NODE, &cfg_subscr_extension_cmd);
1139 install_element(SUBSCR_NODE, &cfg_subscr_authorized_cmd);
1140
Harald Welte68628e82009-03-10 12:17:57 +00001141 return 0;
1142}