Ethernet test for ECE 4180 and others to find your IP address and do a simple HTTP GET request over port 80.

Dependencies:   mbed Socket lwip-eth lwip-sys lwip

Committer:
mkersh3
Date:
Thu Apr 04 05:26:09 2013 +0000
Revision:
0:e7ca326e76ee
Ethernet Test for ECE4180 and others to find their IP Address and do a simple HTTP GET request over port 80.

Who changed what in which revision?

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