ROHC compression/decompression library
|
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 comp_list.h 00019 * @brief Define list compression with its function 00020 * @author Emmanuelle Pechereau <epechereau@toulouse.viveris.com> 00021 * @author Didier Barvaux <didier@barvaux.org> 00022 */ 00023 00024 #ifndef COMP_LIST_H 00025 #define COMP_LIST_H 00026 00027 #include "dllexport.h" 00028 #include "protocols/ipv6.h" 00029 #include "protocols/ip_numbers.h" 00030 00031 #include <stdlib.h> 00032 00033 00034 /** Print a debug trace for the given compression list */ 00035 #define rc_list_debug(comp_list, format, ...) \ 00036 rohc_debug(comp_list, ROHC_TRACE_COMP, (comp_list)->profile_id, \ 00037 format, ##__VA_ARGS__) 00038 00039 /** Print a debug trace for the given decompression list */ 00040 #define rd_list_debug(decomp_list, format, ...) \ 00041 rohc_debug(decomp_list, ROHC_TRACE_DECOMP, (decomp_list)->profile_id, \ 00042 format, ##__VA_ARGS__) 00043 00044 00045 /// Header version 00046 typedef enum 00047 { 00048 HBH = ROHC_IPPROTO_HOPOPTS, /**< Hop by hop header */ 00049 RTHDR = ROHC_IPPROTO_ROUTING, /**< Routing header */ 00050 AH = ROHC_IPPROTO_AH, /**< AH header */ 00051 DEST = ROHC_IPPROTO_DSTOPTS, /**< Destination header */ 00052 /* CSRC lists not supported yet */ 00053 } ext_header_version; 00054 00055 00056 /** 00057 * @brief A list item 00058 */ 00059 struct rohc_list_item 00060 { 00061 /// item type 00062 ext_header_version type; 00063 /// size of the data in bytes 00064 size_t length; 00065 /// item data 00066 unsigned char *data; 00067 }; 00068 00069 00070 /** 00071 * @brief Define a generic element in a compression list 00072 */ 00073 struct list_elt 00074 { 00075 /// element 00076 struct rohc_list_item *item; 00077 /// index 00078 int index_table; 00079 /// next element of the list 00080 struct list_elt *next_elt; 00081 /// previous element 00082 struct list_elt *prev_elt; 00083 }; 00084 00085 00086 /** 00087 * @brief Define a list for compression 00088 */ 00089 struct c_list 00090 { 00091 ///generation identifier 00092 int gen_id; 00093 /// first element of the list 00094 struct list_elt *first_elt; 00095 }; 00096 00097 00098 /** 00099 * @brief Define a compression translation table element 00100 */ 00101 struct c_translation 00102 { 00103 /// flag which indicates the mapping between an item with its index 00104 /// 1 if the mapping is established, 0 if not 00105 int known; 00106 /// item 00107 struct rohc_list_item *item; 00108 /// counter 00109 int counter; 00110 }; 00111 00112 00113 /** 00114 * @brief Define a decompression translation table element 00115 */ 00116 struct d_translation 00117 { 00118 /// flag which indicates the mapping between an item with its index 00119 /// 1 if the mapping is established, 0 if not 00120 int known; 00121 /// item 00122 struct rohc_list_item *item; 00123 }; 00124 00125 00126 /** 00127 * Functions prototypes 00128 */ 00129 00130 /* create, destroy list */ 00131 struct c_list * ROHC_EXPORT list_create(void) 00132 __attribute__((warn_unused_result)); 00133 void ROHC_EXPORT list_destroy(struct c_list *list); 00134 00135 /* add elements */ 00136 int ROHC_EXPORT list_add_at_beginning(struct c_list *list, 00137 struct rohc_list_item *item, 00138 int index); 00139 int ROHC_EXPORT list_add_at_end(struct c_list *list, 00140 struct rohc_list_item *item, 00141 int index); 00142 int ROHC_EXPORT list_add_at_index(struct c_list *list, 00143 struct rohc_list_item *item, 00144 int index, 00145 int index_table); 00146 00147 /* get an element from its position or the position from the element */ 00148 struct list_elt * ROHC_EXPORT list_get_elt_by_index(struct c_list *list, 00149 int index); 00150 int ROHC_EXPORT list_get_index_by_elt(struct c_list *list, 00151 struct rohc_list_item *item); 00152 00153 /* remove an element or empty the list */ 00154 void ROHC_EXPORT list_remove(struct c_list *list, 00155 struct rohc_list_item *item); 00156 void ROHC_EXPORT rohc_list_empty(struct c_list *list); 00157 00158 /* retrieve information about an element of the list */ 00159 int ROHC_EXPORT list_type_is_present(struct c_list *list, 00160 struct rohc_list_item *item); 00161 00162 /* get the size of the list */ 00163 size_t ROHC_EXPORT list_get_size(const struct c_list *const list); 00164 00165 #endif 00166