SEARCH
NEW RPMS
DIRECTORIES
ABOUT
FAQ
VARIOUS
BLOG

BotDetect - Real-Time Bot Detection API
 
 

MAN page from Old RedHat 5.X bind-4.9.6-11.i386.rpm

RESOLVER

Section: C Library Functions (3)
Updated: December 11, 1995
Index 

NAME

res_query, res_search, 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_query(dname, class, type, answer, anslen)
const char *dname;
int class, type;
u_char *answer;
int anslen;

res_search(dname, class, type, answer, anslen)
const char *dname;
int class, type;
u_char *answer;
int anslen;

res_mkquery(op, dname, class, type, data, datalen, newrr, buf, buflen)
int op;
const char *dname;
int class, type;
const char *data;
int datalen;
struct rrec *newrr;
u_char *buf;
int buflen;

res_send(msg, msglen, answer, anslen)
const u_char *msg;
int msglen;
u_char *answer;
int anslen;

res_init()

dn_comp(exp_dn, comp_dn, length, dnptrs, lastdnptr)
const char *exp_dn;
u_char *comp_dn;
int length;
u_char **dnptrs, **lastdnptr;

dn_expand(msg, eomorig, comp_dn, exp_dn, length)
const u_char *msg, *eomorig, *comp_dn;
char *exp_dn;
int length;

herror(const char *s)

hstrerror(int err) 

DESCRIPTION

These routines are used for making, sending and interpretingquery and reply messages with Internet domain name servers.

Global configuration and state information that is used by theresolver routines is kept in the structure_res.Most of the values have reasonable defaults and can be ignored.Optionsstored in_res.optionsare defined inresolv.hand are as follows.Options are stored as a simple bit mask containing the bitwise ``or''of the options enabled.

RES_INIT
True if the initial name server address and default domain name areinitialized (i.e.,res_inithas been called).
RES_DEBUG
Print debugging messages.
RES_AAONLY
Accept authoritative answers only.With this option,res_sendshould continue until it finds an authoritative answer or finds an error.Currently this is not implemented.
RES_USEVC
Use TCP connections for queries instead of UDP datagrams.
RES_STAYOPEN
Used with RES_USEVC to keep the TCP connection open betweenqueries.This is useful only in programs that regularly do many queries.UDP should be the normal mode used.
RES_IGNTC
Unused currently (ignore truncation errors, i.e., don't retry with TCP).
RES_RECURSE
Set the recursion-desired bit in queries.This is the default.(res_senddoes not do iterative queries and expects the name serverto handle recursion.)
RES_DEFNAMES
If set,res_searchwill append the default domain name to single-component names(those that do not contain a dot).This option is enabled by default.
RES_DNSRCH
If this option is set,res_searchwill search for host names in the current domain and in parent domains; seehostname(7).This is used by the standard host lookup routinegethostbyname(3).This option is enabled by default.
RES_NOALIASES
This option turns off the user level aliasing feature controlled bythe HOSTALIASES environment variable. Network daemons should set this option.

Theres_initroutinereads the configuration file (if any; seeresolver(5))to get the default domain name,search list andthe Internet address of the local name server(s).If no server is configured, the host runningthe resolver is tried.The current domain name is defined by the hostnameif not specified in the configuration file;it can be overridden by the environment variable LOCALDOMAIN.This environment variable may contain several blank-separatedtokens if you wish to override thesearch liston a per-process basis. This is similar to thesearchcommand in the configuration file.Another environment variable (``RES_OPTIONS'') can be set tooverride certain internal resolver options which are otherwiseset by changing fields in the_resstructure or are inherited from the configuration file'soptionscommand. The syntax of the ``RES_OPTIONS'' environment variableis explained inresolver(5).Initialization normally occurs on the first callto one of the other resolver routines.

Theres_queryfunction provides an interface to the server query mechanism.It constructs a query, sends it to the local server,awaits a response, and makes preliminary checks on the reply.The query requests information of the specifiedtypeandclassfor the specified fully-qualified domain namedname .The reply message is left in theanswerbuffer with lengthanslensupplied by the caller.

Theres_searchroutine makes a query and awaits a response likeres_query,but in addition, it implements the default and search rulescontrolled by the RES_DEFNAMES and RES_DNSRCH options.It returns the first successful reply.

The remaining routines are lower-level routines used byres_query.Theres_mkqueryfunctionconstructs a standard query message and places it inbuf.It returns the size of the query, or -1 if the query islarger thanbuflen.The query typeopis usually QUERY, but can be any of the query types defined in<arpa/nameser.h>.The domain name for the query is given bydname.Newrris currently unused but is intended for making update messages.

Theres_sendroutinesends a pre-formatted query and returns an answer.It will callres_initif RES_INIT is not set, send the query to the local name server, andhandle timeouts and retries.The length of the reply message is returned, or-1 if there were errors.

Thedn_compfunctioncompresses the domain nameexp_dnand stores it incomp_dn.The size of the compressed name is returned or -1 if there were errors.The size of the array pointed to bycomp_dnis given bylength.The compression usesan array of pointersdnptrsto previously-compressed names in the current message.The first pointer points toto the beginning of the message and the list ends with NULL.The limit to the array is specified bylastdnptr.A side effect ofdn_compis to update the list of pointers forlabels inserted into the messageas the name is compressed.Ifdnptris NULL, names are not compressed.Iflastdnptris NULL, the list of labels is not updated.

Thedn_expandentryexpands the compressed domain namecomp_dnto a full domain nameThe compressed name is contained in a query or reply message;msgis a pointer to the beginning of the message.The uncompressed name is placed in the buffer indicated byexp_dnwhich is of sizelength.The size of compressed name is returned or -1 if there was an error.

The external variableh_errnois set whenever an error occurs during resolver operation. The followingdefinitions are given in<netdb.h>:

#define NETDB_INTERNAL -1  /* see errno */#define NETDB_SUCCESS  0   /* no problem */#define HOST_NOT_FOUND 1   /* Authoritative Answer Host not found */#define TRY_AGAIN      2   /* Non-Authoritive not found, or SERVFAIL */#define NO_RECOVERY    3   /* Nonrecoverable: FORMERR, REFUSED, NOTIMP */#define NO_DATA        4   /* Valid name, no data for requested type */

Theherrorfunction writes a message to the diagnostic output consisting of the stringparameters,the constant string ": ", and a message corresponding to the value ofh_errno.

Thehstrerrorfunction returns a string which is the message text corresponding to thevalue of theerrparameter. 

FILES

/etc/resolv.conf       see resolver(5)
 

SEE ALSO

gethostbyname(3), named(8), resolver(5), hostname(7),
RFC1032, RFC1033, RFC1034, RFC1035, RFC974,
SMM:11 Name Server Operations Guide for BIND


 

Index

NAME
SYNOPSIS
DESCRIPTION
FILES
SEE ALSO

This document was created byman2html,using the manual pages.
 
ICM Bot detect detector