diff options
author | iphydf <iphydf@users.noreply.github.com> | 2018-01-15 01:23:08 +0000 |
---|---|---|
committer | iphydf <iphydf@users.noreply.github.com> | 2018-01-16 20:06:07 +0000 |
commit | 643eea60bb9dcf4ecb33d64666b1bc77cbfd7438 (patch) | |
tree | 2f98b0c7869fddac03f834be508a182da06f07b4 /toxcore/net_crypto.c | |
parent | 22db2b9fe581a35300b66126604d12e83c2eafb1 (diff) |
Make DHT a module-private type.
Diffstat (limited to 'toxcore/net_crypto.c')
-rw-r--r-- | toxcore/net_crypto.c | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/toxcore/net_crypto.c b/toxcore/net_crypto.c index 521dad2f..f03ddb87 100644 --- a/toxcore/net_crypto.c +++ b/toxcore/net_crypto.c | |||
@@ -223,7 +223,7 @@ static int create_cookie_request(const Net_Crypto *c, uint8_t *packet, uint8_t * | |||
223 | uint8_t nonce[CRYPTO_NONCE_SIZE]; | 223 | uint8_t nonce[CRYPTO_NONCE_SIZE]; |
224 | random_nonce(nonce); | 224 | random_nonce(nonce); |
225 | packet[0] = NET_PACKET_COOKIE_REQUEST; | 225 | packet[0] = NET_PACKET_COOKIE_REQUEST; |
226 | memcpy(packet + 1, c->dht->self_public_key, CRYPTO_PUBLIC_KEY_SIZE); | 226 | memcpy(packet + 1, dht_get_self_public_key(c->dht), CRYPTO_PUBLIC_KEY_SIZE); |
227 | memcpy(packet + 1 + CRYPTO_PUBLIC_KEY_SIZE, nonce, CRYPTO_NONCE_SIZE); | 227 | memcpy(packet + 1 + CRYPTO_PUBLIC_KEY_SIZE, nonce, CRYPTO_NONCE_SIZE); |
228 | int len = encrypt_data_symmetric(shared_key, nonce, plain, sizeof(plain), | 228 | int len = encrypt_data_symmetric(shared_key, nonce, plain, sizeof(plain), |
229 | packet + 1 + CRYPTO_PUBLIC_KEY_SIZE + CRYPTO_NONCE_SIZE); | 229 | packet + 1 + CRYPTO_PUBLIC_KEY_SIZE + CRYPTO_NONCE_SIZE); |
@@ -362,7 +362,7 @@ static int udp_handle_cookie_request(void *object, IP_Port source, const uint8_t | |||
362 | return 1; | 362 | return 1; |
363 | } | 363 | } |
364 | 364 | ||
365 | if ((uint32_t)sendpacket(c->dht->net, source, data, sizeof(data)) != sizeof(data)) { | 365 | if ((uint32_t)sendpacket(dht_get_net(c->dht), source, data, sizeof(data)) != sizeof(data)) { |
366 | return 1; | 366 | return 1; |
367 | } | 367 | } |
368 | 368 | ||
@@ -662,7 +662,7 @@ static int send_packet_to(Net_Crypto *c, int crypt_connection_id, const uint8_t | |||
662 | crypto_connection_status(c, crypt_connection_id, &direct_connected, NULL); | 662 | crypto_connection_status(c, crypt_connection_id, &direct_connected, NULL); |
663 | 663 | ||
664 | if (direct_connected) { | 664 | if (direct_connected) { |
665 | if ((uint32_t)sendpacket(c->dht->net, ip_port, data, length) == length) { | 665 | if ((uint32_t)sendpacket(dht_get_net(c->dht), ip_port, data, length) == length) { |
666 | pthread_mutex_unlock(&conn->mutex); | 666 | pthread_mutex_unlock(&conn->mutex); |
667 | return 0; | 667 | return 0; |
668 | } | 668 | } |
@@ -676,7 +676,7 @@ static int send_packet_to(Net_Crypto *c, int crypt_connection_id, const uint8_t | |||
676 | 676 | ||
677 | if ((((UDP_DIRECT_TIMEOUT / 2) + conn->direct_send_attempt_time) > current_time && length < 96) | 677 | if ((((UDP_DIRECT_TIMEOUT / 2) + conn->direct_send_attempt_time) > current_time && length < 96) |
678 | || data[0] == NET_PACKET_COOKIE_REQUEST || data[0] == NET_PACKET_CRYPTO_HS) { | 678 | || data[0] == NET_PACKET_COOKIE_REQUEST || data[0] == NET_PACKET_CRYPTO_HS) { |
679 | if ((uint32_t)sendpacket(c->dht->net, ip_port, data, length) == length) { | 679 | if ((uint32_t)sendpacket(dht_get_net(c->dht), ip_port, data, length) == length) { |
680 | direct_send_attempt = 1; | 680 | direct_send_attempt = 1; |
681 | conn->direct_send_attempt_time = unix_time(); | 681 | conn->direct_send_attempt_time = unix_time(); |
682 | } | 682 | } |
@@ -2941,7 +2941,7 @@ Net_Crypto *new_net_crypto(Logger *log, DHT *dht, TCP_Proxy_Info *proxy_info) | |||
2941 | 2941 | ||
2942 | temp->log = log; | 2942 | temp->log = log; |
2943 | 2943 | ||
2944 | temp->tcp_c = new_tcp_connections(dht->self_secret_key, proxy_info); | 2944 | temp->tcp_c = new_tcp_connections(dht_get_self_secret_key(dht), proxy_info); |
2945 | 2945 | ||
2946 | if (temp->tcp_c == NULL) { | 2946 | if (temp->tcp_c == NULL) { |
2947 | free(temp); | 2947 | free(temp); |
@@ -2965,10 +2965,10 @@ Net_Crypto *new_net_crypto(Logger *log, DHT *dht, TCP_Proxy_Info *proxy_info) | |||
2965 | 2965 | ||
2966 | temp->current_sleep_time = CRYPTO_SEND_PACKET_INTERVAL; | 2966 | temp->current_sleep_time = CRYPTO_SEND_PACKET_INTERVAL; |
2967 | 2967 | ||
2968 | networking_registerhandler(dht->net, NET_PACKET_COOKIE_REQUEST, &udp_handle_cookie_request, temp); | 2968 | networking_registerhandler(dht_get_net(dht), NET_PACKET_COOKIE_REQUEST, &udp_handle_cookie_request, temp); |
2969 | networking_registerhandler(dht->net, NET_PACKET_COOKIE_RESPONSE, &udp_handle_packet, temp); | 2969 | networking_registerhandler(dht_get_net(dht), NET_PACKET_COOKIE_RESPONSE, &udp_handle_packet, temp); |
2970 | networking_registerhandler(dht->net, NET_PACKET_CRYPTO_HS, &udp_handle_packet, temp); | 2970 | networking_registerhandler(dht_get_net(dht), NET_PACKET_CRYPTO_HS, &udp_handle_packet, temp); |
2971 | networking_registerhandler(dht->net, NET_PACKET_CRYPTO_DATA, &udp_handle_packet, temp); | 2971 | networking_registerhandler(dht_get_net(dht), NET_PACKET_CRYPTO_DATA, &udp_handle_packet, temp); |
2972 | 2972 | ||
2973 | bs_list_init(&temp->ip_port_list, sizeof(IP_Port), 8); | 2973 | bs_list_init(&temp->ip_port_list, sizeof(IP_Port), 8); |
2974 | 2974 | ||
@@ -3039,10 +3039,10 @@ void kill_net_crypto(Net_Crypto *c) | |||
3039 | 3039 | ||
3040 | kill_tcp_connections(c->tcp_c); | 3040 | kill_tcp_connections(c->tcp_c); |
3041 | bs_list_free(&c->ip_port_list); | 3041 | bs_list_free(&c->ip_port_list); |
3042 | networking_registerhandler(c->dht->net, NET_PACKET_COOKIE_REQUEST, NULL, NULL); | 3042 | networking_registerhandler(dht_get_net(c->dht), NET_PACKET_COOKIE_REQUEST, NULL, NULL); |
3043 | networking_registerhandler(c->dht->net, NET_PACKET_COOKIE_RESPONSE, NULL, NULL); | 3043 | networking_registerhandler(dht_get_net(c->dht), NET_PACKET_COOKIE_RESPONSE, NULL, NULL); |
3044 | networking_registerhandler(c->dht->net, NET_PACKET_CRYPTO_HS, NULL, NULL); | 3044 | networking_registerhandler(dht_get_net(c->dht), NET_PACKET_CRYPTO_HS, NULL, NULL); |
3045 | networking_registerhandler(c->dht->net, NET_PACKET_CRYPTO_DATA, NULL, NULL); | 3045 | networking_registerhandler(dht_get_net(c->dht), NET_PACKET_CRYPTO_DATA, NULL, NULL); |
3046 | crypto_memzero(c, sizeof(Net_Crypto)); | 3046 | crypto_memzero(c, sizeof(Net_Crypto)); |
3047 | free(c); | 3047 | free(c); |
3048 | } | 3048 | } |