ProjetoBB

Dependencies:   F7_Ethernet WebSocketClient mbed mcp3008

Fork of Nucleo_F746ZG_Ethernet by Dieter Graef

Committer:
DieterGraef
Date:
Sat Jun 18 10:49:12 2016 +0000
Revision:
0:f9b6112278fe
Ethernet for the NUCLEO STM32F746 Board Testprogram uses DHCP and NTP to set the clock

Who changed what in which revision?

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