NDN-DPDK
High-Speed Named Data Networking Forwarder
Loading...
Searching...
No Matches
siphash.h
Go to the documentation of this file.
1#ifndef NDNDPDK_CORE_SIPHASH_H
2#define NDNDPDK_CORE_SIPHASH_H
3
5
6#include "common.h"
7
8#include "../vendor/siphash-20201003.h"
9
11typedef struct sipkey SipHashKey;
12
13enum {
14 SipHashKeyLength = SIP_KEYLEN,
15};
16
17__attribute__((nonnull)) static inline void
18SipHashKey_FromBuffer(SipHashKey* key, const uint8_t buf[SipHashKeyLength]) {
19 sip_tokey(key, buf);
20}
21
23typedef struct siphash SipHash;
24
26__attribute__((nonnull)) static inline void
27SipHash_Init(SipHash* h, const SipHashKey* key) {
28 sip24_init(h, key);
29}
30
32__attribute__((nonnull)) static inline void
33SipHash_Write(SipHash* h, const uint8_t* input, size_t count) {
34 sip24_update(h, input, count);
35}
36
41__attribute__((nonnull)) static inline uint64_t
42SipHash_Final(SipHash* h) {
43 return sip24_final(h);
44}
45
50__attribute__((nonnull)) static inline uint64_t
51SipHash_Sum(const SipHash* h) {
52 SipHash copy = *h;
53 copy.p = RTE_PTR_ADD(copy.buf, RTE_PTR_DIFF(h->p, h->buf));
54 return sip24_final(&copy);
55}
56
57#undef _SIP_ULL
58#undef SIP_ROTL
59#undef SIP_U32TO8_LE
60#undef SIP_U64TO8_LE
61#undef SIP_U8TO64_LE
62#undef SIPHASH_INITIALIZER
63#undef sip_keyof
64#undef sip_endof
65
66#endif // NDNDPDK_CORE_SIPHASH_H
struct sipkey SipHashKey
A key for SipHash.
Definition siphash.h:11
@ SipHashKeyLength
Definition siphash.h:14
struct siphash SipHash
Context for SipHash.
Definition siphash.h:23