blob: 202518e0ed8ff0ba6f4500ba3174832f57729409 [file] [log] [blame]
Holger Hans Peter Freythercfa90d42009-08-10 10:17:50 +02001/* OpenBSC interface to quagga VTY */
2/* (C) 2009 by Harald Welte <laforge@gnumonks.org>
Holger Hans Peter Freythere33966c2009-10-27 12:47:06 +01003 * (C) 2009 by Holger Hans Peter Freyther
Holger Hans Peter Freythercfa90d42009-08-10 10:17:50 +02004 * All Rights Reserved
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License along
17 * with this program; if not, write to the Free Software Foundation, Inc.,
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19 *
20 */
21
22#include <stdlib.h>
23#include <unistd.h>
24#include <sys/types.h>
25
26#include <vty/command.h>
27#include <vty/buffer.h>
28#include <vty/vty.h>
29
30#include <arpa/inet.h>
31
Harald Weltedfe6c7d2010-02-20 16:24:02 +010032#include <osmocore/linuxlist.h>
Holger Hans Peter Freythercfa90d42009-08-10 10:17:50 +020033#include <openbsc/gsm_data.h>
34#include <openbsc/gsm_subscriber.h>
Harald Welteb54d9502009-11-17 06:00:23 +010035#include <openbsc/silent_call.h>
Holger Hans Peter Freythercfa90d42009-08-10 10:17:50 +020036#include <openbsc/gsm_04_11.h>
37#include <openbsc/e1_input.h>
38#include <openbsc/abis_nm.h>
Harald Weltedfe6c7d2010-02-20 16:24:02 +010039#include <osmocore/gsm_utils.h>
Holger Hans Peter Freythercfa90d42009-08-10 10:17:50 +020040#include <openbsc/db.h>
Harald Weltedfe6c7d2010-02-20 16:24:02 +010041#include <osmocore/talloc.h>
Harald Weltea1482332009-11-14 10:08:40 +010042#include <openbsc/signal.h>
Holger Hans Peter Freyther424c4f02010-01-06 06:00:40 +010043#include <openbsc/debug.h>
Holger Hans Peter Freythere0ec3262010-04-15 11:28:14 +020044#include <openbsc/vty.h>
Holger Hans Peter Freythercfa90d42009-08-10 10:17:50 +020045
46static struct gsm_network *gsmnet;
47
48struct cmd_node subscr_node = {
49 SUBSCR_NODE,
50 "%s(subscriber)#",
51 1,
52};
53
Harald Welte62ab20c2010-05-14 18:59:17 +020054/* Down vty node level. */
55DEFUN(subscr_node_exit,
56 subscr_node_exit_cmd, "exit", "Exit current mode and down to previous mode\n")
57{
58 switch (vty->node) {
59 case SUBSCR_NODE:
60 vty->node = VIEW_NODE;
61 subscr_put(vty->index);
62 vty->index = NULL;
63 break;
64 }
65 return CMD_SUCCESS;
66}
67
Holger Hans Peter Freythercfa90d42009-08-10 10:17:50 +020068static int dummy_config_write(struct vty *v)
69{
70 return CMD_SUCCESS;
71}
72
Sylvain Munaut99792902009-12-27 19:30:46 +010073static int hexparse(const char *str, u_int8_t *b, int max_len)
74
75{
76 int i, l, v;
77
78 l = strlen(str);
79 if ((l&1) || ((l>>1) > max_len))
80 return -1;
81
82 memset(b, 0x00, max_len);
83
84 for (i=0; i<l; i++) {
85 char c = str[i];
86 if (c >= '0' && c <= '9')
87 v = c - '0';
88 else if (c >= 'a' && c <= 'f')
89 v = 10 + (c - 'a');
90 else if (c >= 'A' && c <= 'F')
91 v = 10 + (c - 'a');
92 else
93 return -1;
94 b[i>>1] |= v << (i&1 ? 0 : 4);
95 }
96
97 return i>>1;
98}
99
Holger Hans Peter Freythercfa90d42009-08-10 10:17:50 +0200100/* per-subscriber configuration */
101DEFUN(cfg_subscr,
102 cfg_subscr_cmd,
103 "subscriber IMSI",
104 "Select a Subscriber to configure\n")
105{
106 const char *imsi = argv[0];
107 struct gsm_subscriber *subscr;
108
109 subscr = subscr_get_by_imsi(gsmnet, imsi);
110 if (!subscr) {
111 vty_out(vty, "%% No subscriber for IMSI %s%s",
112 imsi, VTY_NEWLINE);
113 return CMD_WARNING;
114 }
115
Holger Hans Peter Freythere33966c2009-10-27 12:47:06 +0100116 /* vty_go_parent should put this subscriber */
Holger Hans Peter Freythercfa90d42009-08-10 10:17:50 +0200117 vty->index = subscr;
118 vty->node = SUBSCR_NODE;
119
120 return CMD_SUCCESS;
121}
122
Holger Hans Peter Freyther424c4f02010-01-06 06:00:40 +0100123static void subscr_dump_full_vty(struct vty *vty, struct gsm_subscriber *subscr)
124{
125 int rc;
126 struct gsm_auth_info ainfo;
127 struct gsm_auth_tuple atuple;
128
129 vty_out(vty, " ID: %llu, Authorized: %d%s", subscr->id,
130 subscr->authorized, VTY_NEWLINE);
131 if (subscr->name)
132 vty_out(vty, " Name: '%s'%s", subscr->name, VTY_NEWLINE);
133 if (subscr->extension)
134 vty_out(vty, " Extension: %s%s", subscr->extension,
135 VTY_NEWLINE);
136 if (subscr->imsi)
137 vty_out(vty, " IMSI: %s%s", subscr->imsi, VTY_NEWLINE);
138 if (subscr->tmsi != GSM_RESERVED_TMSI)
139 vty_out(vty, " TMSI: %08X%s", subscr->tmsi,
140 VTY_NEWLINE);
141
142 rc = get_authinfo_by_subscr(&ainfo, subscr);
143 if (!rc) {
144 vty_out(vty, " A3A8 algorithm id: %d%s",
145 ainfo.auth_algo, VTY_NEWLINE);
146 vty_out(vty, " A3A8 Ki: %s%s",
147 hexdump(ainfo.a3a8_ki, ainfo.a3a8_ki_len),
148 VTY_NEWLINE);
149 }
150
151 rc = get_authtuple_by_subscr(&atuple, subscr);
152 if (!rc) {
153 vty_out(vty, " A3A8 last tuple (used %d times):%s",
154 atuple.use_count, VTY_NEWLINE);
155 vty_out(vty, " seq # : %d%s",
156 atuple.key_seq, VTY_NEWLINE);
157 vty_out(vty, " RAND : %s%s",
158 hexdump(atuple.rand, sizeof(atuple.rand)),
159 VTY_NEWLINE);
160 vty_out(vty, " SRES : %s%s",
161 hexdump(atuple.sres, sizeof(atuple.sres)),
162 VTY_NEWLINE);
163 vty_out(vty, " Kc : %s%s",
164 hexdump(atuple.kc, sizeof(atuple.kc)),
165 VTY_NEWLINE);
166 }
167
168 vty_out(vty, " Use count: %u%s", subscr->use_count, VTY_NEWLINE);
169}
170
171
Holger Hans Peter Freythercfa90d42009-08-10 10:17:50 +0200172/* Subscriber */
173DEFUN(show_subscr,
174 show_subscr_cmd,
175 "show subscriber [IMSI]",
176 SHOW_STR "Display information about a subscriber\n")
177{
178 const char *imsi;
179 struct gsm_subscriber *subscr;
180
181 if (argc >= 1) {
182 imsi = argv[0];
183 subscr = subscr_get_by_imsi(gsmnet, imsi);
184 if (!subscr) {
185 vty_out(vty, "%% unknown subscriber%s",
186 VTY_NEWLINE);
187 return CMD_WARNING;
188 }
Holger Hans Peter Freyther424c4f02010-01-06 06:00:40 +0100189 subscr_dump_full_vty(vty, subscr);
Holger Hans Peter Freythere33966c2009-10-27 12:47:06 +0100190 subscr_put(subscr);
Holger Hans Peter Freythercfa90d42009-08-10 10:17:50 +0200191
192 return CMD_SUCCESS;
193 }
194
195 /* FIXME: iterate over all subscribers ? */
196 return CMD_WARNING;
197
198 return CMD_SUCCESS;
199}
200
201DEFUN(show_subscr_cache,
202 show_subscr_cache_cmd,
203 "show subscriber cache",
204 SHOW_STR "Display contents of subscriber cache\n")
205{
206 struct gsm_subscriber *subscr;
207
208 llist_for_each_entry(subscr, &active_subscribers, entry) {
209 vty_out(vty, " Subscriber:%s", VTY_NEWLINE);
Holger Hans Peter Freyther424c4f02010-01-06 06:00:40 +0100210 subscr_dump_full_vty(vty, subscr);
Holger Hans Peter Freythercfa90d42009-08-10 10:17:50 +0200211 }
212
213 return CMD_SUCCESS;
214}
215
216DEFUN(sms_send_pend,
217 sms_send_pend_cmd,
Sylvain Munautff1f19e2009-12-22 13:22:29 +0100218 "sms send pending",
219 "Send all pending SMS")
Holger Hans Peter Freythercfa90d42009-08-10 10:17:50 +0200220{
221 struct gsm_sms *sms;
Sylvain Munautff1f19e2009-12-22 13:22:29 +0100222 int id = 0;
Holger Hans Peter Freythercfa90d42009-08-10 10:17:50 +0200223
224 while (1) {
Sylvain Munautff1f19e2009-12-22 13:22:29 +0100225 sms = db_sms_get_unsent_by_subscr(gsmnet, id);
Holger Hans Peter Freythercfa90d42009-08-10 10:17:50 +0200226 if (!sms)
Sylvain Munautff1f19e2009-12-22 13:22:29 +0100227 break;
Holger Hans Peter Freythercfa90d42009-08-10 10:17:50 +0200228
229 gsm411_send_sms_subscr(sms->receiver, sms);
Sylvain Munautff1f19e2009-12-22 13:22:29 +0100230
231 id = sms->receiver->id + 1;
Holger Hans Peter Freythercfa90d42009-08-10 10:17:50 +0200232 }
233
234 return CMD_SUCCESS;
235}
236
237struct gsm_sms *sms_from_text(struct gsm_subscriber *receiver, const char *text)
238{
239 struct gsm_sms *sms = sms_alloc();
240
241 if (!sms)
242 return NULL;
243
244 if (!receiver->lac) {
245 /* subscriber currently not attached, store in database? */
246 return NULL;
247 }
248
249 sms->receiver = subscr_get(receiver);
250 strncpy(sms->text, text, sizeof(sms->text)-1);
251
252 /* FIXME: don't use ID 1 static */
253 sms->sender = subscr_get_by_id(gsmnet, 1);
254 sms->reply_path_req = 0;
255 sms->status_rep_req = 0;
256 sms->ud_hdr_ind = 0;
257 sms->protocol_id = 0; /* implicit */
258 sms->data_coding_scheme = 0; /* default 7bit */
259 strncpy(sms->dest_addr, receiver->extension, sizeof(sms->dest_addr)-1);
260 /* Generate user_data */
261 sms->user_data_len = gsm_7bit_encode(sms->user_data, sms->text);
262
263 return sms;
264}
265
Harald Welte20474ad2010-05-16 19:28:32 +0200266static int _send_sms_str(struct gsm_subscriber *receiver, char *str,
267 u_int8_t tp_pid)
Holger Hans Peter Freythercfa90d42009-08-10 10:17:50 +0200268{
269 struct gsm_sms *sms;
270
Harald Welte20474ad2010-05-16 19:28:32 +0200271 sms = sms_from_text(receiver, str);
Harald Welte793a1352009-11-05 15:51:17 +0900272 sms->protocol_id = tp_pid;
Holger Hans Peter Freythercfa90d42009-08-10 10:17:50 +0200273 gsm411_send_sms_subscr(receiver, sms);
274
275 return CMD_SUCCESS;
276}
277
Harald Welte98f9c752009-11-14 08:00:53 +0100278static struct gsm_subscriber *get_subscr_by_argv(const char *type,
279 const char *id)
Holger Hans Peter Freythercfa90d42009-08-10 10:17:50 +0200280{
Harald Welte98f9c752009-11-14 08:00:53 +0100281 if (!strcmp(type, "extension"))
282 return subscr_get_by_extension(gsmnet, id);
283 else if (!strcmp(type, "imsi"))
284 return subscr_get_by_imsi(gsmnet, id);
285 else if (!strcmp(type, "tmsi"))
286 return subscr_get_by_tmsi(gsmnet, atoi(id));
287 else if (!strcmp(type, "id"))
288 return subscr_get_by_id(gsmnet, atoi(id));
289
290 return NULL;
291}
292#define SUBSCR_TYPES "(extension|imsi|tmsi|id)"
Harald Welte28326062010-05-14 20:05:17 +0200293#define SUBSCR_HELP "Operations on a Subscriber\n" \
294 "Identify subscriber by his extension (phone number)\n" \
295 "Identify subscriber by his IMSI\n" \
296 "Identify subscriber by his TMSI\n" \
297 "Identify subscriber by his database ID\n" \
298 "Identifier for the subscriber\n"
Harald Welte98f9c752009-11-14 08:00:53 +0100299
300DEFUN(subscriber_send_sms,
301 subscriber_send_sms_cmd,
302 "subscriber " SUBSCR_TYPES " EXTEN sms send .LINE",
Harald Welte28326062010-05-14 20:05:17 +0200303 SUBSCR_HELP "SMS Operations\n" "Send SMS\n" "Actual SMS Text")
Harald Welte98f9c752009-11-14 08:00:53 +0100304{
305 struct gsm_subscriber *subscr = get_subscr_by_argv(argv[0], argv[1]);
Harald Welte20474ad2010-05-16 19:28:32 +0200306 char *str;
Holger Hans Peter Freythercfa90d42009-08-10 10:17:50 +0200307 int rc;
308
Harald Welte20f98312009-11-14 10:11:45 +0100309 if (!subscr) {
310 vty_out(vty, "%% No subscriber found for %s %s%s",
311 argv[0], argv[1], VTY_NEWLINE);
Holger Hans Peter Freythercfa90d42009-08-10 10:17:50 +0200312 return CMD_WARNING;
Harald Welte20f98312009-11-14 10:11:45 +0100313 }
Harald Welte20474ad2010-05-16 19:28:32 +0200314 str = argv_concat(argv, argc, 2);
315 rc = _send_sms_str(subscr, str, 0);
316 talloc_free(str);
Harald Welte793a1352009-11-05 15:51:17 +0900317
Harald Welteaf8c7b42009-11-14 10:10:54 +0100318 subscr_put(subscr);
319
Harald Welte793a1352009-11-05 15:51:17 +0900320 return rc;
321}
322
Harald Welte98f9c752009-11-14 08:00:53 +0100323DEFUN(subscriber_silent_sms,
324 subscriber_silent_sms_cmd,
Harald Welte28326062010-05-14 20:05:17 +0200325 "subscriber " SUBSCR_TYPES " EXTEN silent-sms send .LINE",
326 SUBSCR_HELP
327 "Silent SMS Operation\n" "Send Silent SMS\n" "Actual SMS text\n")
Harald Welte793a1352009-11-05 15:51:17 +0900328{
Harald Welte98f9c752009-11-14 08:00:53 +0100329 struct gsm_subscriber *subscr = get_subscr_by_argv(argv[0], argv[1]);
Harald Welte20474ad2010-05-16 19:28:32 +0200330 char *str;
Harald Welte793a1352009-11-05 15:51:17 +0900331 int rc;
332
Harald Welte20f98312009-11-14 10:11:45 +0100333 if (!subscr) {
334 vty_out(vty, "%% No subscriber found for %s %s%s",
335 argv[0], argv[1], VTY_NEWLINE);
Harald Welte793a1352009-11-05 15:51:17 +0900336 return CMD_WARNING;
Harald Welte20f98312009-11-14 10:11:45 +0100337 }
Harald Welte793a1352009-11-05 15:51:17 +0900338
Harald Welte20474ad2010-05-16 19:28:32 +0200339 str = argv_concat(argv, argc, 2);
340 rc = _send_sms_str(subscr, str, 0);
341 talloc_free(str);
Harald Welte793a1352009-11-05 15:51:17 +0900342
Harald Welteaf8c7b42009-11-14 10:10:54 +0100343 subscr_put(subscr);
344
Harald Welte793a1352009-11-05 15:51:17 +0900345 return rc;
346}
347
Harald Welte28326062010-05-14 20:05:17 +0200348#define CHAN_TYPES "(any|tch/f|tch/any|sdcch)"
349#define CHAN_TYPE_HELP \
350 "Any channel\n" \
351 "TCH/F channel\n" \
352 "Any TCH channel\n" \
353 "SDCCH channel\n"
354
Sylvain Munaut50480702010-01-02 14:29:43 +0100355DEFUN(subscriber_silent_call_start,
356 subscriber_silent_call_start_cmd,
Harald Welte28326062010-05-14 20:05:17 +0200357 "subscriber " SUBSCR_TYPES " EXTEN silent-call start (any|tch/f|tch/any|sdcch)",
358 SUBSCR_HELP "Silent call operation\n" "Start silent call\n"
359 CHAN_TYPE_HELP)
Sylvain Munaut50480702010-01-02 14:29:43 +0100360{
361 struct gsm_subscriber *subscr = get_subscr_by_argv(argv[0], argv[1]);
362 int rc, type;
363
364 if (!subscr) {
365 vty_out(vty, "%% No subscriber found for %s %s%s",
366 argv[0], argv[1], VTY_NEWLINE);
367 return CMD_WARNING;
368 }
369
370 if (!strcmp(argv[2], "tch/f"))
371 type = RSL_CHANNEED_TCH_F;
372 else if (!strcmp(argv[2], "tch/any"))
373 type = RSL_CHANNEED_TCH_ForH;
374 else if (!strcmp(argv[2], "sdcch"))
375 type = RSL_CHANNEED_SDCCH;
376 else
377 type = RSL_CHANNEED_ANY; /* Defaults to ANY */
378
379 rc = gsm_silent_call_start(subscr, vty, type);
380 if (rc <= 0) {
381 vty_out(vty, "%% Subscriber not attached%s",
382 VTY_NEWLINE);
383 subscr_put(subscr);
384 return CMD_WARNING;
385 }
386
387 subscr_put(subscr);
388
389 return CMD_SUCCESS;
390}
391
392DEFUN(subscriber_silent_call_stop,
393 subscriber_silent_call_stop_cmd,
Harald Welte28326062010-05-14 20:05:17 +0200394 "subscriber " SUBSCR_TYPES " EXTEN silent-call stop",
395 SUBSCR_HELP "Silent call operation\n" "Stop silent call\n"
396 CHAN_TYPE_HELP)
Harald Weltea1482332009-11-14 10:08:40 +0100397{
398 struct gsm_subscriber *subscr = get_subscr_by_argv(argv[0], argv[1]);
399 int rc;
400
401 if (!subscr) {
402 vty_out(vty, "%% No subscriber found for %s %s%s",
Harald Welte20f98312009-11-14 10:11:45 +0100403 argv[0], argv[1], VTY_NEWLINE);
Harald Weltea1482332009-11-14 10:08:40 +0100404 return CMD_WARNING;
405 }
406
Sylvain Munaut50480702010-01-02 14:29:43 +0100407 rc = gsm_silent_call_stop(subscr);
408 if (rc < 0) {
409 subscr_put(subscr);
410 return CMD_WARNING;
Harald Weltea1482332009-11-14 10:08:40 +0100411 }
412
413 subscr_put(subscr);
414
415 return CMD_SUCCESS;
416}
417
Holger Hans Peter Freythercfa90d42009-08-10 10:17:50 +0200418DEFUN(cfg_subscr_name,
419 cfg_subscr_name_cmd,
420 "name NAME",
421 "Set the name of the subscriber")
422{
423 const char *name = argv[0];
424 struct gsm_subscriber *subscr = vty->index;
425
426 strncpy(subscr->name, name, sizeof(subscr->name));
427
428 db_sync_subscriber(subscr);
429
430 return CMD_SUCCESS;
431}
432
433DEFUN(cfg_subscr_extension,
434 cfg_subscr_extension_cmd,
435 "extension EXTENSION",
436 "Set the extension of the subscriber")
437{
438 const char *name = argv[0];
439 struct gsm_subscriber *subscr = vty->index;
440
441 strncpy(subscr->extension, name, sizeof(subscr->extension));
442
443 db_sync_subscriber(subscr);
444
445 return CMD_SUCCESS;
446}
447
448DEFUN(cfg_subscr_authorized,
449 cfg_subscr_authorized_cmd,
Harald Welte28326062010-05-14 20:05:17 +0200450 "auth (0|1)",
451 "Set the authorization status of the subscriber\n"
452 "Not authorized\n" "Authorized\n")
Holger Hans Peter Freythercfa90d42009-08-10 10:17:50 +0200453{
454 int auth = atoi(argv[0]);
455 struct gsm_subscriber *subscr = vty->index;
456
457 if (auth)
458 subscr->authorized = 1;
459 else
460 subscr->authorized = 0;
461
462 db_sync_subscriber(subscr);
463
464 return CMD_SUCCESS;
465}
466
Sylvain Munaut99792902009-12-27 19:30:46 +0100467#define A3A8_ALG_TYPES "(none|comp128v1)"
Harald Welte28326062010-05-14 20:05:17 +0200468#define A3A8_ALG_HELP \
469 "Use No A3A8 algorithm\n" \
470 "Use COMP128v1 algorithm\n"
Sylvain Munaut99792902009-12-27 19:30:46 +0100471
472DEFUN(cfg_subscr_a3a8,
473 cfg_subscr_a3a8_cmd,
474 "a3a8 " A3A8_ALG_TYPES " [KI]",
Harald Welte28326062010-05-14 20:05:17 +0200475 "Set a3a8 parameters for the subscriber\n" A3A8_ALG_HELP
476 "Encryption Key Ki\n")
Sylvain Munaut99792902009-12-27 19:30:46 +0100477{
478 struct gsm_subscriber *subscr = vty->index;
479 const char *alg_str = argv[0];
480 const char *ki_str = argv[1];
481 struct gsm_auth_info ainfo;
482 int rc;
483
484 if (!strcasecmp(alg_str, "none")) {
485 /* Just erase */
486 rc = set_authinfo_for_subscr(NULL, subscr);
487 } else if (!strcasecmp(alg_str, "comp128v1")) {
488 /* Parse hex string Ki */
489 rc = hexparse(ki_str, ainfo.a3a8_ki, sizeof(ainfo.a3a8_ki));
490 if (rc != 16)
491 return CMD_WARNING;
492
493 /* Set the infos */
494 ainfo.auth_algo = AUTH_ALGO_COMP128v1;
495 ainfo.a3a8_ki_len = rc;
496 rc = set_authinfo_for_subscr(&ainfo, subscr);
497 } else {
498 /* Unknown method */
499 return CMD_WARNING;
500 }
501
502 return rc ? CMD_WARNING : CMD_SUCCESS;
503}
504
Harald Weltea1482332009-11-14 10:08:40 +0100505static int scall_cbfn(unsigned int subsys, unsigned int signal,
506 void *handler_data, void *signal_data)
507{
508 struct scall_signal_data *sigdata = signal_data;
509 struct vty *vty = sigdata->data;
510
511 switch (signal) {
512 case S_SCALL_SUCCESS:
513 vty_out(vty, "%% silent call on ARFCN %u timeslot %u%s",
514 sigdata->lchan->ts->trx->arfcn, sigdata->lchan->ts->nr,
515 VTY_NEWLINE);
516 break;
517 case S_SCALL_EXPIRED:
518 vty_out(vty, "%% silent call expired paging%s", VTY_NEWLINE);
519 break;
520 }
521 return 0;
522}
523
Holger Hans Peter Freythere0ec3262010-04-15 11:28:14 +0200524DEFUN(show_stats,
525 show_stats_cmd,
526 "show statistics",
527 SHOW_STR "Display network statistics\n")
528{
529 struct gsm_network *net = gsmnet;
530
531 openbsc_vty_print_statistics(vty, net);
532 vty_out(vty, "Location Update : %lu attach, %lu normal, %lu periodic%s",
533 counter_get(net->stats.loc_upd_type.attach),
534 counter_get(net->stats.loc_upd_type.normal),
535 counter_get(net->stats.loc_upd_type.periodic), VTY_NEWLINE);
536 vty_out(vty, "IMSI Detach Indications : %lu%s",
537 counter_get(net->stats.loc_upd_type.detach), VTY_NEWLINE);
538 vty_out(vty, "Location Update Response: %lu accept, %lu reject%s",
539 counter_get(net->stats.loc_upd_resp.accept),
540 counter_get(net->stats.loc_upd_resp.reject), VTY_NEWLINE);
541 vty_out(vty, "Handover : %lu attempted, %lu no_channel, %lu timeout, "
542 "%lu completed, %lu failed%s",
543 counter_get(net->stats.handover.attempted),
544 counter_get(net->stats.handover.no_channel),
545 counter_get(net->stats.handover.timeout),
546 counter_get(net->stats.handover.completed),
547 counter_get(net->stats.handover.failed), VTY_NEWLINE);
548 vty_out(vty, "SMS MO : %lu submitted, %lu no receiver%s",
549 counter_get(net->stats.sms.submitted),
550 counter_get(net->stats.sms.no_receiver), VTY_NEWLINE);
551 vty_out(vty, "SMS MT : %lu delivered, %lu no memory, %lu other error%s",
552 counter_get(net->stats.sms.delivered),
553 counter_get(net->stats.sms.rp_err_mem),
554 counter_get(net->stats.sms.rp_err_other), VTY_NEWLINE);
555 return CMD_SUCCESS;
556}
557
558
Holger Hans Peter Freythercfa90d42009-08-10 10:17:50 +0200559int bsc_vty_init_extra(struct gsm_network *net)
560{
561 gsmnet = net;
562
Harald Weltea1482332009-11-14 10:08:40 +0100563 register_signal_handler(SS_SCALL, scall_cbfn, NULL);
564
Harald Welteb4d5b172010-05-12 16:10:35 +0000565 install_element_ve(&show_subscr_cmd);
566 install_element_ve(&show_subscr_cache_cmd);
Holger Hans Peter Freythercfa90d42009-08-10 10:17:50 +0200567
Harald Welteb4d5b172010-05-12 16:10:35 +0000568 install_element_ve(&sms_send_pend_cmd);
Harald Welte98f9c752009-11-14 08:00:53 +0100569
Harald Welteb4d5b172010-05-12 16:10:35 +0000570 install_element_ve(&subscriber_send_sms_cmd);
571 install_element_ve(&subscriber_silent_sms_cmd);
572 install_element_ve(&subscriber_silent_call_start_cmd);
573 install_element_ve(&subscriber_silent_call_stop_cmd);
574 install_element_ve(&show_stats_cmd);
Holger Hans Peter Freythercfa90d42009-08-10 10:17:50 +0200575
576 install_element(CONFIG_NODE, &cfg_subscr_cmd);
577 install_node(&subscr_node, dummy_config_write);
578
579 install_default(SUBSCR_NODE);
Harald Welte62ab20c2010-05-14 18:59:17 +0200580 install_element(SUBSCR_NODE, &subscr_node_exit_cmd);
Holger Hans Peter Freythercfa90d42009-08-10 10:17:50 +0200581 install_element(SUBSCR_NODE, &cfg_subscr_name_cmd);
582 install_element(SUBSCR_NODE, &cfg_subscr_extension_cmd);
583 install_element(SUBSCR_NODE, &cfg_subscr_authorized_cmd);
Sylvain Munaut99792902009-12-27 19:30:46 +0100584 install_element(SUBSCR_NODE, &cfg_subscr_a3a8_cmd);
Holger Hans Peter Freythercfa90d42009-08-10 10:17:50 +0200585
586 return 0;
587}