ROHC compression/decompression library
rohc_comp.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 
00017 /**
00018  * @file rohc_comp.h
00019  * @brief ROHC compression routines
00020  * @author Didier Barvaux <didier.barvaux@toulouse.viveris.com>
00021  * @author The hackers from ROHC for Linux
00022  */
00023 
00024 #ifndef COMP_H
00025 #define COMP_H
00026 
00027 #include "rohc.h"
00028 #include "rohc_packets.h"
00029 
00030 #include <stdlib.h>
00031 #include <stdbool.h>
00032 
00033 
00034 /** Macro that handles DLL export declarations gracefully */
00035 #ifdef DLL_EXPORT /* passed by autotools on command line */
00036         #define ROHC_EXPORT __declspec(dllexport)
00037 #else
00038         #define ROHC_EXPORT 
00039 #endif
00040 
00041 
00042 /*
00043  * Declare the private ROHC compressor structure that is defined inside the
00044  * library.
00045  */
00046 
00047 struct rohc_comp;
00048 
00049 
00050 /*
00051  * Public structures and types
00052  */
00053 
00054 
00055 /**
00056  * @brief The different ROHC compressor states
00057  *
00058  * See 4.3.1 in the RFC 3095.
00059  *
00060  * If you add a new compressor state, please also add the corresponding
00061  * textual description in \ref rohc_comp_get_state_descr.
00062  */
00063 typedef enum
00064 {
00065         /** The Initialization and Refresh (IR) state */
00066         IR = 1,
00067         /** The First Order (FO) state */
00068         FO = 2,
00069         /** The Second Order (SO) state */
00070         SO = 3,
00071 } rohc_c_state;
00072 
00073 
00074 /** Some information about the last compressed packet */
00075 typedef struct
00076 {
00077         /** The mode of the last context used by the compressor */
00078         rohc_mode context_mode;
00079         /** The state of the last context used by the compressor */
00080         rohc_c_state context_state;
00081         /** The type of ROHC packet created for the last compressed packet */
00082         rohc_packet_t packet_type;
00083         /** The uncompressed size (in bytes) of the last compressed packet */
00084         unsigned long total_last_uncomp_size;
00085         /** The uncompressed size (in bytes) of the last compressed header */
00086         unsigned long header_last_uncomp_size;
00087         /** The compressed size (in bytes) of the last compressed packet */
00088         unsigned long total_last_comp_size;
00089         /** The compressed size (in bytes) of the last compressed header */
00090         unsigned long header_last_comp_size;
00091 } rohc_comp_last_packet_info_t;
00092 
00093 
00094 /** The prototype of the callback for random numbers */
00095 typedef int (*rohc_comp_random_cb_t) (const struct rohc_comp *const comp,
00096                                       void *const user_context)
00097         __attribute__((nonnull(1)));
00098 
00099 
00100 /*
00101  * Prototypes of main public functions related to ROHC compression
00102  */
00103 
00104 struct rohc_comp * ROHC_EXPORT rohc_alloc_compressor(int max_cid,
00105                                                                                                                                           int jam_use,
00106                                                                                                                                           int adapt_size,
00107                                                                                                                                           int encap_size);
00108 void ROHC_EXPORT rohc_free_compressor(struct rohc_comp *comp);
00109 
00110 bool ROHC_EXPORT rohc_comp_set_random_cb(struct rohc_comp *const comp,
00111                                          rohc_comp_random_cb_t callback,
00112                                          void *const user_context)
00113         __attribute__((nonnull(1, 2)));
00114 
00115 int ROHC_EXPORT rohc_compress(struct rohc_comp *comp,
00116                               unsigned char *ibuf,
00117                               int isize,
00118                               unsigned char *obuf,
00119                               int osize);
00120 
00121 
00122 /*
00123  * Prototypes of public functions related to user interaction
00124  */
00125 
00126 int ROHC_EXPORT rohc_c_is_enabled(struct rohc_comp *comp);
00127 int ROHC_EXPORT rohc_c_using_small_cid(struct rohc_comp *comp);
00128 
00129 void ROHC_EXPORT rohc_activate_profile(struct rohc_comp *comp, int profile);
00130 
00131 void ROHC_EXPORT rohc_c_set_header(struct rohc_comp *compressor, int value);
00132 void ROHC_EXPORT rohc_c_set_mrru(struct rohc_comp *compressor, int value);
00133 void ROHC_EXPORT rohc_c_set_max_cid(struct rohc_comp *compressor, int value);
00134 void ROHC_EXPORT rohc_c_set_large_cid(struct rohc_comp *compressor, int value);
00135 void ROHC_EXPORT rohc_c_set_enable(struct rohc_comp *compressor, int value);
00136 
00137 
00138 /*
00139  * Prototypes of public functions related to ROHC feedback
00140  */
00141 
00142 void ROHC_EXPORT c_piggyback_feedback(struct rohc_comp *comp,
00143                                       unsigned char *packet,
00144                                       int size);
00145 void ROHC_EXPORT c_deliver_feedback(struct rohc_comp *comp,
00146                                     unsigned char *feedback,
00147                                     int size);
00148 int ROHC_EXPORT rohc_feedback_flush(struct rohc_comp *comp,
00149                                     unsigned char *obuf,
00150                                     int osize);
00151 
00152 /* Configure robustness to packet loss/damage */
00153 bool rohc_comp_set_wlsb_window_width(struct rohc_comp *const comp,
00154                                      const size_t width)
00155         __attribute__((nonnull(1), warn_unused_result));
00156 bool rohc_comp_set_periodic_refreshes(struct rohc_comp *const comp,
00157                                       const size_t ir_timeout,
00158                                       const size_t fo_timeout)
00159         __attribute__((nonnull(1), warn_unused_result));
00160 
00161 /*
00162  * Prototypes of public functions related to ROHC compression statistics
00163  */
00164 
00165 int ROHC_EXPORT rohc_c_info(char *buffer);
00166 int ROHC_EXPORT rohc_c_statistics(struct rohc_comp *comp,
00167                                   unsigned int indent,
00168                                   char *buffer);
00169 int ROHC_EXPORT rohc_c_context(struct rohc_comp *comp,
00170                                int cid,
00171                                unsigned int indent,
00172                                char *buffer);
00173 int ROHC_EXPORT rohc_comp_get_last_packet_info(const struct rohc_comp *const comp,
00174                                                rohc_comp_last_packet_info_t *const info);
00175 const char * ROHC_EXPORT rohc_comp_get_state_descr(const rohc_c_state state);
00176 
00177 
00178 #undef ROHC_EXPORT /* do not pollute outside this header */
00179 
00180 #endif
00181