diff options
author | Tilghman Lesher <tilghman@meg.abyt.es> | 2007-12-23 01:38:46 +0000 |
---|---|---|
committer | Tilghman Lesher <tilghman@meg.abyt.es> | 2007-12-23 01:38:46 +0000 |
commit | 5a6759885f90eb81b0eb2748d714fe87d23fe78e (patch) | |
tree | 3908bb415c5441a3d1bf64303608f276cdf973bc /channels | |
parent | 67a704503b725b60f982758115b6d73a1bb1cc4d (diff) |
Merged revisions 94660 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4
........
r94660 | tilghman | 2007-12-22 19:21:03 -0600 (Sat, 22 Dec 2007) | 2 lines
Argh... I suppose third time's the charm.
........
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@94662 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'channels')
-rw-r--r-- | channels/chan_sip.c | 47 |
1 files changed, 24 insertions, 23 deletions
diff --git a/channels/chan_sip.c b/channels/chan_sip.c index 96076ac20..9390fc5e1 100644 --- a/channels/chan_sip.c +++ b/channels/chan_sip.c @@ -3093,33 +3093,34 @@ static struct sip_peer *realtime_peer(const char *newpeername, struct sockaddr_i varregs = ast_load_realtime("sipregs", "name", newpeername, NULL); 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 for dynamic peers */ + } + + if (!var && sin) { /* Then check on IP address for dynamic peers */ ast_copy_string(ipaddr, ast_inet_ntoa(sin->sin_addr), sizeof(ipaddr)); portnum = ntohs(sin->sin_port); sprintf(portstring, "%u", portnum); @@ -3139,7 +3140,7 @@ static struct sip_peer *realtime_peer(const char *newpeername, struct sockaddr_i var = ast_load_realtime("sippeers", "name", newpeername, NULL); } } - if(!var) { /*We couldn't match on ipaddress and port, so we need to check if port is insecure*/ + if (!var) { /*We couldn't match on ipaddress and port, so we need to check if port is insecure*/ peerlist = ast_load_realtime_multientry("sippeers", "host", ipaddr, NULL); if (peerlist) { var = get_insecure_variable_from_config(peerlist); @@ -3163,7 +3164,7 @@ static struct sip_peer *realtime_peer(const char *newpeername, struct sockaddr_i } } } else { - if(realtimeregs) { + if (realtimeregs) { peerlist = ast_load_realtime_multientry("sipregs", "ipaddr", ipaddr, NULL); if (peerlist) { varregs = get_insecure_variable_from_config(peerlist); |