Ethernet for Nucleo and Disco board STM32F746 works with gcc and arm. IAC is untested

Dependents:   STM32F746_iothub_client_sample_mqtt DISCO-F746NG_Ethernet Nucleo_F746ZG_Ethernet thethingsiO-DISCO_F746NG-mqtt ... more

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers dns.h Source File

dns.h

00001 /**
00002  * lwip DNS resolver header file.
00003 
00004  * Author: Jim Pettinato
00005  *   April 2007
00006 
00007  * ported from uIP resolv.c Copyright (c) 2002-2003, Adam Dunkels.
00008  *
00009  * Redistribution and use in source and binary forms, with or without
00010  * modification, are permitted provided that the following conditions
00011  * are met:
00012  * 1. Redistributions of source code must retain the above copyright
00013  *    notice, this list of conditions and the following disclaimer.
00014  * 2. Redistributions in binary form must reproduce the above copyright
00015  *    notice, this list of conditions and the following disclaimer in the
00016  *    documentation and/or other materials provided with the distribution.
00017  * 3. The name of the author may not be used to endorse or promote
00018  *    products derived from this software without specific prior
00019  *    written permission.
00020  *
00021  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
00022  * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
00023  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00024  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
00025  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
00026  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
00027  * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
00028  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
00029  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
00030  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
00031  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00032  */
00033 
00034 #ifndef __LWIP_DNS_H__
00035 #define __LWIP_DNS_H__
00036 
00037 #include "lwip/opt.h"
00038 #include "lwip/ip_addr.h"
00039 #include "lwip/err.h"
00040 #if LWIP_DNS /* don't build if not configured for use in lwipopts.h */
00041 
00042 #ifdef __cplusplus
00043 extern "C" {
00044 #endif
00045 
00046 /** DNS timer period */
00047 #define DNS_TMR_INTERVAL          1000
00048 
00049 /** DNS field TYPE used for "Resource Records" */
00050 #define DNS_RRTYPE_A              1     /* a host address */
00051 #define DNS_RRTYPE_NS             2     /* an authoritative name server */
00052 #define DNS_RRTYPE_MD             3     /* a mail destination (Obsolete - use MX) */
00053 #define DNS_RRTYPE_MF             4     /* a mail forwarder (Obsolete - use MX) */
00054 #define DNS_RRTYPE_CNAME          5     /* the canonical name for an alias */
00055 #define DNS_RRTYPE_SOA            6     /* marks the start of a zone of authority */
00056 #define DNS_RRTYPE_MB             7     /* a mailbox domain name (EXPERIMENTAL) */
00057 #define DNS_RRTYPE_MG             8     /* a mail group member (EXPERIMENTAL) */
00058 #define DNS_RRTYPE_MR             9     /* a mail rename domain name (EXPERIMENTAL) */
00059 #define DNS_RRTYPE_NULL           10    /* a null RR (EXPERIMENTAL) */
00060 #define DNS_RRTYPE_WKS            11    /* a well known service description */
00061 #define DNS_RRTYPE_PTR            12    /* a domain name pointer */
00062 #define DNS_RRTYPE_HINFO          13    /* host information */
00063 #define DNS_RRTYPE_MINFO          14    /* mailbox or mail list information */
00064 #define DNS_RRTYPE_MX             15    /* mail exchange */
00065 #define DNS_RRTYPE_TXT            16    /* text strings */
00066 
00067 /** DNS field CLASS used for "Resource Records" */
00068 #define DNS_RRCLASS_IN            1     /* the Internet */
00069 #define DNS_RRCLASS_CS            2     /* the CSNET class (Obsolete - used only for examples in some obsolete RFCs) */
00070 #define DNS_RRCLASS_CH            3     /* the CHAOS class */
00071 #define DNS_RRCLASS_HS            4     /* Hesiod [Dyer 87] */
00072 #define DNS_RRCLASS_FLUSH         0x800 /* Flush bit */
00073 
00074 /* The size used for the next line is rather a hack, but it prevents including socket.h in all files
00075    that include memp.h, and that would possibly break portability (since socket.h defines some types
00076    and constants possibly already define by the OS).
00077    Calculation rule:
00078    sizeof(struct addrinfo) + sizeof(struct sockaddr_in) + DNS_MAX_NAME_LENGTH + 1 byte zero-termination */
00079 #define NETDB_ELEM_SIZE           (32 + 16 + DNS_MAX_NAME_LENGTH + 1)
00080 
00081 #if DNS_LOCAL_HOSTLIST
00082 /** struct used for local host-list */
00083 struct local_hostlist_entry {
00084   /** static hostname */
00085   const char *name;
00086   /** static host address in network byteorder */
00087   ip_addr_t addr;
00088   struct local_hostlist_entry *next;
00089 };
00090 #if DNS_LOCAL_HOSTLIST_IS_DYNAMIC
00091 #ifndef DNS_LOCAL_HOSTLIST_MAX_NAMELEN
00092 #define DNS_LOCAL_HOSTLIST_MAX_NAMELEN  DNS_MAX_NAME_LENGTH
00093 #endif
00094 #define LOCALHOSTLIST_ELEM_SIZE ((sizeof(struct local_hostlist_entry) + DNS_LOCAL_HOSTLIST_MAX_NAMELEN + 1))
00095 #endif /* DNS_LOCAL_HOSTLIST_IS_DYNAMIC */
00096 #endif /* DNS_LOCAL_HOSTLIST */
00097 
00098 /** Callback which is invoked when a hostname is found.
00099  * A function of this type must be implemented by the application using the DNS resolver.
00100  * @param name pointer to the name that was looked up.
00101  * @param ipaddr pointer to an ip_addr_t containing the IP address of the hostname,
00102  *        or NULL if the name could not be found (or on any other error).
00103  * @param callback_arg a user-specified callback argument passed to dns_gethostbyname
00104 */
00105 typedef void (*dns_found_callback)(const char *name, ip_addr_t *ipaddr, void *callback_arg);
00106 
00107 void           dns_init(void);
00108 void           dns_tmr(void);
00109 void           dns_setserver(u8_t numdns, ip_addr_t *dnsserver);
00110 ip_addr_t      dns_getserver(u8_t numdns);
00111 err_t          dns_gethostbyname(const char *hostname, ip_addr_t *addr,
00112                                  dns_found_callback found, void *callback_arg);
00113 
00114 #if DNS_LOCAL_HOSTLIST && DNS_LOCAL_HOSTLIST_IS_DYNAMIC
00115 int            dns_local_removehost(const char *hostname, const ip_addr_t *addr);
00116 err_t          dns_local_addhost(const char *hostname, const ip_addr_t *addr);
00117 #endif /* DNS_LOCAL_HOSTLIST && DNS_LOCAL_HOSTLIST_IS_DYNAMIC */
00118 
00119 #ifdef __cplusplus
00120 }
00121 #endif
00122 
00123 #endif /* LWIP_DNS */
00124 
00125 #endif /* __LWIP_DNS_H__ */