[ Next Article | Previous Article | Book Contents | Library Home | Legal | Search ]
Communications Technical Reference, Volume 2

res_mkquery Subroutine

Purpose

Makes query messages for name servers.

Library

Standard C Library (libc.a)

Syntax

#include <sys/types.h>
#include <netinet/in.h>
#include <arpa/nameser.h>
#include <resolv.h>
int res_mkquery (Operation, DomName, Class, Type, Data, DataLength)
int res_mkquery (ReservedBuffer, BufferLength)
int Operation;
char *DomName;
int Class, Type;
char *Data;
int DataLength;
struct rrec *Reserved;
char *Buffer;
int BufferLength;

Description

The res_mkquery subroutine creates packets for name servers in the Internet domain. The subroutine also creates a standard query message. The Buffer parameter determines the location of this message.

The res_mkquery subroutine is one of a set of subroutines that form the resolver, a set of functions that resolve domain names. Global information used by the resolver subroutines is kept in the _res data structure. The /usr/include/resolv.h file contains the _res structure definition.

Parameters

Operation 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.
DomName Points to the name of the domain. If the DomName parameter points to a single label and the RES_DEFNAMES structure is set, as it is by default, the subroutine appends the DomName parameter 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_IN Specifies the ARPA Internet.
C_CHAOS Specifies the Chaos network at MIT.
Type Requires one of the following values:
T_A Host address
T_NS Authoritative server
T_MD Mail destination
T_MF Mail forwarder
T_CNAME Canonical 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 command) information
T_UID User ID
T_GID Group ID
Data Points to the data that is sent to the name server as a search key. The data is stored as a character array.
DataLength 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.
BufferLength Specifies the length of the message pointed to by the Buffer parameter.

Return Values

Upon successful completion, the res_mkquery subroutine returns the size of the query. If the query is larger than the value of the BufferLength parameter, the subroutine is unsuccessful and returns a value of -1.

Implementation Specifics

The res_mkquery subroutine is part of Base Operating System (BOS) Runtime.

All applications containing the res_mkquery subroutine must be compiled with _BSD set to a specific value. Acceptable values are 43 and 44. In addition, all socket applications must include the BSD libbsd.a library.

Files

/etc/resolv.conf
                          Contains the name server and domain name.

Related Information

The finger command.

The dn_comp subroutine, dn_expand subroutine, _getlong subroutine, _getshort subroutine, putlong subroutine, putshort subroutine, res_init subroutine, res_query subroutine, res_search subroutine, res_send subroutine.

Sockets Overview and Understanding Domain Name Resolution in AIX Version 4.3 Communications Programming Concepts.


[ Next Article | Previous Article | Book Contents | Library Home | Legal | Search ]