ROHC compression/decompression library
crc.h
Go to the documentation of this file.
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  */
00024 
00025 #ifndef CRC_H
00026 #define CRC_H
00027 
00028 #include "ip.h"
00029 
00030 #include <stdbool.h>
00031 
00032 /// The CRC-2 initial value
00033 #define CRC_INIT_2 0x3
00034 /// The CRC-3 initial value
00035 #define CRC_INIT_3 0x7
00036 /// The CRC-6 initial value
00037 #define CRC_INIT_6 0x3f
00038 /// The CRC-7 initial value
00039 #define CRC_INIT_7 0x7f
00040 /// The CRC-8 initial value
00041 #define CRC_INIT_8 0xff
00042 
00043 
00044 /*
00045  * Function prototypes.
00046  */
00047 
00048 bool rohc_crc_init_table(unsigned char *const table, const int crc_type)
00049         __attribute__((nonnull(1), warn_unused_result));
00050 
00051 unsigned int crc_calculate(const int crc_type,
00052                            const unsigned char *const data,
00053                            const int length,
00054                            const unsigned int init_val,
00055                            const unsigned char *const crc_table)
00056         __attribute__((nonnull(2, 5)));
00057 
00058 unsigned int compute_crc_static(const unsigned char *const ip,
00059                                 const unsigned char *const ip2,
00060                                 const unsigned char *const next_header,
00061                                 const unsigned int crc_type,
00062                                 const unsigned int init_val,
00063                                 const unsigned char *const crc_table)
00064         __attribute__((nonnull(1, 6)));
00065 unsigned int compute_crc_dynamic(const unsigned char *const ip,
00066                                  const unsigned char *const ip2,
00067                                  const unsigned char *const next_header,
00068                                  const unsigned int crc_type,
00069                                  const unsigned int init_val,
00070                                  const unsigned char *const crc_table)
00071         __attribute__((nonnull(1, 6)));
00072 
00073 unsigned int udp_compute_crc_static(const unsigned char *const ip,
00074                                     const unsigned char *const ip2,
00075                                     const unsigned char *const next_header,
00076                                     const unsigned int crc_type,
00077                                     const unsigned int init_val,
00078                                     const unsigned char *const crc_table)
00079         __attribute__((nonnull(1, 3, 6)));
00080 unsigned int udp_compute_crc_dynamic(const unsigned char *const ip,
00081                                      const unsigned char *const ip2,
00082                                      const unsigned char *const next_header,
00083                                      const unsigned int crc_type,
00084                                      const unsigned int init_val,
00085                                      const unsigned char *const crc_table)
00086         __attribute__((nonnull(1, 3, 6)));
00087 
00088 unsigned int rtp_compute_crc_static(const unsigned char *const ip,
00089                                     const unsigned char *const ip2,
00090                                     const unsigned char *const next_header,
00091                                     const unsigned int crc_type,
00092                                     const unsigned int init_val,
00093                                     const unsigned char *const crc_table)
00094         __attribute__((nonnull(1, 3, 6)));
00095 unsigned int rtp_compute_crc_dynamic(const unsigned char *const ip,
00096                                      const unsigned char *const ip2,
00097                                      const unsigned char *const next_header,
00098                                      const unsigned int 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 ipv6_ext_compute_crc_static(const unsigned char *const ip,
00104                                          const unsigned int crc_type,
00105                                          const unsigned int init_val,
00106                                          const unsigned char *const crc_table)
00107         __attribute__((nonnull(1, 4)));
00108 unsigned int ipv6_ext_compute_crc_dynamic(const unsigned char *const ip,
00109                                           const unsigned int crc_type,
00110                                           const unsigned int init_val,
00111                                           const unsigned char *const crc_table)
00112         __attribute__((nonnull(1, 4)));
00113 
00114 
00115 #endif
00116