wip
This commit is contained in:
@@ -47,6 +47,8 @@ struct tcp_listener_t {
|
||||
tcp_connection_t *connections_waiting_for_ack;
|
||||
tcp_connection_t *connections_waiting_for_accept_head;
|
||||
tcp_connection_t *connections_waiting_for_accept_tail;
|
||||
tcp_connection_t *connections_waiting_for_fin;
|
||||
|
||||
void (*callback_ready_to_accept)(void*);
|
||||
void *callback_data;
|
||||
};
|
||||
@@ -60,6 +62,8 @@ struct tcp_connection_t {
|
||||
void (*callback_ready_to_recv)(void*);
|
||||
void (*callback_ready_to_send)(void*);
|
||||
|
||||
bool read_only;
|
||||
|
||||
ip_address_t peer_ip; // Network byte order
|
||||
uint16_t peer_port; // CPU byte order
|
||||
|
||||
@@ -92,16 +96,14 @@ struct tcp_connection_t {
|
||||
uint32_t snd_una; // SND.UNA from RFC 793
|
||||
// It's the sequence number of the last
|
||||
// byte sent and acknowledged by the peer.
|
||||
|
||||
tcp_segment_t out_header; // There must be no padding between
|
||||
char out_buffer[TCP_OUTPUT_BUFFER_SIZE]; // these two
|
||||
char in_buffer[TCP_INPUT_BUFFER_SIZE];
|
||||
|
||||
char out_buffer[TCP_OUTPUT_BUFFER_SIZE];
|
||||
char in_buffer[TCP_INPUT_BUFFER_SIZE];
|
||||
};
|
||||
static_assert(offsetof(tcp_connection_t, out_buffer) == offsetof(tcp_connection_t, out_header) + sizeof(tcp_segment_t));
|
||||
|
||||
typedef struct {
|
||||
void *data;
|
||||
int (*send)(void *data, ip_address_t ip, const void *src, size_t len);
|
||||
int (*send)(void *data, ip_address_t ip, const slice_list_t *slices, size_t num_slices);
|
||||
} tcp_callbacks_t;
|
||||
|
||||
struct tcp_state_t {
|
||||
@@ -123,5 +125,6 @@ tcp_listener_t *tcp_listener_create(tcp_state_t *state, uint16_t port, void *d
|
||||
void tcp_listener_destroy(tcp_listener_t *listener);
|
||||
tcp_connection_t *tcp_listener_accept(tcp_listener_t *listener, void *callback_data, void (*callback_ready_to_recv)(void*), void (*callback_ready_to_send)(void*));
|
||||
void tcp_connection_destroy(tcp_connection_t *connection);
|
||||
void tcp_connection_finish(tcp_connection_t *connection);
|
||||
size_t tcp_connection_recv(tcp_connection_t *connection, void *dst, size_t len);
|
||||
size_t tcp_connection_send(tcp_connection_t *connection, const void *src, size_t len);
|
||||
|
||||
Reference in New Issue
Block a user