ROHC compression/decompression library
rohc_decomp.h
Go to the documentation of this file.
00001 /*
00002  * This program is free software; you can redistribute it and/or modify
00003  * it under the terms of the GNU General Public License as published by
00004  * the Free Software Foundation; either version 2 of the License, or
00005  * (at your option) any later version.
00006  *
00007  * This program is distributed in the hope that it will be useful,
00008  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00009  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00010  * GNU General Public License for more details.
00011  *
00012  * You should have received a copy of the GNU General Public License
00013  * along with this program; if not, write to the Free Software
00014  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00015  */
00016 
00025 #ifndef DECOMP_H
00026 #define DECOMP_H
00027 
00028 #include "rohc.h"
00029 #include "rohc_comp.h"
00030 
00032 #define D_NUM_PROFILES 5
00033 
00034 
00036 typedef enum
00037 {
00039         NO_CONTEXT = 1,
00041         STATIC_CONTEXT = 2,
00043         FULL_CONTEXT = 3,
00044 } rohc_d_state;
00045 
00046 
00054 struct d_decode_data
00055 {
00057         int cid;
00059         int addcidUsed;
00061         int largecidUsed;
00063         unsigned int large_cid_size;
00065         struct d_context *active;
00066 };
00067 
00068 
00072 struct d_statistics
00073 {
00075         unsigned int packets_received;
00077         unsigned int packets_failed_crc;
00079         unsigned int packets_failed_no_context;
00081         unsigned int packets_failed_package;
00083         unsigned int packets_feedback;
00084 };
00085 
00086 
00090 struct rohc_decomp
00091 {
00093         struct rohc_comp *compressor;
00094 
00096         struct medium *medium;
00097 
00099         struct d_context **contexts;
00101         int num_contexts;
00103         struct d_context *last_context;
00104 
00113         unsigned int maxval;
00115         unsigned int errval;
00117         unsigned int okval;
00119         int curval;
00120 
00122         struct d_statistics statistics;
00123 };
00124 
00125 
00129 struct d_context
00130 {
00132         struct d_profile *profile;
00134         void *specific;
00135 
00137         rohc_mode mode;
00140         rohc_d_state state;
00141 
00143         unsigned int latest_used;
00145         unsigned int first_used;
00146 
00148         int curval;
00149 
00150         /* below are some statistics */
00151 
00153         int total_uncompressed_size;
00155         int total_compressed_size;
00157         int header_uncompressed_size;
00159         int header_compressed_size; 
00160 
00162         int num_recv_packets;
00164         int num_recv_ir;
00166         int num_recv_ir_dyn;
00168         int num_sent_feedbacks;
00169 
00171         int num_decomp_failures;
00173         int num_decomp_repairs;
00174 
00176         struct c_wlsb *total_16_uncompressed;
00178         struct c_wlsb *total_16_compressed;
00180         struct c_wlsb *header_16_uncompressed;
00182         struct c_wlsb *header_16_compressed;
00183 };
00184 
00185 
00192 struct d_profile
00193 {
00195         int id;
00196 
00198         char *version;
00200         char *description;
00201 
00203         int (*decode)(struct rohc_decomp *decomp, struct d_context *context,
00204                       unsigned char *packet, int size, int second_byte,
00205                       unsigned char *dest);
00206 
00208         int (*decode_ir)(struct rohc_decomp *decomp, struct d_context *context,
00209                          unsigned char *packet, int size, int large_cid_len,
00210                          int is_addcid_used, unsigned char *dest);
00211 
00214         void * (*allocate_decode_data)(void);
00215 
00218         void (*free_decode_data)(void *);
00219 
00221         unsigned int (*detect_ir_size)(struct d_context *context,
00222                                        unsigned char *packet,
00223                                        unsigned int plen,
00224                                        unsigned int large_cid_len);
00225 
00227         unsigned int (*detect_ir_dyn_size)(struct d_context *context,
00228                                            unsigned char *packet,
00229                                            unsigned int plen,
00230                                            unsigned int large_cid_len);
00231         
00233         int (*get_static_part)(void);
00234 
00236         int (*get_sn)(struct d_context * context);
00237 };
00238 
00239 /*
00240  * Functions related to decompressor:
00241  */
00242 
00243 void context_array_increase(struct rohc_decomp *decomp, int highestcid);
00244 void context_array_decrease(struct rohc_decomp *decomp);
00245 
00246 struct rohc_decomp * rohc_alloc_decompressor(struct rohc_comp *compressor);
00247 void rohc_free_decompressor(struct rohc_decomp *decomp);
00248 
00249 int rohc_decompress(struct rohc_decomp *decomp, unsigned char *ibuf, int isize,
00250                     unsigned char *obuf, int osize);
00251 int rohc_decompress_both(struct rohc_decomp *decomp, unsigned char *ibuf,
00252                          int isize, unsigned char * obuf, int osize, int large);
00253 int d_decode_header(struct rohc_decomp *decomp, unsigned char *ibuf, int isize,
00254                     unsigned char *obuf, int osize,
00255                     struct d_decode_data *ddata);
00256 
00257 /*
00258  * Functions related to context:
00259  */
00260 
00261 struct d_context * find_context(struct rohc_decomp *decomp, int cid);
00262 struct d_context * context_create(struct rohc_decomp *decomp, int with_cid, struct d_profile * profile);
00263 void context_free(struct d_context * context);
00264 
00265 
00266 /*
00267  * Functions related to feedback:
00268  */
00269 
00270 void d_operation_mode_feedback(struct rohc_decomp *decomp, int rohc_status, int cid,
00271                                int addcidUsed, int largecidUsed, int mode,
00272                                struct d_context *context);
00273 void d_change_mode_feedback(struct rohc_decomp *decomp, struct d_context *context);
00274 
00275 
00276 /*
00277  * Functions related to CRC of IR and IR-DYN packets:
00278  */
00279 
00280 int rohc_ir_packet_crc_ok(struct d_context *context,
00281                           unsigned char *walk, unsigned int plen,
00282                           const int largecid, const int addcidUsed,
00283                           const struct d_profile *profile);
00284 int rohc_ir_dyn_packet_crc_ok(unsigned char *walk,
00285                               unsigned int plen,
00286                               const int largecid,
00287                               const int addcidUsed,
00288                               const struct d_profile *profile,
00289                               struct d_context *context);
00290 
00291 
00292 /*
00293  * Functions related to statistics:
00294  */
00295 
00296 int rohc_d_statistics(struct rohc_decomp *decomp, unsigned int indent,
00297                       char *buffer);
00298 int rohc_d_context(struct rohc_decomp *decomp, int index, unsigned int indent,
00299                    char *buffer);
00300 void clear_statistics(struct rohc_decomp *decomp);
00301 
00302 
00303 /*
00304  * Functions related to user interaction:
00305  */
00306 
00307 void user_interactions(struct rohc_decomp *decomp, int feedback_maxval);
00308 
00309 
00310 #endif
00311