47 lines
934 B
C
47 lines
934 B
C
|
|
#pragma once
|
||
|
|
|
||
|
|
#include <cstdint>
|
||
|
|
|
||
|
|
// Port for TCP Control & File Transfer
|
||
|
|
constexpr int FILE_TRANSFER_PORT = 8889;
|
||
|
|
|
||
|
|
enum class PacketType : uint8_t {
|
||
|
|
// Control Events
|
||
|
|
Handshake = 0x01,
|
||
|
|
MouseEvent = 0x02,
|
||
|
|
KeyboardEvent = 0x03,
|
||
|
|
|
||
|
|
// File Transfer
|
||
|
|
FileHeader = 0x10, // Metadata: Name, Size
|
||
|
|
FileData = 0x11, // Chunk of data
|
||
|
|
FileEnd = 0x12, // End of transfer
|
||
|
|
FileAck = 0x13, // Acknowledge receipt
|
||
|
|
FileError = 0x14 // Error during transfer
|
||
|
|
|
||
|
|
,
|
||
|
|
FolderHeader = 0x20,
|
||
|
|
DirEntry = 0x21,
|
||
|
|
FileHeaderV2 = 0x22,
|
||
|
|
FolderEnd = 0x23
|
||
|
|
};
|
||
|
|
|
||
|
|
#pragma pack(push, 1)
|
||
|
|
|
||
|
|
struct CommonHeader {
|
||
|
|
uint8_t type;
|
||
|
|
uint32_t payloadSize;
|
||
|
|
};
|
||
|
|
|
||
|
|
// Payload for FileHeader (Type 0x10)
|
||
|
|
struct FileMetadata {
|
||
|
|
uint64_t fileSize;
|
||
|
|
char fileName[256]; // UTF-8 encoded
|
||
|
|
};
|
||
|
|
|
||
|
|
// Payload for FileAck (Type 0x13)
|
||
|
|
struct FileAckPayload {
|
||
|
|
uint8_t status; // 0 = OK, 1 = Error
|
||
|
|
};
|
||
|
|
|
||
|
|
#pragma pack(pop)
|