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
mkersh3 0:e7ca326e76ee 33 #ifndef __LWIP_PBUF_H__
mkersh3 0:e7ca326e76ee 34 #define __LWIP_PBUF_H__
mkersh3 0:e7ca326e76ee 35
mkersh3 0:e7ca326e76ee 36 #include "lwip/opt.h"
mkersh3 0:e7ca326e76ee 37 #include "lwip/err.h"
mkersh3 0:e7ca326e76ee 38
mkersh3 0:e7ca326e76ee 39 #ifdef __cplusplus
mkersh3 0:e7ca326e76ee 40 extern "C" {
mkersh3 0:e7ca326e76ee 41 #endif
mkersh3 0:e7ca326e76ee 42
mkersh3 0:e7ca326e76ee 43 /** Currently, the pbuf_custom code is only needed for one specific configuration
mkersh3 0:e7ca326e76ee 44 * of IP_FRAG */
mkersh3 0:e7ca326e76ee 45 #define LWIP_SUPPORT_CUSTOM_PBUF (IP_FRAG && !IP_FRAG_USES_STATIC_BUF && !LWIP_NETIF_TX_SINGLE_PBUF)
mkersh3 0:e7ca326e76ee 46
mkersh3 0:e7ca326e76ee 47 #define PBUF_TRANSPORT_HLEN 20
mkersh3 0:e7ca326e76ee 48 #define PBUF_IP_HLEN 20
mkersh3 0:e7ca326e76ee 49
mkersh3 0:e7ca326e76ee 50 typedef enum {
mkersh3 0:e7ca326e76ee 51 PBUF_TRANSPORT,
mkersh3 0:e7ca326e76ee 52 PBUF_IP,
mkersh3 0:e7ca326e76ee 53 PBUF_LINK,
mkersh3 0:e7ca326e76ee 54 PBUF_RAW
mkersh3 0:e7ca326e76ee 55 } pbuf_layer;
mkersh3 0:e7ca326e76ee 56
mkersh3 0:e7ca326e76ee 57 typedef enum {
mkersh3 0:e7ca326e76ee 58 PBUF_RAM, /* pbuf data is stored in RAM */
mkersh3 0:e7ca326e76ee 59 PBUF_ROM, /* pbuf data is stored in ROM */
mkersh3 0:e7ca326e76ee 60 PBUF_REF, /* pbuf comes from the pbuf pool */
mkersh3 0:e7ca326e76ee 61 PBUF_POOL /* pbuf payload refers to RAM */
mkersh3 0:e7ca326e76ee 62 } pbuf_type;
mkersh3 0:e7ca326e76ee 63
mkersh3 0:e7ca326e76ee 64
mkersh3 0:e7ca326e76ee 65 /** indicates this packet's data should be immediately passed to the application */
mkersh3 0:e7ca326e76ee 66 #define PBUF_FLAG_PUSH 0x01U
mkersh3 0:e7ca326e76ee 67 /** indicates this is a custom pbuf: pbuf_free and pbuf_header handle such a
mkersh3 0:e7ca326e76ee 68 a pbuf differently */
mkersh3 0:e7ca326e76ee 69 #define PBUF_FLAG_IS_CUSTOM 0x02U
mkersh3 0:e7ca326e76ee 70 /** indicates this pbuf is UDP multicast to be looped back */
mkersh3 0:e7ca326e76ee 71 #define PBUF_FLAG_MCASTLOOP 0x04U
mkersh3 0:e7ca326e76ee 72
mkersh3 0:e7ca326e76ee 73 struct pbuf {
mkersh3 0:e7ca326e76ee 74 /** next pbuf in singly linked pbuf chain */
mkersh3 0:e7ca326e76ee 75 struct pbuf *next;
mkersh3 0:e7ca326e76ee 76
mkersh3 0:e7ca326e76ee 77 /** pointer to the actual data in the buffer */
mkersh3 0:e7ca326e76ee 78 void *payload;
mkersh3 0:e7ca326e76ee 79
mkersh3 0:e7ca326e76ee 80 /**
mkersh3 0:e7ca326e76ee 81 * total length of this buffer and all next buffers in chain
mkersh3 0:e7ca326e76ee 82 * belonging to the same packet.
mkersh3 0:e7ca326e76ee 83 *
mkersh3 0:e7ca326e76ee 84 * For non-queue packet chains this is the invariant:
mkersh3 0:e7ca326e76ee 85 * p->tot_len == p->len + (p->next? p->next->tot_len: 0)
mkersh3 0:e7ca326e76ee 86 */
mkersh3 0:e7ca326e76ee 87 u16_t tot_len;
mkersh3 0:e7ca326e76ee 88
mkersh3 0:e7ca326e76ee 89 /** length of this buffer */
mkersh3 0:e7ca326e76ee 90 u16_t len;
mkersh3 0:e7ca326e76ee 91
mkersh3 0:e7ca326e76ee 92 /** pbuf_type as u8_t instead of enum to save space */
mkersh3 0:e7ca326e76ee 93 u8_t /*pbuf_type*/ type;
mkersh3 0:e7ca326e76ee 94
mkersh3 0:e7ca326e76ee 95 /** misc flags */
mkersh3 0:e7ca326e76ee 96 u8_t flags;
mkersh3 0:e7ca326e76ee 97
mkersh3 0:e7ca326e76ee 98 /**
mkersh3 0:e7ca326e76ee 99 * the reference count always equals the number of pointers
mkersh3 0:e7ca326e76ee 100 * that refer to this pbuf. This can be pointers from an application,
mkersh3 0:e7ca326e76ee 101 * the stack itself, or pbuf->next pointers from a chain.
mkersh3 0:e7ca326e76ee 102 */
mkersh3 0:e7ca326e76ee 103 u16_t ref;
mkersh3 0:e7ca326e76ee 104 };
mkersh3 0:e7ca326e76ee 105
mkersh3 0:e7ca326e76ee 106 #if LWIP_SUPPORT_CUSTOM_PBUF
mkersh3 0:e7ca326e76ee 107 /** Prototype for a function to free a custom pbuf */
mkersh3 0:e7ca326e76ee 108 typedef void (*pbuf_free_custom_fn)(struct pbuf *p);
mkersh3 0:e7ca326e76ee 109
mkersh3 0:e7ca326e76ee 110 /** A custom pbuf: like a pbuf, but following a function pointer to free it. */
mkersh3 0:e7ca326e76ee 111 struct pbuf_custom {
mkersh3 0:e7ca326e76ee 112 /** The actual pbuf */
mkersh3 0:e7ca326e76ee 113 struct pbuf pbuf;
mkersh3 0:e7ca326e76ee 114 /** This function is called when pbuf_free deallocates this pbuf(_custom) */
mkersh3 0:e7ca326e76ee 115 pbuf_free_custom_fn custom_free_function;
mkersh3 0:e7ca326e76ee 116 };
mkersh3 0:e7ca326e76ee 117 #endif /* LWIP_SUPPORT_CUSTOM_PBUF */
mkersh3 0:e7ca326e76ee 118
mkersh3 0:e7ca326e76ee 119 /* Initializes the pbuf module. This call is empty for now, but may not be in future. */
mkersh3 0:e7ca326e76ee 120 #define pbuf_init()
mkersh3 0:e7ca326e76ee 121
mkersh3 0:e7ca326e76ee 122 struct pbuf *pbuf_alloc(pbuf_layer l, u16_t length, pbuf_type type);
mkersh3 0:e7ca326e76ee 123 #if LWIP_SUPPORT_CUSTOM_PBUF
mkersh3 0:e7ca326e76ee 124 struct pbuf *pbuf_alloced_custom(pbuf_layer l, u16_t length, pbuf_type type,
mkersh3 0:e7ca326e76ee 125 struct pbuf_custom *p, void *payload_mem,
mkersh3 0:e7ca326e76ee 126 u16_t payload_mem_len);
mkersh3 0:e7ca326e76ee 127 #endif /* LWIP_SUPPORT_CUSTOM_PBUF */
mkersh3 0:e7ca326e76ee 128 void pbuf_realloc(struct pbuf *p, u16_t size);
mkersh3 0:e7ca326e76ee 129 u8_t pbuf_header(struct pbuf *p, s16_t header_size);
mkersh3 0:e7ca326e76ee 130 void pbuf_ref(struct pbuf *p);
mkersh3 0:e7ca326e76ee 131 u8_t pbuf_free(struct pbuf *p);
mkersh3 0:e7ca326e76ee 132 u8_t pbuf_clen(struct pbuf *p);
mkersh3 0:e7ca326e76ee 133 void pbuf_cat(struct pbuf *head, struct pbuf *tail);
mkersh3 0:e7ca326e76ee 134 void pbuf_chain(struct pbuf *head, struct pbuf *tail);
mkersh3 0:e7ca326e76ee 135 struct pbuf *pbuf_dechain(struct pbuf *p);
mkersh3 0:e7ca326e76ee 136 err_t pbuf_copy(struct pbuf *p_to, struct pbuf *p_from);
mkersh3 0:e7ca326e76ee 137 u16_t pbuf_copy_partial(struct pbuf *p, void *dataptr, u16_t len, u16_t offset);
mkersh3 0:e7ca326e76ee 138 err_t pbuf_take(struct pbuf *buf, const void *dataptr, u16_t len);
mkersh3 0:e7ca326e76ee 139 struct pbuf *pbuf_coalesce(struct pbuf *p, pbuf_layer layer);
mkersh3 0:e7ca326e76ee 140 #if LWIP_CHECKSUM_ON_COPY
mkersh3 0:e7ca326e76ee 141 err_t pbuf_fill_chksum(struct pbuf *p, u16_t start_offset, const void *dataptr,
mkersh3 0:e7ca326e76ee 142 u16_t len, u16_t *chksum);
mkersh3 0:e7ca326e76ee 143 #endif /* LWIP_CHECKSUM_ON_COPY */
mkersh3 0:e7ca326e76ee 144
mkersh3 0:e7ca326e76ee 145 u8_t pbuf_get_at(struct pbuf* p, u16_t offset);
mkersh3 0:e7ca326e76ee 146 u16_t pbuf_memcmp(struct pbuf* p, u16_t offset, const void* s2, u16_t n);
mkersh3 0:e7ca326e76ee 147 u16_t pbuf_memfind(struct pbuf* p, const void* mem, u16_t mem_len, u16_t start_offset);
mkersh3 0:e7ca326e76ee 148 u16_t pbuf_strstr(struct pbuf* p, const char* substr);
mkersh3 0:e7ca326e76ee 149
mkersh3 0:e7ca326e76ee 150 #ifdef __cplusplus
mkersh3 0:e7ca326e76ee 151 }
mkersh3 0:e7ca326e76ee 152 #endif
mkersh3 0:e7ca326e76ee 153
mkersh3 0:e7ca326e76ee 154 #endif /* __LWIP_PBUF_H__ */