summaryrefslogtreecommitdiff
path: root/protocols/Tox/libtox/src/toxcore/net_crypto.h
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2024-02-15 12:18:35 +0300
committerGeorge Hazan <george.hazan@gmail.com>2024-02-15 12:18:35 +0300
commit31e72718ee54867accf0b739a24adc86f8b7ab54 (patch)
treef964c10c5d97d9fe4fd2bd8187c250faedcb0fd7 /protocols/Tox/libtox/src/toxcore/net_crypto.h
parent282e9c18d9d3b726cce3d2ef0babc88029661cb8 (diff)
libtox update
Diffstat (limited to 'protocols/Tox/libtox/src/toxcore/net_crypto.h')
-rw-r--r--protocols/Tox/libtox/src/toxcore/net_crypto.h61
1 files changed, 34 insertions, 27 deletions
diff --git a/protocols/Tox/libtox/src/toxcore/net_crypto.h b/protocols/Tox/libtox/src/toxcore/net_crypto.h
index 0c3dfd0d45..0d817e4315 100644
--- a/protocols/Tox/libtox/src/toxcore/net_crypto.h
+++ b/protocols/Tox/libtox/src/toxcore/net_crypto.h
@@ -13,8 +13,14 @@
#include "DHT.h"
#include "LAN_discovery.h"
+#include "TCP_client.h"
#include "TCP_connection.h"
+#include "attributes.h"
+#include "crypto_core.h"
#include "logger.h"
+#include "mem.h"
+#include "mono_time.h"
+#include "network.h"
/*** Crypto payloads. */
@@ -43,29 +49,30 @@
/*** Messages. */
-#define PACKET_ID_PADDING 0 // Denotes padding
-#define PACKET_ID_REQUEST 1 // Used to request unreceived packets
-#define PACKET_ID_KILL 2 // Used to kill connection
-
-#define PACKET_ID_ONLINE 24
-#define PACKET_ID_OFFLINE 25
-#define PACKET_ID_NICKNAME 48
-#define PACKET_ID_STATUSMESSAGE 49
-#define PACKET_ID_USERSTATUS 50
-#define PACKET_ID_TYPING 51
-#define PACKET_ID_MESSAGE 64
-#define PACKET_ID_ACTION 65 // PACKET_ID_MESSAGE + MESSAGE_ACTION
-#define PACKET_ID_MSI 69 // Used by AV to setup calls and etc
-#define PACKET_ID_FILE_SENDREQUEST 80
-#define PACKET_ID_FILE_CONTROL 81
-#define PACKET_ID_FILE_DATA 82
-#define PACKET_ID_INVITE_GROUPCHAT 95
-#define PACKET_ID_INVITE_CONFERENCE 96
-#define PACKET_ID_ONLINE_PACKET 97
-#define PACKET_ID_DIRECT_CONFERENCE 98
-#define PACKET_ID_MESSAGE_CONFERENCE 99
-#define PACKET_ID_REJOIN_CONFERENCE 100
-#define PACKET_ID_LOSSY_CONFERENCE 199
+typedef enum Packet_Id {
+ PACKET_ID_REQUEST = 1, // Used to request unreceived packets
+ PACKET_ID_KILL = 2, // Used to kill connection
+
+ PACKET_ID_ONLINE = 24,
+ PACKET_ID_OFFLINE = 25,
+ PACKET_ID_NICKNAME = 48,
+ PACKET_ID_STATUSMESSAGE = 49,
+ PACKET_ID_USERSTATUS = 50,
+ PACKET_ID_TYPING = 51,
+ PACKET_ID_MESSAGE = 64,
+ PACKET_ID_ACTION = 65, // PACKET_ID_MESSAGE + MESSAGE_ACTION
+ PACKET_ID_MSI = 69, // Used by AV to setup calls and etc
+ PACKET_ID_FILE_SENDREQUEST = 80,
+ PACKET_ID_FILE_CONTROL = 81,
+ PACKET_ID_FILE_DATA = 82,
+ PACKET_ID_INVITE_GROUPCHAT = 95,
+ PACKET_ID_INVITE_CONFERENCE = 96,
+ PACKET_ID_ONLINE_PACKET = 97,
+ PACKET_ID_DIRECT_CONFERENCE = 98,
+ PACKET_ID_MESSAGE_CONFERENCE = 99,
+ PACKET_ID_REJOIN_CONFERENCE = 100,
+ PACKET_ID_LOSSY_CONFERENCE = 199,
+} Packet_Id;
/** Maximum size of receiving and sending packet buffers. */
#define CRYPTO_PACKET_BUFFER_SIZE 32768 // Must be a power of 2
@@ -133,7 +140,7 @@ typedef struct New_Connection {
typedef int connection_status_cb(void *object, int id, bool status, void *userdata);
typedef int connection_data_cb(void *object, int id, const uint8_t *data, uint16_t length, void *userdata);
typedef int connection_lossy_data_cb(void *object, int id, const uint8_t *data, uint16_t length, void *userdata);
-typedef void dht_pk_cb(void *data, int32_t number, const uint8_t *dht_public_key, void *userdata);
+typedef void dht_pk_cb(void *object, int32_t number, const uint8_t *dht_public_key, void *userdata);
typedef int new_connection_cb(void *object, const New_Connection *n_c);
/** @brief Set function to be called when someone requests a new connection to us.
@@ -198,7 +205,6 @@ non_null()
int connection_data_handler(const Net_Crypto *c, int crypt_connection_id,
connection_data_cb *connection_data_callback, void *object, int id);
-
/** @brief Set function to be called when connection with crypt_connection_id receives a lossy data packet of length.
*
* The set function should return -1 on failure and 0 on success.
@@ -398,7 +404,8 @@ void load_secret_key(Net_Crypto *c, const uint8_t *sk);
* Sets all the global connection variables to their default values.
*/
non_null()
-Net_Crypto *new_net_crypto(const Logger *log, const Random *rng, const Network *ns, Mono_Time *mono_time, DHT *dht, const TCP_Proxy_Info *proxy_info);
+Net_Crypto *new_net_crypto(const Logger *log, const Memory *mem, const Random *rng, const Network *ns,
+ Mono_Time *mono_time, DHT *dht, const TCP_Proxy_Info *proxy_info);
/** return the optimal interval in ms for running do_net_crypto. */
non_null()
@@ -411,4 +418,4 @@ void do_net_crypto(Net_Crypto *c, void *userdata);
nullable(1)
void kill_net_crypto(Net_Crypto *c);
-#endif
+#endif /* C_TOXCORE_TOXCORE_NET_CRYPTO_H */