1 .\" Copyright 1993 David Metcalfe (david@prism.demon.co.uk)
3 .\" Permission is granted to make and distribute verbatim copies of this
4 .\" manual provided the copyright notice and this permission notice are
5 .\" preserved on all copies.
7 .\" Permission is granted to copy and distribute modified versions of this
8 .\" manual under the conditions for verbatim copying, provided that the
9 .\" entire resulting derived work is distributed under the terms of a
10 .\" permission notice identical to this one.
12 .\" Since the Linux kernel and libraries are constantly changing, this
13 .\" manual page may be incorrect or out-of-date. The author(s) assume no
14 .\" responsibility for errors or omissions, or for damages resulting from
15 .\" the use of the information contained herein. The author(s) may not
16 .\" have taken the same level of care in the production of this manual,
17 .\" which is licensed free of charge, as they might when working
20 .\" Formatted or processed versions of this manual, if unaccompanied by
21 .\" the source, must acknowledge the copyright and authors of this work.
23 .\" References consulted:
24 .\" Linux libc source code
25 .\" Lewine's _POSIX Programmer's Guide_ (O'Reilly & Associates, 1991)
27 .\" Modified 1993-07-25 by Rik Faith (faith@cs.unc.edu)
28 .\" Modified 2004-10-31 by aeb
30 .\" Japanese Version Copyright (c) 1998 Shinji Orito all rights reserved.
31 .\" Translated Mon May 25 21:27:03 JST 1998
32 .\" by Shinji Orito <shinji@os.gulf.or.jp>
33 .\" Updated & Modified Thu Feb 17 03:58:45 JST 2005
34 .\" by Yuichi SATO <ysato444@yahoo.co.jp>
36 .\"WORD: resolver ¥ì¥¾¥ë¥Ð (¥ê¥¾¥ë¥Ð)
37 .\"WORD: override ¥ª¡¼¥Ð¡¼¥é¥¤¥É
38 .\"WORD: call ¸Æ¤Ó½Ð¤·¡¢¸Æ¤Ó½Ð¤¹
39 .\"WORD: fully qualified domain name ´°Á´½¤¾þ¥É¥á¥¤¥ó̾(FQDN)
42 .\"WORD: query Ì䤤¹ç¤ï¤»¡¢Ì䤤¹ç¤ï¤»¤ë
43 .\"WORD: buffer ¥Ð¥Ã¥Õ¥¡¡¼
44 .\"WORD: lower-level routines ²¼°Ì¥ë¡¼¥Á¥ó
45 .\"WORD: limit of the array ÇÛÎó¤ÎÈÏ°Ï
46 .\"WORD: state information ¾õÂ֤ξðÊó
47 .\"WORD: bitwise ``or'' ¥Ó¥Ã¥Èñ°Ì¤ÎÏÀÍýÏÂ
49 .\"WORD: authoritative ¸¢°ÒÉÕ¤±¤µ¤ì¤¿
50 .\"WORD: recursion desired bit ºÆµ¢Í×µá¥Ó¥Ã¥È
51 .\"WORD: single component names °ìÉôʬ¤«¤é¤Ê¤ë̾Á°
53 .TH RESOLVER 3 2008-11-07 "GNU" "Linux Programmer's Manual"
55 res_init, res_query, res_search, res_querydomain, res_mkquery, res_send, dn_comp, dn_expand \- ¥ì¥¾¥ë¥Ð¡¦¥ë¡¼¥Á¥ó
58 .B #include <netinet/in.h>
59 .B #include <arpa/nameser.h>
60 .B #include <resolv.h>
61 .B extern struct state _res;
63 .B int res_init(void);
65 .BI "int res_query(const char *" dname ", int " class ", int " type ,
67 .BI "unsigned char *" answer ", int " anslen );
70 .BI "int res_search(const char *" dname ", int " class ", int " type ,
72 .BI "unsigned char *" answer ", int " anslen );
75 .BI "int res_querydomain(const char *" name ", const char *" domain ,
77 .BI "int " class ", int " type ", unsigned char *" answer ,
81 .BI "int res_mkquery(int " op ", const char *" dname ", int " class ,
83 .BI "int " type ", char *" data ", int " datalen ", struct rrec *" newrr ,
84 .BI "char *" buf ", int " buflen );
87 .BI "int res_send(const char *" msg ", int " msglen ", char *" answer ,
92 .BI "int dn_comp(unsigned char *" exp_dn ", unsigned char *" comp_dn ,
94 .BI "int " length ", unsigned char **" dnptrs ", unsigned char *" exp_dn ,
95 .BI "unsigned char **" lastdnptr );
98 .BI "int dn_expand(unsigned char *" msg ", unsigned char *" eomorig ,
100 .BI "unsigned char *" comp_dn ", char *" exp_dn ,
105 \fI\-lresolv\fP ¤Ç¥ê¥ó¥¯¤¹¤ë¡£
107 ¤³¤ì¤é¤Î´Ø¿ô¤Ï¥¤¥ó¥¿¡¼¥Í¥Ã¥È¤Î¥É¥á¥¤¥ó¥Í¡¼¥à¥µ¡¼¥Ð¡¼¤ËÌ䤤¹ç¤ï¤»¡¢
111 ´Ø¿ô¤Ï¡¢¥Ç¥Õ¥©¥ë¥È¤Î¥É¥á¥¤¥ó̾¡¢¸¡º÷½ç¡¢¥Í¡¼¥à¥µ¡¼¥Ð¡¼
112 ¥¢¥É¥ì¥¹¤òÆÀ¤ë¤¿¤á¤ËÀßÄê¥Õ¥¡¥¤¥ë (resolv.conf(5) »²¾È) ¤òÆɤࡣ
113 ¤â¤·¥µ¡¼¥Ð¡¼¤¬¼¨¤µ¤ì¤Æ¤¤¤Ê¤±¤ì¤Ð¥í¡¼¥«¥ë¥Û¥¹¥È¤ò»î¤¹¡£
114 ¥É¥á¥¤¥ó¤¬¼¨¤µ¤ì¤Æ¤¤¤Ê¤±¤ì¤Ð¥í¡¼¥«¥ë¥Û¥¹¥È¤ËÉÕ¤±¤é¤ì¤¿¥É¥á¥¤¥ó¤òÍѤ¤¤ë¡£
117 ¤Ç¥ª¡¼¥Ð¡¼¥é¥¤¥É¤Ç¤¤ë¡£
119 ¤Ï¡¢¸å½Ò¤¹¤ë´Ø¿ô¤Î¤É¤ì¤«¤¬ºÇ½é¤Ë¸Æ¤Ó½Ð¤µ¤ì¤¿»þ¡¢¤½¤Î´Ø¿ô
123 ´Ø¿ô¤Ï¡¢»ØÄꤵ¤ì¤¿ \fItype\fP ¤È \fIclass\fP ¤Î
124 ´°Á´½¤¾þ¥É¥á¥¤¥ó̾ (FQDN) \fIname\fP ¤ò¡¢¥Í¡¼¥à¥µ¡¼¥Ð¡¼¤ØÌ䤤¹ç¤ï¤»¤ë¡£
125 ±þÅú¤Ï¡¢¸Æ¤Ó½Ð¤·¤¿Â¦¤Ë¤è¤Ã¤ÆÍÑ°Õ¤µ¤ì¤ëŤµ \fIanslen\fP ¤Î \fIanswer\fP
126 ¥Ð¥Ã¥Õ¥¡¡¼¤Ë»Ä¤µ¤ì¤ë¡£
129 ´Ø¿ô¤Ï¡¢Ì䤤¹ç¤ï¤»¤ò¹Ô¤¤
132 ÂԤĤ¬¡¢¤µ¤é¤Ë¥Ç¥Õ¥©¥ë¥È¤ò¼ÂÁõ¤·¤Æ¤ª¤ê
136 ¤Ë¤è¤Ã¤Æµ¬Äꤵ¤ì¤ë¸¡º÷¥ë¡¼¥ë¤òŬÍѤ¹¤ë¡£
137 (²¼µ \fI_res\fP ¥ª¥×¥·¥ç¥ó¤ÎÀâÌÀ¤ò»²¾È)
139 .BR res_querydomain ()
140 ´Ø¿ô¤Ï \fIname\fP ¤È \fIdomain\fP ¤Î·ë¹ç¤Ë
142 ¤òÍѤ¤¤ÆÌ䤤¹ç¤ï¤»¤ò¹Ô¤¦¡£
146 ¤Ç»È¤ï¤ì¤ë²¼°Ì¥ë¡¼¥Á¥ó¤Ç¤¢¤ë¡£
149 ´Ø¿ô¤Ï¡¢¥É¥á¥¤¥ó̾ \fIdname\fP ¤Î°Ù¤Ë¡¢Ä¹¤µ \fIbuflen\fP
150 ¤Î \fIbuf\fP ¤ËÌ䤤¹ç¤ï¤»¤ë¥á¥Ã¥»¡¼¥¸¤òºîÀ®¤¹¤ë¡£
151 Ì䤤¹ç¤ï¤»¤Î·¿ \fIop\fP ¤ÏÄ̾ï
153 ¤À¤¬¡¢ \fI<arpa/nameser.h>\fP ¤ÇÄêµÁ¤µ¤ì¤¿·¿¤Î¤É¤ì¤Ç¤âÎɤ¤¡£
154 \fInewrr\fP ¤Ï¸½ºß»ÈÍѤµ¤ì¤Æ¤¤¤Ê¤¤¡£
157 ´Ø¿ô¤Ï¡¢Ä¹¤µ \fImsglen\fP ¤Î \fImsg\fP ¤Ë·è¤á¤é¤ì¤¿½ñ¼°
158 ¤ÇÌ䤤¹ç¤ï¤»¡¢\fIanswer\fP ¤ËŤµ \fIanslen\fP ¤Î²óÅú¤òÊÖ¤¹¡£
159 ¤Þ¤À¸Æ¤Ó½Ð¤µ¤ì¤Æ¤¤¤Ê¤±¤ì¤Ð
164 ´Ø¿ô¤Ï¥É¥á¥¤¥ó̾ \fIexp_dn\fP ¤ò°µ½Ì¤·¤Æ¡¢Ä¹¤µ \fIlength\fP
165 ¤Î¥Ð¥Ã¥Õ¥¡¡¼ \fIcomp_dn\fP ¤ËÊݸ¤¹¤ë¡£
166 °µ½Ì¤Ë¤Ï¥Ý¥¤¥ó¥¿¡¼ÇÛÎó \fIdnptrs\fP ¤òÍѤ¤¤ë¡£
167 ¤³¤ì¤é¤Î¥Ý¥¤¥ó¥¿¡¼¤Ï¡¢¸½ºß¤Î¥á¥Ã¥»¡¼¥¸¤ÎÃæ¤Ë¤¢¤ë°ÊÁ°¤Ë°µ½Ì¤µ¤ì¤¿Ì¾Á°¤ò»Ø¤¹¡£
168 ºÇ½é¤Î¥Ý¥¤¥ó¥¿¡¼¤Ï¥á¥Ã¥»¡¼¥¸¤ÎËÁƬ¤ò»Ø¤·¡¢¤½¤Î¥ê¥¹¥È¤Ï NULL ¤Ç½ª¤ï¤ë¡£
169 ÇÛÎó¤ÎÈÏ°Ï¤Ï \fIlastdnptr\fP ¤Ç·è¤á¤é¤ì¤ë¡£
170 \fIdnptr\fP ¤¬ NULL ¤Ê¤é¤Ð¥É¥á¥¤¥ó̾¤Ï°µ½Ì¤µ¤ì¤Ê¤¤¡£
171 \fIlastdnptr\fP ¤¬ NULL ¤Ê¤é¤Ð¡¢¤½¤Î¥é¥Ù¥ë¤Î¥ê¥¹¥È¤Ï¥¢¥Ã¥×¥Ç¡¼¥È¤µ¤ì¤Ê¤¤¡£
174 ´Ø¿ô¤Ï¡¢°µ½Ì¤µ¤ì¤¿¥É¥á¥¤¥ó̾ \fIcomp_dn\fP ¤«¤é¥µ¥¤¥º
175 ¤¬ \fIlength\fP ¤Î \fIexp_dn\fP ¥Ð¥Ã¥Õ¥¡¡¼¤ËÀµ¼°¤Ê¥É¥á¥¤¥ó̾¤òŸ³«¤¹¤ë¡£
176 ¤½¤Î°µ½Ì¤µ¤ì¤¿Ì¾Á°¤Ï¡¢Ì䤤¹ç¤ï¤»¡¢¤Þ¤¿¤Ï±þÅú¥á¥Ã¥»¡¼¥¸¤Ë´Þ¤Þ¤ì¤Æ¤¤¤Æ¡¢
177 \fImsg\fP ¤¬¥á¥Ã¥»¡¼¥¸¤ÎËÁƬ¤ò»Ø¤¹¡£
179 ¥ì¥¾¥ë¥Ð¡¦¥ë¡¼¥Á¥ó¤Ï¡¢\fI<resolv.h>\fP ¤ËÄêµÁ¤µ¤ì¤¿ \fI_res\fP ¹½Â¤ÂΤË
180 ´Þ¤Þ¤ì¤Æ¤¤¤ëÁ´ÂÎŪ¤ÊÀßÄê¤È¾õÂ֤ξðÊó¤ò»ÈÍѤ¹¤ë¡£
181 Ä̾ï¥æ¡¼¥¶¡¼¤ËÁàºî¤Ç¤¤ë¹àÌÜ¤Ï \fI_res.options\fP ¤À¤±¤Ç¤¢¤ë¡£
182 ¤³¤Î¹àÌܤϰʲ¼¤Î¥ª¥×¥·¥ç¥ó¤Î¥Ó¥Ã¥Èñ°Ì¤ÎÏÀÍýϤˤǤ¤ë¡£
186 ¤¬¸Æ¤Ó½Ð¤µ¤ì¤Æ¤¤¤ì¤Ð¿¿¡£
189 ¥Ç¥Ð¥Ã¥°¡¦¥á¥Ã¥»¡¼¥¸¤ò½ÐÎϤ¹¤ë¡£
192 ¸¢°ÒÉÕ¤±¤µ¤ì¤¿ (authoritative) ²óÅú¤Î¤ß¼õ¤±Æþ¤ì¤ë¡£
194 ¤Ï¡¢ºÇ½ªÅª¤Ë¸¢°ÒÉÕ¤±¤µ¤ì¤¿²óÅú¤òÆÀ¤é¤ì¤ë¤«¡¢¥¨¥é¡¼¤¬ÊÖ¤µ¤ì¤ë
196 [¸½ºß¼ÂÁõ¤µ¤ì¤Æ¤¤¤Ê¤¤]
199 Ì䤤¹ç¤ï¤»¤Ë UDP ¥Ç¡¼¥¿¥°¥é¥à¤Ç¤Ï¤Ê¤¯ TCP Àܳ¤òÍѤ¤¤ë¡£
202 ¥×¥é¥¤¥Þ¥ê¡¦¥É¥á¥¤¥ó¥Í¡¼¥à¥µ¡¼¥Ð¡¼¤Î¤ßÌ䤤¹ç¤ï¤»¤ë¡£
205 ÀÚ¤êµÍ¤á¥¨¥é¡¼ (truncation error) ¤ò̵»ë¤¹¤ë¡£TCP ¤Ç¥ê¥È¥é¥¤¤·¤Ê¤¤¡£
206 [¸½ºß¼ÂÁõ¤µ¤ì¤Æ¤¤¤Ê¤¤]
209 ºÆµ¢Í×µá (recursion desired) ¥Ó¥Ã¥È¤òÌ䤤¹ç¤ï¤»¤ËÀßÄꤹ¤ë¡£
212 ¤Ç¤Ï¤Ê¤¯¥É¥á¥¤¥ó¥Í¡¼¥à¥µ¡¼¥Ð¡¼¤Ë¤è¤Ã¤Æ¹Ô¤ï¤ì¤ë¡£
218 ¤Ï¥Ç¥Õ¥©¥ë¥È¤Î¥É¥á¥¤¥ó̾¤ò°ìÉôʬ
219 ¤Î¤ß¤«¤é¤Ê¤ë̾Á°¡¢¤¹¤Ê¤ï¤Á¥É¥Ã¥È¤ò´Þ¤Þ¤Ê¤¤Ì¾Á°¤ËÉÕ¤±²Ã¤¨¤ë¡£
223 Ì䤤¹ç¤ï¤»Ãæ¤Ë TCP Àܳ¤òÊݤĤ¿¤á
230 ¤Ï¸½ºß¤Î¥É¥á¥¤¥ó¤ª¤è¤Ó¿Æ¥É¥á¥¤¥ó¤Î
231 ¥Û¥¹¥È̾¤òõ¤¹¡£¤³¤Î¥ª¥×¥·¥ç¥ó¤Ï
232 .BR gethostbyname (3)
237 ´Ø¿ô¤ÏÀ®¸ù¤¹¤ì¤Ð 0 ¤ò¡¢¥¨¥é¡¼¤¬È¯À¸¤¹¤ì¤Ð \-1 ¤òÊÖ¤¹¡£
241 .BR res_querydomain (),
244 ´Ø¿ô¤Ï±þÅú¤ÎŤµ¤òÊÖ¤¹¡£
245 ¤Þ¤¿¡¢¥¨¥é¡¼¤¬È¯À¸¤¹¤ì¤Ð \-1 ¤òÊÖ¤¹¡£
250 ´Ø¿ô¤Ï°µ½Ì¤µ¤ì¤¿¥É¥á¥¤¥ó̾¤ÎŤµ¤òÊÖ¤¹¡£
251 ¤Þ¤¿¡¢¥¨¥é¡¼¤¬È¯À¸¤¹¤ì¤Ð \-1 ¤òÊÖ¤¹¡£
254 /etc/resolv.conf ¥ì¥¾¥ë¥ÐÀßÄê¥Õ¥¡¥¤¥ë
255 /etc/host.conf ¥ì¥¾¥ë¥ÐÀßÄê¥Õ¥¡¥¤¥ë
260 .BR gethostbyname (3),