RESOLVER
NAMESYNOPSIS
DESCRIPTION
RETURN VALUE
FILES
CONFORMING TO
SEE ALSO
COLOPHON
NAME
res_init, res_query, res_search, res_querydomain, res_mkquery, res_send, dn_comp, dn_expand − resolver routines
SYNOPSIS
#include
<netinet/in.h>
#include <arpa/nameser.h>
#include <resolv.h>
extern struct __res_state _res;
int res_init(void);
int res_query(const char *dname, int class, int type,
unsigned char *answer, int anslen);
int res_search(const char *dname, int class, int type,
unsigned char *answer, int anslen);
int res_querydomain(const char *name, const char *domain,
int class,
int type, unsigned char *answer,
int anslen);
int res_mkquery(int op, const char *dname, int class,
int type,
const unsigned char *data, int
datalen,
const unsigned char *newrr, unsigned char
*buf, int buflen);
int res_send(const unsigned char *msg, int msglen,
unsigned char *answer, int anslen);
int dn_comp(const char *exp_dn, unsigned char *comp_dn,
int length, unsigned char **dnptrs, unsigned char **lastdnptr);
int dn_expand(const unsigned char *msg, const unsigned char *eomorig,
const unsigned char
*comp_dn, char *exp_dn,
int length);
Link with −lresolv.
DESCRIPTION
These functions make queries to and interpret the responses from Internet domain name servers.
The res_init() function reads the configuration files (see resolv.conf(5)) to get the default domain name, search order and name server address(es). If no server is given, the local host is tried. If no domain is given, that associated with the local host is used. It can be overridden with the environment variable LOCALDOMAIN. res_init() is normally executed by the first call to one of the other functions.
The res_query() function queries the name server for the fully qualified domain name name of specified type and class. The reply is left in the buffer answer of length anslen supplied by the caller.
The res_search() function makes a query and waits for the response like res_query(), but in addition implements the default and search rules controlled by RES_DEFNAMES and RES_DNSRCH (see description of _res options below).
The res_querydomain() function makes a query using res_query() on the concatenation of name and domain.
The following functions are lower-level routines used by res_query().
The res_mkquery() function constructs a query message in buf of length buflen for the domain name dname. The query type op is usually QUERY, but can be any of the types defined in <arpa/nameser.h>. newrr is currently unused.
The res_send() function sends a preformatted query given in msg of length msglen and returns the answer in answer which is of length anslen. It will call res_init(), if it has not already been called.
The dn_comp() function compresses the domain name exp_dn and stores it in the buffer comp_dn of length length. The compression uses an array of pointers dnptrs 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 limit of the array is specified by lastdnptr. If dnptr is NULL, domain names are not compressed. If lastdnptr is NULL, the list of labels is not updated.
The dn_expand() function expands the compressed domain name comp_dn to a full domain name, which is placed in the buffer exp_dn of size length. The compressed name is contained in a query or reply message, and msg points to the beginning of the message.
The resolver
routines use global configuration and state information
contained in the structure _res, which is defined in
<resolv.h>. The only field that is normally
manipulated by the user is _res.options. This field
can contain the bitwise "OR" of the following
options:
RES_INIT
True if res_init() has been called.
RES_DEBUG
Print debugging messages. This option is available only if glibc was built with debugging enabled, which is not the default.
RES_AAONLY
Accept authoritative answers only. res_send() continues until it finds an authoritative answer or returns an error. [Not currently implemented].
RES_USEVC
Use TCP connections for queries rather than UDP datagrams.
RES_PRIMARY
Query primary domain name server only.
RES_IGNTC
Ignore truncation errors. Don’t retry with TCP. [Not currently implemented].
RES_RECURSE
Set the recursion desired bit in queries. Recursion is carried out by the domain name server, not by res_send(). [Enabled by default].
RES_DEFNAMES
If set, res_search() will append the default domain name to single component names—that is, those that do not contain a dot. [Enabled by default].
RES_STAYOPEN
Used with RES_USEVC to keep the TCP connection open between queries.
RES_DNSRCH
If set, res_search() will search for hostnames in the current domain and in parent domains. This option is used by gethostbyname(3). [Enabled by default].
This list is not complete. You can find some other flags described in resolv.conf(5).
RETURN VALUE
The res_init() function returns 0 on success, or −1 if an error occurs.
The res_query(), res_search(), res_querydomain(), res_mkquery() and res_send() functions return the length of the response, or −1 if an error occurs.
The dn_comp() and dn_expand() functions return the length of the compressed name, or −1 if an error occurs.
FILES
/etc/resolv.conf
resolver configuration file
/etc/host.conf resolver configuration file
CONFORMING TO
4.3BSD.
SEE ALSO
gethostbyname(3), resolv.conf(5), resolver(5), hostname(7), named(8)
COLOPHON
This page is part of release 3.69 of the Linux man-pages project. A description of the project, information about reporting bugs, and the latest version of this page, can be found at http://www.kernel.org/doc/man−pages/.
More Linux Commands
manpages/pack200-java-1.8.0-openjdk.1.html
pack200-java-1.8.0-openjdk(1) Packages a JAR file into a com
The pack200 command is a Java application that transforms a JAR file into a compressed pack200 file with the Java gzip compressor. The pack200 files are highly
manpages/XGetTextProperty.3.html
XGetTextProperty(3) - set and read text properties (ManPage)
The XSetTextProperty function replaces the existing specified property for the named window with the data, type, format, and number of items determined by the v
manpages/free_menu.3menu.html
free_menu(3menu) - create and destroy menus - Linux man page
free_menu.3menu - The function new_menu creates a new menu connected to a specified item pointer array (which must be NULL-terminated). The function free_menu d
manpages/smistrip.1.html
smistrip(1) - extract MIB or PIB modules from text files, li
The smistrip program is used to extract MIB and PIB module files from ASCII documents like RFCs or Internet Drafts. Modules are identified by a starting ASN.1 D
manpages/gjar.1.html
gjar(1) - - Archive tool for Java archives - Linux man page
gjar is an implementation of Suns jar utility that comes with the JDK . If any file is a directory then it is processed recursively. The manifest file name and
manpages/kmousetool.1.html
kmousetool(1) - Accessibility tool to help click the mouse
KMouseTool clicks the mouse whenever the mouse cursor pauses briefly. It was designed to help those with repetitive strain injuries, for whom pressing buttons h
manpages/rt_tgsigqueueinfo.html
rt_tgsigqueueinfo(2) - queue a signal and data to a process
RETURN VALUE ERRORS VERSIONS CONFORMING TO NOTES SEE ALSO COLOPHON NAME rt_sigqueueinfo - queue a signal and data to a process SYNOPSIS long sys_rt_sigqueueinfo
manpages/crypt_ra.3.html
crypt_ra(3) - password hashing (Library - Linux man page)...
The crypt, crypt_r, crypt_rn, and crypt_ra functions calculate a cryptographic hash function of key with one of a number of supported methods as requested with
manpages/wunctrl.3ncurses.html
wunctrl(3ncurses) - miscellaneous curses utility routines...
The unctrl routine returns a character string which is a printable representation of the character c, ignoring attributes. Control characters are displayed in t
manpages/arpwatch.8.html
arpwatch(8) - keep track of ethernet/ip address pairings....
Arpwatch keeps track for MAC/IP address pairings. It syslogs activity and reports certain changes via email. Arpwatch uses pcap(3) to listen for arp packets on
manpages/uptime.1.html
uptime(1) - tell how long the system has been running.......
Print the current time, the length of time the system has been up, the number of users on the system, and the average number of jobs in the run queue over the l
manpages/rsa.1ssl.html
rsa(1ssl) - RSA key processing tool - Linux manual page.....
The rsa command processes RSA keys. They can be converted between various forms and their components printed out. Note this command uses the traditional SSLeay
