ソースの整理中ですが、利用はできます。

Dependencies:   EthernetInterface HttpServer TextLCD mbed-rpc mbed-rtos mbed Socket lwip-eth lwip-sys lwip

Committer:
yueee_yt
Date:
Wed Mar 12 04:19:54 2014 +0000
Revision:
0:7766f6712673
???????????????

Who changed what in which revision?

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