[asterisk-commits] seanbright: branch seanbright/the_ipv6ification_of_chan_iax2_by_the_coward_se...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Sun Mar 4 12:20:14 CST 2012


Author: seanbright
Date: Sun Mar  4 12:20:10 2012
New Revision: 358081

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=358081
Log:
Copy host and port to locals where necessary.

Modified:
    team/seanbright/the_ipv6ification_of_chan_iax2_by_the_coward_sean_bright/channels/chan_iax2.c

Modified: team/seanbright/the_ipv6ification_of_chan_iax2_by_the_coward_sean_bright/channels/chan_iax2.c
URL: http://svnview.digium.com/svn/asterisk/team/seanbright/the_ipv6ification_of_chan_iax2_by_the_coward_sean_bright/channels/chan_iax2.c?view=diff&rev=358081&r1=358080&r2=358081
==============================================================================
--- team/seanbright/the_ipv6ification_of_chan_iax2_by_the_coward_sean_bright/channels/chan_iax2.c (original)
+++ team/seanbright/the_ipv6ification_of_chan_iax2_by_the_coward_sean_bright/channels/chan_iax2.c Sun Mar  4 12:20:10 2012
@@ -4341,13 +4341,15 @@
 	struct iax2_peer *peer=NULL;
 	time_t regseconds = 0, nowtime;
 	int dynamic=0;
+	char *address = ast_strdupa(ast_sockaddr_stringify_addr(addr));
+	char *port = ast_strdupa(ast_sockaddr_stringify_port(addr));
 
 	if (peername) {
 		var = ast_load_realtime("iaxpeers", "name", peername, "host", "dynamic", SENTINEL);
 		if (!var && addr)
-			var = ast_load_realtime("iaxpeers", "name", peername, "host", ast_sockaddr_stringify_addr(addr), SENTINEL);
+			var = ast_load_realtime("iaxpeers", "name", peername, "host", address, SENTINEL);
 	} else if (addr) {
-		var = ast_load_realtime("iaxpeers", "ipaddr", ast_sockaddr_stringify_addr(addr), "port", ast_sockaddr_stringify_port(addr), SENTINEL);
+		var = ast_load_realtime("iaxpeers", "ipaddr", address, "port", port, SENTINEL);
 		if (var) {
 			/* We'll need the peer name in order to build the structure! */
 			for (tmp = var; tmp; tmp = tmp->next) {
@@ -4455,14 +4457,16 @@
 	struct ast_variable *var;
 	struct ast_variable *tmp;
 	struct iax2_user *user=NULL;
+	char *address = ast_sockaddr_stringify_addr(addr);
+	char *port = ast_sockaddr_stringify_port(addr);
 
 	var = ast_load_realtime("iaxusers", "name", username, "host", "dynamic", SENTINEL);
 	if (!var)
-		var = ast_load_realtime("iaxusers", "name", username, "host", ast_sockaddr_stringify_addr(addr), SENTINEL);
+		var = ast_load_realtime("iaxusers", "name", username, "host", address, SENTINEL);
 	if (!var && addr) {
-		var = ast_load_realtime("iaxusers", "name", username, "ipaddr", ast_sockaddr_stringify_addr(addr), "port", ast_sockaddr_stringify_port(addr), SENTINEL);
+		var = ast_load_realtime("iaxusers", "name", username, "ipaddr", address, "port", port, SENTINEL);
 		if (!var)
-			var = ast_load_realtime("iaxusers", "ipaddr", ast_sockaddr_stringify_addr(addr), "port", ast_sockaddr_stringify_port(addr), SENTINEL);
+			var = ast_load_realtime("iaxusers", "ipaddr", address, "port", port, SENTINEL);
 	}
 	if (!var) { /* Last ditch effort */
 		var = ast_load_realtime("iaxusers", "name", username, SENTINEL);
@@ -4519,21 +4523,21 @@
 
 static void realtime_update_peer(const char *peername, struct ast_sockaddr *sockaddr, time_t regtime)
 {
-	char port[10];
 	char regseconds[20];
 	const char *sysname = ast_config_AST_SYSTEM_NAME;
 	char *syslabel = NULL;
+	char *address = ast_strdupa(ast_sockaddr_stringify_addr(sockaddr));
+	char *port = ast_strdupa(ast_sockaddr_stringify_port(sockaddr));
 
 	if (ast_strlen_zero(sysname))	/* No system name, disable this */
 		sysname = NULL;
 	else if (ast_test_flag64(&globalflags, IAX_RTSAVE_SYSNAME))
 		syslabel = "regserver";
 
-	snprintf(regseconds, sizeof(regseconds), "%d", (int)regtime);
-	snprintf(port, sizeof(port), "%d", ast_sockaddr_port(sockaddr));
-	ast_update_realtime("iaxpeers", "name", peername, 
-		"ipaddr", ast_sockaddr_stringify_addr(sockaddr), "port", port, 
-		"regseconds", regseconds, syslabel, sysname, SENTINEL); /* note syslable can be NULL */
+	snprintf(regseconds, sizeof(regseconds), "%d", (int) regtime);
+	ast_update_realtime("iaxpeers", "name", peername,
+		"ipaddr", address, "port", port,
+		"regseconds", regseconds, syslabel, sysname, SENTINEL); /* note syslabel can be NULL */
 }
 
 struct create_addr_info {




More information about the asterisk-commits mailing list