Skip to content

File syn_udp.c

FileList > net > syn_udp.c

Go to the source code of this file

Zero-Alloc Native UDP Demuxing Engine & Task-Blocking Layer Implementation.

  • #include "syntropic/net/syn_udp.h"
  • #include "syntropic/sched/syn_sched.h"
  • #include "syntropic/sched/syn_task.h"
  • #include "syntropic/util/syn_pack.h"
  • #include <string.h>

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.

Public Functions Documentation

function syn_udp_bind

Bind UDP socket to local port.

SYN_UdpSocket * syn_udp_bind (
    SYN_UDP * udp,
    uint16_t local_port
) 

Parameters:

  • udp Pointer to UDP stack instance.
  • local_port Port 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.

uint16_t syn_udp_checksum (
    uint32_t src_ip,
    uint32_t dst_ip,
    const uint8_t * udp_seg,
    size_t len
) 

Parameters:

  • src_ip Source 32-bit IPv4 address.
  • dst_ip Destination 32-bit IPv4 address.
  • udp_seg Pointer to raw UDP segment bytes.
  • len UDP segment length in bytes.

Returns:

Computed 16-bit UDP checksum.


function syn_udp_init

Initialize UDP Stack.

SYN_Status syn_udp_init (
    SYN_UDP * udp,
    SYN_ETH * eth
) 

Parameters:

  • udp Pointer to UDP stack instance.
  • eth Pointer to Ethernet interface instance.

Returns:

SYN_OK on success.


function syn_udp_process_packet

Process incoming UDP IPv4 packet.

SYN_Status syn_udp_process_packet (
    SYN_UDP * udp,
    const uint8_t * ip_packet,
    size_t len
) 

Parameters:

  • udp Pointer to UDP stack instance.
  • ip_packet Pointer to raw IPv4 packet.
  • len IPv4 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:

  • udp Pointer to UDP stack.
  • src_port Source UDP port.
  • dst_ip Destination IPv4 address.
  • dst_port Destination UDP port.
  • data Pointer to payload data buffer.
  • data_len Payload byte length.
  • tx_out Output Ethernet frame buffer.
  • tx_len Pointer to receive final Ethernet frame length.

Returns:

SYN_OK on success.


function syn_udp_unbind

Unbind and release a UDP socket slot.

void syn_udp_unbind (
    SYN_UdpSocket * sock
) 

Parameters:

  • sock Pointer to UDP socket slot.


The documentation for this class was generated from the following file src/syntropic/net/syn_udp.c