ROHC compression/decompression library
|
00001 /* 00002 * Copyright 2007,2008 CNES 00003 * Copyright 2011,2012,2013 Didier Barvaux 00004 * Copyright 2007,2008 Thales Alenia Space 00005 * Copyright 2009,2010 Thales Communications 00006 * Copyright 2007,2009,2010,2012,2013 Viveris Technologies 00007 * Copyright 2012 WBX 00008 * 00009 * This library is free software; you can redistribute it and/or 00010 * modify it under the terms of the GNU Lesser General Public 00011 * License as published by the Free Software Foundation; either 00012 * version 2.1 of the License, or (at your option) any later version. 00013 * 00014 * This library is distributed in the hope that it will be useful, 00015 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00016 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00017 * Lesser General Public License for more details. 00018 * 00019 * You should have received a copy of the GNU Lesser General Public 00020 * License along with this library; if not, write to the Free Software 00021 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 00022 */ 00023 00024 /** 00025 * @file crc.h 00026 * @brief ROHC CRC routines 00027 * @author Didier Barvaux <didier.barvaux@toulouse.viveris.com> 00028 * @author Didier Barvaux <didier@barvaux.org> 00029 * @author FWX <rohc_team@dialine.fr> 00030 */ 00031 00032 #ifndef ROHC_COMMON_CRC_H 00033 #define ROHC_COMMON_CRC_H 00034 00035 #include "ip.h" 00036 #include "dllexport.h" 00037 00038 #ifdef __KERNEL__ 00039 # include <linux/types.h> 00040 #else 00041 # include <stdbool.h> 00042 #endif 00043 00044 /// The CRC-3 initial value 00045 #define CRC_INIT_3 0x7 00046 /// The CRC-7 initial value 00047 #define CRC_INIT_7 0x7f 00048 /// The CRC-8 initial value 00049 #define CRC_INIT_8 0xff 00050 00051 /** The FCS-32 initial value */ 00052 #define CRC_INIT_FCS32 0xffffffff 00053 /** The length (in bytes) of the FCS-32 CRC */ 00054 #define CRC_FCS32_LEN 4U 00055 00056 /** The different types of CRC used to protect ROHC headers */ 00057 typedef enum 00058 { 00059 ROHC_CRC_TYPE_NONE = 0, /**< No CRC selected */ 00060 ROHC_CRC_TYPE_3 = 3, /**< The CRC-3 type */ 00061 ROHC_CRC_TYPE_7 = 7, /**< The CRC-7 type */ 00062 ROHC_CRC_TYPE_8 = 8, /**< The CRC-8 type */ 00063 } rohc_crc_type_t; 00064 00065 00066 /* 00067 * Function prototypes. 00068 */ 00069 00070 bool ROHC_EXPORT rohc_crc_init_table(uint8_t *const table, 00071 const rohc_crc_type_t crc_type) 00072 __attribute__((nonnull(1), warn_unused_result)); 00073 00074 uint8_t ROHC_EXPORT crc_calculate(const rohc_crc_type_t crc_type, 00075 const uint8_t *const data, 00076 const size_t length, 00077 const uint8_t init_val, 00078 const uint8_t *const crc_table) 00079 __attribute__((nonnull(2, 5), warn_unused_result)); 00080 00081 uint32_t ROHC_EXPORT crc_calc_fcs32(const uint8_t *const data, 00082 const size_t length, 00083 const uint32_t init_val) 00084 __attribute__((nonnull(1), warn_unused_result)); 00085 00086 uint8_t ROHC_EXPORT compute_crc_static(const uint8_t *const ip, 00087 const uint8_t *const ip2, 00088 const uint8_t *const next_header, 00089 const rohc_crc_type_t crc_type, 00090 const uint8_t init_val, 00091 const uint8_t *const crc_table) 00092 __attribute__((nonnull(1, 6), warn_unused_result)); 00093 uint8_t ROHC_EXPORT compute_crc_dynamic(const uint8_t *const ip, 00094 const uint8_t *const ip2, 00095 const uint8_t *const next_header, 00096 const rohc_crc_type_t crc_type, 00097 const uint8_t init_val, 00098 const uint8_t *const crc_table) 00099 __attribute__((nonnull(1, 6), warn_unused_result)); 00100 00101 uint8_t ROHC_EXPORT udp_compute_crc_static(const uint8_t *const ip, 00102 const uint8_t *const ip2, 00103 const uint8_t *const next_header, 00104 const rohc_crc_type_t crc_type, 00105 const uint8_t init_val, 00106 const uint8_t *const crc_table) 00107 __attribute__((nonnull(1, 3, 6), warn_unused_result)); 00108 uint8_t ROHC_EXPORT udp_compute_crc_dynamic(const uint8_t *const ip, 00109 const uint8_t *const ip2, 00110 const uint8_t *const next_header, 00111 const rohc_crc_type_t crc_type, 00112 const uint8_t init_val, 00113 const uint8_t *const crc_table) 00114 __attribute__((nonnull(1, 3, 6), warn_unused_result)); 00115 00116 uint8_t ROHC_EXPORT esp_compute_crc_static(const uint8_t *const ip, 00117 const uint8_t *const ip2, 00118 const uint8_t *const next_header, 00119 const rohc_crc_type_t crc_type, 00120 const uint8_t init_val, 00121 const uint8_t *const crc_table) 00122 __attribute__((nonnull(1, 3, 6), warn_unused_result)); 00123 uint8_t ROHC_EXPORT esp_compute_crc_dynamic(const uint8_t *const ip, 00124 const uint8_t *const ip2, 00125 const uint8_t *const next_header, 00126 const rohc_crc_type_t crc_type, 00127 const uint8_t init_val, 00128 const uint8_t *const crc_table) 00129 __attribute__((nonnull(1, 3, 6), warn_unused_result)); 00130 00131 uint8_t ROHC_EXPORT rtp_compute_crc_static(const uint8_t *const ip, 00132 const uint8_t *const ip2, 00133 const uint8_t *const next_header, 00134 const rohc_crc_type_t crc_type, 00135 const uint8_t init_val, 00136 const uint8_t *const crc_table) 00137 __attribute__((nonnull(1, 3, 6), warn_unused_result)); 00138 uint8_t ROHC_EXPORT rtp_compute_crc_dynamic(const uint8_t *const ip, 00139 const uint8_t *const ip2, 00140 const uint8_t *const next_header, 00141 const rohc_crc_type_t crc_type, 00142 const uint8_t init_val, 00143 const uint8_t *const crc_table) 00144 __attribute__((nonnull(1, 3, 6), warn_unused_result)); 00145 00146 uint8_t ROHC_EXPORT tcp_compute_crc_static(const uint8_t *const ip, 00147 const uint8_t *const ip2, 00148 const uint8_t *const next_header, 00149 const rohc_crc_type_t crc_type, 00150 const uint8_t init_val, 00151 const uint8_t *const crc_table) 00152 __attribute__((nonnull(1, 3, 6), warn_unused_result)); 00153 uint8_t ROHC_EXPORT tcp_compute_crc_dynamic(const uint8_t *const ip, 00154 const uint8_t *const ip2, 00155 const uint8_t *const next_header, 00156 const rohc_crc_type_t crc_type, 00157 const uint8_t init_val, 00158 const uint8_t *const crc_table) 00159 __attribute__((nonnull(1, 3, 6), warn_unused_result)); 00160 00161 #endif 00162