From 0aa0cbda4236940832bd5196987a75f2aea4721e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Sch=C3=BCtz?= Date: Mon, 23 Jun 2014 21:49:24 +0200 Subject: [PATCH] Const-correctness for toxcore/onion_announce.c --- toxcore/onion.c | 2 +- toxcore/onion.h | 2 +- toxcore/onion_announce.c | 18 +++++++++--------- toxcore/onion_announce.h | 16 ++++++++-------- 4 files changed, 19 insertions(+), 19 deletions(-) diff --git a/toxcore/onion.c b/toxcore/onion.c index ac654689..3c4d2ad1 100644 --- a/toxcore/onion.c +++ b/toxcore/onion.c @@ -93,7 +93,7 @@ int create_onion_path(DHT *dht, Onion_Path *new_path, Node_format *nodes) * return -1 on failure. * return length of created packet on success. */ -int create_onion_packet(uint8_t *packet, uint16_t max_packet_length, Onion_Path *path, IP_Port dest, uint8_t *data, +int create_onion_packet(uint8_t *packet, uint16_t max_packet_length, const Onion_Path *path, IP_Port dest, const uint8_t *data, uint32_t length) { if (1 + length + SEND_1 > max_packet_length || length == 0) diff --git a/toxcore/onion.h b/toxcore/onion.h index cd12fe2b..0ba724c6 100644 --- a/toxcore/onion.h +++ b/toxcore/onion.h @@ -87,7 +87,7 @@ int create_onion_path(DHT *dht, Onion_Path *new_path, Node_format *nodes); * return -1 on failure. * return length of created packet on success. */ -int create_onion_packet(uint8_t *packet, uint16_t max_packet_length, Onion_Path *path, IP_Port dest, uint8_t *data, +int create_onion_packet(uint8_t *packet, uint16_t max_packet_length, const Onion_Path *path, IP_Port dest, const uint8_t *data, uint32_t length); /* Create and send a onion packet. diff --git a/toxcore/onion_announce.c b/toxcore/onion_announce.c index 658d4c11..d45901e7 100644 --- a/toxcore/onion_announce.c +++ b/toxcore/onion_announce.c @@ -49,8 +49,8 @@ * return -1 on failure. * return packet length on success. */ -int create_announce_request(uint8_t *packet, uint16_t max_packet_length, Onion_Path *path, Node_format dest, - uint8_t *public_key, uint8_t *secret_key, uint8_t *ping_id, uint8_t *client_id, uint8_t *data_public_key, +int create_announce_request(uint8_t *packet, uint16_t max_packet_length, const Onion_Path *path, Node_format dest, + const uint8_t *public_key, const uint8_t *secret_key, const uint8_t *ping_id, const uint8_t *client_id, const uint8_t *data_public_key, uint64_t sendback_data) { uint8_t plain[ONION_PING_ID_SIZE + crypto_box_PUBLICKEYBYTES + crypto_box_PUBLICKEYBYTES + @@ -89,8 +89,8 @@ int create_announce_request(uint8_t *packet, uint16_t max_packet_length, Onion_P * return -1 on failure. * return 0 on success. */ -int create_data_request(uint8_t *packet, uint16_t max_packet_length, Onion_Path *path, IP_Port dest, - uint8_t *public_key, uint8_t *encrypt_public_key, uint8_t *nonce, uint8_t *data, uint16_t length) +int create_data_request(uint8_t *packet, uint16_t max_packet_length, const Onion_Path *path, IP_Port dest, + const uint8_t *public_key, const uint8_t *encrypt_public_key, const uint8_t *nonce, const uint8_t *data, uint16_t length) { if ((unsigned int)DATA_REQUEST_MIN_SIZE + length > ONION_MAX_DATA_SIZE) return -1; @@ -129,8 +129,8 @@ int create_data_request(uint8_t *packet, uint16_t max_packet_length, Onion_Path * return -1 on failure. * return 0 on success. */ -int send_announce_request(Networking_Core *net, Onion_Path *path, Node_format dest, uint8_t *public_key, - uint8_t *secret_key, uint8_t *ping_id, uint8_t *client_id, uint8_t *data_public_key, uint64_t sendback_data) +int send_announce_request(Networking_Core *net, const Onion_Path *path, Node_format dest, const uint8_t *public_key, + const uint8_t *secret_key, const uint8_t *ping_id, const uint8_t *client_id, const uint8_t *data_public_key, uint64_t sendback_data) { uint8_t packet[ONION_MAX_PACKET_SIZE]; int len = create_announce_request(packet, sizeof(packet), path, dest, public_key, secret_key, ping_id, client_id, @@ -159,8 +159,8 @@ int send_announce_request(Networking_Core *net, Onion_Path *path, Node_format de * return -1 on failure. * return 0 on success. */ -int send_data_request(Networking_Core *net, Onion_Path *path, IP_Port dest, uint8_t *public_key, - uint8_t *encrypt_public_key, uint8_t *nonce, uint8_t *data, uint16_t length) +int send_data_request(Networking_Core *net, const Onion_Path *path, IP_Port dest, const uint8_t *public_key, + const uint8_t *encrypt_public_key, const uint8_t *nonce, const uint8_t *data, uint16_t length) { uint8_t packet[ONION_MAX_PACKET_SIZE]; int len = create_data_request(packet, sizeof(packet), path, dest, public_key, encrypt_public_key, nonce, data, length); @@ -175,7 +175,7 @@ int send_data_request(Networking_Core *net, Onion_Path *path, IP_Port dest, uint } /* Generate a ping_id and put it in ping_id */ -static void generate_ping_id(Onion_Announce *onion_a, uint64_t time, const uint8_t *public_key, IP_Port ret_ip_port, +static void generate_ping_id(const Onion_Announce *onion_a, uint64_t time, const uint8_t *public_key, IP_Port ret_ip_port, uint8_t *ping_id) { time /= PING_ID_TIMEOUT; diff --git a/toxcore/onion_announce.h b/toxcore/onion_announce.h index 42f63ccd..ce6025ff 100644 --- a/toxcore/onion_announce.h +++ b/toxcore/onion_announce.h @@ -75,8 +75,8 @@ typedef struct { * return -1 on failure. * return packet length on success. */ -int create_announce_request(uint8_t *packet, uint16_t max_packet_length, Onion_Path *path, Node_format dest, - uint8_t *public_key, uint8_t *secret_key, uint8_t *ping_id, uint8_t *client_id, uint8_t *data_public_key, +int create_announce_request(uint8_t *packet, uint16_t max_packet_length, const Onion_Path *path, Node_format dest, + const uint8_t *public_key, const uint8_t *secret_key, const uint8_t *ping_id, const uint8_t *client_id, const uint8_t *data_public_key, uint64_t sendback_data); /* Create an onion data request packet in packet of max_packet_length (recommended size ONION_MAX_PACKET_SIZE). @@ -93,8 +93,8 @@ int create_announce_request(uint8_t *packet, uint16_t max_packet_length, Onion_P * return -1 on failure. * return 0 on success. */ -int create_data_request(uint8_t *packet, uint16_t max_packet_length, Onion_Path *path, IP_Port dest, - uint8_t *public_key, uint8_t *encrypt_public_key, uint8_t *nonce, uint8_t *data, uint16_t length); +int create_data_request(uint8_t *packet, uint16_t max_packet_length, const Onion_Path *path, IP_Port dest, + const uint8_t *public_key, const uint8_t *encrypt_public_key, const uint8_t *nonce, const uint8_t *data, uint16_t length); /* Create and send an onion announce request packet. * @@ -110,8 +110,8 @@ int create_data_request(uint8_t *packet, uint16_t max_packet_length, Onion_Path * return -1 on failure. * return 0 on success. */ -int send_announce_request(Networking_Core *net, Onion_Path *path, Node_format dest, uint8_t *public_key, - uint8_t *secret_key, uint8_t *ping_id, uint8_t *client_id, uint8_t *data_public_key, uint64_t sendback_data); +int send_announce_request(Networking_Core *net, const Onion_Path *path, Node_format dest, const uint8_t *public_key, + const uint8_t *secret_key, const uint8_t *ping_id, const uint8_t *client_id, const uint8_t *data_public_key, uint64_t sendback_data); /* Create and send an onion data request packet. * @@ -129,8 +129,8 @@ int send_announce_request(Networking_Core *net, Onion_Path *path, Node_format de * return -1 on failure. * return 0 on success. */ -int send_data_request(Networking_Core *net, Onion_Path *path, IP_Port dest, uint8_t *public_key, - uint8_t *encrypt_public_key, uint8_t *nonce, uint8_t *data, uint16_t length); +int send_data_request(Networking_Core *net, const Onion_Path *path, IP_Port dest, const uint8_t *public_key, + const uint8_t *encrypt_public_key, const uint8_t *nonce, const uint8_t *data, uint16_t length); Onion_Announce *new_onion_announce(DHT *dht);