ascii-chat
Binary v0.15.83-53-gb711d8720
Library lib/v0.3.2-701-gb711d8720
Video chat in your terminal
Loading...
Searching...
No Matches
packet_decoder_t Struct Reference

When code needs to work with packet decoder, it keeps header_used, packet, used, size here instead of scattering it across globals. Initialization establishes the handles and sizes; teardown must release any allocation, lock, thread, or callback context recorded in those fields. Callback borrows a complete header+payload until it returns. It must copy any bytes it retains. An error is terminal: reset before feeding a new connection. More...

#include <include/ascii-chat/network/packet/decoder.h>

Data Fields

uint8_t header [sizeof(packet_header_t)]
size_t header_used
uint8_t * packet
size_t used
size_t size
size_t max_payload
 Zero uses MAX_PACKET_SIZE; set before the first feed.
bool failed

Detailed Description

When code needs to work with packet decoder, it keeps header_used, packet, used, size here instead of scattering it across globals. Initialization establishes the handles and sizes; teardown must release any allocation, lock, thread, or callback context recorded in those fields. Callback borrows a complete header+payload until it returns. It must copy any bytes it retains. An error is terminal: reset before feeding a new connection.

Incremental wire framing. Feed only on the owning connection's serial lane.

Definition at line 9 of file network/packet/decoder.h.

Field Documentation

◆ failed

bool packet_decoder_t::failed

Definition at line 15 of file network/packet/decoder.h.

Referenced by packet_decoder_feed().

◆ header

uint8_t packet_decoder_t::header[sizeof(packet_header_t)]

Definition at line 10 of file network/packet/decoder.h.

Referenced by packet_decoder_feed().

◆ header_used

size_t packet_decoder_t::header_used

Definition at line 11 of file network/packet/decoder.h.

Referenced by packet_decoder_feed(), and packet_decoder_pending().

◆ max_payload

size_t packet_decoder_t::max_payload

Zero uses MAX_PACKET_SIZE; set before the first feed.

Definition at line 14 of file network/packet/decoder.h.

Referenced by packet_decoder_feed().

◆ packet

uint8_t* packet_decoder_t::packet

Definition at line 12 of file network/packet/decoder.h.

Referenced by packet_decoder_feed(), and packet_decoder_reset().

◆ size

size_t packet_decoder_t::size

Definition at line 13 of file network/packet/decoder.h.

Referenced by packet_decoder_feed().

◆ used

size_t packet_decoder_t::used

Definition at line 13 of file network/packet/decoder.h.

Referenced by packet_decoder_feed().


The documentation for this struct was generated from the following file: