Mercurial > hg > audiostuff
comparison spandsp-0.0.6pre17/src/spandsp/crc.h @ 4:26cd8f1ef0b1
import spandsp-0.0.6pre17
| author | Peter Meerwald <pmeerw@cosy.sbg.ac.at> |
|---|---|
| date | Fri, 25 Jun 2010 15:50:58 +0200 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| 3:c6c5a16ce2f2 | 4:26cd8f1ef0b1 |
|---|---|
| 1 /* | |
| 2 * SpanDSP - a series of DSP components for telephony | |
| 3 * | |
| 4 * crc.h | |
| 5 * | |
| 6 * Written by Steve Underwood <steveu@coppice.org> | |
| 7 * | |
| 8 * Copyright (C) 2003 Steve Underwood | |
| 9 * | |
| 10 * All rights reserved. | |
| 11 * | |
| 12 * This program is free software; you can redistribute it and/or modify | |
| 13 * it under the terms of the GNU Lesser General Public License version 2.1, | |
| 14 * as published by the Free Software Foundation. | |
| 15 * | |
| 16 * This program is distributed in the hope that it will be useful, | |
| 17 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 19 * GNU Lesser General Public License for more details. | |
| 20 * | |
| 21 * You should have received a copy of the GNU Lesser General Public | |
| 22 * License along with this program; if not, write to the Free Software | |
| 23 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | |
| 24 * | |
| 25 * $Id: crc.h,v 1.5 2009/01/31 08:48:11 steveu Exp $ | |
| 26 */ | |
| 27 | |
| 28 /*! \file */ | |
| 29 | |
| 30 /*! \page crc_page CRC | |
| 31 | |
| 32 \section crc_page_sec_1 What does it do? | |
| 33 | |
| 34 \section crc_page_sec_2 How does it work? | |
| 35 */ | |
| 36 | |
| 37 #if !defined(_SPANDSP_CRC_H_) | |
| 38 #define _SPANDSP_CRC_H_ | |
| 39 | |
| 40 #if defined(__cplusplus) | |
| 41 extern "C" | |
| 42 { | |
| 43 #endif | |
| 44 | |
| 45 /*! \brief Calculate the ITU/CCITT CRC-32 value in buffer. | |
| 46 \param buf The buffer containing the data. | |
| 47 \param len The length of the frame. | |
| 48 \param crc The initial CRC value. This is usually 0xFFFFFFFF, or 0 for a new block (it depends on | |
| 49 the application). It is previous returned CRC value for the continuation of a block. | |
| 50 \return The CRC value. | |
| 51 */ | |
| 52 SPAN_DECLARE(uint32_t) crc_itu32_calc(const uint8_t *buf, int len, uint32_t crc); | |
| 53 | |
| 54 /*! \brief Append an ITU/CCITT CRC-32 value to a frame. | |
| 55 \param buf The buffer containing the frame. This must be at least 2 bytes longer than | |
| 56 the frame it contains, to allow room for the CRC value. | |
| 57 \param len The length of the frame. | |
| 58 \return The new length of the frame. | |
| 59 */ | |
| 60 SPAN_DECLARE(int) crc_itu32_append(uint8_t *buf, int len); | |
| 61 | |
| 62 /*! \brief Check the ITU/CCITT CRC-32 value in a frame. | |
| 63 \param buf The buffer containing the frame. | |
| 64 \param len The length of the frame. | |
| 65 \return TRUE if the CRC is OK, else FALSE. | |
| 66 */ | |
| 67 SPAN_DECLARE(int) crc_itu32_check(const uint8_t *buf, int len); | |
| 68 | |
| 69 /*! \brief Calculate the ITU/CCITT CRC-16 value in buffer. | |
| 70 \param buf The buffer containing the data. | |
| 71 \param len The length of the frame. | |
| 72 \param crc The initial CRC value. This is usually 0xFFFF, or 0 for a new block (it depends on | |
| 73 the application). It is previous returned CRC value for the continuation of a block. | |
| 74 \return The CRC value. | |
| 75 */ | |
| 76 SPAN_DECLARE(uint16_t) crc_itu16_calc(const uint8_t *buf, int len, uint16_t crc); | |
| 77 | |
| 78 /*! \brief Append an ITU/CCITT CRC-16 value to a frame. | |
| 79 \param buf The buffer containing the frame. This must be at least 2 bytes longer than | |
| 80 the frame it contains, to allow room for the CRC value. | |
| 81 \param len The length of the frame. | |
| 82 \return The new length of the frame. | |
| 83 */ | |
| 84 SPAN_DECLARE(int) crc_itu16_append(uint8_t *buf, int len); | |
| 85 | |
| 86 /*! \brief Check the ITU/CCITT CRC-16 value in a frame. | |
| 87 \param buf The buffer containing the frame. | |
| 88 \param len The length of the frame. | |
| 89 \return TRUE if the CRC is OK, else FALSE. | |
| 90 */ | |
| 91 SPAN_DECLARE(int) crc_itu16_check(const uint8_t *buf, int len); | |
| 92 | |
| 93 #if defined(__cplusplus) | |
| 94 } | |
| 95 #endif | |
| 96 | |
| 97 #endif | |
| 98 /*- End of file ------------------------------------------------------------*/ |
