Ethernetwebsoc

Dependencies:   C12832_lcd LM75B WebSocketClient mbed-rtos mbed Socket lwip-eth lwip-sys lwip

Committer:
GordonSin
Date:
Fri May 31 04:09:54 2013 +0000
Revision:
0:0ed2a7c7190c
31/5/2013;

Who changed what in which revision?

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