diff options
author | irungentoo <irungentoo@gmail.com> | 2014-07-02 15:41:59 -0400 |
---|---|---|
committer | irungentoo <irungentoo@gmail.com> | 2014-07-02 15:41:59 -0400 |
commit | 6d4fdb3597ce334d6f63437deeb1b7338bb87759 (patch) | |
tree | 7f195de1654b8bd79baf9807bd771ca17361e51d /toxcore/onion_announce.c | |
parent | d6b6ae4b48ab2387a29b0f9e4753cc57908733df (diff) | |
parent | 53d731b4f16be75a5289fd53267444abb0f732e9 (diff) |
Merge branch 'const_correctness' of https://github.com/schuetzm/ProjectTox-Core
Diffstat (limited to 'toxcore/onion_announce.c')
-rw-r--r-- | toxcore/onion_announce.c | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/toxcore/onion_announce.c b/toxcore/onion_announce.c index 658d4c11..dff05135 100644 --- a/toxcore/onion_announce.c +++ b/toxcore/onion_announce.c | |||
@@ -49,9 +49,9 @@ | |||
49 | * return -1 on failure. | 49 | * return -1 on failure. |
50 | * return packet length on success. | 50 | * return packet length on success. |
51 | */ | 51 | */ |
52 | int create_announce_request(uint8_t *packet, uint16_t max_packet_length, Onion_Path *path, Node_format dest, | 52 | int 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, |
54 | uint64_t sendback_data) | 54 | const uint8_t *data_public_key, 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 + |
57 | ONION_ANNOUNCE_SENDBACK_DATA_LENGTH]; | 57 | ONION_ANNOUNCE_SENDBACK_DATA_LENGTH]; |
@@ -89,8 +89,9 @@ 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 | */ |
92 | int create_data_request(uint8_t *packet, uint16_t max_packet_length, Onion_Path *path, IP_Port dest, | 92 | int 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, |
94 | uint16_t length) | ||
94 | { | 95 | { |
95 | if ((unsigned int)DATA_REQUEST_MIN_SIZE + length > ONION_MAX_DATA_SIZE) | 96 | if ((unsigned int)DATA_REQUEST_MIN_SIZE + length > ONION_MAX_DATA_SIZE) |
96 | return -1; | 97 | return -1; |
@@ -129,8 +130,9 @@ int create_data_request(uint8_t *packet, uint16_t max_packet_length, Onion_Path | |||
129 | * return -1 on failure. | 130 | * return -1 on failure. |
130 | * return 0 on success. | 131 | * return 0 on success. |
131 | */ | 132 | */ |
132 | int send_announce_request(Networking_Core *net, Onion_Path *path, Node_format dest, uint8_t *public_key, | 133 | int 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) | 134 | const uint8_t *secret_key, const uint8_t *ping_id, const uint8_t *client_id, const uint8_t *data_public_key, |
135 | uint64_t sendback_data) | ||
134 | { | 136 | { |
135 | uint8_t packet[ONION_MAX_PACKET_SIZE]; | 137 | 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, | 138 | int len = create_announce_request(packet, sizeof(packet), path, dest, public_key, secret_key, ping_id, client_id, |
@@ -159,8 +161,8 @@ int send_announce_request(Networking_Core *net, Onion_Path *path, Node_format de | |||
159 | * return -1 on failure. | 161 | * return -1 on failure. |
160 | * return 0 on success. | 162 | * return 0 on success. |
161 | */ | 163 | */ |
162 | int send_data_request(Networking_Core *net, Onion_Path *path, IP_Port dest, uint8_t *public_key, | 164 | int 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) | 165 | const uint8_t *encrypt_public_key, const uint8_t *nonce, const uint8_t *data, uint16_t length) |
164 | { | 166 | { |
165 | uint8_t packet[ONION_MAX_PACKET_SIZE]; | 167 | 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); | 168 | int len = create_data_request(packet, sizeof(packet), path, dest, public_key, encrypt_public_key, nonce, data, length); |
@@ -175,8 +177,8 @@ int send_data_request(Networking_Core *net, Onion_Path *path, IP_Port dest, uint | |||
175 | } | 177 | } |
176 | 178 | ||
177 | /* Generate a ping_id and put it in ping_id */ | 179 | /* Generate a ping_id and put it in ping_id */ |
178 | static void generate_ping_id(Onion_Announce *onion_a, uint64_t time, const uint8_t *public_key, IP_Port ret_ip_port, | 180 | static void generate_ping_id(const Onion_Announce *onion_a, uint64_t time, const uint8_t *public_key, |
179 | uint8_t *ping_id) | 181 | IP_Port ret_ip_port, uint8_t *ping_id) |
180 | { | 182 | { |
181 | time /= PING_ID_TIMEOUT; | 183 | time /= PING_ID_TIMEOUT; |
182 | uint8_t data[crypto_box_KEYBYTES + sizeof(time) + crypto_box_PUBLICKEYBYTES + sizeof(ret_ip_port)]; | 184 | uint8_t data[crypto_box_KEYBYTES + sizeof(time) + crypto_box_PUBLICKEYBYTES + sizeof(ret_ip_port)]; |