P4C
The P4 Compiler
Loading...
Searching...
No Matches
nethash.h
1#ifndef LIB_NETHASH_H_
2#define LIB_NETHASH_H_
3
4#include <cstddef>
5#include <cstdint>
6#include <vector>
7
9namespace P4::NetHash {
10
12uint16_t crc16(const uint8_t *buf, size_t len);
13
16uint16_t crc16ANSI(const uint8_t *buf, size_t len);
17
19uint16_t crcCCITT(const uint8_t *buf, size_t len);
20
23uint32_t crc32(const uint8_t *buf, size_t len);
24
27uint32_t crc32FCS(const uint8_t *buf, size_t len);
28
30uint16_t csum16(const uint8_t *buf, size_t len);
31
33uint16_t xor16(const uint8_t *buf, size_t len);
34
36uint64_t identity(const uint8_t *buf, size_t len);
37
38} // namespace P4::NetHash
39
40#endif /* LIB_NETHASH_H_ */
A collection of hashing functions commonly used in network protocols.
Definition nethash.cpp:32
uint64_t identity(const uint8_t *buf, size_t len)
Identity hash – the first (up to) 64bits of the values (i.e. indexes 0 to 7).
Definition nethash.cpp:242
uint32_t crc32(const uint8_t *buf, size_t len)
Definition nethash.cpp:166
uint16_t crcCCITT(const uint8_t *buf, size_t len)
CRC16-CCITT (parameters: NO bit-reflection, polynomial 0x1021, init = ~0 and xor_out = 0).
Definition nethash.cpp:174
uint16_t csum16(const uint8_t *buf, size_t len)
16-bit ones' complement checksum (used in IP, TCP, UDP, ...).
Definition nethash.cpp:178
uint32_t crc32FCS(const uint8_t *buf, size_t len)
Definition nethash.cpp:170
uint16_t xor16(const uint8_t *buf, size_t len)
A 16-bit xor of the values.
Definition nethash.cpp:222
uint16_t crc16ANSI(const uint8_t *buf, size_t len)
Definition nethash.cpp:162
uint16_t crc16(const uint8_t *buf, size_t len)
CRC-16 used in BMv2 (parameters: bit-reflection, polynomial 0x8005, init = 0 and xor_out = 0).
Definition nethash.cpp:158