File syn_tcp.h¶
Go to the source code of this file
Zero-Alloc Native TCP State Machine & Segment Engine.
#include "syntropic/common/syn_defs.h"#include "syntropic/net/syn_eth.h"#include "syntropic/pt/syn_pt.h"#include "syntropic/sched/syn_task.h"#include <stdbool.h>#include <stddef.h>#include <stdint.h>
Classes¶
| Type | Name |
|---|---|
| struct | SYN_TCP Top-level TCP stack instance container. |
| struct | SYN_TcpConn Single TCP socket connection control block. |
| struct | SYN_TcpHeader TCP packet header structure. |
Public Types¶
| Type | Name |
|---|---|
| enum | SYN_TcpState |
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. |
Macros¶
| Type | Name |
|---|---|
| define | PT_TCP_BLOCK_READ (pt, task, conn, buf, max_len, bytes_read) /* multi line expression */Protothread helper macro to block task until TCP data is available. |
| define | SYN_TCP_BUF_SIZE 512 |
| define | SYN_TCP_FLAG_ACK 0x10 |
| define | SYN_TCP_FLAG_FIN 0x01 |
| define | SYN_TCP_FLAG_PSH 0x08 |
| define | SYN_TCP_FLAG_RST 0x04 |
| define | SYN_TCP_FLAG_SYN 0x02 |
| define | SYN_TCP_MAX_CONNS 1 |
Public Types Documentation¶
enum SYN_TcpState¶
enum SYN_TcpState {
SYN_TCP_CLOSED = 0,
SYN_TCP_LISTEN = 1,
SYN_TCP_SYN_RCVD = 2,
SYN_TCP_ESTABLISHED = 3,
SYN_TCP_FIN_WAIT = 4,
SYN_TCP_CLOSE_WAIT = 5
};
TCP Connection State Machine Enum.
Public Functions Documentation¶
function syn_tcp_checksum¶
Compute TCP 16-bit 1's complement checksum over pseudo-header and segment.
Parameters:
src_ipSource 32-bit IPv4 address.dst_ipDestination 32-bit IPv4 address.tcp_segPointer to raw TCP segment bytes.lenTCP segment length in bytes.
Returns:
Computed 16-bit TCP checksum.
function syn_tcp_init¶
Initialize TCP Stack.
Parameters:
tcpPointer to TCP stack container.ethPointer to Ethernet interface engine instance.
Returns:
SYN_OK on success.
function syn_tcp_listen¶
Bind TCP listener to port.
Parameters:
tcpPointer to TCP stack container.portPort 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:
tcpPointer to TCP stack container.ip_packetPointer to raw IPv4 packet.lenIPv4 packet byte length.tx_outOutput buffer for immediate TCP reply segment if generated.tx_lenPointer to receive output segment byte length.
Returns:
SYN_OK on success.
Macro Definition Documentation¶
define PT_TCP_BLOCK_READ¶
Protothread helper macro to block task until TCP data is available.
#define PT_TCP_BLOCK_READ (
pt,
task,
conn,
buf,
max_len,
bytes_read
) `/* multi line expression */`
Parameters:
ptProtothread state.taskTask instance.connTCP connection pointer.bufDestination read buffer.max_lenMaximum bytes to read.bytes_readOutput variable receiving count of read bytes.
define SYN_TCP_BUF_SIZE¶
TCP RX/TX internal payload buffer size in bytes
define SYN_TCP_FLAG_ACK¶
Acknowledgment field significant flag
define SYN_TCP_FLAG_FIN¶
TCP Header Flags Finish flag: No more data from sender
define SYN_TCP_FLAG_PSH¶
Push function flag
define SYN_TCP_FLAG_RST¶
Reset connection flag
define SYN_TCP_FLAG_SYN¶
Synchronize sequence numbers flag
define SYN_TCP_MAX_CONNS¶
Maximum concurrent TCP connections
The documentation for this class was generated from the following file src/syntropic/net/syn_tcp.h