io6Library
WIZnet Dual Stack TCP/IP Ethernet Controller Driver
dns.h
Go to the documentation of this file.
1 //*****************************************************************************
2 //
48 //
49 //*****************************************************************************
50 
51 #ifndef _DNS_H_
52 #define _DNS_H_
53 
54 #ifdef __cplusplus
55 extern "C" {
56 #endif
57 
58 #include <stdint.h>
59 /*
60  * @brief Define it for Debug & Monitor DNS processing.
61  * @note If defined, it dependens on <stdio.h>
62  */
63 //#define _DNS_DEBUG_
64 
65 #define MAX_DNS_BUF_SIZE 256
66 /*
67  * @brief Maxium length of your queried Domain name
68  * @todo SHOULD BE defined it equal as or greater than your Domain name lenght + null character(1)
69  * @note SHOULD BE careful to stack overflow because it is allocated 1.5 times as MAX_DOMAIN_NAME in stack.
70  */
71 #define MAX_DOMAIN_NAME 16 // for example "www.google.com"
72 
73 #define MAX_DNS_RETRY 2
74 #define DNS_WAIT_TIME 3
75 
76 #define IPPORT_DOMAIN 53
77 
78 #define DNS_MSG_ID 0x1122
79 
80 /*
81  * @brief DNS process initialize
82  * @param s : Socket number for DNS
83  * @param buf : Buffer for DNS message
84  */
85 void DNS_init(uint8_t * buf);
86 
87 /*
88  * @brief DNS process
89  * @details Send DNS query and receive DNS response
90  * @param dns_ip : DNS server ip
91  * @param name : Domain name to be queryed
92  * @param ip_from_dns : IP address from DNS server
93  * @return -1 : failed. @ref MAX_DOMIN_NAME is too small \n
94  * 0 : failed (Timeout or Parse error)\n
95  * 1 : success
96  * @note This funtion blocks until success or fail. max time = @ref MAX_DNS_RETRY * @ref DNS_WAIT_TIME
97  */
98 int8_t DNS_run(uint8_t s,uint8_t * dns_ip, uint8_t * name, uint8_t * ip_from_dns,uint8_t mode);
99 
100 /*
101  * @brief DNS 1s Tick Timer handler
102  * @note SHOULD BE register to your system 1s Tick timer handler
103  */
104 void DNS_time_handler(void);
105 
106 #ifdef __cplusplus
107 }
108 #endif
109 
110 #endif /* _DNS_H_ */
DNS_time_handler
void DNS_time_handler(void)
Definition: dns.c:594
DNS_init
void DNS_init(uint8_t *buf)
Definition: dns.c:518
DNS_run
int8_t DNS_run(uint8_t s, uint8_t *dns_ip, uint8_t *name, uint8_t *ip_from_dns, uint8_t mode)
Definition: dns.c:526