diff options
Diffstat (limited to 'toxcore/friend_connection.c')
-rw-r--r-- | toxcore/friend_connection.c | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/toxcore/friend_connection.c b/toxcore/friend_connection.c index 09dea4c3..1838c62d 100644 --- a/toxcore/friend_connection.c +++ b/toxcore/friend_connection.c | |||
@@ -370,6 +370,60 @@ static int send_ping(const Friend_Connections *fr_c, int friendcon_id) | |||
370 | return -1; | 370 | return -1; |
371 | } | 371 | } |
372 | 372 | ||
373 | /* Increases lock_count for the connection with friendcon_id by 1. | ||
374 | * | ||
375 | * return 0 on success. | ||
376 | * return -1 on failure. | ||
377 | */ | ||
378 | int friend_connection_lock(Friend_Connections *fr_c, int friendcon_id) | ||
379 | { | ||
380 | Friend_Conn *friend_con = get_conn(fr_c, friendcon_id); | ||
381 | |||
382 | if (!friend_con) | ||
383 | return -1; | ||
384 | |||
385 | ++friend_con->lock_count; | ||
386 | return 0; | ||
387 | } | ||
388 | |||
389 | /* return FRIENDCONN_STATUS_CONNECTED if the friend is connected. | ||
390 | * return FRIENDCONN_STATUS_CONNECTING if the friend isn't connected. | ||
391 | * return FRIENDCONN_STATUS_NONE on failure. | ||
392 | */ | ||
393 | unsigned int friend_con_connected(Friend_Connections *fr_c, int friendcon_id) | ||
394 | { | ||
395 | Friend_Conn *friend_con = get_conn(fr_c, friendcon_id); | ||
396 | |||
397 | if (!friend_con) | ||
398 | return 0; | ||
399 | |||
400 | return friend_con->status; | ||
401 | } | ||
402 | |||
403 | /* Copy public keys associated to friendcon_id. | ||
404 | * | ||
405 | * return 0 on success. | ||
406 | * return -1 on failure. | ||
407 | */ | ||
408 | int get_friendcon_public_keys(uint8_t *real_pk, uint8_t *dht_temp_pk, Friend_Connections *fr_c, int friendcon_id) | ||
409 | { | ||
410 | Friend_Conn *friend_con = get_conn(fr_c, friendcon_id); | ||
411 | |||
412 | if (!friend_con) | ||
413 | return -1; | ||
414 | |||
415 | memcpy(real_pk, friend_con->real_public_key, crypto_box_PUBLICKEYBYTES); | ||
416 | memcpy(dht_temp_pk, friend_con->dht_temp_pk, crypto_box_PUBLICKEYBYTES); | ||
417 | return 0; | ||
418 | } | ||
419 | |||
420 | /* Set temp dht key for connection. | ||
421 | */ | ||
422 | void set_dht_temp_pk(Friend_Connections *fr_c, int friendcon_id, uint8_t *dht_temp_pk) | ||
423 | { | ||
424 | dht_pk_callback(fr_c, friendcon_id, dht_temp_pk); | ||
425 | } | ||
426 | |||
373 | /* Set the callbacks for the friend connection. | 427 | /* Set the callbacks for the friend connection. |
374 | * index is the index (0 to (MAX_FRIEND_CONNECTION_CALLBACKS - 1)) we want the callback to set in the array. | 428 | * index is the index (0 to (MAX_FRIEND_CONNECTION_CALLBACKS - 1)) we want the callback to set in the array. |
375 | * | 429 | * |