adns.h 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. /* new async dns
  2. *
  3. */
  4. #ifndef _ADNS_H_
  5. #define _ADNS_H_
  6. /* RFC1035
  7. TYPE value and meaning
  8. A 1 a host address
  9. NS 2 an authoritative name server
  10. MD 3 a mail destination (Obsolete - use MX)
  11. MF 4 a mail forwarder (Obsolete - use MX)
  12. CNAME 5 the canonical name for an alias
  13. SOA 6 marks the start of a zone of authority
  14. MB 7 a mailbox domain name (EXPERIMENTAL)
  15. MG 8 a mail group member (EXPERIMENTAL)
  16. MR 9 a mail rename domain name (EXPERIMENTAL)
  17. NULL 10 a null RR (EXPERIMENTAL)
  18. WKS 11 a well known service description
  19. PTR 12 a domain name pointer
  20. HINFO 13 host information
  21. MINFO 14 mailbox or mail list information
  22. MX 15 mail exchange
  23. TXT 16 text strings
  24. */
  25. #define DNS_A 1
  26. #define DNS_CNAME 5
  27. #define DNS_PTR 12
  28. #define DNS_AAAA 28
  29. #define DNS_LOOKUP_A 1
  30. #define DNS_LOOKUP_AAAA 2
  31. #define DNS_IPV4 1
  32. #define DNS_IPV6 2
  33. #define DNS_REVERSE 3
  34. #define DNS_PORT 53
  35. #include <bdlib/src/String.h>
  36. #include <bdlib/src/Array.h>
  37. typedef void (*dns_callback_t)(int, void *client_data, const char *query, bd::Array<bd::String> answers);
  38. int egg_dns_init(void);
  39. //int egg_dns_shutdown(void);
  40. void egg_dns_send(char *query, int len);
  41. int egg_dns_lookup(const char *host, interval_t timeout, dns_callback_t callback, void *client_data, int type = (DNS_LOOKUP_A|DNS_LOOKUP_AAAA));
  42. bd::Array<bd::String> dns_lookup_block(const char *host, interval_t timeout, int type = (DNS_LOOKUP_A|DNS_LOOKUP_AAAA));
  43. int egg_dns_reverse(const char *ip, interval_t timeout, dns_callback_t callback, void *client_data);
  44. bd::Array<bd::String> dns_reverse_block(const char *ip, interval_t timeout);
  45. int egg_dns_cancel(int id, int issue_callback);
  46. void tell_dnsdebug(int);
  47. void dns_cache_flush();
  48. bool valid_dns_id(int, int);
  49. int reverse_ip(const char *host, char *reverse);
  50. bd::String dns_find_ip(bd::Array<bd::String> ips, int af_type);
  51. extern int dns_sock, dns_idx;
  52. extern const char *dns_ip;
  53. #endif /* !_EGG_DNS_H_ */