ascii-chat 0.6.0
Real-time terminal-based video chat with ASCII art conversion
Loading...
Searching...
No Matches
network/acip/acds.h
Go to the documentation of this file.
40#pragma once
41
42#include <stdint.h>
43#include <stdbool.h>
44#include "network/packet.h"
46#include "network/webrtc/stun.h"
47#include "network/webrtc/turn.h"
48
49#ifdef __cplusplus
50extern "C" {
51#endif
52
53// Pack network protocol structures tightly for wire format
54#ifdef _WIN32
55#pragma pack(push, 1)
56#endif
57
71
93typedef struct __attribute__((packed)) {
94 uint8_t identity_pubkey[32];
95 uint8_t signature[64];
96 uint64_t timestamp;
97
98 uint8_t capabilities;
99 uint8_t max_participants;
100 uint8_t session_type;
101
102 uint8_t has_password;
103 uint8_t password_hash[128];
104 uint8_t expose_ip_publicly;
106
107 uint8_t reserved_string_len;
108 // char reserved_string[]; ///< Variable length, follows if len > 0
109
110 // Server connection information (where clients should connect)
111 // For DIRECT_TCP: server_address and server_port specify where to connect
112 // For WEBRTC: these fields are ignored, signaling happens through ACDS
113 char server_address[64];
114 uint16_t server_port;
116
132typedef struct __attribute__((packed)) {
133 uint8_t session_string_len;
134 char session_string[48];
135 uint8_t session_id[16];
136 uint64_t expires_at;
137
138 uint8_t stun_count;
139 uint8_t turn_count;
140 // Followed by: stun_server_t[stun_count], turn_server_t[turn_count]
142
160typedef struct __attribute__((packed)) {
161 uint8_t session_string_len;
162 char session_string[48];
164
176typedef struct __attribute__((packed)) {
177 uint8_t found;
178 uint8_t session_id[16];
179 uint8_t host_pubkey[32];
180 uint8_t capabilities;
181 uint8_t max_participants;
182 uint8_t current_participants;
183 uint8_t session_type;
184 uint8_t has_password;
185 uint64_t created_at;
186 uint64_t expires_at;
187
188 // ACDS Policy Flags (enforced by discovery server)
189 uint8_t require_server_verify;
190 uint8_t require_client_verify;
192
207typedef struct __attribute__((packed)) {
208 uint8_t session_string_len;
209 char session_string[48];
210 uint8_t identity_pubkey[32];
211 uint8_t signature[64];
212 uint64_t timestamp;
213
214 uint8_t has_password;
215 char password[128];
217
230typedef struct __attribute__((packed)) {
231 uint8_t success;
233 char error_message[128];
234
236 uint8_t session_id[16];
237
238 // Server connection information (ONLY if success == 1)
239 uint8_t session_type;
240 char server_address[64];
241 uint16_t server_port;
242
243 // TURN credentials for WebRTC NAT traversal (ONLY if session_type == SESSION_TYPE_WEBRTC)
244 // Generated by ACDS server using HMAC-SHA1 with shared secret
245 // Format follows RFC 5766 time-limited TURN authentication
246 char turn_username[128];
247 char turn_password[128];
249
260typedef struct __attribute__((packed)) {
264
275typedef struct __attribute__((packed)) {
277 uint8_t signature[64];
279
290typedef struct __attribute__((packed)) {
293 uint8_t signature[64];
295
318typedef struct __attribute__((packed)) {
319 uint8_t session_id[16];
320 uint8_t sender_id[16];
321 uint8_t recipient_id[16];
322 uint8_t sdp_type;
323 uint16_t sdp_len;
324 // char sdp_data[]; ///< Variable length SDP string
326
341typedef struct __attribute__((packed)) {
343 uint8_t sender_id[16];
344 uint8_t recipient_id[16];
345 uint16_t candidate_len;
346 // char candidate[]; ///< Variable length ICE candidate
348
367typedef struct __attribute__((packed)) {
368 uint8_t identity_pubkey[32];
369 uint8_t signature[64];
370 uint64_t timestamp;
371 uint8_t string_len;
372 char string[48];
373 uint32_t duration_days;
375
385typedef struct __attribute__((packed)) {
386 uint8_t success;
388 char error_message[128];
389 uint64_t expires_at;
391
401typedef struct __attribute__((packed)) {
402 uint8_t identity_pubkey[32];
403 uint8_t signature[64];
404 uint64_t timestamp;
405 uint8_t string_len;
406 char string[48];
407 uint32_t duration_days;
409
419typedef struct __attribute__((packed)) {
420 uint8_t identity_pubkey[32];
421 uint8_t signature[64];
422 uint64_t timestamp;
423 uint8_t string_len;
424 char string[48];
426
445typedef struct __attribute__((packed)) {
447 char error_message[256];
449
468
478#define ACIP_MAX_SESSION_STRING_LEN 48
479
481#define ACIP_SESSION_EXPIRATION_MS (24ULL * 60 * 60 * 1000)
482
484#define ACIP_DISCOVERY_DEFAULT_PORT 27225
485
488#ifdef _WIN32
489#pragma pack(pop)
490#endif
491
492#ifdef __cplusplus
493}
494#endif
495
/* acds */
asciichat_error_t error_code
acip_string_renew_t
acip_session_join_t
acip_session_joined_t
acip_session_lookup_t
acip_string_reserved_t
acip_webrtc_ice_t
acip_error_code_t
ACIP error codes.
acip_string_release_t
acip_session_created_t
acip_webrtc_sdp_t
acip_session_reconnect_t
acip_session_create_t
acds_session_type_t
Session connection type.
acip_session_info_t
acip_session_leave_t
acip_string_reserve_t
acip_session_end_t
@ ACIP_ERROR_RATE_LIMITED
Too many requests from this IP.
@ ACIP_ERROR_STRING_TAKEN
Requested string already reserved.
@ ACIP_ERROR_STRING_INVALID
String format invalid.
@ ACIP_ERROR_INTERNAL
Internal server error.
@ ACIP_ERROR_INVALID_PASSWORD
Password verification failed.
@ ACIP_ERROR_SESSION_NOT_FOUND
Session does not exist.
@ ACIP_ERROR_SESSION_FULL
Session has reached max participants.
@ ACIP_ERROR_INVALID_SIGNATURE
Identity signature invalid.
@ ACIP_ERROR_NONE
No error (success)
@ SESSION_TYPE_WEBRTC
WebRTC P2P mesh with STUN/TURN relay.
@ SESSION_TYPE_DIRECT_TCP
Direct TCP connection to server IP:port (default)
unsigned short uint16_t
Definition common.h:57
unsigned int uint32_t
Definition common.h:58
unsigned long long uint64_t
Definition common.h:59
unsigned char uint8_t
Definition common.h:56
ASCII-Chat IP Protocol (ACIP) packet type definitions.
Packet protocol implementation with encryption and compression support.
uint8_t session_id[16]
uint8_t participant_id[16]
RGB pixel structure.
Definition video/image.h:80