summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordimitri staessens <dimitri.staessens@ugent.be>2017-06-05 19:17:30 +0000
committerSander Vrijders <sander.vrijders@ugent.be>2017-06-05 19:17:30 +0000
commit3fde03d682361af24019b4a4f446fc887ddd7f79 (patch)
tree6658cfb2281db84cf4e050391fef3a666471a4ce
parentd38da8b1deae62a57d24e7da94a9c25abbf2f438 (diff)
parentea1248d40a0c68f3e6cf09d03354f7a5fc6e2612 (diff)
downloadouroboros-3fde03d682361af24019b4a4f446fc887ddd7f79.tar.gz
ouroboros-3fde03d682361af24019b4a4f446fc887ddd7f79.zip
Merged in dstaesse/ouroboros/be-macro (pull request #514)
include: Fix macro for printing hash
-rw-r--r--include/ouroboros/endian.h6
-rw-r--r--include/ouroboros/hash.h11
-rw-r--r--src/ipcpd/local/main.c2
-rw-r--r--src/ipcpd/shim-eth-llc/main.c2
-rw-r--r--src/ipcpd/shim-udp/main.c2
-rw-r--r--src/irmd/main.c2
6 files changed, 16 insertions, 9 deletions
diff --git a/include/ouroboros/endian.h b/include/ouroboros/endian.h
index 4738159e..16200028 100644
--- a/include/ouroboros/endian.h
+++ b/include/ouroboros/endian.h
@@ -26,9 +26,15 @@
#if defined(__linux__) || defined(__CYGWIN__)
+#ifndef _BSD_SOURCE
#define _BSD_SOURCE
+#endif
+#ifndef __USE_BSD
#define __USE_BSD
+#endif
+#ifndef _DEFAULT_SOURCE
#define _DEFAULT_SOURCE
+#endif
#include <endian.h>
#include <features.h>
diff --git a/include/ouroboros/hash.h b/include/ouroboros/hash.h
index de3ce541..eeca8a28 100644
--- a/include/ouroboros/hash.h
+++ b/include/ouroboros/hash.h
@@ -24,6 +24,7 @@
#ifndef OUROBOROS_LIB_HASH_H
#define OUROBOROS_LIB_HASH_H
+#include <ouroboros/endian.h>
#include <ouroboros/ipcp.h>
#include <ouroboros/crc32.h>
@@ -32,11 +33,11 @@
#define HASH_FMT "%02x%02x%02x%02x"
-#define HASH_VAL(hash) \
- ((*(unsigned int *) hash) & 0xFF000000) >> 24, \
- ((*(unsigned int *) hash) & 0x00FF0000) >> 16, \
- ((*(unsigned int *) hash) & 0x0000FF00) >> 8, \
- ((*(unsigned int *) hash) & 0x000000FF)
+#define HASH_VAL(hash) \
+ (betoh32(*(uint32_t *) hash) & 0xFF000000) >> 24, \
+ (betoh32(*(uint32_t *) hash) & 0x00FF0000) >> 16, \
+ (betoh32(*(uint32_t *) hash) & 0x0000FF00) >> 8, \
+ (betoh32(*(uint32_t *) hash) & 0x000000FF)
uint16_t hash_len(enum hash_algo algo);
diff --git a/src/ipcpd/local/main.c b/src/ipcpd/local/main.c
index 6d89045c..758e57ae 100644
--- a/src/ipcpd/local/main.c
+++ b/src/ipcpd/local/main.c
@@ -23,6 +23,7 @@
#define OUROBOROS_PREFIX "ipcpd-local"
#include <ouroboros/config.h>
+#include <ouroboros/hash.h>
#include <ouroboros/logs.h>
#include <ouroboros/errno.h>
#include <ouroboros/dev.h>
@@ -30,7 +31,6 @@
#include <ouroboros/ipcp.h>
#include <ouroboros/ipcp-dev.h>
#include <ouroboros/local-dev.h>
-#include <ouroboros/hash.h>
#include "ipcp.h"
diff --git a/src/ipcpd/shim-eth-llc/main.c b/src/ipcpd/shim-eth-llc/main.c
index 1696d0ad..971eeb49 100644
--- a/src/ipcpd/shim-eth-llc/main.c
+++ b/src/ipcpd/shim-eth-llc/main.c
@@ -25,6 +25,7 @@
#define OUROBOROS_PREFIX "ipcpd/shim-eth-llc"
#include <ouroboros/config.h>
+#include <ouroboros/hash.h>
#include <ouroboros/errno.h>
#include <ouroboros/list.h>
#include <ouroboros/utils.h>
@@ -34,7 +35,6 @@
#include <ouroboros/fqueue.h>
#include <ouroboros/logs.h>
#include <ouroboros/time_utils.h>
-#include <ouroboros/hash.h>
#include "ipcp.h"
#include "shim_eth_llc_messages.pb-c.h"
diff --git a/src/ipcpd/shim-udp/main.c b/src/ipcpd/shim-udp/main.c
index 273bd058..892334b2 100644
--- a/src/ipcpd/shim-udp/main.c
+++ b/src/ipcpd/shim-udp/main.c
@@ -23,6 +23,7 @@
#define OUROBOROS_PREFIX "ipcpd/shim-udp"
#include <ouroboros/config.h>
+#include <ouroboros/hash.h>
#include <ouroboros/list.h>
#include <ouroboros/utils.h>
#include <ouroboros/dev.h>
@@ -30,7 +31,6 @@
#include <ouroboros/fqueue.h>
#include <ouroboros/errno.h>
#include <ouroboros/logs.h>
-#include <ouroboros/hash.h>
#include "shim_udp_messages.pb-c.h"
#include "ipcp.h"
diff --git a/src/irmd/main.c b/src/irmd/main.c
index 0a88d311..b2e6ba9c 100644
--- a/src/irmd/main.c
+++ b/src/irmd/main.c
@@ -23,11 +23,11 @@
#define OUROBOROS_PREFIX "irmd"
#include <ouroboros/config.h>
+#include <ouroboros/hash.h>
#include <ouroboros/errno.h>
#include <ouroboros/sockets.h>
#include <ouroboros/list.h>
#include <ouroboros/utils.h>
-#include <ouroboros/hash.h>
#include <ouroboros/irm.h>
#include <ouroboros/lockfile.h>
#include <ouroboros/shm_flow_set.h>