diff options
| author | Amlal El Mahrouss <amlal@nekernel.org> | 2025-11-24 03:02:43 +0100 |
|---|---|---|
| committer | Amlal El Mahrouss <amlal@nekernel.org> | 2025-11-24 03:02:43 +0100 |
| commit | 83d870e58457a1d335a1d9b9966a6a1887cc297b (patch) | |
| tree | 72888f88c7728c82f3f6df1f4f70591de15eab36 /dev/kernel/NetworkKit | |
| parent | ab37adbacf0f33845804c788b39680cd754752a8 (diff) | |
feat! breaking changes on kernel sources.
Signed-off-by: Amlal El Mahrouss <amlal@nekernel.org>
Diffstat (limited to 'dev/kernel/NetworkKit')
| -rw-r--r-- | dev/kernel/NetworkKit/IP.h | 76 | ||||
| -rw-r--r-- | dev/kernel/NetworkKit/IPC.h | 90 | ||||
| -rw-r--r-- | dev/kernel/NetworkKit/LTE.h | 16 | ||||
| -rw-r--r-- | dev/kernel/NetworkKit/MAC.h | 34 | ||||
| -rw-r--r-- | dev/kernel/NetworkKit/NetworkDevice.h | 83 | ||||
| -rw-r--r-- | dev/kernel/NetworkKit/NetworkDevice.inl | 32 |
6 files changed, 0 insertions, 331 deletions
diff --git a/dev/kernel/NetworkKit/IP.h b/dev/kernel/NetworkKit/IP.h deleted file mode 100644 index b19d132f..00000000 --- a/dev/kernel/NetworkKit/IP.h +++ /dev/null @@ -1,76 +0,0 @@ -/* ======================================== - - Copyright (C) 2024-2025, Amlal El Mahrouss, licensed under the Apache 2.0 license. - -======================================== */ - -#pragma once - -#include <KernelKit/DebugOutput.h> -#include <NeKit/Defines.h> -#include <NeKit/KString.h> -#include <NeKit/Ref.h> - -namespace Kernel { -class RawIPAddress6; -class RawIPAddress; -class IPFactory; - -class RawIPAddress final { - private: - explicit RawIPAddress(UInt8 bytes[4]); - ~RawIPAddress() = default; - - RawIPAddress& operator=(const RawIPAddress&) = delete; - RawIPAddress(const RawIPAddress&) = default; - - public: - UInt8* Address(); - - UInt8& operator[](const Size& index); - - BOOL operator==(const RawIPAddress& ipv6); - BOOL operator!=(const RawIPAddress& ipv6); - - private: - UInt8 fAddr[4]; - - friend IPFactory; // it is the one creating these addresses, thus this - // is why the constructors are private. -}; - -/** - * @brief IPv6 address. - */ -class RawIPAddress6 final { - private: - explicit RawIPAddress6(UInt8 Bytes[16]); - ~RawIPAddress6() = default; - - RawIPAddress6& operator=(const RawIPAddress6&) = delete; - RawIPAddress6(const RawIPAddress6&) = default; - - public: - UInt8* Address() { return fAddr; } - - UInt8& operator[](const Size& index); - - bool operator==(const RawIPAddress6& ipv6); - bool operator!=(const RawIPAddress6& ipv6); - - private: - UInt8 fAddr[16]; - - friend IPFactory; -}; - -/** - * @brief IP Creation helpers - */ -class IPFactory final { - public: - static ErrorOr<KString> ToKString(Ref<RawIPAddress6>& ipv6); - static ErrorOr<KString> ToKString(Ref<RawIPAddress>& ipv4); - static bool IpCheckVersion4(const Char* ip); -}; -} // namespace Kernel diff --git a/dev/kernel/NetworkKit/IPC.h b/dev/kernel/NetworkKit/IPC.h deleted file mode 100644 index c08a9457..00000000 --- a/dev/kernel/NetworkKit/IPC.h +++ /dev/null @@ -1,90 +0,0 @@ -/* ======================================== - - Copyright (C) 2024-2025, Amlal El Mahrouss, licensed under the Apache 2.0 license.. - - File: IPC.h. - Purpose: IPC protocol. - -======================================== */ - -#ifndef INC_IPC_H -#define INC_IPC_H - -#include <NeKit/Defines.h> -#include <NeKit/KString.h> -#include <hint/CompilerHint.h> - -/// @file IPC.h -/// @brief IPC comm. protocol. - -/// IA separator. -#define kIPCRemoteSeparator ":" - -/// Interchange address, consists of ProcessID:TEAM. -#define kIPCRemoteInvalid "00:00" - -#define kIPCHeaderMagic (0x4950434) - -namespace Kernel { -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; - -enum { - kIPCLockInvalid = 0, - kIPCLockFree = 1, - kIPCLockUsed = 2, -}; - -/// @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]; - UInt32 IpcLock; - /// @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 ALIGN(8) 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 Kernel - -#endif // INC_IPC_H diff --git a/dev/kernel/NetworkKit/LTE.h b/dev/kernel/NetworkKit/LTE.h deleted file mode 100644 index c29f1687..00000000 --- a/dev/kernel/NetworkKit/LTE.h +++ /dev/null @@ -1,16 +0,0 @@ -/* ======================================== - - Copyright (C) 2024-2025, Amlal El Mahrouss, licensed under the Apache 2.0 license.. - - File: LTE.h. - Purpose: LTE protocol classes. - -======================================== */ - -#ifndef _INC_NETWORK_LTE_H_ -#define _INC_NETWORK_LTE_H_ - -#include <NeKit/Defines.h> -#include <NeKit/KString.h> - -#endif // ifndef _INC_NETWORK_LTE_H_ diff --git a/dev/kernel/NetworkKit/MAC.h b/dev/kernel/NetworkKit/MAC.h deleted file mode 100644 index 382eca77..00000000 --- a/dev/kernel/NetworkKit/MAC.h +++ /dev/null @@ -1,34 +0,0 @@ -/* ======================================== - - Copyright (C) 2024-2025, Amlal El Mahrouss, licensed under the Apache 2.0 license. - -======================================== */ - -#pragma once - -#include <NeKit/Array.h> -#include <NeKit/Defines.h> -#include <NeKit/KString.h> - -#define kMACAddrLen (32U) - -namespace Kernel { -class MacAddressGetter; - -/// \brief This retrieves the MAC address of the device. -/// \note Listens for the current NIC. -class MacAddressGetter final { - public: - MacAddressGetter() = default; - ~MacAddressGetter() = default; - - NE_COPY_DEFAULT(MacAddressGetter) - - public: - Array<UInt8, kMACAddrLen>& AsBytes(); - - private: - Array<UInt8, kMACAddrLen> fMacAddress; -}; - -} // namespace Kernel diff --git a/dev/kernel/NetworkKit/NetworkDevice.h b/dev/kernel/NetworkKit/NetworkDevice.h deleted file mode 100644 index 3afa8484..00000000 --- a/dev/kernel/NetworkKit/NetworkDevice.h +++ /dev/null @@ -1,83 +0,0 @@ -/* ======================================== - - Copyright (C) 2024-2025, Amlal El Mahrouss, licensed under the Apache 2.0 license. - -======================================== */ - -#ifndef __INC_NETWORK_DEVICE_H__ -#define __INC_NETWORK_DEVICE_H__ - -#include <KernelKit/DeviceMgr.h> -#include <NetworkKit/IP.h> - -/// @note Can either work with: Ethernet, GPRS, WiFi - -namespace Kernel { -struct NetworkDeviceCommand; -class NetworkDevice; - -/** - * \brief Network device interface, establishes a connection to the NIC. - */ -class NetworkDevice final NE_DEVICE<NetworkDeviceCommand> { - public: - NetworkDevice(void (*out)(DeviceInterface<NetworkDeviceCommand>*, NetworkDeviceCommand), - void (*in)(DeviceInterface<NetworkDeviceCommand>*, NetworkDeviceCommand), - void (*cleanup)(void) = nullptr); - - ~NetworkDevice() override; - - public: - NetworkDevice& operator=(const NetworkDevice&) = default; - NetworkDevice(const NetworkDevice&) = default; - - public: - const Char* Name() const override; - Boolean Name(const Char* newStr); - - private: - Void (*fCleanup)(void); -}; - -struct NetworkDeviceCommand final { - UInt32 CommandName; - UInt32 CommandType; - UInt32 CommandFlags; - VoidPtr CommandBuffer; - SizeT CommandSizeBuffer; -}; - -/// @brief TCP device. -using TCPNetworkDevice = NetworkDevice; - -/// @brief UDP device. -using UDPNetworkDevice = NetworkDevice; - -/// @brief PPP device. -using PPPNetworkDevice = NetworkDevice; - -/// @brief IPC device. -using IPCNetworkDevice = NetworkDevice; - -/// @brief GRPS device. -using GPRSNetworkDevice = NetworkDevice; - -/// @brief GSM device. -using GSMNetworkDevice = NetworkDevice; - -/// @brief Bluetooth device. -using BTNetworkDevice = NetworkDevice; - -/// @brief Printer device. -using PrinterNetworkDevice = NetworkDevice; - -/// @brief Debug device. -using DBGNetworkDevice = NetworkDevice; - -/// @brief LTE device. -using LTENetworkDevice = NetworkDevice; -} // namespace Kernel - -#include <NetworkKit/NetworkDevice.inl> - -#endif // !__INC_NETWORK_DEVICE_H__ diff --git a/dev/kernel/NetworkKit/NetworkDevice.inl b/dev/kernel/NetworkKit/NetworkDevice.inl deleted file mode 100644 index a86d7e56..00000000 --- a/dev/kernel/NetworkKit/NetworkDevice.inl +++ /dev/null @@ -1,32 +0,0 @@ -/* ======================================== - - Copyright (C) 2024-2025, Amlal El Mahrouss, licensed under the Apache 2.0 license. - -======================================== */ - -/*** - Dtor and ctors. -*/ - -#ifndef __INC_NETWORK_DEVICE_H__ -#include <NetworkKit/NetworkDevice.h> -#endif // __INC_NETWORK_DEVICE_H__ - -namespace Kernel { -inline NetworkDevice::NetworkDevice(void (*out)(DeviceInterface<NetworkDeviceCommand>*, - NetworkDeviceCommand), - void (*in)(DeviceInterface<NetworkDeviceCommand>*, - NetworkDeviceCommand), - void (*on_cleanup)(void)) - : DeviceInterface<NetworkDeviceCommand>(out, in), fCleanup(on_cleanup) { - kout << "NetworkDevice initialized.\r"; - - MUST_PASS(out && in && on_cleanup); -} - -inline NetworkDevice::~NetworkDevice() { - kout << "NetworkDevice cleanup.\r"; - - if (fCleanup) fCleanup(); -} -} // namespace Kernel |
