DDraceNetwork Documentation
Loading...
Searching...
No Matches
types.h
Go to the documentation of this file.
1#ifndef BASE_TYPES_H
2#define BASE_TYPES_H
3
4#include <base/detect.h>
5
6#include <cstdint>
7#include <ctime>
8#include <functional>
9
10#if defined(CONF_FAMILY_UNIX)
11#include <sys/types.h> // pid_t
12#endif
13
14enum class TRISTATE
15{
19};
20
26typedef void *IOHANDLE;
27
33typedef struct ASYNCIO ASYNCIO;
34
35typedef int (*FS_LISTDIR_CALLBACK)(const char *name, int is_dir, int dir_type, void *user);
36
37typedef struct
38{
39 const char *m_pName;
40 time_t m_TimeCreated; // seconds since UNIX Epoch
41 time_t m_TimeModified; // seconds since UNIX Epoch
43
44typedef int (*FS_LISTDIR_CALLBACK_FILEINFO)(const CFsFileInfo *info, int is_dir, int dir_type, void *user);
45
50
54inline constexpr auto UTF8_BYTE_LENGTH = 4;
55
56inline constexpr auto IO_MAX_PATH_LENGTH = 512;
57
58inline constexpr auto NETADDR_MAXSTRSIZE = 1 + (8 * 4 + 7) + 1 + 1 + 5 + 1; // [XXXX:XXXX:XXXX:XXXX:XXXX:XXXX:XXXX:XXXX]:XXXXX
59
60inline constexpr auto NETTYPE_INVALID = 0;
61inline constexpr auto NETTYPE_IPV4 = 1 << 0;
62inline constexpr auto NETTYPE_IPV6 = 1 << 1;
63inline constexpr auto NETTYPE_WEBSOCKET_IPV4 = 1 << 2;
64inline constexpr auto NETTYPE_WEBSOCKET_IPV6 = 1 << 3;
65inline constexpr auto NETTYPE_LINK_BROADCAST = 1 << 4;
70inline constexpr auto NETTYPE_TW7 = 1 << 5;
71
74
78typedef struct NETADDR
79{
80 unsigned int type;
81 unsigned char ip[16];
82 unsigned short port;
83
84 bool operator==(const NETADDR &other) const;
85 bool operator!=(const NETADDR &other) const;
86 bool operator<(const NETADDR &other) const;
88
89template<>
90struct std::hash<NETADDR>
91{
92 size_t operator()(const NETADDR &Addr) const noexcept;
93};
94
98typedef struct NETSTATS
99{
100 uint64_t sent_packets;
101 uint64_t sent_bytes;
102 uint64_t recv_packets;
103 uint64_t recv_bytes;
105
106#if defined(CONF_FAMILY_WINDOWS)
112typedef void *PROCESS;
118constexpr PROCESS INVALID_PROCESS = nullptr; // NOLINT(misc-misplaced-const)
119#else
125typedef pid_t PROCESS;
132#endif
133
134#endif // BASE_TYPES_H
struct NETSOCKET_INTERNAL * NETSOCKET
Definition types.h:49
constexpr PROCESS INVALID_PROCESS
Definition types.h:131
pid_t PROCESS
Definition types.h:125
void * IOHANDLE
Definition logger.h:12
Definition aio.cpp:15
Definition types.h:38
time_t m_TimeCreated
Definition types.h:40
time_t m_TimeModified
Definition types.h:41
const char * m_pName
Definition types.h:39
Definition types.h:79
bool operator<(const NETADDR &other) const
Definition system.cpp:152
bool operator==(const NETADDR &other) const
Definition system.cpp:142
unsigned char ip[16]
Definition types.h:81
bool operator!=(const NETADDR &other) const
Definition system.cpp:147
unsigned short port
Definition types.h:82
unsigned int type
Definition types.h:80
Definition system.cpp:71
Definition types.h:99
uint64_t recv_packets
Definition types.h:102
uint64_t recv_bytes
Definition types.h:103
uint64_t sent_packets
Definition types.h:100
uint64_t sent_bytes
Definition types.h:101
size_t operator()(const NETADDR &Addr) const noexcept
Definition system.cpp:157
TRISTATE
Definition types.h:15
@ ALL
Definition types.h:18
@ SOME
Definition types.h:17
@ NONE
Definition types.h:16
constexpr auto NETTYPE_TW7
Definition types.h:70
constexpr auto UTF8_BYTE_LENGTH
Definition types.h:54
constexpr auto NETADDR_MAXSTRSIZE
Definition types.h:58
constexpr auto IO_MAX_PATH_LENGTH
Definition types.h:56
constexpr auto NETTYPE_WEBSOCKET_IPV6
Definition types.h:64
int(* FS_LISTDIR_CALLBACK_FILEINFO)(const CFsFileInfo *info, int is_dir, int dir_type, void *user)
Definition types.h:44
constexpr auto NETTYPE_LINK_BROADCAST
Definition types.h:65
constexpr auto NETTYPE_INVALID
Definition types.h:60
constexpr auto NETTYPE_IPV6
Definition types.h:62
constexpr auto NETTYPE_IPV4
Definition types.h:61
constexpr auto NETTYPE_ALL
Definition types.h:72
int(* FS_LISTDIR_CALLBACK)(const char *name, int is_dir, int dir_type, void *user)
Definition types.h:35
constexpr auto NETTYPE_WEBSOCKET_IPV4
Definition types.h:63
constexpr auto NETTYPE_MASK
Definition types.h:73