summaryrefslogtreecommitdiffhomepage
path: root/Private/Source/Network
diff options
context:
space:
mode:
authorAmlal El Mahrouss <amlal.elmahrouss@icloud.com>2024-01-29 18:17:47 +0100
committerAmlal El Mahrouss <amlal.elmahrouss@icloud.com>2024-01-29 18:18:59 +0100
commit65254486efff0fd1bb78a48ff90b7713a5ce539f (patch)
tree20ce02c12a74ba9e6cd382bf9c1f09a0c611cb4d /Private/Source/Network
parentf03986937db0b927da4b10554801e18e4dc7c43f (diff)
Kernel: Update TODO.
Src: Refactorings according to clang-format. Meta: Update specification. Public: Remove useless UIKit. Signed-off-by: Amlal El Mahrouss <amlal.elmahrouss@icloud.com>
Diffstat (limited to 'Private/Source/Network')
-rw-r--r--Private/Source/Network/IP.cpp158
-rw-r--r--Private/Source/Network/NetworkDevice.cpp26
2 files changed, 75 insertions, 109 deletions
diff --git a/Private/Source/Network/IP.cpp b/Private/Source/Network/IP.cpp
index ba6fd71f..4e8f602a 100644
--- a/Private/Source/Network/IP.cpp
+++ b/Private/Source/Network/IP.cpp
@@ -10,118 +10,86 @@
#include <NetworkKit/IP.hpp>
#include <NewKit/Utils.hpp>
-namespace hCore
-{
- char* RawIPAddress::Address()
- {
- return m_Addr;
- }
+namespace hCore {
+char* RawIPAddress::Address() { return m_Addr; }
- RawIPAddress::RawIPAddress(char bytes[4])
- {
- rt_copy_memory(bytes, m_Addr, 4);
- }
+RawIPAddress::RawIPAddress(char bytes[4]) { rt_copy_memory(bytes, m_Addr, 4); }
- bool RawIPAddress::operator==(const RawIPAddress& ipv4)
- {
- for (Size index = 0; index < 4; ++index)
- {
- if (ipv4.m_Addr[index] != m_Addr[index])
- return false;
- }
+bool RawIPAddress::operator==(const RawIPAddress& ipv4) {
+ for (Size index = 0; index < 4; ++index) {
+ if (ipv4.m_Addr[index] != m_Addr[index]) return false;
+ }
- return true;
- }
+ return true;
+}
- bool RawIPAddress::operator!=(const RawIPAddress& ipv4)
- {
- for (Size index = 0; index < 4; ++index)
- {
- if (ipv4.m_Addr[index] == m_Addr[index])
- return false;
- }
+bool RawIPAddress::operator!=(const RawIPAddress& ipv4) {
+ for (Size index = 0; index < 4; ++index) {
+ if (ipv4.m_Addr[index] == m_Addr[index]) return false;
+ }
- return true;
- }
+ return true;
+}
- char& RawIPAddress::operator[](const Size& index)
- {
- kcout << "[RawIPAddress::operator[]] Fetching Index...\r\n";
+char& RawIPAddress::operator[](const Size& index) {
+ kcout << "[RawIPAddress::operator[]] Fetching Index...\r\n";
- if (index > 4)
- panic(RUNTIME_CHECK_EXPRESSION);
+ if (index > 4) panic(RUNTIME_CHECK_EXPRESSION);
- return m_Addr[index];
- }
+ return m_Addr[index];
+}
- RawIPAddress6::RawIPAddress6(char bytes[8])
- {
- rt_copy_memory(bytes, m_Addr, 8);
- }
+RawIPAddress6::RawIPAddress6(char bytes[8]) {
+ rt_copy_memory(bytes, m_Addr, 8);
+}
- char &RawIPAddress6::operator[](const Size &index)
- {
- kcout << "[RawIPAddress6::operator[]] Fetching Index...\r\n";
+char& RawIPAddress6::operator[](const Size& index) {
+ kcout << "[RawIPAddress6::operator[]] Fetching Index...\r\n";
- if (index > 8)
- panic(RUNTIME_CHECK_EXPRESSION);
+ if (index > 8) panic(RUNTIME_CHECK_EXPRESSION);
- return m_Addr[index];
- }
+ return m_Addr[index];
+}
- bool RawIPAddress6::operator==(const RawIPAddress6& ipv6)
- {
- for (SizeT index = 0; index < 8; ++index)
- {
- if (ipv6.m_Addr[index] != m_Addr[index])
- return false;
- }
+bool RawIPAddress6::operator==(const RawIPAddress6& ipv6) {
+ for (SizeT index = 0; index < 8; ++index) {
+ if (ipv6.m_Addr[index] != m_Addr[index]) return false;
+ }
- return true;
- }
+ return true;
+}
- bool RawIPAddress6::operator!=(const RawIPAddress6& ipv6)
- {
- for (SizeT index = 0; index < 8; ++index)
- {
- if (ipv6.m_Addr[index] == m_Addr[index])
- return false;
- }
+bool RawIPAddress6::operator!=(const RawIPAddress6& ipv6) {
+ for (SizeT index = 0; index < 8; ++index) {
+ if (ipv6.m_Addr[index] == m_Addr[index]) return false;
+ }
- return true;
- }
+ return true;
+}
- ErrorOr<StringView> IPFactory::ToStringView(Ref<RawIPAddress6> ipv6)
- {
- auto str = StringBuilder::Construct(ipv6.Leak().Address());
- return str;
- }
+ErrorOr<StringView> IPFactory::ToStringView(Ref<RawIPAddress6> ipv6) {
+ auto str = StringBuilder::Construct(ipv6.Leak().Address());
+ return str;
+}
- ErrorOr<StringView> IPFactory::ToStringView(Ref<RawIPAddress> ipv4)
- {
- auto str = StringBuilder::Construct(ipv4.Leak().Address());
- return str;
- }
+ErrorOr<StringView> IPFactory::ToStringView(Ref<RawIPAddress> ipv4) {
+ auto str = StringBuilder::Construct(ipv4.Leak().Address());
+ return str;
+}
- bool IPFactory::IpCheckVersion4(const char *ip)
- {
- int cnter = 0;
-
- for (Size base = 0; base < string_length(ip); ++base)
- {
- if (ip[base] == '.')
- {
- cnter = 0;
- }
- else
- {
- if (cnter == 3)
- return false;
-
- ++cnter;
- }
- }
-
- return true;
+bool IPFactory::IpCheckVersion4(const char* ip) {
+ int cnter = 0;
+
+ for (Size base = 0; base < string_length(ip); ++base) {
+ if (ip[base] == '.') {
+ cnter = 0;
+ } else {
+ if (cnter == 3) return false;
+
+ ++cnter;
}
-} // namespace NewKit
+ }
+
+ return true;
+}
+} // namespace hCore
diff --git a/Private/Source/Network/NetworkDevice.cpp b/Private/Source/Network/NetworkDevice.cpp
index 766e1f2e..bd75d7ed 100644
--- a/Private/Source/Network/NetworkDevice.cpp
+++ b/Private/Source/Network/NetworkDevice.cpp
@@ -12,23 +12,21 @@
// network devices implementation.
// PPPNetworkService, TCPNetworkDevice, UDPNetworkService
-namespace hCore
-{
- NetworkDevice::NetworkDevice(void (*out)(NetworkDeviceCommand), void (*in)(NetworkDeviceCommand), void(*on_cleanup)(void))
- : DeviceInterface<NetworkDeviceCommand>(out, in), fCleanup(on_cleanup)
- {
+namespace hCore {
+NetworkDevice::NetworkDevice(void (*out)(NetworkDeviceCommand),
+ void (*in)(NetworkDeviceCommand),
+ void (*on_cleanup)(void))
+ : DeviceInterface<NetworkDeviceCommand>(out, in), fCleanup(on_cleanup) {
#ifdef __DEBUG__
- kcout << "NetworkDevice init.\r\n";
+ kcout << "NetworkDevice init.\r\n";
#endif
- }
+}
- NetworkDevice::~NetworkDevice()
- {
+NetworkDevice::~NetworkDevice() {
#ifdef __DEBUG__
- kcout << "NetworkDevice cleanup.\r\n";
+ kcout << "NetworkDevice cleanup.\r\n";
#endif
- if (fCleanup)
- fCleanup();
- }
-} // namespace NewKit
+ if (fCleanup) fCleanup();
+}
+} // namespace hCore