summaryrefslogtreecommitdiffhomepage
path: root/dev/kernel/NetworkKit/IP.h
diff options
context:
space:
mode:
authorAmlal <amlal@nekernel.org>2025-04-25 13:08:33 +0200
committerAmlal <amlal@nekernel.org>2025-04-25 13:08:33 +0200
commitfb790b07aeba8e22e4190cf3e1834d11ecde6c96 (patch)
tree4cec7d1b321307b1d5935577631dae116a658a37 /dev/kernel/NetworkKit/IP.h
parent63a2d92c5dfe976175cda024ec01905d11b43738 (diff)
dev: better .clang-format, ran format command.
Signed-off-by: Amlal <amlal@nekernel.org>
Diffstat (limited to 'dev/kernel/NetworkKit/IP.h')
-rw-r--r--dev/kernel/NetworkKit/IP.h137
1 files changed, 65 insertions, 72 deletions
diff --git a/dev/kernel/NetworkKit/IP.h b/dev/kernel/NetworkKit/IP.h
index 5df23dc3..bf3b24ff 100644
--- a/dev/kernel/NetworkKit/IP.h
+++ b/dev/kernel/NetworkKit/IP.h
@@ -1,6 +1,6 @@
/* -------------------------------------------
- Copyright (C) 2024-2025, Amlal El Mahrouss, all rights reserved.
+ Copyright (C) 2024-2025, Amlal El Mahrouss, all rights reserved.
------------------------------------------- */
@@ -8,76 +8,69 @@
#include <KernelKit/DebugOutput.h>
#include <NewKit/Defines.h>
-#include <NewKit/Ref.h>
#include <NewKit/KString.h>
+#include <NewKit/Ref.h>
+
+namespace Kernel {
+class RawIPAddress6;
+class RawIPAddress;
+class IPFactory;
+
+class RawIPAddress final {
+ private:
+ explicit RawIPAddress(char bytes[4]);
+ ~RawIPAddress() = default;
+
+ RawIPAddress& operator=(const RawIPAddress&) = delete;
+ RawIPAddress(const RawIPAddress&) = default;
+
+ public:
+ Char* Address();
+
+ Char& operator[](const Size& index);
+
+ BOOL operator==(const RawIPAddress& ipv6);
+ BOOL operator!=(const RawIPAddress& ipv6);
+
+ private:
+ Char 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(char Bytes[8]);
+ ~RawIPAddress6() = default;
+
+ RawIPAddress6& operator=(const RawIPAddress6&) = delete;
+ RawIPAddress6(const RawIPAddress6&) = default;
+
+ public:
+ char* Address() { return fAddr; }
+
+ char& operator[](const Size& index);
+
+ bool operator==(const RawIPAddress6& ipv6);
+ bool operator!=(const RawIPAddress6& ipv6);
+
+ private:
+ char fAddr[8];
+
+ friend IPFactory;
+};
-namespace Kernel
-{
- class RawIPAddress6;
- class RawIPAddress;
- class IPFactory;
-
- class RawIPAddress final
- {
- private:
- explicit RawIPAddress(char bytes[4]);
- ~RawIPAddress() = default;
-
- RawIPAddress& operator=(const RawIPAddress&) = delete;
- RawIPAddress(const RawIPAddress&) = default;
-
- public:
- Char* Address();
-
- Char& operator[](const Size& index);
-
- BOOL operator==(const RawIPAddress& ipv6);
- BOOL operator!=(const RawIPAddress& ipv6);
-
- private:
- Char 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(char Bytes[8]);
- ~RawIPAddress6() = default;
-
- RawIPAddress6& operator=(const RawIPAddress6&) = delete;
- RawIPAddress6(const RawIPAddress6&) = default;
-
- public:
- char* Address()
- {
- return fAddr;
- }
-
- char& operator[](const Size& index);
-
- bool operator==(const RawIPAddress6& ipv6);
- bool operator!=(const RawIPAddress6& ipv6);
-
- private:
- char fAddr[8];
-
- 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
+/**
+ * @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