summaryrefslogtreecommitdiff
path: root/toxcore
diff options
context:
space:
mode:
authorMarc Schütz <schuetzm@gmx.net>2014-06-23 21:49:24 +0200
committerMarc Schütz <schuetzm@gmx.net>2014-06-30 21:26:51 +0200
commit0aa0cbda4236940832bd5196987a75f2aea4721e (patch)
treeedd83ccee53e2fd8701d620f012284199f8dcd6a /toxcore
parentaba594d1f866178ccf8ec2d628c27a340e48e183 (diff)
Const-correctness for toxcore/onion_announce.c
Diffstat (limited to 'toxcore')
-rw-r--r--toxcore/onion.c2
-rw-r--r--toxcore/onion.h2
-rw-r--r--toxcore/onion_announce.c18
-rw-r--r--toxcore/onion_announce.h16
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)
93 * return -1 on failure. 93 * return -1 on failure.
94 * return length of created packet on success. 94 * return length of created packet on success.
95 */ 95 */
96int create_onion_packet(uint8_t *packet, uint16_t max_packet_length, Onion_Path *path, IP_Port dest, uint8_t *data, 96int create_onion_packet(uint8_t *packet, uint16_t max_packet_length, const Onion_Path *path, IP_Port dest, const uint8_t *data,
97 uint32_t length) 97 uint32_t length)
98{ 98{
99 if (1 + length + SEND_1 > max_packet_length || length == 0) 99 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);
87 * return -1 on failure. 87 * return -1 on failure.
88 * return length of created packet on success. 88 * return length of created packet on success.
89 */ 89 */
90int create_onion_packet(uint8_t *packet, uint16_t max_packet_length, Onion_Path *path, IP_Port dest, uint8_t *data, 90int create_onion_packet(uint8_t *packet, uint16_t max_packet_length, const Onion_Path *path, IP_Port dest, const uint8_t *data,
91 uint32_t length); 91 uint32_t length);
92 92
93/* Create and send a onion packet. 93/* 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 @@
49 * return -1 on failure. 49 * return -1 on failure.
50 * return packet length on success. 50 * return packet length on success.
51 */ 51 */
52int create_announce_request(uint8_t *packet, uint16_t max_packet_length, Onion_Path *path, Node_format dest, 52int create_announce_request(uint8_t *packet, uint16_t max_packet_length, const Onion_Path *path, Node_format dest,
53 uint8_t *public_key, uint8_t *secret_key, uint8_t *ping_id, uint8_t *client_id, uint8_t *data_public_key, 53 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,
54 uint64_t sendback_data) 54 uint64_t sendback_data)
55{ 55{
56 uint8_t plain[ONION_PING_ID_SIZE + crypto_box_PUBLICKEYBYTES + crypto_box_PUBLICKEYBYTES + 56 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
89 * return -1 on failure. 89 * return -1 on failure.
90 * return 0 on success. 90 * return 0 on success.
91 */ 91 */
92int create_data_request(uint8_t *packet, uint16_t max_packet_length, Onion_Path *path, IP_Port dest, 92int create_data_request(uint8_t *packet, uint16_t max_packet_length, const Onion_Path *path, IP_Port dest,
93 uint8_t *public_key, uint8_t *encrypt_public_key, uint8_t *nonce, uint8_t *data, uint16_t length) 93 const uint8_t *public_key, const uint8_t *encrypt_public_key, const uint8_t *nonce, const uint8_t *data, uint16_t length)
94{ 94{
95 if ((unsigned int)DATA_REQUEST_MIN_SIZE + length > ONION_MAX_DATA_SIZE) 95 if ((unsigned int)DATA_REQUEST_MIN_SIZE + length > ONION_MAX_DATA_SIZE)
96 return -1; 96 return -1;
@@ -129,8 +129,8 @@ int create_data_request(uint8_t *packet, uint16_t max_packet_length, Onion_Path
129 * return -1 on failure. 129 * return -1 on failure.
130 * return 0 on success. 130 * return 0 on success.
131 */ 131 */
132int send_announce_request(Networking_Core *net, Onion_Path *path, Node_format dest, uint8_t *public_key, 132int send_announce_request(Networking_Core *net, const Onion_Path *path, Node_format dest, const uint8_t *public_key,
133 uint8_t *secret_key, uint8_t *ping_id, uint8_t *client_id, uint8_t *data_public_key, uint64_t sendback_data) 133 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)
134{ 134{
135 uint8_t packet[ONION_MAX_PACKET_SIZE]; 135 uint8_t packet[ONION_MAX_PACKET_SIZE];
136 int len = create_announce_request(packet, sizeof(packet), path, dest, public_key, secret_key, ping_id, client_id, 136 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
159 * return -1 on failure. 159 * return -1 on failure.
160 * return 0 on success. 160 * return 0 on success.
161 */ 161 */
162int send_data_request(Networking_Core *net, Onion_Path *path, IP_Port dest, uint8_t *public_key, 162int send_data_request(Networking_Core *net, const Onion_Path *path, IP_Port dest, const uint8_t *public_key,
163 uint8_t *encrypt_public_key, uint8_t *nonce, uint8_t *data, uint16_t length) 163 const uint8_t *encrypt_public_key, const uint8_t *nonce, const uint8_t *data, uint16_t length)
164{ 164{
165 uint8_t packet[ONION_MAX_PACKET_SIZE]; 165 uint8_t packet[ONION_MAX_PACKET_SIZE];
166 int len = create_data_request(packet, sizeof(packet), path, dest, public_key, encrypt_public_key, nonce, data, length); 166 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
175} 175}
176 176
177/* Generate a ping_id and put it in ping_id */ 177/* Generate a ping_id and put it in ping_id */
178static void generate_ping_id(Onion_Announce *onion_a, uint64_t time, const uint8_t *public_key, IP_Port ret_ip_port, 178static void generate_ping_id(const Onion_Announce *onion_a, uint64_t time, const uint8_t *public_key, IP_Port ret_ip_port,
179 uint8_t *ping_id) 179 uint8_t *ping_id)
180{ 180{
181 time /= PING_ID_TIMEOUT; 181 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 {
75 * return -1 on failure. 75 * return -1 on failure.
76 * return packet length on success. 76 * return packet length on success.
77 */ 77 */
78int create_announce_request(uint8_t *packet, uint16_t max_packet_length, Onion_Path *path, Node_format dest, 78int create_announce_request(uint8_t *packet, uint16_t max_packet_length, const Onion_Path *path, Node_format dest,
79 uint8_t *public_key, uint8_t *secret_key, uint8_t *ping_id, uint8_t *client_id, uint8_t *data_public_key, 79 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,
80 uint64_t sendback_data); 80 uint64_t sendback_data);
81 81
82/* Create an onion data request packet in packet of max_packet_length (recommended size ONION_MAX_PACKET_SIZE). 82/* 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
93 * return -1 on failure. 93 * return -1 on failure.
94 * return 0 on success. 94 * return 0 on success.
95 */ 95 */
96int create_data_request(uint8_t *packet, uint16_t max_packet_length, Onion_Path *path, IP_Port dest, 96int create_data_request(uint8_t *packet, uint16_t max_packet_length, const Onion_Path *path, IP_Port dest,
97 uint8_t *public_key, uint8_t *encrypt_public_key, uint8_t *nonce, uint8_t *data, uint16_t length); 97 const uint8_t *public_key, const uint8_t *encrypt_public_key, const uint8_t *nonce, const uint8_t *data, uint16_t length);
98 98
99/* Create and send an onion announce request packet. 99/* Create and send an onion announce request packet.
100 * 100 *
@@ -110,8 +110,8 @@ int create_data_request(uint8_t *packet, uint16_t max_packet_length, Onion_Path
110 * return -1 on failure. 110 * return -1 on failure.
111 * return 0 on success. 111 * return 0 on success.
112 */ 112 */
113int send_announce_request(Networking_Core *net, Onion_Path *path, Node_format dest, uint8_t *public_key, 113int send_announce_request(Networking_Core *net, const Onion_Path *path, Node_format dest, const uint8_t *public_key,
114 uint8_t *secret_key, uint8_t *ping_id, uint8_t *client_id, uint8_t *data_public_key, uint64_t sendback_data); 114 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);
115 115
116/* Create and send an onion data request packet. 116/* Create and send an onion data request packet.
117 * 117 *
@@ -129,8 +129,8 @@ int send_announce_request(Networking_Core *net, Onion_Path *path, Node_format de
129 * return -1 on failure. 129 * return -1 on failure.
130 * return 0 on success. 130 * return 0 on success.
131 */ 131 */
132int send_data_request(Networking_Core *net, Onion_Path *path, IP_Port dest, uint8_t *public_key, 132int send_data_request(Networking_Core *net, const Onion_Path *path, IP_Port dest, const uint8_t *public_key,
133 uint8_t *encrypt_public_key, uint8_t *nonce, uint8_t *data, uint16_t length); 133 const uint8_t *encrypt_public_key, const uint8_t *nonce, const uint8_t *data, uint16_t length);
134 134
135 135
136Onion_Announce *new_onion_announce(DHT *dht); 136Onion_Announce *new_onion_announce(DHT *dht);