Serves a webpage and saves the user entered data in a .txt file all on the MBED

Dependents:   HTTPServerCustom

Fork of EthernetNetIf by Donatien Garnier

Committer:
wellmon7
Date:
Mon Sep 29 23:43:13 2014 +0000
Revision:
6:5ff4a18d103e
Parent:
0:422060928e37
I don't know what this is asking for...we made slight changes to make the router and mbed applicable

Who changed what in which revision?

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