aboutsummaryrefslogtreecommitdiffstats
path: root/channels/chan_sip.c
diff options
context:
space:
mode:
authortilghman <tilghman@f38db490-d61c-443f-a65b-d21fe96a405b>2007-12-23 01:38:46 +0000
committertilghman <tilghman@f38db490-d61c-443f-a65b-d21fe96a405b>2007-12-23 01:38:46 +0000
commitab1d58647de7c66cedc74248c9f32485dfe6ef82 (patch)
tree3908bb415c5441a3d1bf64303608f276cdf973bc /channels/chan_sip.c
parent7b9f51dd116475115f319aeb903b415adff6c762 (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: http://svn.digium.com/svn/asterisk/trunk@94662 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'channels/chan_sip.c')
-rw-r--r--channels/chan_sip.c47
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);