Modified version of NetServices. Fixes an issue where connections failed should the HTTP response status line be received in a packet on its own prior to any further headers. Changes are made to the HTTPClient.cpp file's readHeaders method.

Committer:
andrewbonney
Date:
Fri Apr 08 14:39:41 2011 +0000
Revision:
0:ec559500a63f

        

Who changed what in which revision?

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