summaryrefslogtreecommitdiff
path: root/src/ipcpd/eth/eth.c
diff options
context:
space:
mode:
authorDimitri Staessens <dimitri@ouroboros.rocks>2023-08-16 18:15:14 +0200
committerSander Vrijders <sander@ouroboros.rocks>2023-08-23 13:09:11 +0200
commitab8ee0b24335790e49127b1330f9d7bcca7f6bfa (patch)
treeb58fa560f7bf52d951547522f9b6d87244af3e06 /src/ipcpd/eth/eth.c
parentde9674f090c2ae71cacd5f8bd6dcf5e8657ad686 (diff)
downloadouroboros-ab8ee0b24335790e49127b1330f9d7bcca7f6bfa.tar.gz
ouroboros-ab8ee0b24335790e49127b1330f9d7bcca7f6bfa.zip
include: Revise printing hashes
The code was a bit convoluted to print hashes as hex strings. Renamed to HASH_FMT32 and HASH_VAL32 to make clear we are printing the first 32 bits only, and added options to print 64 up to 512 bits as well. This doesn't depend on endianness anymore. Adds a small test for the hash (printing) functions. Signed-off-by: Dimitri Staessens <dimitri@ouroboros.rocks> Signed-off-by: Sander Vrijders <sander@ouroboros.rocks>
Diffstat (limited to 'src/ipcpd/eth/eth.c')
-rw-r--r--src/ipcpd/eth/eth.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/src/ipcpd/eth/eth.c b/src/ipcpd/eth/eth.c
index 15082ee3..a429c0a0 100644
--- a/src/ipcpd/eth/eth.c
+++ b/src/ipcpd/eth/eth.c
@@ -37,6 +37,7 @@
#include "config.h"
+#include <ouroboros/endian.h>
#include <ouroboros/hash.h>
#include <ouroboros/errno.h>
#include <ouroboros/list.h>
@@ -1470,7 +1471,7 @@ static int eth_ipcp_bootstrap(const struct ipcp_config * conf)
#endif
if (bind(eth_data.s_fd, (struct sockaddr *) &eth_data.device,
- sizeof(eth_data.device))) {
+ sizeof(eth_data.device))) {
log_err("Failed to bind socket to interface.");
goto fail_device;
}
@@ -1560,12 +1561,12 @@ static int eth_ipcp_bootstrap(const struct ipcp_config * conf)
static int eth_ipcp_reg(const uint8_t * hash)
{
if (shim_data_reg_add_entry(eth_data.shim_data, hash)) {
- log_err("Failed to add " HASH_FMT " to local registry.",
- HASH_VAL(hash));
+ log_err("Failed to add " HASH_FMT32 " to local registry.",
+ HASH_VAL32(hash));
return -1;
}
- log_dbg("Registered " HASH_FMT ".", HASH_VAL(hash));
+ log_dbg("Registered " HASH_FMT32 ".", HASH_VAL32(hash));
return 0;
}
@@ -1645,7 +1646,7 @@ static int eth_ipcp_flow_alloc(int fd,
uint8_t r_addr[MAC_SIZE];
uint64_t addr = 0;
- log_dbg("Allocating flow to " HASH_FMT ".", HASH_VAL(hash));
+ log_dbg("Allocating flow to " HASH_FMT32 ".", HASH_VAL32(hash));
assert(hash);