[asterisk-commits] rizzo: branch rizzo/astobj2 r75382 - /team/rizzo/astobj2/channels/chan_sip.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Tue Jul 17 09:58:33 CDT 2007


Author: rizzo
Date: Tue Jul 17 09:58:32 2007
New Revision: 75382

URL: http://svn.digium.com/view/asterisk?view=rev&rev=75382
Log:
simplify address parsing using ast_parse_arg()


Modified:
    team/rizzo/astobj2/channels/chan_sip.c

Modified: team/rizzo/astobj2/channels/chan_sip.c
URL: http://svn.digium.com/view/asterisk/team/rizzo/astobj2/channels/chan_sip.c?view=diff&rev=75382&r1=75381&r2=75382
==============================================================================
--- team/rizzo/astobj2/channels/chan_sip.c (original)
+++ team/rizzo/astobj2/channels/chan_sip.c Tue Jul 17 09:58:32 2007
@@ -2188,13 +2188,8 @@
 	    ast_apply_ha(localaddr, &theirs) &&
 	    (!global_matchexterniplocally || !ast_apply_ha(localaddr, &ours))) {
 		if (externexpire && time(NULL) >= externexpire) {
-			struct ast_hostent ahp;
-			struct hostent *hp;
-
 			externexpire = time(NULL) + externrefresh;
-			if ((hp = ast_gethostbyname(externhost, &ahp))) {
-				memcpy(&externip.sin_addr, hp->h_addr, sizeof(externip.sin_addr));
-			} else
+			if (ast_parse_arg(externhost, PARSE_INADDR, &externip))
 				ast_log(LOG_NOTICE, "Warning: Re-lookup of '%s' failed!\n", externhost);
 		}
 		*us = externip.sin_addr;
@@ -17672,10 +17667,8 @@
 	struct ast_variable *v;
 	struct sip_peer *peer;
 	struct sip_user *user;
-	struct ast_hostent ahp;
 	char *cat, *stringp, *context, *oldregcontext;
 	char newcontexts[AST_MAX_CONTEXT], oldcontexts[AST_MAX_CONTEXT];
-	struct hostent *hp;
 	struct ast_flags dummy[2];
 	int auto_sip_domains = FALSE;
 	struct sockaddr_in old_bindaddr = bindaddr;
@@ -17879,11 +17872,9 @@
 				ast_log(LOG_WARNING, "Invalid stun address: %s\n", v->value);
 			} )
 		M_F("bindaddr", {
-			if (!(hp = ast_gethostbyname(v->value, &ahp))) {
+			if (ast_parse_arg(v->value, PARSE_INADDR, &bindaddr))
 				ast_log(LOG_WARNING, "Invalid address: %s\n", v->value);
-			} else {
-				memcpy(&bindaddr.sin_addr, hp->h_addr, sizeof(bindaddr.sin_addr));
-			} } )
+			} )
 		M_F("localnet", {
 			int ha_error = 0;
 			struct ast_ha *na;
@@ -17893,17 +17884,13 @@
 			else
 				localaddr = na; } )
 		M_F("externip", {
-			if (!(hp = ast_gethostbyname(v->value, &ahp))) 
+			if (ast_parse_arg(v->value, PARSE_INADDR, &externip))
 				ast_log(LOG_WARNING, "Invalid address for externip keyword: %s\n", v->value);
-			else
-				memcpy(&externip.sin_addr, hp->h_addr, sizeof(externip.sin_addr));
 			externexpire = 0; } )
 		M_F("externhost", {
 			ast_copy_string(externhost, v->value, sizeof(externhost));
-			if (!(hp = ast_gethostbyname(externhost, &ahp))) 
+			if (ast_parse_arg(externhost, PARSE_INADDR, &externip))
 				ast_log(LOG_WARNING, "Invalid address for externhost keyword: %s\n", externhost);
-			else
-				memcpy(&externip.sin_addr, hp->h_addr, sizeof(externip.sin_addr));
 			externexpire = time(NULL); } )
 		M_INT_GE("externrefresh", externrefresh, 1, 10)
 		M_F("allow", ast_parse_allow_disallow(&default_prefs, &global_capability, v->value, 1);)




More information about the asterisk-commits mailing list