diff options
author | dubslow <bunslow@gmail.com> | 2014-09-28 12:37:47 -0500 |
---|---|---|
committer | dubslow <bunslow@gmail.com> | 2014-09-28 12:37:47 -0500 |
commit | 57666d95bac5e070acda74020f5faca88cfa4bd5 (patch) | |
tree | 7dd17305a43ce332984034a1dec783d8e96ac780 /toxcore/net_crypto.h | |
parent | 3711b881cb6f64cf08209f70216ec75672464d1a (diff) | |
parent | 72d6a92efd8cad191282c8a2e294a768c49d5f25 (diff) |
Merge branch 'master' of https://github.com/irungentoo/toxcore
Diffstat (limited to 'toxcore/net_crypto.h')
-rw-r--r-- | toxcore/net_crypto.h | 25 |
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 | ||
166 | typedef struct { | 169 | typedef 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 | */ |
241 | uint64_t get_connection_dht_key(const Net_Crypto *c, int crypt_connection_id, uint8_t *dht_public_key); | 244 | unsigned 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 | */ |
250 | int set_connection_dht_public_key(Net_Crypto *c, int crypt_connection_id, const uint8_t *dht_public_key, | 251 | int 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 | */ | ||
305 | int 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 | */ |