532
<section id="ipops.f.dns_sys_match_ip">
534
<function moreinfo="none">dns_sys_match_ip(hostname, ipaddr)</function>
538
Returns TRUE if ipaddr is associated by DNS to hostname. FALSE otherwise. It
539
does not use the internal DNS resolver, but directly getaddrinfo(...). All
540
addresses returned for the hostname are checked. Note that some hosts may
541
return different lists of IP addresses for each query, if the DNS server
542
is configured in that way (e.g., for providing load balancing through DNS).
545
<para>Parameters:</para>
550
<emphasis>hostname</emphasis> - string or pseudo-variable containing the hostname.
551
The resulting IP addresses from DNS query are compared with ipaddr.
556
<emphasis>ipaddr</emphasis> - string or pseudo-variable containing the ip address.
562
This function can be used from ANY_ROUTE.
567
<function>dns_sys_match_ip</function> usage
569
<programlisting format="linespecific">
571
if (!dns_sys_match_ip("myhost.com", "1.2.3.4")) {
572
xdbg("ip address not associated with hostname\n");
580
<section id="ipops.f.dns_int_match_ip">
582
<function moreinfo="none">dns_int_match_ip(hostname, ipaddr)</function>
586
Returns TRUE if ipaddr is associated by DNS to hostname. FALSE otherwise. It
587
uses internal DNS resolver. At this moment, the function might not check all
588
the IP addresses as returned by dns_sys_match_ip(), because the internal
589
resolver targets to discover the first address to be used for relaying
590
SIP traffic. Thus is better to use dns_sys_match_ip() if the host you want
591
to check has many IP addresses, in different address famililies (IPv4/6).
594
<para>Parameters:</para>
599
<emphasis>hostname</emphasis> - string or pseudo-variable containing the hostname.
600
The resulting IP addresses from DNS query are compared with ipaddr.
605
<emphasis>ipaddr</emphasis> - string or pseudo-variable containing the ip address.
611
This function can be used from ANY_ROUTE.
616
<function>dns_int_match_ip</function> usage
618
<programlisting format="linespecific">
620
if (!dns_int_match_ip("myhost.com", "1.2.3.4")) {
621
xdbg("ip address not associated with hostname\n");
629
<section id="ipops.f.dns_query">
631
<function moreinfo="none">dns_query(hostname, pvid)</function>
635
Store the IP addresses and their type that correspond to hostname
636
in a config variable $dns(pvid=>key).
639
<para>Parameters:</para>
644
<emphasis>hostname</emphasis> - string or pseudo-variable containing the hostname.
645
The resulting IP addresses from DNS query are compared with ipaddr.
650
<emphasis>pvid</emphasis> - container id for script variable.
656
This function can be used from ANY_ROUTE.
661
<function>dns_query</function> usage
663
<programlisting format="linespecific">
665
if(dns_query("test.com", "xyz"))
667
xlog(" number of addresses: $dns(xyz=>count)\n");
668
xlog(" ipv4 address found: $dns(xyz=>ipv4)\n");
669
xlog(" ipv6 address found: $dns(xyz=>ipv6)\n");
671
while($var(i)<$dns(xyz=>count)) {
672
xlog(" #[$var(i)] type ($dns(xyz=>type[$var(i)]))"
673
" addr [$dns(xyz=>addr[$var(i)])]\n");
674
$var(i) = $var(i) + 1;