2022-01-24 03:28:16 +00:00
|
|
|
#ifndef LAIKA_PEER_H
|
|
|
|
#define LAIKA_PEER_H
|
|
|
|
|
|
|
|
#include "laika.h"
|
|
|
|
#include "lsocket.h"
|
|
|
|
#include "lpacket.h"
|
|
|
|
#include "lpolllist.h"
|
|
|
|
|
|
|
|
struct sLaika_peer {
|
2022-01-25 02:50:14 +00:00
|
|
|
struct sLaika_socket sock; /* DO NOT MOVE THIS. this member HAS TO BE FIRST so that typecasting sLaika_peer* to sLaika_sock* works as intended */
|
2022-01-24 03:28:16 +00:00
|
|
|
struct sLaika_pollList *pList; /* pollList we're active in */
|
2022-01-25 03:46:29 +00:00
|
|
|
void (*pktHandler)(struct sLaika_peer *peer, uint8_t id, void *uData);
|
2022-01-25 02:57:54 +00:00
|
|
|
void *uData; /* data to be passed to pktHandler */
|
|
|
|
size_t *pktSizeTable; /* const table to pull pkt size data from */
|
2022-01-24 03:28:16 +00:00
|
|
|
size_t pktSize; /* current pkt size */
|
2022-01-25 03:46:29 +00:00
|
|
|
uint8_t pktID; /* current pkt ID */
|
2022-01-25 02:50:14 +00:00
|
|
|
bool setPollOut; /* is EPOLLOUT/POLLOUT is set on sock's pollfd ? */
|
2022-01-24 03:28:16 +00:00
|
|
|
};
|
|
|
|
|
2022-01-25 03:46:29 +00:00
|
|
|
struct sLaika_peer *laikaS_newPeer(void (*pktHandler)(struct sLaika_peer *peer, uint8_t id, void *uData), size_t *pktSizeTable, struct sLaika_pollList *pList, void *uData);
|
2022-01-24 03:28:16 +00:00
|
|
|
void laikaS_freePeer(struct sLaika_peer *peer);
|
|
|
|
|
|
|
|
bool laikaS_handlePeerIn(struct sLaika_peer *peer);
|
|
|
|
bool laikaS_handlePeerOut(struct sLaika_peer *peer);
|
|
|
|
|
|
|
|
#endif
|