GNU Radio's SATNOGS Package
crc.h
Go to the documentation of this file.
1 /* -*- c++ -*- */
2 /*
3  * gr-satnogs: SatNOGS GNU Radio Out-Of-Tree Module
4  *
5  * Copyright (C) 2019, 2020 Libre Space Foundation <http://libre.space>
6  *
7  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program. If not, see <http://www.gnu.org/licenses/>.
19  */
20 
21 #ifndef INCLUDED_SATNOGS_CRC_H
22 #define INCLUDED_SATNOGS_CRC_H
23 
24 #include <satnogs/api.h>
25 
26 namespace gr {
27 namespace satnogs {
28 
29 /*!
30  * CRC class providing a range of different CRC calculation static methods
31  *
32  */
34 public:
35  typedef enum crc_type {
36  CRC_NONE = 0,
43  CRC_METHODS_NUM
44  } crc_t;
45 
46  static uint16_t
47  crc16_ccitt_reversed(const uint8_t *data, size_t len);
48 
49  static uint16_t
50  crc16_ccitt(const uint8_t *data, size_t len);
51 
52  static uint16_t
53  crc16_aug_ccitt(const uint8_t *data, size_t len);
54 
55  static uint16_t
56  crc16_ax25(const uint8_t *data, size_t len);
57 
58  static uint16_t
59  crc16_ibm(const uint8_t *data, size_t len);
60 
61  static uint32_t
62  crc32_c(const uint8_t *data, size_t len);
63 
64  static size_t
65  crc_size(crc_t t);
66 
67  static size_t
68  append(crc_t t, uint8_t *out, const uint8_t *data, size_t len, bool nbo = true);
69 
70  static bool
71  check(crc_t t, const uint8_t *data, size_t len, bool nbo = true);
72 
73 private:
74  static const uint16_t crc16_ccitt_table_reverse[256];
75  static const uint16_t crc16_ccitt_table[256];
76  static const uint32_t crc32_c_table[256];
77 };
78 
79 } // namespace satnogs
80 } // namespace gr
81 
82 #endif /* INCLUDED_SATNOGS_CRC_H */
data_t t[NROOTS+1]
Definition: decode_rs.h:77
Definition: crc.h:41
Definition: amsat_duv_decoder.h:29
enum gr::satnogs::crc::crc_type crc_t
crc_type
Definition: crc.h:35
Definition: crc.h:40
Definition: crc.h:37
Definition: crc.h:33
Definition: crc.h:42
#define SATNOGS_API
Definition: api.h:30