summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorAlfred E. Heggestad <aeh@db.org>2016-07-30 11:21:44 +0200
committerAlfred E. Heggestad <aeh@db.org>2016-07-30 11:21:44 +0200
commit85e7ca656ea838805a702df278d1d73a2fb8f684 (patch)
treee2c0afe59e864efcd24b5c044ddba47e9061ad3d /modules
parent49ea18057b64e2a806d6799bc2aa87b30491634e (diff)
debug_cmd.so: new module for Debug Commands
move some debug commands from menu.so to debug_cmd.so
Diffstat (limited to 'modules')
-rw-r--r--modules/debug_cmd/debug_cmd.c87
-rw-r--r--modules/debug_cmd/module.mk10
-rw-r--r--modules/menu/menu.c43
3 files changed, 97 insertions, 43 deletions
diff --git a/modules/debug_cmd/debug_cmd.c b/modules/debug_cmd/debug_cmd.c
new file mode 100644
index 0000000..19d3adb
--- /dev/null
+++ b/modules/debug_cmd/debug_cmd.c
@@ -0,0 +1,87 @@
+/**
+ * @file debug_cmd.c Debug commands
+ *
+ * Copyright (C) 2010 - 2016 Creytiv.com
+ */
+#include <stdlib.h>
+#include <time.h>
+#include <re.h>
+#include <baresip.h>
+
+
+static uint64_t start_ticks; /**< Ticks when app started */
+static time_t start_time; /**< Start time of application */
+
+
+static int cmd_net_debug(struct re_printf *pf, void *unused)
+{
+ (void)unused;
+ return net_debug(pf, baresip_network());
+}
+
+
+static int print_system_info(struct re_printf *pf, void *arg)
+{
+ uint32_t uptime;
+ int err = 0;
+
+ (void)arg;
+
+ uptime = (uint32_t)((long long)(tmr_jiffies() - start_ticks)/1000);
+
+ err |= re_hprintf(pf, "\n--- System info: ---\n");
+
+ err |= re_hprintf(pf, " Machine: %s/%s\n", sys_arch_get(),
+ sys_os_get());
+ err |= re_hprintf(pf, " Version: %s (libre v%s)\n",
+ BARESIP_VERSION, sys_libre_version_get());
+ err |= re_hprintf(pf, " Build: %H\n", sys_build_get, NULL);
+ err |= re_hprintf(pf, " Kernel: %H\n", sys_kernel_get, NULL);
+ err |= re_hprintf(pf, " Uptime: %H\n", fmt_human_time, &uptime);
+ err |= re_hprintf(pf, " Started: %s", ctime(&start_time));
+
+#ifdef __VERSION__
+ err |= re_hprintf(pf, " Compiler: %s\n", __VERSION__);
+#endif
+
+ return err;
+}
+
+
+static const struct cmd debugcmdv[] = {
+ {'M', 0, "Main loop debug", re_debug },
+ {'m', 0, "Module debug", mod_debug },
+ {'n', 0, "Network debug", cmd_net_debug },
+ {'s', 0, "System info", print_system_info },
+ {'t', 0, "Timer debug", tmr_status },
+ {'y', 0, "Memory status", mem_status },
+};
+
+
+static int module_init(void)
+{
+ int err;
+
+ start_ticks = tmr_jiffies();
+ (void)time(&start_time);
+
+ err = cmd_register(debugcmdv, ARRAY_SIZE(debugcmdv));
+
+ return err;
+}
+
+
+static int module_close(void)
+{
+ cmd_unregister(debugcmdv);
+
+ return 0;
+}
+
+
+const struct mod_export DECL_EXPORTS(debug_cmd) = {
+ "debug_cmd",
+ "application",
+ module_init,
+ module_close
+};
diff --git a/modules/debug_cmd/module.mk b/modules/debug_cmd/module.mk
new file mode 100644
index 0000000..3680314
--- /dev/null
+++ b/modules/debug_cmd/module.mk
@@ -0,0 +1,10 @@
+#
+# module.mk
+#
+# Copyright (C) 2010 Creytiv.com
+#
+
+MOD := debug_cmd
+$(MOD)_SRCS += debug_cmd.c
+
+include mk/mod.mk
diff --git a/modules/menu/menu.c b/modules/menu/menu.c
index c8cfc7b..c1f089c 100644
--- a/modules/menu/menu.c
+++ b/modules/menu/menu.c
@@ -27,7 +27,6 @@ enum statmode {
static uint64_t start_ticks; /**< Ticks when app started */
-static time_t start_time; /**< Start time of application */
static struct tmr tmr_alert; /**< Incoming call alert timer */
static struct tmr tmr_stat; /**< Call status timer */
static enum statmode statmode; /**< Status mode */
@@ -125,34 +124,6 @@ static bool have_active_calls(void)
}
-static int print_system_info(struct re_printf *pf, void *arg)
-{
- uint32_t uptime;
- int err = 0;
-
- (void)arg;
-
- uptime = (uint32_t)((long long)(tmr_jiffies() - start_ticks)/1000);
-
- err |= re_hprintf(pf, "\n--- System info: ---\n");
-
- err |= re_hprintf(pf, " Machine: %s/%s\n", sys_arch_get(),
- sys_os_get());
- err |= re_hprintf(pf, " Version: %s (libre v%s)\n",
- BARESIP_VERSION, sys_libre_version_get());
- err |= re_hprintf(pf, " Build: %H\n", sys_build_get, NULL);
- err |= re_hprintf(pf, " Kernel: %H\n", sys_kernel_get, NULL);
- err |= re_hprintf(pf, " Uptime: %H\n", fmt_human_time, &uptime);
- err |= re_hprintf(pf, " Started: %s", ctime(&start_time));
-
-#ifdef __VERSION__
- err |= re_hprintf(pf, " Compiler: %s\n", __VERSION__);
-#endif
-
- return err;
-}
-
-
/**
* Print the SIP Registration for all User-Agents
*
@@ -442,15 +413,7 @@ static int cmd_config_print(struct re_printf *pf, void *unused)
}
-static int cmd_net_debug(struct re_printf *pf, void *unused)
-{
- (void)unused;
- return net_debug(pf, baresip_network());
-}
-
-
static const struct cmd cmdv[] = {
- {'M', 0, "Main loop debug", re_debug },
{'\n', 0, "Accept incoming call", cmd_answer },
{'D', 0, "Accept incoming call", cmd_answer },
{'b', 0, "Hangup call", cmd_hangup },
@@ -459,14 +422,9 @@ static const struct cmd cmdv[] = {
{'h', 0, "Help menu", cmd_print },
{'i', 0, "SIP debug", ua_print_sip_status },
{'l', 0, "List active calls", cmd_print_calls },
- {'m', 0, "Module debug", mod_debug },
- {'n', 0, "Network debug", cmd_net_debug },
{'o', CMD_PRM, "Options", options_command },
{'r', 0, "Registration info", ua_print_reg_status },
- {'s', 0, "System info", print_system_info },
- {'t', 0, "Timer debug", tmr_status },
{'u', 0, "UA debug", cmd_ua_debug },
- {'y', 0, "Memory status", mem_status },
{0x1b, 0, "Hangup call", cmd_hangup },
{' ', 0, "Toggle UAs", cmd_ua_next },
{'T', 0, "Toggle UAs", cmd_ua_next },
@@ -1023,7 +981,6 @@ static int module_init(void)
return ENOMEM;
start_ticks = tmr_jiffies();
- (void)time(&start_time);
tmr_init(&tmr_alert);
statmode = STATMODE_CALL;