Network Packet
The network packet is the core of the network API. Each time we send or receive a packet, a new packet is created to hold its data and be passed to the API's function.
This packet's design is inspired by Linux's socket buffer interface. Even though this is a heavily simplified version of it, the philosophy remains the same:
- The packet's content is hidden after its metadata struct
- changes to the packet can only be done incrementally (similar to a stack)
◆ packet_peek_literal
◆ packet_pop_literal
◆ packet_put_literal
◆ packet_clone()
| struct packet * packet_clone |
( |
const struct packet * |
packet | ) |
|
The packet's content as well as the current offsets will be duplicated, so that one can use a duplicated packet just like the original one.
◆ packet_header_size()
| static size_t packet_header_size |
( |
const struct packet * |
packet | ) |
|
|
inlinestatic |
- Returns
- the size of the packet's header
◆ packet_payload()
| static void * packet_payload |
( |
const struct packet * |
packet | ) |
|
|
inlinestatic |
- Returns
- the sart of the packet's payload (L4)
◆ packet_payload_size()
| static size_t packet_payload_size |
( |
const struct packet * |
packet | ) |
|
|
inlinestatic |
- Returns
- the size of the packet's payload
◆ packet_peek()
| size_t packet_peek |
( |
struct packet * |
packet, |
|
|
void * |
data, |
|
|
size_t |
size |
|
) |
| |
- Returns
- The number of bytes actually read.
◆ packet_pop()
| size_t packet_pop |
( |
struct packet * |
packet, |
|
|
void * |
data, |
|
|
size_t |
size |
|
) |
| |
Popped data cannot be re-read afterwards.
- Returns
- The number of bytes actually read.
◆ packet_read_size()
| static size_t packet_read_size |
( |
const struct packet * |
packet | ) |
|
|
inlinestatic |
- Returns
- The current number of bytes that can be read from the packet
◆ packet_size()
| static size_t packet_size |
( |
const struct packet * |
packet | ) |
|
|
inlinestatic |
- Returns
- The current number of bytes placed into the packet