diff options
author | irungentoo <irungentoo@gmail.com> | 2015-08-07 20:53:53 -0400 |
---|---|---|
committer | irungentoo <irungentoo@gmail.com> | 2015-08-07 20:53:53 -0400 |
commit | 6cb8ff4d650c0466968978bae37485f9c5ae6c4f (patch) | |
tree | 4ccdc76384c42b829a3bba1b0251f4d1c988c046 /toxcore/ping.c | |
parent | 4d28630d4938f4a5a0f9db5f58650036a45f2ddc (diff) |
Removed a useless define.
Diffstat (limited to 'toxcore/ping.c')
-rw-r--r-- | toxcore/ping.c | 34 |
1 files changed, 17 insertions, 17 deletions
diff --git a/toxcore/ping.c b/toxcore/ping.c index 543ceec5..877aaca2 100644 --- a/toxcore/ping.c +++ b/toxcore/ping.c | |||
@@ -55,8 +55,8 @@ struct PING { | |||
55 | 55 | ||
56 | 56 | ||
57 | #define PING_PLAIN_SIZE (1 + sizeof(uint64_t)) | 57 | #define PING_PLAIN_SIZE (1 + sizeof(uint64_t)) |
58 | #define DHT_PING_SIZE (1 + CLIENT_ID_SIZE + crypto_box_NONCEBYTES + PING_PLAIN_SIZE + crypto_box_MACBYTES) | 58 | #define DHT_PING_SIZE (1 + crypto_box_PUBLICKEYBYTES + crypto_box_NONCEBYTES + PING_PLAIN_SIZE + crypto_box_MACBYTES) |
59 | #define PING_DATA_SIZE (CLIENT_ID_SIZE + sizeof(IP_Port)) | 59 | #define PING_DATA_SIZE (crypto_box_PUBLICKEYBYTES + sizeof(IP_Port)) |
60 | 60 | ||
61 | int send_ping_request(PING *ping, IP_Port ipp, const uint8_t *public_key) | 61 | int send_ping_request(PING *ping, IP_Port ipp, const uint8_t *public_key) |
62 | { | 62 | { |
@@ -74,7 +74,7 @@ int send_ping_request(PING *ping, IP_Port ipp, const uint8_t *public_key) | |||
74 | // Generate random ping_id. | 74 | // Generate random ping_id. |
75 | uint8_t data[PING_DATA_SIZE]; | 75 | uint8_t data[PING_DATA_SIZE]; |
76 | id_copy(data, public_key); | 76 | id_copy(data, public_key); |
77 | memcpy(data + CLIENT_ID_SIZE, &ipp, sizeof(IP_Port)); | 77 | memcpy(data + crypto_box_PUBLICKEYBYTES, &ipp, sizeof(IP_Port)); |
78 | ping_id = ping_array_add(&ping->ping_array, data, sizeof(data)); | 78 | ping_id = ping_array_add(&ping->ping_array, data, sizeof(data)); |
79 | 79 | ||
80 | if (ping_id == 0) | 80 | if (ping_id == 0) |
@@ -86,13 +86,13 @@ int send_ping_request(PING *ping, IP_Port ipp, const uint8_t *public_key) | |||
86 | 86 | ||
87 | pk[0] = NET_PACKET_PING_REQUEST; | 87 | pk[0] = NET_PACKET_PING_REQUEST; |
88 | id_copy(pk + 1, ping->dht->self_public_key); // Our pubkey | 88 | id_copy(pk + 1, ping->dht->self_public_key); // Our pubkey |
89 | new_nonce(pk + 1 + CLIENT_ID_SIZE); // Generate new nonce | 89 | new_nonce(pk + 1 + crypto_box_PUBLICKEYBYTES); // Generate new nonce |
90 | 90 | ||
91 | 91 | ||
92 | rc = encrypt_data_symmetric(shared_key, | 92 | rc = encrypt_data_symmetric(shared_key, |
93 | pk + 1 + CLIENT_ID_SIZE, | 93 | pk + 1 + crypto_box_PUBLICKEYBYTES, |
94 | ping_plain, sizeof(ping_plain), | 94 | ping_plain, sizeof(ping_plain), |
95 | pk + 1 + CLIENT_ID_SIZE + crypto_box_NONCEBYTES); | 95 | pk + 1 + crypto_box_PUBLICKEYBYTES + crypto_box_NONCEBYTES); |
96 | 96 | ||
97 | if (rc != PING_PLAIN_SIZE + crypto_box_MACBYTES) | 97 | if (rc != PING_PLAIN_SIZE + crypto_box_MACBYTES) |
98 | return 1; | 98 | return 1; |
@@ -115,13 +115,13 @@ static int send_ping_response(PING *ping, IP_Port ipp, const uint8_t *public_key | |||
115 | 115 | ||
116 | pk[0] = NET_PACKET_PING_RESPONSE; | 116 | pk[0] = NET_PACKET_PING_RESPONSE; |
117 | id_copy(pk + 1, ping->dht->self_public_key); // Our pubkey | 117 | id_copy(pk + 1, ping->dht->self_public_key); // Our pubkey |
118 | new_nonce(pk + 1 + CLIENT_ID_SIZE); // Generate new nonce | 118 | new_nonce(pk + 1 + crypto_box_PUBLICKEYBYTES); // Generate new nonce |
119 | 119 | ||
120 | // Encrypt ping_id using recipient privkey | 120 | // Encrypt ping_id using recipient privkey |
121 | rc = encrypt_data_symmetric(shared_encryption_key, | 121 | rc = encrypt_data_symmetric(shared_encryption_key, |
122 | pk + 1 + CLIENT_ID_SIZE, | 122 | pk + 1 + crypto_box_PUBLICKEYBYTES, |
123 | ping_plain, sizeof(ping_plain), | 123 | ping_plain, sizeof(ping_plain), |
124 | pk + 1 + CLIENT_ID_SIZE + crypto_box_NONCEBYTES ); | 124 | pk + 1 + crypto_box_PUBLICKEYBYTES + crypto_box_NONCEBYTES ); |
125 | 125 | ||
126 | if (rc != PING_PLAIN_SIZE + crypto_box_MACBYTES) | 126 | if (rc != PING_PLAIN_SIZE + crypto_box_MACBYTES) |
127 | return 1; | 127 | return 1; |
@@ -148,8 +148,8 @@ static int handle_ping_request(void *_dht, IP_Port source, const uint8_t *packet | |||
148 | // Decrypt ping_id | 148 | // Decrypt ping_id |
149 | DHT_get_shared_key_recv(dht, shared_key, packet + 1); | 149 | DHT_get_shared_key_recv(dht, shared_key, packet + 1); |
150 | rc = decrypt_data_symmetric(shared_key, | 150 | rc = decrypt_data_symmetric(shared_key, |
151 | packet + 1 + CLIENT_ID_SIZE, | 151 | packet + 1 + crypto_box_PUBLICKEYBYTES, |
152 | packet + 1 + CLIENT_ID_SIZE + crypto_box_NONCEBYTES, | 152 | packet + 1 + crypto_box_PUBLICKEYBYTES + crypto_box_NONCEBYTES, |
153 | PING_PLAIN_SIZE + crypto_box_MACBYTES, | 153 | PING_PLAIN_SIZE + crypto_box_MACBYTES, |
154 | ping_plain ); | 154 | ping_plain ); |
155 | 155 | ||
@@ -189,8 +189,8 @@ static int handle_ping_response(void *_dht, IP_Port source, const uint8_t *packe | |||
189 | uint8_t ping_plain[PING_PLAIN_SIZE]; | 189 | uint8_t ping_plain[PING_PLAIN_SIZE]; |
190 | // Decrypt ping_id | 190 | // Decrypt ping_id |
191 | rc = decrypt_data_symmetric(shared_key, | 191 | rc = decrypt_data_symmetric(shared_key, |
192 | packet + 1 + CLIENT_ID_SIZE, | 192 | packet + 1 + crypto_box_PUBLICKEYBYTES, |
193 | packet + 1 + CLIENT_ID_SIZE + crypto_box_NONCEBYTES, | 193 | packet + 1 + crypto_box_PUBLICKEYBYTES + crypto_box_NONCEBYTES, |
194 | PING_PLAIN_SIZE + crypto_box_MACBYTES, | 194 | PING_PLAIN_SIZE + crypto_box_MACBYTES, |
195 | ping_plain); | 195 | ping_plain); |
196 | 196 | ||
@@ -211,7 +211,7 @@ static int handle_ping_response(void *_dht, IP_Port source, const uint8_t *packe | |||
211 | return 1; | 211 | return 1; |
212 | 212 | ||
213 | IP_Port ipp; | 213 | IP_Port ipp; |
214 | memcpy(&ipp, data + CLIENT_ID_SIZE, sizeof(IP_Port)); | 214 | memcpy(&ipp, data + crypto_box_PUBLICKEYBYTES, sizeof(IP_Port)); |
215 | 215 | ||
216 | if (!ipport_equal(&ipp, &source)) | 216 | if (!ipport_equal(&ipp, &source)) |
217 | return 1; | 217 | return 1; |
@@ -269,12 +269,12 @@ int add_to_ping(PING *ping, const uint8_t *public_key, IP_Port ip_port) | |||
269 | 269 | ||
270 | for (i = 0; i < MAX_TO_PING; ++i) { | 270 | for (i = 0; i < MAX_TO_PING; ++i) { |
271 | if (!ip_isset(&ping->to_ping[i].ip_port.ip)) { | 271 | if (!ip_isset(&ping->to_ping[i].ip_port.ip)) { |
272 | memcpy(ping->to_ping[i].public_key, public_key, CLIENT_ID_SIZE); | 272 | memcpy(ping->to_ping[i].public_key, public_key, crypto_box_PUBLICKEYBYTES); |
273 | ipport_copy(&ping->to_ping[i].ip_port, &ip_port); | 273 | ipport_copy(&ping->to_ping[i].ip_port, &ip_port); |
274 | return 0; | 274 | return 0; |
275 | } | 275 | } |
276 | 276 | ||
277 | if (memcmp(ping->to_ping[i].public_key, public_key, CLIENT_ID_SIZE) == 0) { | 277 | if (memcmp(ping->to_ping[i].public_key, public_key, crypto_box_PUBLICKEYBYTES) == 0) { |
278 | return -1; | 278 | return -1; |
279 | } | 279 | } |
280 | } | 280 | } |
@@ -283,7 +283,7 @@ int add_to_ping(PING *ping, const uint8_t *public_key, IP_Port ip_port) | |||
283 | 283 | ||
284 | for (i = 0; i < MAX_TO_PING; ++i) { | 284 | for (i = 0; i < MAX_TO_PING; ++i) { |
285 | if (id_closest(ping->dht->self_public_key, ping->to_ping[(i + r) % MAX_TO_PING].public_key, public_key) == 2) { | 285 | if (id_closest(ping->dht->self_public_key, ping->to_ping[(i + r) % MAX_TO_PING].public_key, public_key) == 2) { |
286 | memcpy(ping->to_ping[(i + r) % MAX_TO_PING].public_key, public_key, CLIENT_ID_SIZE); | 286 | memcpy(ping->to_ping[(i + r) % MAX_TO_PING].public_key, public_key, crypto_box_PUBLICKEYBYTES); |
287 | ipport_copy(&ping->to_ping[(i + r) % MAX_TO_PING].ip_port, &ip_port); | 287 | ipport_copy(&ping->to_ping[(i + r) % MAX_TO_PING].ip_port, &ip_port); |
288 | return 0; | 288 | return 0; |
289 | } | 289 | } |