summaryrefslogtreecommitdiffhomepage
path: root/src/kernel/NetworkKit/NetworkDevice.h
blob: 2c2c5aa625d89788cf7353120f01aa94d87c416a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
// Copyright 2024-2026, Amlal El Mahrouss (amlal@nekernel.org)
// Licensed under the Apache License, Version 2.0 (see LICENSE file)
// Official repository: https://github.com/nekernel-org/nekernel

#ifndef INC_NETWORK_DEVICE_H
#define INC_NETWORK_DEVICE_H

#include <KernelKit/DeviceMgr.h>
#include <NetworkKit/IP.h>

/// @note Can either work with: Ethernet, GPRS, WiFi

namespace Kernel {
struct NetworkDeviceCommand;
class NetworkDevice;

/**
 * \brief Network device interface, establishes a connection to the NIC.
 */
class NetworkDevice final NE_DEVICE<NetworkDeviceCommand> {
 public:
  NetworkDevice(void (*out)(IDevice<NetworkDeviceCommand>*, NetworkDeviceCommand),
                void (*in)(IDevice<NetworkDeviceCommand>*, NetworkDeviceCommand),
                void (*cleanup)(void) = nullptr);

  ~NetworkDevice() override;

 public:
  NetworkDevice& operator=(const NetworkDevice&) = default;
  NetworkDevice(const NetworkDevice&)            = default;

 public:
  const Char* Name() const override;
  Boolean     Name(const Char* newStr);

 private:
  Void (*fCleanup)(void);
};

struct NetworkDeviceCommand final {
  UInt32  CommandName;
  UInt32  CommandType;
  UInt32  CommandFlags;
  VoidPtr CommandBuffer;
  SizeT   CommandSizeBuffer;
};

/// @brief TCP device.
using TCPNetworkDevice = NetworkDevice;

/// @brief UDP device.
using UDPNetworkDevice = NetworkDevice;

/// @brief PPP device.
using PPPNetworkDevice = NetworkDevice;

/// @brief IPC device.
using IPCNetworkDevice = NetworkDevice;

/// @brief GRPS device.
using GPRSNetworkDevice = NetworkDevice;

/// @brief GSM device.
using GSMNetworkDevice = NetworkDevice;

/// @brief Bluetooth device.
using BTNetworkDevice = NetworkDevice;

/// @brief Printer device.
using PrinterNetworkDevice = NetworkDevice;

/// @brief Debug device.
using DBGNetworkDevice = NetworkDevice;

/// @brief LTE device.
using LTENetworkDevice = NetworkDevice;
}  // namespace Kernel

#include "NetworkDevice.inl"

#endif  // !__INC_NETWORK_DEVICE_H__