Module: sip-router
Branch: master
Commit: b2e5040fa324fa8c95c5b44a5fcab58ed84a4c55
URL:
http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=b2e5040…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: Wed Dec 26 12:32:00 2012 +0100
core: check for IP in no_naptr_srv_sip_resolvehost()
- catch IP addresses before attempting to do SRV query
---
resolve.c | 18 ++++++++++++++++++
1 files changed, 18 insertions(+), 0 deletions(-)
diff --git a/resolve.c b/resolve.c
index 2a690a4..0a77ed7 100644
--- a/resolve.c
+++ b/resolve.c
@@ -1462,6 +1462,7 @@ struct hostent* no_naptr_srv_sip_resolvehost(str* name, unsigned
short* port, ch
int proto_pref;
} srv_proto_list[PROTO_LAST], tmp_srv_element;
struct hostent* he;
+ struct ip_addr* ip;
str srv_name;
static char tmp_srv[MAX_DNS_NAME]; /* tmp. buff. for SRV lookups */
int len;
@@ -1470,6 +1471,23 @@ struct hostent* no_naptr_srv_sip_resolvehost(str* name, unsigned
short* port, ch
he=0;
len=0;
+ /* check if it's an ip address */
+ if (((ip=str2ip(name))!=0)
+#ifdef USE_IPV6
+ || ((ip=str2ip6(name))!=0)
+#endif
+ ){
+ /* we are lucky, this is an ip address */
+ /* set proto if needed - default udp */
+ if ((proto)&&(*proto==PROTO_NONE))
+ *proto=PROTO_UDP;
+ /* set port if needed - default 5060/5061 */
+ if ((port)&&(*port==0))
+ *port=((proto) && (*proto==PROTO_TLS))?SIPS_PORT:SIP_PORT;
+ he=ip_addr2he(name, ip);
+ return he;
+ }
+
if ((name->len+SRV_MAX_PREFIX_LEN+1)>MAX_DNS_NAME){
LOG(L_WARN, "WARNING: no_naptr_srv_sip_resolvehost: domain name too long"
" (%d), unable to perform SRV lookup\n", name->len);