From ea1248d40a0c68f3e6cf09d03354f7a5fc6e2612 Mon Sep 17 00:00:00 2001 From: dimitri staessens Date: Sun, 4 Jun 2017 18:31:07 +0200 Subject: include: Fix macro for printing hash --- include/ouroboros/endian.h | 6 ++++++ include/ouroboros/hash.h | 11 ++++++----- src/ipcpd/local/main.c | 2 +- src/ipcpd/shim-eth-llc/main.c | 2 +- src/ipcpd/shim-udp/main.c | 2 +- src/irmd/main.c | 2 +- 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 #include 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 #include #include @@ -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 +#include #include #include #include @@ -30,7 +31,6 @@ #include #include #include -#include #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 +#include #include #include #include @@ -34,7 +35,6 @@ #include #include #include -#include #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 4ea0ad3d..309e0588 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 +#include #include #include #include @@ -30,7 +31,6 @@ #include #include #include -#include #include "shim_udp_messages.pb-c.h" #include "ipcp.h" diff --git a/src/irmd/main.c b/src/irmd/main.c index b3243192..377cc565 100644 --- a/src/irmd/main.c +++ b/src/irmd/main.c @@ -23,11 +23,11 @@ #define OUROBOROS_PREFIX "irmd" #include +#include #include #include #include #include -#include #include #include #include -- cgit v1.2.3