summaryrefslogtreecommitdiff
path: root/src/irmd/main.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/irmd/main.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/irmd/main.c')
-rw-r--r--src/irmd/main.c18
1 files changed, 9 insertions, 9 deletions
diff --git a/src/irmd/main.c b/src/irmd/main.c
index bb65297f..b5184ade 100644
--- a/src/irmd/main.c
+++ b/src/irmd/main.c
@@ -1201,14 +1201,14 @@ int name_reg(const char * name,
pthread_rwlock_unlock(&irmd.reg_lock);
if (ipcp_reg(pid, hash, len)) {
- log_err("Could not register " HASH_FMT " with IPCP %d.",
- HASH_VAL(hash), pid);
+ log_err("Could not register " HASH_FMT32 " with IPCP %d.",
+ HASH_VAL32(hash), pid);
free(hash);
return -1;
}
- log_info("Registered %s with IPCP %d as " HASH_FMT ".",
- name, pid, HASH_VAL(hash));
+ log_info("Registered %s with IPCP %d as " HASH_FMT32 ".",
+ name, pid, HASH_VAL32(hash));
free(hash);
@@ -1736,8 +1736,8 @@ static int flow_req_arr(pid_t pid,
struct timespec wt = {IRMD_REQ_ARR_TIMEOUT / 1000,
(IRMD_REQ_ARR_TIMEOUT % 1000) * MILLION};
- log_dbg("Flow req arrived from IPCP %d for " HASH_FMT ".",
- pid, HASH_VAL(hash));
+ log_dbg("Flow req arrived from IPCP %d for " HASH_FMT32 ".",
+ pid, HASH_VAL32(hash));
pthread_rwlock_rdlock(&irmd.reg_lock);
@@ -1751,7 +1751,7 @@ static int flow_req_arr(pid_t pid,
hash, IPCP_HASH_LEN(ipcp));
if (n == NULL) {
pthread_rwlock_unlock(&irmd.reg_lock);
- log_err("Unknown hash: " HASH_FMT ".", HASH_VAL(hash));
+ log_err("Unknown hash: " HASH_FMT32 ".", HASH_VAL32(hash));
return -1;
}
@@ -1761,7 +1761,7 @@ static int flow_req_arr(pid_t pid,
/* Give the process a bit of slop time to call accept */
if (reg_name_leave_state(n, NAME_IDLE, &wt) == -1) {
- log_err("No processes for " HASH_FMT ".", HASH_VAL(hash));
+ log_err("No processes for " HASH_FMT32 ".", HASH_VAL32(hash));
return -1;
}
@@ -1770,7 +1770,7 @@ static int flow_req_arr(pid_t pid,
switch (reg_name_get_state(n)) {
case NAME_IDLE:
pthread_rwlock_unlock(&irmd.reg_lock);
- log_err("No processes for " HASH_FMT ".", HASH_VAL(hash));
+ log_err("No processes for " HASH_FMT32 ".", HASH_VAL32(hash));
return -1;
case NAME_AUTO_ACCEPT:
c_pid = malloc(sizeof(*c_pid));