rosell@stolaf.edu (Rob Rosell) (06/12/91)
Greetings Everybody!! I am attemptig to write an applications which will list the hosts in the current domain or within another specified domain. The information needs to be retrieved through the domain name server. The problem is that the man page which I have read over, along with the header files, is rather incomplete in it's explanation of the resolver functions. There are 5 functions listed in the resolver man page. NAME resolver, res_mkquery, res_send, res_init, dn_comp, dn_expand - resolver routines SYNOPSIS #include <sys/types.h> #include <netinet/in.h> #include <arpa/nameser.h> #include <resolv.h> res_mkquery(op, dname, class, type, data, datalen, newrr, buf, buflen) int op; char *dname; int class, type; char *data; int datalen; struct rrec *newrr; char *buf; int buflen; res_send(msg, msglen, answer, anslen) char *msg; int msglen; char *answer; int anslen; res_init() dn_comp(exp_dn, comp_dn, length, dnptrs, lastdnptr) u_char *exp_dn, *comp_dn; int length; u_char **dnptrs, **lastdnptr; dn_expand(msg, msglen, comp_dn, exp_dn, length) u_char *msg, *eomorig, *comp_dn, exp_dn; int length; Supposedly, res_init reads from the initialization file, /etc/resolv.conf I believe, to get the default domain name and Internet address of the initial hosts the name server is running on. I'm fine up to this point. res_mkquery is supposed to construct a query and place it in buf, so that the query may later be sent to the domain name server. Parameters for int op; char *dname; int class, type; char *buf; and int buflen; are given either in the man pages or in the header files. Data, and newrr are completely unmentioned except for a VERY brief statement about newrr in the man page which says it isn't used for anything yet anyway... Ok, supposing I figure out what data is for, I am ready to send my query with res_send. I think that msg is the query we are sending, i.e. buf from res_mkquery. res_send should place the answer from the domain name server in char *answer. I've tried various parameters for res_mkquery but I find no significant results when I attempt to send the query with res_send. The most baffeling members of the resolver functions are dn_comp and dn_expand. Nowhere is there an explanation of *eomorig for dn_expand, or an explanation of why the domainname should be compressed in the first place. I understand the concepts behind these two functions but I am at a loss as to how to use them, or what they're arguements For any and all help I will be most greatfull!!! Thanks! ------------------------------------------------------------------------------- E-Mail: rosell@acc.stolaf.edu SnailMail: Rob Rosell rosell@acc.stolaf.edu Snail Mail: Rob Rosell (The Guy in the Hat) St.Olaf College Computers, Coshmuters, Why do I bother? Northfield, MN 55057 ------------------------------------------------------------------------------
jackv@turnkey.tcc.com (Jack F. Vogel) (06/14/91)
In article <1991Jun11.214929.19156@news.stolaf.edu> rosell@stolaf.edu (Rob Rosell) writes: >Greetings Everybody!! > >I am attemptig to write an applications which will list the hosts in the >current domain or within another specified domain. The information needs >to be retrieved through the domain name server. Why bother reinventing the wheel, get the BIND distribution and build the nslookup utility, it's 'ls' feature does what you want. Also, if you really MUST write something studying the resolver code and the nslookup's use of it should answer all your questions. You can find the distribution on any good archive site, like uunet.uu.net or ucbarpa.Berkeley.Edu. Disclaimer: I don't speak for my employer. -- Jack F. Vogel jackv@locus.com AIX370 Technical Support - or - Locus Computing Corp. jackv@turnkey.TCC.COM