[Asterisk-cvs] asterisk/channels chan_sip.c,1.510.2.50,1.510.2.51

russell at lists.digium.com russell at lists.digium.com
Sun Feb 20 21:58:49 CST 2005


Update of /usr/cvsroot/asterisk/channels
In directory mongoose.digium.com:/tmp/cvs-serv28787/channels

Modified Files:
      Tag: v1-0
	chan_sip.c 
Log Message:
handle DNS failures on startup more gracefully (bug #3086)


Index: chan_sip.c
===================================================================
RCS file: /usr/cvsroot/asterisk/channels/chan_sip.c,v
retrieving revision 1.510.2.50
retrieving revision 1.510.2.51
diff -u -d -r1.510.2.50 -r1.510.2.51
--- chan_sip.c	14 Feb 2005 22:47:57 -0000	1.510.2.50
+++ chan_sip.c	21 Feb 2005 03:57:27 -0000	1.510.2.51
@@ -190,7 +190,6 @@
 static int global_capability = AST_FORMAT_ULAW | AST_FORMAT_ALAW | AST_FORMAT_GSM | AST_FORMAT_H263;
 static int noncodeccapability = AST_RTP_DTMF;
 
-static char ourhost[256];
 static struct in_addr __ourip;
 static int ourport;
 
@@ -8603,10 +8602,6 @@
 	global_dtmfmode = SIP_DTMF_RFC2833;
 	global_promiscredir = 0;
 	
-	if (gethostname(ourhost, sizeof(ourhost))) {
-		ast_log(LOG_WARNING, "Unable to get hostname, SIP disabled\n");
-		return 0;
-	}
 	cfg = ast_load(config);
 
 	/* We *must* have a config file otherwise stop immediately */
@@ -8827,19 +8822,11 @@
 		cat = ast_category_browse(cfg, cat);
 	}
 	
-	if (ntohl(bindaddr.sin_addr.s_addr)) {
-		memcpy(&__ourip, &bindaddr.sin_addr, sizeof(__ourip));
-	} else {
-		hp = ast_gethostbyname(ourhost, &ahp);
-		if (!hp) {
-			ast_log(LOG_WARNING, "Unable to get IP address for %s, SIP disabled\n", ourhost);
-			if (!__ourip.s_addr) {
-				ast_destroy(cfg);
-				return 0;
-			}
-		} else
-			memcpy(&__ourip, hp->h_addr, sizeof(__ourip));
-	}
+	if (ast_find_ourip(&__ourip, bindaddr)) {
+		ast_log(LOG_WARNING, "Unable to get own IP address, SIP disabled\n");
+		return 0;
+ 	}
+
 	if (!ntohs(bindaddr.sin_port))
 		bindaddr.sin_port = ntohs(DEFAULT_SIP_PORT);
 	bindaddr.sin_family = AF_INET;




More information about the svn-commits mailing list