summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2014-09-03 17:24:00 +0200
committerMatthias Schiffer <mschiffer@universe-factory.net>2014-09-03 17:41:11 +0200
commited0aec25c50b53e63070c2a4a25480724bdf343a (patch)
tree17a706b4dbbd4780d53a0dabbbd41f62c7fc5d83 /src
parentedbfeca6cedb55872f8a92b790e1a989a3cf47e5 (diff)
downloadfastd-ed0aec25c50b53e63070c2a4a25480724bdf343a.tar
fastd-ed0aec25c50b53e63070c2a4a25480724bdf343a.zip
Fix UHASH build on *BSD
Diffstat (limited to 'src')
-rw-r--r--src/crypto/mac/uhash/builtin/uhash_builtin.c2
-rw-r--r--src/fastd_config.h.in8
-rw-r--r--src/util.h23
3 files changed, 31 insertions, 2 deletions
diff --git a/src/crypto/mac/uhash/builtin/uhash_builtin.c b/src/crypto/mac/uhash/builtin/uhash_builtin.c
index 07ee749..e4710ae 100644
--- a/src/crypto/mac/uhash/builtin/uhash_builtin.c
+++ b/src/crypto/mac/uhash/builtin/uhash_builtin.c
@@ -35,8 +35,6 @@
#include "../../../../util.h"
#include "../../../../log.h"
-#include <endian.h>
-
/** MAC state used by this UHASH implmentation */
struct fastd_mac_state {
diff --git a/src/fastd_config.h.in b/src/fastd_config.h.in
index 9949eca..e396bf8 100644
--- a/src/fastd_config.h.in
+++ b/src/fastd_config.h.in
@@ -41,6 +41,14 @@
/** Defined if the platform defines get_current_dir_name() */
#cmakedefine HAVE_GET_CURRENT_DIR_NAME
+/** Defined if <endian.h> exists */
+#cmakedefine HAVE_ENDIAN_H
+
+/** Defined if <sys/endian.h> exists */
+#cmakedefine HAVE_SYS_ENDIAN_H
+
+/** Defined if be32toh etc. exist */
+#cmakedefine HAVE_LINUX_ENDIAN
/** Defined if the platform supports SO_BINDTODEVICE */
#cmakedefine USE_BINDTODEVICE
diff --git a/src/util.h b/src/util.h
index fe6720b..3acc42f 100644
--- a/src/util.h
+++ b/src/util.h
@@ -32,6 +32,18 @@
#pragma once
+
+#include <sys/types.h>
+
+#ifdef HAVE_ENDIAN_H
+#include <endian.h>
+#endif
+
+#ifdef HAVE_SYS_ENDIAN_H
+#include <sys/endian.h>
+#endif
+
+
/**
Returns a pointer to a data structure, given the address of a member contained in the structure
@@ -91,3 +103,14 @@ static inline size_t max_size_t(size_t a, size_t b) {
static inline size_t min_size_t(size_t a, size_t b) {
return (a < b) ? a : b;
}
+
+
+#ifndef HAVE_LINUX_ENDIAN
+
+/** converts a 32bit integer from big endian to host byte order */
+#define be32toh(x) betoh32(x)
+
+/** converts a 32bit integer from little endian to host byte order */
+#define le32toh(x) letoh32(x)
+
+#endif