From 6ea68d219dc3a1bcc0deef1683e8442082025940 Mon Sep 17 00:00:00 2001 From: Amlal EL Mahrouss Date: Tue, 30 Jul 2024 10:01:42 +0200 Subject: [IMP] SCIKit: SharedInterface1 and UnknownInterface, both are defined in foreign SOs. [REFACTOR] IPCEP is just now IPC. Signed-off-by: Amlal EL Mahrouss --- Kernel/NetworkKit/IPC.hxx | 80 +++++++++++++++++++++++++++++++++++++ Kernel/NetworkKit/IPCEP.hxx | 79 ------------------------------------ Kernel/NetworkKit/NetworkDevice.hpp | 2 +- 3 files changed, 81 insertions(+), 80 deletions(-) create mode 100644 Kernel/NetworkKit/IPC.hxx delete mode 100644 Kernel/NetworkKit/IPCEP.hxx (limited to 'Kernel/NetworkKit') diff --git a/Kernel/NetworkKit/IPC.hxx b/Kernel/NetworkKit/IPC.hxx new file mode 100644 index 00000000..e53d8f1c --- /dev/null +++ b/Kernel/NetworkKit/IPC.hxx @@ -0,0 +1,80 @@ +/* ------------------------------------------- + + Copyright ZKA Technologies. + + File: IPC.hxx. + Purpose: IPC protocol. + +------------------------------------------- */ + +#ifndef _INC_IPC_ENDPOINT_HXX_ +#define _INC_IPC_ENDPOINT_HXX_ + +#include +#include + +/// @file IPC.hxx +/// @brief IPC protocol. + +/// IA separator. +#define cRemoteSeparator "." + +/// Interchange address, consists of PID:TEAM. +#define cRemoteInvalid "00:00" + +#define cRemoteHeaderMagic (0x4950434) + +namespace Kernel +{ + /// @brief 128-bit IPC address. + struct PACKED IPC_ADDRESS_STRUCT final + { + UInt64 ProcessID; + UInt64 ProcessTeam; + + //////////////////////////////////// + // some operators. + //////////////////////////////////// + + bool operator==(const IPC_ADDRESS_STRUCT& addr) noexcept + { + return addr.ProcessID == this->ProcessID && addr.ProcessTeam == this->ProcessTeam; + } + + bool operator==(IPC_ADDRESS_STRUCT& addr) noexcept + { + return addr.ProcessID == this->ProcessID && addr.ProcessTeam == this->ProcessTeam; + } + }; + + typedef struct IPC_ADDRESS_STRUCT IPCEPAddressKind; + + enum + { + eIPCEPLittleEndian = 0, + eIPCEPBigEndian = 1 + }; + + constexpr auto cIPCEPMsgSize = 6094U; + + /// @brief IPC connection header, message cannot be greater than 6K. + typedef struct IPC_MESSAGE_STRUCT final + { + UInt32 IpcHeaderMagic; // cRemoteHeaderMagic + UInt8 IpcEndianess; // 0 : LE, 1 : BE + SizeT IpcPacketSize; + IPCEPAddressKind IpcFrom; + IPCEPAddressKind IpcTo; + UInt32 IpcCRC32; + UInt32 IpcMsg; + UInt32 IpcMsgSz; + UInt8 IpcData[cIPCEPMsgSize]; + } PACKED IPC_MESSAGE_STRUCT; + + /// @brief Sanitize packet function + /// @retval true packet is correct. + /// @retval false packet is incorrect and process has crashed. + Bool ipc_sanitize_packet(IPC_MESSAGE_STRUCT* pckt); +} // namespace Kernel + +#endif // _INC_IPC_ENDPOINT_HXX_ diff --git a/Kernel/NetworkKit/IPCEP.hxx b/Kernel/NetworkKit/IPCEP.hxx deleted file mode 100644 index 7a7d8fc9..00000000 --- a/Kernel/NetworkKit/IPCEP.hxx +++ /dev/null @@ -1,79 +0,0 @@ -/* ------------------------------------------- - - Copyright ZKA Technologies. - - File: IPCEP.hxx. - Purpose: IPC protocol. - -------------------------------------------- */ - -#ifndef _INC_IPC_ENDPOINT_HXX_ -#define _INC_IPC_ENDPOINT_HXX_ - -#include -#include - -/// @brief IPC Endpoint Protocol (IPCEP for short). - -/// IA separator. -#define cRemoteSeparator "." - -/// Interchange address, consists of PID:TEAM. -#define cRemoteInvalid "00:00" - -#define cRemoteHeaderMagic (0x4950434) - -namespace Kernel -{ - /// @brief 128-bit IPC address. - struct PACKED IPCEPAddress final - { - UInt64 ProcessID; - UInt64 ProcessTeam; - - //////////////////////////////////// - // some operators. - //////////////////////////////////// - - bool operator==(const IPCEPAddress& addr) noexcept - { - return addr.ProcessID == this->ProcessID && addr.ProcessTeam == this->ProcessTeam; - } - - bool operator==(IPCEPAddress& addr) noexcept - { - return addr.ProcessID == this->ProcessID && addr.ProcessTeam == this->ProcessTeam; - } - }; - - typedef struct IPCEPAddress IPCEPAddressType; - - enum - { - eIPCEPLittleEndian = 0, - eIPCEPBigEndian = 1 - }; - - constexpr auto cIPCEPMsgSize = 6094U; - - /// @brief IPCEP connection header, message cannot be greater than 6K. - typedef struct IPCEPMessageHeader final - { - UInt32 IpcHeaderMagic; // cRemoteHeaderMagic - UInt8 IpcEndianess; // 0 : LE, 1 : BE - SizeT IpcPacketSize; - IPCEPAddressType IpcFrom; - IPCEPAddressType IpcTo; - UInt32 IpcCRC32; - UInt32 IpcMsg; - UInt32 IpcMsgSz; - UInt8 IpcData[cIPCEPMsgSize]; - } PACKED IPCEPMessageHeader; - - /// @brief Sanitize packet function - /// @retval true packet is correct. - /// @retval false packet is incorrect and process has crashed. - Bool ipc_sanitize_packet(IPCEPMessageHeader* pckt); -} // namespace Kernel - -#endif // _INC_IPC_ENDPOINT_HXX_ diff --git a/Kernel/NetworkKit/NetworkDevice.hpp b/Kernel/NetworkKit/NetworkDevice.hpp index 956475aa..eed5f071 100644 --- a/Kernel/NetworkKit/NetworkDevice.hpp +++ b/Kernel/NetworkKit/NetworkDevice.hpp @@ -62,7 +62,7 @@ namespace Kernel /// @brief PPP device. using PPPNetworkDevice = NetworkDevice; - /// @brief IPCEP device. + /// @brief IPC device. using IPCEPNetworkDevice = NetworkDevice; /// @brief GRPS device. -- cgit v1.2.3