From adc518a2063ee78e4217a8aba51b116af1af42f4 Mon Sep 17 00:00:00 2001 From: Dirk Engling Date: Sat, 28 Nov 2026 19:46:59 +0100 Subject: Add helper to pack uint32 in network byte order --- src/trackerlogic.h | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src/trackerlogic.h') diff --git a/src/trackerlogic.h b/src/trackerlogic.h index 4086b23..a05c790 100644 --- a/src/trackerlogic.h +++ b/src/trackerlogic.h @@ -4,10 +4,12 @@ #ifndef OT_TRACKERLOGIC_H__ #define OT_TRACKERLOGIC_H__ +#include #include #include #include #include +#include #include #include #include @@ -124,6 +126,14 @@ static inline int time_is_past(ot_time deadline) { return time_now_seconds() > d survive a restart, and the clock above counts from boot. */ static inline ot_time time_wall_minutes(void) { return time(NULL) / 60; } +/* Appends a 32 bit value in network byte order to a binary reply and + advances the cursor. The caller has made sure of the room. */ +static inline void pack_uint32(char **cursor, uint32_t value) { + value = htonl(value); + memcpy(*cursor, &value, sizeof(value)); + *cursor += sizeof(value); +} + /* Cleared from the interrupt handler and read by every worker */ extern _Atomic int g_opentracker_running; -- cgit v1.3