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 <cstdint>
5#include <ctime>
6#include <functional>
7
8#include <base/detect.h>
9
10#if defined(CONF_FAMILY_UNIX)
11#include <sys/types.h> // pid_t
12#endif
13
14enum class TRISTATE
15{
16 NONE,
17 SOME,
18 ALL,
19};
20
26typedef void *IOHANDLE;
27
28typedef int (*FS_LISTDIR_CALLBACK)(const char *name, int is_dir, int dir_type, void *user);
29
30typedef struct
31{
32 const char *m_pName;
33 time_t m_TimeCreated; // seconds since UNIX Epoch
34 time_t m_TimeModified; // seconds since UNIX Epoch
36
37typedef int (*FS_LISTDIR_CALLBACK_FILEINFO)(const CFsFileInfo *info, int is_dir, int dir_type, void *user);
38
43
47inline constexpr auto UTF8_BYTE_LENGTH = 4;
48
49inline constexpr auto IO_MAX_PATH_LENGTH = 512;
50
51inline constexpr auto NETADDR_MAXSTRSIZE = 1 + (8 * 4 + 7) + 1 + 1 + 5 + 1; // [XXXX:XXXX:XXXX:XXXX:XXXX:XXXX:XXXX:XXXX]:XXXXX
52
53inline constexpr auto NETTYPE_INVALID = 0;
54inline constexpr auto NETTYPE_IPV4 = 1 << 0;
55inline constexpr auto NETTYPE_IPV6 = 1 << 1;
56inline constexpr auto NETTYPE_WEBSOCKET_IPV4 = 1 << 2;
57inline constexpr auto NETTYPE_WEBSOCKET_IPV6 = 1 << 3;
58inline constexpr auto NETTYPE_LINK_BROADCAST = 1 << 4;
63inline constexpr auto NETTYPE_TW7 = 1 << 5;
64
67
71typedef struct NETADDR
72{
73 unsigned int type;
74 unsigned char ip[16];
75 unsigned short port;
76
77 bool operator==(const NETADDR &other) const;
78 bool operator!=(const NETADDR &other) const;
79 bool operator<(const NETADDR &other) const;
81
82template<>
83struct std::hash<NETADDR>
84{
85 size_t operator()(const NETADDR &Addr) const noexcept;
86};
87
91typedef struct NETSTATS
92{
93 uint64_t sent_packets;
94 uint64_t sent_bytes;
95 uint64_t recv_packets;
96 uint64_t recv_bytes;
98
99#if defined(CONF_FAMILY_WINDOWS)
105typedef void *PROCESS;
111constexpr PROCESS INVALID_PROCESS = nullptr;
112#else
118typedef pid_t PROCESS;
125#endif
126
127#endif // BASE_TYPES_H
void * IOHANDLE
Definition types.h:26
struct NETSOCKET_INTERNAL * NETSOCKET
Definition types.h:42
constexpr PROCESS INVALID_PROCESS
Definition types.h:124
pid_t PROCESS
Definition types.h:118
Definition types.h:31
time_t m_TimeCreated
Definition types.h:33
time_t m_TimeModified
Definition types.h:34
const char * m_pName
Definition types.h:32
Definition types.h:72
bool operator<(const NETADDR &other) const
Definition system.cpp:1092
bool operator==(const NETADDR &other) const
Definition system.cpp:1082
unsigned char ip[16]
Definition types.h:74
bool operator!=(const NETADDR &other) const
Definition system.cpp:1087
unsigned short port
Definition types.h:75
unsigned int type
Definition types.h:73
Definition system.cpp:115
Definition types.h:92
uint64_t recv_packets
Definition types.h:95
uint64_t recv_bytes
Definition types.h:96
uint64_t sent_packets
Definition types.h:93
uint64_t sent_bytes
Definition types.h:94
TRISTATE
Definition types.h:15
constexpr auto NETTYPE_TW7
Definition types.h:63
constexpr auto UTF8_BYTE_LENGTH
Definition types.h:47
constexpr auto NETADDR_MAXSTRSIZE
Definition types.h:51
constexpr auto IO_MAX_PATH_LENGTH
Definition types.h:49
constexpr auto NETTYPE_WEBSOCKET_IPV6
Definition types.h:57
int(* FS_LISTDIR_CALLBACK_FILEINFO)(const CFsFileInfo *info, int is_dir, int dir_type, void *user)
Definition types.h:37
constexpr auto NETTYPE_LINK_BROADCAST
Definition types.h:58
constexpr auto NETTYPE_INVALID
Definition types.h:53
constexpr auto NETTYPE_IPV6
Definition types.h:55
constexpr auto NETTYPE_IPV4
Definition types.h:54
constexpr auto NETTYPE_ALL
Definition types.h:65
int(* FS_LISTDIR_CALLBACK)(const char *name, int is_dir, int dir_type, void *user)
Definition types.h:28
constexpr auto NETTYPE_WEBSOCKET_IPV4
Definition types.h:56
constexpr auto NETTYPE_MASK
Definition types.h:66