uc-sdk
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
dns.h
Go to the documentation of this file.
1 
34 #ifndef __LWIP_DNS_H__
35 #define __LWIP_DNS_H__
36 
37 #include "lwip/opt.h"
38 
39 #if LWIP_DNS /* don't build if not configured for use in lwipopts.h */
40 
41 #ifdef __cplusplus
42 extern "C" {
43 #endif
44 
46 #define DNS_TMR_INTERVAL 1000
47 
49 #define DNS_RRTYPE_A 1 /* a host address */
50 #define DNS_RRTYPE_NS 2 /* an authoritative name server */
51 #define DNS_RRTYPE_MD 3 /* a mail destination (Obsolete - use MX) */
52 #define DNS_RRTYPE_MF 4 /* a mail forwarder (Obsolete - use MX) */
53 #define DNS_RRTYPE_CNAME 5 /* the canonical name for an alias */
54 #define DNS_RRTYPE_SOA 6 /* marks the start of a zone of authority */
55 #define DNS_RRTYPE_MB 7 /* a mailbox domain name (EXPERIMENTAL) */
56 #define DNS_RRTYPE_MG 8 /* a mail group member (EXPERIMENTAL) */
57 #define DNS_RRTYPE_MR 9 /* a mail rename domain name (EXPERIMENTAL) */
58 #define DNS_RRTYPE_NULL 10 /* a null RR (EXPERIMENTAL) */
59 #define DNS_RRTYPE_WKS 11 /* a well known service description */
60 #define DNS_RRTYPE_PTR 12 /* a domain name pointer */
61 #define DNS_RRTYPE_HINFO 13 /* host information */
62 #define DNS_RRTYPE_MINFO 14 /* mailbox or mail list information */
63 #define DNS_RRTYPE_MX 15 /* mail exchange */
64 #define DNS_RRTYPE_TXT 16 /* text strings */
65 
67 #define DNS_RRCLASS_IN 1 /* the Internet */
68 #define DNS_RRCLASS_CS 2 /* the CSNET class (Obsolete - used only for examples in some obsolete RFCs) */
69 #define DNS_RRCLASS_CH 3 /* the CHAOS class */
70 #define DNS_RRCLASS_HS 4 /* Hesiod [Dyer 87] */
71 #define DNS_RRCLASS_FLUSH 0x800 /* Flush bit */
72 
73 /* The size used for the next line is rather a hack, but it prevents including socket.h in all files
74  that include memp.h, and that would possibly break portability (since socket.h defines some types
75  and constants possibly already define by the OS).
76  Calculation rule:
77  sizeof(struct addrinfo) + sizeof(struct sockaddr_in) + DNS_MAX_NAME_LENGTH + 1 byte zero-termination */
78 #define NETDB_ELEM_SIZE (32 + 16 + DNS_MAX_NAME_LENGTH + 1)
79 
80 #if DNS_LOCAL_HOSTLIST
81 
82 struct local_hostlist_entry {
84  const char *name;
86  ip_addr_t addr;
87  struct local_hostlist_entry *next;
88 };
89 #if DNS_LOCAL_HOSTLIST_IS_DYNAMIC
90 #ifndef DNS_LOCAL_HOSTLIST_MAX_NAMELEN
91 #define DNS_LOCAL_HOSTLIST_MAX_NAMELEN DNS_MAX_NAME_LENGTH
92 #endif
93 #define LOCALHOSTLIST_ELEM_SIZE ((sizeof(struct local_hostlist_entry) + DNS_LOCAL_HOSTLIST_MAX_NAMELEN + 1))
94 #endif /* DNS_LOCAL_HOSTLIST_IS_DYNAMIC */
95 #endif /* DNS_LOCAL_HOSTLIST */
96 
104 typedef void (*dns_found_callback)(const char *name, ip_addr_t *ipaddr, void *callback_arg);
105 
106 void dns_init(void);
107 void dns_tmr(void);
108 void dns_setserver(u8_t numdns, ip_addr_t *dnsserver);
109 ip_addr_t dns_getserver(u8_t numdns);
110 err_t dns_gethostbyname(const char *hostname, ip_addr_t *addr,
111  dns_found_callback found, void *callback_arg);
112 
113 #if DNS_LOCAL_HOSTLIST && DNS_LOCAL_HOSTLIST_IS_DYNAMIC
114 int dns_local_removehost(const char *hostname, const ip_addr_t *addr);
115 err_t dns_local_addhost(const char *hostname, const ip_addr_t *addr);
116 #endif /* DNS_LOCAL_HOSTLIST && DNS_LOCAL_HOSTLIST_IS_DYNAMIC */
117 
118 #ifdef __cplusplus
119 }
120 #endif
121 
122 #endif /* LWIP_DNS */
123 
124 #endif /* __LWIP_DNS_H__ */