diff options
| author | Your Name <you@example.com> | 2026-05-17 04:50:07 +0530 |
|---|---|---|
| committer | Your Name <you@example.com> | 2026-05-17 04:50:07 +0530 |
| commit | edd125d0e3fe5fe7c0edf30c429723f3b0120c68 (patch) | |
| tree | 5b1134ad7a6cfce7adeb46f5069e33b509ce9751 /main/session.h | |
| parent | cb4bd7d7c10cadcb43f82c09b13ffed744e541f7 (diff) | |
feat(phase6): bytes-based billing - dual metric support
- session_create_bytes() + session_add_bytes() for bytes-metric sessions
- session_is_expired() dispatches on config metric (bytes vs milliseconds)
- cashu_calculate_allotment() unified dispatcher for both metrics
- tollgate_api discovery/usage/session_event use configured metric
- config: metric field defaults to 'bytes', step_size_bytes=22020096 (21MB)
- 14 new unit tests (148 total passing)
- ASSERT_EQ_UINT64 macro added to test framework
Diffstat (limited to 'main/session.h')
| -rw-r--r-- | main/session.h | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/main/session.h b/main/session.h index 8e2d48d..6282f5a 100644 --- a/main/session.h +++ b/main/session.h | |||
| @@ -13,6 +13,8 @@ typedef struct { | |||
| 13 | char mac[SESSION_MAX_MAC_LEN]; | 13 | char mac[SESSION_MAX_MAC_LEN]; |
| 14 | uint64_t allotment_ms; | 14 | uint64_t allotment_ms; |
| 15 | int64_t start_time_ms; | 15 | int64_t start_time_ms; |
| 16 | uint64_t allotment_bytes; | ||
| 17 | uint64_t bytes_consumed; | ||
| 16 | bool active; | 18 | bool active; |
| 17 | char spent_secrets[5][65]; | 19 | char spent_secrets[5][65]; |
| 18 | int spent_secret_count; | 20 | int spent_secret_count; |
| @@ -23,6 +25,11 @@ esp_err_t session_manager_init(void); | |||
| 23 | session_t *session_create(uint32_t client_ip, uint64_t allotment_ms, | 25 | session_t *session_create(uint32_t client_ip, uint64_t allotment_ms, |
| 24 | const char *spent_secrets[], int secret_count); | 26 | const char *spent_secrets[], int secret_count); |
| 25 | 27 | ||
| 28 | session_t *session_create_bytes(uint32_t client_ip, uint64_t allotment_bytes, | ||
| 29 | const char *spent_secrets[], int secret_count); | ||
| 30 | |||
| 31 | void session_add_bytes(uint32_t client_ip, uint64_t bytes); | ||
| 32 | |||
| 26 | session_t *session_find_by_ip(uint32_t client_ip); | 33 | session_t *session_find_by_ip(uint32_t client_ip); |
| 27 | session_t *session_find_by_mac(const char *mac); | 34 | session_t *session_find_by_mac(const char *mac); |
| 28 | 35 | ||