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 * Copyright (c) 2001-2004 Swedish Institute of Computer Science.
mkersh3 0:e7ca326e76ee 3 * All rights reserved.
mkersh3 0:e7ca326e76ee 4 *
mkersh3 0:e7ca326e76ee 5 * Redistribution and use in source and binary forms, with or without modification,
mkersh3 0:e7ca326e76ee 6 * are permitted provided that the following conditions are met:
mkersh3 0:e7ca326e76ee 7 *
mkersh3 0:e7ca326e76ee 8 * 1. Redistributions of source code must retain the above copyright notice,
mkersh3 0:e7ca326e76ee 9 * this list of conditions and the following disclaimer.
mkersh3 0:e7ca326e76ee 10 * 2. Redistributions in binary form must reproduce the above copyright notice,
mkersh3 0:e7ca326e76ee 11 * this list of conditions and the following disclaimer in the documentation
mkersh3 0:e7ca326e76ee 12 * and/or other materials provided with the distribution.
mkersh3 0:e7ca326e76ee 13 * 3. The name of the author may not be used to endorse or promote products
mkersh3 0:e7ca326e76ee 14 * derived from this software without specific prior written permission.
mkersh3 0:e7ca326e76ee 15 *
mkersh3 0:e7ca326e76ee 16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
mkersh3 0:e7ca326e76ee 17 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
mkersh3 0:e7ca326e76ee 18 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
mkersh3 0:e7ca326e76ee 19 * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
mkersh3 0:e7ca326e76ee 20 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
mkersh3 0:e7ca326e76ee 21 * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
mkersh3 0:e7ca326e76ee 22 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
mkersh3 0:e7ca326e76ee 23 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
mkersh3 0:e7ca326e76ee 24 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
mkersh3 0:e7ca326e76ee 25 * OF SUCH DAMAGE.
mkersh3 0:e7ca326e76ee 26 *
mkersh3 0:e7ca326e76ee 27 * This file is part of the lwIP TCP/IP stack.
mkersh3 0:e7ca326e76ee 28 *
mkersh3 0:e7ca326e76ee 29 * Author: Adam Dunkels <adam@sics.se>
mkersh3 0:e7ca326e76ee 30 *
mkersh3 0:e7ca326e76ee 31 */
mkersh3 0:e7ca326e76ee 32 #ifndef __LWIP_TCPIP_H__
mkersh3 0:e7ca326e76ee 33 #define __LWIP_TCPIP_H__
mkersh3 0:e7ca326e76ee 34
mkersh3 0:e7ca326e76ee 35 #include "lwip/opt.h"
mkersh3 0:e7ca326e76ee 36
mkersh3 0:e7ca326e76ee 37 #if !NO_SYS /* don't build if not configured for use in lwipopts.h */
mkersh3 0:e7ca326e76ee 38
mkersh3 0:e7ca326e76ee 39 #include "lwip/api_msg.h"
mkersh3 0:e7ca326e76ee 40 #include "lwip/netifapi.h"
mkersh3 0:e7ca326e76ee 41 #include "lwip/pbuf.h"
mkersh3 0:e7ca326e76ee 42 #include "lwip/api.h"
mkersh3 0:e7ca326e76ee 43 #include "lwip/sys.h"
mkersh3 0:e7ca326e76ee 44 #include "lwip/timers.h"
mkersh3 0:e7ca326e76ee 45 #include "lwip/netif.h"
mkersh3 0:e7ca326e76ee 46
mkersh3 0:e7ca326e76ee 47 #ifdef __cplusplus
mkersh3 0:e7ca326e76ee 48 extern "C" {
mkersh3 0:e7ca326e76ee 49 #endif
mkersh3 0:e7ca326e76ee 50
mkersh3 0:e7ca326e76ee 51 /** Define this to something that triggers a watchdog. This is called from
mkersh3 0:e7ca326e76ee 52 * tcpip_thread after processing a message. */
mkersh3 0:e7ca326e76ee 53 #ifndef LWIP_TCPIP_THREAD_ALIVE
mkersh3 0:e7ca326e76ee 54 #define LWIP_TCPIP_THREAD_ALIVE()
mkersh3 0:e7ca326e76ee 55 #endif
mkersh3 0:e7ca326e76ee 56
mkersh3 0:e7ca326e76ee 57 #if LWIP_TCPIP_CORE_LOCKING
mkersh3 0:e7ca326e76ee 58 /** The global semaphore to lock the stack. */
mkersh3 0:e7ca326e76ee 59 extern sys_mutex_t lock_tcpip_core;
mkersh3 0:e7ca326e76ee 60 #define LOCK_TCPIP_CORE() sys_mutex_lock(&lock_tcpip_core)
mkersh3 0:e7ca326e76ee 61 #define UNLOCK_TCPIP_CORE() sys_mutex_unlock(&lock_tcpip_core)
mkersh3 0:e7ca326e76ee 62 #define TCPIP_APIMSG(m) tcpip_apimsg_lock(m)
mkersh3 0:e7ca326e76ee 63 #define TCPIP_APIMSG_ACK(m)
mkersh3 0:e7ca326e76ee 64 #define TCPIP_NETIFAPI(m) tcpip_netifapi_lock(m)
mkersh3 0:e7ca326e76ee 65 #define TCPIP_NETIFAPI_ACK(m)
mkersh3 0:e7ca326e76ee 66 #else /* LWIP_TCPIP_CORE_LOCKING */
mkersh3 0:e7ca326e76ee 67 #define LOCK_TCPIP_CORE()
mkersh3 0:e7ca326e76ee 68 #define UNLOCK_TCPIP_CORE()
mkersh3 0:e7ca326e76ee 69 #define TCPIP_APIMSG(m) tcpip_apimsg(m)
mkersh3 0:e7ca326e76ee 70 #define TCPIP_APIMSG_ACK(m) sys_sem_signal(&m->conn->op_completed)
mkersh3 0:e7ca326e76ee 71 #define TCPIP_NETIFAPI(m) tcpip_netifapi(m)
mkersh3 0:e7ca326e76ee 72 #define TCPIP_NETIFAPI_ACK(m) sys_sem_signal(&m->sem)
mkersh3 0:e7ca326e76ee 73 #endif /* LWIP_TCPIP_CORE_LOCKING */
mkersh3 0:e7ca326e76ee 74
mkersh3 0:e7ca326e76ee 75 /** Function prototype for the init_done function passed to tcpip_init */
mkersh3 0:e7ca326e76ee 76 typedef void (*tcpip_init_done_fn)(void *arg);
mkersh3 0:e7ca326e76ee 77 /** Function prototype for functions passed to tcpip_callback() */
mkersh3 0:e7ca326e76ee 78 typedef void (*tcpip_callback_fn)(void *ctx);
mkersh3 0:e7ca326e76ee 79
mkersh3 0:e7ca326e76ee 80 void tcpip_init(tcpip_init_done_fn tcpip_init_done, void *arg);
mkersh3 0:e7ca326e76ee 81
mkersh3 0:e7ca326e76ee 82 #if LWIP_NETCONN
mkersh3 0:e7ca326e76ee 83 err_t tcpip_apimsg(struct api_msg *apimsg);
mkersh3 0:e7ca326e76ee 84 #if LWIP_TCPIP_CORE_LOCKING
mkersh3 0:e7ca326e76ee 85 err_t tcpip_apimsg_lock(struct api_msg *apimsg);
mkersh3 0:e7ca326e76ee 86 #endif /* LWIP_TCPIP_CORE_LOCKING */
mkersh3 0:e7ca326e76ee 87 #endif /* LWIP_NETCONN */
mkersh3 0:e7ca326e76ee 88
mkersh3 0:e7ca326e76ee 89 err_t tcpip_input(struct pbuf *p, struct netif *inp);
mkersh3 0:e7ca326e76ee 90
mkersh3 0:e7ca326e76ee 91 #if LWIP_NETIF_API
mkersh3 0:e7ca326e76ee 92 err_t tcpip_netifapi(struct netifapi_msg *netifapimsg);
mkersh3 0:e7ca326e76ee 93 #if LWIP_TCPIP_CORE_LOCKING
mkersh3 0:e7ca326e76ee 94 err_t tcpip_netifapi_lock(struct netifapi_msg *netifapimsg);
mkersh3 0:e7ca326e76ee 95 #endif /* LWIP_TCPIP_CORE_LOCKING */
mkersh3 0:e7ca326e76ee 96 #endif /* LWIP_NETIF_API */
mkersh3 0:e7ca326e76ee 97
mkersh3 0:e7ca326e76ee 98 err_t tcpip_callback_with_block(tcpip_callback_fn function, void *ctx, u8_t block);
mkersh3 0:e7ca326e76ee 99 #define tcpip_callback(f, ctx) tcpip_callback_with_block(f, ctx, 1)
mkersh3 0:e7ca326e76ee 100
mkersh3 0:e7ca326e76ee 101 /* free pbufs or heap memory from another context without blocking */
mkersh3 0:e7ca326e76ee 102 err_t pbuf_free_callback(struct pbuf *p);
mkersh3 0:e7ca326e76ee 103 err_t mem_free_callback(void *m);
mkersh3 0:e7ca326e76ee 104
mkersh3 0:e7ca326e76ee 105 #if LWIP_TCPIP_TIMEOUT
mkersh3 0:e7ca326e76ee 106 err_t tcpip_timeout(u32_t msecs, sys_timeout_handler h, void *arg);
mkersh3 0:e7ca326e76ee 107 err_t tcpip_untimeout(sys_timeout_handler h, void *arg);
mkersh3 0:e7ca326e76ee 108 #endif /* LWIP_TCPIP_TIMEOUT */
mkersh3 0:e7ca326e76ee 109
mkersh3 0:e7ca326e76ee 110 enum tcpip_msg_type {
mkersh3 0:e7ca326e76ee 111 #if LWIP_NETCONN
mkersh3 0:e7ca326e76ee 112 TCPIP_MSG_API,
mkersh3 0:e7ca326e76ee 113 #endif /* LWIP_NETCONN */
mkersh3 0:e7ca326e76ee 114 TCPIP_MSG_INPKT,
mkersh3 0:e7ca326e76ee 115 #if LWIP_NETIF_API
mkersh3 0:e7ca326e76ee 116 TCPIP_MSG_NETIFAPI,
mkersh3 0:e7ca326e76ee 117 #endif /* LWIP_NETIF_API */
mkersh3 0:e7ca326e76ee 118 #if LWIP_TCPIP_TIMEOUT
mkersh3 0:e7ca326e76ee 119 TCPIP_MSG_TIMEOUT,
mkersh3 0:e7ca326e76ee 120 TCPIP_MSG_UNTIMEOUT,
mkersh3 0:e7ca326e76ee 121 #endif /* LWIP_TCPIP_TIMEOUT */
mkersh3 0:e7ca326e76ee 122 TCPIP_MSG_CALLBACK
mkersh3 0:e7ca326e76ee 123 };
mkersh3 0:e7ca326e76ee 124
mkersh3 0:e7ca326e76ee 125 struct tcpip_msg {
mkersh3 0:e7ca326e76ee 126 enum tcpip_msg_type type;
mkersh3 0:e7ca326e76ee 127 sys_sem_t *sem;
mkersh3 0:e7ca326e76ee 128 union {
mkersh3 0:e7ca326e76ee 129 #if LWIP_NETCONN
mkersh3 0:e7ca326e76ee 130 struct api_msg *apimsg;
mkersh3 0:e7ca326e76ee 131 #endif /* LWIP_NETCONN */
mkersh3 0:e7ca326e76ee 132 #if LWIP_NETIF_API
mkersh3 0:e7ca326e76ee 133 struct netifapi_msg *netifapimsg;
mkersh3 0:e7ca326e76ee 134 #endif /* LWIP_NETIF_API */
mkersh3 0:e7ca326e76ee 135 struct {
mkersh3 0:e7ca326e76ee 136 struct pbuf *p;
mkersh3 0:e7ca326e76ee 137 struct netif *netif;
mkersh3 0:e7ca326e76ee 138 } inp;
mkersh3 0:e7ca326e76ee 139 struct {
mkersh3 0:e7ca326e76ee 140 tcpip_callback_fn function;
mkersh3 0:e7ca326e76ee 141 void *ctx;
mkersh3 0:e7ca326e76ee 142 } cb;
mkersh3 0:e7ca326e76ee 143 #if LWIP_TCPIP_TIMEOUT
mkersh3 0:e7ca326e76ee 144 struct {
mkersh3 0:e7ca326e76ee 145 u32_t msecs;
mkersh3 0:e7ca326e76ee 146 sys_timeout_handler h;
mkersh3 0:e7ca326e76ee 147 void *arg;
mkersh3 0:e7ca326e76ee 148 } tmo;
mkersh3 0:e7ca326e76ee 149 #endif /* LWIP_TCPIP_TIMEOUT */
mkersh3 0:e7ca326e76ee 150 } msg;
mkersh3 0:e7ca326e76ee 151 };
mkersh3 0:e7ca326e76ee 152
mkersh3 0:e7ca326e76ee 153 #ifdef __cplusplus
mkersh3 0:e7ca326e76ee 154 }
mkersh3 0:e7ca326e76ee 155 #endif
mkersh3 0:e7ca326e76ee 156
mkersh3 0:e7ca326e76ee 157 #endif /* !NO_SYS */
mkersh3 0:e7ca326e76ee 158
mkersh3 0:e7ca326e76ee 159 #endif /* __LWIP_TCPIP_H__ */