Trial code integration web page update with analogue data and ntp support

Dependencies:   NTPClient_NetServices mbed

Committer:
pmr1
Date:
Fri Aug 06 17:57:45 2010 +0000
Revision:
0:8cc2035bebfc

        

Who changed what in which revision?

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