res_mkquery()--Place Domain Query in Buffer


  Syntax
 #include <sys/types.h>
 #include <netinet/in.h>
 #include <arpa/nameser.h>
 #include <resolv.h>

 int res_mkquery(int  operation,
                 char *domain_name,
                 int  class,
                 int  type,
                 char *search_data,
                 int  search_data_length,
                 struct rrec *reserved,
                 char *query_buffer,
                 int  query_buffer_length)

  Service Program Name: QSOSRV2

  Default Public Authority: *USE

  Threadsafe: Yes

The res_mkquery() function is used to make standard query messages (DNS packets) for name servers.


Parameters

operation
(Input) The query operation desired. This gets put into OPCODE in the header of the packet. Common values are listed below (see <arpa/nameser.h> for all possible values):
ns_o_query or QUERY Standard query request. (This value is almost always used.)

domain_name
(Input) The pointer to the name of the domain.

class
(Input) The class of data being looked for. Common values are listed below (see <arpa/nameser.h> for all possible values):
ns_c_in or C_IN Specifies the ARPA Internet.
ns_c_any or C_ANY This is the wildcard match.

type
(Input) The type of request being made. Common values are listed below (see <arpa/nameser.h> for all possible values):
ns_t_a or T_A Host address.
ns_t_aaaa IPv6 address.
ns_t_ns or T_NS Authoritative server.
ns_t_cname or T_CNAME Canonical name.
ns_t_soa or T_SOA Start of authority zone.
ns_t_wks or T_WKS Well-known service.
ns_t_ptr or T_PTR Domain name pointer.
ns_t_hinfo or T_HINFO Host information.
ns_t_mx or T_MX Mail routing information.
ns_t_txt or T_TXT Text strings.
ns_t_any or T_ANY Wildcard match.

search_data
(Input) A buffer containing the data for inverse queries. It is NULL for types other than IQUERY.

search_data_length
(Input) The length of search_data. It is NULL for types other than IQUERY.

reserved
(Input) A reserved and currently unused parameter. It is always a NULL pointer (defined for compatibility).

query_buffer
(Output) A pointer to a user-supplied location containing the query message.

query_buffer_length
(Input) The length of query_buffer.

Authorities:

No authorization is required.


Return Value

res_mkquery() returns an integer. Possible values are:


Error Conditions

When the res_mkquery() function fails, errno can be set to one of the following:

[EFAULT]

The system detected a pointer that was invalid while attempting to access an input pointer.

[EINVAL]

The _res appears to be initialized but the reserved field is not set to zeros.

[EMSGSIZE]

The message buffer was too small. The query was larger than the value of query_buffer_length



Usage Notes

  1. res_mkquery() creates a standard query message (DNS packet). It fills in the header fields, compresses the domain name into the question section, and fills in the other question fields. This query message is placed in query_buffer.

  2. res_mkquery() calls res_init() if the _res structure has not been initialized.

  3. res_mkquery() expects EBCDIC data as input. The output from res_mkquery() is also EBCDIC.

  4. In a thread-enabled environment, the _res structure is shared among all threads within a process.

Related Information



API introduced: V3R1
Top | UNIX-Type APIs | APIs by category