Module: sip-router
Branch: master
Commit: b50888cf447ea3a3315e665c97f71a07bb687337
URL:
http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=b50888c…
Author: Øyvind Kolbu <oyvind.kolbu(a)usit.uio.no>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: Mon Sep 30 11:15:13 2013 +0200
core: resolve down to A/AAAA records when no naptr records
- try all protocols, not only UDP
---
dns_cache.c | 10 +++++++++-
resolve.c | 27 +++++++++++----------------
2 files changed, 20 insertions(+), 17 deletions(-)
diff --git a/dns_cache.c b/dns_cache.c
index 6db93c1..917b43e 100644
--- a/dns_cache.c
+++ b/dns_cache.c
@@ -2830,8 +2830,10 @@ struct hostent* dns_naptr_sip_resolvehost(str* name, unsigned
short* port,
naptr_bmp_t tried_bmp;
struct dns_hash_entry* e;
char n_proto;
+ char origproto;
str srv_name;
+ origproto=*proto;
he=0;
if (dns_hash==0){ /* not init => use normal, non-cached version */
LOG(L_WARN, "WARNING: dns_sip_resolvehost: called before dns cache"
@@ -2872,7 +2874,13 @@ struct hostent* dns_naptr_sip_resolvehost(str* name, unsigned
short* port,
dns_hash_put(e);
}
naptr_not_found:
- return no_naptr_srv_sip_resolvehost(name,port,proto);
+ *proto = origproto;
+ he = no_naptr_srv_sip_resolvehost(name,port,proto);
+ /* fallback all the way down to A/AAAA */
+ if (he==0) {
+ he=dns_get_he(name,dns_flags);
+ }
+ return he;
}
#endif /* USE_NAPTR */
diff --git a/resolve.c b/resolve.c
index be47260..d01ab80 100644
--- a/resolve.c
+++ b/resolve.c
@@ -1498,20 +1498,7 @@ struct hostent* no_naptr_srv_sip_resolvehost(str* name, unsigned
short* port, ch
}
if (default_order){
for (i=0; i<list_len;i++) {
- switch ( srv_proto_list[i].proto) {
- case PROTO_UDP:
- srv_proto_list[i].proto_pref=4;
- break;
- case PROTO_TCP:
- srv_proto_list[i].proto_pref=3;
- break;
- case PROTO_TLS:
- srv_proto_list[i].proto_pref=2;
- break;
- case PROTO_SCTP:
- srv_proto_list[i].proto_pref=1;
- break;
- }
+ srv_proto_list[i].proto_pref=proto_pref_score(i);;
}
}
@@ -1571,6 +1558,9 @@ struct hostent* no_naptr_srv_sip_resolvehost(str* name, unsigned
short* port, ch
if ((port)&&(*port==0)){
*port=(srv_proto_list[i].proto==PROTO_TLS)?SIPS_PORT:SIP_PORT; /* just in case we
don't find another */
}
+ if ((proto)&&(*proto==0)){
+ *proto = PROTO_UDP;
+ }
srv_name.s=tmp_srv;
srv_name.len=len;
#ifdef USE_DNS_CACHE
@@ -1611,9 +1601,9 @@ struct hostent* naptr_sip_resolvehost(str* name, unsigned short*
port,
char n_proto;
str srv_name;
naptr_bmp_t tried_bmp; /* tried bitmap */
+ char origproto;
-
-
+ origproto = *proto;
naptr_head=0;
he=0;
if (name->len >= MAX_DNS_NAME) {
@@ -1650,7 +1640,12 @@ struct hostent* naptr_sip_resolvehost(str* name, unsigned short*
port,
#endif
}
/* fallback to srv lookup */
+ *proto = origproto;
he=no_naptr_srv_sip_resolvehost(name,port,proto);
+ /* fallback all the way down to A/AAAA */
+ if (he==0) {
+ he=dns_get_he(name,dns_flags);
+ }
end:
if (naptr_head)
free_rdata_list(naptr_head);