-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdns.h
47 lines (28 loc) · 965 Bytes
/
dns.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#ifndef _DNS_H_
#define _DNS_H_
#ifdef __cplusplus
extern "C"{
#endif
#define DNS_PORT 53
#define MAX_DOMAIN 255
#define DNS_TYPE_A 1 //ipv4
#define DNS_TYPE_CNAME 5 //cname
#define DNS_TYPE_AAAA 28 //ipv6
typedef struct{
unsigned short id;
unsigned short flags;
unsigned short qry_cnt;
unsigned short ans_cnt;
unsigned short auth_cnt;
unsigned short add_cnt;
}dns_hdr;
int dns_write_domain( char* data, int size, char* domain, int* space );
int dns_parse_domain( char* dns, int offset, char* domain, int* space );
int dns_parse_query( char* dns, int offset, int size, char* domain, int* dns_type, int* dns_class, int* space );
char* dns_type_name( int dns_type );
int dns_parse_resource_record( char* dns, int offset, int size, char* domain, char* address, int* dns_type, int* dns_class, int* ttl, int* space );
char* dns_ip_addr( int dns_type, char* addr );
#ifdef __cplusplus
}
#endif
#endif