|
ascii-chat 0.6.0
Real-time terminal-based video chat with ASCII art conversion
|
Packet protocol implementation with encryption and compression support. More...
Go to the source code of this file.
Data Structures | |
| struct | packet_header_t |
| Network packet header structure. More... | |
| struct | size_packet_t |
| Terminal size update packet. More... | |
| struct | client_info_packet_t |
| Client information packet structure. More... | |
| struct | stream_header_t |
| Stream header packet structure. More... | |
| struct | client_list_packet_t |
| Client list packet structure. More... | |
| struct | server_state_packet_t |
| Server state packet structure. More... | |
| struct | error_packet_t |
| Error packet structure carrying error code and textual description. More... | |
| struct | remote_log_packet_t |
| Remote log packet structure carrying log level and message text. More... | |
| struct | auth_failure_packet_t |
| Authentication failure packet structure. More... | |
| struct | protocol_version_packet_t |
| Protocol version negotiation packet structure (Packet Type 1) More... | |
| struct | ascii_frame_packet_t |
| ASCII frame packet structure (Packet Type 2) More... | |
| struct | image_frame_packet_t |
| Image frame packet structure (Packet Type 3) More... | |
| struct | audio_batch_packet_t |
| Audio batch packet structure (Packet Type 28) More... | |
| struct | crypto_capabilities_packet_t |
| Crypto capabilities packet structure (Packet Type 14) More... | |
| struct | crypto_parameters_packet_t |
| Crypto parameters packet structure (Packet Type 15) More... | |
| struct | terminal_capabilities_packet_t |
| Terminal capabilities packet structure (Packet Type 5) More... | |
| struct | packet_envelope_t |
| Packet envelope containing received packet data. More... | |
Macros | |
| #define | REMOTE_LOG_FLAG_TRUNCATED 0x0001U |
| Remote log packet flag definitions. | |
Network Protocol Constants | |
| #define | LARGE_PACKET_THRESHOLD (100 * 1024) |
| Large packet size threshold (100KB) | |
| #define | MAX_PACKET_SIZE ((size_t)5 * 1024 * 1024) |
| Maximum packet size (5MB) | |
| #define | MAX_ERROR_MESSAGE_LENGTH 512 |
| Maximum error message length (512 bytes) | |
| #define | MAX_REMOTE_LOG_MESSAGE_LENGTH 512 |
| Maximum remote log message length (512 bytes) | |
Timeout Configuration Constants | |
Timeout constants for handling packets of different sizes. Large packets require extended timeouts for successful transmission. | |
| #define | BASE_SEND_TIMEOUT 5 |
| Base send timeout in seconds (5 seconds) | |
| #define | LARGE_PACKET_EXTRA_TIMEOUT_PER_MB 0.8 |
| Extra timeout per MB for large packets (0.8 seconds per MB) | |
| #define | MIN_CLIENT_TIMEOUT 10 |
| Minimum client timeout in seconds (10 seconds) | |
| #define | MAX_CLIENT_TIMEOUT 60 |
| Maximum client timeout in seconds (60 seconds) | |
Audio Batching Constants | |
Audio batching configuration for efficient audio transmission. Batched audio reduces packet overhead and improves bandwidth usage. | |
| #define | AUDIO_BATCH_COUNT 32 |
| Number of audio chunks per batch (4 chunks) | |
| #define | AUDIO_BATCH_SAMPLES (AUDIO_SAMPLES_PER_PACKET * AUDIO_BATCH_COUNT) |
| Total samples in audio batch (8192 samples) | |
| #define | AUDIO_BATCH_MS 186 |
| Audio batch duration in milliseconds (~186ms) | |
| #define | AUDIO_SAMPLES_PER_PACKET 256 |
| Samples per audio packet (256 samples) | |
Protocol Constants | |
| #define | PACKET_MAGIC 0xDEADBEEF |
| Packet magic number (0xDEADBEEF) | |
Multi-User Protocol Constants | |
| #define | ASCIICHAT_DEFAULT_DISPLAY_NAME "AsciiChatter" |
| Default display name for clients without a custom name. | |
Protocol Negotiation Constants | |
| #define | FEATURE_RLE_ENCODING 0x01 |
| Feature flags for protocol_version_packet_t. | |
| #define | FEATURE_DELTA_FRAMES 0x02 |
| Delta frame encoding (future) | |
Client Capability Flags | |
Bitmask flags for client capabilities in multi-user protocol. | |
| #define | CLIENT_CAP_VIDEO 0x01 |
| Client can send/receive video. | |
| #define | CLIENT_CAP_AUDIO 0x02 |
| Client can send/receive audio. | |
| #define | CLIENT_CAP_COLOR 0x04 |
| Client supports color rendering. | |
| #define | CLIENT_CAP_STRETCH 0x08 |
| Client can stretch frames to fill terminal. | |
Stream Type Flags | |
Bitmask flags for stream types in multi-user protocol. | |
| #define | STREAM_TYPE_VIDEO 0x01 |
| Video stream. | |
| #define | STREAM_TYPE_AUDIO 0x02 |
| Audio stream. | |
Crypto Algorithm Constants | |
Algorithm identifiers for key exchange, authentication, and encryption. Used in crypto handshake packet negotiation. | |
| #define | KEX_ALGO_X25519 0x01 |
| X25519 key exchange (Curve25519) | |
| #define | AUTH_ALGO_ED25519 0x01 |
| Ed25519 authentication (Edwards-curve signatures) | |
| #define | AUTH_ALGO_NONE 0x00 |
| No authentication (plaintext mode) | |
| #define | CIPHER_ALGO_XSALSA20_POLY1305 0x01 |
| XSalsa20-Poly1305 authenticated encryption. | |
Functions | |
Packet Validation Functions | |
| 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. | |
| asciichat_error_t | packet_validate_crc32 (const void *data, size_t len, uint32_t expected_crc) |
| Validate packet CRC32 checksum. | |
Basic Packet I/O Functions | |
| 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. | |
| 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. | |
Secure Packet I/O Functions | |
| 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. | |
| 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. | |
Legacy Packet I/O Functions | |
These functions provide basic packet I/O without encryption support. Use send_packet_secure() and receive_packet_secure() for encryption support. | |
| int | send_packet (socket_t sockfd, packet_type_t type, const void *data, size_t len) |
| Send a basic packet without encryption. | |
| int | receive_packet (socket_t sockfd, packet_type_t *type, void **data, size_t *len) |
| Receive a basic packet without encryption. | |
Protocol Packet Functions | |
Convenience functions for sending specific protocol packets. These functions construct the appropriate packet structure and send it over the socket. | |
| int | send_ping_packet (socket_t sockfd) |
| Send a ping packet (keepalive) | |
| int | send_pong_packet (socket_t sockfd) |
| Send a pong packet (keepalive response) | |
| int | send_clear_console_packet (socket_t sockfd) |
| Send a clear console packet. | |
| 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. | |
| 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. | |
| 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. | |
| 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. | |
| int | send_protocol_version_packet (socket_t sockfd, const protocol_version_packet_t *version) |
| Send protocol version negotiation packet. | |
| int | send_crypto_capabilities_packet (socket_t sockfd, const crypto_capabilities_packet_t *caps) |
| Send crypto capabilities packet. | |
| int | send_crypto_parameters_packet (socket_t sockfd, const crypto_parameters_packet_t *params) |
| Send crypto parameters packet. | |
| 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. | |
| 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. | |
| asciichat_error_t | send_ascii_frame_packet (socket_t sockfd, const char *frame_data, size_t frame_size) |
| Send ASCII frame packet. | |
| 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. | |
Packet protocol implementation with encryption and compression support.
Definition in file packet.h.