NDN-DPDK
High-Speed Named Data Networking Forwarder
All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
siphash.h
Go to the documentation of this file.
1 #ifndef NDNDPDK_CORE_SIPHASH_H
2 #define NDNDPDK_CORE_SIPHASH_H
3 
6 #include "common.h"
7 
8 #include "../vendor/siphash-20201003.h"
9 
11 typedef struct sipkey SipHashKey;
12 
13 enum {
14  SipHashKeyLength = SIP_KEYLEN,
15 };
16 
17 __attribute__((nonnull)) static inline void
18 SipHashKey_FromBuffer(SipHashKey* key, const uint8_t buf[SipHashKeyLength]) {
19  sip_tokey(key, buf);
20 }
21 
23 typedef struct siphash SipHash;
24 
26 __attribute__((nonnull)) static inline void
27 SipHash_Init(SipHash* h, const SipHashKey* key) {
28  sip24_init(h, key);
29 }
30 
32 __attribute__((nonnull)) static inline void
33 SipHash_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
42 SipHash_Final(SipHash* h) {
43  return sip24_final(h);
44 }
45 
50 __attribute__((nonnull)) static inline uint64_t
51 SipHash_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