summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorHolger Hans Peter Freyther <holger@moiji-mobile.com>2016-04-04 17:06:29 +0200
committerHolger Hans Peter Freyther <holger@moiji-mobile.com>2016-04-04 17:09:30 +0200
commitc39c3df2514b41d98c3ee1c2b32d422ea74513c2 (patch)
tree153c2aab3d32ce66bf7038d874b24809717cf25e /src
parentb2b13f69ae5916477ea3f6e37b57b52a83ac5a63 (diff)
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
Diffstat (limited to 'src')
-rw-r--r--src/call.c56
-rw-r--r--src/call.h10
-rw-r--r--src/vty.c43
3 files changed, 109 insertions, 0 deletions
diff --git a/src/call.c b/src/call.c
index 1316205..9be6b4d 100644
--- a/src/call.c
+++ b/src/call.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";
+ }
+}
diff --git a/src/call.h b/src/call.h
index b6cb8bf..e844485 100644
--- a/src/call.h
+++ b/src/call.h
@@ -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[];
diff --git a/src/vty.c b/src/vty.c
index 191cec8..36c273e 100644
--- a/src/vty.c
+++ b/src/vty.c
@@ -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);
}