Packet (C-API)¶
This page describes the C implementation of Packets¶
-
group
PACKET Functions
-
A0_STATIC_INLINE void a0_packet_callback_call (a0_packet_callback_t callback, a0_packet_t pkt)
-
a0_err_t
a0_packet_init(a0_packet_t*) Initializes a packet. This includes setting the id.
-
a0_err_t
a0_packet_stats(a0_packet_t, a0_packet_stats_t*) Compute packet statistics.
-
a0_err_t
a0_packet_header_iterator_init(a0_packet_header_iterator_t*, a0_packet_t*) Initializes an iterator over all headers.
-
a0_err_t
a0_packet_header_iterator_next(a0_packet_header_iterator_t*, a0_packet_header_t *out) Emit the next header.
-
a0_err_t
a0_packet_header_iterator_next_match(a0_packet_header_iterator_t*, const char *key, a0_packet_header_t *out) Emit the next header with the given key.
-
a0_err_t
a0_packet_serialize(a0_packet_t, a0_alloc_t, a0_flat_packet_t *out) Serializes the packet to the allocated location.
Note: the header order will NOT be retained.
-
a0_err_t
a0_packet_deserialize(a0_flat_packet_t, a0_alloc_t, a0_packet_t *out_pkt, a0_buf_t *out_buf) Deserializes the flat packet into a normal packet.
-
a0_err_t
a0_packet_deep_copy(a0_packet_t, a0_alloc_t, a0_packet_t *out_pkt, a0_buf_t *out_buf) Deep copies the packet contents.
-
a0_err_t
a0_flat_packet_stats(a0_flat_packet_t, a0_packet_stats_t*) Compute packet statistics, for serialized packets.
-
a0_err_t
a0_flat_packet_id(a0_flat_packet_t, a0_uuid_t**) Retrieve the uuid within the flat packet.
Note: the result points into the flat packet. It is not copied out.
-
a0_err_t
a0_flat_packet_payload(a0_flat_packet_t, a0_buf_t*) Retrieve the payload within the flat packet.
Note: the result points into the flat packet. It is not copied out.
-
a0_err_t
a0_flat_packet_header(a0_flat_packet_t, size_t idx, a0_packet_header_t*) Retrieve the i-th header within the flat packet.
Note: the result points into the flat packet. It is not copied out.
-
a0_err_t
a0_flat_packet_header_iterator_init(a0_flat_packet_header_iterator_t*, a0_flat_packet_t*) Initializes an iterator over all headers.
-
a0_err_t
a0_flat_packet_header_iterator_next(a0_flat_packet_header_iterator_t*, a0_packet_header_t *out) Emit the next header.
-
a0_err_t
a0_flat_packet_header_iterator_next_match(a0_flat_packet_header_iterator_t*, const char *key, a0_packet_header_t *out) Emit the next header with the given key.
Variables
-
const char *
A0_DEP Packet header key used to annotate a dependence on another packet.
The value should be a packet id.
-
struct
a0_packet_header_t¶ - #include <packet.h>
A single packet header.
-
struct
a0_packet_headers_block_s¶ - #include <packet.h>
A headers block contains a list of headers, along with an optional pointer to the next block.
https://en.wikipedia.org/wiki/Unrolled_linked_list
This is meant to make it easier for abstractions to add additional headers without allocating heap space.
void foo(a0_packet_headers_block_t* caller_headers) { a0_packet_headers_block_t all_headers; all_headers.headers = additional_headers; all_headers.size = num_additional_headers; all_headers.next_block = caller_headers; bar(&all_headers); }
-
struct
a0_packet_t¶ - #include <packet.h>
A Packet is a unit of information used by protocols to transmit user data. There is a primary user payload, as well as key-value annotations, and a unique identifier.
-
struct
a0_flat_packet_t¶ - #include <packet.h>
A Flat Packet is a serialized Packet.
-
struct
a0_packet_callback_t¶ - #include <packet.h>
-
struct
a0_packet_id_callback_t¶ - #include <packet.h>
-
struct
a0_packet_stats_t¶ - #include <packet.h>
Various computed stats of a given packet.
-
struct
a0_packet_header_iterator_t¶ - #include <packet.h>
-
struct
a0_flat_packet_header_iterator_t¶ - #include <packet.h>
-