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 
00024 #ifndef CRC_H
00025 #define CRC_H
00026 
00027 #include "ip.h"
00028 
00030 #define CRC_TYPE_2 1
00031 
00032 #define CRC_TYPE_3 2
00033 
00034 #define CRC_TYPE_6 3
00035 
00036 #define CRC_TYPE_7 4
00037 
00038 #define CRC_TYPE_8 5
00039 
00041 #define CRC_INIT_2 0x3
00042 
00043 #define CRC_INIT_3 0x7
00044 
00045 #define CRC_INIT_6 0x3f
00046 
00047 #define CRC_INIT_7 0x7f
00048 
00049 #define CRC_INIT_8 0xff
00050 
00051 
00053 extern unsigned char crc_table_8[256];
00055 extern unsigned char crc_table_7[256];
00057 extern unsigned char crc_table_6[256];
00059 extern unsigned char crc_table_3[256];
00061 extern unsigned char crc_table_2[256];
00062 
00063 
00064 /*
00065  * Function prototypes.
00066  */
00067 
00068 unsigned int crc_calculate(int type,
00069                            unsigned char *data,
00070                            int length,
00071                            unsigned int init_val);
00072 
00073 int crc_get_polynom(int type);
00074 
00075 void crc_init_table(unsigned char *table, unsigned char polynum);
00076 
00077 unsigned int compute_crc_static(const unsigned char *ip,
00078                                 const unsigned char *ip2,
00079                                 const unsigned char *next_header,
00080                                 unsigned int crc_type,
00081                                 unsigned int init_val);
00082 unsigned int compute_crc_dynamic(const unsigned char *ip,
00083                                  const unsigned char *ip2,
00084                                  const unsigned char *next_header,
00085                                  unsigned int crc_type,
00086                                  unsigned int init_val);
00087 
00088 unsigned int udp_compute_crc_static(const unsigned char *ip,
00089                                     const unsigned char *ip2,
00090                                     const unsigned char *next_header,
00091                                     unsigned int crc_type,
00092                                     unsigned int init_val);
00093 unsigned int udp_compute_crc_dynamic(const unsigned char *ip,
00094                                      const unsigned char *ip2,
00095                                      const unsigned char *next_header,
00096                                      unsigned int crc_type,
00097                                      unsigned int init_val);
00098 
00099 
00100 unsigned int rtp_compute_crc_static(const unsigned char *ip,
00101                                     const unsigned char *ip2,
00102                                     const unsigned char *next_header,
00103                                     unsigned int crc_type,
00104                                     unsigned int init_val);
00105 unsigned int rtp_compute_crc_dynamic(const unsigned char *ip,
00106                                      const unsigned char *ip2,
00107                                      const unsigned char *next_header,
00108                                      unsigned int crc_type,
00109                                      unsigned int init_val);
00110 
00111 unsigned int ipv6_ext_compute_crc_static(const unsigned char *ip,
00112                                          unsigned int crc_type,
00113                                          unsigned int init_val);
00114 unsigned int ipv6_ext_compute_crc_dynamic(const unsigned char *ip,
00115                                           unsigned int crc_type,
00116                                           unsigned int init_val);
00117 
00118 #endif
00119