ROHC compression/decompression library
d_generic.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 
00026 #ifndef D_GENERIC_H
00027 #define D_GENERIC_H
00028 
00029 #include <stdlib.h>
00030 
00031 #include "rohc_decomp.h"
00032 #include "comp_list.h"
00033 
00034 #define MAX_ITEM 15
00035 
00036 #define LIST_COMP_WINDOW 100
00037 
00038 #define L 5
00039 
00048 struct d_generic_changes
00049 {
00051         struct ip_packet ip;
00052 
00054         int rnd;
00056         int nbo;
00057 
00059         int complist;
00061         int size_list;
00062         
00064         unsigned char *next_header;
00066         unsigned int next_header_len;
00067 };
00068 
00069 
00077 struct d_generic_context
00078 {
00080         struct d_generic_changes *last1;
00082         struct d_generic_changes *last2;
00084         struct d_generic_changes *active1;
00086         struct d_generic_changes *active2;
00087 
00089         int first_packet_processed;
00090 
00092         struct d_lsb_decode sn;
00094         struct d_ip_id_decode ip_id1;
00096         struct d_ip_id_decode ip_id2;
00097 
00099         struct list_decomp * list_decomp1;
00101         struct list_decomp * list_decomp2;
00102 
00104         int multiple_ip;
00105 
00107         int packet_type;
00108 
00109         /* below are some information and handlers to manage the next header
00110          * (if any) located just after the IP headers (1 or 2 IP headers) */
00111 
00113         unsigned short next_header_proto;
00114 
00116         unsigned int next_header_len;
00117 
00120         int (*build_next_header)(struct d_generic_context *context,
00121                                  struct d_generic_changes *active,
00122                                  unsigned char *dest,
00123                                  int payload_size);
00124 
00127         int (*decode_static_next_header)(struct d_generic_context *context,
00128                                          const unsigned char *packet,
00129                                          unsigned int length,
00130                                          unsigned char *dest);
00131 
00134         int (*decode_dynamic_next_header)(struct d_generic_context *context,
00135                                           const unsigned char *packet,
00136                                           unsigned int length,
00137                                           unsigned char *dest);
00138 
00140         int (*decode_uo_tail)(struct d_generic_context *context,
00141                               const unsigned char *packet,
00142                               unsigned int length,
00143                               unsigned char *dest);
00144 
00146         unsigned int (*compute_crc_static)(const unsigned char *ip,
00147                                            const unsigned char *ip2,
00148                                            const unsigned char *next_header,
00149                                            unsigned int crc_type,
00150                                            unsigned int init_val);
00151 
00153         unsigned int (*compute_crc_dynamic)(const unsigned char *ip,
00154                                             const unsigned char *ip2,
00155                                             const unsigned char *next_header,
00156                                             unsigned int crc_type,
00157                                             unsigned int init_val);
00158 
00160         void *specific;
00161 
00163         int counter;
00164 
00166         unsigned int last_packet_time;
00168         unsigned int current_packet_time;
00170         unsigned int inter_arrival_time;
00171 };
00172 
00176 struct list_decomp
00177 {
00179         struct c_list * ref_list;
00181         struct c_list * list_table[LIST_COMP_WINDOW];
00183         struct c_list * temp_list;
00185         struct item  based_table[MAX_ITEM];
00187         struct d_translation  trans_table[MAX_ITEM];
00189         int counter_list;
00191         int counter;
00193         int list_decomp;
00195         int ref_ok;
00197         int size_ext;
00198 
00200         void (*free_table)(struct list_decomp * decomp);
00202         int (*encode_extension)(struct d_generic_changes * active, 
00203                         struct list_decomp * decomp, unsigned char *dest);
00206         int (*check_index)(struct list_decomp * decomp, int index);
00209         void (*create_item)(const unsigned char *data,int length,
00210                                 int index, struct list_decomp * decomp);
00212         int (*get_ext_size)(const unsigned char * ext);
00213 };
00214 
00215 /*
00216  * Public function prototypes.
00217  */
00218 
00219 void * d_generic_create(void);
00220 
00221 void d_generic_destroy(void *context);
00222 
00223 int d_generic_decode(struct rohc_decomp *decomp,
00224                      struct d_context *context,
00225                      unsigned char *packet,
00226                      int size,
00227                      int second_byte,
00228                      unsigned char *dest);
00229 
00230 int d_generic_decode_ir(struct rohc_decomp *decomp,
00231                         struct d_context *context,
00232                         unsigned char *packet,
00233                         int plen,
00234                         int large_cid_len,
00235                         int is_addcid_used,
00236                         unsigned char *dest);
00237 
00238 unsigned int d_generic_detect_ir_size(struct d_context *context,
00239                                       unsigned char *packet,
00240                                       unsigned int plen,
00241                                       unsigned int large_cid_len);
00242 
00243 unsigned int d_generic_detect_ir_dyn_size(struct d_context *context,
00244                                           unsigned char *first_byte,
00245                                           unsigned int plen,
00246                                           unsigned int large_cid_len);
00247 
00248 int d_algo_list_decompress(struct list_decomp * decomp, 
00249                            const unsigned char *packet);
00250 
00251 int decode_type_0(struct list_decomp * decomp,
00252                   const unsigned char * packet, 
00253                   int gen_id, int ps, int m);
00254 
00255 int decode_type_1(struct list_decomp * decomp,
00256                   const unsigned char * packet, 
00257                   int gen_id, 
00258                   int ps, int m, int ref_id);
00259 
00260 int decode_type_2(struct list_decomp * decomp, 
00261                   const unsigned char * packet, 
00262                   int gen_id, int ps, int ref_id);
00263 
00264 int decode_type_3(struct list_decomp * decomp,
00265                   const unsigned char * packet, 
00266                   int gen_id, 
00267                   int ps, int m, int ref_id);
00268 
00269 int d_generic_get_sn(struct d_context *context);
00270 
00271 int find_packet_type(struct rohc_decomp *decomp,
00272                      struct d_context *context,
00273                      const unsigned char *packet,
00274                      int second_byte);
00275 
00276 #endif
00277