[Asterisk-cvs] asterisk acl.c,1.36,1.37
markster at lists.digium.com
markster at lists.digium.com
Tue Feb 8 21:22:23 CST 2005
Update of /usr/cvsroot/asterisk
In directory mongoose.digium.com:/tmp/cvs-serv21776
Modified Files:
acl.c
Log Message:
Handle DNS failures on startup more gracefully (bug #3086)
Index: acl.c
===================================================================
RCS file: /usr/cvsroot/asterisk/acl.c,v
retrieving revision 1.36
retrieving revision 1.37
diff -u -d -r1.36 -r1.37
--- acl.c 18 Jan 2005 13:58:33 -0000 1.36
+++ acl.c 9 Feb 2005 03:22:41 -0000 1.37
@@ -384,3 +384,32 @@
ast_log(LOG_WARNING, "Out of memory!\n");
return NULL;
}
+
+int ast_find_ourip(struct in_addr *ourip, struct sockaddr_in bindaddr)
+{
+ char ourhost[256];
+ struct ast_hostent ahp;
+ struct hostent *hp;
+ struct in_addr saddr;
+
+ /* just use the bind address if it is nonzero */
+ if (ntohl(bindaddr.sin_addr.s_addr)) {
+ memcpy(ourip, &bindaddr.sin_addr, sizeof(*ourip));
+ return 0;
+ }
+ /* try to use our hostname */
+ if (gethostname(ourhost, sizeof(ourhost))) {
+ ast_log(LOG_WARNING, "Unable to get hostname\n");
+ } else {
+ hp = ast_gethostbyname(ourhost, &ahp);
+ if (hp) {
+ memcpy(ourip, hp->h_addr, sizeof(*ourip));
+ return 0;
+ }
+ }
+ /* A.ROOT-SERVERS.NET. */
+ if (inet_aton("198.41.0.4", &saddr) && !ast_ouraddrfor(&saddr, ourip))
+ return 0;
+ return -1;
+}
+
More information about the svn-commits
mailing list