NetServices Stack source

Dependents:   HelloWorld ServoInterfaceBoardExample1 4180_Lab4

Committer:
donatien
Date:
Fri Jun 11 16:05:15 2010 +0000
Revision:
0:632c9925f013
Child:
2:a4f97773c90f

        

Who changed what in which revision?

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