Embedded C project:18/12/2014

Dependencies:   DS1307 TextLCD mbed

Committer:
ninoderkinderen
Date:
Thu Dec 18 09:35:49 2014 +0000
Revision:
0:8d87bc453349
Programma embedded C

Who changed what in which revision?

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