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