summaryrefslogtreecommitdiffhomepage
path: root/dev/kernel/NetworkKit/IPC.h
diff options
context:
space:
mode:
authorAmlal El Mahrouss <amlal.elmahrouss@icloud.com>2025-03-23 19:13:48 +0100
committerAmlal El Mahrouss <amlal.elmahrouss@icloud.com>2025-03-23 19:15:17 +0100
commita13e1c0911c0627184bc38f18c7fdda64447b3ad (patch)
tree073a62c09bf216e85a3f310376640fa1805147f9 /dev/kernel/NetworkKit/IPC.h
parent149fa096eb306d03686b3b67e813cf1a78e08cd0 (diff)
meta(kernel): Reworked repository's filesystem structure.
Removing useless parts of the project too. Signed-off-by: Amlal El Mahrouss <amlal.elmahrouss@icloud.com>
Diffstat (limited to 'dev/kernel/NetworkKit/IPC.h')
-rw-r--r--dev/kernel/NetworkKit/IPC.h91
1 files changed, 91 insertions, 0 deletions
diff --git a/dev/kernel/NetworkKit/IPC.h b/dev/kernel/NetworkKit/IPC.h
new file mode 100644
index 00000000..e8f0898f
--- /dev/null
+++ b/dev/kernel/NetworkKit/IPC.h
@@ -0,0 +1,91 @@
+/* -------------------------------------------
+
+ Copyright (C) 2024-2025, Amlal EL Mahrouss, all rights reserved..
+
+ File: IPC.h.
+ Purpose: IPC protocol.
+
+------------------------------------------- */
+
+#ifndef INC_IPC_H
+#define INC_IPC_H
+
+#include <NewKit/Defines.h>
+#include <NewKit/KString.h>
+#include <HintsKit/CompilerHint.h>
+
+/// @file IPC.h
+/// @brief IPC comm. protocol.
+
+/// IA separator.
+#define kIPCRemoteSeparator ":"
+
+/// Interchange address, consists of PID:TEAM.
+#define kIPCRemoteInvalid "00:00"
+
+#define kIPCHeaderMagic (0x4950434)
+
+namespace NeOS
+{
+ struct IPC_ADDR;
+ struct IPC_MSG;
+
+ /// @brief 128-bit IPC address.
+ struct PACKED IPC_ADDR final
+ {
+ UInt64 UserProcessID;
+ UInt64 UserProcessTeam;
+
+ ////////////////////////////////////
+ // some operators.
+ ////////////////////////////////////
+
+ bool operator==(const IPC_ADDR& addr) noexcept;
+
+ bool operator==(IPC_ADDR& addr) noexcept;
+
+ bool operator!=(const IPC_ADDR& addr) noexcept;
+
+ bool operator!=(IPC_ADDR& addr) noexcept;
+ };
+
+ typedef struct IPC_ADDR IPC_ADDR;
+
+ enum
+ {
+ kIPCLittleEndian = 0,
+ kIPCBigEndian = 1,
+ kIPCMixedEndian = 2,
+ };
+
+ constexpr inline auto kIPCMsgSize = 6094U;
+
+ /// @brief IPC connection header, message cannot be greater than 6K.
+ typedef struct IPC_MSG final
+ {
+ UInt32 IpcHeaderMagic; // cRemoteHeaderMagic
+ UInt8 IpcEndianess; // 0 : LE, 1 : BE
+ SizeT IpcPacketSize;
+ IPC_ADDR IpcFrom;
+ IPC_ADDR IpcTo;
+ UInt32 IpcCRC32;
+ UInt32 IpcMsg;
+ UInt32 IpcMsgSz;
+ UInt8 IpcData[kIPCMsgSize];
+
+ /// @brief Passes the message to target, could be anything, HTTP packet, JSON or whatever.
+ static Bool Pass(IPC_MSG* self, IPC_MSG* target) noexcept;
+ } PACKED IPC_MSG;
+
+ /// @brief Sanitize packet function
+ /// @retval true packet is correct.
+ /// @retval false packet is incorrect and process has crashed.
+ Bool ipc_sanitize_packet(_Input IPC_MSG* pckt_in);
+
+ /// @brief Construct packet function
+ /// @retval true packet is correct.
+ /// @retval false packet is incorrect and process has crashed.
+ Bool ipc_construct_packet(_Output _Input IPC_MSG** pckt_in);
+} // namespace NeOS
+
+#endif // INC_IPC_H