resolv.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. #ifndef _RESOLV_H
  2. #define _RESOLV_H
  3. #include <stdint.h>
  4. #include <arpa/nameser.h>
  5. #include <netinet/in.h>
  6. #ifdef __cplusplus
  7. extern "C" {
  8. #endif
  9. #define MAXNS 3
  10. #define MAXDFLSRCH 3
  11. #define MAXDNSRCH 6
  12. #define LOCALDOMAINPARTS 2
  13. #define RES_TIMEOUT 5
  14. #define MAXRESOLVSORT 10
  15. #define RES_MAXNDOTS 15
  16. #define RES_MAXRETRANS 30
  17. #define RES_MAXRETRY 5
  18. #define RES_DFLRETRY 2
  19. #define RES_MAXTIME 65535
  20. /* unused; purely for broken apps */
  21. typedef struct __res_state {
  22. int retrans;
  23. int retry;
  24. unsigned long options;
  25. int nscount;
  26. struct sockaddr_in nsaddr_list[MAXNS];
  27. # define nsaddr nsaddr_list[0]
  28. unsigned short id;
  29. char *dnsrch[MAXDNSRCH+1];
  30. char defdname[256];
  31. unsigned long pfcode;
  32. unsigned ndots:4;
  33. unsigned nsort:4;
  34. unsigned ipv6_unavail:1;
  35. unsigned unused:23;
  36. struct {
  37. struct in_addr addr;
  38. uint32_t mask;
  39. } sort_list[MAXRESOLVSORT];
  40. void *qhook;
  41. void *rhook;
  42. int res_h_errno;
  43. int _vcsock;
  44. unsigned _flags;
  45. union {
  46. char pad[52];
  47. struct {
  48. uint16_t nscount;
  49. uint16_t nsmap[MAXNS];
  50. int nssocks[MAXNS];
  51. uint16_t nscount6;
  52. uint16_t nsinit;
  53. struct sockaddr_in6 *nsaddrs[MAXNS];
  54. unsigned int _initstamp[2];
  55. } _ext;
  56. } _u;
  57. } *res_state;
  58. #define __RES 19991006
  59. #ifndef _PATH_RESCONF
  60. #define _PATH_RESCONF "/etc/resolv.conf"
  61. #endif
  62. struct res_sym {
  63. int number;
  64. char *name;
  65. char *humanname;
  66. };
  67. #define RES_F_VC 0x00000001
  68. #define RES_F_CONN 0x00000002
  69. #define RES_F_EDNS0ERR 0x00000004
  70. #define RES_EXHAUSTIVE 0x00000001
  71. #define RES_INIT 0x00000001
  72. #define RES_DEBUG 0x00000002
  73. #define RES_AAONLY 0x00000004
  74. #define RES_USEVC 0x00000008
  75. #define RES_PRIMARY 0x00000010
  76. #define RES_IGNTC 0x00000020
  77. #define RES_RECURSE 0x00000040
  78. #define RES_DEFNAMES 0x00000080
  79. #define RES_STAYOPEN 0x00000100
  80. #define RES_DNSRCH 0x00000200
  81. #define RES_INSECURE1 0x00000400
  82. #define RES_INSECURE2 0x00000800
  83. #define RES_NOALIASES 0x00001000
  84. #define RES_USE_INET6 0x00002000
  85. #define RES_ROTATE 0x00004000
  86. #define RES_NOCHECKNAME 0x00008000
  87. #define RES_KEEPTSIG 0x00010000
  88. #define RES_BLAST 0x00020000
  89. #define RES_USEBSTRING 0x00040000
  90. #define RES_NOIP6DOTINT 0x00080000
  91. #define RES_USE_EDNS0 0x00100000
  92. #define RES_SNGLKUP 0x00200000
  93. #define RES_SNGLKUPREOP 0x00400000
  94. #define RES_USE_DNSSEC 0x00800000
  95. #define RES_DEFAULT (RES_RECURSE|RES_DEFNAMES|RES_DNSRCH|RES_NOIP6DOTINT)
  96. #define RES_PRF_STATS 0x00000001
  97. #define RES_PRF_UPDATE 0x00000002
  98. #define RES_PRF_CLASS 0x00000004
  99. #define RES_PRF_CMD 0x00000008
  100. #define RES_PRF_QUES 0x00000010
  101. #define RES_PRF_ANS 0x00000020
  102. #define RES_PRF_AUTH 0x00000040
  103. #define RES_PRF_ADD 0x00000080
  104. #define RES_PRF_HEAD1 0x00000100
  105. #define RES_PRF_HEAD2 0x00000200
  106. #define RES_PRF_TTLID 0x00000400
  107. #define RES_PRF_HEADX 0x00000800
  108. #define RES_PRF_QUERY 0x00001000
  109. #define RES_PRF_REPLY 0x00002000
  110. #define RES_PRF_INIT 0x00004000
  111. struct __res_state *__res_state(void);
  112. #define _res (*__res_state())
  113. int res_init(void);
  114. int res_query(const char *, int, int, unsigned char *, int);
  115. int res_querydomain(const char *, const char *, int, int, unsigned char *, int);
  116. int res_search(const char *, int, int, unsigned char *, int);
  117. int res_mkquery(int, const char *, int, int, const unsigned char *, int, const unsigned char*, unsigned char *, int);
  118. int res_send(const unsigned char *, int, unsigned char *, int);
  119. int dn_comp(const char *, unsigned char *, int, unsigned char **, unsigned char **);
  120. int dn_expand(const unsigned char *, const unsigned char *, const unsigned char *, char *, int);
  121. int dn_skipname(const unsigned char *, const unsigned char *);
  122. #ifdef __cplusplus
  123. }
  124. #endif
  125. #endif