res_mkquery(3) — Subroutines
NAME
res_mkquery − Make query messages for name servers
SYNOPSIS
#include <sys/types.h>
#include <netinet/in.h>
#include <arpa/nameser.h>
#include <resolv.h> int res_mkquery(
int query_type,
const u_char ∗domain_name,
int class,
int type,
const char ∗data,
int data_length,
const u_char ∗reserved,
u_char ∗buffer,
int buf_length );
LIBRARY
Standard C Library (libc)
PARAMETERS
query_type
Specifies a query type. The usual type is QUERY, but the parameter can be set to any of the query types defined in the arpa/nameser.h file.
domain_name
Points to the name of the domain. If the domain_name parameter points to a single label and the RES_DEFNAMES bit is set, as it is by default, the function appends domain_name to the current domain name. The current domain name is defined by the name server in use or in the /etc/resolv.conf file.
class
Specifies one of the following parameters:
C_INSpecifies the ARPA Internet.
C_CHAOS
Specifies the Chaos network at MIT.
typeRequires one of the following values:
T_AHost address
T_NSAuthoritative server
T_MDMail destination
T_MFMail forwarder
T_CNAME
Canonical name
T_SOAStart of authority zone
T_MBMailbox domain name
T_MGMail group member
T_MRMail rename name
T_NULL
NULL resource record
T_WKSWell known service
T_PTRDomain name pointer
T_HINFO
Host information
T_MINFO
Mailbox information
T_MXMail routing information
T_UINFO
User (finger) information
T_UIDUser ID
T_GIDGroup ID
dataPoints to the data that is sent to the name server as a search key. The data is stored as a character array.
data_length
Defines the size of the array pointed to by the data parameter.
reserved
Specifies a reserved and currently unused parameter.
buffer
Points to a location containing the query message.
buf_length
Specifies the length of the message pointed to by the buffer parameter.
DESCRIPTION
The res_mkquery() function makes packets for name servers in the Internet domain. The res_mkquery() function makes a standard query message and places it in the location pointed to by the buffer parameter.
The res_mkquery() function is one of a set of subroutines that form the resolver, a set of functions that resolve domain names. Global information that is used by the resolver functions is kept in the _res data structure. The /include/resolv.h file contains the _res data structure definition.
RETURN VALUES
Upon successful completion, the res_mkquery() function returns the size of the query. If the query is larger than the value of the buf_length parameter, the function fails and returns a value of -1.
ERRORS
If an error occurs during a resolver operation, the h_errno external variable is set. Error code values and reasons are defined in <netdb.h>.
FILES
/etc/resolv.conf
Contains the name server and domain name.
SEE ALSO
Functions: dn_comp(3), dn_expand(3), dn_find(3), dn_skipname(3), _getlong(3), _getshort(3), putlong(3), putshort(3), res_init(3), res_query(3), res_search(3), res_send(3).