summaryrefslogtreecommitdiff
path: root/src/trackerlogic.h
diff options
context:
space:
mode:
authorDirk Engling <erdgeist@erdgeist.org>2026-11-28 19:46:59 +0100
committerDirk Engling <erdgeist@erdgeist.org>2026-11-28 19:46:59 +0100
commitadc518a2063ee78e4217a8aba51b116af1af42f4 (patch)
treee5099842d850fffaef5bfd959822eeaa22599f55 /src/trackerlogic.h
parentcc7482269feb12c275a156efd42dd6a3d6cb189d (diff)
Add helper to pack uint32 in network byte order
Diffstat (limited to 'src/trackerlogic.h')
-rw-r--r--src/trackerlogic.h10
1 files changed, 10 insertions, 0 deletions
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 @@
4#ifndef OT_TRACKERLOGIC_H__ 4#ifndef OT_TRACKERLOGIC_H__
5#define OT_TRACKERLOGIC_H__ 5#define OT_TRACKERLOGIC_H__
6 6
7#include <arpa/inet.h>
7#include <signal.h> 8#include <signal.h>
8#include <stdatomic.h> 9#include <stdatomic.h>
9#include <stdint.h> 10#include <stdint.h>
10#include <stdlib.h> 11#include <stdlib.h>
12#include <string.h>
11#include <sys/time.h> 13#include <sys/time.h>
12#include <sys/types.h> 14#include <sys/types.h>
13#include <time.h> 15#include <time.h>
@@ -124,6 +126,14 @@ static inline int time_is_past(ot_time deadline) { return time_now_seconds() > d
124 survive a restart, and the clock above counts from boot. */ 126 survive a restart, and the clock above counts from boot. */
125static inline ot_time time_wall_minutes(void) { return time(NULL) / 60; } 127static inline ot_time time_wall_minutes(void) { return time(NULL) / 60; }
126 128
129/* Appends a 32 bit value in network byte order to a binary reply and
130 advances the cursor. The caller has made sure of the room. */
131static inline void pack_uint32(char **cursor, uint32_t value) {
132 value = htonl(value);
133 memcpy(*cursor, &value, sizeof(value));
134 *cursor += sizeof(value);
135}
136
127/* Cleared from the interrupt handler and read by every worker */ 137/* Cleared from the interrupt handler and read by every worker */
128extern _Atomic int g_opentracker_running; 138extern _Atomic int g_opentracker_running;
129 139