36 lines
1.5 KiB
C++
36 lines
1.5 KiB
C++
#pragma once
|
|
|
|
#include <cstdint>
|
|
|
|
#include <lwip/ip_addr.h>
|
|
#include <lwip/pbuf.h>
|
|
|
|
constexpr auto ERR_OK = std::int8_t{0};
|
|
constexpr auto ERR_MEM = std::int8_t{-1};
|
|
constexpr auto ERR_ABRT = std::int8_t{-13};
|
|
constexpr auto ERR_RST = std::int8_t{-14};
|
|
constexpr auto TCP_WRITE_FLAG_COPY = std::uint8_t{1};
|
|
|
|
struct tcp_pcb {
|
|
void *argument{};
|
|
std::int8_t (*receive)(void *, tcp_pcb *, pbuf *, std::int8_t){};
|
|
std::int8_t (*sent)(void *, tcp_pcb *, std::uint16_t){};
|
|
std::int8_t (*poll)(void *, tcp_pcb *){};
|
|
void (*error)(void *, std::int8_t){};
|
|
std::int8_t (*connected)(void *, tcp_pcb *, std::int8_t){};
|
|
std::bool_t alive{};
|
|
};
|
|
|
|
auto tcp_new_ip_type(std::uint8_t type) -> tcp_pcb *;
|
|
auto tcp_arg(tcp_pcb *pcb, void *argument) -> void;
|
|
auto tcp_recv(tcp_pcb *pcb, std::int8_t (*callback)(void *, tcp_pcb *, pbuf *, std::int8_t)) -> void;
|
|
auto tcp_sent(tcp_pcb *pcb, std::int8_t (*callback)(void *, tcp_pcb *, std::uint16_t)) -> void;
|
|
auto tcp_poll(tcp_pcb *pcb, std::int8_t (*callback)(void *, tcp_pcb *), std::uint8_t interval) -> void;
|
|
auto tcp_err(tcp_pcb *pcb, void (*callback)(void *, std::int8_t)) -> void;
|
|
auto tcp_connect(tcp_pcb *pcb, ip_addr_t const *address, std::uint16_t port, std::int8_t (*callback)(void *, tcp_pcb *, std::int8_t)) -> std::int8_t;
|
|
auto tcp_write(tcp_pcb *pcb, void const *data, std::uint16_t size, std::uint8_t flags) -> std::int8_t;
|
|
auto tcp_output(tcp_pcb *pcb) -> std::int8_t;
|
|
auto tcp_recved(tcp_pcb *pcb, std::uint16_t size) -> void;
|
|
auto tcp_close(tcp_pcb *pcb) -> std::int8_t;
|
|
auto tcp_abort(tcp_pcb *pcb) -> void;
|