[svn-commits] tzafrir: branch tzafrir/monitor-rtp r214066 - /team/tzafrir/monitor-rtp/res/

SVN commits to the Digium repositories svn-commits at lists.digium.com
Tue Aug 25 14:07:05 CDT 2009


Author: tzafrir
Date: Tue Aug 25 14:07:01 2009
New Revision: 214066

URL: http://svn.asterisk.org/svn-view/asterisk?view=rev&rev=214066
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/res/res_monitor.c

Modified: team/tzafrir/monitor-rtp/res/res_monitor.c
URL: http://svn.asterisk.org/svn-view/asterisk/team/tzafrir/monitor-rtp/res/res_monitor.c?view=diff&rev=214066&r1=214065&r2=214066
==============================================================================
--- team/tzafrir/monitor-rtp/res/res_monitor.c (original)
+++ team/tzafrir/monitor-rtp/res/res_monitor.c Tue Aug 25 14:07:01 2009
@@ -253,6 +253,12 @@
 
 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;
+
 /*! 
  * \brief Change state of monitored channel 
  * \param chan 
@@ -858,6 +864,57 @@
 	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;
+	/* FIXME: config flags for ast_config_load: */
+	struct ast_flags	config_flags = {};
+
+	ast_log(LOG_DEBUG, "%s [%s]\n", channelreloadreason2txt(reason), config_file);
+	cfg = ast_config_load(config_file, config_flags);
+	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 svn-commits mailing list