Skip to content

File syn_tcp.c

FileList > net > syn_tcp.c

Go to the source code of this file

Zero-Alloc Native TCP State Machine & Segment Engine Implementation.

  • #include "syntropic/net/syn_tcp.h"
  • #include "syntropic/port/syn_port_system.h"
  • #include "syntropic/sched/syn_sched.h"
  • #include "syntropic/util/syn_assert.h"
  • #include "syntropic/util/syn_pack.h"
  • #include <string.h>

Public Functions

Type Name
uint16_t syn_tcp_checksum (uint32_t src_ip, uint32_t dst_ip, const uint8_t * tcp_seg, size_t len)
Compute TCP 16-bit 1's complement checksum over pseudo-header and segment.
SYN_Status syn_tcp_init (SYN_TCP * tcp, SYN_ETH * eth)
Initialize TCP Stack.
SYN_Status syn_tcp_listen (SYN_TCP * tcp, uint16_t port)
Bind TCP listener to port.
SYN_Status syn_tcp_process_packet (SYN_TCP * tcp, const uint8_t * ip_packet, size_t len, uint8_t * tx_out, size_t * tx_len)
Process incoming TCP IPv4 segment.

Public Static Functions

Type Name
void build_tcp_segment (SYN_TCP * tcp, SYN_TcpConn * conn, uint8_t flags, const uint8_t * payload, size_t payload_len, uint8_t * tx_out, size_t * tx_len)
Build outbound TCP segment frame into buffer.

Public Functions Documentation

function syn_tcp_checksum

Compute TCP 16-bit 1's complement checksum over pseudo-header and segment.

uint16_t syn_tcp_checksum (
    uint32_t src_ip,
    uint32_t dst_ip,
    const uint8_t * tcp_seg,
    size_t len
) 

Parameters:

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

Returns:

Computed 16-bit TCP checksum.


function syn_tcp_init

Initialize TCP Stack.

SYN_Status syn_tcp_init (
    SYN_TCP * tcp,
    SYN_ETH * eth
) 

Parameters:

  • tcp Pointer to TCP stack container.
  • eth Pointer to Ethernet interface engine instance.

Returns:

SYN_OK on success.


function syn_tcp_listen

Bind TCP listener to port.

SYN_Status syn_tcp_listen (
    SYN_TCP * tcp,
    uint16_t port
) 

Parameters:

  • tcp Pointer to TCP stack container.
  • port Port number to listen on.

Returns:

SYN_OK on success.


function syn_tcp_process_packet

Process incoming TCP IPv4 segment.

SYN_Status syn_tcp_process_packet (
    SYN_TCP * tcp,
    const uint8_t * ip_packet,
    size_t len,
    uint8_t * tx_out,
    size_t * tx_len
) 

Parameters:

  • tcp Pointer to TCP stack container.
  • ip_packet Pointer to raw IPv4 packet.
  • len IPv4 packet byte length.
  • tx_out Output buffer for immediate TCP reply segment if generated.
  • tx_len Pointer to receive output segment byte length.

Returns:

SYN_OK on success.


Public Static Functions Documentation

function build_tcp_segment

Build outbound TCP segment frame into buffer.

static void build_tcp_segment (
    SYN_TCP * tcp,
    SYN_TcpConn * conn,
    uint8_t flags,
    const uint8_t * payload,
    size_t payload_len,
    uint8_t * tx_out,
    size_t * tx_len
) 

Parameters:

  • tcp Pointer to TCP stack.
  • conn Pointer to TCP connection block.
  • flags TCP control flags bitmask.
  • payload Pointer to payload buffer.
  • payload_len Payload byte length.
  • tx_out Output Ethernet frame buffer.
  • tx_len Output Ethernet frame length pointer.


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