![]() |
libvdns, the Vantages DNS C++ API |
![]() |
| Home | | | Applications | | | libvdns | | | Download | | | Known Issues | | | Documentation | | | Bug Tracker & Feature Requests | | | People |
The libvdns is a C++ library that Vantages uses to do its queries. This library is a general purpose DNS library
whose API is intended to be generally usable for development.
The API is still under development, and has been used, primarily, for querying infrastructure records. Thus, while the library
can send and receive queries for arbitrary DNS types, the list of classes that actually represent RR types is still being developed.
For example, one can query for and receive MX records with libvdns. However, the data returned is kept as an abstract
rdata BLOB in the base class DnsRR. By contrast, querying for a DNSKEY will result in an instance of the class
DnsDnskey. Over time, we will be developing more support for all DNS RR types.
The major components of this API can be broken into the RR types, the message components, the resolver, and
the DNSSEC verification classes. Note: these are just informal distinctions. All classes exists in the library, and the only reason for
discussing them as different components is to explain their relationships at an abstract level.
Currently, headers are installed in the $(prefix)/include/vantages/ directory. In addition, the default installation
process for Vantages installs both libvdns, and the vantaged daemon. In order to install just libvdns, use the following:
$ ./configure --with-vantaged=no
$ make
$ sudo make install
libvdns classes Core classes
Example Code
#include <stdio.h>
#include <string>
#include <vantages/dns_defs.h>
#include <vantages/dns_resolver.h>
#include <vantages/dns_packet.h>
#include <vantages/dns_a.h>
#include <vantages/dns_err.h>
int main(int argc, char *argv[])
{
DnsResolver oRes;
DnsPacket oResp;
std::string sA = "secspider.cs.ucla.edu";
if (!oRes.send(sA, oResp))
{
fprintf(stderr, "Unable to query: '%s'\n", DnsError::getInstance().getError().c_str());
}
else
{
RRList_t oAns;
oResp.getAnswers(oAns);
for (RRIter_t tIter = oAns.begin();
oAns.end() != tIter;
tIter++)
{
if (DNS_RR_A == (*tIter)->type())
{
uint32_t uIP = ((DnsA *) (*tIter))->ip();
fprintf(stdout, "Got IP: %d.%d.%d.%d\n", (uIP>>24)&0x00ff, (uIP>>16)&0x00ff, (uIP>>8)&0x00ff,uIP&0x00ff);
}
}
}
return 0;
}
|
(Contact us at tools