current version
[opsoft_test.git] / gclib2 / include / dns.h
blobe50a8fcb2e71c2ea9a92e5830fe77abbc706c0ab
1 /*
2 * (c) Oleg Puchinin 2006-2008
3 * graycardinalster@gmail.com
5 */
7 #ifndef DEFINE_DNS_H
8 #define DEFINE_DNS_H
10 #ifndef DEFINE_GCLIB2_H
11 #include <gclib2.h>
12 #endif
14 #ifndef DEFINE_DNS_INTERNALS_H
15 struct dns_query;
16 struct dns_reply;
17 struct dns_header;
18 #endif
20 class DNS
22 public:
23 DNS ();
24 ~DNS ();
26 int init ();
27 dns_query * loop () ;
28 void set_timeout (int sec) ;
29 int get_socket () ;
30 void clean () ;
31 char * A (char *host) ;
32 char * async_A (char *host, dns_query ** qRet = NULL) ;
33 char * MX (char *host) ;
34 char * async_MX (char *IP, dns_query ** qRet = NULL) ;
35 char * ip2name (char *IP) ;
36 char * async_ip2name (char *IP, dns_query ** qRet = NULL) ;
38 private:
39 char * bestServer () ;
40 dns_query * query_async (uint16_t flags, uint16_t dr_type, uint16_t dr_class, char * host) ;
41 List * query_sync(uint16_t flags, uint16_t dr_type, uint16_t dr_class, char * host,
42 char ** d_resp = NULL, int *d_resp_len = NULL) ;
43 dns_reply * scan (List *list, uint16_t dr_type, uint16_t dr_class) ;
44 __dlist_entry_t * inquiries_scan (char * host, uint16_t dr_type, uint16_t dr_class) ;
45 dns_reply * bestMXReply (List * list) ;
46 char * __name2dns (char *name, int *len) ;
47 char * __ddup (char * ptr, unsigned char ch) ;
48 char * __dns_rd_chunk (DPBuf * p, char ** ptr, char * done) ;
49 char * __dns_resp_domain (DPBuf * p, char * domain, char **domain_end) ;
50 char * make_dns_pkt (uint16_t id, uint16_t flags, uint16_t d_type,
51 uint16_t d_class, char * domain, int *len) ;
52 List * resp_split (dns_header *hdr, char *pkt, int len) ;
53 void resp_clean (List * list) ;
54 char * ip2arpa (char *IP) ;
55 void clean_query (dns_query * q) ;
57 int dns_sock;
58 int dns_last_id;
59 int dns_timeout;
60 List * dns_servers;
61 List * dns_inquiries;
65 __export int dns_init () ;
66 __export char * dns_A (char *host) ;
67 __export char * dns_async_A (char *host, dns_query ** qRet = NULL) ;
68 __export char * dns_MX (char *host) ;
69 __export char * dns_async_MX (char *IP, dns_query ** qRet = NULL) ;
70 __export char * dns_ip2name (char *IP) ;
71 __export char * dns_async_ip2name (char *IP, dns_query ** qRet = NULL) ;
72 __export void dns_clean () ;
73 __export int dns_get_socket () ;
74 dns_query * dns_loop () ;
76 #endif