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_NETBUF_H__
mkersh3 0:e7ca326e76ee 33 #define __LWIP_NETBUF_H__
mkersh3 0:e7ca326e76ee 34
mkersh3 0:e7ca326e76ee 35 #include "lwip/opt.h"
mkersh3 0:e7ca326e76ee 36 #include "lwip/pbuf.h"
mkersh3 0:e7ca326e76ee 37 #include "lwip/ip_addr.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 /** This netbuf has dest-addr/port set */
mkersh3 0:e7ca326e76ee 44 #define NETBUF_FLAG_DESTADDR 0x01
mkersh3 0:e7ca326e76ee 45 /** This netbuf includes a checksum */
mkersh3 0:e7ca326e76ee 46 #define NETBUF_FLAG_CHKSUM 0x02
mkersh3 0:e7ca326e76ee 47
mkersh3 0:e7ca326e76ee 48 struct netbuf {
mkersh3 0:e7ca326e76ee 49 struct pbuf *p, *ptr;
mkersh3 0:e7ca326e76ee 50 ip_addr_t addr;
mkersh3 0:e7ca326e76ee 51 u16_t port;
mkersh3 0:e7ca326e76ee 52 #if LWIP_NETBUF_RECVINFO || LWIP_CHECKSUM_ON_COPY
mkersh3 0:e7ca326e76ee 53 #if LWIP_CHECKSUM_ON_COPY
mkersh3 0:e7ca326e76ee 54 u8_t flags;
mkersh3 0:e7ca326e76ee 55 #endif /* LWIP_CHECKSUM_ON_COPY */
mkersh3 0:e7ca326e76ee 56 u16_t toport_chksum;
mkersh3 0:e7ca326e76ee 57 #if LWIP_NETBUF_RECVINFO
mkersh3 0:e7ca326e76ee 58 ip_addr_t toaddr;
mkersh3 0:e7ca326e76ee 59 #endif /* LWIP_NETBUF_RECVINFO */
mkersh3 0:e7ca326e76ee 60 #endif /* LWIP_NETBUF_RECVINFO || LWIP_CHECKSUM_ON_COPY */
mkersh3 0:e7ca326e76ee 61 };
mkersh3 0:e7ca326e76ee 62
mkersh3 0:e7ca326e76ee 63 /* Network buffer functions: */
mkersh3 0:e7ca326e76ee 64 struct netbuf * netbuf_new (void);
mkersh3 0:e7ca326e76ee 65 void netbuf_delete (struct netbuf *buf);
mkersh3 0:e7ca326e76ee 66 void * netbuf_alloc (struct netbuf *buf, u16_t size);
mkersh3 0:e7ca326e76ee 67 void netbuf_free (struct netbuf *buf);
mkersh3 0:e7ca326e76ee 68 err_t netbuf_ref (struct netbuf *buf,
mkersh3 0:e7ca326e76ee 69 const void *dataptr, u16_t size);
mkersh3 0:e7ca326e76ee 70 void netbuf_chain (struct netbuf *head,
mkersh3 0:e7ca326e76ee 71 struct netbuf *tail);
mkersh3 0:e7ca326e76ee 72
mkersh3 0:e7ca326e76ee 73 err_t netbuf_data (struct netbuf *buf,
mkersh3 0:e7ca326e76ee 74 void **dataptr, u16_t *len);
mkersh3 0:e7ca326e76ee 75 s8_t netbuf_next (struct netbuf *buf);
mkersh3 0:e7ca326e76ee 76 void netbuf_first (struct netbuf *buf);
mkersh3 0:e7ca326e76ee 77
mkersh3 0:e7ca326e76ee 78
mkersh3 0:e7ca326e76ee 79 #define netbuf_copy_partial(buf, dataptr, len, offset) \
mkersh3 0:e7ca326e76ee 80 pbuf_copy_partial((buf)->p, (dataptr), (len), (offset))
mkersh3 0:e7ca326e76ee 81 #define netbuf_copy(buf,dataptr,len) netbuf_copy_partial(buf, dataptr, len, 0)
mkersh3 0:e7ca326e76ee 82 #define netbuf_take(buf, dataptr, len) pbuf_take((buf)->p, dataptr, len)
mkersh3 0:e7ca326e76ee 83 #define netbuf_len(buf) ((buf)->p->tot_len)
mkersh3 0:e7ca326e76ee 84 #define netbuf_fromaddr(buf) (&((buf)->addr))
mkersh3 0:e7ca326e76ee 85 #define netbuf_set_fromaddr(buf, fromaddr) ip_addr_set((&(buf)->addr), fromaddr)
mkersh3 0:e7ca326e76ee 86 #define netbuf_fromport(buf) ((buf)->port)
mkersh3 0:e7ca326e76ee 87 #if LWIP_NETBUF_RECVINFO
mkersh3 0:e7ca326e76ee 88 #define netbuf_destaddr(buf) (&((buf)->toaddr))
mkersh3 0:e7ca326e76ee 89 #define netbuf_set_destaddr(buf, destaddr) ip_addr_set((&(buf)->addr), destaddr)
mkersh3 0:e7ca326e76ee 90 #define netbuf_destport(buf) (((buf)->flags & NETBUF_FLAG_DESTADDR) ? (buf)->toport_chksum : 0)
mkersh3 0:e7ca326e76ee 91 #endif /* LWIP_NETBUF_RECVINFO */
mkersh3 0:e7ca326e76ee 92 #if LWIP_CHECKSUM_ON_COPY
mkersh3 0:e7ca326e76ee 93 #define netbuf_set_chksum(buf, chksum) do { (buf)->flags = NETBUF_FLAG_CHKSUM; \
mkersh3 0:e7ca326e76ee 94 (buf)->toport_chksum = chksum; } while(0)
mkersh3 0:e7ca326e76ee 95 #endif /* LWIP_CHECKSUM_ON_COPY */
mkersh3 0:e7ca326e76ee 96
mkersh3 0:e7ca326e76ee 97 #ifdef __cplusplus
mkersh3 0:e7ca326e76ee 98 }
mkersh3 0:e7ca326e76ee 99 #endif
mkersh3 0:e7ca326e76ee 100
mkersh3 0:e7ca326e76ee 101 #endif /* __LWIP_NETBUF_H__ */