network: prevent adding endpoint routes for addresses on the network
[project/unetd.git] / siphash.h
index ff76d9c57891e7758a364ff7590412b593327494..233d33aed21340729618fa4b9a83a6a73000bd52 100644 (file)
--- a/siphash.h
+++ b/siphash.h
 #include <stdint.h>
 #include <stdlib.h>
 #include <stdbool.h>
-#include <libubox/utils.h>
+#include "utils.h"
 
 #define SIPHASH_ALIGNMENT __alignof__(uint64_t)
 typedef struct {
        uint64_t key[2];
 } siphash_key_t;
 
-static inline uint16_t get_unaligned_le16(const uint8_t *p)
-{
-       return p[0] | p[1] << 8;
-}
-
-static inline uint32_t get_unaligned_le32(const uint8_t *p)
-{
-       return p[0] | p[1] << 8 | p[2] << 16 | p[3] << 24;
-}
-
-static inline uint64_t get_unaligned_le64(const uint8_t *p)
-{
-       return (uint64_t)get_unaligned_le32(p + 4) << 32 |
-              get_unaligned_le32(p);
-}
-
 static inline bool siphash_key_is_zero(const siphash_key_t *key)
 {
        return !(key->key[0] | key->key[1]);
@@ -54,4 +38,12 @@ static inline void siphash_to_le64(void *dest, const void *data, size_t len,
        *(uint64_t *)dest = cpu_to_le64(hash);
 }
 
+static inline void siphash_to_be64(void *dest, const void *data, size_t len,
+                                  const siphash_key_t *key)
+{
+       uint64_t hash = siphash(data, len, key);
+
+       *(uint64_t *)dest = cpu_to_be64(hash);
+}
+
 #endif /* _LINUX_SIPHASH_H */