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 crc.h 00019 * @brief ROHC CRC routines 00020 * @author Didier Barvaux <didier.barvaux@toulouse.viveris.com> 00021 * @author The hackers from ROHC for Linux 00022 * @author Didier Barvaux <didier@barvaux.org> 00023 * @author FWX <rohc_team@dialine.fr> 00024 */ 00025 00026 #ifndef CRC_H 00027 #define CRC_H 00028 00029 #include "ip.h" 00030 #include "dllexport.h" 00031 00032 #ifdef __KERNEL__ 00033 # include <linux/types.h> 00034 #else 00035 # include <stdbool.h> 00036 #endif 00037 00038 /// The CRC-2 initial value 00039 #define CRC_INIT_2 0x3 00040 /// The CRC-3 initial value 00041 #define CRC_INIT_3 0x7 00042 /// The CRC-6 initial value 00043 #define CRC_INIT_6 0x3f 00044 /// The CRC-7 initial value 00045 #define CRC_INIT_7 0x7f 00046 /// The CRC-8 initial value 00047 #define CRC_INIT_8 0xff 00048 00049 /** The FCS-32 initial value */ 00050 #define CRC_INIT_FCS32 0xffffffff 00051 /** The length (in bytes) of the FCS-32 CRC */ 00052 #define CRC_FCS32_LEN 4U 00053 00054 /** The different types of CRC used to protect ROHC headers */ 00055 typedef enum 00056 { 00057 ROHC_CRC_TYPE_NONE = 0, /**< No CRC selected */ 00058 ROHC_CRC_TYPE_2 = 2, /**< The CRC-2 type */ 00059 ROHC_CRC_TYPE_3 = 3, /**< The CRC-3 type */ 00060 ROHC_CRC_TYPE_6 = 6, /**< The CRC-6 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(unsigned char *const table, 00071 const rohc_crc_type_t crc_type) 00072 __attribute__((nonnull(1), warn_unused_result)); 00073 00074 unsigned int ROHC_EXPORT crc_calculate(const rohc_crc_type_t crc_type, 00075 const unsigned char *const data, 00076 const size_t length, 00077 const unsigned char init_val, 00078 const unsigned char *const crc_table) 00079 __attribute__((nonnull(2, 5))); 00080 00081 uint32_t ROHC_EXPORT crc_calc_fcs32(const unsigned char *const data, 00082 const size_t length, 00083 const uint32_t init_val) 00084 __attribute__((nonnull(1))); 00085 00086 unsigned int ROHC_EXPORT compute_crc_static(const unsigned char *const ip, 00087 const unsigned char *const ip2, 00088 const unsigned char *const next_header, 00089 const rohc_crc_type_t crc_type, 00090 const unsigned int init_val, 00091 const unsigned char *const crc_table) 00092 __attribute__((nonnull(1, 6))); 00093 unsigned int ROHC_EXPORT compute_crc_dynamic(const unsigned char *const ip, 00094 const unsigned char *const ip2, 00095 const unsigned char *const next_header, 00096 const rohc_crc_type_t crc_type, 00097 const unsigned int init_val, 00098 const unsigned char *const crc_table) 00099 __attribute__((nonnull(1, 6))); 00100 00101 unsigned int ROHC_EXPORT udp_compute_crc_static(const unsigned char *const ip, 00102 const unsigned char *const ip2, 00103 const unsigned char *const next_header, 00104 const rohc_crc_type_t crc_type, 00105 const unsigned int init_val, 00106 const unsigned char *const crc_table) 00107 __attribute__((nonnull(1, 3, 6))); 00108 unsigned int ROHC_EXPORT udp_compute_crc_dynamic(const unsigned char *const ip, 00109 const unsigned char *const ip2, 00110 const unsigned char *const next_header, 00111 const rohc_crc_type_t crc_type, 00112 const unsigned int init_val, 00113 const unsigned char *const crc_table) 00114 __attribute__((nonnull(1, 3, 6))); 00115 00116 unsigned int ROHC_EXPORT esp_compute_crc_static(const unsigned char *const ip, 00117 const unsigned char *const ip2, 00118 const unsigned char *const next_header, 00119 const rohc_crc_type_t crc_type, 00120 const unsigned int init_val, 00121 const unsigned char *const crc_table) 00122 __attribute__((nonnull(1, 3, 6))); 00123 unsigned int ROHC_EXPORT esp_compute_crc_dynamic(const unsigned char *const ip, 00124 const unsigned char *const ip2, 00125 const unsigned char *const next_header, 00126 const rohc_crc_type_t crc_type, 00127 const unsigned int init_val, 00128 const unsigned char *const crc_table) 00129 __attribute__((nonnull(1, 3, 6))); 00130 00131 unsigned int ROHC_EXPORT rtp_compute_crc_static(const unsigned char *const ip, 00132 const unsigned char *const ip2, 00133 const unsigned char *const next_header, 00134 const rohc_crc_type_t crc_type, 00135 const unsigned int init_val, 00136 const unsigned char *const crc_table) 00137 __attribute__((nonnull(1, 3, 6))); 00138 unsigned int ROHC_EXPORT rtp_compute_crc_dynamic(const unsigned char *const ip, 00139 const unsigned char *const ip2, 00140 const unsigned char *const next_header, 00141 const rohc_crc_type_t crc_type, 00142 const unsigned int init_val, 00143 const unsigned char *const crc_table) 00144 __attribute__((nonnull(1, 3, 6))); 00145 00146 #endif 00147