MCPcopy Create free account
hub / github.com/OpenSIPS/opensips / sip_resolvehost

Function sip_resolvehost

resolve.c:1654–1786  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1652
1653#if 0
1654struct hostent* sip_resolvehost(str* name, unsigned short* port, int *proto,
1655 int is_sips)
1656{
1657 static char tmp[MAX_DNS_NAME];
1658 struct ip_addr *ip;
1659 struct rdata *head;
1660 struct rdata *rd;
1661 struct hostent* he;
1662
1663 if ( (is_sips)
1664 && (tls_disable)
1665 ) {
1666 LM_ERR("cannot resolve SIPS as no TLS support is configured\n");
1667 return 0;
1668 }
1669
1670 /* check if it's an ip address */
1671 if ( ((ip=str2ip(name))!=0)
1672 || ((ip=str2ip6(name))!=0)
1673 ){
1674 /* we are lucky, this is an ip address */
1675 if (proto && *proto==PROTO_NONE)
1676 *proto = (is_sips)?PROTO_TLS:PROTO_UDP;
1677 if (port && *port==0)
1678 *port = (is_sips||((*proto)==PROTO_TLS))?SIPS_PORT:SIP_PORT;
1679 return ip_addr2he(name,ip);
1680 }
1681
1682 /* do we have a port? */
1683 if ( !port || (*port)!=0 ) {
1684 /* have port -> no NAPTR, no SRV lookup, just A record lookup */
1685 LM_DBG("has port -> do A record lookup!\n");
1686 /* set default PROTO if not set */
1687 if (proto && *proto==PROTO_NONE)
1688 *proto = (is_sips)?PROTO_TLS:PROTO_UDP;
1689 goto do_a;
1690 }
1691
1692 /* no port... what about proto? */
1693 if ( !proto || (*proto)!=PROTO_NONE ) {
1694 /* have proto, but no port -> do SRV lookup */
1695 LM_DBG("no port, has proto -> do SRV lookup!\n");
1696 if (is_sips && (*proto)!=PROTO_TLS) {
1697 LM_ERR("forced proto %d not matching sips uri\n", *proto);
1698 return 0;
1699 }
1700 goto do_srv;
1701 }
1702
1703 LM_DBG("no port, no proto -> do NAPTR lookup!\n");
1704 /* no proto, no port -> do NAPTR lookup */
1705 if (name->len >= MAX_DNS_NAME) {
1706 LM_ERR("domain name too long\n");
1707 return 0;
1708 }
1709 memcpy(tmp, name->s, name->len);
1710 tmp[name->len] = '\0';
1711 /* do NAPTR lookup */

Callers 13

mk_proxyFunction · 0.85
mk_shm_proxyFunction · 0.85
check_ip_addressFunction · 0.85
send_keepaliveFunction · 0.85
get_natping_socketFunction · 0.85
nh_timerFunction · 0.85
_removeFunction · 0.85
_remove_ip_port_urecordFunction · 0.85
is_from_user_enumFunction · 0.85
_uri_to_ip_portFunction · 0.85
add_node_infoFunction · 0.85

Calls 11

str2ipFunction · 0.85
str2ip6Function · 0.85
ip_addr2heFunction · 0.85
get_recordFunction · 0.85
filter_and_sort_naptrFunction · 0.85
free_rdata_listFunction · 0.85
do_srv_lookupFunction · 0.85
get_naptr_protoFunction · 0.85
resolvehostFunction · 0.85
srv2dns_nodeFunction · 0.85
shm_freeFunction · 0.85

Tested by

no test coverage detected