mirror of
https://github.com/CPunch/Laika.git
synced 2025-10-04 07:10:07 +00:00
Minor refactoring
This commit is contained in:
@@ -25,7 +25,7 @@ enum {
|
||||
struct sLaikaB_box {
|
||||
uint8_t *data;
|
||||
uint8_t *unlockedData;
|
||||
sLaikaV_vm vm;
|
||||
struct sLaikaV_vm vm;
|
||||
};
|
||||
|
||||
inline void laikaB_unlock() {
|
||||
|
@@ -121,4 +121,8 @@ enum {
|
||||
typedef uint8_t LAIKAPKT_ID;
|
||||
typedef uint16_t LAIKAPKT_SIZE;
|
||||
|
||||
#ifdef DEBUG
|
||||
const char* laikaD_getPacketName(LAIKAPKT_ID);
|
||||
#endif
|
||||
|
||||
#endif
|
26
lib/src/lpacket.c
Normal file
26
lib/src/lpacket.c
Normal file
@@ -0,0 +1,26 @@
|
||||
#include "lpacket.h"
|
||||
|
||||
#ifdef DEBUG
|
||||
const char* laikaD_getPacketName(LAIKAPKT_ID id) {
|
||||
const char *PKTNAMES[] = {
|
||||
"LAIKAPKT_VARPKT",
|
||||
"LAIKAPKT_HANDSHAKE_REQ",
|
||||
"LAIKAPKT_HANDSHAKE_RES",
|
||||
"LAIKAPKT_TUNNEL_OPEN",
|
||||
"LAIKAPKT_TUNNEL_CLOSE",
|
||||
"LAIKAPKT_TUNNEL_CONNECTION_ADD",
|
||||
"LAIKAPKT_TUNNEL_CONNECTION_RMV",
|
||||
"LAIKAPKT_TUNNEL_CONNECTION_DATA",
|
||||
"LAIKAPKT_SHELL_OPEN",
|
||||
"LAIKAPKT_SHELL_CLOSE",
|
||||
"LAIKAPKT_SHELL_DATA",
|
||||
"LAIKAPKT_AUTHENTICATED_HANDSHAKE_REQ",
|
||||
"LAIKAPKT_AUTHENTICATED_ADD_PEER_RES",
|
||||
"LAIKAPKT_AUTHENTICATED_RMV_PEER_RES",
|
||||
"LAIKAPKT_AUTHENTICATED_SHELL_OPEN_REQ",
|
||||
"LAIKAPKT_AUTHENTICATED_TUNNEL_OPEN_REQ"
|
||||
};
|
||||
|
||||
return id >= LAIKAPKT_MAXNONE ? "LAIKAPKT_UNKNOWN" : PKTNAMES[id];
|
||||
}
|
||||
#endif
|
@@ -166,6 +166,7 @@ bool laikaS_handlePeerIn(struct sLaika_socket *sock) {
|
||||
|
||||
/* read packet ID */
|
||||
peer->pktID = laikaS_readByte(&peer->sock);
|
||||
LAIKA_DEBUG("%s", laikaD_getPacketName(peer->pktID));
|
||||
|
||||
/* LAIKAPKT_VARPKT's body is unencrypted, and handled by this switch statement. LAIKAPKT_VARPKT is
|
||||
also likely not to be defined in our pktSizeTable. the LAIKAPKT_VARPKT case calls laikaS_startInPacket
|
||||
|
@@ -105,6 +105,8 @@ struct sLaika_tunnelConnection *laikaT_newConnection(struct sLaika_tunnel *tunne
|
||||
NULL
|
||||
);
|
||||
|
||||
laikaS_setNonBlock(&con->sock);
|
||||
|
||||
con->tunnel = tunnel;
|
||||
con->next = NULL;
|
||||
con->id = id;
|
||||
@@ -135,7 +137,7 @@ void laikaT_freeConnection(struct sLaika_tunnelConnection *connection) {
|
||||
/* unlink from list */
|
||||
last->next = connection->next;
|
||||
} else { /* connectionHead was NULL, or connection *was* the connectionHead. */
|
||||
tunnel->connectionHead = NULL;
|
||||
tunnel->connectionHead = connection->next;
|
||||
}
|
||||
|
||||
/* tell peer connection is removed */
|
||||
|
Reference in New Issue
Block a user