blob: f1e35e882f027a4bbf740937eba34e44d6db9300 [file] [log] [blame]
Harald Welte59b04682009-06-10 05:40:52 +08001/* 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 Welte684b9752009-08-09 15:13:54 +020026#include <vty/buffer.h>
Harald Welte59b04682009-06-10 05:40:52 +080027#include <vty/vty.h>
28
29#include <arpa/inet.h>
30
31#include <openbsc/linuxlist.h>
32#include <openbsc/gsm_data.h>
Harald Welte59b04682009-06-10 05:40:52 +080033#include <openbsc/e1_input.h>
34#include <openbsc/abis_nm.h>
Harald Welte684b9752009-08-09 15:13:54 +020035#include <openbsc/gsm_utils.h>
Harald Welte59b04682009-06-10 05:40:52 +080036#include <openbsc/db.h>
Harald Weltee87eb462009-08-07 13:29:14 +020037#include <openbsc/talloc.h>
Harald Welte59b04682009-06-10 05:40:52 +080038
39static struct gsm_network *gsmnet;
40
Harald Weltee87eb462009-08-07 13:29:14 +020041struct cmd_node net_node = {
42 GSMNET_NODE,
43 "%s(network)#",
44 1,
45};
46
Harald Welte59b04682009-06-10 05:40:52 +080047struct cmd_node bts_node = {
48 BTS_NODE,
49 "%s(bts)#",
50 1,
51};
52
53struct cmd_node trx_node = {
54 TRX_NODE,
55 "%s(trx)#",
56 1,
57};
58
59struct cmd_node ts_node = {
60 TS_NODE,
61 "%s(ts)#",
62 1,
63};
64
Harald Welte59b04682009-06-10 05:40:52 +080065static int dummy_config_write(struct vty *v)
66{
67 return CMD_SUCCESS;
68}
69
70static void net_dump_nmstate(struct vty *vty, struct gsm_nm_state *nms)
71{
72 vty_out(vty,"Oper '%s', Admin %u, Avail '%s'%s",
73 nm_opstate_name(nms->operational), nms->administrative,
74 nm_avail_name(nms->availability), VTY_NEWLINE);
75}
76
77static void net_dump_vty(struct vty *vty, struct gsm_network *net)
78{
79 vty_out(vty, "BSC is on Country Code %u, Network Code %u "
80 "and has %u BTS%s", net->country_code, net->network_code,
81 net->num_bts, VTY_NEWLINE);
82 vty_out(vty, " Long network name: '%s'%s",
83 net->name_long, VTY_NEWLINE);
84 vty_out(vty, " Short network name: '%s'%s",
85 net->name_short, VTY_NEWLINE);
Harald Welte (local)a59a27e2009-08-12 14:42:23 +020086 vty_out(vty, " Authentication policy: %s%s",
87 gsm_auth_policy_name(net->auth_policy), VTY_NEWLINE);
Harald Weltecca253a2009-08-30 15:47:06 +090088 vty_out(vty, " Encryption: A5/%u%s", net->a5_encryption,
89 VTY_NEWLINE);
Harald Welte59b04682009-06-10 05:40:52 +080090}
91
92DEFUN(show_net, show_net_cmd, "show network",
93 SHOW_STR "Display information about a GSM NETWORK\n")
94{
95 struct gsm_network *net = gsmnet;
96 net_dump_vty(vty, net);
97
98 return CMD_SUCCESS;
99}
100
101static void e1isl_dump_vty(struct vty *vty, struct e1inp_sign_link *e1l)
102{
103 struct e1inp_line *line;
104
105 if (!e1l) {
106 vty_out(vty, " None%s", VTY_NEWLINE);
107 return;
108 }
109
110 line = e1l->ts->line;
111
112 vty_out(vty, " E1 Line %u, Type %s: Timeslot %u, Mode %s%s",
113 line->num, line->driver->name, e1l->ts->num,
114 e1inp_signtype_name(e1l->type), VTY_NEWLINE);
115 vty_out(vty, " E1 TEI %u, SAPI %u%s",
116 e1l->tei, e1l->sapi, VTY_NEWLINE);
117}
118
119static void bts_dump_vty(struct vty *vty, struct gsm_bts *bts)
120{
Holger Hans Peter Freythera098dfb2009-08-21 14:44:12 +0200121 vty_out(vty, "BTS %u is of %s type in band %s, has CI %u LAC %u, "
Harald Welte91afe4c2009-06-20 18:15:19 +0200122 "BSIC %u, TSC %u and %u TRX%s",
123 bts->nr, btstype2str(bts->type), gsm_band_name(bts->band),
Holger Hans Peter Freythera098dfb2009-08-21 14:44:12 +0200124 bts->cell_identity,
Harald Welte91afe4c2009-06-20 18:15:19 +0200125 bts->location_area_code, bts->bsic, bts->tsc,
126 bts->num_trx, VTY_NEWLINE);
Harald Welte (local)e19be3f2009-08-12 13:28:23 +0200127 if (bts->cell_barred)
128 vty_out(vty, " CELL IS BARRED%s", VTY_NEWLINE);
Harald Welte59b04682009-06-10 05:40:52 +0800129 if (is_ipaccess_bts(bts))
Harald Welte25572872009-10-20 00:22:00 +0200130 vty_out(vty, " Unit ID: %u/%u/0, OML Stream ID 0x%02x%s",
Harald Welte59b04682009-06-10 05:40:52 +0800131 bts->ip_access.site_id, bts->ip_access.bts_id,
Harald Welte25572872009-10-20 00:22:00 +0200132 bts->oml_tei, VTY_NEWLINE);
Harald Welte59b04682009-06-10 05:40:52 +0800133 vty_out(vty, " NM State: ");
134 net_dump_nmstate(vty, &bts->nm_state);
135 vty_out(vty, " Site Mgr NM State: ");
136 net_dump_nmstate(vty, &bts->site_mgr.nm_state);
137 vty_out(vty, " Paging: FIXME pending requests, %u free slots%s",
138 bts->paging.available_slots, VTY_NEWLINE);
Harald Welte25572872009-10-20 00:22:00 +0200139 if (!is_ipaccess_bts(bts)) {
140 vty_out(vty, " E1 Signalling Link:%s", VTY_NEWLINE);
141 e1isl_dump_vty(vty, bts->oml_link);
142 }
Harald Welte59b04682009-06-10 05:40:52 +0800143 /* FIXME: oml_link, chan_desc */
144}
145
146DEFUN(show_bts, show_bts_cmd, "show bts [number]",
147 SHOW_STR "Display information about a BTS\n"
148 "BTS number")
149{
150 struct gsm_network *net = gsmnet;
151 int bts_nr;
152
153 if (argc != 0) {
154 /* use the BTS number that the user has specified */
155 bts_nr = atoi(argv[0]);
156 if (bts_nr > net->num_bts) {
157 vty_out(vty, "%% can't find BTS '%s'%s", argv[0],
158 VTY_NEWLINE);
159 return CMD_WARNING;
160 }
Harald Weltee712a5f2009-06-21 16:17:15 +0200161 bts_dump_vty(vty, gsm_bts_num(net, bts_nr));
Harald Welte59b04682009-06-10 05:40:52 +0800162 return CMD_SUCCESS;
163 }
164 /* print all BTS's */
165 for (bts_nr = 0; bts_nr < net->num_bts; bts_nr++)
Harald Weltee712a5f2009-06-21 16:17:15 +0200166 bts_dump_vty(vty, gsm_bts_num(net, bts_nr));
Harald Welte59b04682009-06-10 05:40:52 +0800167
168 return CMD_SUCCESS;
169}
170
Harald Welte62868882009-08-08 16:12:58 +0200171/* utility functions */
172static void parse_e1_link(struct gsm_e1_subslot *e1_link, const char *line,
173 const char *ts, const char *ss)
174{
175 e1_link->e1_nr = atoi(line);
176 e1_link->e1_ts = atoi(ts);
177 if (!strcmp(ss, "full"))
178 e1_link->e1_ts_ss = 255;
179 else
180 e1_link->e1_ts_ss = atoi(ss);
181}
182
183static void config_write_e1_link(struct vty *vty, struct gsm_e1_subslot *e1_link,
184 const char *prefix)
185{
186 if (!e1_link->e1_ts)
187 return;
188
189 if (e1_link->e1_ts_ss == 255)
190 vty_out(vty, "%se1 line %u timeslot %u sub-slot full%s",
191 prefix, e1_link->e1_nr, e1_link->e1_ts, VTY_NEWLINE);
192 else
193 vty_out(vty, "%se1 line %u timeslot %u sub-slot %u%s",
194 prefix, e1_link->e1_nr, e1_link->e1_ts,
195 e1_link->e1_ts_ss, VTY_NEWLINE);
196}
197
198
Harald Welte97ceef92009-08-06 19:06:46 +0200199static void config_write_ts_single(struct vty *vty, struct gsm_bts_trx_ts *ts)
200{
Harald Welte62868882009-08-08 16:12:58 +0200201 vty_out(vty, " timeslot %u%s", ts->nr, VTY_NEWLINE);
202 if (ts->pchan != GSM_PCHAN_NONE)
203 vty_out(vty, " phys_chan_config %s%s",
204 gsm_pchan_name(ts->pchan), VTY_NEWLINE);
205 config_write_e1_link(vty, &ts->e1_link, " ");
Harald Welte97ceef92009-08-06 19:06:46 +0200206}
207
208static void config_write_trx_single(struct vty *vty, struct gsm_bts_trx *trx)
209{
210 int i;
211
Harald Weltee87eb462009-08-07 13:29:14 +0200212 vty_out(vty, " trx %u%s", trx->nr, VTY_NEWLINE);
213 vty_out(vty, " arfcn %u%s", trx->arfcn, VTY_NEWLINE);
214 vty_out(vty, " max_power_red %u%s", trx->max_power_red, VTY_NEWLINE);
Harald Welte62868882009-08-08 16:12:58 +0200215 config_write_e1_link(vty, &trx->rsl_e1_link, " rsl ");
216 vty_out(vty, " rsl e1 tei %u%s", trx->rsl_tei, VTY_NEWLINE);
Harald Welte97ceef92009-08-06 19:06:46 +0200217
218 for (i = 0; i < TRX_NR_TS; i++)
219 config_write_ts_single(vty, &trx->ts[i]);
220}
221
222static void config_write_bts_single(struct vty *vty, struct gsm_bts *bts)
223{
224 struct gsm_bts_trx *trx;
225
Harald Weltee87eb462009-08-07 13:29:14 +0200226 vty_out(vty, " bts %u%s", bts->nr, VTY_NEWLINE);
227 vty_out(vty, " type %s%s", btstype2str(bts->type), VTY_NEWLINE);
228 vty_out(vty, " band %s%s", gsm_band_name(bts->band), VTY_NEWLINE);
Holger Hans Peter Freythera098dfb2009-08-21 14:44:12 +0200229 vty_out(vty, " cell_identity %u%s", bts->cell_identity, VTY_NEWLINE);
Harald Weltee87eb462009-08-07 13:29:14 +0200230 vty_out(vty, " location_area_code %u%s", bts->location_area_code,
Harald Welte97ceef92009-08-06 19:06:46 +0200231 VTY_NEWLINE);
Harald Weltee87eb462009-08-07 13:29:14 +0200232 vty_out(vty, " training_sequence_code %u%s", bts->tsc, VTY_NEWLINE);
233 vty_out(vty, " base_station_id_code %u%s", bts->bsic, VTY_NEWLINE);
Harald Welte (local)cbd46102009-08-13 10:14:26 +0200234 vty_out(vty, " ms max power %u%s", bts->ms_max_power, VTY_NEWLINE);
Harald Welte (local)b6ea7f72009-08-14 23:09:25 +0200235 if (bts->chan_desc.t3212)
236 vty_out(vty, " periodic location update %u%s",
237 bts->chan_desc.t3212 * 10, VTY_NEWLINE);
Harald Welte3e774612009-08-10 13:48:16 +0200238 vty_out(vty, " channel allocator %s%s",
239 bts->chan_alloc_reverse ? "descending" : "ascending",
240 VTY_NEWLINE);
Harald Welte (local)e19be3f2009-08-12 13:28:23 +0200241 if (bts->cell_barred)
242 vty_out(vty, " cell barred 1%s", VTY_NEWLINE);
Harald Welte25572872009-10-20 00:22:00 +0200243 if (is_ipaccess_bts(bts)) {
Harald Weltee87eb462009-08-07 13:29:14 +0200244 vty_out(vty, " ip.access unit_id %u %u%s",
Harald Welte3ffe1b32009-08-07 00:25:23 +0200245 bts->ip_access.site_id, bts->ip_access.bts_id, VTY_NEWLINE);
Harald Welte25572872009-10-20 00:22:00 +0200246 vty_out(vty, " oml ip.access stream_id %u%s", bts->oml_tei, VTY_NEWLINE);
247 } else {
Harald Welte62868882009-08-08 16:12:58 +0200248 config_write_e1_link(vty, &bts->oml_e1_link, " oml ");
249 vty_out(vty, " oml e1 tei %u%s", bts->oml_tei, VTY_NEWLINE);
250 }
Harald Welte97ceef92009-08-06 19:06:46 +0200251
252 llist_for_each_entry(trx, &bts->trx_list, list)
253 config_write_trx_single(vty, trx);
254}
255
256static int config_write_bts(struct vty *v)
257{
258 struct gsm_bts *bts;
259
260 llist_for_each_entry(bts, &gsmnet->bts_list, list)
261 config_write_bts_single(v, bts);
262
263 return CMD_SUCCESS;
264}
265
Harald Weltee87eb462009-08-07 13:29:14 +0200266static int config_write_net(struct vty *vty)
267{
268 vty_out(vty, "network%s", VTY_NEWLINE);
Harald Welte62868882009-08-08 16:12:58 +0200269 vty_out(vty, " network country code %u%s", gsmnet->country_code, VTY_NEWLINE);
Harald Weltee87eb462009-08-07 13:29:14 +0200270 vty_out(vty, " mobile network code %u%s", gsmnet->network_code, VTY_NEWLINE);
Harald Welte62868882009-08-08 16:12:58 +0200271 vty_out(vty, " short name %s%s", gsmnet->name_short, VTY_NEWLINE);
272 vty_out(vty, " long name %s%s", gsmnet->name_long, VTY_NEWLINE);
Harald Welte (local)a59a27e2009-08-12 14:42:23 +0200273 vty_out(vty, " auth policy %s%s", gsm_auth_policy_name(gsmnet->auth_policy), VTY_NEWLINE);
Harald Weltecca253a2009-08-30 15:47:06 +0900274 vty_out(vty, " encryption a5 %u%s", gsmnet->a5_encryption, VTY_NEWLINE);
Harald Weltee87eb462009-08-07 13:29:14 +0200275
276 return CMD_SUCCESS;
277}
Harald Welte97ceef92009-08-06 19:06:46 +0200278
Harald Welte59b04682009-06-10 05:40:52 +0800279static void trx_dump_vty(struct vty *vty, struct gsm_bts_trx *trx)
280{
281 vty_out(vty, "TRX %u of BTS %u is on ARFCN %u%s",
282 trx->nr, trx->bts->nr, trx->arfcn, VTY_NEWLINE);
Harald Welte91afe4c2009-06-20 18:15:19 +0200283 vty_out(vty, " RF Nominal Power: %d dBm, reduced by %u dB, "
Harald Welte62868882009-08-08 16:12:58 +0200284 "resulting BS power: %d dBm%s",
Harald Welte91afe4c2009-06-20 18:15:19 +0200285 trx->nominal_power, trx->max_power_red,
Harald Welte62868882009-08-08 16:12:58 +0200286 trx->nominal_power - trx->max_power_red, VTY_NEWLINE);
Harald Welte59b04682009-06-10 05:40:52 +0800287 vty_out(vty, " NM State: ");
288 net_dump_nmstate(vty, &trx->nm_state);
289 vty_out(vty, " Baseband Transceiver NM State: ");
290 net_dump_nmstate(vty, &trx->bb_transc.nm_state);
Harald Welte25572872009-10-20 00:22:00 +0200291 if (is_ipaccess_bts(trx->bts)) {
292 vty_out(vty, " ip.access stream ID: 0x%02x%s",
293 trx->rsl_tei, VTY_NEWLINE);
294 } else {
295 vty_out(vty, " E1 Signalling Link:%s", VTY_NEWLINE);
296 e1isl_dump_vty(vty, trx->rsl_link);
297 }
Harald Welte59b04682009-06-10 05:40:52 +0800298}
299
300DEFUN(show_trx,
301 show_trx_cmd,
302 "show trx [bts_nr] [trx_nr]",
303 SHOW_STR "Display information about a TRX\n")
304{
305 struct gsm_network *net = gsmnet;
306 struct gsm_bts *bts = NULL;
307 struct gsm_bts_trx *trx;
308 int bts_nr, trx_nr;
309
310 if (argc >= 1) {
311 /* use the BTS number that the user has specified */
312 bts_nr = atoi(argv[0]);
313 if (bts_nr >= net->num_bts) {
314 vty_out(vty, "%% can't find BTS '%s'%s", argv[0],
315 VTY_NEWLINE);
316 return CMD_WARNING;
317 }
Harald Weltee712a5f2009-06-21 16:17:15 +0200318 bts = gsm_bts_num(net, bts_nr);
Harald Welte59b04682009-06-10 05:40:52 +0800319 }
320 if (argc >= 2) {
321 trx_nr = atoi(argv[1]);
322 if (trx_nr >= bts->num_trx) {
323 vty_out(vty, "%% can't find TRX '%s'%s", argv[1],
324 VTY_NEWLINE);
325 return CMD_WARNING;
326 }
Harald Weltee712a5f2009-06-21 16:17:15 +0200327 trx = gsm_bts_trx_num(bts, trx_nr);
Harald Welte59b04682009-06-10 05:40:52 +0800328 trx_dump_vty(vty, trx);
329 return CMD_SUCCESS;
330 }
331 if (bts) {
332 /* print all TRX in this BTS */
333 for (trx_nr = 0; trx_nr < bts->num_trx; trx_nr++) {
Harald Weltee712a5f2009-06-21 16:17:15 +0200334 trx = gsm_bts_trx_num(bts, trx_nr);
Harald Welte59b04682009-06-10 05:40:52 +0800335 trx_dump_vty(vty, trx);
336 }
337 return CMD_SUCCESS;
338 }
339
340 for (bts_nr = 0; bts_nr < net->num_bts; bts_nr++) {
Harald Weltee712a5f2009-06-21 16:17:15 +0200341 bts = gsm_bts_num(net, bts_nr);
Harald Welte59b04682009-06-10 05:40:52 +0800342 for (trx_nr = 0; trx_nr < bts->num_trx; trx_nr++) {
Harald Weltee712a5f2009-06-21 16:17:15 +0200343 trx = gsm_bts_trx_num(bts, trx_nr);
Harald Welte59b04682009-06-10 05:40:52 +0800344 trx_dump_vty(vty, trx);
345 }
346 }
347
348 return CMD_SUCCESS;
349}
350
Harald Welte97ceef92009-08-06 19:06:46 +0200351
Harald Welte59b04682009-06-10 05:40:52 +0800352static void ts_dump_vty(struct vty *vty, struct gsm_bts_trx_ts *ts)
353{
354 struct in_addr ia;
355
356 vty_out(vty, "Timeslot %u of TRX %u in BTS %u, phys cfg %s%s",
357 ts->nr, ts->trx->nr, ts->trx->bts->nr,
358 gsm_pchan_name(ts->pchan), VTY_NEWLINE);
359 vty_out(vty, " NM State: ");
360 net_dump_nmstate(vty, &ts->nm_state);
361 if (is_ipaccess_bts(ts->trx->bts)) {
362 ia.s_addr = ts->abis_ip.bound_ip;
Harald Welte8cdeaad2009-07-12 09:50:35 +0200363 vty_out(vty, " Bound IP: %s Port %u RTP_TYPE2=%u CONN_ID=%u%s",
Harald Welte59b04682009-06-10 05:40:52 +0800364 inet_ntoa(ia), ts->abis_ip.bound_port,
Harald Welte8cdeaad2009-07-12 09:50:35 +0200365 ts->abis_ip.rtp_payload2, ts->abis_ip.conn_id,
Harald Welte59b04682009-06-10 05:40:52 +0800366 VTY_NEWLINE);
367 } else {
368 vty_out(vty, " E1 Line %u, Timeslot %u, Subslot %u%s",
369 ts->e1_link.e1_nr, ts->e1_link.e1_ts,
370 ts->e1_link.e1_ts_ss, VTY_NEWLINE);
371 }
372}
373
374DEFUN(show_ts,
375 show_ts_cmd,
376 "show timeslot [bts_nr] [trx_nr] [ts_nr]",
377 SHOW_STR "Display information about a TS\n")
378{
379 struct gsm_network *net = gsmnet;
380 struct gsm_bts *bts;
381 struct gsm_bts_trx *trx;
382 struct gsm_bts_trx_ts *ts;
383 int bts_nr, trx_nr, ts_nr;
384
385 if (argc >= 1) {
386 /* use the BTS number that the user has specified */
387 bts_nr = atoi(argv[0]);
388 if (bts_nr >= net->num_bts) {
389 vty_out(vty, "%% can't find BTS '%s'%s", argv[0],
390 VTY_NEWLINE);
391 return CMD_WARNING;
392 }
Harald Weltee712a5f2009-06-21 16:17:15 +0200393 bts = gsm_bts_num(net, bts_nr);
Harald Welte59b04682009-06-10 05:40:52 +0800394 }
395 if (argc >= 2) {
396 trx_nr = atoi(argv[1]);
397 if (trx_nr >= bts->num_trx) {
398 vty_out(vty, "%% can't find TRX '%s'%s", argv[1],
399 VTY_NEWLINE);
400 return CMD_WARNING;
401 }
Harald Weltee712a5f2009-06-21 16:17:15 +0200402 trx = gsm_bts_trx_num(bts, trx_nr);
Harald Welte59b04682009-06-10 05:40:52 +0800403 }
404 if (argc >= 3) {
405 ts_nr = atoi(argv[2]);
406 if (ts_nr >= TRX_NR_TS) {
407 vty_out(vty, "%% can't find TS '%s'%s", argv[2],
408 VTY_NEWLINE);
409 return CMD_WARNING;
410 }
411 ts = &trx->ts[ts_nr];
412 ts_dump_vty(vty, ts);
413 return CMD_SUCCESS;
414 }
415 for (bts_nr = 0; bts_nr < net->num_bts; bts_nr++) {
Harald Weltee712a5f2009-06-21 16:17:15 +0200416 bts = gsm_bts_num(net, bts_nr);
Harald Welte59b04682009-06-10 05:40:52 +0800417 for (trx_nr = 0; trx_nr < bts->num_trx; trx_nr++) {
Harald Weltee712a5f2009-06-21 16:17:15 +0200418 trx = gsm_bts_trx_num(bts, trx_nr);
Harald Welte59b04682009-06-10 05:40:52 +0800419 for (ts_nr = 0; ts_nr < TRX_NR_TS; ts_nr++) {
420 ts = &trx->ts[ts_nr];
421 ts_dump_vty(vty, ts);
422 }
423 }
424 }
425
426 return CMD_SUCCESS;
427}
428
Holger Hans Peter Freytherbdae6f92009-08-10 10:17:50 +0200429void subscr_dump_vty(struct vty *vty, struct gsm_subscriber *subscr)
Harald Welte59b04682009-06-10 05:40:52 +0800430{
Harald Welte91afe4c2009-06-20 18:15:19 +0200431 vty_out(vty, " ID: %llu, Authorized: %d%s", subscr->id,
Harald Welte59b04682009-06-10 05:40:52 +0800432 subscr->authorized, VTY_NEWLINE);
433 if (subscr->name)
434 vty_out(vty, " Name: '%s'%s", subscr->name, VTY_NEWLINE);
435 if (subscr->extension)
436 vty_out(vty, " Extension: %s%s", subscr->extension,
437 VTY_NEWLINE);
438 if (subscr->imsi)
439 vty_out(vty, " IMSI: %s%s", subscr->imsi, VTY_NEWLINE);
Holger Hans Peter Freythercd8bacf2009-08-19 12:53:57 +0200440 if (subscr->tmsi != GSM_RESERVED_TMSI)
441 vty_out(vty, " TMSI: %08X%s", subscr->tmsi,
Harald Welte270c06c2009-08-15 03:24:51 +0200442 VTY_NEWLINE);
Harald Welte (local)02d5efa2009-08-14 20:27:16 +0200443 vty_out(vty, " Use count: %u%s", subscr->use_count, VTY_NEWLINE);
Harald Welte59b04682009-06-10 05:40:52 +0800444}
445
446static void lchan_dump_vty(struct vty *vty, struct gsm_lchan *lchan)
447{
448 vty_out(vty, "Lchan %u in Timeslot %u of TRX %u in BTS %u, Type %s%s",
449 lchan->nr, lchan->ts->nr, lchan->ts->trx->nr,
450 lchan->ts->trx->bts->nr, gsm_lchan_name(lchan->type),
451 VTY_NEWLINE);
452 vty_out(vty, " Use Count: %u%s", lchan->use_count, VTY_NEWLINE);
453 vty_out(vty, " BS Power %u, MS Power %u%s", lchan->bs_power,
454 lchan->ms_power, VTY_NEWLINE);
455 if (lchan->subscr) {
456 vty_out(vty, " Subscriber:%s", VTY_NEWLINE);
457 subscr_dump_vty(vty, lchan->subscr);
458 } else
459 vty_out(vty, " No Subscriber%s", VTY_NEWLINE);
460}
461
Harald Welte03740842009-06-10 23:11:52 +0800462#if 0
463TODO: callref and remote callref of call must be resolved to get gsm_trans object
Harald Welte59b04682009-06-10 05:40:52 +0800464static void call_dump_vty(struct vty *vty, struct gsm_call *call)
465{
466 vty_out(vty, "Call Type %u, State %u, Transaction ID %u%s",
467 call->type, call->state, call->transaction_id, VTY_NEWLINE);
468
469 if (call->local_lchan) {
470 vty_out(vty, "Call Local Channel:%s", VTY_NEWLINE);
471 lchan_dump_vty(vty, call->local_lchan);
472 } else
473 vty_out(vty, "Call has no Local Channel%s", VTY_NEWLINE);
474
475 if (call->remote_lchan) {
476 vty_out(vty, "Call Remote Channel:%s", VTY_NEWLINE);
477 lchan_dump_vty(vty, call->remote_lchan);
478 } else
479 vty_out(vty, "Call has no Remote Channel%s", VTY_NEWLINE);
480
481 if (call->called_subscr) {
482 vty_out(vty, "Called Subscriber:%s", VTY_NEWLINE);
483 subscr_dump_vty(vty, call->called_subscr);
484 } else
485 vty_out(vty, "Call has no Called Subscriber%s", VTY_NEWLINE);
486}
Harald Welte03740842009-06-10 23:11:52 +0800487#endif
Harald Welte59b04682009-06-10 05:40:52 +0800488
489DEFUN(show_lchan,
490 show_lchan_cmd,
491 "show lchan [bts_nr] [trx_nr] [ts_nr] [lchan_nr]",
492 SHOW_STR "Display information about a logical channel\n")
493{
494 struct gsm_network *net = gsmnet;
495 struct gsm_bts *bts;
496 struct gsm_bts_trx *trx;
497 struct gsm_bts_trx_ts *ts;
498 struct gsm_lchan *lchan;
499 int bts_nr, trx_nr, ts_nr, lchan_nr;
500
501 if (argc >= 1) {
502 /* use the BTS number that the user has specified */
503 bts_nr = atoi(argv[0]);
504 if (bts_nr >= net->num_bts) {
505 vty_out(vty, "%% can't find BTS %s%s", argv[0],
506 VTY_NEWLINE);
507 return CMD_WARNING;
508 }
Harald Weltee712a5f2009-06-21 16:17:15 +0200509 bts = gsm_bts_num(net, bts_nr);
Harald Welte59b04682009-06-10 05:40:52 +0800510 }
511 if (argc >= 2) {
512 trx_nr = atoi(argv[1]);
513 if (trx_nr >= bts->num_trx) {
514 vty_out(vty, "%% can't find TRX %s%s", argv[1],
515 VTY_NEWLINE);
516 return CMD_WARNING;
517 }
Harald Weltee712a5f2009-06-21 16:17:15 +0200518 trx = gsm_bts_trx_num(bts, trx_nr);
Harald Welte59b04682009-06-10 05:40:52 +0800519 }
520 if (argc >= 3) {
521 ts_nr = atoi(argv[2]);
522 if (ts_nr >= TRX_NR_TS) {
523 vty_out(vty, "%% can't find TS %s%s", argv[2],
524 VTY_NEWLINE);
525 return CMD_WARNING;
526 }
527 ts = &trx->ts[ts_nr];
528 }
529 if (argc >= 4) {
530 lchan_nr = atoi(argv[3]);
531 if (lchan_nr >= TS_MAX_LCHAN) {
532 vty_out(vty, "%% can't find LCHAN %s%s", argv[3],
533 VTY_NEWLINE);
534 return CMD_WARNING;
535 }
536 lchan = &ts->lchan[lchan_nr];
537 lchan_dump_vty(vty, lchan);
538 return CMD_SUCCESS;
539 }
540 for (bts_nr = 0; bts_nr < net->num_bts; bts_nr++) {
Harald Weltee712a5f2009-06-21 16:17:15 +0200541 bts = gsm_bts_num(net, bts_nr);
Harald Welte59b04682009-06-10 05:40:52 +0800542 for (trx_nr = 0; trx_nr < bts->num_trx; trx_nr++) {
Harald Weltee712a5f2009-06-21 16:17:15 +0200543 trx = gsm_bts_trx_num(bts, trx_nr);
Harald Welte59b04682009-06-10 05:40:52 +0800544 for (ts_nr = 0; ts_nr < TRX_NR_TS; ts_nr++) {
545 ts = &trx->ts[ts_nr];
546 for (lchan_nr = 0; lchan_nr < TS_MAX_LCHAN;
547 lchan_nr++) {
548 lchan = &ts->lchan[lchan_nr];
549 if (lchan->type == GSM_LCHAN_NONE)
550 continue;
551 lchan_dump_vty(vty, lchan);
552 }
553 }
554 }
555 }
556
557 return CMD_SUCCESS;
558}
559
560static void e1drv_dump_vty(struct vty *vty, struct e1inp_driver *drv)
561{
562 vty_out(vty, "E1 Input Driver %s%s", drv->name, VTY_NEWLINE);
563}
564
565DEFUN(show_e1drv,
566 show_e1drv_cmd,
567 "show e1_driver",
568 SHOW_STR "Display information about available E1 drivers\n")
569{
570 struct e1inp_driver *drv;
571
572 llist_for_each_entry(drv, &e1inp_driver_list, list)
573 e1drv_dump_vty(vty, drv);
574
575 return CMD_SUCCESS;
576}
577
578static void e1line_dump_vty(struct vty *vty, struct e1inp_line *line)
579{
580 vty_out(vty, "E1 Line Number %u, Name %s, Driver %s%s",
581 line->num, line->name ? line->name : "",
582 line->driver->name, VTY_NEWLINE);
583}
584
585DEFUN(show_e1line,
586 show_e1line_cmd,
587 "show e1_line [line_nr]",
588 SHOW_STR "Display information about a E1 line\n")
589{
590 struct e1inp_line *line;
591
592 if (argc >= 1) {
593 int num = atoi(argv[0]);
594 llist_for_each_entry(line, &e1inp_line_list, list) {
595 if (line->num == num) {
596 e1line_dump_vty(vty, line);
597 return CMD_SUCCESS;
598 }
599 }
600 return CMD_WARNING;
601 }
602
603 llist_for_each_entry(line, &e1inp_line_list, list)
604 e1line_dump_vty(vty, line);
605
606 return CMD_SUCCESS;
607}
608
609static void e1ts_dump_vty(struct vty *vty, struct e1inp_ts *ts)
610{
Harald Welte62868882009-08-08 16:12:58 +0200611 if (ts->type == E1INP_TS_TYPE_NONE)
612 return;
Harald Welte59b04682009-06-10 05:40:52 +0800613 vty_out(vty, "E1 Timeslot %2u of Line %u is Type %s%s",
614 ts->num, ts->line->num, e1inp_tstype_name(ts->type),
615 VTY_NEWLINE);
616}
617
618DEFUN(show_e1ts,
619 show_e1ts_cmd,
620 "show e1_timeslot [line_nr] [ts_nr]",
621 SHOW_STR "Display information about a E1 timeslot\n")
622{
Harald Welte49c79562009-11-17 06:12:16 +0100623 struct e1inp_line *line = NULL;
Harald Welte59b04682009-06-10 05:40:52 +0800624 struct e1inp_ts *ts;
625 int ts_nr;
626
627 if (argc == 0) {
628 llist_for_each_entry(line, &e1inp_line_list, list) {
629 for (ts_nr = 0; ts_nr < NUM_E1_TS; ts_nr++) {
630 ts = &line->ts[ts_nr];
631 e1ts_dump_vty(vty, ts);
632 }
633 }
634 return CMD_SUCCESS;
635 }
636 if (argc >= 1) {
637 int num = atoi(argv[0]);
638 llist_for_each_entry(line, &e1inp_line_list, list) {
639 if (line->num == num)
640 break;
641 }
642 if (!line || line->num != num) {
643 vty_out(vty, "E1 line %s is invalid%s",
644 argv[0], VTY_NEWLINE);
645 return CMD_WARNING;
646 }
647 }
648 if (argc >= 2) {
649 ts_nr = atoi(argv[1]);
650 if (ts_nr > NUM_E1_TS) {
651 vty_out(vty, "E1 timeslot %s is invalid%s",
652 argv[1], VTY_NEWLINE);
653 return CMD_WARNING;
654 }
655 ts = &line->ts[ts_nr];
656 e1ts_dump_vty(vty, ts);
657 return CMD_SUCCESS;
658 } else {
659 for (ts_nr = 0; ts_nr < NUM_E1_TS; ts_nr++) {
660 ts = &line->ts[ts_nr];
661 e1ts_dump_vty(vty, ts);
662 }
663 return CMD_SUCCESS;
664 }
665 return CMD_SUCCESS;
666}
667
668static void paging_dump_vty(struct vty *vty, struct gsm_paging_request *pag)
669{
670 vty_out(vty, "Paging on BTS %u%s", pag->bts->nr, VTY_NEWLINE);
671 subscr_dump_vty(vty, pag->subscr);
672}
673
674static void bts_paging_dump_vty(struct vty *vty, struct gsm_bts *bts)
675{
676 struct gsm_paging_request *pag;
677
678 llist_for_each_entry(pag, &bts->paging.pending_requests, entry)
679 paging_dump_vty(vty, pag);
680}
681
682DEFUN(show_paging,
683 show_paging_cmd,
684 "show paging [bts_nr]",
685 SHOW_STR "Display information about paging reuqests of a BTS\n")
686{
687 struct gsm_network *net = gsmnet;
688 struct gsm_bts *bts;
689 int bts_nr;
690
691 if (argc >= 1) {
692 /* use the BTS number that the user has specified */
693 bts_nr = atoi(argv[0]);
694 if (bts_nr >= net->num_bts) {
695 vty_out(vty, "%% can't find BTS %s%s", argv[0],
696 VTY_NEWLINE);
697 return CMD_WARNING;
698 }
Harald Weltee712a5f2009-06-21 16:17:15 +0200699 bts = gsm_bts_num(net, bts_nr);
Harald Welte59b04682009-06-10 05:40:52 +0800700 bts_paging_dump_vty(vty, bts);
701
702 return CMD_SUCCESS;
703 }
704 for (bts_nr = 0; bts_nr < net->num_bts; bts_nr++) {
Harald Weltee712a5f2009-06-21 16:17:15 +0200705 bts = gsm_bts_num(net, bts_nr);
Harald Welte59b04682009-06-10 05:40:52 +0800706 bts_paging_dump_vty(vty, bts);
707 }
708
709 return CMD_SUCCESS;
710}
711
Harald Weltee87eb462009-08-07 13:29:14 +0200712DEFUN(cfg_net,
713 cfg_net_cmd,
714 "network",
715 "Configure the GSM network")
716{
717 vty->index = gsmnet;
718 vty->node = GSMNET_NODE;
719
720 return CMD_SUCCESS;
721}
722
723
724DEFUN(cfg_net_ncc,
725 cfg_net_ncc_cmd,
726 "network country code <1-999>",
727 "Set the GSM network country code")
728{
729 gsmnet->country_code = atoi(argv[0]);
730
731 return CMD_SUCCESS;
732}
733
734DEFUN(cfg_net_mnc,
735 cfg_net_mnc_cmd,
736 "mobile network code <1-999>",
737 "Set the GSM mobile network code")
738{
739 gsmnet->network_code = atoi(argv[0]);
740
741 return CMD_SUCCESS;
742}
743
744DEFUN(cfg_net_name_short,
745 cfg_net_name_short_cmd,
746 "short name NAME",
747 "Set the short GSM network name")
748{
749 if (gsmnet->name_short)
750 talloc_free(gsmnet->name_short);
751
752 gsmnet->name_short = talloc_strdup(gsmnet, argv[0]);
753
754 return CMD_SUCCESS;
755}
756
757DEFUN(cfg_net_name_long,
758 cfg_net_name_long_cmd,
759 "long name NAME",
760 "Set the long GSM network name")
761{
762 if (gsmnet->name_long)
763 talloc_free(gsmnet->name_long);
764
765 gsmnet->name_long = talloc_strdup(gsmnet, argv[0]);
766
767 return CMD_SUCCESS;
768}
Harald Welte59b04682009-06-10 05:40:52 +0800769
Harald Welte (local)a59a27e2009-08-12 14:42:23 +0200770DEFUN(cfg_net_auth_policy,
771 cfg_net_auth_policy_cmd,
772 "auth policy (closed|accept-all|token)",
773 "Set the GSM network authentication policy\n")
774{
775 enum gsm_auth_policy policy = gsm_auth_policy_parse(argv[0]);
776
777 gsmnet->auth_policy = policy;
778
779 return CMD_SUCCESS;
780}
781
Harald Weltecca253a2009-08-30 15:47:06 +0900782DEFUN(cfg_net_encryption,
783 cfg_net_encryption_cmd,
784 "encryption a5 (0|1|2)",
785 "Enable or disable encryption (A5) for this network\n")
786{
787 gsmnet->auth_policy = atoi(argv[0]);
788
789 return CMD_SUCCESS;
790}
791
Harald Welte59b04682009-06-10 05:40:52 +0800792/* per-BTS configuration */
793DEFUN(cfg_bts,
794 cfg_bts_cmd,
795 "bts BTS_NR",
796 "Select a BTS to configure\n")
797{
798 int bts_nr = atoi(argv[0]);
799 struct gsm_bts *bts;
800
Harald Weltee712a5f2009-06-21 16:17:15 +0200801 if (bts_nr > gsmnet->num_bts) {
802 vty_out(vty, "%% The next unused BTS number is %u%s",
803 gsmnet->num_bts, VTY_NEWLINE);
Harald Welte59b04682009-06-10 05:40:52 +0800804 return CMD_WARNING;
Harald Weltee712a5f2009-06-21 16:17:15 +0200805 } else if (bts_nr == gsmnet->num_bts) {
806 /* allocate a new one */
807 bts = gsm_bts_alloc(gsmnet, GSM_BTS_TYPE_UNKNOWN,
808 HARDCODED_TSC, HARDCODED_BSIC);
809 } else
810 bts = gsm_bts_num(gsmnet, bts_nr);
811
812 if (!bts)
813 return CMD_WARNING;
Harald Welte59b04682009-06-10 05:40:52 +0800814
815 vty->index = bts;
816 vty->node = BTS_NODE;
817
818 return CMD_SUCCESS;
819}
820
821DEFUN(cfg_bts_type,
822 cfg_bts_type_cmd,
823 "type TYPE",
824 "Set the BTS type\n")
825{
826 struct gsm_bts *bts = vty->index;
827
Harald Welte3ffe1b32009-08-07 00:25:23 +0200828 bts->type = parse_btstype(argv[0]);
829
Harald Welte25572872009-10-20 00:22:00 +0200830 if (is_ipaccess_bts(bts)) {
831 /* Set the default OML Stream ID to 0xff */
832 bts->oml_tei = 0xff;
833 }
834
Harald Welte59b04682009-06-10 05:40:52 +0800835 return CMD_SUCCESS;
836}
837
Harald Welte91afe4c2009-06-20 18:15:19 +0200838DEFUN(cfg_bts_band,
839 cfg_bts_band_cmd,
840 "band BAND",
841 "Set the frequency band of this BTS\n")
842{
843 struct gsm_bts *bts = vty->index;
Harald Welte62868882009-08-08 16:12:58 +0200844 int band = gsm_band_parse(argv[0]);
Harald Welte91afe4c2009-06-20 18:15:19 +0200845
846 if (band < 0) {
847 vty_out(vty, "%% BAND %d is not a valid GSM band%s",
848 band, VTY_NEWLINE);
849 return CMD_WARNING;
850 }
851
852 bts->band = band;
853
854 return CMD_SUCCESS;
855}
856
Holger Hans Peter Freythera098dfb2009-08-21 14:44:12 +0200857DEFUN(cfg_bts_ci,
858 cfg_bts_ci_cmd,
859 "cell_identity <0-65535>",
860 "Set the Cell identity of this BTS\n")
861{
862 struct gsm_bts *bts = vty->index;
863 int ci = atoi(argv[0]);
864
865 if (ci < 0 || ci > 0xffff) {
866 vty_out(vty, "%% CI %d is not in the valid range (0-65535)%s",
867 ci, VTY_NEWLINE);
868 return CMD_WARNING;
869 }
870 bts->cell_identity = ci;
871
872 return CMD_SUCCESS;
873}
874
Harald Welte59b04682009-06-10 05:40:52 +0800875DEFUN(cfg_bts_lac,
876 cfg_bts_lac_cmd,
Holger Hans Peter Freyther54a22832009-09-29 14:02:33 +0200877 "location_area_code <0-65535>",
Harald Welte59b04682009-06-10 05:40:52 +0800878 "Set the Location Area Code (LAC) of this BTS\n")
879{
880 struct gsm_bts *bts = vty->index;
881 int lac = atoi(argv[0]);
882
Holger Hans Peter Freyther54a22832009-09-29 14:02:33 +0200883 if (lac < 0 || lac > 0xffff) {
884 vty_out(vty, "%% LAC %d is not in the valid range (0-65535)%s",
Harald Welte59b04682009-06-10 05:40:52 +0800885 lac, VTY_NEWLINE);
886 return CMD_WARNING;
887 }
Holger Hans Peter Freyther6c6ab862009-10-01 04:07:15 +0200888
889 if (lac == GSM_LAC_RESERVED_DETACHED || lac == GSM_LAC_RESERVED_ALL_BTS) {
890 vty_out(vty, "%% LAC %d is reserved by GSM 04.08%s",
891 lac, VTY_NEWLINE);
892 return CMD_WARNING;
893 }
894
Harald Welte59b04682009-06-10 05:40:52 +0800895 bts->location_area_code = lac;
896
897 return CMD_SUCCESS;
898}
899
900DEFUN(cfg_bts_tsc,
901 cfg_bts_tsc_cmd,
902 "training_sequence_code <0-255>",
903 "Set the Training Sequence Code (TSC) of this BTS\n")
904{
905 struct gsm_bts *bts = vty->index;
906 int tsc = atoi(argv[0]);
907
908 if (tsc < 0 || tsc > 0xff) {
909 vty_out(vty, "%% TSC %d is not in the valid range (0-255)%s",
910 tsc, VTY_NEWLINE);
911 return CMD_WARNING;
912 }
913 bts->tsc = tsc;
914
915 return CMD_SUCCESS;
916}
917
918DEFUN(cfg_bts_bsic,
919 cfg_bts_bsic_cmd,
920 "base_station_id_code <0-63>",
921 "Set the Base Station Identity Code (BSIC) of this BTS\n")
922{
923 struct gsm_bts *bts = vty->index;
924 int bsic = atoi(argv[0]);
925
926 if (bsic < 0 || bsic > 0x3f) {
Harald Welte62868882009-08-08 16:12:58 +0200927 vty_out(vty, "%% BSIC %d is not in the valid range (0-255)%s",
Harald Welte59b04682009-06-10 05:40:52 +0800928 bsic, VTY_NEWLINE);
929 return CMD_WARNING;
930 }
931 bts->bsic = bsic;
932
933 return CMD_SUCCESS;
934}
935
936
937DEFUN(cfg_bts_unit_id,
938 cfg_bts_unit_id_cmd,
Harald Weltef515aa02009-08-07 13:27:09 +0200939 "ip.access unit_id <0-65534> <0-255>",
940 "Set the ip.access BTS Unit ID of this BTS\n")
Harald Welte59b04682009-06-10 05:40:52 +0800941{
942 struct gsm_bts *bts = vty->index;
943 int site_id = atoi(argv[0]);
944 int bts_id = atoi(argv[1]);
945
Harald Weltef515aa02009-08-07 13:27:09 +0200946 if (!is_ipaccess_bts(bts)) {
947 vty_out(vty, "%% BTS is not of ip.access type%s", VTY_NEWLINE);
948 return CMD_WARNING;
949 }
950
Harald Welte59b04682009-06-10 05:40:52 +0800951 bts->ip_access.site_id = site_id;
952 bts->ip_access.bts_id = bts_id;
953
954 return CMD_SUCCESS;
955}
956
Harald Welte25572872009-10-20 00:22:00 +0200957DEFUN(cfg_bts_stream_id,
958 cfg_bts_stream_id_cmd,
959 "oml ip.access stream_id <0-255>",
960 "Set the ip.access Stream ID of the OML link of this BTS\n")
961{
962 struct gsm_bts *bts = vty->index;
963 int stream_id = atoi(argv[0]);
964
965 if (!is_ipaccess_bts(bts)) {
966 vty_out(vty, "%% BTS is not of ip.access type%s", VTY_NEWLINE);
967 return CMD_WARNING;
968 }
969
970 bts->oml_tei = stream_id;
971
972 return CMD_SUCCESS;
973}
974
975
Harald Welte62868882009-08-08 16:12:58 +0200976DEFUN(cfg_bts_oml_e1,
977 cfg_bts_oml_e1_cmd,
978 "oml e1 line E1_LINE timeslot <1-31> sub-slot (0|1|2|3|full)",
979 "E1 interface to be used for OML\n")
980{
981 struct gsm_bts *bts = vty->index;
982
983 parse_e1_link(&bts->oml_e1_link, argv[0], argv[1], argv[2]);
984
985 return CMD_SUCCESS;
986}
987
988
989DEFUN(cfg_bts_oml_e1_tei,
990 cfg_bts_oml_e1_tei_cmd,
991 "oml e1 tei <0-63>",
992 "Set the TEI to be used for OML")
993{
994 struct gsm_bts *bts = vty->index;
995
996 bts->oml_tei = atoi(argv[0]);
997
998 return CMD_SUCCESS;
999}
1000
Harald Welte3e774612009-08-10 13:48:16 +02001001DEFUN(cfg_bts_challoc, cfg_bts_challoc_cmd,
1002 "channel allocator (ascending|descending)",
1003 "Should the channel allocator allocate in reverse TRX order?")
1004{
1005 struct gsm_bts *bts = vty->index;
1006
1007 if (!strcmp(argv[0], "ascending"))
1008 bts->chan_alloc_reverse = 0;
1009 else
1010 bts->chan_alloc_reverse = 1;
1011
1012 return CMD_SUCCESS;
1013}
1014
Harald Welte (local)e19be3f2009-08-12 13:28:23 +02001015DEFUN(cfg_bts_cell_barred, cfg_bts_cell_barred_cmd,
1016 "cell barred (0|1)",
1017 "Should this cell be barred from access?")
1018{
1019 struct gsm_bts *bts = vty->index;
1020
1021 bts->cell_barred = atoi(argv[0]);
1022
1023 return CMD_SUCCESS;
1024}
1025
Harald Welte (local)cbd46102009-08-13 10:14:26 +02001026DEFUN(cfg_bts_ms_max_power, cfg_bts_ms_max_power_cmd,
1027 "ms max power <0-40>",
1028 "Maximum transmit power of the MS")
1029{
1030 struct gsm_bts *bts = vty->index;
1031
1032 bts->ms_max_power = atoi(argv[0]);
1033
1034 return CMD_SUCCESS;
1035}
1036
Harald Welte (local)b6ea7f72009-08-14 23:09:25 +02001037DEFUN(cfg_bts_per_loc_upd, cfg_bts_per_loc_upd_cmd,
1038 "periodic location update <0-1530>",
1039 "Periodic Location Updating Interval in Minutes")
1040{
1041 struct gsm_bts *bts = vty->index;
1042
1043 bts->chan_desc.t3212 = atoi(argv[0]) / 10;
1044
1045 return CMD_SUCCESS;
1046}
1047
Harald Welte3e774612009-08-10 13:48:16 +02001048
Harald Welte59b04682009-06-10 05:40:52 +08001049/* per TRX configuration */
1050DEFUN(cfg_trx,
1051 cfg_trx_cmd,
1052 "trx TRX_NR",
1053 "Select a TRX to configure")
1054{
1055 int trx_nr = atoi(argv[0]);
1056 struct gsm_bts *bts = vty->index;
1057 struct gsm_bts_trx *trx;
1058
Harald Weltee712a5f2009-06-21 16:17:15 +02001059 if (trx_nr > bts->num_trx) {
1060 vty_out(vty, "%% The next unused TRX number in this BTS is %u%s",
1061 bts->num_trx, VTY_NEWLINE);
Harald Welte59b04682009-06-10 05:40:52 +08001062 return CMD_WARNING;
Harald Weltee712a5f2009-06-21 16:17:15 +02001063 } else if (trx_nr == bts->num_trx) {
1064 /* we need to allocate a new one */
1065 trx = gsm_bts_trx_alloc(bts);
1066 } else
1067 trx = gsm_bts_trx_num(bts, trx_nr);
1068
1069 if (!trx)
1070 return CMD_WARNING;
Harald Welte59b04682009-06-10 05:40:52 +08001071
1072 vty->index = trx;
1073 vty->node = TRX_NODE;
1074
1075 return CMD_SUCCESS;
1076}
1077
1078DEFUN(cfg_trx_arfcn,
1079 cfg_trx_arfcn_cmd,
1080 "arfcn <1-1024>",
1081 "Set the ARFCN for this TRX\n")
1082{
1083 int arfcn = atoi(argv[0]);
1084 struct gsm_bts_trx *trx = vty->index;
1085
1086 /* FIXME: check if this ARFCN is supported by this TRX */
1087
1088 trx->arfcn = arfcn;
1089
1090 /* FIXME: patch ARFCN into SYSTEM INFORMATION */
1091 /* FIXME: use OML layer to update the ARFCN */
1092 /* FIXME: use RSL layer to update SYSTEM INFORMATION */
1093
1094 return CMD_SUCCESS;
1095}
1096
Harald Welte91afe4c2009-06-20 18:15:19 +02001097DEFUN(cfg_trx_max_power_red,
1098 cfg_trx_max_power_red_cmd,
1099 "max_power_red <0-100>",
1100 "Reduction of maximum BS RF Power in dB\n")
1101{
1102 int maxpwr_r = atoi(argv[0]);
1103 struct gsm_bts_trx *trx = vty->index;
Harald Welte01acd742009-11-18 09:20:22 +01001104 int upper_limit = 24; /* default 12.21 max power red. */
Harald Welte91afe4c2009-06-20 18:15:19 +02001105
1106 /* FIXME: check if our BTS type supports more than 12 */
1107 if (maxpwr_r < 0 || maxpwr_r > upper_limit) {
1108 vty_out(vty, "%% Power %d dB is not in the valid range%s",
1109 maxpwr_r, VTY_NEWLINE);
1110 return CMD_WARNING;
1111 }
1112 if (maxpwr_r & 1) {
1113 vty_out(vty, "%% Power %d dB is not an even value%s",
1114 maxpwr_r, VTY_NEWLINE);
1115 return CMD_WARNING;
1116 }
1117
1118 trx->max_power_red = maxpwr_r;
1119
1120 /* FIXME: make sure we update this using OML */
1121
1122 return CMD_SUCCESS;
1123}
1124
Harald Welte62868882009-08-08 16:12:58 +02001125DEFUN(cfg_trx_rsl_e1,
1126 cfg_trx_rsl_e1_cmd,
1127 "rsl e1 line E1_LINE timeslot <1-31> sub-slot (0|1|2|3|full)",
1128 "E1 interface to be used for RSL\n")
1129{
1130 struct gsm_bts_trx *trx = vty->index;
1131
1132 parse_e1_link(&trx->rsl_e1_link, argv[0], argv[1], argv[2]);
1133
1134 return CMD_SUCCESS;
1135}
1136
1137DEFUN(cfg_trx_rsl_e1_tei,
1138 cfg_trx_rsl_e1_tei_cmd,
1139 "rsl e1 tei <0-63>",
1140 "Set the TEI to be used for RSL")
1141{
1142 struct gsm_bts_trx *trx = vty->index;
1143
1144 trx->rsl_tei = atoi(argv[0]);
1145
1146 return CMD_SUCCESS;
1147}
1148
1149
Harald Welte59b04682009-06-10 05:40:52 +08001150/* per TS configuration */
1151DEFUN(cfg_ts,
1152 cfg_ts_cmd,
Harald Welte62868882009-08-08 16:12:58 +02001153 "timeslot <0-7>",
Harald Welte59b04682009-06-10 05:40:52 +08001154 "Select a Timeslot to configure")
1155{
1156 int ts_nr = atoi(argv[0]);
1157 struct gsm_bts_trx *trx = vty->index;
1158 struct gsm_bts_trx_ts *ts;
1159
1160 if (ts_nr >= TRX_NR_TS) {
1161 vty_out(vty, "%% A GSM TRX only has %u Timeslots per TRX%s",
1162 TRX_NR_TS, VTY_NEWLINE);
1163 return CMD_WARNING;
1164 }
1165
1166 ts = &trx->ts[ts_nr];
1167
1168 vty->index = ts;
1169 vty->node = TS_NODE;
1170
1171 return CMD_SUCCESS;
1172}
1173
Harald Welte3ffe1b32009-08-07 00:25:23 +02001174DEFUN(cfg_ts_pchan,
1175 cfg_ts_pchan_cmd,
1176 "phys_chan_config PCHAN",
1177 "Physical Channel configuration (TCH/SDCCH/...)")
1178{
1179 struct gsm_bts_trx_ts *ts = vty->index;
1180 int pchanc;
1181
1182 pchanc = gsm_pchan_parse(argv[0]);
1183 if (pchanc < 0)
1184 return CMD_WARNING;
1185
1186 ts->pchan = pchanc;
1187
1188 return CMD_SUCCESS;
1189}
1190
1191DEFUN(cfg_ts_e1_subslot,
1192 cfg_ts_e1_subslot_cmd,
Harald Welte62868882009-08-08 16:12:58 +02001193 "e1 line E1_LINE timeslot <1-31> sub-slot (0|1|2|3|full)",
Harald Welte3ffe1b32009-08-07 00:25:23 +02001194 "E1 sub-slot connected to this on-air timeslot")
1195{
1196 struct gsm_bts_trx_ts *ts = vty->index;
1197
Harald Welte62868882009-08-08 16:12:58 +02001198 parse_e1_link(&ts->e1_link, argv[0], argv[1], argv[2]);
Harald Welte3ffe1b32009-08-07 00:25:23 +02001199
1200 return CMD_SUCCESS;
1201}
Harald Welte59b04682009-06-10 05:40:52 +08001202
Harald Welte59b04682009-06-10 05:40:52 +08001203int bsc_vty_init(struct gsm_network *net)
1204{
1205 gsmnet = net;
1206
1207 cmd_init(1);
1208 vty_init();
1209
1210 install_element(VIEW_NODE, &show_net_cmd);
1211 install_element(VIEW_NODE, &show_bts_cmd);
1212 install_element(VIEW_NODE, &show_trx_cmd);
1213 install_element(VIEW_NODE, &show_ts_cmd);
1214 install_element(VIEW_NODE, &show_lchan_cmd);
1215
1216 install_element(VIEW_NODE, &show_e1drv_cmd);
1217 install_element(VIEW_NODE, &show_e1line_cmd);
1218 install_element(VIEW_NODE, &show_e1ts_cmd);
1219
1220 install_element(VIEW_NODE, &show_paging_cmd);
1221
Harald Weltee87eb462009-08-07 13:29:14 +02001222 install_element(CONFIG_NODE, &cfg_net_cmd);
1223 install_node(&net_node, config_write_net);
1224 install_default(GSMNET_NODE);
Harald Welte62868882009-08-08 16:12:58 +02001225 install_element(GSMNET_NODE, &cfg_net_ncc_cmd);
Harald Weltee87eb462009-08-07 13:29:14 +02001226 install_element(GSMNET_NODE, &cfg_net_mnc_cmd);
1227 install_element(GSMNET_NODE, &cfg_net_name_short_cmd);
1228 install_element(GSMNET_NODE, &cfg_net_name_long_cmd);
Harald Welte (local)a59a27e2009-08-12 14:42:23 +02001229 install_element(GSMNET_NODE, &cfg_net_auth_policy_cmd);
Harald Weltecca253a2009-08-30 15:47:06 +09001230 install_element(GSMNET_NODE, &cfg_net_encryption_cmd);
Harald Weltee87eb462009-08-07 13:29:14 +02001231
1232 install_element(GSMNET_NODE, &cfg_bts_cmd);
Harald Welte97ceef92009-08-06 19:06:46 +02001233 install_node(&bts_node, config_write_bts);
Harald Welte59b04682009-06-10 05:40:52 +08001234 install_default(BTS_NODE);
1235 install_element(BTS_NODE, &cfg_bts_type_cmd);
Harald Welte91afe4c2009-06-20 18:15:19 +02001236 install_element(BTS_NODE, &cfg_bts_band_cmd);
Holger Hans Peter Freythera098dfb2009-08-21 14:44:12 +02001237 install_element(BTS_NODE, &cfg_bts_ci_cmd);
Harald Welte59b04682009-06-10 05:40:52 +08001238 install_element(BTS_NODE, &cfg_bts_lac_cmd);
1239 install_element(BTS_NODE, &cfg_bts_tsc_cmd);
Harald Welte62868882009-08-08 16:12:58 +02001240 install_element(BTS_NODE, &cfg_bts_bsic_cmd);
Harald Welte59b04682009-06-10 05:40:52 +08001241 install_element(BTS_NODE, &cfg_bts_unit_id_cmd);
Harald Welte25572872009-10-20 00:22:00 +02001242 install_element(BTS_NODE, &cfg_bts_stream_id_cmd);
Harald Welte62868882009-08-08 16:12:58 +02001243 install_element(BTS_NODE, &cfg_bts_oml_e1_cmd);
1244 install_element(BTS_NODE, &cfg_bts_oml_e1_tei_cmd);
Harald Welte3e774612009-08-10 13:48:16 +02001245 install_element(BTS_NODE, &cfg_bts_challoc_cmd);
Harald Welte (local)e19be3f2009-08-12 13:28:23 +02001246 install_element(BTS_NODE, &cfg_bts_cell_barred_cmd);
Harald Welte (local)cbd46102009-08-13 10:14:26 +02001247 install_element(BTS_NODE, &cfg_bts_ms_max_power_cmd);
Harald Welte (local)b6ea7f72009-08-14 23:09:25 +02001248 install_element(BTS_NODE, &cfg_bts_per_loc_upd_cmd);
Harald Welte3e774612009-08-10 13:48:16 +02001249
Harald Welte59b04682009-06-10 05:40:52 +08001250
1251 install_element(BTS_NODE, &cfg_trx_cmd);
1252 install_node(&trx_node, dummy_config_write);
1253 install_default(TRX_NODE);
1254 install_element(TRX_NODE, &cfg_trx_arfcn_cmd);
Harald Welte7f597bc2009-06-20 22:36:12 +02001255 install_element(TRX_NODE, &cfg_trx_max_power_red_cmd);
Harald Welte62868882009-08-08 16:12:58 +02001256 install_element(TRX_NODE, &cfg_trx_rsl_e1_cmd);
1257 install_element(TRX_NODE, &cfg_trx_rsl_e1_tei_cmd);
Harald Welte59b04682009-06-10 05:40:52 +08001258
1259 install_element(TRX_NODE, &cfg_ts_cmd);
1260 install_node(&ts_node, dummy_config_write);
1261 install_default(TS_NODE);
Harald Welte3ffe1b32009-08-07 00:25:23 +02001262 install_element(TS_NODE, &cfg_ts_pchan_cmd);
1263 install_element(TS_NODE, &cfg_ts_e1_subslot_cmd);
Harald Welte59b04682009-06-10 05:40:52 +08001264
Holger Hans Peter Freytherbdae6f92009-08-10 10:17:50 +02001265 bsc_vty_init_extra(net);
Harald Welte59b04682009-06-10 05:40:52 +08001266
1267 return 0;
1268}