Re: NS rr set from libdns

Laurent Bercot <[email protected]>
Newsgroups gmane.network.djbdns
Message-ID <[email protected]>
> Hello;
> I recently began using the libdns routines to make my C program to
> DNS lookups. As advertised, it's fun! It's easy!

 Depending on what you're doing, you might be interested in skadns:
 http://www.skarnet.org/software/skadns/

 It's built upon DJB's libdns.
 The difference with using libdns directly is that with libdns, you
have to include all of your DNS queries into your main loop, which
might be impractical if said loop is already handling a lot of different
sources of file descriptors. skadns hides the internal DNS stuff from
you; it gives you one file descriptor to select on, and only triggers it
on completed queries.

 Of course, it won't help you at all if you're interested in sending
basic iterative queries more than in just getting the result of standard
recursive queries. In other words, skadns allows you to perform several
"dnsqr" simultaneously, but if you want to perform several "dnsq"
simultaneously, you'll still have to do it by hand with libdns.


> What would you do to get NS records with libdns?

 As Paul said, your best bet is to construct a packet by hand, taking
inspiration from the internals of dns_ip4() and friends. You can have
a look at how dnscache does.

 If using skadns, the right way to send a NS query for "example.com"
would be something like:

 #include "dns.h"
 #include "skadns.h"

 ...

 char *domain = "example.com." ;
 char *q = 0 ;
 uint16 id ;

 ...

 if (!dns_domain_fromdot(q, domain, strlen(domain))) die() ;
 id = skadns_send(a, q, DNS_T_NS) ; /* a being your skadns stuff pointer */

-- 
 Laurent
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.