diff options
author | mannol <eniz_vukovic@hotmail.com> | 2015-04-29 01:02:47 +0200 |
---|---|---|
committer | mannol <eniz_vukovic@hotmail.com> | 2015-04-29 01:02:47 +0200 |
commit | d8c34f4ffafedc256e9a52af5e591c4998c0003d (patch) | |
tree | 190b3605de8f24a85caace8a841115e96dc4e539 /toxcore/friend_connection.h | |
parent | 9bba7a0434d0967d5dd76b8afc7783ea2edad0cf (diff) | |
parent | 3454bc7da78e467f55f6b7fea4e03775d2649a63 (diff) |
Merge branch 'master' into new_api
Diffstat (limited to 'toxcore/friend_connection.h')
-rw-r--r-- | toxcore/friend_connection.h | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/toxcore/friend_connection.h b/toxcore/friend_connection.h index b814eb0c..baca4b76 100644 --- a/toxcore/friend_connection.h +++ b/toxcore/friend_connection.h | |||
@@ -36,6 +36,7 @@ | |||
36 | #define GROUPCHAT_CALLBACK_INDEX 1 | 36 | #define GROUPCHAT_CALLBACK_INDEX 1 |
37 | 37 | ||
38 | #define PACKET_ID_ALIVE 16 | 38 | #define PACKET_ID_ALIVE 16 |
39 | #define PACKET_ID_SHARE_RELAYS 17 | ||
39 | #define PACKET_ID_FRIEND_REQUESTS 18 | 40 | #define PACKET_ID_FRIEND_REQUESTS 18 |
40 | 41 | ||
41 | /* Interval between the sending of ping packets. */ | 42 | /* Interval between the sending of ping packets. */ |
@@ -47,6 +48,14 @@ | |||
47 | /* Time before friend is removed from the DHT after last hearing about him. */ | 48 | /* Time before friend is removed from the DHT after last hearing about him. */ |
48 | #define FRIEND_DHT_TIMEOUT BAD_NODE_TIMEOUT | 49 | #define FRIEND_DHT_TIMEOUT BAD_NODE_TIMEOUT |
49 | 50 | ||
51 | #define FRIEND_MAX_STORED_TCP_RELAYS (MAX_FRIEND_TCP_CONNECTIONS * 4) | ||
52 | |||
53 | /* Max number of tcp relays sent to friends */ | ||
54 | #define MAX_SHARED_RELAYS (RECOMMENDED_FRIEND_TCP_CONNECTIONS) | ||
55 | |||
56 | /* Interval between the sending of tcp relay information */ | ||
57 | #define SHARE_RELAYS_INTERVAL (5 * 60) | ||
58 | |||
50 | 59 | ||
51 | enum { | 60 | enum { |
52 | FRIENDCONN_STATUS_NONE, | 61 | FRIENDCONN_STATUS_NONE, |
@@ -61,12 +70,13 @@ typedef struct { | |||
61 | uint8_t dht_temp_pk[crypto_box_PUBLICKEYBYTES]; | 70 | uint8_t dht_temp_pk[crypto_box_PUBLICKEYBYTES]; |
62 | uint16_t dht_lock; | 71 | uint16_t dht_lock; |
63 | IP_Port dht_ip_port; | 72 | IP_Port dht_ip_port; |
64 | uint64_t dht_ping_lastrecv, dht_ip_port_lastrecv; | 73 | uint64_t dht_pk_lastrecv, dht_ip_port_lastrecv; |
65 | 74 | ||
66 | int onion_friendnum; | 75 | int onion_friendnum; |
67 | int crypt_connection_id; | 76 | int crypt_connection_id; |
68 | 77 | ||
69 | uint64_t ping_lastrecv, ping_lastsent; | 78 | uint64_t ping_lastrecv, ping_lastsent; |
79 | uint64_t share_relays_lastsent; | ||
70 | 80 | ||
71 | struct { | 81 | struct { |
72 | int (*status_callback)(void *object, int id, uint8_t status); | 82 | int (*status_callback)(void *object, int id, uint8_t status); |
@@ -83,6 +93,9 @@ typedef struct { | |||
83 | } callbacks[MAX_FRIEND_CONNECTION_CALLBACKS]; | 93 | } callbacks[MAX_FRIEND_CONNECTION_CALLBACKS]; |
84 | 94 | ||
85 | uint16_t lock_count; | 95 | uint16_t lock_count; |
96 | |||
97 | Node_format tcp_relays[FRIEND_MAX_STORED_TCP_RELAYS]; | ||
98 | uint16_t tcp_relay_counter; | ||
86 | } Friend_Conn; | 99 | } Friend_Conn; |
87 | 100 | ||
88 | 101 | ||
@@ -96,6 +109,8 @@ typedef struct { | |||
96 | 109 | ||
97 | int (*fr_request_callback)(void *object, const uint8_t *source_pubkey, const uint8_t *data, uint16_t len); | 110 | int (*fr_request_callback)(void *object, const uint8_t *source_pubkey, const uint8_t *data, uint16_t len); |
98 | void *fr_request_object; | 111 | void *fr_request_object; |
112 | |||
113 | uint64_t last_LANdiscovery; | ||
99 | } Friend_Connections; | 114 | } Friend_Connections; |
100 | 115 | ||
101 | /* return friendcon_id corresponding to the real public key on success. | 116 | /* return friendcon_id corresponding to the real public key on success. |
@@ -127,6 +142,13 @@ int get_friendcon_public_keys(uint8_t *real_pk, uint8_t *dht_temp_pk, Friend_Con | |||
127 | */ | 142 | */ |
128 | void set_dht_temp_pk(Friend_Connections *fr_c, int friendcon_id, const uint8_t *dht_temp_pk); | 143 | void set_dht_temp_pk(Friend_Connections *fr_c, int friendcon_id, const uint8_t *dht_temp_pk); |
129 | 144 | ||
145 | /* Add a TCP relay associated to the friend. | ||
146 | * | ||
147 | * return -1 on failure. | ||
148 | * return 0 on success. | ||
149 | */ | ||
150 | int friend_add_tcp_relay(Friend_Connections *fr_c, int friendcon_id, IP_Port ip_port, const uint8_t *public_key); | ||
151 | |||
130 | /* Set the callbacks for the friend connection. | 152 | /* Set the callbacks for the friend connection. |
131 | * index is the index (0 to (MAX_FRIEND_CONNECTION_CALLBACKS - 1)) we want the callback to set in the array. | 153 | * index is the index (0 to (MAX_FRIEND_CONNECTION_CALLBACKS - 1)) we want the callback to set in the array. |
132 | * | 154 | * |