From f95d8bf159d10b5a9521dcaa0bc37aa0e9dfc02b Mon Sep 17 00:00:00 2001 From: Amlal El Mahrouss Date: Sun, 5 May 2024 21:10:18 +0200 Subject: MHR-23: Add run_format.sh, kernel patches. Signed-off-by: Amlal El Mahrouss --- Private/NetworkKit/IP.hpp | 95 +++++++++++++++++++----------------- Private/NetworkKit/IPCEP.hxx | 59 ++++++++++++---------- Private/NetworkKit/MAC.hxx | 32 ++++++------ Private/NetworkKit/NetworkDevice.hpp | 73 ++++++++++++++------------- 4 files changed, 139 insertions(+), 120 deletions(-) (limited to 'Private/NetworkKit') diff --git a/Private/NetworkKit/IP.hpp b/Private/NetworkKit/IP.hpp index b8876aaa..f61bbdfd 100644 --- a/Private/NetworkKit/IP.hpp +++ b/Private/NetworkKit/IP.hpp @@ -11,66 +11,73 @@ #include #include -namespace NewOS { -class RawIPAddress6; -class RawIPAddress; -class IPFactory; +namespace NewOS +{ + class RawIPAddress6; + class RawIPAddress; + class IPFactory; -class RawIPAddress final { - private: - explicit RawIPAddress(char bytes[4]); - ~RawIPAddress() = default; + class RawIPAddress final + { + private: + explicit RawIPAddress(char bytes[4]); + ~RawIPAddress() = default; - RawIPAddress &operator=(const RawIPAddress &) = delete; - RawIPAddress(const RawIPAddress &) = default; + RawIPAddress& operator=(const RawIPAddress&) = delete; + RawIPAddress(const RawIPAddress&) = default; - public: - char *Address(); + public: + char* Address(); - char &operator[](const Size &index); + char& operator[](const Size& index); - bool operator==(const RawIPAddress &ipv6); - bool operator!=(const RawIPAddress &ipv6); + bool operator==(const RawIPAddress& ipv6); + bool operator!=(const RawIPAddress& ipv6); - private: - char fAddr[4]; + private: + char fAddr[4]; - friend IPFactory; // it is the one creating these addresses, thus this - // is why the constructors are private. -}; + 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(char Bytes[8]); - ~RawIPAddress6() = default; + class RawIPAddress6 final + { + private: + explicit RawIPAddress6(char Bytes[8]); + ~RawIPAddress6() = default; - RawIPAddress6 &operator=(const RawIPAddress6 &) = delete; - RawIPAddress6(const RawIPAddress6 &) = default; + RawIPAddress6& operator=(const RawIPAddress6&) = delete; + RawIPAddress6(const RawIPAddress6&) = default; - public: - char *Address() { return fAddr; } + public: + char* Address() + { + return fAddr; + } - char &operator[](const Size &index); + char& operator[](const Size& index); - bool operator==(const RawIPAddress6 &ipv6); - bool operator!=(const RawIPAddress6 &ipv6); + bool operator==(const RawIPAddress6& ipv6); + bool operator!=(const RawIPAddress6& ipv6); - private: - char fAddr[8]; + private: + char fAddr[8]; - friend IPFactory; -}; + friend IPFactory; + }; -/** + /** * @brief IP Creation helpers */ -class IPFactory final { - public: - static ErrorOr ToStringView(Ref ipv6); - static ErrorOr ToStringView(Ref ipv4); - static bool IpCheckVersion4(const char *ip); -}; -} // namespace NewOS + class IPFactory final + { + public: + static ErrorOr ToStringView(Ref ipv6); + static ErrorOr ToStringView(Ref ipv4); + static bool IpCheckVersion4(const char* ip); + }; +} // namespace NewOS diff --git a/Private/NetworkKit/IPCEP.hxx b/Private/NetworkKit/IPCEP.hxx index cd7345e4..705d1ad1 100644 --- a/Private/NetworkKit/IPCEP.hxx +++ b/Private/NetworkKit/IPCEP.hxx @@ -18,33 +18,40 @@ #define kRemoteSeparator "." /// Interchange address, consists of domain:namespace. -#define kRemoteInvalid "00.00.00.00:0000" +#define kRemoteInvalid "00.00.00.00:0000" #define kRemoteBitWidth 96 /* 96-bit address space. */ #define kRemoteHeaderMagic 0xFEEDFACE -namespace NewOS { -/// @brief 96-bit number to represent the domain and namespace -struct PACKED IPCEPAddress { - UInt32 RemoteAddress; - UInt64 RemoteNamespace; -}; - -typedef struct IPCEPAddress IPCEPAddressType; - -enum { kIPCEPLittleEndian = 0, kIPCEPBigEndian = 1 }; - -/// @brief IPCEP connection header -typedef struct IPCEPConnectionHeader { - UInt32 IpcHeader; // kRemoteHeaderMagic - UInt8 IpcEndianess; // 0 : LE, 1 : BE - SizeT IpcPacketSize; - IPCEPAddressType IpcFrom; - IPCEPAddressType IpcTo; - UInt32 IpcCRC32; - SizeT IpcDataSize; - Char IpcData[]; -} PACKED IPCEPConnectionHeader; -} // namespace NewOS - -#endif // _INC_IPC_ENDPOINT_HXX_ +namespace NewOS +{ + /// @brief 96-bit number to represent the domain and namespace + struct PACKED IPCEPAddress + { + UInt32 RemoteAddress; + UInt64 RemoteNamespace; + }; + + typedef struct IPCEPAddress IPCEPAddressType; + + enum + { + kIPCEPLittleEndian = 0, + kIPCEPBigEndian = 1 + }; + + /// @brief IPCEP connection header + typedef struct IPCEPConnectionHeader + { + UInt32 IpcHeader; // kRemoteHeaderMagic + UInt8 IpcEndianess; // 0 : LE, 1 : BE + SizeT IpcPacketSize; + IPCEPAddressType IpcFrom; + IPCEPAddressType IpcTo; + UInt32 IpcCRC32; + SizeT IpcDataSize; + Char IpcData[]; + } PACKED IPCEPConnectionHeader; +} // namespace NewOS + +#endif // _INC_IPC_ENDPOINT_HXX_ diff --git a/Private/NetworkKit/MAC.hxx b/Private/NetworkKit/MAC.hxx index 59f4b31f..1198c1f1 100644 --- a/Private/NetworkKit/MAC.hxx +++ b/Private/NetworkKit/MAC.hxx @@ -10,18 +10,20 @@ #include #include -namespace NewOS { -class MacAddressGetter; - -/// \brief This retrieves the MAC address of the device. -/// \note Listens for the current NIC. -class MacAddressGetter final { - public: - explicit MacAddressGetter() = default; - - public: - StringView& AsString(); - Array& AsBytes(); -}; - -} // namespace NewOS +namespace NewOS +{ + class MacAddressGetter; + + /// \brief This retrieves the MAC address of the device. + /// \note Listens for the current NIC. + class MacAddressGetter final + { + public: + explicit MacAddressGetter() = default; + + public: + StringView& AsString(); + Array& AsBytes(); + }; + +} // namespace NewOS diff --git a/Private/NetworkKit/NetworkDevice.hpp b/Private/NetworkKit/NetworkDevice.hpp index 24106478..c51de978 100644 --- a/Private/NetworkKit/NetworkDevice.hpp +++ b/Private/NetworkKit/NetworkDevice.hpp @@ -10,53 +10,56 @@ #include #include -namespace NewOS { -struct NetworkDeviceCommand; -class NetworkDevice; +namespace NewOS +{ + struct NetworkDeviceCommand; + class NetworkDevice; -/** + /** * \brief Network device interface, establishes a connection to the NIC. */ -class NetworkDevice final : public DeviceInterface { - public: - NetworkDevice(void (*out)(NetworkDeviceCommand), - void (*in)(NetworkDeviceCommand), - void (*onCleanup)(void) = nullptr); + class NetworkDevice final : public DeviceInterface + { + public: + NetworkDevice(void (*out)(NetworkDeviceCommand), + void (*in)(NetworkDeviceCommand), + void (*onCleanup)(void) = nullptr); - ~NetworkDevice() override; + ~NetworkDevice() override; - public: - NetworkDevice &operator=(const NetworkDevice &) = default; - NetworkDevice(const NetworkDevice &) = default; + public: + NetworkDevice& operator=(const NetworkDevice&) = default; + NetworkDevice(const NetworkDevice&) = default; - public: - const char *Name() const override; + public: + const char* Name() const override; - private: - void (*fCleanup)(void); -}; + private: + void (*fCleanup)(void); + }; -struct PACKED NetworkDeviceCommand final { - UInt32 CommandName; - UInt32 CommandType; - UInt32 CommandFlags; - VoidPtr CommandBuffer; - SizeT CommandSizeBuffer; -}; + struct PACKED NetworkDeviceCommand final + { + UInt32 CommandName; + UInt32 CommandType; + UInt32 CommandFlags; + VoidPtr CommandBuffer; + SizeT CommandSizeBuffer; + }; -/// @brief TCP device. -using TCPNetworkDevice = NetworkDevice; + /// @brief TCP device. + using TCPNetworkDevice = NetworkDevice; -/// @brief UDP device. -using UDPNetworkDevice = NetworkDevice; + /// @brief UDP device. + using UDPNetworkDevice = NetworkDevice; -/// @brief PPP device. -using PPPNetworkDevice = NetworkDevice; + /// @brief PPP device. + using PPPNetworkDevice = NetworkDevice; -/// @brief HPC device. -using HPCNetworkDevice = NetworkDevice; -} // namespace NewOS + /// @brief HPC device. + using HPCNetworkDevice = NetworkDevice; +} // namespace NewOS #include -#endif // !__NETWORK_DEVICE__ +#endif // !__NETWORK_DEVICE__ -- cgit v1.2.3