Dependencies:   mbed

Dependents:   TCP

Committer:
slowness
Date:
Tue Sep 06 18:05:46 2011 +0000
Revision:
0:58c3d014a4e7

        

Who changed what in which revision?

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