upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
path: root/tollgate_core/src/tollgate_session.h
diff options
context:
space:
mode:
Diffstat (limited to 'tollgate_core/src/tollgate_session.h')
-rw-r--r--tollgate_core/src/tollgate_session.h42
1 files changed, 0 insertions, 42 deletions
diff --git a/tollgate_core/src/tollgate_session.h b/tollgate_core/src/tollgate_session.h
deleted file mode 100644
index 4008b24..0000000
--- a/tollgate_core/src/tollgate_session.h
+++ /dev/null
@@ -1,42 +0,0 @@
1#ifndef TOLLGATE_CORE_SESSION_H
2#define TOLLGATE_CORE_SESSION_H
3
4#include <stdint.h>
5#include <stdbool.h>
6
7#define TG_SESSION_MAX_CLIENTS 10
8#define TG_SESSION_MAX_MAC_LEN 18
9
10typedef enum {
11 TG_PAYMENT_CASHU,
12 TG_PAYMENT_MINING,
13 TG_PAYMENT_BYTES
14} tg_payment_method_t;
15
16typedef struct {
17 uint32_t client_ip;
18 char mac[TG_SESSION_MAX_MAC_LEN];
19 uint64_t allotment_ms;
20 int64_t start_time_ms;
21 uint64_t allotment_bytes;
22 uint64_t bytes_consumed;
23 tg_payment_method_t payment_method;
24 bool active;
25} tg_session_t;
26
27int tg_session_init(void);
28tg_session_t *tg_session_create(uint32_t client_ip, uint64_t allotment_ms);
29tg_session_t *tg_session_create_bytes(uint32_t client_ip, uint64_t allotment_bytes);
30void tg_session_add_bytes(uint32_t client_ip, uint64_t bytes);
31tg_session_t *tg_session_find_by_ip(uint32_t client_ip);
32tg_session_t *tg_session_find_by_mac(const char *mac);
33void tg_session_extend(tg_session_t *session, uint64_t additional_ms);
34bool tg_session_is_expired(const tg_session_t *session);
35void tg_session_revoke(tg_session_t *session);
36void tg_session_revoke_all(void);
37int tg_session_active_count(void);
38void tg_session_tick(void);
39tg_session_t *tg_session_get_array(void);
40int tg_session_get_array_size(void);
41
42#endif