vty: Add simple VTY output for current calls

Start with a show call summary that lists simple data about the
current set of calls:

Call(5002) initial(type=SIP,state=CONFIRMED) remote(type=MNCC,state=INITIAL)
Call(5001) initial(type=MNCC,state=PROCEEDING) remote(type=SIP,state=CONFIRMED)

Related: OS#1680
changes/26/126/1
Holger Hans Peter Freyther 7 years ago
parent b2b13f69ae
commit c39c3df251
  1. 56
      src/call.c
  2. 10
      src/call.h
  3. 43
      src/vty.c

@ -28,6 +28,40 @@ extern void *tall_mncc_ctx;
LLIST_HEAD(g_call_list);
static uint32_t last_call_id = 5000;
const struct value_string call_type_vals[] = {
{ CALL_TYPE_NONE, "NONE" },
{ CALL_TYPE_SIP, "SIP" },
{ CALL_TYPE_MNCC, "MNCC" },
{ 0, NULL },
};
const struct value_string mncc_state_vals[] = {
{ MNCC_CC_INITIAL, "INITIAL" },
{ MNCC_CC_PROCEEDING, "PROCEEDING" },
{ MNCC_CC_CONNECTED, "CONNECTED" },
{ 0, NULL },
};
const struct value_string mncc_dir_vals[] = {
{ MNCC_DIR_MO, "MO" },
{ MNCC_DIR_MT, "MT" },
{ 0, NULL },
};
const struct value_string sip_state_vals[] = {
{ SIP_CC_INITIAL, "INITIAL" },
{ SIP_CC_DLG_CNFD, "CONFIRMED" },
{ SIP_CC_CONNECTED, "CONNECTED" },
{ 0, NULL },
};
const struct value_string sip_dir_vals[] = {
{ SIP_DIR_MO, "MO" },
{ SIP_DIR_MT, "MT" },
{ 0, NULL },
};
void calls_init(void)
{}
@ -114,3 +148,25 @@ struct call_leg *call_leg_other(struct call_leg *leg)
leg, leg->call->id);
return NULL;
}
const char *call_leg_type(struct call_leg *leg)
{
return get_value_string(call_type_vals, leg->type);
}
const char *call_leg_state(struct call_leg *leg)
{
struct mncc_call_leg *mncc;
struct sip_call_leg *sip;
switch (leg->type) {
case CALL_TYPE_SIP:
sip = (struct sip_call_leg *) leg;
return get_value_string(sip_state_vals, sip->state);
case CALL_TYPE_MNCC:
mncc = (struct mncc_call_leg *) leg;
return get_value_string(mncc_state_vals, mncc->state);
default:
return "unknown call type";
}
}

@ -4,6 +4,7 @@
#include <osmocom/core/linuxlist.h>
#include <osmocom/core/timer.h>
#include <osmocom/core/utils.h>
#include <stdbool.h>
@ -133,3 +134,12 @@ void call_leg_release(struct call_leg *leg);
struct call *call_mncc_create(void);
struct call *call_sip_create(void);
const char *call_leg_type(struct call_leg *leg);
const char *call_leg_state(struct call_leg *leg);
extern const struct value_string call_type_vals[];
extern const struct value_string mncc_state_vals[];
extern const struct value_string mncc_dir_vals[];
extern const struct value_string sip_state_vals[];
extern const struct value_string sip_dir_vals[];

@ -20,6 +20,7 @@
#include "vty.h"
#include "app.h"
#include "call.h"
#include <talloc.h>
@ -171,6 +172,46 @@ DEFUN(cfg_no_use_imsi, cfg_no_use_imsi_cmd,
return CMD_SUCCESS;
}
DEFUN(show_calls_sum, show_calls_sum_cmd,
"show calls summary",
SHOW_STR "Current calls\n")
{
struct call *call;
llist_for_each_entry(call, &g_call_list, entry) {
char *initial_type, *initial_state;
char *remote_type, *remote_state;
initial_type = initial_state = NULL;
remote_type = remote_state = NULL;
if (call->initial) {
initial_type = talloc_strdup(tall_mncc_ctx,
call_leg_type(call->initial));
initial_state = talloc_strdup(tall_mncc_ctx,
call_leg_state(call->initial));
}
if (call->remote) {
remote_type = talloc_strdup(tall_mncc_ctx,
call_leg_type(call->remote));
remote_state = talloc_strdup(tall_mncc_ctx,
call_leg_state(call->remote));
}
vty_out(vty, "Call(%u) initial(type=%s,state=%s) remote(type=%s,state=%s)%s",
call->id, initial_type, initial_state, remote_type, remote_state,
VTY_NEWLINE);
talloc_free(initial_type);
talloc_free(initial_state);
talloc_free(remote_type);
talloc_free(remote_state);
}
return CMD_SUCCESS;
}
void mncc_sip_vty_init(void)
{
/* default values */
@ -196,4 +237,6 @@ void mncc_sip_vty_init(void)
install_node(&app_node, config_write_app);
install_element(APP_NODE, &cfg_use_imsi_cmd);
install_element(APP_NODE, &cfg_no_use_imsi_cmd);
install_element_ve(&show_calls_sum_cmd);
}

Loading…
Cancel
Save