ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/gvpe/src/rohc/comp.h
Revision: 1.3
Committed: Tue Apr 26 00:55:56 2005 UTC (19 years, 1 month ago) by pcg
Content type: text/plain
Branch: MAIN
CVS Tags: rel-2_01, rel-3_0, rel-2_2, rel-2_0, rel-2_21, rel-2_22, rel-2_25, HEAD
Changes since 1.2: +1 -1 lines
Log Message:
*** empty log message ***

File Contents

# Content
1 /*
2 ROHC Project 2003 at Lulea University of Technology, Sweden.
3 Authors: Andreas Vernersson <andver-8@student.luth.se>
4 Daniel Pettersson <danpet-7@student.luth.se>
5 Erik Soderstrom <soderstrom@yahoo.com>
6 Fredrik Lindstrom <frelin-9@student.luth.se>
7 Johan Stenmark <johste-8@student.luth.se>
8 Martin Juhlin <juhlin@users.sourceforge.net>
9 Mikael Larsson <larmik-9@student.luth.se>
10 Robert Maxe <robmax-1@student.luth.se>
11
12 Copyright (C) 2003 Andreas Vernersson, Daniel Pettersson,
13 Erik Soderström, Fredrik Lindström, Johan Stenmark,
14 Martin Juhlin, Mikael Larsson, Robert Maxe.
15
16 This program is free software; you can redistribute it and/or modify
17 it under the terms of the GNU General Public License as published by
18 the Free Software Foundation; either version 2 of the License, or
19 (at your option) any later version.
20
21 This program is distributed in the hope that it will be useful,
22 but WITHOUT ANY WARRANTY; without even the implied warranty of
23 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 GNU General Public License for more details.
25
26 You should have received a copy of the GNU General Public License
27 along with this program; if not, write to the Free Software
28 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
29 */
30 /***************************************************************************
31 * File: comp.h *
32 * Description: Functions and structures for the compressor framework *
33 ***************************************************************************/
34
35 #ifndef _COMP_H
36 #define _COMP_H
37
38 #include "rohc.h"
39
40 /////////////////////////////////////////////////////////////////////
41 // Public functions
42
43 struct sc_rohc;
44 struct sc_context;
45 struct sc_feedback;
46
47 /* Allocate space for a compressor (transmit side) */
48 void *rohc_alloc_compressor(int max_cid);
49
50 /* Free space used by a compressor */
51 void rohc_free_compressor(struct sc_rohc *compressor);
52
53 /* Compress a packet */
54 int rohc_compress(struct sc_rohc *compressor, unsigned char *ibuf, int isize,
55 unsigned char *obuf, int osize);
56
57 /* Store static info (about profiles etc) in the buffer (no compressor is needed) */
58 int rohc_c_info(char *buffer);
59
60 /* Store compression statistics for a compressor in the buffer */
61 int rohc_c_statistics(struct sc_rohc *compressor, char *buffer);
62
63 /* Store context statistics for a compressor in the buffer */
64 int rohc_c_context(struct sc_rohc *compressor, int index, char *buffer);
65
66 /* Get compressor enabled/disable status */
67 int rohc_c_is_enabled(struct sc_rohc *compressor);
68
69 /* Is the compressor using small cid? */
70 int rohc_c_using_small_cid(struct sc_rohc * ch);
71
72
73 // Functions used by rohc's proc device
74
75 void rohc_c_set_header(struct sc_rohc *compressor, int value);
76 void rohc_c_set_mrru(struct sc_rohc *compressor, int value);
77 void rohc_c_set_max_cid(struct sc_rohc *compressor, int value);
78 void rohc_c_set_large_cid(struct sc_rohc *compressor, int value);
79 void rohc_c_set_connection_type(struct sc_rohc *compressor, int value);
80 void rohc_c_set_enable(struct sc_rohc *compressor, int value);
81
82 // These functions are used by the decompressor to send feedback..
83
84 // Add this feedback to the next outgoing ROHC packet:
85 void c_piggyback_feedback(struct sc_rohc *,unsigned char *, int size);
86
87 // Deliver received feedback in in decompressor to compressor..
88 void c_deliver_feedback(struct sc_rohc *,unsigned char *packet, int size);
89
90
91 /////////////////////////////////////////////////////////////////////
92 // Profiles
93
94 #define C_NUM_PROFILES 4
95
96 // The generic interface to compression profiles
97
98 // To implement a new profile you need to implement the following interface
99 // (see c_ip.c or c_udp.c for examples) and add it to the "c_profiles" array
100 // in comp.c
101
102 struct sc_profile {
103 unsigned short protocol; // IP-Protocol
104 unsigned short id; // Profile ID
105 char *version; // Version string
106 char *description; // Description string
107
108 // Called when a new context should be initialized, based on the given packet
109 int (*create)(struct sc_context *context, const struct iphdr *packet);
110
111 // Destroy profile specific data in context
112 void (*destroy)(struct sc_context *context);
113
114 // Check if the packet belongs to the given context (using STATIC-DEF fields etc) */
115 int (*check_context)(struct sc_context *context, const struct iphdr *packet);
116
117 // Compress the packet using the given context. Payload_offset indicates where the
118 // payload starts. Returns the size of the compressed packet or <=0 in case of an
119 // error..
120 int (*encode)(struct sc_context *, const struct iphdr *packet, int packet_size,
121 unsigned char *dest, int dest_size, int *payload_offset);
122
123 // Called when feedback to the context arrives..
124 void (*feedback)(struct sc_context *, struct sc_feedback *);
125 };
126
127 struct sc_profile *c_get_profile_from_protocol(struct sc_rohc *comp, int protocol);
128 struct sc_profile *c_get_profile_from_id(struct sc_rohc *comp, int profile_id);
129
130 ////////////////////////////////////////////////////////////////////////
131
132 typedef enum {U=1,O=2,R=3} C_MODE;
133 typedef enum {IR=1,FO=2,SO=3} C_STATE;
134
135 struct sc_context {
136 int used; // 1==used, 0==unused
137 int latest_used; // time when this context was created
138 int first_used; // time when this context was latest used
139
140 int cid;
141 int profile_id;
142 struct sc_profile *profile;
143
144 struct sc_rohc *compressor;
145
146 // Parameters and initial values common for all
147 // profiles:
148
149 C_MODE c_mode;
150 C_STATE c_state;
151
152 int nbo, rnd;
153 int nbo2, rnd2; // for second ip header if available
154
155 // Statistics information
156 int total_uncompressed_size, total_compressed_size;
157 int header_uncompressed_size, header_compressed_size;
158 int num_send_packets, num_send_ir, num_send_ir_dyn, num_recv_feedbacks;
159 struct sc_wlsb *total_16_uncompressed, *total_16_compressed;
160 struct sc_wlsb *header_16_uncompressed, *header_16_compressed;
161
162
163 // Profile specific context here:
164 void *profile_context;
165 };
166
167
168 // Create a new context
169 struct sc_context *c_create_context(struct sc_rohc *, struct sc_profile *profile, struct iphdr *ip);
170
171 // Find a context that match the given profile and IP-packet
172 struct sc_context *c_find_context(struct sc_rohc *, struct sc_profile *profile, struct iphdr *ip);
173
174 // Find a context given the CID
175 struct sc_context *c_get_context(struct sc_rohc *, int cid);
176 /////////////////////////////////////////////////////////////////////
177
178 struct sc_feedback {
179 unsigned char size; // =field(size) om field(code)==0, annars =field(code)
180 int cid;
181
182 int type; // 1=FEEDBACK-1, 2=FEEDBACK-2
183
184 unsigned char *data; // whole feedback packet exluding first feedback-type octet
185 int specific_offset;
186 int specific_size;
187
188 // feedback-2 only:
189 enum {ACK,NACK,STATIC_NACK,RESERVED} acktype; // 0=ACK, 1=NACK, 2=STATIC-NACK, 3=RESERVED
190 };
191
192 /////////////////////////////////////////////////////////////////////
193
194 #define FEEDBACK_BUFFER_SIZE 10 // Number of outgoing feedbacks that can be queued..
195
196 struct sc_rohc {
197 int enabled;
198
199 int max_cid; // smallCID = [0-15], largeCID = [0-65535]
200 int large_cid;
201
202 int num_used;
203 int num_allocated;
204 struct sc_context *contexts; // allokeras om vid behov.
205
206 int mrru; // Maximum reconstructed reception unit (== 0)
207 int max_header_size; // Maximum header size that will be compressed
208 int connection_type;
209
210 int profiles[C_NUM_PROFILES];
211
212 unsigned char *feedback_buffer[FEEDBACK_BUFFER_SIZE];
213 unsigned int feedback_size [FEEDBACK_BUFFER_SIZE];
214 int feedback_pointer;
215
216 int num_packets; // total number of sent packets
217 int total_compressed_size, total_uncompressed_size;
218
219 struct sc_rohc *feedback_for;
220
221 };
222
223 int c_get_feedback(struct sc_rohc *, unsigned char *);
224 void c_add_feedback(struct sc_rohc *, unsigned char *, int size);
225
226 /////////////////////////////////////////////////////////////////////
227
228 #endif