res_mkquery()

Construct an Internet domain name query

Synopsis:

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

int res_mkquery( int op, 
                 const char * dname, 
                 int class,
                 int type, 
                 const u_char * data, 
                 int datalen,
                 const u_char * newrr,
                 u_char * buf, 
                 int buflen );

Arguments:

op
Usually QUERY, but it can be also IQUERY or NS_NOTIFY_OP. Note that not all of the query types defined in <arpa/nameser.h> are supported.
dname
The domain name for the query.
class
The class of information that you want; one of:
  • C_IN — ARPA Internet.
  • C_CHAOS — Chaos net (MIT).
  • C_HS — Hesiod name server (MIT).
  • C_ANY — any class.

You typically use C_IN.

type
The type of information that you want. You typically use T_PTR, but you can use any of the T_* constants defined in <arpa/nameser.h>.
data
NULL, or a pointer to resource record data.
datalen
The length of the data.
newrr
Currently unused. This argument is intended for making update messages.
buf
A pointer to a buffer where the function can build the query.
buflen
The length of the buffer.

Library:

libsocket

Use the -l socket option to qcc to link against this library.

Description:

The res_mkquery() function is a low-level routine that's used by res_query() to construct an Internet domain name query. This routine constructs a standard query message and places it in buf. It returns the size of the query, or -1 if the query is larger than buflen.

The resolver routines are used for making, sending, and interpreting query and reply messages with Internet domain name servers. Global configuration and state information used by the resolver routines is kept in the structure _res. For more information on the options, see res_init().

Based on:

RFC 974, RFC 1032, RFC 1033, RFC 1034, RFC 1035

Returns:

The size of the prepared query, in bytes, or -1 if an error occurs.

Files:

/etc/resolv.conf
Resolver configuration file.

Environment variables:

LOCALDOMAIN
When set, LOCALDOMAIN contains a domain name that overrides the current domain name.

Classification:

Unix

Safety:  
Cancellation point Yes
Interrupt handler No
Signal handler No
Thread No