[asterisk-commits] jpeeler: branch jpeeler/sip-dnsmgr r111772 - in /team/jpeeler/sip-dnsmgr: cha...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Fri Mar 28 13:56:28 CDT 2008


Author: jpeeler
Date: Fri Mar 28 13:56:27 2008
New Revision: 111772

URL: http://svn.digium.com/view/asterisk?view=rev&rev=111772
Log:
removed debug message causing segfault, better to pass around sockaddr_in structs then address and port separately

Modified:
    team/jpeeler/sip-dnsmgr/channels/chan_sip.c
    team/jpeeler/sip-dnsmgr/include/asterisk/dnsmgr.h
    team/jpeeler/sip-dnsmgr/main/dnsmgr.c

Modified: team/jpeeler/sip-dnsmgr/channels/chan_sip.c
URL: http://svn.digium.com/view/asterisk/team/jpeeler/sip-dnsmgr/channels/chan_sip.c?view=diff&rev=111772&r1=111771&r2=111772
==============================================================================
--- team/jpeeler/sip-dnsmgr/channels/chan_sip.c (original)
+++ team/jpeeler/sip-dnsmgr/channels/chan_sip.c Fri Mar 28 13:56:27 2008
@@ -9226,10 +9226,10 @@
  
 		snprintf(service, sizeof(service), "_sip._%s.%s", get_transport(r->transport), r->hostname); /* have to use static get_transport function */
 		ast_log(LOG_DEBUG, "hostname: %s portno:%d sin_family:%d\n", r->hostname, r->portno, r->us.sin_family);
-		ast_dnsmgr_lookup_srv(r->hostname, &r->us.sin_addr, &r->us.sin_port, &r->dnsmgr, service);
+		ast_dnsmgr_lookup_srv(r->hostname, &r->us, &r->dnsmgr, service);
 		ast_log(LOG_DEBUG, "after dnsmgr lookup port=%d\n", htons(r->us.sin_port));
 	} else {
-		ast_log(LOG_DEBUG, "DNS manager detected, r->us.sin_addr=%s r->us.sin_port=%d\n", ast_inet_ntoa(r->us.sin_addr), ntohs(r->us.sin_port));
+		ast_log(LOG_DEBUG, "DNS manager detected, r->us.sin_addr=%s r->us.sin_port=%d r->us.sin_family=%d\n", ast_inet_ntoa(r->us.sin_addr), ntohs(r->us.sin_port), r->us.sin_family);
 	}
 
 	if (r->call) {	/* We have a registration */

Modified: team/jpeeler/sip-dnsmgr/include/asterisk/dnsmgr.h
URL: http://svn.digium.com/view/asterisk/team/jpeeler/sip-dnsmgr/include/asterisk/dnsmgr.h?view=diff&rev=111772&r1=111771&r2=111772
==============================================================================
--- team/jpeeler/sip-dnsmgr/include/asterisk/dnsmgr.h (original)
+++ team/jpeeler/sip-dnsmgr/include/asterisk/dnsmgr.h Fri Mar 28 13:56:27 2008
@@ -81,7 +81,7 @@
  */
 int ast_dnsmgr_lookup(const char *name, struct in_addr *result, struct ast_dnsmgr_entry **dnsmgr);
 
-int ast_dnsmgr_lookup_srv(const char *name, struct in_addr *result_addr, unsigned short *result_portno, struct ast_dnsmgr_entry **dnsmgr, const char *service);
+int ast_dnsmgr_lookup_srv(const char *name, struct sockaddr_in *sin, struct ast_dnsmgr_entry **dnsmgr, const char *service);
 
 /*!
  * \brief Force a refresh of a dnsmgr entry

Modified: team/jpeeler/sip-dnsmgr/main/dnsmgr.c
URL: http://svn.digium.com/view/asterisk/team/jpeeler/sip-dnsmgr/main/dnsmgr.c?view=diff&rev=111772&r1=111771&r2=111772
==============================================================================
--- team/jpeeler/sip-dnsmgr/main/dnsmgr.c (original)
+++ team/jpeeler/sip-dnsmgr/main/dnsmgr.c Fri Mar 28 13:56:27 2008
@@ -172,7 +172,7 @@
 	return !*dnsmgr;
 }
 
-int ast_dnsmgr_lookup_srv(const char *name, struct in_addr *result_addr, unsigned short *result_portno, struct ast_dnsmgr_entry **dnsmgr, const char *service)
+int ast_dnsmgr_lookup_srv(const char *name, struct sockaddr_in *sin, struct ast_dnsmgr_entry **dnsmgr, const char *service)
 {
 	char realhostname[MAXHOSTNAMELEN];
 	int real_portno;
@@ -180,7 +180,7 @@
 	struct hostent *hp;
 	struct ast_hostent ahp;
 
-	if (ast_strlen_zero(name) || !result_addr || !result_portno || !dnsmgr || !service) {
+	if (ast_strlen_zero(name) || !sin || !dnsmgr || !service) {
 		return -1;
 	}
 
@@ -190,7 +190,7 @@
 
 	/* if it's actually an IP address and not a name,
 	   there's no need for a managed lookup */
-	if (inet_aton(name, result_addr))
+	if (inet_aton(name, &sin->sin_addr))
 		return 0;
 
 	ast_verb(4, "doing dnsmgr_lookup for '%s'\n", name);
@@ -199,16 +199,14 @@
 	if (srv_ret > 0) {
 		char buf[INET_ADDRSTRLEN];
 		hp = ast_gethostbyname(realhostname, &ahp);
-		*result_portno = htons((unsigned short)real_portno);
-		ast_log(LOG_DEBUG, "name=%s realhostname=%s result_portno=%d hp->h_addr=%s\n", name, realhostname, ntohs(*result_portno), inet_ntop(AF_INET, hp->h_addr, buf, sizeof(buf)));
-		//result_addr->sin_port = *result_portno;
+		sin->sin_port = htons((unsigned short)real_portno);
+		ast_log(LOG_DEBUG, "name=%s realhostname=%s result_portno=%d hp->h_addr=%s\n", name, realhostname, ntohs(sin->sin_port), inet_ntop(AF_INET, hp->h_addr, buf, sizeof(buf)));
 	} else {
 		hp = ast_gethostbyname(name, &ahp);
-		ast_log(LOG_DEBUG, "name=%s realhostname=%s result_portno=%d hp->h_addr=%s\n", name, realhostname, *result_portno, hp->h_addr);
 	}
 
 	if (hp) {
-		memcpy(result_addr, hp->h_addr, sizeof(result_addr));
+		memcpy(&sin->sin_addr, hp->h_addr, sizeof(sin->sin_addr));
 	}
 
 
@@ -217,7 +215,7 @@
 		return 0;
 	
 	ast_verb(3, "adding dns manager for '%s'\n", name);
-	*dnsmgr = ast_dnsmgr_get_srv(name, result_addr, result_portno, service);
+	*dnsmgr = ast_dnsmgr_get_srv(name, &sin->sin_addr, &sin->sin_port, service);
 	return !*dnsmgr;
 }
 




More information about the asterisk-commits mailing list