diff --git a/modules/ipops/README b/modules/ipops/README index 982db00c198..b213b036a9c 100644 --- a/modules/ipops/README +++ b/modules/ipops/README @@ -39,6 +39,7 @@ I 4.11. dns_sys_match_ip(hostname, ipaddr) 4.12. dns_int_match_ip(hostname, ipaddr) 4.13. dns_query(hostname, pvid) + 4.14. srv_query(srvcname, pvid) List of Examples @@ -55,6 +56,7 @@ I 1.11. dns_sys_match_ip usage 1.12. dns_int_match_ip usage 1.13. dns_query usage + 1.14. srv_query usage Chapter 1. Admin Guide @@ -82,6 +84,7 @@ Chapter 1. Admin Guide 4.11. dns_sys_match_ip(hostname, ipaddr) 4.12. dns_int_match_ip(hostname, ipaddr) 4.13. dns_query(hostname, pvid) + 4.14. srv_query(srvcname, pvid) 1. Overview @@ -136,6 +139,7 @@ Chapter 1. Admin Guide 4.11. dns_sys_match_ip(hostname, ipaddr) 4.12. dns_int_match_ip(hostname, ipaddr) 4.13. dns_query(hostname, pvid) + 4.14. srv_query(srvcname, pvid) 4.1. is_ip (ip) @@ -416,3 +420,44 @@ if(dns_query("test.com", "xyz")) } } ... + +4.14. srv_query(srvcname, pvid) + + Queries DNS SRV records to resolve a service/protocol name into a list + of priorities, weights, ports, and targets sorted by priority and + weight as outlined in RFC 2782. + + Parameters: + * srvcname - string or pseudo-variable containing the + service/protocol. For example, "_sip._tcp.example.com". + * pvid - container id for script variable. + + Output: + + Returns a positive number indicating success or a negative number when + an error is encountered. It can be used from ANY_ROUTE. + + The $srvquery pseudo-variable (PV) is loaded with the results of the + query. Multiple queries can be stored in the PV using the pvid key. + Each query contains zero-indexed arrays sorted by priority and weight + that contain: + * count - number of records found + * port [index] - port number + * priority [index] - priority number as defined by RFC 2782 + * target [index] - target host name + * weight [index] - weight number as defined by RFC 2782 + + Example 1.14. srv_query usage +... +if (srv_query ("_sip._udp.example.com", "udp") > 0) { + $var(cnt) = $srvquery(udp=>count); + $var(i) = 0; + while ($var(i) < $var(cnt)) { + xlog ("port[$var(i)] $srvquery(udp=>port[$var(i)])\n)"; + xlog ("priority[$var(i)] $srvquery(udp=>priority[$var(i)])\n)"; + xlog ("target[$var(i)] $srvquery(udp=>target[$var(i)])\n)"; + xlog ("weight[$var(i)] $srvquery(udp=>weight[$var(i)])\n)"; + $var(i) = $var(i) + 1; + } +} +... diff --git a/modules/ipops/doc/ipops_admin.xml b/modules/ipops/doc/ipops_admin.xml index bbf68cfb148..90c4168b59f 100644 --- a/modules/ipops/doc/ipops_admin.xml +++ b/modules/ipops/doc/ipops_admin.xml @@ -674,6 +674,91 @@ if(dns_query("test.com", "xyz")) $var(i) = $var(i) + 1; } } +... + + + + + +
+ + <function moreinfo="none">srv_query(srvcname, pvid)</function> + + + +Queries DNS SRV records to resolve a service/protocol name into a list of priorities, weights, ports, and targets sorted by priority and weight as outlined in RFC 2782. + + + Parameters: + + + + + srvcname - string or pseudo-variable containing the service/protocol. For example, "_sip._tcp.example.com". + + + + + pvid - container id for script variable. + + + + + Output: + + + Returns a positive number indicating success or a negative number when an error is encountered. It can be used from ANY_ROUTE. + + + + The $srvquery pseudo-variable (PV) is loaded with the results of the query. Multiple queries can be stored in the PV using the pvid key. Each query contains zero-indexed arrays sorted by priority and weight that contain: + + + + + + count - number of records found + + + + + port [index] - port number + + + + + priority [index] - priority number as defined by RFC 2782 + + + + + target [index] - target host name + + + + + weight [index] - weight number as defined by RFC 2782 + + + + + + + <function>srv_query</function> usage + + +... +if (srv_query ("_sip._udp.example.com", "udp") > 0) { + $var(cnt) = $srvquery(udp=>count); + $var(i) = 0; + while ($var(i) < $var(cnt)) { + xlog ("port[$var(i)] $srvquery(udp=>port[$var(i)])\n)"; + xlog ("priority[$var(i)] $srvquery(udp=>priority[$var(i)])\n)"; + xlog ("target[$var(i)] $srvquery(udp=>target[$var(i)])\n)"; + xlog ("weight[$var(i)] $srvquery(udp=>weight[$var(i)])\n)"; + $var(i) = $var(i) + 1; + } +} ...