Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
dns.h
00001 /** 00002 * @file 00003 * DNS API 00004 */ 00005 00006 /** 00007 * lwip DNS resolver header file. 00008 00009 * Author: Jim Pettinato 00010 * April 2007 00011 00012 * ported from uIP resolv.c Copyright (c) 2002-2003, Adam Dunkels. 00013 * 00014 * Redistribution and use in source and binary forms, with or without 00015 * modification, are permitted provided that the following conditions 00016 * are met: 00017 * 1. Redistributions of source code must retain the above copyright 00018 * notice, this list of conditions and the following disclaimer. 00019 * 2. Redistributions in binary form must reproduce the above copyright 00020 * notice, this list of conditions and the following disclaimer in the 00021 * documentation and/or other materials provided with the distribution. 00022 * 3. The name of the author may not be used to endorse or promote 00023 * products derived from this software without specific prior 00024 * written permission. 00025 * 00026 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS 00027 * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 00028 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 00029 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY 00030 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 00031 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 00032 * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 00033 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 00034 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 00035 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 00036 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00037 */ 00038 00039 #ifndef LWIP_HDR_DNS_H 00040 #define LWIP_HDR_DNS_H 00041 00042 #include "lwip/opt.h" 00043 00044 #if LWIP_DNS 00045 00046 #include "lwip/ip_addr.h" 00047 00048 #ifdef __cplusplus 00049 extern "C" { 00050 #endif 00051 00052 /** DNS timer period */ 00053 #define DNS_TMR_INTERVAL 1000 00054 00055 /* DNS resolve types: */ 00056 #define LWIP_DNS_ADDRTYPE_IPV4 0 00057 #define LWIP_DNS_ADDRTYPE_IPV6 1 00058 #define LWIP_DNS_ADDRTYPE_IPV4_IPV6 2 /* try to resolve IPv4 first, try IPv6 if IPv4 fails only */ 00059 #define LWIP_DNS_ADDRTYPE_IPV6_IPV4 3 /* try to resolve IPv6 first, try IPv4 if IPv6 fails only */ 00060 #if LWIP_IPV4 && LWIP_IPV6 00061 #ifndef LWIP_DNS_ADDRTYPE_DEFAULT 00062 #define LWIP_DNS_ADDRTYPE_DEFAULT LWIP_DNS_ADDRTYPE_IPV4_IPV6 00063 #endif 00064 #elif defined(LWIP_IPV4) 00065 #define LWIP_DNS_ADDRTYPE_DEFAULT LWIP_DNS_ADDRTYPE_IPV4 00066 #else 00067 #define LWIP_DNS_ADDRTYPE_DEFAULT LWIP_DNS_ADDRTYPE_IPV6 00068 #endif 00069 00070 #if DNS_LOCAL_HOSTLIST 00071 /** struct used for local host-list */ 00072 struct local_hostlist_entry { 00073 /** static hostname */ 00074 const char *name; 00075 /** static host address in network byteorder */ 00076 ip_addr_t addr; 00077 struct local_hostlist_entry *next; 00078 }; 00079 #if DNS_LOCAL_HOSTLIST_IS_DYNAMIC 00080 #ifndef DNS_LOCAL_HOSTLIST_MAX_NAMELEN 00081 #define DNS_LOCAL_HOSTLIST_MAX_NAMELEN DNS_MAX_NAME_LENGTH 00082 #endif 00083 #define LOCALHOSTLIST_ELEM_SIZE ((sizeof(struct local_hostlist_entry) + DNS_LOCAL_HOSTLIST_MAX_NAMELEN + 1)) 00084 #endif /* DNS_LOCAL_HOSTLIST_IS_DYNAMIC */ 00085 #endif /* DNS_LOCAL_HOSTLIST */ 00086 00087 /** Callback which is invoked when a hostname is found. 00088 * A function of this type must be implemented by the application using the DNS resolver. 00089 * @param name pointer to the name that was looked up. 00090 * @param ipaddr pointer to an ip_addr_t containing the IP address of the hostname, 00091 * or NULL if the name could not be found (or on any other error). 00092 * @param callback_arg a user-specified callback argument passed to dns_gethostbyname 00093 */ 00094 typedef void (*dns_found_callback)(const char *name, const ip_addr_t *ipaddr, void *callback_arg); 00095 00096 void dns_init(void); 00097 void dns_tmr(void); 00098 void dns_setserver(u8_t numdns, const ip_addr_t *dnsserver); 00099 const ip_addr_t* dns_getserver(u8_t numdns); 00100 err_t dns_gethostbyname(const char *hostname, ip_addr_t *addr, 00101 dns_found_callback found, void *callback_arg); 00102 err_t dns_gethostbyname_addrtype(const char *hostname, ip_addr_t *addr, 00103 dns_found_callback found, void *callback_arg, 00104 u8_t dns_addrtype); 00105 00106 00107 #if DNS_LOCAL_HOSTLIST && DNS_LOCAL_HOSTLIST_IS_DYNAMIC 00108 int dns_local_removehost(const char *hostname, const ip_addr_t *addr); 00109 err_t dns_local_addhost(const char *hostname, const ip_addr_t *addr); 00110 #endif /* DNS_LOCAL_HOSTLIST && DNS_LOCAL_HOSTLIST_IS_DYNAMIC */ 00111 00112 #ifdef __cplusplus 00113 } 00114 #endif 00115 00116 #endif /* LWIP_DNS */ 00117 00118 #endif /* LWIP_HDR_DNS_H */
Generated on Tue Jul 12 2022 18:19:28 by
1.7.2