static int friend_new_connection(Friend_Connections *fr_c, int friendcon_id) { Friend_Conn *const friend_con = get_conn(fr_c, friendcon_id); if (!friend_con) { return -1; } if (friend_con->crypt_connection_id != -1) { return -1; } /* If dht_temp_pk does not contains a pk. */ if (!friend_con->dht_lock) { return -1; } const int id = new_crypto_connection(fr_c->net_crypto, friend_con->real_public_key, friend_con->dht_temp_pk); if (id == -1) { return -1; } friend_con->crypt_connection_id = id; connection_status_handler(fr_c->net_crypto, id, &handle_status, fr_c, friendcon_id); connection_data_handler(fr_c->net_crypto, id, &handle_packet, fr_c, friendcon_id); connection_lossy_data_handler(fr_c->net_crypto, id, &handle_lossy_packet, fr_c, friendcon_id); nc_dht_pk_callback(fr_c->net_crypto, id, &dht_pk_callback, fr_c, friendcon_id); return 0; }
static int friend_new_connection(Friend_Connections *fr_c, int friendcon_id) { Friend_Conn *friend_con = get_conn(fr_c, friendcon_id); if (!friend_con) return -1; if (friend_con->crypt_connection_id != -1) { return -1; } int id = new_crypto_connection(fr_c->net_crypto, friend_con->real_public_key); if (id == -1) return -1; friend_con->crypt_connection_id = id; connection_status_handler(fr_c->net_crypto, id, &handle_status, fr_c, friendcon_id); connection_data_handler(fr_c->net_crypto, id, &handle_packet, fr_c, friendcon_id); connection_lossy_data_handler(fr_c->net_crypto, id, &handle_lossy_packet, fr_c, friendcon_id); nc_dht_pk_callback(fr_c->net_crypto, id, &dht_pk_callback, fr_c, friendcon_id); return 0; }