File syn_udp.h¶
Go to the source code of this file
Zero-Alloc Native UDP Demuxing Engine & Task-Blocking Layer.
#include "syntropic/common/syn_defs.h"#include "syntropic/net/syn_eth.h"#include "syntropic/pt/syn_pt.h"#include "syntropic/sched/syn_sched.h"#include "syntropic/sched/syn_task.h"#include <stdbool.h>#include <stddef.h>#include <stdint.h>
Classes¶
| Type | Name |
|---|---|
| struct | SYN_UDP UDP protocol stack container instance. |
| struct | SYN_UdpHeader UDP packet header structure (8 bytes). |
| struct | SYN_UdpSocket UDP socket slot control block. |
Public Functions¶
| Type | Name |
|---|---|
| SYN_UdpSocket * | syn_udp_bind (SYN_UDP * udp, uint16_t local_port) Bind UDP socket to local port. |
| uint16_t | syn_udp_checksum (uint32_t src_ip, uint32_t dst_ip, const uint8_t * udp_seg, size_t len) Compute UDP 16-bit 1's complement checksum over pseudo-header and segment. |
| SYN_Status | syn_udp_init (SYN_UDP * udp, SYN_ETH * eth) Initialize UDP Stack. |
| SYN_Status | syn_udp_process_packet (SYN_UDP * udp, const uint8_t * ip_packet, size_t len) Process incoming UDP IPv4 packet. |
| int | syn_udp_sendto (SYN_UDP * udp, uint16_t src_port, uint32_t dst_ip, uint16_t dst_port, const uint8_t * data, size_t data_len, uint8_t * tx_out, size_t * tx_len) Construct outbound UDP packet into frame output buffer. |
| void | syn_udp_unbind (SYN_UdpSocket * sock) Unbind and release a UDP socket slot. |
Macros¶
| Type | Name |
|---|---|
| define | PT_UDP_BLOCK_READ (pt, task, sock, buf, max_len, bytes_read, src_ip, src_port) /* multi line expression */Protothread helper macro to block task until UDP packet arrives. |
| define | SYN_UDP_BUF_SIZE 256 |
| define | SYN_UDP_MAX_SOCKETS 4 |
Public Functions Documentation¶
function syn_udp_bind¶
Bind UDP socket to local port.
Parameters:
udpPointer to UDP stack instance.local_portPort number to bind.
Returns:
Pointer to allocated UDP socket slot, or NULL if capacity exceeded.
function syn_udp_checksum¶
Compute UDP 16-bit 1's complement checksum over pseudo-header and segment.
Parameters:
src_ipSource 32-bit IPv4 address.dst_ipDestination 32-bit IPv4 address.udp_segPointer to raw UDP segment bytes.lenUDP segment length in bytes.
Returns:
Computed 16-bit UDP checksum.
function syn_udp_init¶
Initialize UDP Stack.
Parameters:
udpPointer to UDP stack instance.ethPointer to Ethernet interface instance.
Returns:
SYN_OK on success.
function syn_udp_process_packet¶
Process incoming UDP IPv4 packet.
Parameters:
udpPointer to UDP stack instance.ip_packetPointer to raw IPv4 packet.lenIPv4 packet byte length.
Returns:
SYN_OK on success.
function syn_udp_sendto¶
Construct outbound UDP packet into frame output buffer.
int syn_udp_sendto (
SYN_UDP * udp,
uint16_t src_port,
uint32_t dst_ip,
uint16_t dst_port,
const uint8_t * data,
size_t data_len,
uint8_t * tx_out,
size_t * tx_len
)
Parameters:
udpPointer to UDP stack.src_portSource UDP port.dst_ipDestination IPv4 address.dst_portDestination UDP port.dataPointer to payload data buffer.data_lenPayload byte length.tx_outOutput Ethernet frame buffer.tx_lenPointer to receive final Ethernet frame length.
Returns:
SYN_OK on success.
function syn_udp_unbind¶
Unbind and release a UDP socket slot.
Parameters:
sockPointer to UDP socket slot.
Macro Definition Documentation¶
define PT_UDP_BLOCK_READ¶
Protothread helper macro to block task until UDP packet arrives.
#define PT_UDP_BLOCK_READ (
pt,
task,
sock,
buf,
max_len,
bytes_read,
src_ip,
src_port
) `/* multi line expression */`
Parameters:
ptProtothread state.taskTask instance.sockUDP socket pointer.bufDestination read buffer.max_lenMaximum bytes to read.bytes_readPointer to output size_t receiving count of read bytes.src_ipPointer to uint32_t receiving sender IP address.src_portPointer to uint16_t receiving sender port.
define SYN_UDP_BUF_SIZE¶
UDP socket internal RX buffer size in bytes
define SYN_UDP_MAX_SOCKETS¶
Maximum concurrent UDP bound sockets
The documentation for this class was generated from the following file src/syntropic/net/syn_udp.h