ascii-chat 0.6.0
Real-time terminal-based video chat with ASCII art conversion
Loading...
Searching...
No Matches
packet.c File Reference

📦 Packet protocol handler with CRC validation, encryption, and compression More...

Go to the source code of this file.

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 return parsed information.
 
asciichat_error_t packet_validate_crc32 (const void *data, size_t len, uint32_t expected_crc)
 Validate packet CRC32.
 
asciichat_error_t packet_send (socket_t sockfd, packet_type_t type, const void *data, size_t len)
 Send a packet with proper header and CRC32.
 
asciichat_error_t packet_receive (socket_t sockfd, packet_type_t *type, void **data, size_t *len)
 Receive a packet with proper header validation and CRC32 checking.
 
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.
 
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.
 
int send_ping_packet (socket_t sockfd)
 Send a ping packet.
 
int send_pong_packet (socket_t sockfd)
 Send a pong packet.
 
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 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.
 

Detailed Description

📦 Packet protocol handler with CRC validation, encryption, and compression

Definition in file packet.c.