[Asterisk-cvs] asterisk acl.c,1.27.2.2,1.27.2.3
russell at lists.digium.com
russell at lists.digium.com
Sun Feb 20 21:58:49 CST 2005
Update of /usr/cvsroot/asterisk
In directory mongoose.digium.com:/tmp/cvs-serv28787
Modified Files:
Tag: v1-0
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.27.2.2
retrieving revision 1.27.2.3
diff -u -d -r1.27.2.2 -r1.27.2.3
--- acl.c 24 Oct 2004 21:24:17 -0000 1.27.2.2
+++ acl.c 21 Feb 2005 03:57:26 -0000 1.27.2.3
@@ -378,3 +378,32 @@
return 0;
#endif
}
+
+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