Some quick code to use UDP-only (no TCP) with mBed. Echos received packets and sends packets when a button is pressed

Dependencies:   mbed

Committer:
pehrhovey
Date:
Sun Mar 14 00:54:12 2010 +0000
Revision:
0:a548a085de55

        

Who changed what in which revision?

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