21#ifndef KERNEL_NET_PACKET_H
22#define KERNEL_NET_PACKET_H
25#include <kernel/types.h>
68 struct ipv4_header *ipv4;
78#define PACKET_ALIGN (sizeof(uint64_t))
135#define packet_put_literal(packet, data) packet_put(packet, &data, sizeof(data))
138#define packet_peek_literal(packet, data) \
139 packet_peek(packet, &data, sizeof(data))
142#define packet_pop_literal(packet, data) packet_pop(packet, &data, sizeof(data))
static size_t packet_read_size(const struct packet *packet)
Definition: packet.h:109
static size_t packet_size(const struct packet *packet)
Definition: packet.h:103
static void packet_mark_l2_start(struct packet *packet)
Set the current end of the packet as the start of the link layer.
Definition: packet.h:145
struct packet * packet_new(size_t packet_size)
Create a new packet.
Definition: packet.c:8
static void * packet_payload(const struct packet *packet)
Definition: packet.h:169
static size_t packet_header_size(const struct packet *packet)
Definition: packet.h:175
size_t packet_pop(struct packet *packet, void *data, size_t size)
Read data from the packet.
Definition: packet.c:83
size_t packet_peek(struct packet *packet, void *data, size_t size)
Read data from the packet.
Definition: packet.c:73
static void packet_mark_l3_start(struct packet *packet)
Set the current end of the packet as the start of the network layer.
Definition: packet.h:157
struct packet * packet_clone(const struct packet *packet)
Clone a packet.
Definition: packet.c:29
static void * packet_end(const struct packet *packet)
Find the end of the actual packet's content.
Definition: packet.h:115
static void packet_set_l3_size(struct packet *packet, size_t size)
Set the start of the packet payload N bytes after the network layer.
Definition: packet.h:163
error_t packet_put(struct packet *packet, const void *data, size_t size)
Append new data to the packet.
Definition: packet.c:62
static size_t packet_payload_size(const struct packet *packet)
Definition: packet.h:182
void packet_free(struct packet *packet)
Free a packet.
Definition: packet.c:51
static void * packet_start(const struct packet *packet)
Find the start of the actual packet's content.
Definition: packet.h:97
error_t packet_send(struct packet *packet)
Send the packet.
Definition: packet.c:56
static void packet_set_l2_size(struct packet *packet, size_t size)
Set the start of the network layer N bytes after the link layer.
Definition: packet.h:151
#define align_up(_value, _power)
Align _value to the next multiple of _power.
Definition: math.h:47
An ethernet device.
Definition: ethernet.h:50
Intrusive doubly-linked list node.
Definition: linked_list.h:27
A network packet.
Definition: packet.h:51
node_t rx_this
Definition: packet.h:75
union packet::@2 l2
The packet's link layer header.
union packet::@3 l3
The packet's network layer header.
void * payload
Start of the packet's content (L4 and beyond)
Definition: packet.h:73
size_t allocated_size
Size allocated for the packet.
Definition: packet.h:52
size_t popped
Number of popped bytes.
Definition: packet.h:54
struct ethernet_device * netdev
The internet device this packet went/is going through.
Definition: packet.h:57
size_t packet_size
Size of the contained packet.
Definition: packet.h:53