RESOLVER(3,L) AIX Technical Reference RESOLVER(3,L)
-------------------------------------------------------------------------------
resolver: res_mkquery, res_send, res_init, dn_comp,
dn_expand, getshort, getlong, putshort, putlong
PURPOSE
Makes, sends, and interprets name server information.
LIBRARY
Internet Library (libc.a)
SYNTAX
#include <sys/types.h>
#include <netinet/in.h>
#include <arpa/nameser.h>
#include <resolv.h>
res_query (name, class, type, answer, anslen)
char *name;
int class, type;
u_char *answer;
int anslen;
res_search (name, class, type, answer, anslen)
char *name;
int class, type;
u_char *answer;
int anslen;
res_querydomain (name, domain, class, type, answer, anslen)
char *name; *domain;
int class, type;
u_char *answer;
int anslen;
int res_mkquery(op, dname, class, type, data, datalen, resource buf, buflen)
int op;
char *dname;
int class, type;
char *data;
int datalen;
struct rrec *resource;
char *buf;
int buflen;
int res_send (msgp, msglen, answer, anslen)
char *msgp;
int msglen;
Processed November 7, 1990 RESOLVER(3,L) 1
RESOLVER(3,L) AIX Technical Reference RESOLVER(3,L)
char *answer;
int anslen;
res_init()
int dn_comp(exp_dn, comp_dn, length, dnptrs, lastdnptr)
char *exp_dn, *comp_dn;
int length;
char **dnptrs, **lastdnptr;
int dn_expand(msgp, eomorig, comp_dn, exp_dn, length)
char *msgp, *eomorig
char *comp_dn, *exp_dn;
int length;
dn_expand (msg, eomorig, comp_dn, exp_dn, length)
u_char *msg, *eomorig *comp_dn, *exp_dn;
int length;
dn_find (exp_dn, msg, dnptrs, lastdnptr)
char *exp_dn, *msg;
char **dnptrs **lastdnptr;
unsigned short getshort (msgp)
char *msgp;
unsigned long getlong (msgp)
char *msgp;
putshort (short, msgp)
unsigned short short;
char *msgp;
putlong (long, msgp)
unsigned long long;
char *msgp;
DESCRIPTION
The res_query, res_mkquery, res_search, res_send, res_init, res_querydomain,
dn_comp, dn_expand, getshort, getlong, putshort, and putlong subroutines are
used to make, send, and interpret packets for name servers in the Internet
domain. Together these subroutines form the resolver, a set of functions that
resolves domain names.
Global information that is used by these resolver subroutines is kept in the
_res structure. This structure is defined in the resolv.h header file, and it
contains the following members:
Processed November 7, 1990 RESOLVER(3,L) 2
RESOLVER(3,L) AIX Technical Reference RESOLVER(3,L)
int retrans;
int retry;
long options;
int nscount;
struct sockaddr_in nsaddr_list[MAXNS];
ushort id;
char defdname[MAXDNAME]
#define nsaddr nsaddr_list[0]
The options field of the _res structure is constructed by logically ORing the
following values:
RES_INIT Indicates whether the initial name server and default domain
name have been initialized (that is, whether res_init has been
called).
RES_DEBUG Prints debugging messages.
RES_USEVC Uses TCP instead of UDP connections for queries.
RES_STAYOPEN Used with RES_USEVC to keep the TCP connection open between
queries. While UDP is the mode normally used, TCP mode and this
option are useful for programs that regularly do many queries.
RES_RECURSE Sets the recursion desired bit in queries. This is the default.
(res_send does not do iterative queries and expects the name
server to handle recursion.)
RES_DEFNAMES Appends the default domain name to single label queries. This
is the default.
The res_mkquery subroutine makes a standard query message and places it in the
location pointed to by the buf parameter, which has a length that is specified
by the buflen parameter. The op parameter is usually QUERY but can be set to
any of the query types defined in the arpa/nameser.h header file, as listed
below:
QUERY Standard query
IQUERY Inverse query
CQUERYM Completion query (multiple)
CQUERYU Completion query (unique)
The dname parameter points to the name of the domain. If the value pointed to
by dname is a single label and the RES_DEFNAMES bit is set, as it is by
default, dname is appended with the current domain name. The current domain
name is defined by the name server in use or in the /etc/resolv.conf file.
The class parameter has one of the following values:
Processed November 7, 1990 RESOLVER(3,L) 3
RESOLVER(3,L) AIX Technical Reference RESOLVER(3,L)
C_IN Specifies the ARPA Internet
C_CHAOS Specifies the chaos network at MIT
The type parameter has a value taken from the following list:
T_A Host address
T_NS Authoritative server
T_MD Mail destination
T_MF Mail forwarder
T_CNAME Cannonical name
T_SOA Start of authority zone
T_MB Mailbox domain name
T_MG Mail group member
T_MR Mail rename name
T_NULL NULL resource record
T_WKS Well-known service
T_PTR Domain name pointer
T_HINFO Host information
T_MINFO Mailbox information
T_MX Mail routing information
T_UINFO User (finger) information
T_UID User ID
T_GID Group ID
The data parameter is a pointer to the data to be sent to the name server as a
search key, and the datalen parameter defines the size of that data.
The resource parameter is a pointer to resource records.
The res_query subroutine formulates a normal query, sends, and awaits answer.
The returned answer is placed in the supplied buffer answer. It performs a
preliminary check of answer and if no error is indicated and the answer count
is nonzero, res_query returns the size of the response on success only; on
Processed November 7, 1990 RESOLVER(3,L) 4
RESOLVER(3,L) AIX Technical Reference RESOLVER(3,L)
error, it returns a value of -1. The error number is left in h_errno. The
caller must parse answer and determine whether it answers the question.
The res_search subroutine formulates a normal query, sends, and retrieves the
answer in the supplied buffer. res_search returns the size of the response on
success and a value of -1 on error. If enabled, res_search implements search
rules until answer or unrecoverable failure is detected. The error number is
left in h_errno. This subroutine is only useful for queries in the same name
hierarchy as the local host.
The res_querydomain subroutine performs a call on res_query on the
concatenation of name and domain, removing a trailing dot from name if the
domain is NULL.
The res_send subroutine sends a query to name servers, calling the res_init
subroutine if RES_INIT is not set. This subroutine sends the query to the
local name server and handles timeouts and retries.
The res_init subroutine reads the /etc/resolv.conf file for the default domain
name and Internet address of the initial hosts running the name server. If
this line does not exist, the res_init subroutine tries the host from which it
was called.
The dn_comp subroutine compresses the domain name pointed to by the exp_dn
parameter and stores it in the area pointed to by the comp_dn parameter. The
length parameter is the size of the array pointed to by the comp_dn parameter.
The dnptrs parameter is a list of pointers to previously compressed names in
the current message. The first pointer points to the beginning of the message
and the list ends with NULL. The lastdnptr parameter is a pointer to the end
of the array pointed to by the dnptrs parameter.
A side effect of this subroutine is to update the list of pointers for labels
that the dn_comp subroutine inserts into the message as the name is compressed.
No names are compressed if the value of dnptrs is NULL. If the lastdnptr
parameter is NULL, the list of pointers is not updated.
The dn_expand subroutine expands the compressed domain name pointed to by the
comp_dn parameter to a full domain name, converting the expanded names to
uppercase. The msgp parameter is a pointer to the beginning of the message.
The exp_dn parameter is a pointer to a buffer, of the size specified by the
length parameter, that holds the result. The emorig parameter points to the
end of the original message, which contains the compressed domain name.
The dn_skipname subroutine skips over a compressed domain name.
The dn_find subroutine searches for an expanded domain name from a list of
previously compressed names and returns the offset from msg, if found.
The getshort and getlong subroutines get quantities from the byte stream or
arbitrary byte boundaries. The putshort and putlong subroutines put quantities
into the byte stream or arbitrary byte boundaries. The msgp parameter for all
of these subroutines represents a pointer into the byte stream.
Processed November 7, 1990 RESOLVER(3,L) 5
RESOLVER(3,L) AIX Technical Reference RESOLVER(3,L)
RETURN VALUE
The res_mkquery subroutine returns the size of the query on success. A value
of -1 is returned if the subroutine fails because the query is larger than the
value of the buflen parameter. The res_send subroutine returns the length of
the message if it succeeds and a value of -1 if it fails. The dn_comp
subroutine returns the size of the compressed domain name if it succeeds. A
value of -1 is returned if the subroutine fails. The dn_expand subroutine
returns the size of the expanded domain name on success. A value of -1 is
returned if dn_expand fails. The getshort and getlong subroutines return a
short and a long value, respectively.
FILE
/etc/resolv.conf Contains name server and domain name information.
RELATED INFORMATION
See "resolver" in AIX TCP/IP User's Guide, Chapter 2.
Processed November 7, 1990 RESOLVER(3,L) 6