[asterisk-commits] tzafrir: branch tzafrir/monitor-rtp-14 r213889 - /team/tzafrir/monitor-rtp-14...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Mon Aug 24 18:18:38 CDT 2009
Author: tzafrir
Date: Mon Aug 24 18:18:35 2009
New Revision: 213889
URL: http://svn.asterisk.org/svn-view/asterisk?view=rev&rev=213889
Log:
monitor.conf: basic res_monitor code to read it
Add reload_config in res_monitor.c to read a monitor.conf file.
The module does not yet actually load the configuration on (re)load.
Modified:
team/tzafrir/monitor-rtp-14/res/res_monitor.c
Modified: team/tzafrir/monitor-rtp-14/res/res_monitor.c
URL: http://svn.asterisk.org/svn-view/asterisk/team/tzafrir/monitor-rtp-14/res/res_monitor.c?view=diff&rev=213889&r1=213888&r2=213889
==============================================================================
--- team/tzafrir/monitor-rtp-14/res/res_monitor.c (original)
+++ team/tzafrir/monitor-rtp-14/res/res_monitor.c Mon Aug 24 18:18:35 2009
@@ -63,6 +63,11 @@
static unsigned long seq = 0;
+static const char *config_file = "monitor.conf";
+static char rtp_server_name[BUFSIZ];
+static char reporting_host[BUFSIZ];
+static in_port_t rtp_portbase_rx = 9000;
+static in_port_t rtp_portbase_tx = 11000;
static char *monitor_synopsis = "Monitor a channel";
static char *monitor_descrip = "Monitor([file_format[:urlbase]|[fname_base]|[options]]):\n"
@@ -670,6 +675,55 @@
return do_pause_or_unpause(s, m, MONITOR_ACTION_UNPAUSE);
}
+static int reload_config(enum channelreloadreason reason)
+{
+ struct ast_config *cfg;
+ struct ast_variable *v;
+
+ ast_log(LOG_DEBUG, "%s [%s]\n", channelreloadreason2txt(reason), config_file);
+ cfg = ast_config_load(config_file);
+ if (!cfg) {
+ ast_log(LOG_NOTICE, "Unable to load config %s. No monitoring to RTP\n", config_file);
+ return 0;
+ }
+ rtp_server_name[0] = '\0';
+ for (v = ast_variable_browse(cfg, "general"); v; v = v->next) {
+ if (!strcasecmp(v->name, "rtp_server")) {
+ ast_copy_string(rtp_server_name, v->value, sizeof(rtp_server_name));
+ } else if (!strcasecmp(v->name, "rtp_portbase_rx")) {
+ char portstr[BUFSIZ];
+ unsigned int port_value;
+
+ ast_copy_string(portstr, v->value, sizeof(portstr));
+ if ((sscanf(v->value, "%u", &port_value) != 1) /* TBD: || (port_value > MAXPORTNUM) */) {
+ ast_log(LOG_WARNING, "%s:%d: invalid port number '%s'.\n",
+ config_file, v->lineno, v->value);
+ } else {
+ rtp_portbase_rx = port_value;
+ }
+ } else if (!strcasecmp(v->name, "rtp_portbase_tx")) {
+ char portstr[BUFSIZ];
+ unsigned int port_value;
+
+ ast_copy_string(portstr, v->value, sizeof(portstr));
+ if ((sscanf(v->value, "%u", &port_value) != 1) /* TBD: || (port_value > MAXPORTNUM) */) {
+ ast_log(LOG_WARNING, "%s:%d: invalid port number '%s'.\n",
+ config_file, v->lineno, v->value);
+ } else {
+ rtp_portbase_tx = port_value;
+ }
+ } else if (!strcasecmp(v->name, "reporting_host")) {
+ ast_copy_string(reporting_host, v->value, sizeof(reporting_host));
+ } else {
+ ast_log(LOG_NOTICE, "%s:%d: Bad config option '%s' - (ignoring)\n",
+ config_file, v->lineno, v->name);
+ }
+ }
+ ast_log(LOG_DEBUG, "monitor to %s [RX=%d, TX=%d]\n",
+ rtp_server_name, rtp_portbase_rx, rtp_portbase_tx);
+ ast_config_destroy(cfg);
+ return 0;
+}
static int load_module(void)
{
More information about the asterisk-commits
mailing list