RESOLVER(@LIB_NETWORK_EXT_U@) LOCAL RESOLVER(@LIB_NETWORK_EXT_U@) NAME res_ninit, res_nisourserver, fp_resstat, res_npquery, res_hostalias, res_nquery, res_nsearch, res_nquerydomain, res_nmkquery, res_nsend, res_nupdate, res_nmkupdate, res_nclose, res_nsendsigned, res_nfindprimary, res_nsendupdate, dn_comp, dn_expand, hstrerror, res_init, res_isourserver, p_nquery, res_query, res_search, res_querydomain, res_mkquery, res_send, res_update, res_close, herror - resolver routines SYNOPSIS #include #include #include #include res_ninit(_________ _____) res_nisourserver(_____ _________ _____, _____ ______ ___________ _____) fp_resstat(_____ _________ _____, ____ ___) res_npquery(_____ _________ _____, _____ ______ ____, ___ ______, ____ ___) res_hostalias(_____ _________ _____, _____ ____ _____, ____ ____, ______ ______) res_nquery(_________ _____, _____ ____ ______, ___ _____, ___ ____, ______ _______, ___ ______) res_nsearch(_________ _____, _____ ____ ______, ___ _____, ___ ____, ______ _ ______, ___ ______) res_nquerydomain(_________ _____, _____ ____ _____, _____ ____ _______, ___ _____, ___ ____, ______ _______, ___ ______) res_nmkquery(_________ ______ ___ ___ _____ ____ ______, ___ _____, ___ ____, _____ ______ _____, ___ _______, _____ ______ ______, ______ ____, ___ ______) res_nsend(_________ _____, _____ ______ ____, ___ ______, ______ _______, ___ ______) res_nupdate(_________ _____, _________ _________) res_nmkupdate(_________ _____, _________ _________, ______ ____, ___ ______) res_nclose(_________ _____) res_nsendsigned(_________ _____, _____ ______ ____, ___ ______, ___________ ____, ______ _______, ___ ______) res_nfindprimary(_________ _____, _________ _________, ___________ ____, ____ ______, ___ _____, ______ _______ _____) res_nsendupdate(_________ _____, _________ _________, ___________ ____, ____ ______, ______ _______ ____) dn_comp(_____ ____ _______, ______ ________, ___ ______, ______ _________ ___________) dn_expand(_____ ______ _____ _________ ________, ____ _______, ___ ______) hstrerror(___ ___) DEPRECATED #include #include #include #include res_init(____) res_isourserver(_____ ______ ___________ _____) p_nquery(_____ ______ ____, ___ ______, ____ ___) p_query(_____ ______ ____, ____ ___) hostalias(_____ ____ _____) res_query(_____ ____ ______, ___ ______ ____, ______ _______, ___ ______) res_search(_____ ____ ______, ___ ______ ____, ______ _______, ___ ______) res_querydomain(_____ ____ _____, _____ ____ _______, ___ _____, ___ ____, ______ _______, ___ ______) res_mkquery(___ __, _____ ____ _______ ___ ______ ____, _____ ____ _____, ___ _______, ______ ____ ______, ______ ____, ___ ______) res_send(_____ ______ ____, ___ ______, ______ _______, ___ ______) res_update(_________ _________) res_close(____) herror(_____ ____ __) DESCRIPTION These routines are used for making, sending and interpreting query and reply messages with Internet domain name servers. State information is kept in _____ and is used to control the behavior of these functions. _____ should be set to all zeros prior to the first call to any of these functions. The functions res_init(), res_isourserver(), p_nquery(), p_query(), hostalias(), res_query(), res_search(), res_querydomain(), res_mkquery(), res_send(), res_update(), res_close() and herror() are deprecated and are supplied for compatability with old source code. They use global config- uration and state information that is kept in the structure ____ rather than that referenced through _____ _ Most of the values in _____ and ____ are initialized on the first call to res_ninit() / res_init() to reasonable defaults and can be ignored. Op- tions stored in ______________ / ____________ are defined in ________ and 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 are initialized (i.e., res_ninit() / res_init() has been called). RES_DEBUG Print debugging messages. RES_AAONLY Accept authoritative answers only. should 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 between queries. This is useful only in programs that regularly do many queries. UDP should be the normal mode used. RES_IGNTC Ignore truncation errors, i.e., don't retry with TCP. RES_RECURSE Set the recursion-desired bit in queries. This is the default. (res_nsend() / res_send() does not do iterative queries and ex- pects the name server to handle recursion.) RES_DEFNAMES If set, res_nsearch() / res_search() will append the default do- main 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_nsearch() / res_search() will search for host names in the current domain and in parent domains; see hostname(@DESC_EXT@). This is used by the standard host lookup routine gethostbyname(@LIB_NETWORK_EXT@). This option is en- abled by default. RES_NOALIASES This option turns off the user level aliasing feature controlled by the HOSTALIASES environment variable. Network daemons should set this option. RES_USE_INET6 This option causes gethostbyname(@LIB_NETWORK_EXT@) to look for AAAA records before looking for A records if none are found. RES_ROTATE This options causes the res_nsend() / res_send() to rotate the list of nameservers in __________________ / ________________. RES_KEEPTSIG This option causes res_nsendsigned() to leave the message un- changed after TSIG verification; otherwise the TSIG record would be removed and the header updated. The res_ninit() / res_init() routine reads the configuration file (if any; see resolver(@FORMAT_EXT@)) to get the default domain name, search list and the Internet address of the local name server(s). If no server is configured, the host running the resolver is tried. The current do- main name is defined by the hostname if not specified in the configura- tion file; it can be overridden by the environment variable LOCALDOMAIN. This environment variable may contain several blank-separated tokens if you wish to override the ``search list'' on a per-process basis. This is similar to the search command in the configuration file. Another envi- ronment variable (``RES_OPTIONS'') can be set to override certain inter- nal resolver options which are otherwise set by changing fields in the _____ / ____ structure or are inherited from the configuration file's options command. The syntax of the ``RES_OPTIONS'' environment variable is explained in resolver(@FORMAT_EXT@). Initialization normally occurs on the first call to one of the other resolver routines. The res_nquery() / res_query() functions provides interfaces to the serv- er query mechanism. They constructs a query, sends it to the local serv- er, awaits a response, and makes preliminary checks on the reply. The query requests information of the specified ____ and _____ for the speci- fied fully-qualified domain name _____. The reply message is left in the ______ buffer with length ______ supplied by the caller. res_nquery() / res_query() return -1 on error or the length of the answer. The res_nsearch() / res_search() routines make a query and awaits a re- sponse like res_nquery() / res_query(), but in addition, it implements the default and search rules controlled by the RES_DEFNAMES and RES_DNSRCH options. It returns the length of the first successful reply which is stored in ______ or -1 on error. The remaining routines are lower-level routines used by res_nquery() / res_query(). The res_nmkquery() / res_mkquery() functions constructs a standard query message and places it in ___. It returns the size of the query, or -1 if the query is larger than ______. The query type __ is usually QUERY, but can be any of the query types defined in ________________. The domain name for the query is given by _____. _____ is currently unused but is intended for making update messages. The res_nsend() / res_send() / res_nsendsigned() routines sends a pre- formatted query and returns an answer. It will call res_ninit() / res_init() if RES_INIT is not set, send the query to the local name serv- er, and handle timeouts and retries. Additionally, res_nsendsigned() will use TSIG signatures to add authentication to the query and verify the response. In this case, only one nameserver will be contacted. The length of the reply message is returned, or -1 if there were errors. res_nquery() / res_query(), res_nsearch() / res_search() and res_nsend() / res_send() return a length that may be bigger than ______. In that case the query should be retried with a bigger buffer. NOTE the answer to the second query may be larger still so supplying a buffer that bigger that the answer returned by the previous query is recommended. ______ MUST be big enough to receive a maximum UDP response from the server or parts of the answer will be silently discarded. The default maximum UDP response size is 512 bytes. The functions res_nisourserver() / res_isourserver() return true when ___ is one of the servers in __________________ / ________________. The functions res_npquery() / p_nquery() / p_query() print out the query and any answer in ___ on __. p_query() is equivalent to p_nquery() with ______ set to 512. The function fp_resstat() prints out the active flag bits in ______________ preceeded by the text ";; res options:" on ____. The functions res_hostalias() / hostalias() lookup up name in the file referred to by the HOSTALIASES files return a fully qualified hostname if found not found or an error occurred. res_hostalias() uses ___ to store the result in, hostalias() uses a static buffer. The functions res_nupdate() / res_update() take a list of ns_updrec ________. Identifies the containing zone for each record and groups the records according to containing zone maintaining in zone order then sends and update request to the servers for these zones. The number of zones updated is returned or -1 on error. The functions res_nfindprimary() / res_nsendupdate() are used to perform TSIG authenticated dynamic update operations. res_nfindprimary() deter- mines the zone to be updated and the IP address of the primary server, using authenticated queries (to only one nameserver) if the key is not NULL. res_nsendupdate() sends a dynamic update to the specified IP ad- dress, authenticating the update if the key is not NULL. The functions res_nmkupdate() / res_mkupdate() take a linked list of ns_updrec ________ and construct a UPDATE message in ___. res_nmkupdate() / res_mkupdate() return the length of the constructed message on no error or one of the following error values. -1 An error occurred parsing ________. -2 The buffer ___ was too small. -3 The first record was not a zone section or there was a section order problem. The section order is S_ZONE, S_PREREQ and S_UPDATE. -4 A number overflow occurred. -5 Unknown operation or no records. The functions res_nclose() / res_close() close any open files referenced through _____ / ____. The dn_comp() function compresses the domain name ______ and stores it in _______. The size of the compressed name is returned or -1 if there were errors. The size of the array pointed to by _______ is given by ______. The compression uses an array of pointers ______ to previously-compressed names in the current message. The first pointer points to to the begin- ning of the message and the list ends with NULL. The limit to the array is specified by _________. A side effect of dn_comp() is to update the list of pointers for labels inserted into the message as the name is com- pressed. If _____ is NULL, names are not compressed. If _________ is NULL, the list of labels is not updated. The dn_expand() entry expands the compressed domain name _______ to a full domain name. The compressed name is contained in a query or reply message; ___ is a pointer to the beginning of the message. The uncom- pressed name is placed in the buffer indicated by ______ which is of size ______. The size of compressed name is returned or -1 if there was an er- ror. The variables __________________ / ________________ and external variable _______ is set whenever an error occurs during resolver operation. The following definitions are given in _________: #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-Authoritative not found, or SERVFAIL */ #define NO_RECOVERY 3 /* Non-Recoverable: FORMERR, REFUSED, NOTIMP */ #define NO_DATA 4 /* Valid name, no data for requested type */ The herror() function writes a message to the diagnostic output consist- ing of the string parameter _, the constant string ": ", and a message corresponding to the value of _______ _ The hstrerror() function returns a string which is the message text cor- responding to the value of the ___ parameter. FILES /etc/resolv.conf See resolver(@FORMAT_EXT@). SEE ALSO gethostbyname(@LIB_NETWORK_EXT@), hostname(@DESC_EXT@), @INDOT@named(@SYS_OPS_EXT@), resolver(@FORMAT_EXT@); RFC1032, RFC1033, RFC1034, RFC1035, RFC974; SMM:11, ``Name Server Operations Guide for BIND'' 4th Berkeley Distribution October 19, 1998 6