ascii-chat 0.6.0
Real-time terminal-based video chat with ASCII art conversion
Loading...
Searching...
No Matches
packet.h
Go to the documentation of this file.
1
73#pragma once
74
75#include "platform/socket.h"
77#include "crypto/crypto.h"
78#include "log/logging.h"
79#include <stdint.h>
80#include <stddef.h>
81#include <stdbool.h>
82#include <errno.h>
83
84// Pack network protocol structures tightly for wire format
85#ifdef _WIN32
86#pragma pack(push, 1)
87#endif
88
103#define LARGE_PACKET_THRESHOLD (100 * 1024)
104
113#define MAX_PACKET_SIZE ((size_t)5 * 1024 * 1024)
114
122#define MAX_ERROR_MESSAGE_LENGTH 512
123
132#define MAX_REMOTE_LOG_MESSAGE_LENGTH 512
133
153#define BASE_SEND_TIMEOUT 5
154
163#define LARGE_PACKET_EXTRA_TIMEOUT_PER_MB 0.8
164
173#define MIN_CLIENT_TIMEOUT 10
174
183#define MAX_CLIENT_TIMEOUT 60
184
204#define AUDIO_BATCH_COUNT 32
205
214#define AUDIO_BATCH_SAMPLES (AUDIO_SAMPLES_PER_PACKET * AUDIO_BATCH_COUNT)
215
223#define AUDIO_BATCH_MS 186
224
233#define AUDIO_SAMPLES_PER_PACKET 256
234
251#define PACKET_MAGIC 0xDEADBEEF
252
281typedef enum {
284
289
298
311
334
341
344
355
360
361 // ============================================================================
362 // Discovery Service Protocol (ACDS)
363 // ============================================================================
364 // ACIP packets use range 100-199 to avoid conflicts with ascii-chat protocol (1-35)
365 // See network/acip/protocol.h for protocol overview and utility functions
366 // See network/acip/acds.h for ACDS message structures and detailed documentation
367
386
391
400
406
433static inline bool packet_is_handshake_type(packet_type_t type) {
434 // Initial handshake packets (14-23)
436 return true;
437 }
438 // Rekey packets (25-27) - Note: REKEY_COMPLETE is encrypted with new key but still considered handshake
440 return true;
441 }
442 return false;
443}
444
464static inline bool packet_is_precompressed(packet_type_t type) {
465 // Opus audio packets are already compressed by Opus codec
466 return (type == PACKET_TYPE_AUDIO_OPUS || type == PACKET_TYPE_AUDIO_OPUS_BATCH);
467}
468
503
517#define ASCIICHAT_DEFAULT_DISPLAY_NAME "AsciiChatter"
518
529typedef struct {
534}
536
545typedef struct {
549 char display_name[MAX_DISPLAY_NAME_LEN];
553}
555
573
589
607
626
628#define REMOTE_LOG_FLAG_TRUNCATED 0x0001U
644
665
674typedef struct {
678 uint8_t reserved[7];
679}
681
694#define FEATURE_RLE_ENCODING 0x01
695#define FEATURE_DELTA_FRAMES 0x02
727
755
783
807
815#define CLIENT_CAP_VIDEO 0x01
816#define CLIENT_CAP_AUDIO 0x02
817#define CLIENT_CAP_COLOR 0x04
818#define CLIENT_CAP_STRETCH 0x08
829#define STREAM_TYPE_VIDEO 0x01
830#define STREAM_TYPE_AUDIO 0x02
861
900
940
949#define KEX_ALGO_X25519 0x01
950#define AUTH_ALGO_ED25519 0x01
951#define AUTH_ALGO_NONE 0x00
952#define CIPHER_ALGO_XSALSA20_POLY1305 0x01
956#ifdef _WIN32
957#pragma pack(pop)
958#endif
959
994
1013
1038 uint32_t *expected_crc);
1039
1058asciichat_error_t packet_validate_crc32(const void *data, size_t len, uint32_t expected_crc);
1059
1086asciichat_error_t packet_send(socket_t sockfd, packet_type_t type, const void *data, size_t len);
1087
1107asciichat_error_t packet_receive(socket_t sockfd, packet_type_t *type, void **data, size_t *len);
1108
1140asciichat_error_t send_packet_secure(socket_t sockfd, packet_type_t type, const void *data, size_t len,
1141 crypto_context_t *crypto_ctx);
1142
1167packet_recv_result_t receive_packet_secure(socket_t sockfd, void *crypto_ctx, bool enforce_encryption,
1168 packet_envelope_t *envelope);
1169
1196int send_packet(socket_t sockfd, packet_type_t type, const void *data, size_t len);
1197
1215int receive_packet(socket_t sockfd, packet_type_t *type, void **data, size_t *len);
1216
1241int send_ping_packet(socket_t sockfd);
1242
1255int send_pong_packet(socket_t sockfd);
1256
1268
1282 const char *message);
1283
1294asciichat_error_t packet_parse_error_message(const void *data, size_t len, asciichat_error_t *out_error_code,
1295 char *message_buffer, size_t message_buffer_size,
1296 size_t *out_message_length);
1297
1309 remote_log_direction_t direction, uint16_t flags, const char *message);
1310
1323asciichat_error_t packet_parse_remote_log(const void *data, size_t len, log_level_t *out_level,
1324 remote_log_direction_t *out_direction, uint16_t *out_flags,
1325 char *message_buffer, size_t message_buffer_size, size_t *out_message_length);
1326
1341
1356
1371
1389asciichat_error_t send_audio_batch_packet(socket_t sockfd, const float *samples, int num_samples, int batch_count,
1390 crypto_context_t *crypto_ctx);
1391
1412asciichat_error_t av_send_audio_opus_batch(socket_t sockfd, const uint8_t *opus_data, size_t opus_size,
1413 const uint16_t *frame_sizes, int sample_rate, int frame_duration,
1414 int frame_count, crypto_context_t *crypto_ctx);
1415
1430asciichat_error_t send_ascii_frame_packet(socket_t sockfd, const char *frame_data, size_t frame_size);
1431
1449asciichat_error_t send_image_frame_packet(socket_t sockfd, const void *image_data, uint16_t width, uint16_t height,
1450 uint8_t format);
1451
🔌 Cross-platform abstraction layer umbrella header for ascii-chat
asciichat_error_t error_code
unsigned short uint16_t
Definition common.h:57
unsigned int uint32_t
Definition common.h:58
unsigned char uint8_t
Definition common.h:56
asciichat_error_t
Error and exit codes - unified status values (0-255)
Definition error_codes.h:46
#define MAX_CLIENTS
Maximum possible clients (static array size) - actual runtime limit set by –max-clients (1-32)
Definition limits.h:23
#define MAX_DISPLAY_NAME_LEN
Maximum display name length in characters.
Definition limits.h:20
enum remote_log_direction remote_log_direction_t
Remote log packet direction enumeration.
log_level_t
Logging levels enumeration.
Definition log/logging.h:59
uint32_t pixel_format
Pixel format enum (0=RGB24, 1=RGBA32, 2=BGR24, etc.)
Definition packet.h:774
uint8_t hmac_size
HMAC size in bytes (e.g., 32 for HMAC-SHA256)
Definition packet.h:895
asciichat_error_t send_packet_secure(socket_t sockfd, packet_type_t type, const void *data, size_t len, crypto_context_t *crypto_ctx)
Send a packet with encryption and compression support.
Definition packet.c:433
uint8_t preferred_auth
Preferred authentication algorithm (AUTH_ALGO_*)
Definition packet.h:856
uint32_t capabilities
Terminal capabilities bitmask (TERM_CAP_* flags)
Definition packet.h:911
uint32_t color_level
Color level enum value (terminal_color_mode_t)
Definition packet.h:913
uint16_t supported_auth_algorithms
Supported authentication algorithms bitmask (AUTH_ALGO_*)
Definition packet.h:848
uint32_t timestamp
Timestamp when frame was captured (milliseconds since epoch)
Definition packet.h:780
uint32_t color_count
Actual color count (16, 256, or 16777216)
Definition packet.h:915
uint8_t selected_kex
Selected key exchange algorithm (KEX_ALGO_*)
Definition packet.h:875
uint32_t magic
Magic number (PACKET_MAGIC) for packet validation.
Definition packet.h:492
uint16_t flags
Additional flags (REMOTE_LOG_FLAG_*)
Definition packet.h:639
uint16_t supported_kex_algorithms
Supported key exchange algorithms bitmask (KEX_ALGO_*)
Definition packet.h:846
asciichat_error_t packet_parse_remote_log(const void *data, size_t len, log_level_t *out_level, remote_log_direction_t *out_direction, uint16_t *out_flags, char *message_buffer, size_t message_buffer_size, size_t *out_message_length)
Parse a remote log packet payload into components.
Definition packet.c:953
uint32_t message_length
Message payload length in bytes (0-512)
Definition packet.h:641
uint8_t log_level
Log level associated with the message (log_level_t cast to uint8_t)
Definition packet.h:635
uint32_t width
Terminal width in characters.
Definition packet.h:742
uint32_t client_count
Number of clients in the list (0 to MAX_CLIENTS)
Definition packet.h:584
asciichat_error_t packet_send_error(socket_t sockfd, const crypto_context_t *crypto_ctx, asciichat_error_t error_code, const char *message)
Send an error packet with optional encryption context.
Definition packet.c:807
uint8_t preferred_cipher
Preferred cipher algorithm (CIPHER_ALGO_*)
Definition packet.h:858
uint32_t client_id
Client ID (0 = server, >0 = client identifier)
Definition packet.h:500
asciichat_error_t packet_validate_crc32(const void *data, size_t len, uint32_t expected_crc)
Validate packet CRC32 checksum.
Definition packet.c:261
asciichat_error_t packet_send_remote_log(socket_t sockfd, const crypto_context_t *crypto_ctx, log_level_t level, remote_log_direction_t direction, uint16_t flags, const char *message)
Send a remote log packet with optional encryption context.
Definition packet.c:896
uint16_t height
Terminal height in characters.
Definition packet.h:921
uint8_t selected_cipher
Selected cipher algorithm (CIPHER_ALGO_*)
Definition packet.h:879
uint32_t message_length
Length of message payload in bytes (0-512)
Definition packet.h:623
asciichat_error_t send_image_frame_packet(socket_t sockfd, const void *image_data, uint16_t width, uint16_t height, uint8_t format)
Send image frame packet.
Definition packet.c:1230
uint8_t compression_threshold
Compression threshold percentage (0-100, e.g., 80 = compress if >80% size reduction)
Definition packet.h:720
uint32_t active_client_count
Number of clients actively sending video/audio streams.
Definition packet.h:602
uint16_t auth_public_key_size
Authentication public key size in bytes (e.g., 32 for Ed25519, 1952 for Dilithium3)
Definition packet.h:885
uint32_t length
Payload data length in bytes (0 for header-only packets)
Definition packet.h:496
uint32_t error_code
Error code from asciichat_error_t enumeration.
Definition packet.h:621
void * allocated_buffer
Buffer that needs to be freed by caller (may be NULL if not allocated)
Definition packet.h:990
uint8_t selected_auth
Selected authentication algorithm (AUTH_ALGO_*)
Definition packet.h:877
uint32_t timestamp
Timestamp when frame/audio was captured (milliseconds since epoch)
Definition packet.h:570
uint32_t checksum
CRC32 checksum of original ASCII data.
Definition packet.h:750
int send_protocol_version_packet(socket_t sockfd, const protocol_version_packet_t *version)
Send protocol version negotiation packet.
Definition packet.c:1016
int send_pong_packet(socket_t sockfd)
Send a pong packet (keepalive response)
Definition packet.c:793
uint32_t original_size
Size of original uncompressed ASCII data in bytes.
Definition packet.h:746
uint32_t height
Terminal height in characters.
Definition packet.h:744
uint8_t reason_flags
Bitmask of auth_failure_reason_t values indicating failure causes.
Definition packet.h:676
uint32_t connected_client_count
Total number of currently connected clients.
Definition packet.h:600
asciichat_error_t send_audio_batch_packet(socket_t sockfd, const float *samples, int num_samples, int batch_count, crypto_context_t *crypto_ctx)
Send a batched audio packet with encryption support.
Definition packet.c:1072
asciichat_error_t packet_receive(socket_t sockfd, packet_type_t *type, void **data, size_t *len)
Receive a packet with header validation and CRC32 checking.
Definition packet.c:351
uint8_t verification_enabled
Server verification enabled flag (1=enabled, 0=disabled)
Definition packet.h:881
uint32_t height
Terminal height in characters.
Definition packet.h:533
uint16_t protocol_revision
Minor protocol revision (server can be newer)
Definition packet.h:714
uint32_t compressed_size
Size of compressed data (0 = not compressed)
Definition packet.h:748
uint16_t protocol_version
Major protocol version (must match for compatibility)
Definition packet.h:712
asciichat_error_t packet_parse_error_message(const void *data, size_t len, asciichat_error_t *out_error_code, char *message_buffer, size_t message_buffer_size, size_t *out_message_length)
Parse an error packet payload into components.
Definition packet.c:854
uint16_t supported_cipher_algorithms
Supported cipher algorithms bitmask (CIPHER_ALGO_*)
Definition packet.h:850
uint16_t signature_size
Signature size in bytes (e.g., 64 for Ed25519, 3309 for Dilithium3)
Definition packet.h:887
int receive_packet(socket_t sockfd, packet_type_t *type, void **data, size_t *len)
Receive a basic packet without encryption.
Definition packet.c:767
asciichat_error_t send_ascii_frame_packet(socket_t sockfd, const char *frame_data, size_t frame_size)
Send ASCII frame packet.
Definition packet.c:1191
uint32_t stream_type
Stream type bitmask (STREAM_TYPE_VIDEO | STREAM_TYPE_AUDIO)
Definition packet.h:568
asciichat_error_t av_send_audio_opus_batch(socket_t sockfd, const uint8_t *opus_data, size_t opus_size, const uint16_t *frame_sizes, int sample_rate, int frame_duration, int frame_count, crypto_context_t *crypto_ctx)
Send Opus-encoded audio batch packet with encryption support.
Definition packet.c:1136
size_t allocated_size
Size of allocated buffer in bytes.
Definition packet.h:992
size_t len
Length of payload data in bytes.
Definition packet.h:986
int send_packet(socket_t sockfd, packet_type_t type, const void *data, size_t len)
Send a basic packet without encryption.
Definition packet.c:754
asciichat_error_t packet_validate_header(const packet_header_t *header, uint16_t *pkt_type, uint32_t *pkt_len, uint32_t *expected_crc)
Validate packet header and extract information.
Definition packet.c:75
uint32_t render_mode
Render mode enum value (foreground/background/half-block)
Definition packet.h:917
uint16_t feature_flags
Feature flags bitmask (FEATURE_RLE_ENCODING, etc.)
Definition packet.h:722
void * data
Packet payload data (decrypted and decompressed if applicable)
Definition packet.h:984
asciichat_error_t packet_send(socket_t sockfd, packet_type_t type, const void *data, size_t len)
Send a packet with header and CRC32 checksum.
Definition packet.c:291
uint8_t preferred_kex
Preferred key exchange algorithm (KEX_ALGO_*)
Definition packet.h:854
uint8_t nonce_size
Nonce size in bytes (e.g., 24 for XSalsa20)
Definition packet.h:891
uint32_t compressed_size
Compressed data size (0 = not compressed, >0 = compressed)
Definition packet.h:776
uint16_t width
Terminal width in characters.
Definition packet.h:919
packet_recv_result_t receive_packet_secure(socket_t sockfd, void *crypto_ctx, bool enforce_encryption, packet_envelope_t *envelope)
Receive a packet with decryption and decompression support.
Definition packet.c:568
uint16_t type
Packet type (packet_type_t enumeration)
Definition packet.h:494
int send_crypto_capabilities_packet(socket_t sockfd, const crypto_capabilities_packet_t *caps)
Send crypto capabilities packet.
Definition packet.c:1030
uint32_t checksum
CRC32 checksum of pixel data.
Definition packet.h:778
uint8_t desired_fps
Client's desired frame rate (1-144 FPS)
Definition packet.h:935
uint32_t client_id
Unique client identifier (1-9, 0 = server)
Definition packet.h:547
uint8_t requires_verification
Server verification requirement flag (1=required, 0=optional)
Definition packet.h:852
uint32_t channels
Number of audio channels (1=mono, 2=stereo)
Definition packet.h:804
int send_clear_console_packet(socket_t sockfd)
Send a clear console packet.
Definition packet.c:803
uint8_t detection_reliable
Detection reliability flag (1=reliable detection, 0=best guess)
Definition packet.h:927
uint8_t direction
Direction hint so receivers can annotate origin.
Definition packet.h:637
int send_ping_packet(socket_t sockfd)
Send a ping packet (keepalive)
Definition packet.c:783
uint32_t height
Image height in pixels.
Definition packet.h:772
packet_type_t type
Packet type (from packet_types.h)
Definition packet.h:982
uint32_t batch_count
Number of audio chunks in this batch (usually AUDIO_BATCH_COUNT = 32)
Definition packet.h:798
uint32_t width
Image width in pixels.
Definition packet.h:770
uint32_t flags
Frame flags bitmask (HAS_COLOR, IS_COMPRESSED, etc.)
Definition packet.h:752
uint32_t client_id
Client ID that this stream originates from (1-9)
Definition packet.h:566
uint32_t sample_rate
Sample rate in Hz (e.g., 44100, 48000)
Definition packet.h:802
uint32_t total_samples
Total audio samples across all chunks (typically 8192)
Definition packet.h:800
uint8_t compression_algorithms
Supported compression algorithms bitmask (COMPRESS_ALGO_*)
Definition packet.h:718
uint32_t width
Terminal width in characters.
Definition packet.h:531
bool was_encrypted
True if packet was encrypted (decrypted before envelope creation)
Definition packet.h:988
uint32_t palette_type
Palette type enum value (palette_type_t)
Definition packet.h:931
int send_crypto_parameters_packet(socket_t sockfd, const crypto_parameters_packet_t *params)
Send crypto parameters packet.
Definition packet.c:1044
uint32_t capabilities
Client capabilities bitmask (CLIENT_CAP_VIDEO | CLIENT_CAP_AUDIO | CLIENT_CAP_COLOR | CLIENT_CAP_STRE...
Definition packet.h:552
uint8_t mac_size
MAC size in bytes (e.g., 16 for Poly1305)
Definition packet.h:893
uint16_t shared_secret_size
Shared secret size in bytes (e.g., 32 for X25519)
Definition packet.h:889
uint16_t kex_public_key_size
Key exchange public key size in bytes (e.g., 32 for X25519, 1568 for Kyber1024)
Definition packet.h:883
uint32_t crc32
CRC32 checksum of payload data (0 if length == 0)
Definition packet.h:498
packet_recv_result_t
Packet reception result codes.
Definition packet.h:1003
uint32_t utf8_support
UTF-8 support flag (0=no UTF-8, 1=UTF-8 supported)
Definition packet.h:929
uint8_t supports_encryption
Encryption support flag (1=support encryption, 0=plaintext only)
Definition packet.h:716
@ PACKET_RECV_ERROR
Network error occurred.
Definition packet.h:1009
@ PACKET_RECV_EOF
Connection closed (EOF)
Definition packet.h:1007
@ PACKET_RECV_SECURITY_VIOLATION
Encryption policy violation (e.g., unencrypted packet when encryption required)
Definition packet.h:1011
@ PACKET_RECV_SUCCESS
Packet received successfully.
Definition packet.h:1005
auth_failure_reason_t
Authentication failure reason flags.
Definition packet.h:653
packet_type_t
Network protocol packet type enumeration.
Definition packet.h:281
@ AUTH_FAIL_PASSWORD_INCORRECT
Password verification failed (incorrect password)
Definition packet.h:657
@ AUTH_FAIL_PASSWORD_REQUIRED
Server requires password but client didn't provide one.
Definition packet.h:655
@ AUTH_FAIL_CLIENT_KEY_REQUIRED
Server requires client key but client didn't provide one.
Definition packet.h:659
@ AUTH_FAIL_CLIENT_KEY_REJECTED
Client key not in whitelist (access denied)
Definition packet.h:661
@ AUTH_FAIL_SIGNATURE_INVALID
Client signature verification failed (invalid signature)
Definition packet.h:663
@ PACKET_TYPE_ACIP_WEBRTC_ICE
WebRTC ICE candidate (bidirectional)
Definition packet.h:390
@ PACKET_TYPE_AUDIO_OPUS_BATCH
Batched Opus-encoded audio frames.
Definition packet.h:359
@ PACKET_TYPE_AUDIO_OPUS
Opus-encoded single audio frame.
Definition packet.h:357
@ PACKET_TYPE_CLIENT_LEAVE
Clean disconnect notification.
Definition packet.h:302
@ PACKET_TYPE_ACIP_SESSION_INFO
Session info response (Discovery Server -> Client)
Definition packet.h:375
@ PACKET_TYPE_IMAGE_FRAME
Complete RGB image with dimensions.
Definition packet.h:288
@ PACKET_TYPE_CRYPTO_AUTH_RESPONSE
Client -> Server: {HMAC[32]} (UNENCRYPTED)
Definition packet.h:323
@ PACKET_TYPE_TEXT_MESSAGE
Text message.
Definition packet.h:350
@ PACKET_TYPE_AUDIO_MESSAGE
Audio message.
Definition packet.h:348
@ PACKET_TYPE_PONG
Keepalive pong response.
Definition packet.h:297
@ PACKET_TYPE_ACIP_SESSION_RECONNECT
Reconnect to session (Client -> Discovery Server)
Definition packet.h:385
@ PACKET_TYPE_CRYPTO_HANDSHAKE_COMPLETE
Server -> Client: "encryption ready" (UNENCRYPTED)
Definition packet.h:329
@ PACKET_TYPE_STREAM_START
Client requests to start sending video/audio.
Definition packet.h:304
@ PACKET_TYPE_CRYPTO_KEY_EXCHANGE_INIT
Server -> Client: {server_pubkey[32]} (UNENCRYPTED)
Definition packet.h:317
@ PACKET_TYPE_ACIP_ERROR
Generic error response (Discovery Server -> Client)
Definition packet.h:404
@ PACKET_TYPE_AUDIO
Single audio packet (legacy)
Definition packet.h:291
@ PACKET_TYPE_CRYPTO_KEY_EXCHANGE_RESP
Client -> Server: {client_pubkey[32]} (UNENCRYPTED)
Definition packet.h:319
@ PACKET_TYPE_CRYPTO_REKEY_COMPLETE
Initiator -> Responder: Empty (encrypted with NEW key, but still handshake)
Definition packet.h:340
@ PACKET_TYPE_SERVER_STATE
Server sends current state to clients.
Definition packet.h:310
@ PACKET_TYPE_ACIP_STRING_RESERVE
Reserve session string (Client -> Discovery Server)
Definition packet.h:393
@ PACKET_TYPE_CRYPTO_AUTH_FAILED
Server -> Client: "authentication failed" (UNENCRYPTED)
Definition packet.h:325
@ PACKET_TYPE_ENCRYPTED
Encrypted packet (after handshake completion)
Definition packet.h:333
@ PACKET_TYPE_CRYPTO_REKEY_REQUEST
Initiator -> Responder: {new_ephemeral_pk[32]} (UNENCRYPTED during rekey)
Definition packet.h:336
@ PACKET_TYPE_SIZE_MESSAGE
Terminal size message.
Definition packet.h:346
@ PACKET_TYPE_REMOTE_LOG
Bidirectional remote logging packet.
Definition packet.h:354
@ PACKET_TYPE_CRYPTO_SERVER_AUTH_RESP
Server -> Client: {HMAC[32]} server proves knowledge (UNENCRYPTED)
Definition packet.h:327
@ PACKET_TYPE_PROTOCOL_VERSION
Protocol version and capabilities negotiation.
Definition packet.h:283
@ PACKET_TYPE_CLEAR_CONSOLE
Server tells client to clear console.
Definition packet.h:308
@ PACKET_TYPE_CRYPTO_NO_ENCRYPTION
Client -> Server: "I want to proceed without encryption" (UNENCRYPTED)
Definition packet.h:331
@ PACKET_TYPE_ACIP_SESSION_CREATE
Create new session (Client -> Discovery Server)
Definition packet.h:369
@ PACKET_TYPE_ACIP_STRING_RESERVED
String reserved response (Discovery Server -> Client)
Definition packet.h:395
@ PACKET_TYPE_ACIP_DISCOVERY_PING
Discovery server ping (keepalive)
Definition packet.h:402
@ PACKET_TYPE_CRYPTO_AUTH_CHALLENGE
Server -> Client: {nonce[32]} (UNENCRYPTED)
Definition packet.h:321
@ PACKET_TYPE_ASCII_FRAME
Complete ASCII frame with all metadata.
Definition packet.h:286
@ PACKET_TYPE_CRYPTO_PARAMETERS
Server -> Client: Chosen algorithms + data sizes (UNENCRYPTED)
Definition packet.h:315
@ PACKET_TYPE_ACIP_SESSION_LOOKUP
Lookup session by string (Client -> Discovery Server)
Definition packet.h:373
@ PACKET_TYPE_CRYPTO_CAPABILITIES
Client -> Server: Supported crypto algorithms (UNENCRYPTED)
Definition packet.h:313
@ PACKET_TYPE_ACIP_SESSION_LEAVE
Leave session (Client -> Discovery Server)
Definition packet.h:381
@ PACKET_TYPE_ACIP_WEBRTC_SDP
WebRTC SDP offer/answer (bidirectional)
Definition packet.h:388
@ PACKET_TYPE_ACIP_SESSION_JOIN
Join existing session (Client -> Discovery Server)
Definition packet.h:377
@ PACKET_TYPE_ACIP_SESSION_CREATED
Session created response (Discovery Server -> Client)
Definition packet.h:371
@ PACKET_TYPE_ACIP_STRING_RELEASE
Release string reservation (Client -> Discovery Server)
Definition packet.h:399
@ PACKET_TYPE_CLIENT_JOIN
Client announces capability to send media.
Definition packet.h:300
@ PACKET_TYPE_CLIENT_CAPABILITIES
Client reports terminal capabilities.
Definition packet.h:293
@ PACKET_TYPE_ACIP_STRING_RENEW
Renew string reservation (Client -> Discovery Server)
Definition packet.h:397
@ PACKET_TYPE_ERROR_MESSAGE
Error packet with asciichat_error_t code and human-readable message.
Definition packet.h:352
@ PACKET_TYPE_PING
Keepalive ping packet.
Definition packet.h:295
@ PACKET_TYPE_AUDIO_BATCH
Batched audio packets for efficiency.
Definition packet.h:343
@ PACKET_TYPE_CRYPTO_REKEY_RESPONSE
Responder -> Initiator: {new_ephemeral_pk[32]} (UNENCRYPTED during rekey)
Definition packet.h:338
@ PACKET_TYPE_ACIP_SESSION_JOINED
Session joined response (Discovery Server -> Client)
Definition packet.h:379
@ PACKET_TYPE_STREAM_STOP
Client stops sending media.
Definition packet.h:306
@ PACKET_TYPE_ACIP_SESSION_END
End session (Host -> Discovery Server)
Definition packet.h:383
int socket_t
Socket handle type (POSIX: int)
Definition socket.h:50
#define PACKED_ATTR
Packed structure attribute (POSIX: attribute((packed)))
📝 Logging API with multiple log levels and terminal output control
Cross-platform socket interface for ascii-chat.
ASCII frame packet structure (Packet Type 2)
Definition packet.h:740
Audio batch packet structure (Packet Type 28)
Definition packet.h:796
Authentication failure packet structure.
Definition packet.h:674
Client information packet structure.
Definition packet.h:545
Client list packet structure.
Definition packet.h:582
Crypto capabilities packet structure (Packet Type 14)
Definition packet.h:844
Cryptographic context structure.
Crypto parameters packet structure (Packet Type 15)
Definition packet.h:873
Error packet structure carrying error code and textual description.
Definition packet.h:619
Image frame packet structure (Packet Type 3)
Definition packet.h:768
Packet envelope containing received packet data.
Definition packet.h:980
Network packet header structure.
Definition packet.h:490
Protocol version negotiation packet structure (Packet Type 1)
Definition packet.h:710
Remote log packet structure carrying log level and message text.
Definition packet.h:633
Server state packet structure.
Definition packet.h:598
Terminal size update packet.
Definition packet.h:529
Stream header packet structure.
Definition packet.h:564
Terminal capabilities packet structure (Packet Type 5)
Definition packet.h:909