summaryrefslogtreecommitdiff
path: root/toxcore/Messenger.h
diff options
context:
space:
mode:
Diffstat (limited to 'toxcore/Messenger.h')
-rw-r--r--toxcore/Messenger.h27
1 files changed, 6 insertions, 21 deletions
diff --git a/toxcore/Messenger.h b/toxcore/Messenger.h
index 60d00225..454c31cb 100644
--- a/toxcore/Messenger.h
+++ b/toxcore/Messenger.h
@@ -26,11 +26,9 @@
26#ifndef MESSENGER_H 26#ifndef MESSENGER_H
27#define MESSENGER_H 27#define MESSENGER_H
28 28
29#include "net_crypto.h"
30#include "DHT.h"
31#include "friend_requests.h" 29#include "friend_requests.h"
32#include "LAN_discovery.h" 30#include "LAN_discovery.h"
33#include "onion_client.h" 31#include "friend_connection.h"
34 32
35#define MAX_NAME_LENGTH 128 33#define MAX_NAME_LENGTH 128
36/* TODO: this must depend on other variable. */ 34/* TODO: this must depend on other variable. */
@@ -41,8 +39,7 @@
41 39
42#define FRIEND_ADDRESS_SIZE (crypto_box_PUBLICKEYBYTES + sizeof(uint32_t) + sizeof(uint16_t)) 40#define FRIEND_ADDRESS_SIZE (crypto_box_PUBLICKEYBYTES + sizeof(uint32_t) + sizeof(uint16_t))
43 41
44/* NOTE: Packet ids below 16 must never be used. */ 42/* NOTE: Packet ids below 17 must never be used. */
45#define PACKET_ID_ALIVE 16
46#define PACKET_ID_SHARE_RELAYS 17 43#define PACKET_ID_SHARE_RELAYS 17
47#define PACKET_ID_NICKNAME 48 44#define PACKET_ID_NICKNAME 48
48#define PACKET_ID_STATUSMESSAGE 49 45#define PACKET_ID_STATUSMESSAGE 49
@@ -104,15 +101,9 @@ enum {
104/* Default start timeout in seconds between friend requests. */ 101/* Default start timeout in seconds between friend requests. */
105#define FRIENDREQUEST_TIMEOUT 5; 102#define FRIENDREQUEST_TIMEOUT 5;
106 103
107/* Interval between the sending of ping packets. */
108#define FRIEND_PING_INTERVAL 6
109
110/* Interval between the sending of tcp relay information */ 104/* Interval between the sending of tcp relay information */
111#define FRIEND_SHARE_RELAYS_INTERVAL (5 * 60) 105#define FRIEND_SHARE_RELAYS_INTERVAL (5 * 60)
112 106
113/* If no packets are received from friend in this time interval, kill the connection. */
114#define FRIEND_CONNECTION_TIMEOUT (FRIEND_PING_INTERVAL * 3)
115
116/* Must be < MAX_CRYPTO_DATA_SIZE */ 107/* Must be < MAX_CRYPTO_DATA_SIZE */
117#define AVATAR_DATA_MAX_CHUNK_SIZE (MAX_CRYPTO_DATA_SIZE-1) 108#define AVATAR_DATA_MAX_CHUNK_SIZE (MAX_CRYPTO_DATA_SIZE-1)
118 109
@@ -120,7 +111,6 @@ enum {
120#define AVATAR_DATA_TRANSFER_LIMIT (10*AVATAR_MAX_DATA_LENGTH) 111#define AVATAR_DATA_TRANSFER_LIMIT (10*AVATAR_MAX_DATA_LENGTH)
121#define AVATAR_DATA_TRANSFER_TIMEOUT (60) /* 164kB every 60 seconds is not a lot */ 112#define AVATAR_DATA_TRANSFER_TIMEOUT (60) /* 164kB every 60 seconds is not a lot */
122 113
123#define FRIEND_DHT_TIMEOUT BAD_NODE_TIMEOUT /* Time before friend is removed from the DHT after last hearing about him. */
124 114
125/* USERSTATUS - 115/* USERSTATUS -
126 * Represents userstatuses someone can have. 116 * Represents userstatuses someone can have.
@@ -197,14 +187,8 @@ enum {
197 187
198typedef struct { 188typedef struct {
199 uint8_t client_id[crypto_box_PUBLICKEYBYTES]; 189 uint8_t client_id[crypto_box_PUBLICKEYBYTES];
190 int friendcon_id;
200 191
201 uint8_t dht_temp_pk[crypto_box_PUBLICKEYBYTES];
202 uint16_t dht_lock;
203 IP_Port dht_ip_port;
204 uint64_t dht_ping_lastrecv, dht_ip_port_lastrecv;
205
206 uint32_t onion_friendnum;
207 int crypt_connection_id;
208 uint64_t friendrequest_lastsent; // Time at which the last friend request was sent. 192 uint64_t friendrequest_lastsent; // Time at which the last friend request was sent.
209 uint32_t friendrequest_timeout; // The timeout between successful friendrequest sending attempts. 193 uint32_t friendrequest_timeout; // The timeout between successful friendrequest sending attempts.
210 uint8_t status; // 0 if no friend, 1 if added, 2 if friend request sent, 3 if confirmed friend, 4 if online. 194 uint8_t status; // 0 if no friend, 1 if added, 2 if friend request sent, 3 if confirmed friend, 4 if online.
@@ -225,8 +209,7 @@ typedef struct {
225 uint32_t message_id; // a semi-unique id used in read receipts. 209 uint32_t message_id; // a semi-unique id used in read receipts.
226 uint8_t receives_read_receipts; // shall we send read receipts to this person? 210 uint8_t receives_read_receipts; // shall we send read receipts to this person?
227 uint32_t friendrequest_nospam; // The nospam number used in the friend request. 211 uint32_t friendrequest_nospam; // The nospam number used in the friend request.
228 uint64_t ping_lastrecv; 212 uint64_t ping_lastrecv;//TODO remove
229 uint64_t ping_lastsent;
230 uint64_t share_relays_lastsent; 213 uint64_t share_relays_lastsent;
231 struct File_Transfers file_sending[MAX_CONCURRENT_FILE_PIPES]; 214 struct File_Transfers file_sending[MAX_CONCURRENT_FILE_PIPES];
232 struct File_Transfers file_receiving[MAX_CONCURRENT_FILE_PIPES]; 215 struct File_Transfers file_receiving[MAX_CONCURRENT_FILE_PIPES];
@@ -256,6 +239,8 @@ typedef struct Messenger {
256 Onion_Announce *onion_a; 239 Onion_Announce *onion_a;
257 Onion_Client *onion_c; 240 Onion_Client *onion_c;
258 241
242 Friend_Connections *fr_c;
243
259 Friend_Requests fr; 244 Friend_Requests fr;
260 uint8_t name[MAX_NAME_LENGTH]; 245 uint8_t name[MAX_NAME_LENGTH];
261 uint16_t name_length; 246 uint16_t name_length;