2019-09-12 00:41:57 +02:00
|
|
|
/* -*- c++ -*- */
|
|
|
|
/*
|
|
|
|
* gr-satnogs: SatNOGS GNU Radio Out-Of-Tree Module
|
|
|
|
*
|
|
|
|
* Copyright (C) 2019, Libre Space Foundation <http://libre.space>
|
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef INCLUDED_SATNOGS_CRC_H
|
|
|
|
#define INCLUDED_SATNOGS_CRC_H
|
|
|
|
|
|
|
|
#include <satnogs/api.h>
|
|
|
|
|
2019-09-12 15:25:10 +02:00
|
|
|
namespace gr {
|
|
|
|
namespace satnogs {
|
2019-09-12 00:41:57 +02:00
|
|
|
|
|
|
|
/*!
|
|
|
|
* CRC class providing a range of different CRC calculation static methods
|
|
|
|
*
|
|
|
|
*/
|
2019-09-12 15:25:10 +02:00
|
|
|
class SATNOGS_API crc {
|
2019-09-12 00:41:57 +02:00
|
|
|
public:
|
|
|
|
typedef enum crc_type {
|
2019-09-12 18:45:45 +02:00
|
|
|
CRC_NONE = 0,
|
|
|
|
CRC16_CCITT,
|
|
|
|
CRC16_CCITT_REVERSED,
|
|
|
|
CRC16_AX25,
|
|
|
|
CRC16_IBM,
|
2019-09-16 14:15:51 +02:00
|
|
|
CRC32_C,
|
2019-09-12 18:45:45 +02:00
|
|
|
CRC_METHODS_NUM
|
2019-09-12 00:41:57 +02:00
|
|
|
} crc_t;
|
|
|
|
|
|
|
|
static uint16_t
|
|
|
|
crc16_ccitt_reversed(const uint8_t *data, size_t len);
|
|
|
|
|
|
|
|
static uint16_t
|
|
|
|
crc16_ccitt(const uint8_t *data, size_t len);
|
|
|
|
|
|
|
|
static uint16_t
|
|
|
|
crc16_ax25(const uint8_t *data, size_t len);
|
|
|
|
|
|
|
|
static uint16_t
|
|
|
|
crc16_ibm(const uint8_t *data, size_t len);
|
|
|
|
|
2019-09-16 14:15:51 +02:00
|
|
|
static uint32_t
|
|
|
|
crc32_c(const uint8_t *data, size_t len);
|
|
|
|
|
2019-09-12 18:45:45 +02:00
|
|
|
static size_t
|
|
|
|
crc_size(crc_t t);
|
|
|
|
|
2019-09-12 00:41:57 +02:00
|
|
|
private:
|
|
|
|
static const uint16_t crc16_ccitt_table_reverse[256];
|
|
|
|
static const uint16_t crc16_ccitt_table[256];
|
2019-09-16 14:15:51 +02:00
|
|
|
static const uint32_t crc32_c_table[256];
|
2019-09-12 00:41:57 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace satnogs
|
|
|
|
} // namespace gr
|
|
|
|
|
|
|
|
#endif /* INCLUDED_SATNOGS_CRC_H */
|
|
|
|
|