diff options
author | Dimitri Staessens <[email protected]> | 2023-08-16 18:15:14 +0200 |
---|---|---|
committer | Sander Vrijders <[email protected]> | 2023-08-23 13:09:11 +0200 |
commit | ab8ee0b24335790e49127b1330f9d7bcca7f6bfa (patch) | |
tree | b58fa560f7bf52d951547522f9b6d87244af3e06 /src/ipcpd/udp | |
parent | de9674f090c2ae71cacd5f8bd6dcf5e8657ad686 (diff) | |
download | ouroboros-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 <[email protected]>
Signed-off-by: Sander Vrijders <[email protected]>
Diffstat (limited to 'src/ipcpd/udp')
-rw-r--r-- | src/ipcpd/udp/main.c | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/src/ipcpd/udp/main.c b/src/ipcpd/udp/main.c index ee7e2f8f..62cd3181 100644 --- a/src/ipcpd/udp/main.c +++ b/src/ipcpd/udp/main.c @@ -31,6 +31,7 @@ #define OUROBOROS_PREFIX "ipcpd/udp" #include <ouroboros/bitmap.h> +#include <ouroboros/endian.h> #include <ouroboros/hash.h> #include <ouroboros/list.h> #include <ouroboros/utils.h> @@ -858,8 +859,8 @@ static int udp_ipcp_reg(const uint8_t * hash) ipcp_hash_str(hashstr, hash); if (shim_data_reg_add_entry(udp_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)); free(hashstr); return -1; } @@ -892,7 +893,7 @@ static int udp_ipcp_reg(const uint8_t * hash) } } #endif - log_dbg("Registered " HASH_FMT ".", HASH_VAL(hash)); + log_dbg("Registered " HASH_FMT32 ".", HASH_VAL32(hash)); free(hashstr); @@ -936,7 +937,7 @@ static int udp_ipcp_unreg(const uint8_t * hash) shim_data_reg_del_entry(udp_data.shim_data, hash); - log_dbg("Unregistered " HASH_FMT ".", HASH_VAL(hash)); + log_dbg("Unregistered " HASH_FMT32 ".", HASH_VAL32(hash)); free(hashstr); @@ -1009,7 +1010,7 @@ static int udp_ipcp_flow_alloc(int fd, uint32_t ip_addr = 0; char ipstr[INET_ADDRSTRLEN]; - log_dbg("Allocating flow to " HASH_FMT ".", HASH_VAL(dst)); + log_dbg("Allocating flow to " HASH_FMT32 ".", HASH_VAL32(dst)); (void) qs; |