From 0081896332601e6310e309a7facf3027bd308107 Mon Sep 17 00:00:00 2001 From: Stephen-Seo Date: Thu, 13 Mar 2025 10:09:03 +0000 Subject: [PATCH] deploy: 0055b76f98c6a6b33fddc63cf5edbe55d3491514 --- UDPC_8h.html | 6 +- UDPC_8h_source.html | 626 ++++++++++++++++++++++---------------------- 2 files changed, 316 insertions(+), 316 deletions(-) diff --git a/UDPC_8h.html b/UDPC_8h.html index 9533621..1828aca 100644 --- a/UDPC_8h.html +++ b/UDPC_8h.html @@ -391,7 +391,7 @@ Variables

Public API for UDPConnection.

Note that all functions are thread-safe unless mentioned otherwise in the function's documentation.

UDPC maintains a binary state for each connection. This state is either "good mode" or "bad mode". All connections start in "bad mode". When in "bad -mode", the fastest packet sending rate is 1 packet per 0.1 seconds, or 10 packets per second. When in "good mode", the fastest packet sending rate is 1 packet per 33.333 milliseconds, or 30 packets a second. Queued packets are sent immediately at the current mode's fastest-interval rate. If there are no queued packets, then "heartbeat" packets are sent at a rate of 1 packet per 0.15 seconds, or roughly 6 packets a second. This "heartbeat interval" can be adjusted with the UDPC_set_heartbeat_millis() function.

+mode", the fastest packet sending rate is 1 packet per 0.1 seconds, or 10 packets per second. When in "good mode", the fastest packet sending rate is 1 packet per 33.333 milliseconds, or 30 packets a second. Queued packets are sent immediately at the current mode's fastest-interval rate. If there are no queued packets, then "heartbeat" packets are sent at a rate of 1 packet per 0.15 seconds, or roughly 6 packets a second.

Typedef Documentation

◆ UDPC_AuthPolicy

@@ -607,7 +607,7 @@ mode", the fastest packet sending rate is 1 packet per 0.1 seconds, or 10 packet
UDPC_atostr_unsafe_free_ptr(&addrString);
UDPC_EXPORT const char * UDPC_atostr_unsafe_cid(UDPC_ConnectionId cid)
Similar to UPDC_atostr(), but the returned ptr must be free'd.
UDPC_EXPORT void UDPC_atostr_unsafe_free_ptr(const char **addrBuf)
Free an addr string created with UDPC_atostr_unsafe() and zeroes the pointer.
-
Data identifying a peer via addr, port, and scope_id.
Definition UDPC.h:169
+
Data identifying a peer via addr, port, and scope_id.
Definition UDPC.h:168
@@ -981,7 +981,7 @@ mode", the fastest packet sending rate is 1 packet per 0.1 seconds, or 10 packet
UDPC_free_PacketInfo_ptr(&pinfo); // This is safe, no double free.
UDPC_EXPORT void UDPC_free_PacketInfo_ptr(UDPC_PacketInfo *pInfoPtr)
Frees a UDPC_PacketInfo.
UDPC_EXPORT UDPC_PacketInfo UDPC_get_received(UDPC_HContext ctx, unsigned long *remaining)
Get a received packet from a given UDPC context.
-
Data representing a received/sent packet.
Definition UDPC.h:184
+
Data representing a received/sent packet.
Definition UDPC.h:183
diff --git a/UDPC_8h_source.html b/UDPC_8h_source.html index b619687..dbe0eca 100644 --- a/UDPC_8h_source.html +++ b/UDPC_8h_source.html @@ -93,307 +93,307 @@ $(function(){ initResizable(false); });
Go to the documentation of this file.
1
-
27#ifndef UDPC_CONNECTION_H
-
28#define UDPC_CONNECTION_H
-
29
-
30#ifndef DOXYGEN_SHOULD_SKIP_THIS
-
31
-
32// Determine platform macros
-
33# define UDPC_PLATFORM_WINDOWS 1
-
34# define UDPC_PLATFORM_MAC 2
-
35# define UDPC_PLATFORM_LINUX 3
-
36# define UDPC_PLATFORM_UNKNOWN 0
-
37
-
38# if defined _WIN32
-
39# define UDPC_PLATFORM UDPC_PLATFORM_WINDOWS
-
40# elif defined __APPLE__
-
41# define UDPC_PLATFORM UDPC_PLATFORM_MAC
-
42# elif defined __linux__
-
43# define UDPC_PLATFORM UDPC_PLATFORM_LINUX
-
44# else
-
45# define UDPC_PLATFORM UDPC_PLATFORM_UNKNOWN
-
46# endif
-
47
-
48#endif // DOXYGEN_SHOULD_SKIP_THIS
-
49
-
50// OS-based networking macros
-
51#if UDPC_PLATFORM == UDPC_PLATFORM_WINDOWS
-
52# include <winsock2.h>
-
53# ifdef UDPC_PLATFORM_MINGW
-
54# include <ws2ipdef.h>
-
55# include <in6addr.h>
-
56# else
-
57# include <Ws2ipdef.h>
-
58# include <In6addr.h>
-
59# endif
-
60
-
61# ifndef DOXYGEN_SHOULD_SKIP_THIS
-
62
-
63# define UDPC_CLEANUPSOCKET(x) closesocket(x)
-
64# define UDPC_SOCKETTYPE SOCKET
-
65# define UDPC_IPV6_SOCKADDR_TYPE SOCKADDR_IN6
-
66# define UDPC_IPV6_ADDR_TYPE IN6_ADDR
-
67# define UDPC_IPV6_ADDR_SUB(addr) addr.u.Byte
-
68# define UDPC_SOCKET_RETURN_ERROR(socket) (socket == INVALID_SOCKET)
-
69
-
70# endif // DOXYGEN_SHOULD_SKIP_THIS
-
71
-
72#elif UDPC_PLATFORM == UDPC_PLATFORM_MAC || UDPC_PLATFORM == UDPC_PLATFORM_LINUX
-
73# include <fcntl.h>
-
74# include <netinet/in.h>
-
75# include <sys/socket.h>
-
76# include <unistd.h>
-
77
-
78# ifndef DOXYGEN_SHOULD_SKIP_THIS
-
79
-
80# define UDPC_CLEANUPSOCKET(x) close(x)
-
81# define UDPC_SOCKETTYPE int
-
82# define UDPC_IPV6_SOCKADDR_TYPE struct sockaddr_in6
-
83# define UDPC_IPV6_ADDR_TYPE struct in6_addr
-
84# define UDPC_IPV6_ADDR_SUB(addr) addr.s6_addr
-
85# define UDPC_SOCKET_RETURN_ERROR(socket) (socket <= 0)
-
86
-
87# endif // DOXYGEN_SHOULD_SKIP_THIS
-
88
-
89#else
-
90# ifndef DOXYGEN_SHOULD_SKIP_THIS
-
91# define UDPC_CLEANUPSOCKET(x) ((void)0)
-
92# endif // DOXYGEN_SHOULD_SKIP_THIS
-
93#endif
-
94
-
95// other defines
-
97#define UDPC_PACKET_MAX_SIZE 8192
-
98#define UDPC_DEFAULT_PROTOCOL_ID 1357924680 // 0x50f04948
-
99
-
100#ifndef DOXYGEN_SHOULD_SKIP_THIS
-
101
-
102// other defines continued
-
103
-
104# ifndef UDPC_LIBSODIUM_ENABLED
-
105# ifndef crypto_sign_PUBLICKEYBYTES
-
106# define crypto_sign_PUBLICKEYBYTES 1
-
107# endif
-
108# ifndef crypto_sign_SECRETKEYBYTES
-
109# define crypto_sign_SECRETKEYBYTES 1
-
110# endif
-
111# ifndef crypto_sign_BYTES
-
112# define crypto_sign_BYTES 1
-
113# endif
-
114# endif
-
115
-
116# if UDPC_PLATFORM == UDPC_PLATFORM_WINDOWS
-
117# define UDPC_EXPORT __declspec(dllexport)
-
118# else
-
119# define UDPC_EXPORT
-
120# endif
-
121
-
122#endif // DOXYGEN_SHOULD_SKIP_THIS
-
123
-
124#ifdef __cplusplus
-
125# include <cstdint>
-
126extern "C" {
-
127#else
-
128# include <stdint.h>
-
129#endif
-
130
-
132struct UDPC_Context;
-
133typedef struct UDPC_Context *UDPC_HContext;
-
134
-
135typedef enum UDPC_EXPORT UDPC_LoggingType {
- - - - - -
147 UDPC_DEBUG
-
148} UDPC_LoggingType;
-
149
-
-
152typedef enum UDPC_EXPORT UDPC_AuthPolicy {
- - -
157 // Used internally to get max size of enum
-
158 UDPC_AUTH_POLICY_SIZE
- +
26#ifndef UDPC_CONNECTION_H
+
27#define UDPC_CONNECTION_H
+
28
+
29#ifndef DOXYGEN_SHOULD_SKIP_THIS
+
30
+
31// Determine platform macros
+
32# define UDPC_PLATFORM_WINDOWS 1
+
33# define UDPC_PLATFORM_MAC 2
+
34# define UDPC_PLATFORM_LINUX 3
+
35# define UDPC_PLATFORM_UNKNOWN 0
+
36
+
37# if defined _WIN32
+
38# define UDPC_PLATFORM UDPC_PLATFORM_WINDOWS
+
39# elif defined __APPLE__
+
40# define UDPC_PLATFORM UDPC_PLATFORM_MAC
+
41# elif defined __linux__
+
42# define UDPC_PLATFORM UDPC_PLATFORM_LINUX
+
43# else
+
44# define UDPC_PLATFORM UDPC_PLATFORM_UNKNOWN
+
45# endif
+
46
+
47#endif // DOXYGEN_SHOULD_SKIP_THIS
+
48
+
49// OS-based networking macros
+
50#if UDPC_PLATFORM == UDPC_PLATFORM_WINDOWS
+
51# include <winsock2.h>
+
52# ifdef UDPC_PLATFORM_MINGW
+
53# include <ws2ipdef.h>
+
54# include <in6addr.h>
+
55# else
+
56# include <Ws2ipdef.h>
+
57# include <In6addr.h>
+
58# endif
+
59
+
60# ifndef DOXYGEN_SHOULD_SKIP_THIS
+
61
+
62# define UDPC_CLEANUPSOCKET(x) closesocket(x)
+
63# define UDPC_SOCKETTYPE SOCKET
+
64# define UDPC_IPV6_SOCKADDR_TYPE SOCKADDR_IN6
+
65# define UDPC_IPV6_ADDR_TYPE IN6_ADDR
+
66# define UDPC_IPV6_ADDR_SUB(addr) addr.u.Byte
+
67# define UDPC_SOCKET_RETURN_ERROR(socket) (socket == INVALID_SOCKET)
+
68
+
69# endif // DOXYGEN_SHOULD_SKIP_THIS
+
70
+
71#elif UDPC_PLATFORM == UDPC_PLATFORM_MAC || UDPC_PLATFORM == UDPC_PLATFORM_LINUX
+
72# include <fcntl.h>
+
73# include <netinet/in.h>
+
74# include <sys/socket.h>
+
75# include <unistd.h>
+
76
+
77# ifndef DOXYGEN_SHOULD_SKIP_THIS
+
78
+
79# define UDPC_CLEANUPSOCKET(x) close(x)
+
80# define UDPC_SOCKETTYPE int
+
81# define UDPC_IPV6_SOCKADDR_TYPE struct sockaddr_in6
+
82# define UDPC_IPV6_ADDR_TYPE struct in6_addr
+
83# define UDPC_IPV6_ADDR_SUB(addr) addr.s6_addr
+
84# define UDPC_SOCKET_RETURN_ERROR(socket) (socket <= 0)
+
85
+
86# endif // DOXYGEN_SHOULD_SKIP_THIS
+
87
+
88#else
+
89# ifndef DOXYGEN_SHOULD_SKIP_THIS
+
90# define UDPC_CLEANUPSOCKET(x) ((void)0)
+
91# endif // DOXYGEN_SHOULD_SKIP_THIS
+
92#endif
+
93
+
94// other defines
+
96#define UDPC_PACKET_MAX_SIZE 8192
+
97#define UDPC_DEFAULT_PROTOCOL_ID 1357924680 // 0x50f04948
+
98
+
99#ifndef DOXYGEN_SHOULD_SKIP_THIS
+
100
+
101// other defines continued
+
102
+
103# ifndef UDPC_LIBSODIUM_ENABLED
+
104# ifndef crypto_sign_PUBLICKEYBYTES
+
105# define crypto_sign_PUBLICKEYBYTES 1
+
106# endif
+
107# ifndef crypto_sign_SECRETKEYBYTES
+
108# define crypto_sign_SECRETKEYBYTES 1
+
109# endif
+
110# ifndef crypto_sign_BYTES
+
111# define crypto_sign_BYTES 1
+
112# endif
+
113# endif
+
114
+
115# if UDPC_PLATFORM == UDPC_PLATFORM_WINDOWS
+
116# define UDPC_EXPORT __declspec(dllexport)
+
117# else
+
118# define UDPC_EXPORT
+
119# endif
+
120
+
121#endif // DOXYGEN_SHOULD_SKIP_THIS
+
122
+
123#ifdef __cplusplus
+
124# include <cstdint>
+
125extern "C" {
+
126#else
+
127# include <stdint.h>
+
128#endif
+
129
+
131struct UDPC_Context;
+
132typedef struct UDPC_Context *UDPC_HContext;
+
133
+
134typedef enum UDPC_EXPORT UDPC_LoggingType {
+ + + + + +
146 UDPC_DEBUG
+
147} UDPC_LoggingType;
+
148
+
+
151typedef enum UDPC_EXPORT UDPC_AuthPolicy {
+ + +
156 // Used internally to get max size of enum
+
157 UDPC_AUTH_POLICY_SIZE
+
-
160
-
-
169typedef struct UDPC_EXPORT UDPC_ConnectionId {
-
170 UDPC_IPV6_ADDR_TYPE addr;
-
171 uint32_t scope_id;
-
172 uint16_t port;
- +
159
+
+
168typedef struct UDPC_EXPORT UDPC_ConnectionId {
+
169 UDPC_IPV6_ADDR_TYPE addr;
+
170 uint32_t scope_id;
+
171 uint16_t port;
+
-
174
-
-
184typedef struct UDPC_EXPORT UDPC_PacketInfo {
-
189 // id is stored at offset 8, size 4 (uint32_t) even for "empty" PktInfos
-
190 char *data;
-
201 uint32_t flags;
-
209 uint32_t id;
-
219 uint16_t dataSize;
-
220 uint16_t rtt;
- - - +
173
+
+
183typedef struct UDPC_EXPORT UDPC_PacketInfo {
+
188 // id is stored at offset 8, size 4 (uint32_t) even for "empty" PktInfos
+
189 char *data;
+
200 uint32_t flags;
+
208 uint32_t id;
+
218 uint16_t dataSize;
+
219 uint16_t rtt;
+ + +
-
226
-
-
246typedef enum UDPC_EXPORT UDPC_EventType {
-
247 UDPC_ET_NONE,
-
248 UDPC_ET_REQUEST_CONNECT,
-
249 UDPC_ET_REQUEST_DISCONNECT,
-
250 UDPC_ET_CONNECTED,
-
251 UDPC_ET_DISCONNECTED,
-
252 UDPC_ET_FAIL_CONNECT,
-
253 UDPC_ET_GOOD_MODE,
-
254 UDPC_ET_BAD_MODE
- +
225
+
+
245typedef enum UDPC_EXPORT UDPC_EventType {
+
246 UDPC_ET_NONE,
+
247 UDPC_ET_REQUEST_CONNECT,
+
248 UDPC_ET_REQUEST_DISCONNECT,
+
249 UDPC_ET_CONNECTED,
+
250 UDPC_ET_DISCONNECTED,
+
251 UDPC_ET_FAIL_CONNECT,
+
252 UDPC_ET_GOOD_MODE,
+
253 UDPC_ET_BAD_MODE
+
-
256
-
-
267typedef struct UDPC_EXPORT UDPC_Event {
-
268 UDPC_EventType type;
-
269 UDPC_ConnectionId conId;
-
-
270 union Value {
-
271 int dropAllWithAddr;
-
272 int enableLibSodium;
-
273 } v;
+
255
+
+
266typedef struct UDPC_EXPORT UDPC_Event {
+
267 UDPC_EventType type;
+
268 UDPC_ConnectionId conId;
+
+
269 union Value {
+
270 int dropAllWithAddr;
+
271 int enableLibSodium;
+
272 } v;
- +
-
275
-
286UDPC_EXPORT UDPC_ConnectionId UDPC_create_id(UDPC_IPV6_ADDR_TYPE addr, uint16_t port);
-
287
-
295UDPC_EXPORT UDPC_ConnectionId UDPC_create_id_full(UDPC_IPV6_ADDR_TYPE addr, uint32_t scope_id, uint16_t port);
-
296
-
306UDPC_EXPORT UDPC_ConnectionId UDPC_create_id_anyaddr(uint16_t port);
-
307
-
318UDPC_EXPORT UDPC_ConnectionId UDPC_create_id_easy(const char *addrString, uint16_t port);
-
319
-
320UDPC_EXPORT UDPC_ConnectionId UDPC_create_id_hostname(const char *hostname, uint16_t port);
-
321
-
344UDPC_EXPORT UDPC_HContext UDPC_init(UDPC_ConnectionId listenId, int isClient, int isUsingLibsodium);
-
364UDPC_EXPORT UDPC_HContext UDPC_init_threaded_update(
-
365 UDPC_ConnectionId listenId,
-
366 int isClient,
-
367 int isUsingLibsodium);
-
387UDPC_EXPORT UDPC_HContext UDPC_init_threaded_update_ms(
-
388 UDPC_ConnectionId listenId,
-
389 int isClient,
-
390 int updateMS,
-
391 int isUsingLibsodium);
-
392
-
402UDPC_EXPORT int UDPC_enable_threaded_update(UDPC_HContext ctx);
-
413UDPC_EXPORT int UDPC_enable_threaded_update_ms(UDPC_HContext ctx, int updateMS);
-
422UDPC_EXPORT int UDPC_disable_threaded_update(UDPC_HContext ctx);
-
423
-
429UDPC_EXPORT int UDPC_is_valid_context(UDPC_HContext ctx);
-
430
-
440UDPC_EXPORT void UDPC_destroy(UDPC_HContext ctx);
-
441
-
461UDPC_EXPORT void UDPC_update(UDPC_HContext ctx);
-
462
- -
474 UDPC_HContext ctx,
-
475 UDPC_ConnectionId connectionId,
-
476 int enableLibSodium);
-
477
-
496UDPC_EXPORT void UDPC_queue_send(UDPC_HContext ctx, UDPC_ConnectionId destinationId,
-
497 int isChecked, const void *data, uint32_t size);
-
498
-
515UDPC_EXPORT unsigned long UDPC_get_queue_send_current_size(UDPC_HContext ctx);
-
516
-
533UDPC_EXPORT unsigned long UDPC_get_queued_size(UDPC_HContext ctx, UDPC_ConnectionId id, int *exists);
-
534
-
543UDPC_EXPORT unsigned long UDPC_get_max_queued_size();
-
544
-
551UDPC_EXPORT int UDPC_set_accept_new_connections(UDPC_HContext ctx, int isAccepting);
-
552
-
564UDPC_EXPORT void UDPC_drop_connection(UDPC_HContext ctx, UDPC_ConnectionId connectionId, int dropAllWithAddr);
-
565
-
575UDPC_EXPORT int UDPC_has_connection(UDPC_HContext ctx, UDPC_ConnectionId connectionId);
-
576
-
591UDPC_EXPORT UDPC_ConnectionId* UDPC_get_list_connected(UDPC_HContext ctx, unsigned int *size);
-
592
- -
598
-
610UDPC_EXPORT uint32_t UDPC_get_protocol_id(UDPC_HContext ctx);
-
611
-
622UDPC_EXPORT uint32_t UDPC_set_protocol_id(UDPC_HContext ctx, uint32_t id);
-
623
-
632UDPC_EXPORT UDPC_LoggingType UDPC_get_logging_type(UDPC_HContext ctx);
-
633
-
643UDPC_EXPORT UDPC_LoggingType UDPC_set_logging_type(UDPC_HContext ctx, UDPC_LoggingType loggingType);
-
644
-
653UDPC_EXPORT int UDPC_get_receiving_events(UDPC_HContext ctx);
-
654
-
664UDPC_EXPORT int UDPC_set_receiving_events(UDPC_HContext ctx, int isReceivingEvents);
-
665
-
677UDPC_EXPORT UDPC_Event UDPC_get_event(UDPC_HContext ctx, unsigned long *remaining);
-
678
-
686UDPC_EXPORT UDPC_PacketInfo UDPC_get_received(UDPC_HContext ctx, unsigned long *remaining);
-
687
-
695UDPC_EXPORT void UDPC_free_PacketInfo(UDPC_PacketInfo pInfo);
-
696
-
712UDPC_EXPORT void UDPC_free_PacketInfo_ptr(UDPC_PacketInfo *pInfoPtr);
-
713
-
731UDPC_EXPORT int UDPC_set_libsodium_keys(UDPC_HContext ctx, const unsigned char *sk, const unsigned char *pk);
-
732
-
746UDPC_EXPORT int UDPC_set_libsodium_key_easy(UDPC_HContext ctx, const unsigned char *sk);
-
747
-
756UDPC_EXPORT int UDPC_unset_libsodium_keys(UDPC_HContext ctx);
-
757
-
773UDPC_EXPORT int UDPC_add_whitelist_pk(UDPC_HContext ctx, const unsigned char *pk);
-
774
-
783UDPC_EXPORT int UDPC_has_whitelist_pk(UDPC_HContext ctx, const unsigned char *pk);
-
784
-
793UDPC_EXPORT int UDPC_remove_whitelist_pk(UDPC_HContext ctx, const unsigned char *pk);
-
794
-
809UDPC_EXPORT int UDPC_clear_whitelist(UDPC_HContext ctx);
-
810
-
825UDPC_EXPORT int UDPC_get_auth_policy(UDPC_HContext ctx);
-
826
-
841UDPC_EXPORT int UDPC_set_auth_policy(UDPC_HContext ctx, int value);
-
842
-
847UDPC_EXPORT const char *UDPC_atostr_cid(UDPC_HContext ctx, UDPC_ConnectionId connectionId);
-
848
-
878UDPC_EXPORT const char *UDPC_atostr(UDPC_HContext ctx, UDPC_IPV6_ADDR_TYPE addr);
-
879
-
894UDPC_EXPORT const char *UDPC_atostr_unsafe(UDPC_IPV6_ADDR_TYPE addr);
-
895
-
908UDPC_EXPORT const char *UDPC_atostr_unsafe_cid(UDPC_ConnectionId cid);
-
909
-
913UDPC_EXPORT void UDPC_atostr_unsafe_free(const char *addrBuf);
-
914
-
926UDPC_EXPORT void UDPC_atostr_unsafe_free_ptr(const char **addrBuf);
-
927
-
928// =============================================================================
-
929// Helpers
-
930
-
932UDPC_EXPORT UDPC_IPV6_ADDR_TYPE UDPC_strtoa(const char *addrStr);
-
933
-
934UDPC_EXPORT UDPC_IPV6_ADDR_TYPE UDPC_strtoa_link(const char *addrStr, uint32_t *linkId_out);
-
935
-
936UDPC_EXPORT UDPC_IPV6_ADDR_TYPE UDPC_a4toa6(uint32_t a4_be);
-
937
-
938UDPC_EXPORT int UDPC_is_big_endian();
-
939
-
980UDPC_EXPORT uint16_t UDPC_no16i(uint16_t i);
-
981
-
1022UDPC_EXPORT uint32_t UDPC_no32i(uint32_t i);
-
1023
-
1064UDPC_EXPORT uint64_t UDPC_no64i(uint64_t i);
-
1065
-
1097UDPC_EXPORT float UDPC_no32f(float f);
-
1098
-
1130UDPC_EXPORT double UDPC_no64f(double f);
-
1131
-
1132#ifdef __cplusplus
-
1133}
+
274
+
285UDPC_EXPORT UDPC_ConnectionId UDPC_create_id(UDPC_IPV6_ADDR_TYPE addr, uint16_t port);
+
286
+
294UDPC_EXPORT UDPC_ConnectionId UDPC_create_id_full(UDPC_IPV6_ADDR_TYPE addr, uint32_t scope_id, uint16_t port);
+
295
+
305UDPC_EXPORT UDPC_ConnectionId UDPC_create_id_anyaddr(uint16_t port);
+
306
+
317UDPC_EXPORT UDPC_ConnectionId UDPC_create_id_easy(const char *addrString, uint16_t port);
+
318
+
319UDPC_EXPORT UDPC_ConnectionId UDPC_create_id_hostname(const char *hostname, uint16_t port);
+
320
+
343UDPC_EXPORT UDPC_HContext UDPC_init(UDPC_ConnectionId listenId, int isClient, int isUsingLibsodium);
+
363UDPC_EXPORT UDPC_HContext UDPC_init_threaded_update(
+
364 UDPC_ConnectionId listenId,
+
365 int isClient,
+
366 int isUsingLibsodium);
+
386UDPC_EXPORT UDPC_HContext UDPC_init_threaded_update_ms(
+
387 UDPC_ConnectionId listenId,
+
388 int isClient,
+
389 int updateMS,
+
390 int isUsingLibsodium);
+
391
+
401UDPC_EXPORT int UDPC_enable_threaded_update(UDPC_HContext ctx);
+
412UDPC_EXPORT int UDPC_enable_threaded_update_ms(UDPC_HContext ctx, int updateMS);
+
421UDPC_EXPORT int UDPC_disable_threaded_update(UDPC_HContext ctx);
+
422
+
428UDPC_EXPORT int UDPC_is_valid_context(UDPC_HContext ctx);
+
429
+
439UDPC_EXPORT void UDPC_destroy(UDPC_HContext ctx);
+
440
+
460UDPC_EXPORT void UDPC_update(UDPC_HContext ctx);
+
461
+ +
473 UDPC_HContext ctx,
+
474 UDPC_ConnectionId connectionId,
+
475 int enableLibSodium);
+
476
+
495UDPC_EXPORT void UDPC_queue_send(UDPC_HContext ctx, UDPC_ConnectionId destinationId,
+
496 int isChecked, const void *data, uint32_t size);
+
497
+
514UDPC_EXPORT unsigned long UDPC_get_queue_send_current_size(UDPC_HContext ctx);
+
515
+
532UDPC_EXPORT unsigned long UDPC_get_queued_size(UDPC_HContext ctx, UDPC_ConnectionId id, int *exists);
+
533
+
542UDPC_EXPORT unsigned long UDPC_get_max_queued_size();
+
543
+
550UDPC_EXPORT int UDPC_set_accept_new_connections(UDPC_HContext ctx, int isAccepting);
+
551
+
563UDPC_EXPORT void UDPC_drop_connection(UDPC_HContext ctx, UDPC_ConnectionId connectionId, int dropAllWithAddr);
+
564
+
574UDPC_EXPORT int UDPC_has_connection(UDPC_HContext ctx, UDPC_ConnectionId connectionId);
+
575
+
590UDPC_EXPORT UDPC_ConnectionId* UDPC_get_list_connected(UDPC_HContext ctx, unsigned int *size);
+
591
+ +
597
+
609UDPC_EXPORT uint32_t UDPC_get_protocol_id(UDPC_HContext ctx);
+
610
+
621UDPC_EXPORT uint32_t UDPC_set_protocol_id(UDPC_HContext ctx, uint32_t id);
+
622
+
631UDPC_EXPORT UDPC_LoggingType UDPC_get_logging_type(UDPC_HContext ctx);
+
632
+
642UDPC_EXPORT UDPC_LoggingType UDPC_set_logging_type(UDPC_HContext ctx, UDPC_LoggingType loggingType);
+
643
+
652UDPC_EXPORT int UDPC_get_receiving_events(UDPC_HContext ctx);
+
653
+
663UDPC_EXPORT int UDPC_set_receiving_events(UDPC_HContext ctx, int isReceivingEvents);
+
664
+
676UDPC_EXPORT UDPC_Event UDPC_get_event(UDPC_HContext ctx, unsigned long *remaining);
+
677
+
685UDPC_EXPORT UDPC_PacketInfo UDPC_get_received(UDPC_HContext ctx, unsigned long *remaining);
+
686
+
694UDPC_EXPORT void UDPC_free_PacketInfo(UDPC_PacketInfo pInfo);
+
695
+
711UDPC_EXPORT void UDPC_free_PacketInfo_ptr(UDPC_PacketInfo *pInfoPtr);
+
712
+
730UDPC_EXPORT int UDPC_set_libsodium_keys(UDPC_HContext ctx, const unsigned char *sk, const unsigned char *pk);
+
731
+
745UDPC_EXPORT int UDPC_set_libsodium_key_easy(UDPC_HContext ctx, const unsigned char *sk);
+
746
+
755UDPC_EXPORT int UDPC_unset_libsodium_keys(UDPC_HContext ctx);
+
756
+
772UDPC_EXPORT int UDPC_add_whitelist_pk(UDPC_HContext ctx, const unsigned char *pk);
+
773
+
782UDPC_EXPORT int UDPC_has_whitelist_pk(UDPC_HContext ctx, const unsigned char *pk);
+
783
+
792UDPC_EXPORT int UDPC_remove_whitelist_pk(UDPC_HContext ctx, const unsigned char *pk);
+
793
+
808UDPC_EXPORT int UDPC_clear_whitelist(UDPC_HContext ctx);
+
809
+
824UDPC_EXPORT int UDPC_get_auth_policy(UDPC_HContext ctx);
+
825
+
840UDPC_EXPORT int UDPC_set_auth_policy(UDPC_HContext ctx, int value);
+
841
+
846UDPC_EXPORT const char *UDPC_atostr_cid(UDPC_HContext ctx, UDPC_ConnectionId connectionId);
+
847
+
877UDPC_EXPORT const char *UDPC_atostr(UDPC_HContext ctx, UDPC_IPV6_ADDR_TYPE addr);
+
878
+
893UDPC_EXPORT const char *UDPC_atostr_unsafe(UDPC_IPV6_ADDR_TYPE addr);
+
894
+
907UDPC_EXPORT const char *UDPC_atostr_unsafe_cid(UDPC_ConnectionId cid);
+
908
+
912UDPC_EXPORT void UDPC_atostr_unsafe_free(const char *addrBuf);
+
913
+
925UDPC_EXPORT void UDPC_atostr_unsafe_free_ptr(const char **addrBuf);
+
926
+
927// =============================================================================
+
928// Helpers
+
929
+
931UDPC_EXPORT UDPC_IPV6_ADDR_TYPE UDPC_strtoa(const char *addrStr);
+
932
+
933UDPC_EXPORT UDPC_IPV6_ADDR_TYPE UDPC_strtoa_link(const char *addrStr, uint32_t *linkId_out);
+
934
+
935UDPC_EXPORT UDPC_IPV6_ADDR_TYPE UDPC_a4toa6(uint32_t a4_be);
+
936
+
937UDPC_EXPORT int UDPC_is_big_endian();
+
938
+
979UDPC_EXPORT uint16_t UDPC_no16i(uint16_t i);
+
980
+
1021UDPC_EXPORT uint32_t UDPC_no32i(uint32_t i);
+
1022
+
1063UDPC_EXPORT uint64_t UDPC_no64i(uint64_t i);
+
1064
+
1096UDPC_EXPORT float UDPC_no32f(float f);
+
1097
+
1129UDPC_EXPORT double UDPC_no64f(double f);
+
1130
+
1131#ifdef __cplusplus
+
1132}
+
1133#endif
1134#endif
-
1135#endif
UDPC_EXPORT uint32_t UDPC_set_protocol_id(UDPC_HContext ctx, uint32_t id)
Sets the protocol id of the UDPC context.
UDPC_EXPORT uint16_t UDPC_no16i(uint16_t i)
Converts a 16-bit int into/from network byte order (big endian).
UDPC_EXPORT uint64_t UDPC_no64i(uint64_t i)
Converts a 64-bit int into/from network byte order (big endian).
@@ -404,8 +404,8 @@ $(function(){ initResizable(false); });
UDPC_EXPORT const char * UDPC_atostr_unsafe_cid(UDPC_ConnectionId cid)
Similar to UPDC_atostr(), but the returned ptr must be free'd.
UDPC_EXPORT int UDPC_enable_threaded_update_ms(UDPC_HContext ctx, int updateMS)
Enables auto updating on a separate thread for the given UDPC_HContext with the specified update inte...
UDPC_EXPORT unsigned long UDPC_get_queued_size(UDPC_HContext ctx, UDPC_ConnectionId id, int *exists)
Gets the size of a connection's queue of queued packets.
-
enum UDPC_EXPORT UDPC_AuthPolicy UDPC_AuthPolicy
Definition UDPC.h:152
-
UDPC_INFO
Log errors, warnings, and info.
Definition UDPC.h:143
+
enum UDPC_EXPORT UDPC_AuthPolicy UDPC_AuthPolicy
Definition UDPC.h:151
+
UDPC_INFO
Log errors, warnings, and info.
Definition UDPC.h:142
UDPC_EXPORT UDPC_IPV6_ADDR_TYPE UDPC_strtoa(const char *addrStr)
addrStr must be a valid ipv6 address or a valid ipv4 address
UDPC_EXPORT UDPC_Event UDPC_get_event(UDPC_HContext ctx, unsigned long *remaining)
Gets a recorded event.
UDPC_EXPORT void UDPC_atostr_unsafe_free_ptr(const char **addrBuf)
Free an addr string created with UDPC_atostr_unsafe() and zeroes the pointer.
@@ -422,7 +422,7 @@ $(function(){ initResizable(false); });
UDPC_EXPORT int UDPC_unset_libsodium_keys(UDPC_HContext ctx)
Removes set keys if any used for packet verification.
UDPC_EXPORT void UDPC_free_PacketInfo(UDPC_PacketInfo pInfo)
Frees a UDPC_PacketInfo.
UDPC_EXPORT void UDPC_update(UDPC_HContext ctx)
Updates the context.
-
UDPC_AUTH_POLICY_STRICT
Only peers with public key verification will be allowed.
Definition UDPC.h:156
+
UDPC_AUTH_POLICY_STRICT
Only peers with public key verification will be allowed.
Definition UDPC.h:155
UDPC_EXPORT UDPC_ConnectionId * UDPC_get_list_connected(UDPC_HContext ctx, unsigned int *size)
Gets a dynamically allocated array of connected peers' identifiers.
UDPC_EXPORT UDPC_LoggingType UDPC_set_logging_type(UDPC_HContext ctx, UDPC_LoggingType loggingType)
Sets the logging type of the UDPC context.
UDPC_EXPORT int UDPC_add_whitelist_pk(UDPC_HContext ctx, const unsigned char *pk)
Adds a public key to the whitelist.
@@ -437,11 +437,11 @@ $(function(){ initResizable(false); });
UDPC_EXPORT const char * UDPC_atostr_unsafe(UDPC_IPV6_ADDR_TYPE addr)
Similar to UPDC_atostr(), but the returned ptr must be free'd.
UDPC_EXPORT double UDPC_no64f(double f)
Converts a 64-bit float into/from network byte order (big endian).
UDPC_EXPORT int UDPC_has_whitelist_pk(UDPC_HContext ctx, const unsigned char *pk)
Checks if a public key is in the whitelist.
-
UDPC_AUTH_POLICY_FALLBACK
All peers will not be denied regardless of use of public key verification.
Definition UDPC.h:154
-
UDPC_WARNING
Log errors and warnings.
Definition UDPC.h:141
+
UDPC_AUTH_POLICY_FALLBACK
All peers will not be denied regardless of use of public key verification.
Definition UDPC.h:153
+
UDPC_WARNING
Log errors and warnings.
Definition UDPC.h:140
UDPC_EXPORT const char * UDPC_atostr(UDPC_HContext ctx, UDPC_IPV6_ADDR_TYPE addr)
Returns a pointer to a null-terminated address string derived from the given address.
UDPC_EXPORT unsigned long UDPC_get_queue_send_current_size(UDPC_HContext ctx)
Gets the size of the data structure holding queued packets.
-
UDPC_SILENT
Does not log anything.
Definition UDPC.h:137
+
UDPC_SILENT
Does not log anything.
Definition UDPC.h:136
UDPC_EXPORT uint32_t UDPC_get_protocol_id(UDPC_HContext ctx)
Gets the protocol id of the UDPC context.
UDPC_EXPORT void UDPC_destroy(UDPC_HContext ctx)
Cleans up the UDPC_HContext.
UDPC_EXPORT int UDPC_get_auth_policy(UDPC_HContext ctx)
Gets how peers are handled regarding public key verification.
@@ -450,26 +450,26 @@ $(function(){ initResizable(false); });
UDPC_EXPORT int UDPC_remove_whitelist_pk(UDPC_HContext ctx, const unsigned char *pk)
Removes a public key from the whitelist.
UDPC_EXPORT int UDPC_set_libsodium_keys(UDPC_HContext ctx, const unsigned char *sk, const unsigned char *pk)
Sets public/private keys used for packet verification.
UDPC_EXPORT int UDPC_is_valid_context(UDPC_HContext ctx)
Checks if the given UDPC_HContext is valid (successfully initialized)
-
UDPC_ERROR
Only log errors.
Definition UDPC.h:139
+
UDPC_ERROR
Only log errors.
Definition UDPC.h:138
UDPC_EXPORT UDPC_LoggingType UDPC_get_logging_type(UDPC_HContext ctx)
Gets the logging type of the UDPC context.
-
UDPC_VERBOSE
Log errors, warning, info, and verbose.
Definition UDPC.h:145
+
UDPC_VERBOSE
Log errors, warning, info, and verbose.
Definition UDPC.h:144
UDPC_EXPORT void UDPC_free_PacketInfo_ptr(UDPC_PacketInfo *pInfoPtr)
Frees a UDPC_PacketInfo.
UDPC_EXPORT int UDPC_set_libsodium_key_easy(UDPC_HContext ctx, const unsigned char *sk)
Sets the public/private keys used for packet verification.
-
enum UDPC_EXPORT UDPC_EventType UDPC_EventType
An enum describing the type of event.
Definition UDPC.h:246
+
enum UDPC_EXPORT UDPC_EventType UDPC_EventType
An enum describing the type of event.
Definition UDPC.h:245
struct UDPC_EXPORT UDPC_PacketInfo UDPC_PacketInfo
Data representing a received/sent packet.
struct UDPC_EXPORT UDPC_ConnectionId UDPC_ConnectionId
Data identifying a peer via addr, port, and scope_id.
UDPC_EXPORT UDPC_ConnectionId UDPC_create_id(UDPC_IPV6_ADDR_TYPE addr, uint16_t port)
Creates an UDPC_ConnectionId with the given addr and port.
UDPC_EXPORT UDPC_PacketInfo UDPC_get_received(UDPC_HContext ctx, unsigned long *remaining)
Get a received packet from a given UDPC context.
-
Data identifying a peer via addr, port, and scope_id.
Definition UDPC.h:169
-
A struct containing information related to the type of event.
Definition UDPC.h:267
-
Data representing a received/sent packet.
Definition UDPC.h:184
-
char * data
Definition UDPC.h:190
-
UDPC_ConnectionId sender
The UDPC_ConnectionId of the sender.
Definition UDPC.h:222
-
uint16_t dataSize
The size in bytes of the received packet's data inside the data pointer member variable.
Definition UDPC.h:219
-
UDPC_ConnectionId receiver
The UDPC_ConnectionId of the receiver.
Definition UDPC.h:224
-
uint32_t id
The packet's id.
Definition UDPC.h:209
-
uint32_t flags
Flags indication some additional information about the received packet.
Definition UDPC.h:201
-
Definition UDPC.h:270
+
Data identifying a peer via addr, port, and scope_id.
Definition UDPC.h:168
+
A struct containing information related to the type of event.
Definition UDPC.h:266
+
Data representing a received/sent packet.
Definition UDPC.h:183
+
char * data
Definition UDPC.h:189
+
UDPC_ConnectionId sender
The UDPC_ConnectionId of the sender.
Definition UDPC.h:221
+
uint16_t dataSize
The size in bytes of the received packet's data inside the data pointer member variable.
Definition UDPC.h:218
+
UDPC_ConnectionId receiver
The UDPC_ConnectionId of the receiver.
Definition UDPC.h:223
+
uint32_t id
The packet's id.
Definition UDPC.h:208
+
uint32_t flags
Flags indication some additional information about the received packet.
Definition UDPC.h:200
+
Definition UDPC.h:269