![]() |
|
|||
0001 #ifndef _SLHC_H 0002 #define _SLHC_H 0003 /* 0004 * Definitions for tcp compression routines. 0005 * 0006 * $Header: slcompress.h,v 1.10 89/12/31 08:53:02 van Exp $ 0007 * 0008 * Copyright (c) 1989 Regents of the University of California. 0009 * All rights reserved. 0010 * 0011 * Redistribution and use in source and binary forms are permitted 0012 * provided that the above copyright notice and this paragraph are 0013 * duplicated in all such forms and that any documentation, 0014 * advertising materials, and other materials related to such 0015 * distribution and use acknowledge that the software was developed 0016 * by the University of California, Berkeley. The name of the 0017 * University may not be used to endorse or promote products derived 0018 * from this software without specific prior written permission. 0019 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR 0020 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED 0021 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 0022 * 0023 * Van Jacobson (van@helios.ee.lbl.gov), Dec 31, 1989: 0024 * - Initial distribution. 0025 * 0026 * 0027 * modified for KA9Q Internet Software Package by 0028 * Katie Stevens (dkstevens@ucdavis.edu) 0029 * University of California, Davis 0030 * Computing Services 0031 * - 01-31-90 initial adaptation 0032 * 0033 * - Feb 1991 Bill_Simpson@um.cc.umich.edu 0034 * variable number of conversation slots 0035 * allow zero or one slots 0036 * separate routines 0037 * status display 0038 */ 0039 0040 /* 0041 * Compressed packet format: 0042 * 0043 * The first octet contains the packet type (top 3 bits), TCP 0044 * 'push' bit, and flags that indicate which of the 4 TCP sequence 0045 * numbers have changed (bottom 5 bits). The next octet is a 0046 * conversation number that associates a saved IP/TCP header with 0047 * the compressed packet. The next two octets are the TCP checksum 0048 * from the original datagram. The next 0 to 15 octets are 0049 * sequence number changes, one change per bit set in the header 0050 * (there may be no changes and there are two special cases where 0051 * the receiver implicitly knows what changed -- see below). 0052 * 0053 * There are 5 numbers which can change (they are always inserted 0054 * in the following order): TCP urgent pointer, window, 0055 * acknowledgment, sequence number and IP ID. (The urgent pointer 0056 * is different from the others in that its value is sent, not the 0057 * change in value.) Since typical use of SLIP links is biased 0058 * toward small packets (see comments on MTU/MSS below), changes 0059 * use a variable length coding with one octet for numbers in the 0060 * range 1 - 255 and 3 octets (0, MSB, LSB) for numbers in the 0061 * range 256 - 65535 or 0. (If the change in sequence number or 0062 * ack is more than 65535, an uncompressed packet is sent.) 0063 */ 0064 0065 /* 0066 * Packet types (must not conflict with IP protocol version) 0067 * 0068 * The top nibble of the first octet is the packet type. There are 0069 * three possible types: IP (not proto TCP or tcp with one of the 0070 * control flags set); uncompressed TCP (a normal IP/TCP packet but 0071 * with the 8-bit protocol field replaced by an 8-bit connection id -- 0072 * this type of packet syncs the sender & receiver); and compressed 0073 * TCP (described above). 0074 * 0075 * LSB of 4-bit field is TCP "PUSH" bit (a worthless anachronism) and 0076 * is logically part of the 4-bit "changes" field that follows. Top 0077 * three bits are actual packet type. For backward compatibility 0078 * and in the interest of conserving bits, numbers are chosen so the 0079 * IP protocol version number (4) which normally appears in this nibble 0080 * means "IP packet". 0081 */ 0082 0083 0084 #include <linux/ip.h> 0085 #include <linux/tcp.h> 0086 0087 /* SLIP compression masks for len/vers byte */ 0088 #define SL_TYPE_IP 0x40 0089 #define SL_TYPE_UNCOMPRESSED_TCP 0x70 0090 #define SL_TYPE_COMPRESSED_TCP 0x80 0091 #define SL_TYPE_ERROR 0x00 0092 0093 /* Bits in first octet of compressed packet */ 0094 #define NEW_C 0x40 /* flag bits for what changed in a packet */ 0095 #define NEW_I 0x20 0096 #define NEW_S 0x08 0097 #define NEW_A 0x04 0098 #define NEW_W 0x02 0099 #define NEW_U 0x01 0100 0101 /* reserved, special-case values of above */ 0102 #define SPECIAL_I (NEW_S|NEW_W|NEW_U) /* echoed interactive traffic */ 0103 #define SPECIAL_D (NEW_S|NEW_A|NEW_W|NEW_U) /* unidirectional data */ 0104 #define SPECIALS_MASK (NEW_S|NEW_A|NEW_W|NEW_U) 0105 0106 #define TCP_PUSH_BIT 0x10 0107 0108 /* 0109 * data type and sizes conversion assumptions: 0110 * 0111 * VJ code KA9Q style generic 0112 * u_char byte_t unsigned char 8 bits 0113 * u_short int16 unsigned short 16 bits 0114 * u_int int16 unsigned short 16 bits 0115 * u_long unsigned long unsigned long 32 bits 0116 * int int32 long 32 bits 0117 */ 0118 0119 typedef __u8 byte_t; 0120 typedef __u32 int32; 0121 0122 /* 0123 * "state" data for each active tcp conversation on the wire. This is 0124 * basically a copy of the entire IP/TCP header from the last packet 0125 * we saw from the conversation together with a small identifier 0126 * the transmit & receive ends of the line use to locate saved header. 0127 */ 0128 struct cstate { 0129 byte_t cs_this; /* connection id number (xmit) */ 0130 bool initialized; /* true if initialized */ 0131 struct cstate *next; /* next in ring (xmit) */ 0132 struct iphdr cs_ip; /* ip/tcp hdr from most recent packet */ 0133 struct tcphdr cs_tcp; 0134 unsigned char cs_ipopt[64]; 0135 unsigned char cs_tcpopt[64]; 0136 int cs_hsize; 0137 }; 0138 #define NULLSLSTATE (struct cstate *)0 0139 0140 /* 0141 * all the state data for one serial line (we need one of these per line). 0142 */ 0143 struct slcompress { 0144 struct cstate *tstate; /* transmit connection states (array)*/ 0145 struct cstate *rstate; /* receive connection states (array)*/ 0146 0147 byte_t tslot_limit; /* highest transmit slot id (0-l)*/ 0148 byte_t rslot_limit; /* highest receive slot id (0-l)*/ 0149 0150 byte_t xmit_oldest; /* oldest xmit in ring */ 0151 byte_t xmit_current; /* most recent xmit id */ 0152 byte_t recv_current; /* most recent rcvd id */ 0153 0154 byte_t flags; 0155 #define SLF_TOSS 0x01 /* tossing rcvd frames until id received */ 0156 0157 int32 sls_o_nontcp; /* outbound non-TCP packets */ 0158 int32 sls_o_tcp; /* outbound TCP packets */ 0159 int32 sls_o_uncompressed; /* outbound uncompressed packets */ 0160 int32 sls_o_compressed; /* outbound compressed packets */ 0161 int32 sls_o_searches; /* searches for connection state */ 0162 int32 sls_o_misses; /* times couldn't find conn. state */ 0163 0164 int32 sls_i_uncompressed; /* inbound uncompressed packets */ 0165 int32 sls_i_compressed; /* inbound compressed packets */ 0166 int32 sls_i_error; /* inbound error packets */ 0167 int32 sls_i_tossed; /* inbound packets tossed because of error */ 0168 0169 int32 sls_i_runt; 0170 int32 sls_i_badcheck; 0171 }; 0172 #define NULLSLCOMPR (struct slcompress *)0 0173 0174 /* In slhc.c: */ 0175 struct slcompress *slhc_init(int rslots, int tslots); 0176 void slhc_free(struct slcompress *comp); 0177 0178 int slhc_compress(struct slcompress *comp, unsigned char *icp, int isize, 0179 unsigned char *ocp, unsigned char **cpp, int compress_cid); 0180 int slhc_uncompress(struct slcompress *comp, unsigned char *icp, int isize); 0181 int slhc_remember(struct slcompress *comp, unsigned char *icp, int isize); 0182 int slhc_toss(struct slcompress *comp); 0183 0184 #endif /* _SLHC_H */
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.1.0 LXR engine. The LXR team |
![]() ![]() |