Dependents:   RTnoV3 RTnoV3_LED RTnoV3_Template RTnoV3_ADC ... more

Committer:
sherckuith
Date:
Sat Dec 31 11:25:27 2011 +0000
Revision:
0:479ce5546098
Ethernet

Who changed what in which revision?

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