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 * Definitions for tcp compression routines.
mkersh3 0:e7ca326e76ee 3 *
mkersh3 0:e7ca326e76ee 4 * $Id: vj.h,v 1.7 2010/02/22 17:52:09 goldsimon Exp $
mkersh3 0:e7ca326e76ee 5 *
mkersh3 0:e7ca326e76ee 6 * Copyright (c) 1989 Regents of the University of California.
mkersh3 0:e7ca326e76ee 7 * All rights reserved.
mkersh3 0:e7ca326e76ee 8 *
mkersh3 0:e7ca326e76ee 9 * Redistribution and use in source and binary forms are permitted
mkersh3 0:e7ca326e76ee 10 * provided that the above copyright notice and this paragraph are
mkersh3 0:e7ca326e76ee 11 * duplicated in all such forms and that any documentation,
mkersh3 0:e7ca326e76ee 12 * advertising materials, and other materials related to such
mkersh3 0:e7ca326e76ee 13 * distribution and use acknowledge that the software was developed
mkersh3 0:e7ca326e76ee 14 * by the University of California, Berkeley. The name of the
mkersh3 0:e7ca326e76ee 15 * University may not be used to endorse or promote products derived
mkersh3 0:e7ca326e76ee 16 * from this software without specific prior written permission.
mkersh3 0:e7ca326e76ee 17 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
mkersh3 0:e7ca326e76ee 18 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
mkersh3 0:e7ca326e76ee 19 * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
mkersh3 0:e7ca326e76ee 20 *
mkersh3 0:e7ca326e76ee 21 * Van Jacobson (van@helios.ee.lbl.gov), Dec 31, 1989:
mkersh3 0:e7ca326e76ee 22 * - Initial distribution.
mkersh3 0:e7ca326e76ee 23 */
mkersh3 0:e7ca326e76ee 24
mkersh3 0:e7ca326e76ee 25 #ifndef VJ_H
mkersh3 0:e7ca326e76ee 26 #define VJ_H
mkersh3 0:e7ca326e76ee 27
mkersh3 0:e7ca326e76ee 28 #include "lwip/ip.h"
mkersh3 0:e7ca326e76ee 29 #include "lwip/tcp_impl.h"
mkersh3 0:e7ca326e76ee 30
mkersh3 0:e7ca326e76ee 31 #define MAX_SLOTS 16 /* must be > 2 and < 256 */
mkersh3 0:e7ca326e76ee 32 #define MAX_HDR 128
mkersh3 0:e7ca326e76ee 33
mkersh3 0:e7ca326e76ee 34 /*
mkersh3 0:e7ca326e76ee 35 * Compressed packet format:
mkersh3 0:e7ca326e76ee 36 *
mkersh3 0:e7ca326e76ee 37 * The first octet contains the packet type (top 3 bits), TCP
mkersh3 0:e7ca326e76ee 38 * 'push' bit, and flags that indicate which of the 4 TCP sequence
mkersh3 0:e7ca326e76ee 39 * numbers have changed (bottom 5 bits). The next octet is a
mkersh3 0:e7ca326e76ee 40 * conversation number that associates a saved IP/TCP header with
mkersh3 0:e7ca326e76ee 41 * the compressed packet. The next two octets are the TCP checksum
mkersh3 0:e7ca326e76ee 42 * from the original datagram. The next 0 to 15 octets are
mkersh3 0:e7ca326e76ee 43 * sequence number changes, one change per bit set in the header
mkersh3 0:e7ca326e76ee 44 * (there may be no changes and there are two special cases where
mkersh3 0:e7ca326e76ee 45 * the receiver implicitly knows what changed -- see below).
mkersh3 0:e7ca326e76ee 46 *
mkersh3 0:e7ca326e76ee 47 * There are 5 numbers which can change (they are always inserted
mkersh3 0:e7ca326e76ee 48 * in the following order): TCP urgent pointer, window,
mkersh3 0:e7ca326e76ee 49 * acknowlegement, sequence number and IP ID. (The urgent pointer
mkersh3 0:e7ca326e76ee 50 * is different from the others in that its value is sent, not the
mkersh3 0:e7ca326e76ee 51 * change in value.) Since typical use of SLIP links is biased
mkersh3 0:e7ca326e76ee 52 * toward small packets (see comments on MTU/MSS below), changes
mkersh3 0:e7ca326e76ee 53 * use a variable length coding with one octet for numbers in the
mkersh3 0:e7ca326e76ee 54 * range 1 - 255 and 3 octets (0, MSB, LSB) for numbers in the
mkersh3 0:e7ca326e76ee 55 * range 256 - 65535 or 0. (If the change in sequence number or
mkersh3 0:e7ca326e76ee 56 * ack is more than 65535, an uncompressed packet is sent.)
mkersh3 0:e7ca326e76ee 57 */
mkersh3 0:e7ca326e76ee 58
mkersh3 0:e7ca326e76ee 59 /*
mkersh3 0:e7ca326e76ee 60 * Packet types (must not conflict with IP protocol version)
mkersh3 0:e7ca326e76ee 61 *
mkersh3 0:e7ca326e76ee 62 * The top nibble of the first octet is the packet type. There are
mkersh3 0:e7ca326e76ee 63 * three possible types: IP (not proto TCP or tcp with one of the
mkersh3 0:e7ca326e76ee 64 * control flags set); uncompressed TCP (a normal IP/TCP packet but
mkersh3 0:e7ca326e76ee 65 * with the 8-bit protocol field replaced by an 8-bit connection id --
mkersh3 0:e7ca326e76ee 66 * this type of packet syncs the sender & receiver); and compressed
mkersh3 0:e7ca326e76ee 67 * TCP (described above).
mkersh3 0:e7ca326e76ee 68 *
mkersh3 0:e7ca326e76ee 69 * LSB of 4-bit field is TCP "PUSH" bit (a worthless anachronism) and
mkersh3 0:e7ca326e76ee 70 * is logically part of the 4-bit "changes" field that follows. Top
mkersh3 0:e7ca326e76ee 71 * three bits are actual packet type. For backward compatibility
mkersh3 0:e7ca326e76ee 72 * and in the interest of conserving bits, numbers are chosen so the
mkersh3 0:e7ca326e76ee 73 * IP protocol version number (4) which normally appears in this nibble
mkersh3 0:e7ca326e76ee 74 * means "IP packet".
mkersh3 0:e7ca326e76ee 75 */
mkersh3 0:e7ca326e76ee 76
mkersh3 0:e7ca326e76ee 77 /* packet types */
mkersh3 0:e7ca326e76ee 78 #define TYPE_IP 0x40
mkersh3 0:e7ca326e76ee 79 #define TYPE_UNCOMPRESSED_TCP 0x70
mkersh3 0:e7ca326e76ee 80 #define TYPE_COMPRESSED_TCP 0x80
mkersh3 0:e7ca326e76ee 81 #define TYPE_ERROR 0x00
mkersh3 0:e7ca326e76ee 82
mkersh3 0:e7ca326e76ee 83 /* Bits in first octet of compressed packet */
mkersh3 0:e7ca326e76ee 84 #define NEW_C 0x40 /* flag bits for what changed in a packet */
mkersh3 0:e7ca326e76ee 85 #define NEW_I 0x20
mkersh3 0:e7ca326e76ee 86 #define NEW_S 0x08
mkersh3 0:e7ca326e76ee 87 #define NEW_A 0x04
mkersh3 0:e7ca326e76ee 88 #define NEW_W 0x02
mkersh3 0:e7ca326e76ee 89 #define NEW_U 0x01
mkersh3 0:e7ca326e76ee 90
mkersh3 0:e7ca326e76ee 91 /* reserved, special-case values of above */
mkersh3 0:e7ca326e76ee 92 #define SPECIAL_I (NEW_S|NEW_W|NEW_U) /* echoed interactive traffic */
mkersh3 0:e7ca326e76ee 93 #define SPECIAL_D (NEW_S|NEW_A|NEW_W|NEW_U) /* unidirectional data */
mkersh3 0:e7ca326e76ee 94 #define SPECIALS_MASK (NEW_S|NEW_A|NEW_W|NEW_U)
mkersh3 0:e7ca326e76ee 95
mkersh3 0:e7ca326e76ee 96 #define TCP_PUSH_BIT 0x10
mkersh3 0:e7ca326e76ee 97
mkersh3 0:e7ca326e76ee 98
mkersh3 0:e7ca326e76ee 99 /*
mkersh3 0:e7ca326e76ee 100 * "state" data for each active tcp conversation on the wire. This is
mkersh3 0:e7ca326e76ee 101 * basically a copy of the entire IP/TCP header from the last packet
mkersh3 0:e7ca326e76ee 102 * we saw from the conversation together with a small identifier
mkersh3 0:e7ca326e76ee 103 * the transmit & receive ends of the line use to locate saved header.
mkersh3 0:e7ca326e76ee 104 */
mkersh3 0:e7ca326e76ee 105 struct cstate {
mkersh3 0:e7ca326e76ee 106 struct cstate *cs_next; /* next most recently used state (xmit only) */
mkersh3 0:e7ca326e76ee 107 u_short cs_hlen; /* size of hdr (receive only) */
mkersh3 0:e7ca326e76ee 108 u_char cs_id; /* connection # associated with this state */
mkersh3 0:e7ca326e76ee 109 u_char cs_filler;
mkersh3 0:e7ca326e76ee 110 union {
mkersh3 0:e7ca326e76ee 111 char csu_hdr[MAX_HDR];
mkersh3 0:e7ca326e76ee 112 struct ip_hdr csu_ip; /* ip/tcp hdr from most recent packet */
mkersh3 0:e7ca326e76ee 113 } vjcs_u;
mkersh3 0:e7ca326e76ee 114 };
mkersh3 0:e7ca326e76ee 115 #define cs_ip vjcs_u.csu_ip
mkersh3 0:e7ca326e76ee 116 #define cs_hdr vjcs_u.csu_hdr
mkersh3 0:e7ca326e76ee 117
mkersh3 0:e7ca326e76ee 118
mkersh3 0:e7ca326e76ee 119 struct vjstat {
mkersh3 0:e7ca326e76ee 120 unsigned long vjs_packets; /* outbound packets */
mkersh3 0:e7ca326e76ee 121 unsigned long vjs_compressed; /* outbound compressed packets */
mkersh3 0:e7ca326e76ee 122 unsigned long vjs_searches; /* searches for connection state */
mkersh3 0:e7ca326e76ee 123 unsigned long vjs_misses; /* times couldn't find conn. state */
mkersh3 0:e7ca326e76ee 124 unsigned long vjs_uncompressedin; /* inbound uncompressed packets */
mkersh3 0:e7ca326e76ee 125 unsigned long vjs_compressedin; /* inbound compressed packets */
mkersh3 0:e7ca326e76ee 126 unsigned long vjs_errorin; /* inbound unknown type packets */
mkersh3 0:e7ca326e76ee 127 unsigned long vjs_tossed; /* inbound packets tossed because of error */
mkersh3 0:e7ca326e76ee 128 };
mkersh3 0:e7ca326e76ee 129
mkersh3 0:e7ca326e76ee 130 /*
mkersh3 0:e7ca326e76ee 131 * all the state data for one serial line (we need one of these per line).
mkersh3 0:e7ca326e76ee 132 */
mkersh3 0:e7ca326e76ee 133 struct vjcompress {
mkersh3 0:e7ca326e76ee 134 struct cstate *last_cs; /* most recently used tstate */
mkersh3 0:e7ca326e76ee 135 u_char last_recv; /* last rcvd conn. id */
mkersh3 0:e7ca326e76ee 136 u_char last_xmit; /* last sent conn. id */
mkersh3 0:e7ca326e76ee 137 u_short flags;
mkersh3 0:e7ca326e76ee 138 u_char maxSlotIndex;
mkersh3 0:e7ca326e76ee 139 u_char compressSlot; /* Flag indicating OK to compress slot ID. */
mkersh3 0:e7ca326e76ee 140 #if LINK_STATS
mkersh3 0:e7ca326e76ee 141 struct vjstat stats;
mkersh3 0:e7ca326e76ee 142 #endif
mkersh3 0:e7ca326e76ee 143 struct cstate tstate[MAX_SLOTS]; /* xmit connection states */
mkersh3 0:e7ca326e76ee 144 struct cstate rstate[MAX_SLOTS]; /* receive connection states */
mkersh3 0:e7ca326e76ee 145 };
mkersh3 0:e7ca326e76ee 146
mkersh3 0:e7ca326e76ee 147 /* flag values */
mkersh3 0:e7ca326e76ee 148 #define VJF_TOSS 1U /* tossing rcvd frames because of input err */
mkersh3 0:e7ca326e76ee 149
mkersh3 0:e7ca326e76ee 150 extern void vj_compress_init (struct vjcompress *comp);
mkersh3 0:e7ca326e76ee 151 extern u_int vj_compress_tcp (struct vjcompress *comp, struct pbuf *pb);
mkersh3 0:e7ca326e76ee 152 extern void vj_uncompress_err (struct vjcompress *comp);
mkersh3 0:e7ca326e76ee 153 extern int vj_uncompress_uncomp(struct pbuf *nb, struct vjcompress *comp);
mkersh3 0:e7ca326e76ee 154 extern int vj_uncompress_tcp (struct pbuf **nb, struct vjcompress *comp);
mkersh3 0:e7ca326e76ee 155
mkersh3 0:e7ca326e76ee 156 #endif /* VJ_H */