ID the MBED processor on the network if you have more than one. View MBED name on DHCP of your Router - Example \"MBED PE\" Change your ID in Core / host.h

Committer:
JeffM
Date:
Sat Nov 06 14:11:02 2010 +0000
Revision:
0:fd3b85615428
MBED ID 1A

Who changed what in which revision?

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