Module: kamailio
Branch: master
Commit: 01771c42d3b96678a2d0ba08bc1e5c83191ada8d
URL:
https://github.com/kamailio/kamailio/commit/01771c42d3b96678a2d0ba08bc1e5c8…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2017-07-19T14:38:22+02:00
core: dns case - init local proto to UDP if not provided for srv resolve
---
Modified: src/core/dns_cache.c
---
Diff:
https://github.com/kamailio/kamailio/commit/01771c42d3b96678a2d0ba08bc1e5c8…
Patch:
https://github.com/kamailio/kamailio/commit/01771c42d3b96678a2d0ba08bc1e5c8…
---
diff --git a/src/core/dns_cache.c b/src/core/dns_cache.c
index 3558a5ffcb..d933300187 100644
--- a/src/core/dns_cache.c
+++ b/src/core/dns_cache.c
@@ -3227,12 +3227,16 @@ inline static int dns_srv_sip_resolve(struct dns_srv_handle* h,
str* name,
return -E_DNS_NO_SRV;
}
if ((h->srv==0) && (h->a==0)){ /* first call */
- if (proto && *proto==0){ /* makes sure we have a protocol set*/
- *proto=PROTO_UDP; /* default */
- }
- h->port=(*proto==PROTO_TLS)?SIPS_PORT:SIP_PORT; /* just in case we
+ if (proto) {
+ if(*proto==0) { /* makes sure we have a protocol set*/
+ *proto=PROTO_UDP; /* default */
+ }
+ h->port=(*proto==PROTO_TLS)?SIPS_PORT:SIP_PORT; /* just in case we
don't find another */
- h->proto=*proto; /* store initial protocol */
+ h->proto=*proto; /* store initial protocol */
+ } else {
+ h->proto=PROTO_UDP; /* default */
+ }
if (port){
if (*port==0){
/* try SRV if initial call & no port specified
@@ -3274,7 +3278,8 @@ inline static int dns_srv_sip_resolve(struct dns_srv_handle* h,
str* name,
srv_name.len=strlen(tmp);
if ((ret=dns_srv_resolve_ip(h, &srv_name, ip, port, flags))>=0)
{
- h->proto = *proto = srv_proto_list[i].proto;
+ h->proto = srv_proto_list[i].proto;
+ if(proto) *proto = h->proto;
#ifdef DNS_CACHE_DEBUG
LM_DBG("(%.*s, %d, %d), srv0, ret=%d\n",
name->len, name->s, h->srv_no, h->ip_no, ret);