[asterisk-commits] mnicholson: branch 1.6.2 r270975 - in /branches/1.6.2: ./ main/
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Wed Jun 16 15:41:48 CDT 2010
Author: mnicholson
Date: Wed Jun 16 15:41:40 2010
New Revision: 270975
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=270975
Log:
Merged revisions 270974 via svnmerge from
https://origsvn.digium.com/svn/asterisk/trunk
........
r270974 | mnicholson | 2010-06-16 15:34:31 -0500 (Wed, 16 Jun 2010) | 8 lines
Set sin_family to AF_INET when doing lookups, also reset sin_port the first time the ip address changes.
(closes issue #15827)
Reported by: DennisD
Patches:
dnsmgr_15827.patch uploaded by chappell (license 8)
Tested by: DennisD, gentlec, damage, wimpy
........
Modified:
branches/1.6.2/ (props changed)
branches/1.6.2/main/acl.c
branches/1.6.2/main/dnsmgr.c
Propchange: branches/1.6.2/
------------------------------------------------------------------------------
Binary property 'trunk-merged' - no diff available.
Modified: branches/1.6.2/main/acl.c
URL: http://svnview.digium.com/svn/asterisk/branches/1.6.2/main/acl.c?view=diff&rev=270975&r1=270974&r2=270975
==============================================================================
--- branches/1.6.2/main/acl.c (original)
+++ branches/1.6.2/main/acl.c Wed Jun 16 15:41:40 2010
@@ -387,6 +387,7 @@
}
}
if ((hp = ast_gethostbyname(value, &ahp))) {
+ sin->sin_family = hp->h_addrtype;
memcpy(&sin->sin_addr, hp->h_addr, sizeof(sin->sin_addr));
} else {
ast_log(LOG_WARNING, "Unable to lookup '%s'\n", value);
Modified: branches/1.6.2/main/dnsmgr.c
URL: http://svnview.digium.com/svn/asterisk/branches/1.6.2/main/dnsmgr.c?view=diff&rev=270975&r1=270974&r2=270975
==============================================================================
--- branches/1.6.2/main/dnsmgr.c (original)
+++ branches/1.6.2/main/dnsmgr.c Wed Jun 16 15:41:40 2010
@@ -52,8 +52,6 @@
struct ast_dnsmgr_entry {
/*! where we will store the resulting IP address and port number */
struct sockaddr_in *result;
- /*! the last result, used to check if address/port has changed */
- struct sockaddr_in last;
/*! SRV record to lookup, if provided. Composed of service, protocol, and domain name: _Service._Proto.Name */
char *service;
/*! Set to 1 if the entry changes */
@@ -96,7 +94,6 @@
entry->result = result;
ast_mutex_init(&entry->lock);
strcpy(entry->name, name);
- memcpy(&entry->last, result, sizeof(entry->last));
if (service) {
entry->service = ((char *) entry) + sizeof(*entry) + strlen(name);
strcpy(entry->service, service);
@@ -123,6 +120,9 @@
ast_free(entry);
}
+/*
+ * Allocate a new DNS manager entry and perform the initial lookup before returning
+ */
int ast_dnsmgr_lookup(const char *name, struct sockaddr_in *result, struct ast_dnsmgr_entry **dnsmgr, const char *service)
{
if (ast_strlen_zero(name) || !result || !dnsmgr)
@@ -133,8 +133,10 @@
/* if it's actually an IP address and not a name,
there's no need for a managed lookup */
- if (inet_aton(name, &result->sin_addr))
+ if (inet_aton(name, &result->sin_addr)) {
+ result->sin_family = AF_INET;
return 0;
+ }
ast_verb(4, "doing dnsmgr_lookup for '%s'\n", name);
@@ -164,15 +166,15 @@
if (verbose)
ast_verb(3, "refreshing '%s'\n", entry->name);
- tmp.sin_port = entry->last.sin_port;
+ memset(&tmp, 0, sizeof(tmp));
+ tmp.sin_port = entry->result->sin_port;
- if (!ast_get_ip_or_srv(&tmp, entry->name, entry->service) && inaddrcmp(&tmp, &entry->last)) {
- ast_copy_string(iabuf, ast_inet_ntoa(entry->last.sin_addr), sizeof(iabuf));
+ if (!ast_get_ip_or_srv(&tmp, entry->name, entry->service) && inaddrcmp(&tmp, entry->result)) {
+ ast_copy_string(iabuf, ast_inet_ntoa(entry->result->sin_addr), sizeof(iabuf));
ast_copy_string(iabuf2, ast_inet_ntoa(tmp.sin_addr), sizeof(iabuf2));
ast_log(LOG_NOTICE, "dnssrv: host '%s' changed from %s:%d to %s:%d\n",
- entry->name, iabuf, ntohs(entry->last.sin_port), iabuf2, ntohs(tmp.sin_port));
+ entry->name, iabuf, ntohs(entry->result->sin_port), iabuf2, ntohs(tmp.sin_port));
*entry->result = tmp;
- entry->last = tmp;
changed = entry->changed = 1;
}
More information about the asterisk-commits
mailing list