OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-stable/] [newlib-1.18.0/] [newlib/] [libc/] [sys/] [linux/] [include/] [net/] [slcompress.h] - Blame information for rev 829

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 207 jeremybenn
/*
2
 * Definitions for tcp compression routines.
3
 *
4
 * Copyright (c) 1989, 1993
5
 *      The Regents of the University of California.  All rights reserved.
6
 *
7
 * Redistribution and use in source and binary forms, with or without
8
 * modification, are permitted provided that the following conditions
9
 * are met:
10
 * 1. Redistributions of source code must retain the above copyright
11
 *    notice, this list of conditions and the following disclaimer.
12
 * 2. Redistributions in binary form must reproduce the above copyright
13
 *    notice, this list of conditions and the following disclaimer in the
14
 *    documentation and/or other materials provided with the distribution.
15
 * 3. All advertising materials mentioning features or use of this software
16
 *    must display the following acknowledgement:
17
 *      This product includes software developed by the University of
18
 *      California, Berkeley and its contributors.
19
 * 4. Neither the name of the University nor the names of its contributors
20
 *    may be used to endorse or promote products derived from this software
21
 *    without specific prior written permission.
22
 *
23
 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
24
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
27
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
29
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
32
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33
 * SUCH DAMAGE.
34
 *
35
 *      Van Jacobson (van@helios.ee.lbl.gov), Dec 31, 1989:
36
 *      - Initial distribution.
37
 * $FreeBSD: src/sys/net/slcompress.h,v 1.17 2002/03/19 21:54:18 alfred Exp $
38
 */
39
 
40
#ifndef _NET_SLCOMPRESS_H_
41
#define _NET_SLCOMPRESS_H_
42
 
43
#define MAX_STATES 16           /* must be > 2 and < 256 */
44
#define MAX_HDR 128
45
 
46
/*
47
 * Compressed packet format:
48
 *
49
 * The first octet contains the packet type (top 3 bits), TCP
50
 * 'push' bit, and flags that indicate which of the 4 TCP sequence
51
 * numbers have changed (bottom 5 bits).  The next octet is a
52
 * conversation number that associates a saved IP/TCP header with
53
 * the compressed packet.  The next two octets are the TCP checksum
54
 * from the original datagram.  The next 0 to 15 octets are
55
 * sequence number changes, one change per bit set in the header
56
 * (there may be no changes and there are two special cases where
57
 * the receiver implicitly knows what changed -- see below).
58
 *
59
 * There are 5 numbers which can change (they are always inserted
60
 * in the following order): TCP urgent pointer, window,
61
 * acknowledgement, sequence number and IP ID.  (The urgent pointer
62
 * is different from the others in that its value is sent, not the
63
 * change in value.)  Since typical use of SLIP links is biased
64
 * toward small packets (see comments on MTU/MSS below), changes
65
 * use a variable length coding with one octet for numbers in the
66
 * range 1 - 255 and 3 octets (0, MSB, LSB) for numbers in the
67
 * range 256 - 65535 or 0.  (If the change in sequence number or
68
 * ack is more than 65535, an uncompressed packet is sent.)
69
 */
70
 
71
/*
72
 * Packet types (must not conflict with IP protocol version)
73
 *
74
 * The top nibble of the first octet is the packet type.  There are
75
 * three possible types: IP (not proto TCP or tcp with one of the
76
 * control flags set); uncompressed TCP (a normal IP/TCP packet but
77
 * with the 8-bit protocol field replaced by an 8-bit connection id --
78
 * this type of packet syncs the sender & receiver); and compressed
79
 * TCP (described above).
80
 *
81
 * LSB of 4-bit field is TCP "PUSH" bit (a worthless anachronism) and
82
 * is logically part of the 4-bit "changes" field that follows.  Top
83
 * three bits are actual packet type.  For backward compatibility
84
 * and in the interest of conserving bits, numbers are chosen so the
85
 * IP protocol version number (4) which normally appears in this nibble
86
 * means "IP packet".
87
 */
88
 
89
/* packet types */
90
#define TYPE_IP 0x40
91
#define TYPE_UNCOMPRESSED_TCP 0x70
92
#define TYPE_COMPRESSED_TCP 0x80
93
#define TYPE_ERROR 0x00
94
 
95
/* Bits in first octet of compressed packet */
96
#define NEW_C   0x40    /* flag bits for what changed in a packet */
97
#define NEW_I   0x20
98
#define NEW_S   0x08
99
#define NEW_A   0x04
100
#define NEW_W   0x02
101
#define NEW_U   0x01
102
 
103
/* reserved, special-case values of above */
104
#define SPECIAL_I (NEW_S|NEW_W|NEW_U)           /* echoed interactive traffic */
105
#define SPECIAL_D (NEW_S|NEW_A|NEW_W|NEW_U)     /* unidirectional data */
106
#define SPECIALS_MASK (NEW_S|NEW_A|NEW_W|NEW_U)
107
 
108
#define TCP_PUSH_BIT 0x10
109
 
110
 
111
/*
112
 * "state" data for each active tcp conversation on the wire.  This is
113
 * basically a copy of the entire IP/TCP header from the last packet
114
 * we saw from the conversation together with a small identifier
115
 * the transmit & receive ends of the line use to locate saved header.
116
 */
117
struct cstate {
118
        struct cstate *cs_next; /* next most recently used cstate (xmit only) */
119
        u_int16_t cs_hlen;      /* size of hdr (receive only) */
120
        u_char cs_id;           /* connection # associated with this state */
121
        u_char cs_filler;
122
        union {
123
                char csu_hdr[MAX_HDR];
124
                struct ip csu_ip;       /* ip/tcp hdr from most recent packet */
125
        } slcs_u;
126
};
127
#define cs_ip slcs_u.csu_ip
128
#define cs_hdr slcs_u.csu_hdr
129
 
130
/*
131
 * all the state data for one serial line (we need one of these
132
 * per line).
133
 */
134
struct slcompress {
135
        struct cstate *last_cs; /* most recently used tstate */
136
        u_char last_recv;       /* last rcvd conn. id */
137
        u_char last_xmit;       /* last sent conn. id */
138
        u_int16_t flags;
139
#ifndef SL_NO_STATS
140
        int sls_packets;        /* outbound packets */
141
        int sls_compressed;     /* outbound compressed packets */
142
        int sls_searches;       /* searches for connection state */
143
        int sls_misses;         /* times couldn't find conn. state */
144
        int sls_uncompressedin; /* inbound uncompressed packets */
145
        int sls_compressedin;   /* inbound compressed packets */
146
        int sls_errorin;        /* inbound unknown type packets */
147
        int sls_tossed;         /* inbound packets tossed because of error */
148
#endif
149
        struct cstate tstate[MAX_STATES];       /* xmit connection states */
150
        struct cstate rstate[MAX_STATES];       /* receive connection states */
151
};
152
/* flag values */
153
#define SLF_TOSS 1              /* tossing rcvd frames because of input err */
154
 
155
void     sl_compress_init(struct slcompress *, int);
156
u_int    sl_compress_tcp(struct mbuf *, struct ip *, struct slcompress *, int);
157
int      sl_uncompress_tcp(u_char **, int, u_int, struct slcompress *);
158
int      sl_uncompress_tcp_core(u_char *, int, int, u_int,
159
            struct slcompress *, u_char **, u_int *);
160
 
161
#endif /* !_NET_SLCOMPRESS_H_ */

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.