-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathCRC16Bit.hpp
More file actions
33 lines (29 loc) · 866 Bytes
/
CRC16Bit.hpp
File metadata and controls
33 lines (29 loc) · 866 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#ifndef CRC16BIT_HPP_INCLUDED
#define CRC16BIT_HPP_INCLUDED
#include <cstdint>
#include "Packet.hpp"
#include "VerificationAlgorithm.hpp"
typedef uint16_t (*crcfn16)(uint16_t, const void *, const uint64_t, uint16_t);
class CRC16Bit: public VerificationAlgorithm {
private:
uint16_t crc16;
bool isInit;
uint16_t crc16_table[8][256] = {{0}};
void crcspeed16little_init(crcfn16 crcfn, uint16_t table[8][256]);
uint16_t crc16_lookup(uint16_t crc, const void *in_data, uint64_t len);
public:
public:
CRC16Bit(uint16_t crc16_){
crc16 = crc16_;
isInit = false;
}
bool verifyCRC(Packet* packet, uint16_t chk);
uint16_t doCRC(Packet* packet);
uint32_t generateVerificationCode(Packet* packet){
return (uint32_t) doCRC(packet);
}
std::string getAlgName(){
return "CRC16";
}
};
#endif