Skip to content

Commit

Permalink
wip: ipv6 -> ""
Browse files Browse the repository at this point in the history
  • Loading branch information
Green-Sky committed Feb 4, 2025
1 parent b42e921 commit 07f555f
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
16 changes: 8 additions & 8 deletions toxcore/DHT.c
Original file line number Diff line number Diff line change
Expand Up @@ -1360,10 +1360,10 @@ bool dht_send_nodes_request(DHT *dht, const IP_Port *ip_port, const uint8_t *pub
return sendpacket(dht->net, ip_port, data, len) > 0;
}

/** Send a nodes response: message for IPv6 nodes */
/** Send a nodes response */
non_null()
static int send_nodes_response_ipv6(const DHT *dht, const IP_Port *ip_port, const uint8_t *public_key, const uint8_t *client_id,
const uint8_t *sendback_data, uint16_t length, const uint8_t *shared_encryption_key)
static int send_nodes_response(const DHT *dht, const IP_Port *ip_port, const uint8_t *public_key, const uint8_t *client_id,
const uint8_t *sendback_data, uint16_t length, const uint8_t *shared_encryption_key)
{
/* Check if packet is going to be sent to ourself. */
if (pk_equal(public_key, dht->self_public_key)) {
Expand Down Expand Up @@ -1400,7 +1400,7 @@ static int send_nodes_response_ipv6(const DHT *dht, const IP_Port *ip_port, cons
VLA(uint8_t, data, data_size);

const int len = dht_create_packet(dht->mem, dht->rng,
dht->self_public_key, shared_encryption_key, NET_PACKET_NODES_RESPONSE_IPV6,
dht->self_public_key, shared_encryption_key, NET_PACKET_NODES_RESPONSE,
plain, 1 + nodes_length + length, data, data_size);

if (len < 0 || (uint32_t)len != data_size) {
Expand Down Expand Up @@ -1440,7 +1440,7 @@ static int handle_nodes_request(void *object, const IP_Port *source, const uint8
return 1;
}

send_nodes_response_ipv6(dht, source, packet + 1, plain, plain + CRYPTO_PUBLIC_KEY_SIZE, sizeof(uint64_t), shared_key);
send_nodes_response(dht, source, packet + 1, plain, plain + CRYPTO_PUBLIC_KEY_SIZE, sizeof(uint64_t), shared_key);

ping_add(dht->ping, packet + 1, source);

Expand Down Expand Up @@ -1537,7 +1537,7 @@ static bool handle_nodes_response_core(void *object, const IP_Port *source, cons
}

non_null()
static int handle_nodes_response_ipv6(void *object, const IP_Port *source, const uint8_t *packet, uint16_t length,
static int handle_nodes_response(void *object, const IP_Port *source, const uint8_t *packet, uint16_t length,
void *userdata)
{
DHT *const dht = (DHT *)object;
Expand Down Expand Up @@ -2598,7 +2598,7 @@ DHT *new_dht(const Logger *log, const Memory *mem, const Random *rng, const Netw
}

networking_registerhandler(dht->net, NET_PACKET_NODES_REQUEST, &handle_nodes_request, dht);
networking_registerhandler(dht->net, NET_PACKET_NODES_RESPONSE_IPV6, &handle_nodes_response_ipv6, dht);
networking_registerhandler(dht->net, NET_PACKET_NODES_RESPONSE, &handle_nodes_response, dht);
networking_registerhandler(dht->net, NET_PACKET_CRYPTO, &cryptopacket_handle, dht);
networking_registerhandler(dht->net, NET_PACKET_LAN_DISCOVERY, &handle_lan_discovery, dht);
cryptopacket_registerhandler(dht, CRYPTO_PACKET_NAT_PING, &handle_nat_ping, dht);
Expand Down Expand Up @@ -2677,7 +2677,7 @@ void kill_dht(DHT *dht)
}

networking_registerhandler(dht->net, NET_PACKET_NODES_REQUEST, nullptr, nullptr);
networking_registerhandler(dht->net, NET_PACKET_NODES_RESPONSE_IPV6, nullptr, nullptr);
networking_registerhandler(dht->net, NET_PACKET_NODES_RESPONSE, nullptr, nullptr);
networking_registerhandler(dht->net, NET_PACKET_CRYPTO, nullptr, nullptr);
networking_registerhandler(dht->net, NET_PACKET_LAN_DISCOVERY, nullptr, nullptr);
cryptopacket_registerhandler(dht, CRYPTO_PACKET_NAT_PING, nullptr, nullptr);
Expand Down
2 changes: 1 addition & 1 deletion toxcore/network.c
Original file line number Diff line number Diff line change
Expand Up @@ -775,7 +775,7 @@ static const char *net_packet_type_name(Net_Packet_Type type)
case NET_PACKET_NODES_REQUEST:
return "NODES_REQUEST";

case NET_PACKET_NODES_RESPONSE_IPV6:
case NET_PACKET_NODES_RESPONSE:
return "NODES_RESPONSE_IPV6";

case NET_PACKET_COOKIE_REQUEST:
Expand Down
2 changes: 1 addition & 1 deletion toxcore/network.h
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ typedef enum Net_Packet_Type {
NET_PACKET_PING_REQUEST = 0x00, /* Ping request packet ID. */
NET_PACKET_PING_RESPONSE = 0x01, /* Ping response packet ID. */
NET_PACKET_NODES_REQUEST = 0x02, /* Nodes request packet ID. */
NET_PACKET_NODES_RESPONSE_IPV6 = 0x04, /* Nodes response packet ID for other addresses. */
NET_PACKET_NODES_RESPONSE = 0x04, /* Nodes response packet ID. */
NET_PACKET_COOKIE_REQUEST = 0x18, /* Cookie request packet */
NET_PACKET_COOKIE_RESPONSE = 0x19, /* Cookie response packet */
NET_PACKET_CRYPTO_HS = 0x1a, /* Crypto handshake packet */
Expand Down

0 comments on commit 07f555f

Please sign in to comment.