mirror of
https://github.com/CPunch/Laika.git
synced 2025-10-01 22:10:05 +00:00
Added laikaP_pushOutQueue, minor refactoring
- sLaika_pollList now holds an outQueue, if events are sent to a peer, the pollList will keep track so the caller (cnc, bot, etc) can handle each pollOut for the queued peers.
This commit is contained in:
@@ -31,14 +31,14 @@ enum {
|
||||
/* layout of LAIKAPKT_STAGE2_HANDSHAKE_REQ
|
||||
* uint8_t peerType;
|
||||
*/
|
||||
LAIKAPKT_AUTHENTICATED_ADD_BOT, /* notification that a bot has connected to the cnc */
|
||||
/* layout of LAIKAPKT_AUTHENTICATED_ADD_BOT
|
||||
LAIKAPKT_AUTHENTICATED_ADD_PEER, /* notification that a peer has connected to the cnc */
|
||||
/* layout of LAIKAPKT_AUTHENTICATED_ADD_PEER
|
||||
* uint8_t pubKey[crypto_kx_PUBLICKEYBYTES]; -- pubkey of said bot
|
||||
* uint8_t peerType;
|
||||
* -- reserved info later (machine info including hostname, OS, machineType, ip, etc.)
|
||||
*/
|
||||
LAIKAPKT_AUTHENTICATED_RMV_BOT, /* notification that a bot has disconnected from the cnc */
|
||||
/* layout of LAIKAPKT_AUTHENTICATED_RMV_BOT
|
||||
LAIKAPKT_AUTHENTICATED_RMV_PEER, /* notification that a peer has disconnected from the cnc */
|
||||
/* layout of LAIKAPKT_AUTHENTICATED_RMV_PEER
|
||||
* uint8_t pubKey[crypto_kx_PUBLICKEYBYTES]; -- pubkey of said bot
|
||||
* uint8_t peerType;
|
||||
*/
|
||||
|
@@ -16,8 +16,11 @@ struct sLaika_pollEvent {
|
||||
bool pollOut;
|
||||
};
|
||||
|
||||
struct sLaika_peer;
|
||||
|
||||
struct sLaika_pollList {
|
||||
struct hashmap *sockets;
|
||||
struct sLaika_peer **outQueue; /* holds peers which have data needed to be sent */
|
||||
struct sLaika_pollEvent *revents;
|
||||
#ifdef LAIKA_USE_EPOLL
|
||||
/* epoll */
|
||||
@@ -29,8 +32,10 @@ struct sLaika_pollList {
|
||||
int fdCapacity;
|
||||
int fdCount;
|
||||
#endif
|
||||
int reventCapacity;
|
||||
int reventCap;
|
||||
int reventCount;
|
||||
int outCap;
|
||||
int outCount;
|
||||
};
|
||||
|
||||
void laikaP_initPList(struct sLaika_pollList *pList);
|
||||
@@ -40,6 +45,8 @@ void laikaP_rmvSock(struct sLaika_pollList *pList, struct sLaika_socket *sock);
|
||||
void laikaP_addPollOut(struct sLaika_pollList *pList, struct sLaika_socket *sock);
|
||||
void laikaP_rmvPollOut(struct sLaika_pollList *pList, struct sLaika_socket *sock);
|
||||
void laikaP_iterList(struct sLaika_pollList *pList, tLaika_pollIter iter, void *uData);
|
||||
void laikaP_pushOutQueue(struct sLaika_pollList *pList, struct sLaika_peer *peer);
|
||||
void laikaP_resetOutQueue(struct sLaika_pollList *pList);
|
||||
|
||||
struct sLaika_pollEvent *laikaP_poll(struct sLaika_pollList *pList, int timeout, int *nevents);
|
||||
|
||||
|
Reference in New Issue
Block a user