|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "message.h"
|
|
|
|
#include "client.h"
|
|
|
|
|
|
|
|
#include <stddef.h>
|
|
|
|
#include <netinet/in.h>
|
|
|
|
|
|
|
|
struct Connection {
|
|
|
|
int sockfd;
|
|
|
|
socklen_t addrlen;
|
|
|
|
struct sockaddr_in remote_addr;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct Connection*
|
|
|
|
connection_new(unsigned int source_port, const char* source_ip, unsigned int dest_port, const char* dest_ip);
|
|
|
|
|
|
|
|
struct Connection*
|
|
|
|
connection_poll_ready(struct Client* client);
|
|
|
|
|
|
|
|
void
|
|
|
|
connection_read(struct Connection* connection, union Message* resp);
|
|
|
|
|
|
|
|
void
|
|
|
|
req_finalize(struct Client* client, uint8_t cmdset, uint8_t cmdid, uint8_t hostbyte, bool need_ack, size_t length, union Request* req);
|
|
|
|
|
|
|
|
void
|
|
|
|
req_send(struct Connection* conn, union Request* req, size_t length);
|
|
|
|
|