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 #include <stdbool.h> 00033 00034 /// The CRC-2 initial value 00035 #define CRC_INIT_2 0x3 00036 /// The CRC-3 initial value 00037 #define CRC_INIT_3 0x7 00038 /// The CRC-6 initial value 00039 #define CRC_INIT_6 0x3f 00040 /// The CRC-7 initial value 00041 #define CRC_INIT_7 0x7f 00042 /// The CRC-8 initial value 00043 #define CRC_INIT_8 0xff 00044 00045 00046 /** The different types of CRC used to protect ROHC headers */ 00047 typedef enum 00048 { 00049 ROHC_CRC_TYPE_NONE = 0, /**< No CRC selected */ 00050 ROHC_CRC_TYPE_2 = 2, /**< The CRC-2 type */ 00051 ROHC_CRC_TYPE_3 = 3, /**< The CRC-3 type */ 00052 ROHC_CRC_TYPE_6 = 6, /**< The CRC-6 type */ 00053 ROHC_CRC_TYPE_7 = 7, /**< The CRC-7 type */ 00054 ROHC_CRC_TYPE_8 = 8, /**< The CRC-8 type */ 00055 } rohc_crc_type_t; 00056 00057 00058 /* 00059 * Function prototypes. 00060 */ 00061 00062 bool ROHC_EXPORT rohc_crc_init_table(unsigned char *const table, 00063 const rohc_crc_type_t crc_type) 00064 __attribute__((nonnull(1), warn_unused_result)); 00065 00066 unsigned int ROHC_EXPORT crc_calculate(const rohc_crc_type_t crc_type, 00067 const unsigned char *const data, 00068 const int length, 00069 const unsigned int init_val, 00070 const unsigned char *const crc_table) 00071 __attribute__((nonnull(2, 5))); 00072 00073 unsigned int ROHC_EXPORT compute_crc_static(const unsigned char *const ip, 00074 const unsigned char *const ip2, 00075 const unsigned char *const next_header, 00076 const rohc_crc_type_t crc_type, 00077 const unsigned int init_val, 00078 const unsigned char *const crc_table) 00079 __attribute__((nonnull(1, 6))); 00080 unsigned int ROHC_EXPORT compute_crc_dynamic(const unsigned char *const ip, 00081 const unsigned char *const ip2, 00082 const unsigned char *const next_header, 00083 const rohc_crc_type_t crc_type, 00084 const unsigned int init_val, 00085 const unsigned char *const crc_table) 00086 __attribute__((nonnull(1, 6))); 00087 00088 unsigned int ROHC_EXPORT udp_compute_crc_static(const unsigned char *const ip, 00089 const unsigned char *const ip2, 00090 const unsigned char *const next_header, 00091 const rohc_crc_type_t crc_type, 00092 const unsigned int init_val, 00093 const unsigned char *const crc_table) 00094 __attribute__((nonnull(1, 3, 6))); 00095 unsigned int ROHC_EXPORT udp_compute_crc_dynamic(const unsigned char *const ip, 00096 const unsigned char *const ip2, 00097 const unsigned char *const next_header, 00098 const rohc_crc_type_t crc_type, 00099 const unsigned int init_val, 00100 const unsigned char *const crc_table) 00101 __attribute__((nonnull(1, 3, 6))); 00102 00103 unsigned int ROHC_EXPORT esp_compute_crc_static(const unsigned char *const ip, 00104 const unsigned char *const ip2, 00105 const unsigned char *const next_header, 00106 const rohc_crc_type_t crc_type, 00107 const unsigned int init_val, 00108 const unsigned char *const crc_table) 00109 __attribute__((nonnull(1, 3, 6))); 00110 unsigned int ROHC_EXPORT esp_compute_crc_dynamic(const unsigned char *const ip, 00111 const unsigned char *const ip2, 00112 const unsigned char *const next_header, 00113 const rohc_crc_type_t crc_type, 00114 const unsigned int init_val, 00115 const unsigned char *const crc_table) 00116 __attribute__((nonnull(1, 3, 6))); 00117 00118 unsigned int ROHC_EXPORT rtp_compute_crc_static(const unsigned char *const ip, 00119 const unsigned char *const ip2, 00120 const unsigned char *const next_header, 00121 const rohc_crc_type_t crc_type, 00122 const unsigned int init_val, 00123 const unsigned char *const crc_table) 00124 __attribute__((nonnull(1, 3, 6))); 00125 unsigned int ROHC_EXPORT rtp_compute_crc_dynamic(const unsigned char *const ip, 00126 const unsigned char *const ip2, 00127 const unsigned char *const next_header, 00128 const rohc_crc_type_t crc_type, 00129 const unsigned int init_val, 00130 const unsigned char *const crc_table) 00131 __attribute__((nonnull(1, 3, 6))); 00132 00133 #endif 00134