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 /// Header version 00035 typedef enum 00036 { 00037 HBH = ROHC_IPPROTO_HOPOPTS, /**< Hop by hop header */ 00038 RTHDR = ROHC_IPPROTO_ROUTING, /**< Routing header */ 00039 AH = ROHC_IPPROTO_AH, /**< AH header */ 00040 DEST = ROHC_IPPROTO_DSTOPTS, /**< Destination header */ 00041 /* CSRC lists not supported yet */ 00042 } ext_header_version; 00043 00044 00045 /** 00046 * @brief A list item 00047 */ 00048 struct rohc_list_item 00049 { 00050 /// item type 00051 ext_header_version type; 00052 /// size of the data in bytes 00053 size_t length; 00054 /// item data 00055 unsigned char *data; 00056 }; 00057 00058 00059 /** 00060 * @brief Define a generic element in a compression list 00061 */ 00062 struct list_elt 00063 { 00064 /// element 00065 struct rohc_list_item *item; 00066 /// index 00067 int index_table; 00068 /// next element of the list 00069 struct list_elt *next_elt; 00070 /// previous element 00071 struct list_elt *prev_elt; 00072 }; 00073 00074 00075 /** 00076 * @brief Define a list for compression 00077 */ 00078 struct c_list 00079 { 00080 ///generation identifier 00081 int gen_id; 00082 /// first element of the list 00083 struct list_elt *first_elt; 00084 }; 00085 00086 00087 /** 00088 * @brief Define a compression translation table element 00089 */ 00090 struct c_translation 00091 { 00092 /// flag which indicates the mapping between an item with its index 00093 /// 1 if the mapping is established, 0 if not 00094 int known; 00095 /// item 00096 struct rohc_list_item *item; 00097 /// counter 00098 int counter; 00099 }; 00100 00101 00102 /** 00103 * @brief Define a decompression translation table element 00104 */ 00105 struct d_translation 00106 { 00107 /// flag which indicates the mapping between an item with its index 00108 /// 1 if the mapping is established, 0 if not 00109 int known; 00110 /// item 00111 struct rohc_list_item *item; 00112 }; 00113 00114 00115 /** 00116 * Functions prototypes 00117 */ 00118 00119 /* create, destroy list */ 00120 int ROHC_EXPORT list_create(struct c_list *list); 00121 void ROHC_EXPORT list_destroy(struct c_list *list); 00122 00123 /* add elements */ 00124 int ROHC_EXPORT list_add_at_beginning(struct c_list *list, 00125 struct rohc_list_item *item, 00126 int index); 00127 int ROHC_EXPORT list_add_at_end(struct c_list *list, 00128 struct rohc_list_item *item, 00129 int index); 00130 int ROHC_EXPORT list_add_at_index(struct c_list *list, 00131 struct rohc_list_item *item, 00132 int index, 00133 int index_table); 00134 00135 /* get an element from its position or the position from the element */ 00136 struct list_elt * ROHC_EXPORT list_get_elt_by_index(struct c_list *list, 00137 int index); 00138 int ROHC_EXPORT list_get_index_by_elt(struct c_list *list, 00139 struct rohc_list_item *item); 00140 00141 /* remove an element or empty the list */ 00142 void ROHC_EXPORT list_remove(struct c_list *list, 00143 struct rohc_list_item *item); 00144 void ROHC_EXPORT list_empty(struct c_list *list); 00145 00146 /* retrieve information about an element of the list */ 00147 int ROHC_EXPORT list_type_is_present(struct c_list *list, 00148 struct rohc_list_item *item); 00149 00150 /* get the size of the list */ 00151 size_t ROHC_EXPORT list_get_size(const struct c_list *const list); 00152 00153 #endif 00154