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 <netinet/in.h>
       #include <arpa/nameser.h>
       #include <resolv.h>
       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 **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 ã ãã <arpa/nameser.h>
       ã§å®ç¾©ãããåã®ã©ãã§ãè¯ãã 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 ãã¡ãã»ã¼ã¸ã®åé ãæãã

       ã¬ã¾ã«ãã»ã«ã¼ãã³ã¯ã<resolv.h> ã«å®ç¾©ããã _res æ§é ä½ã«
       å«ã¾ãã¦ããå¨ä½çãªè¨å®ã¨ç¶æã®æå ±ã使ç¨ããã é常ã¦ã¼ã¶ã¼ã«æä½ã§ããé ç®ã¯
       _res.options ã ãã§ããã ãã®é ç®ã¯ä»¥ä¸ã®ãªãã·ã§ã³ã®ãããåä½ã®è«çåã«ã§ããã

       RES_INIT
              res_init()  ãå¼ã³åºããã¦ããã°çã

       RES_DEBUG
              Print debugging messages.  This option is available only if
              glibc was built with debugging enabled, which is not the
              default.

       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)  ã§ç¨ããããã
              [ããã©ã«ãã§æå¹]

       ãã®ãªã¹ãã¯å®å¨ãªãã®ã§ã¯ãªãã resolv.conf(5)
       ã«ã¯ä»ã«ããã¤ãã®ãã©ã°ãè¨è¼ããã¦ããã

è¿ãå¤
       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)

ãã®ææ¸ã«ã¤ãã¦
       ãã® man ãã¼ã¸ã¯ Linux man-pages ããã¸ã§ã¯ãã®ãªãªã¼ã¹ 3.51 ã®ä¸é¨
       ã§ãããããã¸ã§ã¯ãã®èª¬æã¨ãã°å ±åã«é¢ããæå ±ã¯
       http://www.kernel.org/doc/man-pages/ ã«æ¸ããã¦ããã



GNU                               2013-03-05                       RESOLVER(3)