lpc1768

Committer:
jh1cdv00
Date:
Tue Jan 27 01:38:19 2015 +0000
Revision:
0:f35dada1dac1
lpc1768

Who changed what in which revision?

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