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