Module: sip-router
Branch: 4.0
Commit: 3253fcb7e7ef628727799a92ca68739dba3d10ca
URL:
http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=3253fcb…
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
(cherry picked from commit b50888cf447ea3a3315e665c97f71a07bb687337)
---
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 1243c92..5690cb6 100644
--- a/dns_cache.c
+++ b/dns_cache.c
@@ -2857,8 +2857,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"
@@ -2903,7 +2905,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 e739f4b..e29e189 100644
--- a/resolve.c
+++ b/resolve.c
@@ -1519,20 +1519,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);;
}
}
@@ -1592,6 +1579,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
@@ -1632,9 +1622,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) {
@@ -1673,7 +1663,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);