diff options
| author | Amlal El Mahrouss <amlalelmahrouss@icloud.com> | 2024-02-03 14:52:52 +0100 |
|---|---|---|
| committer | Amlal El Mahrouss <amlalelmahrouss@icloud.com> | 2024-02-03 14:52:52 +0100 |
| commit | fcccf780db4cdc23858c108c6cde1d08360ee88f (patch) | |
| tree | 6e9d871860fe4a6f415b95f7d77d2ac5bf9275a2 /Private/NetworkKit | |
| parent | 1f0cdb9f4ad64623ae8434a81fcbe8d37a5c8164 (diff) | |
Kernel: Got stuck at the way I do things, trying another approach see
hcore ticket HCR-11 in Jira.
Signed-off-by: Amlal El Mahrouss <amlalelmahrouss@icloud.com>
Diffstat (limited to 'Private/NetworkKit')
| -rw-r--r-- | Private/NetworkKit/IP.hpp | 84 | ||||
| -rw-r--r-- | Private/NetworkKit/NetworkDevice.hpp | 57 |
2 files changed, 65 insertions, 76 deletions
diff --git a/Private/NetworkKit/IP.hpp b/Private/NetworkKit/IP.hpp index de9d6e74..8761b65d 100644 --- a/Private/NetworkKit/IP.hpp +++ b/Private/NetworkKit/IP.hpp @@ -9,79 +9,71 @@ #pragma once -#include <NewKit/Defines.hpp> #include <KernelKit/DebugOutput.hpp> -#include <NewKit/String.hpp> +#include <NewKit/Defines.hpp> #include <NewKit/Ref.hpp> +#include <NewKit/String.hpp> -namespace HCore -{ +namespace HCore { 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 m_Addr[4]; + private: + char m_Addr[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 m_Addr; - } + public: + char *Address() { return m_Addr; } - 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 m_Addr[8]; + private: + char m_Addr[8]; - friend IPFactory; + friend IPFactory; }; /** * @brief IP Creation helpers */ -class IPFactory final -{ - public: - static ErrorOr<StringView> ToStringView(Ref<RawIPAddress6> ipv6); - static ErrorOr<StringView> ToStringView(Ref<RawIPAddress> ipv4); - static bool IpCheckVersion4(const char *ip); - +class IPFactory final { + public: + static ErrorOr<StringView> ToStringView(Ref<RawIPAddress6> ipv6); + static ErrorOr<StringView> ToStringView(Ref<RawIPAddress> ipv4); + static bool IpCheckVersion4(const char *ip); }; -} // namespace HCore +} // namespace HCore diff --git a/Private/NetworkKit/NetworkDevice.hpp b/Private/NetworkKit/NetworkDevice.hpp index 31a304cf..a9edb09c 100644 --- a/Private/NetworkKit/NetworkDevice.hpp +++ b/Private/NetworkKit/NetworkDevice.hpp @@ -13,41 +13,38 @@ #include <KernelKit/Device.hpp> #include <NetworkKit/IP.hpp> -namespace HCore -{ - struct NetworkDeviceCommand; +namespace HCore { +struct NetworkDeviceCommand; - class NetworkDevice final : public DeviceInterface<NetworkDeviceCommand> - { - public: - NetworkDevice(void(*out)(NetworkDeviceCommand), void(*in)(NetworkDeviceCommand), - void(*on_cleanup)(void) = nullptr); +class NetworkDevice final : public DeviceInterface<NetworkDeviceCommand> { + public: + NetworkDevice(void (*out)(NetworkDeviceCommand), + void (*in)(NetworkDeviceCommand), + void (*on_cleanup)(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 { return ("NetworkDevice"); } + public: + const char *Name() const override { return ("NetworkDevice"); } - private: - void(*fCleanup)(void); + private: + void (*fCleanup)(void); +}; - }; +struct NetworkDeviceCommand { + UInt32 Command; + UInt32 VLan; + UInt32 DmaLow; + UInt32 DmaHigh; +}; - struct NetworkDeviceCommand - { - UInt32 Command; - UInt32 VLan; - UInt32 DmaLow; - UInt32 DmaHigh; - }; +using TCPNetworkDevice = NetworkDevice; +using UDPNetworkDevice = NetworkDevice; +using PPPNetworkDevice = NetworkDevice; +} // namespace HCore - using TCPNetworkDevice = NetworkDevice; - using UDPNetworkDevice = NetworkDevice; - using PPPNetworkDevice = NetworkDevice; -} // namespace HCore - -#endif // !_INC_NETWORKDEVICE_HPP__ +#endif // !_INC_NETWORKDEVICE_HPP__ |
