![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
First step: AutoIP compiled in and working
lwip/include/lwip/dns.h@1:4218cacaf696, 2010-06-18 (annotated)
- Committer:
- darran
- Date:
- Fri Jun 18 15:54:21 2010 +0000
- Revision:
- 1:4218cacaf696
- Parent:
- 0:55a05330f8cc
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
darran | 1:4218cacaf696 | 1 | /** |
darran | 1:4218cacaf696 | 2 | * lwip DNS resolver header file. |
darran | 1:4218cacaf696 | 3 | |
darran | 1:4218cacaf696 | 4 | * Author: Jim Pettinato |
darran | 1:4218cacaf696 | 5 | * April 2007 |
darran | 1:4218cacaf696 | 6 | |
darran | 1:4218cacaf696 | 7 | * ported from uIP resolv.c Copyright (c) 2002-2003, Adam Dunkels. |
darran | 1:4218cacaf696 | 8 | * |
darran | 1:4218cacaf696 | 9 | * Redistribution and use in source and binary forms, with or without |
darran | 1:4218cacaf696 | 10 | * modification, are permitted provided that the following conditions |
darran | 1:4218cacaf696 | 11 | * are met: |
darran | 1:4218cacaf696 | 12 | * 1. Redistributions of source code must retain the above copyright |
darran | 1:4218cacaf696 | 13 | * notice, this list of conditions and the following disclaimer. |
darran | 1:4218cacaf696 | 14 | * 2. Redistributions in binary form must reproduce the above copyright |
darran | 1:4218cacaf696 | 15 | * notice, this list of conditions and the following disclaimer in the |
darran | 1:4218cacaf696 | 16 | * documentation and/or other materials provided with the distribution. |
darran | 1:4218cacaf696 | 17 | * 3. The name of the author may not be used to endorse or promote |
darran | 1:4218cacaf696 | 18 | * products derived from this software without specific prior |
darran | 1:4218cacaf696 | 19 | * written permission. |
darran | 1:4218cacaf696 | 20 | * |
darran | 1:4218cacaf696 | 21 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS |
darran | 1:4218cacaf696 | 22 | * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
darran | 1:4218cacaf696 | 23 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
darran | 1:4218cacaf696 | 24 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY |
darran | 1:4218cacaf696 | 25 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
darran | 1:4218cacaf696 | 26 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE |
darran | 1:4218cacaf696 | 27 | * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
darran | 1:4218cacaf696 | 28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, |
darran | 1:4218cacaf696 | 29 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING |
darran | 1:4218cacaf696 | 30 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
darran | 1:4218cacaf696 | 31 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
darran | 1:4218cacaf696 | 32 | */ |
darran | 1:4218cacaf696 | 33 | |
darran | 1:4218cacaf696 | 34 | #ifndef __LWIP_DNS_H__ |
darran | 1:4218cacaf696 | 35 | #define __LWIP_DNS_H__ |
darran | 1:4218cacaf696 | 36 | |
darran | 1:4218cacaf696 | 37 | #include "lwip/opt.h" |
darran | 1:4218cacaf696 | 38 | |
darran | 1:4218cacaf696 | 39 | #if LWIP_DNS /* don't build if not configured for use in lwipopts.h */ |
darran | 1:4218cacaf696 | 40 | |
darran | 1:4218cacaf696 | 41 | /** DNS timer period */ |
darran | 1:4218cacaf696 | 42 | #define DNS_TMR_INTERVAL 1000 |
darran | 1:4218cacaf696 | 43 | |
darran | 1:4218cacaf696 | 44 | /** DNS field TYPE used for "Resource Records" */ |
darran | 1:4218cacaf696 | 45 | #define DNS_RRTYPE_A 1 /* a host address */ |
darran | 1:4218cacaf696 | 46 | #define DNS_RRTYPE_NS 2 /* an authoritative name server */ |
darran | 1:4218cacaf696 | 47 | #define DNS_RRTYPE_MD 3 /* a mail destination (Obsolete - use MX) */ |
darran | 1:4218cacaf696 | 48 | #define DNS_RRTYPE_MF 4 /* a mail forwarder (Obsolete - use MX) */ |
darran | 1:4218cacaf696 | 49 | #define DNS_RRTYPE_CNAME 5 /* the canonical name for an alias */ |
darran | 1:4218cacaf696 | 50 | #define DNS_RRTYPE_SOA 6 /* marks the start of a zone of authority */ |
darran | 1:4218cacaf696 | 51 | #define DNS_RRTYPE_MB 7 /* a mailbox domain name (EXPERIMENTAL) */ |
darran | 1:4218cacaf696 | 52 | #define DNS_RRTYPE_MG 8 /* a mail group member (EXPERIMENTAL) */ |
darran | 1:4218cacaf696 | 53 | #define DNS_RRTYPE_MR 9 /* a mail rename domain name (EXPERIMENTAL) */ |
darran | 1:4218cacaf696 | 54 | #define DNS_RRTYPE_NULL 10 /* a null RR (EXPERIMENTAL) */ |
darran | 1:4218cacaf696 | 55 | #define DNS_RRTYPE_WKS 11 /* a well known service description */ |
darran | 1:4218cacaf696 | 56 | #define DNS_RRTYPE_PTR 12 /* a domain name pointer */ |
darran | 1:4218cacaf696 | 57 | #define DNS_RRTYPE_HINFO 13 /* host information */ |
darran | 1:4218cacaf696 | 58 | #define DNS_RRTYPE_MINFO 14 /* mailbox or mail list information */ |
darran | 1:4218cacaf696 | 59 | #define DNS_RRTYPE_MX 15 /* mail exchange */ |
darran | 1:4218cacaf696 | 60 | #define DNS_RRTYPE_TXT 16 /* text strings */ |
darran | 1:4218cacaf696 | 61 | |
darran | 1:4218cacaf696 | 62 | /** DNS field CLASS used for "Resource Records" */ |
darran | 1:4218cacaf696 | 63 | #define DNS_RRCLASS_IN 1 /* the Internet */ |
darran | 1:4218cacaf696 | 64 | #define DNS_RRCLASS_CS 2 /* the CSNET class (Obsolete - used only for examples in some obsolete RFCs) */ |
darran | 1:4218cacaf696 | 65 | #define DNS_RRCLASS_CH 3 /* the CHAOS class */ |
darran | 1:4218cacaf696 | 66 | #define DNS_RRCLASS_HS 4 /* Hesiod [Dyer 87] */ |
darran | 1:4218cacaf696 | 67 | #define DNS_RRCLASS_FLUSH 0x800 /* Flush bit */ |
darran | 1:4218cacaf696 | 68 | |
darran | 1:4218cacaf696 | 69 | /* The size used for the next line is rather a hack, but it prevents including socket.h in all files |
darran | 1:4218cacaf696 | 70 | that include memp.h, and that would possibly break portability (since socket.h defines some types |
darran | 1:4218cacaf696 | 71 | and constants possibly already define by the OS). |
darran | 1:4218cacaf696 | 72 | Calculation rule: |
darran | 1:4218cacaf696 | 73 | sizeof(struct addrinfo) + sizeof(struct sockaddr_in) + DNS_MAX_NAME_LENGTH + 1 byte zero-termination */ |
darran | 1:4218cacaf696 | 74 | #define NETDB_ELEM_SIZE (32 + 16 + DNS_MAX_NAME_LENGTH + 1) |
darran | 1:4218cacaf696 | 75 | |
darran | 1:4218cacaf696 | 76 | #if DNS_LOCAL_HOSTLIST |
darran | 1:4218cacaf696 | 77 | /** struct used for local host-list */ |
darran | 1:4218cacaf696 | 78 | struct local_hostlist_entry { |
darran | 1:4218cacaf696 | 79 | /** static hostname */ |
darran | 1:4218cacaf696 | 80 | const char *name; |
darran | 1:4218cacaf696 | 81 | /** static host address in network byteorder */ |
darran | 1:4218cacaf696 | 82 | ip_addr_t addr; |
darran | 1:4218cacaf696 | 83 | struct local_hostlist_entry *next; |
darran | 1:4218cacaf696 | 84 | }; |
darran | 1:4218cacaf696 | 85 | #if DNS_LOCAL_HOSTLIST_IS_DYNAMIC |
darran | 1:4218cacaf696 | 86 | #ifndef DNS_LOCAL_HOSTLIST_MAX_NAMELEN |
darran | 1:4218cacaf696 | 87 | #define DNS_LOCAL_HOSTLIST_MAX_NAMELEN DNS_MAX_NAME_LENGTH |
darran | 1:4218cacaf696 | 88 | #endif |
darran | 1:4218cacaf696 | 89 | #define LOCALHOSTLIST_ELEM_SIZE ((sizeof(struct local_hostlist_entry) + DNS_LOCAL_HOSTLIST_MAX_NAMELEN + 1)) |
darran | 1:4218cacaf696 | 90 | #endif /* DNS_LOCAL_HOSTLIST_IS_DYNAMIC */ |
darran | 1:4218cacaf696 | 91 | #endif /* DNS_LOCAL_HOSTLIST */ |
darran | 1:4218cacaf696 | 92 | |
darran | 1:4218cacaf696 | 93 | /** Callback which is invoked when a hostname is found. |
darran | 1:4218cacaf696 | 94 | * A function of this type must be implemented by the application using the DNS resolver. |
darran | 1:4218cacaf696 | 95 | * @param name pointer to the name that was looked up. |
darran | 1:4218cacaf696 | 96 | * @param ipaddr pointer to an ip_addr_t containing the IP address of the hostname, |
darran | 1:4218cacaf696 | 97 | * or NULL if the name could not be found (or on any other error). |
darran | 1:4218cacaf696 | 98 | * @param callback_arg a user-specified callback argument passed to dns_gethostbyname |
darran | 1:4218cacaf696 | 99 | */ |
darran | 1:4218cacaf696 | 100 | typedef void (*dns_found_callback)(const char *name, ip_addr_t *ipaddr, void *callback_arg); |
darran | 1:4218cacaf696 | 101 | |
darran | 1:4218cacaf696 | 102 | void dns_init(void); |
darran | 1:4218cacaf696 | 103 | void dns_tmr(void); |
darran | 1:4218cacaf696 | 104 | void dns_setserver(u8_t numdns, ip_addr_t *dnsserver); |
darran | 1:4218cacaf696 | 105 | ip_addr_t dns_getserver(u8_t numdns); |
darran | 1:4218cacaf696 | 106 | err_t dns_gethostbyname(const char *hostname, ip_addr_t *addr, |
darran | 1:4218cacaf696 | 107 | dns_found_callback found, void *callback_arg); |
darran | 1:4218cacaf696 | 108 | |
darran | 1:4218cacaf696 | 109 | #if DNS_LOCAL_HOSTLIST && DNS_LOCAL_HOSTLIST_IS_DYNAMIC |
darran | 1:4218cacaf696 | 110 | int dns_local_removehost(const char *hostname, const ip_addr_t *addr); |
darran | 1:4218cacaf696 | 111 | err_t dns_local_addhost(const char *hostname, const ip_addr_t *addr); |
darran | 1:4218cacaf696 | 112 | #endif /* DNS_LOCAL_HOSTLIST && DNS_LOCAL_HOSTLIST_IS_DYNAMIC */ |
darran | 1:4218cacaf696 | 113 | |
darran | 1:4218cacaf696 | 114 | #endif /* LWIP_DNS */ |
darran | 1:4218cacaf696 | 115 | |
darran | 1:4218cacaf696 | 116 | #endif /* __LWIP_DNS_H__ */ |