.\" Copyright 1993 David Metcalfe (david@prism.demon.co.uk) .\" .\" %%%LICENSE_START(VERBATIM) .\" Permission is granted to make and distribute verbatim copies of this .\" manual provided the copyright notice and this permission notice are .\" preserved on all copies. .\" .\" Permission is granted to copy and distribute modified versions of this .\" manual under the conditions for verbatim copying, provided that the .\" entire resulting derived work is distributed under the terms of a .\" permission notice identical to this one. .\" .\" Since the Linux kernel and libraries are constantly changing, this .\" manual page may be incorrect or out-of-date. The author(s) assume no .\" responsibility for errors or omissions, or for damages resulting from .\" the use of the information contained herein. The author(s) may not .\" have taken the same level of care in the production of this manual, .\" which is licensed free of charge, as they might when working .\" professionally. .\" .\" Formatted or processed versions of this manual, if unaccompanied by .\" the source, must acknowledge the copyright and authors of this work. .\" %%%LICENSE_END .\" .\" References consulted: .\" Linux libc source code .\" Lewine's _POSIX Programmer's Guide_ (O'Reilly & Associates, 1991) .\" 386BSD man pages .\" Modified 1993-07-25 by Rik Faith (faith@cs.unc.edu) .\" Modified 2004-10-31 by aeb .\" .\"******************************************************************* .\" .\" This file was generated with po4a. Translate the source file. .\" .\"******************************************************************* .\" .\" Japanese Version Copyright (c) 1998 Shinji Orito all rights reserved. .\" Translated Mon May 25 21:27:03 JST 1998 .\" by Shinji Orito .\" Updated & Modified Thu Feb 17 03:58:45 JST 2005 .\" by Yuichi SATO .\" Updated 2012-05-05, Akihiro MOTOKI .\" Updated 2013-05-06, Akihiro MOTOKI .\" .TH RESOLVER 3 2014\-05\-28 GNU "Linux Programmer's Manual" .SH 名前 res_init, res_query, res_search, res_querydomain, res_mkquery, res_send, dn_comp, dn_expand \- レゾルバルーチン .SH 書式 .nf \fB#include \fP \fB#include \fP \fB#include \fP \fBextern struct __res_state _res;\fP .sp \fBint res_init(void);\fP .sp \fBint res_query(const char *\fP\fIdname\fP\fB, int \fP\fIclass\fP\fB, int \fP\fItype\fP\fB,\fP .RS \fBunsigned char *\fP\fIanswer\fP\fB, int \fP\fIanslen\fP\fB);\fP .RE .sp \fBint res_search(const char *\fP\fIdname\fP\fB, int \fP\fIclass\fP\fB, int \fP\fItype\fP\fB,\fP .RS \fBunsigned char *\fP\fIanswer\fP\fB, int \fP\fIanslen\fP\fB);\fP .RE .sp \fBint res_querydomain(const char *\fP\fIname\fP\fB, const char *\fP\fIdomain\fP\fB,\fP .RS \fBint \fP\fIclass\fP\fB, int \fP\fItype\fP\fB, unsigned char *\fP\fIanswer\fP\fB,\fP \fBint \fP\fIanslen\fP\fB);\fP .RE .sp \fBint res_mkquery(int \fP\fIop\fP\fB, const char *\fP\fIdname\fP\fB, int \fP\fIclass\fP\fB,\fP .RS \fBint \fP\fItype\fP\fB, const unsigned char *\fP\fIdata\fP\fB, int \fP\fIdatalen\fP\fB,\fP \fBconst unsigned char *\fP\fInewrr\fP\fB, unsigned char *\fP\fIbuf\fP\fB, int \fP\fIbuflen\fP\fB);\fP .RE .sp \fBint res_send(const unsigned char *\fP\fImsg\fP\fB, int \fP\fImsglen\fP\fB,\fP .RS \fBunsigned char *\fP\fIanswer\fP\fB, int \fP\fIanslen\fP\fB);\fP .RE .sp \fBint dn_comp(const char *\fP\fIexp_dn\fP\fB, unsigned char *\fP\fIcomp_dn\fP\fB,\fP .RS \fBint \fP\fIlength\fP\fB, unsigned char **\fP\fIdnptrs\fP\fB, unsigned char **\fP\fIlastdnptr\fP\fB);\fP .RE .sp \fBint dn_expand(const unsigned char *\fP\fImsg\fP\fB, const unsigned char *\fP\fIeomorig\fP\fB,\fP .RS \fBconst unsigned char *\fP\fIcomp_dn\fP\fB, char *\fP\fIexp_dn\fP\fB,\fP \fBint \fP\fIlength\fP\fB);\fP .RE .fi .sp \fI\-lresolv\fP でリンクする。 .SH 説明 これらの関数はインターネットのドメインネームサーバーに問い合わせ、 その応答を解釈する。 .PP \fBres_init\fP() 関数は、デフォルトのドメイン名、検索順、ネームサーバー アドレスを得るために設定ファイル (\fBresolv.conf\fP(5) 参照) を読む。 もしサーバーが示されていなければローカルホストを試す。 ドメインが示されていなければローカルホストに付けられたドメインを用いる。 環境変数 \fBLOCALDOMAIN\fP でオーバーライドできる。 \fBres_init\fP() は、後述する関数のどれかが最初に呼び出された時、その関数 から実行される。 .PP \fBres_query\fP() 関数は、指定された \fItype\fP と \fIclass\fP の 完全修飾ドメイン名 (FQDN) \fIname\fP を、ネームサーバーへ問い合わせる。 応答は、呼び出した側によって用意される長さ \fIanslen\fP の \fIanswer\fP バッファーに残される。 .PP \fBres_search\fP() 関数は、問い合わせを行い \fBres_query\fP() 同様その応答を 待つが、さらにデフォルトを実装しており \fBRES_DEFNAMES\fP と \fBRES_DNSRCH\fP によって規定される検索ルールを適用する。 (下記 \fI_res\fP オプションの説明を参照) .PP \fBres_querydomain\fP() 関数は \fIname\fP と \fIdomain\fP の結合に \fBres_query\fP() を用いて問い合わせを行う。 .PP 次の関数は、 \fBres_query\fP() で使われる下位ルーチンである。 .PP \fBres_mkquery\fP() 関数は、ドメイン名 \fIdname\fP の為に、長さ \fIbuflen\fP の \fIbuf\fP に問い合わせるメッセージを作成する。 問い合わせの型 \fIop\fP は通常 \fBQUERY\fP だが、 \fI\fP で定義された型のどれでも良い。 \fInewrr\fP は現在使用されていない。 .PP \fBres_send\fP() 関数は、長さ \fImsglen\fP の \fImsg\fP に決められた書式 で問い合わせ、\fIanswer\fP に長さ \fIanslen\fP の回答を返す。 まだ呼び出されていなければ \fBres_init\fP() を呼び出す。 .PP \fBdn_comp\fP() 関数はドメイン名 \fIexp_dn\fP を圧縮して、長さ \fIlength\fP のバッファー \fIcomp_dn\fP に保存する。 圧縮にはポインター配列 \fIdnptrs\fP を用いる。 これらのポインターは、現在のメッセージの中にある以前に圧縮された名前を指す。 最初のポインターはメッセージの冒頭を指し、そのリストは NULL で終わる。 配列の範囲は \fIlastdnptr\fP で決められる。 \fIdnptr\fP が NULL ならばドメイン名は圧縮されない。 \fIlastdnptr\fP が NULL ならば、そのラベルのリストはアップデートされない。 .PP \fBdn_expand\fP() 関数は、圧縮されたドメイン名 \fIcomp_dn\fP からサイズ が \fIlength\fP の \fIexp_dn\fP バッファーに正式なドメイン名を展開する。 その圧縮された名前は、問い合わせ、または応答メッセージに含まれていて、 \fImsg\fP がメッセージの冒頭を指す。 .PP レゾルバルーチンは、\fI\fP に定義された \fI_res\fP 構造体に 含まれている全体的な設定と状態の情報を使用する。 通常ユーザーに操作できる項目は \fI_res.options\fP だけである。 この項目は以下のオプションのビット単位の論理和にできる。 .TP \fBRES_INIT\fP \fBres_init\fP() が呼び出されていれば真。 .TP \fBRES_DEBUG\fP .\" See resolv/README. .\" Support for RES_DEBUG was made conditional in glibc 2.2. デバッグ情報を表示する。このオプションは、 glibc がデバッグを有効にしてコンパイルされている場合にのみ利用できる。 デフォルトでは glibc のデバッグは有効になっていない。 .TP \fBRES_AAONLY\fP 権威付けされた (authoritative) 回答のみ受け入れる。 \fBres_send\fP() は、最終的に権威付けされた回答を得られるか、エラーが返される まで続行する。 [現在実装されていない] .TP \fBRES_USEVC\fP 問い合わせに UDP データグラムではなく TCP 接続を用いる。 .TP \fBRES_PRIMARY\fP プライマリドメインネームサーバーのみ問い合わせる。 .TP \fBRES_IGNTC\fP 切り詰めエラー (truncation error) を無視する。TCP でリトライしない。 [現在実装されていない] .TP \fBRES_RECURSE\fP 再帰要求 (recursion desired) ビットを問い合わせに設定する。 再帰は \fBres_send\fP() ではなくドメインネームサーバーによって行われる。 [デフォルトで有効] .TP \fBRES_DEFNAMES\fP 設定されていれば、 \fBres_search\fP() はデフォルトのドメイン名を一部分 のみからなる名前、すなわちドットを含まない名前に付け加える。 [デフォルトで有効] .TP \fBRES_STAYOPEN\fP 問い合わせ中に TCP 接続を保つため \fBRES_USEVC\fP と共に用いられる。 .TP \fBRES_DNSRCH\fP 設定されていれば、 \fBres_search\fP() は現在のドメインおよび親ドメインの ホスト名を探す。このオプションは \fBgethostbyname\fP(3) で用いられる。 [デフォルトで有効] .PP このリストは完全なものではない。 \fBresolv.conf\fP(5) には他にいくつかのフラグが記載されている。 .SH 返り値 \fBres_init\fP() 関数は成功すれば 0 を、エラーが発生すれば \-1 を返す。 .PP \fBres_query\fP(), \fBres_search\fP(), \fBres_querydomain\fP(), \fBres_mkquery\fP(), \fBres_send\fP() 関数は応答の長さを返す。 また、エラーが発生すれば \-1 を返す。 .PP \fBdn_comp\fP() と \fBdn_expand\fP() 関数は圧縮されたドメイン名の長さを返す。 また、エラーが発生すれば \-1 を返す。 .SH ファイル .nf /etc/resolv.conf レゾルバ設定ファイル /etc/host.conf レゾルバ設定ファイル .fi .SH 準拠 4.3BSD. .SH 関連項目 \fBgethostbyname\fP(3), \fBresolv.conf\fP(5), \fBresolver\fP(5), \fBhostname\fP(7), \fBnamed\fP(8) .SH この文書について この man ページは Linux \fIman\-pages\fP プロジェクトのリリース 3.79 の一部 である。プロジェクトの説明とバグ報告に関する情報は http://www.kernel.org/doc/man\-pages/ に書かれている。