summaryrefslogtreecommitdiff
path: root/toxcore/net_crypto.h
diff options
context:
space:
mode:
Diffstat (limited to 'toxcore/net_crypto.h')
-rw-r--r--toxcore/net_crypto.h25
1 files changed, 18 insertions, 7 deletions
diff --git a/toxcore/net_crypto.h b/toxcore/net_crypto.h
index 5e5df499..3245b6a2 100644
--- a/toxcore/net_crypto.h
+++ b/toxcore/net_crypto.h
@@ -111,7 +111,6 @@ typedef struct {
111 uint64_t cookie_request_number; /* number used in the cookie request packets for this connection */ 111 uint64_t cookie_request_number; /* number used in the cookie request packets for this connection */
112 uint8_t dht_public_key[crypto_box_PUBLICKEYBYTES]; /* The dht public key of the peer */ 112 uint8_t dht_public_key[crypto_box_PUBLICKEYBYTES]; /* The dht public key of the peer */
113 uint8_t dht_public_key_set; /* True if the dht public key is set, false if it isn't. */ 113 uint8_t dht_public_key_set; /* True if the dht public key is set, false if it isn't. */
114 uint64_t dht_public_key_timestamp; /* Timestamp of the last time we confirmed the key was correct. */
115 114
116 uint8_t *temp_packet; /* Where the cookie request/handshake packet is stored while it is being sent. */ 115 uint8_t *temp_packet; /* Where the cookie request/handshake packet is stored while it is being sent. */
117 uint16_t temp_packet_length; 116 uint16_t temp_packet_length;
@@ -161,6 +160,10 @@ typedef struct {
161 uint8_t maximum_speed_reached; 160 uint8_t maximum_speed_reached;
162 161
163 pthread_mutex_t mutex; 162 pthread_mutex_t mutex;
163
164 void (*dht_pk_callback)(void *data, int32_t number, const uint8_t *dht_public_key);
165 void *dht_pk_callback_object;
166 uint32_t dht_pk_callback_number;
164} Crypto_Connection; 167} Crypto_Connection;
165 168
166typedef struct { 169typedef struct {
@@ -236,19 +239,16 @@ int new_crypto_connection(Net_Crypto *c, const uint8_t *real_public_key);
236/* Copy friends DHT public key into dht_key. 239/* Copy friends DHT public key into dht_key.
237 * 240 *
238 * return 0 on failure (no key copied). 241 * return 0 on failure (no key copied).
239 * return timestamp on success (key copied). 242 * return 1 on success (key copied).
240 */ 243 */
241uint64_t get_connection_dht_key(const Net_Crypto *c, int crypt_connection_id, uint8_t *dht_public_key); 244unsigned int get_connection_dht_key(const Net_Crypto *c, int crypt_connection_id, uint8_t *dht_public_key);
242 245
243/* Set the DHT public key of the crypto connection. 246/* Set the DHT public key of the crypto connection.
244 * timestamp is the time (current_time_monotonic()) at which the key was last confirmed belonging to
245 * the other peer.
246 * 247 *
247 * return -1 on failure. 248 * return -1 on failure.
248 * return 0 on success. 249 * return 0 on success.
249 */ 250 */
250int set_connection_dht_public_key(Net_Crypto *c, int crypt_connection_id, const uint8_t *dht_public_key, 251int set_connection_dht_public_key(Net_Crypto *c, int crypt_connection_id, const uint8_t *dht_public_key);
251 uint64_t timestamp);
252 252
253/* Set the direct ip of the crypto connection. 253/* Set the direct ip of the crypto connection.
254 * 254 *
@@ -294,6 +294,17 @@ int connection_lossy_data_handler(Net_Crypto *c, int crypt_connection_id,
294 int (*connection_lossy_data_callback)(void *object, int id, const uint8_t *data, uint16_t length), void *object, 294 int (*connection_lossy_data_callback)(void *object, int id, const uint8_t *data, uint16_t length), void *object,
295 int id); 295 int id);
296 296
297/* Set the function for this friend that will be callbacked with object and number
298 * when that friend gives us his DHT temporary public key.
299 *
300 * object and number will be passed as argument to this function.
301 *
302 * return -1 on failure.
303 * return 0 on success.
304 */
305int nc_dht_pk_callback(Net_Crypto *c, int crypt_connection_id, void (*function)(void *data, int32_t number,
306 const uint8_t *dht_public_key), void *object, uint32_t number);
307
297/* returns the number of packet slots left in the sendbuffer. 308/* returns the number of packet slots left in the sendbuffer.
298 * return 0 if failure. 309 * return 0 if failure.
299 */ 310 */