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 
00031 /*
00032  * Declare the private ROHC compressor structure that is defined inside the
00033  * library.
00034  */
00035 
00036 struct rohc_comp;
00037 
00038 
00039 /*
00040  * Public structures
00041  */
00042 
00043 
00044 /**
00045  * @brief The different ROHC compressor states
00046  *
00047  * See 4.3.1 in the RFC 3095.
00048  *
00049  * If you add a new compressor state, please also add the corresponding
00050  * textual description in \ref rohc_comp_get_state_descr.
00051  */
00052 typedef enum
00053 {
00054         /** The Initialization and Refresh (IR) state */
00055         IR = 1,
00056         /** The First Order (FO) state */
00057         FO = 2,
00058         /** The Second Order (SO) state */
00059         SO = 3,
00060 } rohc_c_state;
00061 
00062 
00063 /** Some information about the last compressed packet */
00064 typedef struct
00065 {
00066         /** The mode of the last context used by the compressor */
00067         rohc_mode context_mode;
00068         /** The state of the last context used by the compressor */
00069         rohc_c_state context_state;
00070         /** The type of ROHC packet created for the last compressed packet */
00071         rohc_packet_t packet_type;
00072         /** The uncompressed size (in bytes) of the last compressed packet */
00073         unsigned long total_last_uncomp_size;
00074         /** The uncompressed size (in bytes) of the last compressed header */
00075         unsigned long header_last_uncomp_size;
00076         /** The compressed size (in bytes) of the last compressed packet */
00077         unsigned long total_last_comp_size;
00078         /** The compressed size (in bytes) of the last compressed header */
00079         unsigned long header_last_comp_size;
00080 } rohc_comp_last_packet_info_t;
00081 
00082 
00083 /*
00084  * Prototypes of main public functions related to ROHC compression
00085  */
00086 
00087 struct rohc_comp * rohc_alloc_compressor(int max_cid,
00088                                          int jam_use,
00089                                          int adapt_size,
00090                                          int encap_size);
00091 void rohc_free_compressor(struct rohc_comp *comp);
00092 
00093 int rohc_compress(struct rohc_comp *comp, unsigned char *ibuf, int isize,
00094                   unsigned char *obuf, int osize);
00095 
00096 
00097 /*
00098  * Prototypes of public functions related to user interaction
00099  */
00100 
00101 int rohc_c_is_enabled(struct rohc_comp *comp);
00102 int rohc_c_using_small_cid(struct rohc_comp *comp);
00103 
00104 void rohc_activate_profile(struct rohc_comp *comp, int profile);
00105 
00106 void rohc_c_set_header(struct rohc_comp *compressor, int value);
00107 void rohc_c_set_mrru(struct rohc_comp *compressor, int value);
00108 void rohc_c_set_max_cid(struct rohc_comp *compressor, int value);
00109 void rohc_c_set_large_cid(struct rohc_comp *compressor, int value);
00110 void rohc_c_set_enable(struct rohc_comp *compressor, int value);
00111 
00112 
00113 /*
00114  * Prototypes of public functions related to ROHC feedback
00115  */
00116 
00117 void c_piggyback_feedback(struct rohc_comp *comp, unsigned char *packet,
00118                           int size);
00119 void c_deliver_feedback(struct rohc_comp *comp, unsigned char *feedback,
00120                         int size);
00121 int rohc_feedback_flush(struct rohc_comp *comp,
00122                         unsigned char *obuf,
00123                         int osize);
00124 
00125 
00126 /*
00127  * Prototypes of public functions related to ROHC compression statistics
00128  */
00129 
00130 int rohc_c_info(char *buffer);
00131 int rohc_c_statistics(struct rohc_comp *comp, unsigned int indent,
00132                       char *buffer);
00133 int rohc_c_context(struct rohc_comp *comp, int cid, unsigned int indent,
00134                    char *buffer);
00135 int rohc_comp_get_last_packet_info(const struct rohc_comp *const comp,
00136                                    rohc_comp_last_packet_info_t *const info);
00137 const char * rohc_comp_get_state_descr(const rohc_c_state state);
00138 
00139 #endif
00140