ROHC compression/decompression library
|
00001 /* 00002 * Copyright 2013 Didier Barvaux 00003 * Copyright 2007,2008 Thales Alenia Space 00004 * 00005 * This library is free software; you can redistribute it and/or 00006 * modify it under the terms of the GNU Lesser General Public 00007 * License as published by the Free Software Foundation; either 00008 * version 2.1 of the License, or (at your option) any later version. 00009 * 00010 * This library is distributed in the hope that it will be useful, 00011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00013 * Lesser General Public License for more details. 00014 * 00015 * You should have received a copy of the GNU Lesser General Public 00016 * License along with this library; if not, write to the Free Software 00017 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 00018 */ 00019 00020 /** 00021 * @file decomp/schemes/list.h 00022 * @brief ROHC generic list decompression 00023 * @author Didier Barvaux <didier@barvaux.org> 00024 */ 00025 00026 #ifndef ROHC_DECOMP_LIST_H 00027 #define ROHC_DECOMP_LIST_H 00028 00029 #include "comp_list.h" 00030 #include "rohc_traces_internal.h" 00031 00032 00033 /** Print a warning trace for the given decompression list */ 00034 #define rd_list_warn(decomp_list, format, ...) \ 00035 rohc_warning(decomp_list, ROHC_TRACE_DECOMP, (decomp_list)->profile_id, \ 00036 format, ##__VA_ARGS__) 00037 00038 /** Print a debug trace for the given decompression list */ 00039 #define rd_list_debug(decomp_list, format, ...) \ 00040 rohc_debug(decomp_list, ROHC_TRACE_DECOMP, (decomp_list)->profile_id, \ 00041 format, ##__VA_ARGS__) 00042 00043 00044 /** 00045 * @brief The context for list decompression 00046 * 00047 * The context contains a translation table that associates IDs and list 00048 * items together. The different lists (gen_id ones, reference one, anonymous 00049 * one) references the items from the translation table. 00050 */ 00051 struct list_decomp 00052 { 00053 /** The translation table */ 00054 struct rohc_list_item trans_table[ROHC_LIST_MAX_ITEM]; 00055 00056 /** All the possible named lists, indexed by gen_id */ 00057 struct rohc_list lists[ROHC_LIST_GEN_ID_MAX + 1]; 00058 00059 /** The temporary packet list (not persistent accross packets) */ 00060 struct rohc_list pkt_list; 00061 00062 00063 /* Functions for handling the data to decompress */ 00064 00065 /** The handler used to check if the index corresponds to a valid item */ 00066 bool (*check_item)(const struct list_decomp *const decomp, 00067 const size_t index_table); 00068 00069 /** The handler used to get the size of a list item */ 00070 int (*get_item_size)(const unsigned char *data, const size_t data_len); 00071 00072 /** The handler used to compare two items */ 00073 rohc_list_item_cmp cmp_item; 00074 00075 /** The handler used to create a list item */ 00076 bool (*create_item)(const unsigned char *const data, 00077 const size_t length, 00078 const size_t index_table, 00079 struct list_decomp *const decomp); 00080 00081 /** The handler used to add the extension to IP packet */ 00082 size_t (*build_uncomp_item)(const struct list_decomp *const decomp, 00083 const uint8_t ip_nh_type, 00084 unsigned char *const dest); 00085 00086 00087 /* Traces */ 00088 00089 #if !defined(ROHC_ENABLE_DEPRECATED_API) || ROHC_ENABLE_DEPRECATED_API == 1 00090 /** The old callback function used to manage traces */ 00091 rohc_trace_callback_t trace_callback; 00092 #endif 00093 /** The new callback function used to manage traces */ 00094 rohc_trace_callback2_t trace_callback2; 00095 /** The private context of the callback function used to manage traces */ 00096 void *trace_callback_priv; 00097 /** The profile ID the decompression list was created for */ 00098 int profile_id; 00099 }; 00100 00101 00102 00103 /* 00104 * Generic list decompression 00105 */ 00106 00107 int ROHC_EXPORT rohc_list_decode_maybe(struct list_decomp *const decomp, 00108 const unsigned char *const packet, 00109 const size_t packet_len) 00110 __attribute__((warn_unused_result, nonnull(1, 2))); 00111 00112 bool ROHC_EXPORT rohc_decomp_list_create_item(struct list_decomp *const decomp, 00113 00114 const unsigned int xi_index, 00115 const unsigned int xi_index_value, 00116 const uint8_t *const rohc_packet, 00117 const size_t rohc_max_len, 00118 size_t *const item_length) 00119 __attribute__((warn_unused_result, nonnull(1, 4, 6))); 00120 00121 #endif 00122