diff options
author | tilghman <tilghman@f38db490-d61c-443f-a65b-d21fe96a405b> | 2007-12-23 01:21:03 +0000 |
---|---|---|
committer | tilghman <tilghman@f38db490-d61c-443f-a65b-d21fe96a405b> | 2007-12-23 01:21:03 +0000 |
commit | f182e877967dd0cf99001815fe5dda2176c48c61 (patch) | |
tree | d5bb817350fc1f5672989ca03417caef8d725a00 | |
parent | 469c7537fdb0a2a2cda13d62df71d11972dc1875 (diff) |
Argh... I suppose third time's the charm.
git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.4@94660 f38db490-d61c-443f-a65b-d21fe96a405b
-rw-r--r-- | channels/chan_sip.c | 43 |
1 files changed, 22 insertions, 21 deletions
diff --git a/channels/chan_sip.c b/channels/chan_sip.c index c04020a61..d77510ab2 100644 --- a/channels/chan_sip.c +++ b/channels/chan_sip.c @@ -2500,33 +2500,34 @@ static struct sip_peer *realtime_peer(const char *newpeername, struct sockaddr_i /* First check on peer name */ if (newpeername) { var = ast_load_realtime("sippeers", "name", newpeername, "host", "dynamic", NULL); - if (!var && sin) { + if (!var && sin) var = ast_load_realtime("sippeers", "name", newpeername, "host", ast_inet_ntoa(sin->sin_addr), NULL); - if (!var) { - var = ast_load_realtime("sippeers", "name", newpeername, NULL); - /*!\note - * If this one loaded something, then we need to ensure that the host - * field matched. The only reason why we can't have this as a criteria - * is because we only have the IP address and the host field might be - * set as a name (and the reverse PTR might not match). - */ - if (var) { - for (tmp = var; tmp; tmp = tmp->next) { - if (!strcasecmp(var->name, "host")) { - struct in_addr sin2 = { 0, }; - struct ast_dnsmgr_entry *dnsmgr = NULL; - if ((ast_dnsmgr_lookup(tmp->value, &sin2, &dnsmgr) < 0) || (memcmp(&sin2, &sin->sin_addr, sizeof(sin2)) != 0)) { - /* No match */ - ast_variables_destroy(var); - var = NULL; - } - break; + if (!var) { + var = ast_load_realtime("sippeers", "name", newpeername, NULL); + /*!\note + * If this one loaded something, then we need to ensure that the host + * field matched. The only reason why we can't have this as a criteria + * is because we only have the IP address and the host field might be + * set as a name (and the reverse PTR might not match). + */ + if (var) { + for (tmp = var; tmp; tmp = tmp->next) { + if (!strcasecmp(var->name, "host")) { + struct in_addr sin2 = { 0, }; + struct ast_dnsmgr_entry *dnsmgr = NULL; + if ((ast_dnsmgr_lookup(tmp->value, &sin2, &dnsmgr) < 0) || (memcmp(&sin2, &sin->sin_addr, sizeof(sin2)) != 0)) { + /* No match */ + ast_variables_destroy(var); + var = NULL; } + break; } } } } - } else if (sin) { /* Then check on IP address */ + } + + if (!var && sin) { /* Then check on IP address */ iabuf = ast_inet_ntoa(sin->sin_addr); portnum = ntohs(sin->sin_port); sprintf(portstring, "%d", portnum); |