ROHC compression/decompression library
|
00001 /* 00002 * Copyright 2011,2012,2013 Didier Barvaux 00003 * Copyright 2007,2009,2010,2013 Viveris Technologies 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 sdvl.h 00022 * @brief Self-Describing Variable-Length (SDVL) encoding 00023 * @author Didier Barvaux <didier.barvaux@toulouse.viveris.com> 00024 * @author Didier Barvaux <didier@barvaux.org> 00025 */ 00026 00027 #ifndef ROHC_COMMON_SDVL_H 00028 #define ROHC_COMMON_SDVL_H 00029 00030 #include "dllexport.h" 00031 00032 #include <stdlib.h> 00033 #include <stdint.h> 00034 #ifdef __KERNEL__ 00035 # include <linux/types.h> 00036 #else 00037 # include <stdbool.h> 00038 #endif 00039 00040 00041 /* 00042 * Constants related to fields length for SDVL-encoding 00043 */ 00044 00045 /** The maximum numbers of bits that can be SDVL-encoded in 1, 2, 3 00046 * and 4 bytes */ 00047 typedef enum 00048 { 00049 /** Maximum number of bits in 1 SDVL-encoded byte */ 00050 ROHC_SDVL_MAX_BITS_IN_1_BYTE = 7U, 00051 /** Maximum number of bits in 2 SDVL-encoded byte */ 00052 ROHC_SDVL_MAX_BITS_IN_2_BYTES = 14U, 00053 /** Maximum number of bits in 3 SDVL-encoded byte */ 00054 ROHC_SDVL_MAX_BITS_IN_3_BYTES = 21U, 00055 /** Maximum number of bits in 4 SDVL-encoded byte */ 00056 ROHC_SDVL_MAX_BITS_IN_4_BYTES = 29U, 00057 } rohc_sdvl_max_bits_t; 00058 00059 00060 /* 00061 * Function prototypes. 00062 */ 00063 00064 bool ROHC_EXPORT sdvl_can_value_be_encoded(const uint32_t value) 00065 __attribute__((warn_unused_result, const)); 00066 bool ROHC_EXPORT sdvl_can_length_be_encoded(const size_t bits_nr) 00067 __attribute__((warn_unused_result, const)); 00068 00069 size_t ROHC_EXPORT sdvl_get_min_len(const size_t nr_min_required, 00070 const size_t nr_encoded) 00071 __attribute__((warn_unused_result, const)); 00072 00073 size_t ROHC_EXPORT sdvl_get_encoded_len(const uint32_t value) 00074 __attribute__((warn_unused_result, const)); 00075 00076 bool ROHC_EXPORT sdvl_encode(uint8_t *const packet, 00077 const size_t packet_max_len, 00078 size_t *const packet_len, 00079 const uint32_t value, 00080 const size_t bits_nr) 00081 __attribute__((warn_unused_result, nonnull(1, 3))); 00082 00083 bool ROHC_EXPORT sdvl_encode_full(uint8_t *const packet, 00084 const size_t packet_max_len, 00085 size_t *const packet_len, 00086 const uint32_t value) 00087 __attribute__((warn_unused_result, nonnull(1, 3))); 00088 00089 size_t ROHC_EXPORT sdvl_decode(const uint8_t *const data, 00090 const size_t length, 00091 uint32_t *const value, 00092 size_t *const bits_nr) 00093 __attribute__((warn_unused_result, nonnull(1, 3, 4))); 00094 00095 #endif 00096