[vty] Move db usage out of the libbsc (fork dumping of subscr)

vty_interface.c is part of libbsc.a but it started to use code
which is found in db.c recently. Fork the subscriber dumping and
provide more information on the layer3+ (MSC) commands. This
is restoring the separation again.
This commit is contained in:
Holger Hans Peter Freyther 2010-01-06 06:00:40 +01:00
parent 0a77fa17bc
commit 1dd0a1b9aa
2 changed files with 53 additions and 6 deletions

View File

@ -512,7 +512,7 @@ DEFUN(show_ts,
return CMD_SUCCESS;
}
void subscr_dump_vty(struct vty *vty, struct gsm_subscriber *subscr)
static void subscr_dump_vty(struct vty *vty, struct gsm_subscriber *subscr)
{
int rc;
struct gsm_auth_info ainfo;

View File

@ -40,9 +40,7 @@
#include <openbsc/db.h>
#include <openbsc/talloc.h>
#include <openbsc/signal.h>
/* forward declarations */
void subscr_dump_vty(struct vty *vty, struct gsm_subscriber *subscr);
#include <openbsc/debug.h>
static struct gsm_network *gsmnet;
@ -124,6 +122,55 @@ DEFUN(cfg_subscr,
return CMD_SUCCESS;
}
static void subscr_dump_full_vty(struct vty *vty, struct gsm_subscriber *subscr)
{
int rc;
struct gsm_auth_info ainfo;
struct gsm_auth_tuple atuple;
vty_out(vty, " ID: %llu, Authorized: %d%s", subscr->id,
subscr->authorized, VTY_NEWLINE);
if (subscr->name)
vty_out(vty, " Name: '%s'%s", subscr->name, VTY_NEWLINE);
if (subscr->extension)
vty_out(vty, " Extension: %s%s", subscr->extension,
VTY_NEWLINE);
if (subscr->imsi)
vty_out(vty, " IMSI: %s%s", subscr->imsi, VTY_NEWLINE);
if (subscr->tmsi != GSM_RESERVED_TMSI)
vty_out(vty, " TMSI: %08X%s", subscr->tmsi,
VTY_NEWLINE);
rc = get_authinfo_by_subscr(&ainfo, subscr);
if (!rc) {
vty_out(vty, " A3A8 algorithm id: %d%s",
ainfo.auth_algo, VTY_NEWLINE);
vty_out(vty, " A3A8 Ki: %s%s",
hexdump(ainfo.a3a8_ki, ainfo.a3a8_ki_len),
VTY_NEWLINE);
}
rc = get_authtuple_by_subscr(&atuple, subscr);
if (!rc) {
vty_out(vty, " A3A8 last tuple (used %d times):%s",
atuple.use_count, VTY_NEWLINE);
vty_out(vty, " seq # : %d%s",
atuple.key_seq, VTY_NEWLINE);
vty_out(vty, " RAND : %s%s",
hexdump(atuple.rand, sizeof(atuple.rand)),
VTY_NEWLINE);
vty_out(vty, " SRES : %s%s",
hexdump(atuple.sres, sizeof(atuple.sres)),
VTY_NEWLINE);
vty_out(vty, " Kc : %s%s",
hexdump(atuple.kc, sizeof(atuple.kc)),
VTY_NEWLINE);
}
vty_out(vty, " Use count: %u%s", subscr->use_count, VTY_NEWLINE);
}
/* Subscriber */
DEFUN(show_subscr,
show_subscr_cmd,
@ -141,7 +188,7 @@ DEFUN(show_subscr,
VTY_NEWLINE);
return CMD_WARNING;
}
subscr_dump_vty(vty, subscr);
subscr_dump_full_vty(vty, subscr);
subscr_put(subscr);
return CMD_SUCCESS;
@ -162,7 +209,7 @@ DEFUN(show_subscr_cache,
llist_for_each_entry(subscr, &active_subscribers, entry) {
vty_out(vty, " Subscriber:%s", VTY_NEWLINE);
subscr_dump_vty(vty, subscr);
subscr_dump_full_vty(vty, subscr);
}
return CMD_SUCCESS;