resolverのヘルプ・マニュアル
日本語 英語
resolver --help
man resolver
RESOLVER(3) Linux Programmer’s Manual RESOLVER(3)
名前
res_init, res_query, res_search, res_querydomain, res_mkquery,
res_send, dn_comp, dn_expand - レゾルバ・ルーチン
書式
#include
#include
#include
extern struct 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, char *data, int datalen, struct rrec *newrr,
char *buf, int buflen);
int res_send(const char *msg, int msglen, char *answer,
int anslen);
int dn_comp(unsigned char *exp_dn, unsigned char *comp_dn,
int length, unsigned char **dnptrs, unsigned char *exp_dn,
unsigned char **lastdnptr);
int dn_expand(unsigned char *msg, unsigned char *eomorig,
unsigned char *comp_dn, char *exp_dn,
int length);
-lresolv でリンクする。
説明
これらの関数はインターネットのドメインネームサーバーに問い合わせ、そ の
応答を解釈する。
res_init() 関数は、デフォルトのドメイン名、検索順、ネームサーバーアドレ
スを得るために設定ファイル (resolv.conf(5) 参照) を読む。もしサーバーが
示 されていなければローカルホストを試す。ドメインが示されていなければロ
ーカルホストに付けられたドメインを用いる。環境変数 LOCALDOMAIN でオーバ
ー ライドできる。 res_init() は、後述する関数のどれかが最初に呼び出され
た時、その関数から実行される。
res_query() 関数は、指定された type と class の完全修 飾 ド メ イ ン 名
(FQDN) name を、ネームサーバーへ問い合わせる。応答は、呼び出した側によ
って用意される長さ anslen の answer バッファーに残される。
res_search() 関数は、問い合わせを行い res_query() 同様その応答を待つ が
、 さらにデフォルトを実装しており RES_DEFNAMES と RES_DNSRCH によって規
定される検索ルールを適用する。 (下記 _res オプションの説明を参照)
res_querydomain() 関数は name と domain の結合に res_query() を用いて問
い合わせを行う。
次の関数は、 res_query() で使われる下位ルーチンである。
res_mkquery() 関数は、ドメイン名 dname の為に、長さ buflen の buf に問
い合わせるメッセージを作成する。問い合わせの型 op は通常 QUERY だ が 、
で定義された型のどれでも良い。 newrr は現在使用されて
いない。
res_send() 関数は、長さ msglen の msg に決められた書式で 問 い 合 わ せ
、answer に 長 さ anslen の 回答を返す。まだ呼び出されていなければ
res_init() を呼び出す。
dn_comp() 関数はドメイン名 exp_dn を圧縮して、長さ length のバッファ ー
comp_dn に保存する。圧縮にはポインター配列 dnptrs を用いる。これらのポ
インターは、現在のメッセージの中にある以前に圧縮された名前を指す。最 初
の ポインターはメッセージの冒頭を指し、そのリストは NULL で終わる。配列
の範囲は lastdnptr で決められる。 dnptr が NULL ならばドメイン名は圧 縮
されない。 lastdnptr が NULL ならば、そのラベルのリストはアップデートさ
れない。
dn_expand() 関数は、圧縮されたドメイン名 comp_dn からサイズが length の
exp_dn バッファーに正式なドメイン名を展開する。その圧縮された名前は、問
い合わせ、または応答メッセージに含まれていて、 msg がメッセージの冒頭を
指す。
レゾルバ・ルーチンは、 に定義された _res 構造体に含まれている
全体的な設定と状態の情報を使用する。通常ユーザーに操作で き る 項 目 は
_res.options だけである。この項目は以下のオプションのビット単位の論理和
にできる。
RES_INIT
res_init() が呼び出されていれば真。
RES_DEBUG
デバッグ・メッセージを出力する。
RES_AAONLY
権威付けされた (authoritative) 回答のみ受け入れる 。 res_send()
は、最終的に権威付けされた回答を得られるか、エラーが返されるまで
続行する。 [現在実装されていない]
RES_USEVC
問い合わせに UDP データグラムではなく TCP 接続を用いる。
RES_PRIMARY
プライマリ・ドメインネームサーバーのみ問い合わせる。
RES_IGNTC
切り詰めエラー (truncation error) を無視する。TCP でリトライしな
い。 [現在実装されていない]
RES_RECURSE
再 帰要求 (recursion desired) ビットを問い合わせに設定する。再帰
は res_send() ではなくドメインネームサーバーによって行われる。 [
デフォルトで有効]
RES_DEFNAMES
設定されていれば、 res_search() はデフォルトのドメイン名を一部分
のみからなる名前、すなわちドットを含まない名前に付け加える。 [デ
フォルトで有効]
RES_STAYOPEN
問い合わせ中に TCP 接続を保つため RES_USEVC と共に用いられる。
RES_DNSRCH
設定されていれば、 res_search() は現在のドメインおよび親ドメイン
のホスト名を探す。このオプションは gethostbyname(3) で用いられる
。 [デフォルトで有効]
返り値
res_init() 関数は成功すれば 0 を、エラーが発生すれば -1 を返す。
res_query(), res_search(), res_querydomain(), res_mkquery(), res_send()
関数は応答の長さを返す。また、エラーが発生すれば -1 を返す。
dn_comp() と dn_expand() 関数は圧縮されたドメイン名の長さを返す。また、
エラーが発生すれば -1 を返す。
ファイル
/etc/resolv.conf レゾルバ設定ファイル
/etc/host.conf レゾルバ設定ファイル
準拠
4.3BSD.
関連項目
gethostbyname(3), resolv.conf(5), resolver(5), hostname(7), named(8)
GNU 2008-11-07 RESOLVER(3)
RESOLVER(3) Linux Programmer’s Manual RESOLVER(3)
NAME
res_init, res_query, res_search, res_querydomain, res_mkquery,
res_send, dn_comp, dn_expand - resolver routines
SYNOPSIS
#include
#include
#include
extern struct 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, char *data, int datalen, struct rrec *newrr,
char *buf, int buflen);
int res_send(const char *msg, int msglen, char *answer,
int anslen);
int dn_comp(unsigned char *exp_dn, unsigned char *comp_dn,
int length, unsigned char **dnptrs, unsigned char *exp_dn,
unsigned char **lastdnptr);
int dn_expand(unsigned char *msg, unsigned char *eomorig,
unsigned char *comp_dn, char *exp_dn,
int length);
Link with -lresolv.
DESCRIPTION
These functions make queries to and interpret the responses from Inter-
net 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 quali-
fied 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 . newrr is cur-
rently unused.
The res_send() function sends a pre-formatted 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 mes-
sage. 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 . 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.
RES_AAONLY
Accept authoritative answers only. res_send() continues until
it finds an authoritative answer or returns an error. [Not cur-
rently 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 sin-
gle component names, i.e., 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].
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 com-
pressed 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.22 of the Linux man-pages project. A
description of the project, and information about reporting bugs, can
be found at http://www.kernel.org/doc/man-pages/.
GNU 2008-11-07 RESOLVER(3)