ソースの整理中ですが、利用はできます。

Dependencies:   EthernetInterface HttpServer TextLCD mbed-rpc mbed-rtos mbed Socket lwip-eth lwip-sys lwip

Committer:
yueee_yt
Date:
Wed Mar 12 04:19:54 2014 +0000
Revision:
0:7766f6712673
???????????????

Who changed what in which revision?

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