README
上传用户:sy_wanhua
上传日期:2013-07-25
资源大小:3048k
文件大小:4k
- For information about licensing, please see the LICENSE file in this
- directory, or http://www.vovida.org/license.html .
- Compiling the code
- To include DNS SRV in the util package:
- 1) make sure BIND 8 is installed in the system
- 2) update the BIND package in build/Makefile.pkg to contain the
- path to BIND appropriately.
- 3) update build/Makefile.opt file to include the BIND package:
- USE_BIND=1
- 4) cd to top level directory, e.g. vocal
- make util
- The DnsResolver utility implements the usage rules as defined
- in RFC 2782: a DNS RR for specifying the location of services
- (DNS SRV). See also IETF draft "draft-ietf-sip-srv-01.txt",
- SIP: Session Initiation Protocol -- Locating SIP Servers.
- For an example using the DnsResolver, take a look at the
- sipstack: sip/sipstack/SipMsg.* and SipUdp_impl.*
- Here's a brief usage guide:
- 1) Instantiate a DnsResolver object (which automatically do a SRV
- record lookup:
- Sptr<DnsResolver> dnsResolver = new
- DnsResolver("level3.com", ns_t_srv, "_sip", "_udp");
- // domainName, SRV type, service, protocol
- int idx = 0;
- int dnsNum = dnsResolver.getNumDnsRecords(); // get number of dns records
- boolean done = false;
- Sptr<DnsRecord>* dnsRecord = 0;
- while ((idx < dnsNum) && (done==false))
- {
- dnsRecord = dnsResolver->getRecord( dnsNum - 1 );
- Data address = (*dnsRecord)->getAddress(); // get resolved IP address
- int portNum = (*dnsRecord)->getPort(); // get port #
- ..........
- ..... // update SipUrl with the resolved IP @ and port
- // if send Sip request fails
- // continue
- // else
- // done = true; // exit while loop
- }
- 2) The order of the list of DnsRecords (cached in a DnsResolver object)
- can be shuffled by invoking:
- dnsResolver.reOrder(); // shuffle existing DnsRecords
- 3) At any time, an application can reuse a DnsResolver object and
- do a DNS SRV/ A record lookup by invoking:
- dnsResolver.dnsLookUp(); // clear DnsRecords, and do a new ns lookup
- Implementation details about DnsResolver
- ========================================
- DnsRecord - class that defines the DNS record information from the
- Name Server, target name, port number, IP address,
- priority, weight, etc.
- DnsResolver - utility class which maintains a vector of DnsRecords.
- On object instantiaion, this class automatically do
- a DNS lookup based on the "qType" parameter: ns_t_srv
- (for SRV lookup) or ns_t_a (for A record lookup).
- If a SRV record lookup succeeds, the code automatically
- resolves the host name to an IP address for each matching
- SRV record.
- If a SRV lookup fails, the code automatically invokes
- the Name Server once more, this time doing an A record
- lookup. Information from an A record lookup differs
- from a SRV record. Default weight and priority values
- are assigned to the A record:
- DEFAULT_WT = 10;
- DEFAULT_PRIO= 10;
- This class also implements a load balancing algorithm
- given a set of equal priority SRV records with differnt
- weight values (re: RFC 2782)
- Dependency:
- BIND 8 - freely downloadable from http://www.isc.org/products/BIND/
- Note that we do not upgrade to BIND 9 due to the following reason:
- from http://www.isc.org/products/BIND/bind9.html site:
- BIND 9.1 is primarily a name server software distribution. In addition
- to the name server, it also includes a new lightweight stub resolver
- library and associated resolver daemon that fully support forward and
- reverse lookups of both IPv4 and IPv6 addresses. This library is still
- considered experimental and is not a complete replacement for the BIND
- 8 resolver library. Applications that use the BIND 8 res_* functions
- to perform DNS lookups or dynamic updates still need to be linked
- against the BIND 8 libraries.............
- << --- last updated on May 17, 2001 by Wendy Breu --- >>