diff options
Diffstat (limited to 'toxcore')
-rw-r--r-- | toxcore/DHT.c | 6 | ||||
-rw-r--r-- | toxcore/LAN_discovery.c | 4 | ||||
-rw-r--r-- | toxcore/Messenger.c | 2 | ||||
-rw-r--r-- | toxcore/TCP_server.c | 2 | ||||
-rw-r--r-- | toxcore/net_crypto.c | 22 | ||||
-rw-r--r-- | toxcore/network.h | 2 | ||||
-rw-r--r-- | toxcore/onion.c | 18 | ||||
-rw-r--r-- | toxcore/onion.h | 8 | ||||
-rw-r--r-- | toxcore/onion_announce.c | 14 | ||||
-rw-r--r-- | toxcore/onion_client.c | 6 | ||||
-rw-r--r-- | toxcore/ping.c | 4 |
11 files changed, 44 insertions, 44 deletions
diff --git a/toxcore/DHT.c b/toxcore/DHT.c index 1055ddcd..ae61d988 100644 --- a/toxcore/DHT.c +++ b/toxcore/DHT.c | |||
@@ -1067,7 +1067,7 @@ static int sendnodes_ipv6(const DHT *dht, IP_Port ip_port, const uint8_t *public | |||
1067 | return sendpacket(dht->net, ip_port, data, 1 + CLIENT_ID_SIZE + crypto_box_NONCEBYTES + len); | 1067 | return sendpacket(dht->net, ip_port, data, 1 + CLIENT_ID_SIZE + crypto_box_NONCEBYTES + len); |
1068 | } | 1068 | } |
1069 | 1069 | ||
1070 | static int handle_getnodes(void *object, IP_Port source, uint8_t *packet, uint32_t length) | 1070 | static int handle_getnodes(void *object, IP_Port source, const uint8_t *packet, uint32_t length) |
1071 | { | 1071 | { |
1072 | uint32_t cmp_len = 1 + CLIENT_ID_SIZE + crypto_box_NONCEBYTES + CLIENT_ID_SIZE + crypto_box_MACBYTES; | 1072 | uint32_t cmp_len = 1 + CLIENT_ID_SIZE + crypto_box_NONCEBYTES + CLIENT_ID_SIZE + crypto_box_MACBYTES; |
1073 | 1073 | ||
@@ -1194,7 +1194,7 @@ static int handle_sendnodes_core(void *object, IP_Port source, const uint8_t *pa | |||
1194 | return 0; | 1194 | return 0; |
1195 | } | 1195 | } |
1196 | 1196 | ||
1197 | static int handle_sendnodes_ipv6(void *object, IP_Port source, uint8_t *packet, uint32_t length) | 1197 | static int handle_sendnodes_ipv6(void *object, IP_Port source, const uint8_t *packet, uint32_t length) |
1198 | { | 1198 | { |
1199 | DHT *dht = object; | 1199 | DHT *dht = object; |
1200 | Node_format plain_nodes[MAX_SENT_NODES]; | 1200 | Node_format plain_nodes[MAX_SENT_NODES]; |
@@ -2296,7 +2296,7 @@ void cryptopacket_registerhandler(DHT *dht, uint8_t byte, cryptopacket_handler_c | |||
2296 | dht->cryptopackethandlers[byte].object = object; | 2296 | dht->cryptopackethandlers[byte].object = object; |
2297 | } | 2297 | } |
2298 | 2298 | ||
2299 | static int cryptopacket_handle(void *object, IP_Port source, uint8_t *packet, uint32_t length) | 2299 | static int cryptopacket_handle(void *object, IP_Port source, const uint8_t *packet, uint32_t length) |
2300 | { | 2300 | { |
2301 | DHT *dht = object; | 2301 | DHT *dht = object; |
2302 | 2302 | ||
diff --git a/toxcore/LAN_discovery.c b/toxcore/LAN_discovery.c index 2deeadfd..e1b8534c 100644 --- a/toxcore/LAN_discovery.c +++ b/toxcore/LAN_discovery.c | |||
@@ -98,7 +98,7 @@ static void fetch_broadcast_info(uint16_t port) | |||
98 | * return 1 if sent to at least one broadcast target. | 98 | * return 1 if sent to at least one broadcast target. |
99 | * return 0 on failure to find any valid broadcast target. | 99 | * return 0 on failure to find any valid broadcast target. |
100 | */ | 100 | */ |
101 | static uint32_t send_broadcasts(Networking_Core *net, uint16_t port, uint8_t *data, uint16_t length) | 101 | static uint32_t send_broadcasts(Networking_Core *net, uint16_t port, const uint8_t *data, uint16_t length) |
102 | { | 102 | { |
103 | /* fetch only once? on every packet? every X seconds? | 103 | /* fetch only once? on every packet? every X seconds? |
104 | * old: every packet, new: once */ | 104 | * old: every packet, new: once */ |
@@ -207,7 +207,7 @@ int LAN_ip(IP ip) | |||
207 | return -1; | 207 | return -1; |
208 | } | 208 | } |
209 | 209 | ||
210 | static int handle_LANdiscovery(void *object, IP_Port source, uint8_t *packet, uint32_t length) | 210 | static int handle_LANdiscovery(void *object, IP_Port source, const uint8_t *packet, uint32_t length) |
211 | { | 211 | { |
212 | DHT *dht = object; | 212 | DHT *dht = object; |
213 | 213 | ||
diff --git a/toxcore/Messenger.c b/toxcore/Messenger.c index 37a7a252..dc8db8b3 100644 --- a/toxcore/Messenger.c +++ b/toxcore/Messenger.c | |||
@@ -1261,7 +1261,7 @@ int group_names(Messenger *m, int groupnumber, uint8_t names[][MAX_NICK_BYTES], | |||
1261 | return group_client_names(m->chats[groupnumber], names, lengths, length); | 1261 | return group_client_names(m->chats[groupnumber], names, lengths, length); |
1262 | } | 1262 | } |
1263 | 1263 | ||
1264 | static int handle_group(void *object, IP_Port source, uint8_t *packet, uint32_t length) | 1264 | static int handle_group(void *object, IP_Port source, const uint8_t *packet, uint32_t length) |
1265 | { | 1265 | { |
1266 | Messenger *m = object; | 1266 | Messenger *m = object; |
1267 | 1267 | ||
diff --git a/toxcore/TCP_server.c b/toxcore/TCP_server.c index d055215e..b900db6b 100644 --- a/toxcore/TCP_server.c +++ b/toxcore/TCP_server.c | |||
@@ -619,7 +619,7 @@ static int rm_connection_index(TCP_Server *TCP_server, TCP_Secure_Connection *co | |||
619 | } | 619 | } |
620 | } | 620 | } |
621 | 621 | ||
622 | static int handle_onion_recv_1(void *object, IP_Port dest, uint8_t *data, uint16_t length) | 622 | static int handle_onion_recv_1(void *object, IP_Port dest, const uint8_t *data, uint16_t length) |
623 | { | 623 | { |
624 | TCP_Server *TCP_server = object; | 624 | TCP_Server *TCP_server = object; |
625 | uint32_t index = dest.ip.ip6.uint32[0]; | 625 | uint32_t index = dest.ip.ip6.uint32[0]; |
diff --git a/toxcore/net_crypto.c b/toxcore/net_crypto.c index 78a6121c..c34c24d7 100644 --- a/toxcore/net_crypto.c +++ b/toxcore/net_crypto.c | |||
@@ -120,7 +120,7 @@ static int create_cookie(uint8_t *cookie, uint8_t *bytes, uint8_t *encryption_ke | |||
120 | * return -1 on failure. | 120 | * return -1 on failure. |
121 | * return 0 on success. | 121 | * return 0 on success. |
122 | */ | 122 | */ |
123 | static int open_cookie(uint8_t *bytes, uint8_t *cookie, uint8_t *encryption_key) | 123 | static int open_cookie(uint8_t *bytes, const uint8_t *cookie, const uint8_t *encryption_key) |
124 | { | 124 | { |
125 | uint8_t contents[COOKIE_CONTENTS_LENGTH]; | 125 | uint8_t contents[COOKIE_CONTENTS_LENGTH]; |
126 | int len = decrypt_data_symmetric(encryption_key, cookie, cookie + crypto_box_NONCEBYTES, | 126 | int len = decrypt_data_symmetric(encryption_key, cookie, cookie + crypto_box_NONCEBYTES, |
@@ -178,7 +178,7 @@ static int create_cookie_response(Net_Crypto *c, uint8_t *packet, uint8_t *reque | |||
178 | * return 0 on success. | 178 | * return 0 on success. |
179 | */ | 179 | */ |
180 | static int handle_cookie_request(Net_Crypto *c, uint8_t *request_plain, uint8_t *shared_key, uint8_t *dht_public_key, | 180 | static int handle_cookie_request(Net_Crypto *c, uint8_t *request_plain, uint8_t *shared_key, uint8_t *dht_public_key, |
181 | uint8_t *packet, uint16_t length) | 181 | const uint8_t *packet, uint16_t length) |
182 | { | 182 | { |
183 | if (length != COOKIE_REQUEST_LENGTH) | 183 | if (length != COOKIE_REQUEST_LENGTH) |
184 | return -1; | 184 | return -1; |
@@ -197,7 +197,7 @@ static int handle_cookie_request(Net_Crypto *c, uint8_t *request_plain, uint8_t | |||
197 | 197 | ||
198 | /* Handle the cookie request packet (for raw UDP) | 198 | /* Handle the cookie request packet (for raw UDP) |
199 | */ | 199 | */ |
200 | static int udp_handle_cookie_request(void *object, IP_Port source, uint8_t *packet, uint32_t length) | 200 | static int udp_handle_cookie_request(void *object, IP_Port source, const uint8_t *packet, uint32_t length) |
201 | { | 201 | { |
202 | Net_Crypto *c = object; | 202 | Net_Crypto *c = object; |
203 | uint8_t request_plain[COOKIE_REQUEST_PLAIN_LENGTH]; | 203 | uint8_t request_plain[COOKIE_REQUEST_PLAIN_LENGTH]; |
@@ -275,8 +275,8 @@ static int tcp_oob_handle_cookie_request(Net_Crypto *c, TCP_Client_Connection *T | |||
275 | * return -1 on failure. | 275 | * return -1 on failure. |
276 | * return COOKIE_LENGTH on success. | 276 | * return COOKIE_LENGTH on success. |
277 | */ | 277 | */ |
278 | static int handle_cookie_response(uint8_t *cookie, uint64_t *number, uint8_t *packet, uint32_t length, | 278 | static int handle_cookie_response(uint8_t *cookie, uint64_t *number, const uint8_t *packet, uint32_t length, |
279 | uint8_t *shared_key) | 279 | const uint8_t *shared_key) |
280 | { | 280 | { |
281 | if (length != COOKIE_RESPONSE_LENGTH) | 281 | if (length != COOKIE_RESPONSE_LENGTH) |
282 | return -1; | 282 | return -1; |
@@ -349,7 +349,7 @@ static int create_crypto_handshake(Net_Crypto *c, uint8_t *packet, uint8_t *cook | |||
349 | * return 0 on success. | 349 | * return 0 on success. |
350 | */ | 350 | */ |
351 | static int handle_crypto_handshake(Net_Crypto *c, uint8_t *nonce, uint8_t *session_pk, uint8_t *peer_real_pk, | 351 | static int handle_crypto_handshake(Net_Crypto *c, uint8_t *nonce, uint8_t *session_pk, uint8_t *peer_real_pk, |
352 | uint8_t *dht_public_key, uint8_t *cookie, uint8_t *packet, uint32_t length, uint8_t *expected_real_pk) | 352 | uint8_t *dht_public_key, uint8_t *cookie, const uint8_t *packet, uint32_t length, uint8_t *expected_real_pk) |
353 | { | 353 | { |
354 | if (length != HANDSHAKE_PACKET_LENGTH) | 354 | if (length != HANDSHAKE_PACKET_LENGTH) |
355 | return -1; | 355 | return -1; |
@@ -815,7 +815,7 @@ static uint16_t get_nonce_uint16(uint8_t *nonce) | |||
815 | * return -1 on failure. | 815 | * return -1 on failure. |
816 | * return length of data on success. | 816 | * return length of data on success. |
817 | */ | 817 | */ |
818 | static int handle_data_packet(Net_Crypto *c, int crypt_connection_id, uint8_t *data, uint8_t *packet, uint16_t length) | 818 | static int handle_data_packet(Net_Crypto *c, int crypt_connection_id, uint8_t *data, const uint8_t *packet, uint16_t length) |
819 | { | 819 | { |
820 | if (length <= (1 + sizeof(uint16_t) + crypto_box_MACBYTES) || length > MAX_CRYPTO_PACKET_SIZE) | 820 | if (length <= (1 + sizeof(uint16_t) + crypto_box_MACBYTES) || length > MAX_CRYPTO_PACKET_SIZE) |
821 | return -1; | 821 | return -1; |
@@ -1039,7 +1039,7 @@ static int send_kill_packet(Net_Crypto *c, int crypt_connection_id) | |||
1039 | * return -1 on failure. | 1039 | * return -1 on failure. |
1040 | * return 0 on success. | 1040 | * return 0 on success. |
1041 | */ | 1041 | */ |
1042 | static int handle_data_packet_helper(Net_Crypto *c, int crypt_connection_id, uint8_t *packet, uint16_t length) | 1042 | static int handle_data_packet_helper(Net_Crypto *c, int crypt_connection_id, const uint8_t *packet, uint16_t length) |
1043 | { | 1043 | { |
1044 | if (length > MAX_CRYPTO_PACKET_SIZE || length <= CRYPTO_DATA_PACKET_MIN_SIZE) | 1044 | if (length > MAX_CRYPTO_PACKET_SIZE || length <= CRYPTO_DATA_PACKET_MIN_SIZE) |
1045 | return -1; | 1045 | return -1; |
@@ -1133,7 +1133,7 @@ static int handle_data_packet_helper(Net_Crypto *c, int crypt_connection_id, uin | |||
1133 | * return -1 on failure. | 1133 | * return -1 on failure. |
1134 | * return 0 on success. | 1134 | * return 0 on success. |
1135 | */ | 1135 | */ |
1136 | static int handle_packet_connection(Net_Crypto *c, int crypt_connection_id, uint8_t *packet, uint16_t length) | 1136 | static int handle_packet_connection(Net_Crypto *c, int crypt_connection_id, const uint8_t *packet, uint16_t length) |
1137 | { | 1137 | { |
1138 | if (length == 0 || length > MAX_CRYPTO_PACKET_SIZE) | 1138 | if (length == 0 || length > MAX_CRYPTO_PACKET_SIZE) |
1139 | return -1; | 1139 | return -1; |
@@ -1370,7 +1370,7 @@ void new_connection_handler(Net_Crypto *c, int (*new_connection_callback)(void * | |||
1370 | * return -1 on failure. | 1370 | * return -1 on failure. |
1371 | * return 0 on success. | 1371 | * return 0 on success. |
1372 | */ | 1372 | */ |
1373 | static int handle_new_connection_handshake(Net_Crypto *c, IP_Port source, uint8_t *data, uint16_t length) | 1373 | static int handle_new_connection_handshake(Net_Crypto *c, IP_Port source, const uint8_t *data, uint16_t length) |
1374 | { | 1374 | { |
1375 | New_Connection n_c; | 1375 | New_Connection n_c; |
1376 | n_c.cookie = malloc(COOKIE_LENGTH); | 1376 | n_c.cookie = malloc(COOKIE_LENGTH); |
@@ -2123,7 +2123,7 @@ static int crypto_id_ip_port(Net_Crypto *c, IP_Port ip_port) | |||
2123 | * Crypto data packets. | 2123 | * Crypto data packets. |
2124 | * | 2124 | * |
2125 | */ | 2125 | */ |
2126 | static int udp_handle_packet(void *object, IP_Port source, uint8_t *packet, uint32_t length) | 2126 | static int udp_handle_packet(void *object, IP_Port source, const uint8_t *packet, uint32_t length) |
2127 | { | 2127 | { |
2128 | if (length <= CRYPTO_MIN_PACKET_SIZE || length > MAX_CRYPTO_PACKET_SIZE) | 2128 | if (length <= CRYPTO_MIN_PACKET_SIZE || length > MAX_CRYPTO_PACKET_SIZE) |
2129 | return 1; | 2129 | return 1; |
diff --git a/toxcore/network.h b/toxcore/network.h index e5c24a2d..359d26c8 100644 --- a/toxcore/network.h +++ b/toxcore/network.h | |||
@@ -270,7 +270,7 @@ int addr_resolve_or_parse_ip(const char *address, IP *to, IP *extra); | |||
270 | * Packet data is put into data. | 270 | * Packet data is put into data. |
271 | * Packet length is put into length. | 271 | * Packet length is put into length. |
272 | */ | 272 | */ |
273 | typedef int (*packet_handler_callback)(void *object, IP_Port ip_port, uint8_t *data, uint32_t len); | 273 | typedef int (*packet_handler_callback)(void *object, IP_Port ip_port, const uint8_t *data, uint32_t len); |
274 | 274 | ||
275 | typedef struct { | 275 | typedef struct { |
276 | packet_handler_callback function; | 276 | packet_handler_callback function; |
diff --git a/toxcore/onion.c b/toxcore/onion.c index 479c6209..194178f3 100644 --- a/toxcore/onion.c +++ b/toxcore/onion.c | |||
@@ -149,7 +149,7 @@ int send_onion_packet(Networking_Core *net, Onion_Path *path, IP_Port dest, uint | |||
149 | * return -1 on failure. | 149 | * return -1 on failure. |
150 | * return 0 on success. | 150 | * return 0 on success. |
151 | */ | 151 | */ |
152 | int send_onion_response(Networking_Core *net, IP_Port dest, uint8_t *data, uint32_t length, uint8_t *ret) | 152 | int send_onion_response(Networking_Core *net, IP_Port dest, const uint8_t *data, uint32_t length, const uint8_t *ret) |
153 | { | 153 | { |
154 | if (length > ONION_RESPONSE_MAX_DATA_SIZE || length == 0) | 154 | if (length > ONION_RESPONSE_MAX_DATA_SIZE || length == 0) |
155 | return -1; | 155 | return -1; |
@@ -165,7 +165,7 @@ int send_onion_response(Networking_Core *net, IP_Port dest, uint8_t *data, uint3 | |||
165 | return 0; | 165 | return 0; |
166 | } | 166 | } |
167 | 167 | ||
168 | static int handle_send_initial(void *object, IP_Port source, uint8_t *packet, uint32_t length) | 168 | static int handle_send_initial(void *object, IP_Port source, const uint8_t *packet, uint32_t length) |
169 | { | 169 | { |
170 | Onion *onion = object; | 170 | Onion *onion = object; |
171 | 171 | ||
@@ -189,7 +189,7 @@ static int handle_send_initial(void *object, IP_Port source, uint8_t *packet, ui | |||
189 | return onion_send_1(onion, plain, len, source, packet + 1); | 189 | return onion_send_1(onion, plain, len, source, packet + 1); |
190 | } | 190 | } |
191 | 191 | ||
192 | int onion_send_1(Onion *onion, uint8_t *plain, uint32_t len, IP_Port source, uint8_t *nonce) | 192 | int onion_send_1(Onion *onion, uint8_t *plain, uint32_t len, IP_Port source, const uint8_t *nonce) |
193 | { | 193 | { |
194 | IP_Port send_to; | 194 | IP_Port send_to; |
195 | ipport_unpack(&send_to, plain); | 195 | ipport_unpack(&send_to, plain); |
@@ -219,7 +219,7 @@ int onion_send_1(Onion *onion, uint8_t *plain, uint32_t len, IP_Port source, uin | |||
219 | return 0; | 219 | return 0; |
220 | } | 220 | } |
221 | 221 | ||
222 | static int handle_send_1(void *object, IP_Port source, uint8_t *packet, uint32_t length) | 222 | static int handle_send_1(void *object, IP_Port source, const uint8_t *packet, uint32_t length) |
223 | { | 223 | { |
224 | Onion *onion = object; | 224 | Onion *onion = object; |
225 | 225 | ||
@@ -268,7 +268,7 @@ static int handle_send_1(void *object, IP_Port source, uint8_t *packet, uint32_t | |||
268 | return 0; | 268 | return 0; |
269 | } | 269 | } |
270 | 270 | ||
271 | static int handle_send_2(void *object, IP_Port source, uint8_t *packet, uint32_t length) | 271 | static int handle_send_2(void *object, IP_Port source, const uint8_t *packet, uint32_t length) |
272 | { | 272 | { |
273 | Onion *onion = object; | 273 | Onion *onion = object; |
274 | 274 | ||
@@ -316,7 +316,7 @@ static int handle_send_2(void *object, IP_Port source, uint8_t *packet, uint32_t | |||
316 | } | 316 | } |
317 | 317 | ||
318 | 318 | ||
319 | static int handle_recv_3(void *object, IP_Port source, uint8_t *packet, uint32_t length) | 319 | static int handle_recv_3(void *object, IP_Port source, const uint8_t *packet, uint32_t length) |
320 | { | 320 | { |
321 | Onion *onion = object; | 321 | Onion *onion = object; |
322 | 322 | ||
@@ -350,7 +350,7 @@ static int handle_recv_3(void *object, IP_Port source, uint8_t *packet, uint32_t | |||
350 | return 0; | 350 | return 0; |
351 | } | 351 | } |
352 | 352 | ||
353 | static int handle_recv_2(void *object, IP_Port source, uint8_t *packet, uint32_t length) | 353 | static int handle_recv_2(void *object, IP_Port source, const uint8_t *packet, uint32_t length) |
354 | { | 354 | { |
355 | Onion *onion = object; | 355 | Onion *onion = object; |
356 | 356 | ||
@@ -384,7 +384,7 @@ static int handle_recv_2(void *object, IP_Port source, uint8_t *packet, uint32_t | |||
384 | return 0; | 384 | return 0; |
385 | } | 385 | } |
386 | 386 | ||
387 | static int handle_recv_1(void *object, IP_Port source, uint8_t *packet, uint32_t length) | 387 | static int handle_recv_1(void *object, IP_Port source, const uint8_t *packet, uint32_t length) |
388 | { | 388 | { |
389 | Onion *onion = object; | 389 | Onion *onion = object; |
390 | 390 | ||
@@ -417,7 +417,7 @@ static int handle_recv_1(void *object, IP_Port source, uint8_t *packet, uint32_t | |||
417 | return 0; | 417 | return 0; |
418 | } | 418 | } |
419 | 419 | ||
420 | void set_callback_handle_recv_1(Onion *onion, int (*function)(void *, IP_Port, uint8_t *, uint16_t), void *object) | 420 | void set_callback_handle_recv_1(Onion *onion, int (*function)(void *, IP_Port, const uint8_t *, uint16_t), void *object) |
421 | { | 421 | { |
422 | onion->recv_1_function = function; | 422 | onion->recv_1_function = function; |
423 | onion->callback_object = object; | 423 | onion->callback_object = object; |
diff --git a/toxcore/onion.h b/toxcore/onion.h index 13dc8f52..07d5b6d9 100644 --- a/toxcore/onion.h +++ b/toxcore/onion.h | |||
@@ -35,7 +35,7 @@ typedef struct { | |||
35 | Shared_Keys shared_keys_2; | 35 | Shared_Keys shared_keys_2; |
36 | Shared_Keys shared_keys_3; | 36 | Shared_Keys shared_keys_3; |
37 | 37 | ||
38 | int (*recv_1_function)(void *, IP_Port, uint8_t *, uint16_t); | 38 | int (*recv_1_function)(void *, IP_Port, const uint8_t *, uint16_t); |
39 | void *callback_object; | 39 | void *callback_object; |
40 | } Onion; | 40 | } Onion; |
41 | 41 | ||
@@ -94,7 +94,7 @@ int send_onion_packet(Networking_Core *net, Onion_Path *path, IP_Port dest, uint | |||
94 | * return -1 on failure. | 94 | * return -1 on failure. |
95 | * return 0 on success. | 95 | * return 0 on success. |
96 | */ | 96 | */ |
97 | int send_onion_response(Networking_Core *net, IP_Port dest, uint8_t *data, uint32_t length, uint8_t *ret); | 97 | int send_onion_response(Networking_Core *net, IP_Port dest, const uint8_t *data, uint32_t length, const uint8_t *ret); |
98 | 98 | ||
99 | /* Function to handle/send received decrypted versions of the packet sent with send_onion_packet. | 99 | /* Function to handle/send received decrypted versions of the packet sent with send_onion_packet. |
100 | * | 100 | * |
@@ -106,13 +106,13 @@ int send_onion_response(Networking_Core *net, IP_Port dest, uint8_t *data, uint3 | |||
106 | * Source family must be set to something else than AF_INET6 or AF_INET so that the callback gets called | 106 | * Source family must be set to something else than AF_INET6 or AF_INET so that the callback gets called |
107 | * when the response is received. | 107 | * when the response is received. |
108 | */ | 108 | */ |
109 | int onion_send_1(Onion *onion, uint8_t *plain, uint32_t len, IP_Port source, uint8_t *nonce); | 109 | int onion_send_1(Onion *onion, uint8_t *plain, uint32_t len, IP_Port source, const uint8_t *nonce); |
110 | 110 | ||
111 | /* Set the callback to be called when the dest ip_port doesn't have AF_INET6 or AF_INET as the family. | 111 | /* Set the callback to be called when the dest ip_port doesn't have AF_INET6 or AF_INET as the family. |
112 | * | 112 | * |
113 | * Format: function(void *object, IP_Port dest, uint8_t *data, uint32_t length) | 113 | * Format: function(void *object, IP_Port dest, uint8_t *data, uint32_t length) |
114 | */ | 114 | */ |
115 | void set_callback_handle_recv_1(Onion *onion, int (*function)(void *, IP_Port, uint8_t *, uint16_t), void *object); | 115 | void set_callback_handle_recv_1(Onion *onion, int (*function)(void *, IP_Port, const uint8_t *, uint16_t), void *object); |
116 | 116 | ||
117 | Onion *new_onion(DHT *dht); | 117 | Onion *new_onion(DHT *dht); |
118 | 118 | ||
diff --git a/toxcore/onion_announce.c b/toxcore/onion_announce.c index a9891b9c..a8f71a4e 100644 --- a/toxcore/onion_announce.c +++ b/toxcore/onion_announce.c | |||
@@ -115,7 +115,7 @@ int send_data_request(Networking_Core *net, Onion_Path *path, IP_Port dest, uint | |||
115 | } | 115 | } |
116 | 116 | ||
117 | /* Generate a ping_id and put it in ping_id */ | 117 | /* Generate a ping_id and put it in ping_id */ |
118 | static void generate_ping_id(Onion_Announce *onion_a, uint64_t time, uint8_t *public_key, IP_Port ret_ip_port, | 118 | static void generate_ping_id(Onion_Announce *onion_a, uint64_t time, const uint8_t *public_key, IP_Port ret_ip_port, |
119 | uint8_t *ping_id) | 119 | uint8_t *ping_id) |
120 | { | 120 | { |
121 | time /= PING_ID_TIMEOUT; | 121 | time /= PING_ID_TIMEOUT; |
@@ -132,7 +132,7 @@ static void generate_ping_id(Onion_Announce *onion_a, uint64_t time, uint8_t *pu | |||
132 | * return -1 if no | 132 | * return -1 if no |
133 | * return position in list if yes | 133 | * return position in list if yes |
134 | */ | 134 | */ |
135 | static int in_entries(Onion_Announce *onion_a, uint8_t *public_key) | 135 | static int in_entries(const Onion_Announce *onion_a, const uint8_t *public_key) |
136 | { | 136 | { |
137 | uint32_t i; | 137 | uint32_t i; |
138 | 138 | ||
@@ -179,8 +179,8 @@ static int cmp_entry(const void *a, const void *b) | |||
179 | * return -1 if failure | 179 | * return -1 if failure |
180 | * return position if added | 180 | * return position if added |
181 | */ | 181 | */ |
182 | static int add_to_entries(Onion_Announce *onion_a, IP_Port ret_ip_port, uint8_t *public_key, uint8_t *data_public_key, | 182 | static int add_to_entries(Onion_Announce *onion_a, IP_Port ret_ip_port, const uint8_t *public_key, const uint8_t *data_public_key, |
183 | uint8_t *ret) | 183 | const uint8_t *ret) |
184 | { | 184 | { |
185 | 185 | ||
186 | int pos = in_entries(onion_a, public_key); | 186 | int pos = in_entries(onion_a, public_key); |
@@ -213,14 +213,14 @@ static int add_to_entries(Onion_Announce *onion_a, IP_Port ret_ip_port, uint8_t | |||
213 | return in_entries(onion_a, public_key); | 213 | return in_entries(onion_a, public_key); |
214 | } | 214 | } |
215 | 215 | ||
216 | static int handle_announce_request(void *object, IP_Port source, uint8_t *packet, uint32_t length) | 216 | static int handle_announce_request(void *object, IP_Port source, const uint8_t *packet, uint32_t length) |
217 | { | 217 | { |
218 | Onion_Announce *onion_a = object; | 218 | Onion_Announce *onion_a = object; |
219 | 219 | ||
220 | if (length != ANNOUNCE_REQUEST_SIZE_RECV) | 220 | if (length != ANNOUNCE_REQUEST_SIZE_RECV) |
221 | return 1; | 221 | return 1; |
222 | 222 | ||
223 | uint8_t *packet_public_key = packet + 1 + crypto_box_NONCEBYTES; | 223 | const uint8_t *packet_public_key = packet + 1 + crypto_box_NONCEBYTES; |
224 | uint8_t shared_key[crypto_box_BEFORENMBYTES]; | 224 | uint8_t shared_key[crypto_box_BEFORENMBYTES]; |
225 | get_shared_key(&onion_a->shared_keys_recv, shared_key, onion_a->dht->self_secret_key, packet_public_key); | 225 | get_shared_key(&onion_a->shared_keys_recv, shared_key, onion_a->dht->self_secret_key, packet_public_key); |
226 | 226 | ||
@@ -302,7 +302,7 @@ static int handle_announce_request(void *object, IP_Port source, uint8_t *packet | |||
302 | return 0; | 302 | return 0; |
303 | } | 303 | } |
304 | 304 | ||
305 | static int handle_data_request(void *object, IP_Port source, uint8_t *packet, uint32_t length) | 305 | static int handle_data_request(void *object, IP_Port source, const uint8_t *packet, uint32_t length) |
306 | { | 306 | { |
307 | Onion_Announce *onion_a = object; | 307 | Onion_Announce *onion_a = object; |
308 | 308 | ||
diff --git a/toxcore/onion_client.c b/toxcore/onion_client.c index 630882cc..ae5e8810 100644 --- a/toxcore/onion_client.c +++ b/toxcore/onion_client.c | |||
@@ -164,7 +164,7 @@ static int new_sendback(Onion_Client *onion_c, uint32_t num, uint8_t *public_key | |||
164 | * return ~0 on failure | 164 | * return ~0 on failure |
165 | * return num (see new_sendback(...)) on success | 165 | * return num (see new_sendback(...)) on success |
166 | */ | 166 | */ |
167 | static uint32_t check_sendback(Onion_Client *onion_c, uint8_t *sendback, uint8_t *ret_pubkey, IP_Port *ret_ip_port) | 167 | static uint32_t check_sendback(Onion_Client *onion_c, const uint8_t *sendback, uint8_t *ret_pubkey, IP_Port *ret_ip_port) |
168 | { | 168 | { |
169 | uint64_t sback; | 169 | uint64_t sback; |
170 | memcpy(&sback, sendback, sizeof(uint64_t)); | 170 | memcpy(&sback, sendback, sizeof(uint64_t)); |
@@ -377,7 +377,7 @@ static int client_ping_nodes(Onion_Client *onion_c, uint32_t num, Node_format *n | |||
377 | return 0; | 377 | return 0; |
378 | } | 378 | } |
379 | 379 | ||
380 | static int handle_announce_response(void *object, IP_Port source, uint8_t *packet, uint32_t length) | 380 | static int handle_announce_response(void *object, IP_Port source, const uint8_t *packet, uint32_t length) |
381 | { | 381 | { |
382 | Onion_Client *onion_c = object; | 382 | Onion_Client *onion_c = object; |
383 | 383 | ||
@@ -432,7 +432,7 @@ static int handle_announce_response(void *object, IP_Port source, uint8_t *packe | |||
432 | 432 | ||
433 | #define DATA_IN_RESPONSE_MIN_SIZE ONION_DATA_IN_RESPONSE_MIN_SIZE | 433 | #define DATA_IN_RESPONSE_MIN_SIZE ONION_DATA_IN_RESPONSE_MIN_SIZE |
434 | 434 | ||
435 | static int handle_data_response(void *object, IP_Port source, uint8_t *packet, uint32_t length) | 435 | static int handle_data_response(void *object, IP_Port source, const uint8_t *packet, uint32_t length) |
436 | { | 436 | { |
437 | Onion_Client *onion_c = object; | 437 | Onion_Client *onion_c = object; |
438 | 438 | ||
diff --git a/toxcore/ping.c b/toxcore/ping.c index ea8fd04d..e00036af 100644 --- a/toxcore/ping.c +++ b/toxcore/ping.c | |||
@@ -129,7 +129,7 @@ static int send_ping_response(PING *ping, IP_Port ipp, const uint8_t *client_id, | |||
129 | return sendpacket(ping->dht->net, ipp, pk, sizeof(pk)); | 129 | return sendpacket(ping->dht->net, ipp, pk, sizeof(pk)); |
130 | } | 130 | } |
131 | 131 | ||
132 | static int handle_ping_request(void *_dht, IP_Port source, uint8_t *packet, uint32_t length) | 132 | static int handle_ping_request(void *_dht, IP_Port source, const uint8_t *packet, uint32_t length) |
133 | { | 133 | { |
134 | DHT *dht = _dht; | 134 | DHT *dht = _dht; |
135 | int rc; | 135 | int rc; |
@@ -168,7 +168,7 @@ static int handle_ping_request(void *_dht, IP_Port source, uint8_t *packet, uint | |||
168 | return 0; | 168 | return 0; |
169 | } | 169 | } |
170 | 170 | ||
171 | static int handle_ping_response(void *_dht, IP_Port source, uint8_t *packet, uint32_t length) | 171 | static int handle_ping_response(void *_dht, IP_Port source, const uint8_t *packet, uint32_t length) |
172 | { | 172 | { |
173 | DHT *dht = _dht; | 173 | DHT *dht = _dht; |
174 | int rc; | 174 | int rc; |