1 #ifndef _SLHC_H 1 2 #define _SLHC_H 3 /* 4 * Definitions for tcp compression routines. 5 * 6 * $Header: slcompress.h,v 1.10 89/12/31 08:53 7 * 8 * Copyright (c) 1989 Regents of the Universit 9 * All rights reserved. 10 * 11 * Redistribution and use in source and binary 12 * provided that the above copyright notice an 13 * duplicated in all such forms and that any d 14 * advertising materials, and other materials 15 * distribution and use acknowledge that the s 16 * by the University of California, Berkeley. 17 * University may not be used to endorse or pr 18 * from this software without specific prior w 19 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WIT 20 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMI 21 * WARRANTIES OF MERCHANTABILITY AND FITNESS F 22 * 23 * Van Jacobson (van@helios.ee.lbl.gov), 24 * - Initial distribution. 25 * 26 * 27 * modified for KA9Q Internet Software Package 28 * Katie Stevens (dkstevens@ucdavis.edu) 29 * University of California, Davis 30 * Computing Services 31 * - 01-31-90 initial adaptation 32 * 33 * - Feb 1991 Bill_Simpson@um.cc.umi 34 * variable number of con 35 * allow zero or one slot 36 * separate routines 37 * status display 38 */ 39 40 /* 41 * Compressed packet format: 42 * 43 * The first octet contains the packet type (t 44 * 'push' bit, and flags that indicate which o 45 * numbers have changed (bottom 5 bits). The 46 * conversation number that associates a saved 47 * the compressed packet. The next two octets 48 * from the original datagram. The next 0 to 49 * sequence number changes, one change per bit 50 * (there may be no changes and there are two 51 * the receiver implicitly knows what changed 52 * 53 * There are 5 numbers which can change (they 54 * in the following order): TCP urgent pointer 55 * acknowledgment, sequence number and IP ID. 56 * is different from the others in that its va 57 * change in value.) Since typical use of SLI 58 * toward small packets (see comments on MTU/M 59 * use a variable length coding with one octet 60 * range 1 - 255 and 3 octets (0, MSB, LSB) fo 61 * range 256 - 65535 or 0. (If the change in 62 * ack is more than 65535, an uncompressed pac 63 */ 64 65 /* 66 * Packet types (must not conflict with IP pro 67 * 68 * The top nibble of the first octet is the pa 69 * three possible types: IP (not proto TCP or 70 * control flags set); uncompressed TCP (a nor 71 * with the 8-bit protocol field replaced by a 72 * this type of packet syncs the sender & rece 73 * TCP (described above). 74 * 75 * LSB of 4-bit field is TCP "PUSH" bit (a wor 76 * is logically part of the 4-bit "changes" fi 77 * three bits are actual packet type. For bac 78 * and in the interest of conserving bits, num 79 * IP protocol version number (4) which normal 80 * means "IP packet". 81 */ 82 83 84 #include <linux/ip.h> 85 #include <linux/tcp.h> 86 87 /* SLIP compression masks for len/vers byte */ 88 #define SL_TYPE_IP 0x40 89 #define SL_TYPE_UNCOMPRESSED_TCP 0x70 90 #define SL_TYPE_COMPRESSED_TCP 0x80 91 #define SL_TYPE_ERROR 0x00 92 93 /* Bits in first octet of compressed packet */ 94 #define NEW_C 0x40 /* flag bits for what 95 #define NEW_I 0x20 96 #define NEW_S 0x08 97 #define NEW_A 0x04 98 #define NEW_W 0x02 99 #define NEW_U 0x01 100 101 /* reserved, special-case values of above */ 102 #define SPECIAL_I (NEW_S|NEW_W|NEW_U) 103 #define SPECIAL_D (NEW_S|NEW_A|NEW_W|NEW_U) 104 #define SPECIALS_MASK (NEW_S|NEW_A|NEW_W|NEW_U 105 106 #define TCP_PUSH_BIT 0x10 107 108 /* 109 * data type and sizes conversion assumptions: 110 * 111 * VJ code KA9Q style generi 112 * u_char byte_t unsign 113 * u_short int16 unsign 114 * u_int int16 unsign 115 * u_long unsigned long unsign 116 * int int32 long 117 */ 118 119 typedef __u8 byte_t; 120 typedef __u32 int32; 121 122 /* 123 * "state" data for each active tcp conversati 124 * basically a copy of the entire IP/TCP heade 125 * we saw from the conversation together with 126 * the transmit & receive ends of the line use 127 */ 128 struct cstate { 129 byte_t cs_this; /* connection 130 bool initialized; /* true if ini 131 struct cstate *next; /* next in rin 132 struct iphdr cs_ip; /* ip/tcp hdr 133 struct tcphdr cs_tcp; 134 unsigned char cs_ipopt[64]; 135 unsigned char cs_tcpopt[64]; 136 int cs_hsize; 137 }; 138 #define NULLSLSTATE (struct cstate *)0 139 140 /* 141 * all the state data for one serial line (we 142 */ 143 struct slcompress { 144 struct cstate *tstate; /* transmit co 145 struct cstate *rstate; /* receive con 146 147 byte_t tslot_limit; /* highest tra 148 byte_t rslot_limit; /* highest rec 149 150 byte_t xmit_oldest; /* oldest xmit 151 byte_t xmit_current; /* most recent 152 byte_t recv_current; /* most recent 153 154 byte_t flags; 155 #define SLF_TOSS 0x01 /* tossing rcv 156 157 int32 sls_o_nontcp; /* outbound no 158 int32 sls_o_tcp; /* outbound TC 159 int32 sls_o_uncompressed; /* out 160 int32 sls_o_compressed; /* outbound co 161 int32 sls_o_searches; /* searches fo 162 int32 sls_o_misses; /* times could 163 164 int32 sls_i_uncompressed; /* inb 165 int32 sls_i_compressed; /* inbound com 166 int32 sls_i_error; /* inbound err 167 int32 sls_i_tossed; /* inbound pac 168 169 int32 sls_i_runt; 170 int32 sls_i_badcheck; 171 }; 172 #define NULLSLCOMPR (struct slcompress *)0 173 174 /* In slhc.c: */ 175 struct slcompress *slhc_init(int rslots, int t 176 void slhc_free(struct slcompress *comp); 177 178 int slhc_compress(struct slcompress *comp, uns 179 unsigned char *ocp, unsigned 180 int slhc_uncompress(struct slcompress *comp, u 181 int slhc_remember(struct slcompress *comp, uns 182 int slhc_toss(struct slcompress *comp); 183 184 #endif /* _SLHC_H */ 185
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.