NeKernel dev
Loading...
Searching...
No Matches
IP.h
Go to the documentation of this file.
1/* ========================================
2
3 Copyright (C) 2024-2025, Amlal El Mahrouss, licensed under the Apache 2.0 license.
4
5======================================== */
6
7#pragma once
8
10#include <NeKit/Config.h>
11#include <NeKit/KString.h>
12#include <NeKit/Ref.h>
13
14namespace Kernel {
15class RawIPAddress6;
16class RawIPAddress;
17class IPFactory;
18
19class RawIPAddress final {
20 private:
21 explicit RawIPAddress(UInt8 bytes[4]);
22 ~RawIPAddress() = default;
23
25 RawIPAddress(const RawIPAddress&) = default;
26
27 public:
28 UInt8* Address();
29
30 UInt8& operator[](const Size& index);
31
32 BOOL operator==(const RawIPAddress& ipv6);
33 BOOL operator!=(const RawIPAddress& ipv6);
34
35 private:
37
38 friend IPFactory; // it is the one creating these addresses, thus this
39 // is why the constructors are private.
40};
41
45class RawIPAddress6 final {
46 private:
47 explicit RawIPAddress6(UInt8 Bytes[16]);
48 ~RawIPAddress6() = default;
49
51 RawIPAddress6(const RawIPAddress6&) = default;
52
53 public:
54 UInt8* Address() { return fAddr; }
55
56 UInt8& operator[](const Size& index);
57
58 bool operator==(const RawIPAddress6& ipv6);
59 bool operator!=(const RawIPAddress6& ipv6);
60
61 private:
63
64 friend IPFactory;
65};
66
70class IPFactory final {
71 public:
74 static bool IpCheckVersion4(const Char* ip);
75};
76} // namespace Kernel
#define BOOL
ErrorOr class for error handling.
Definition ErrorOr.h:22
IP Creation helpers.
Definition IP.h:70
static bool IpCheckVersion4(const Char *ip)
Definition IPAddress.cc:88
static ErrorOr< KString > ToKString(Ref< RawIPAddress6 > &ipv6)
Definition IPAddress.cc:74
IPv6 address.
Definition IP.h:45
bool operator==(const RawIPAddress6 &ipv6)
Definition IPAddress.cc:57
RawIPAddress6(const RawIPAddress6 &)=default
UInt8 fAddr[16]
Definition IP.h:62
RawIPAddress6 & operator=(const RawIPAddress6 &)=delete
friend IPFactory
Definition IP.h:64
UInt8 & operator[](const Size &index)
Definition IPAddress.cc:48
UInt8 * Address()
Definition IP.h:54
bool operator!=(const RawIPAddress6 &ipv6)
Definition IPAddress.cc:65
RawIPAddress6(UInt8 Bytes[16])
Definition IPAddress.cc:44
Definition IP.h:19
BOOL operator!=(const RawIPAddress &ipv6)
Definition IPAddress.cc:27
UInt8 * Address()
Definition IPAddress.cc:11
UInt8 & operator[](const Size &index)
Definition IPAddress.cc:35
friend IPFactory
Definition IP.h:38
RawIPAddress(const RawIPAddress &)=default
RawIPAddress(UInt8 bytes[4])
Definition IPAddress.cc:15
BOOL operator==(const RawIPAddress &ipv6)
Definition IPAddress.cc:19
UInt8 fAddr[4]
Definition IP.h:36
RawIPAddress & operator=(const RawIPAddress &)=delete
Reference wrapper class. /// =========================================================== ///.
Definition Ref.h:22
UPS inline definitions.
Definition Device.h:12
char Char
Definition Config.h:51
__SIZE_TYPE__ Size
Definition Config.h:59
__UINT8_TYPE__ UInt8
Definition Config.h:55