diff options
author | irungentoo <irungentoo@gmail.com> | 2014-03-28 22:37:42 -0400 |
---|---|---|
committer | irungentoo <irungentoo@gmail.com> | 2014-03-28 22:37:42 -0400 |
commit | 8aaa5fe996e44a0c68c069b8e70649264f5e8a56 (patch) | |
tree | 09a7a2c680425d772bdf2d2b6a0499a1ead3a00d /toxcore/onion.c | |
parent | a11667355491b6a0b18111e0c6ef16f816521214 (diff) |
TCP server almost ready.
Diffstat (limited to 'toxcore/onion.c')
-rw-r--r-- | toxcore/onion.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/toxcore/onion.c b/toxcore/onion.c index 292f9309..6bc6ab07 100644 --- a/toxcore/onion.c +++ b/toxcore/onion.c | |||
@@ -181,13 +181,18 @@ static int handle_send_initial(void *object, IP_Port source, uint8_t *packet, ui | |||
181 | if ((uint32_t)len != length - (1 + crypto_box_NONCEBYTES + crypto_box_PUBLICKEYBYTES + crypto_box_MACBYTES)) | 181 | if ((uint32_t)len != length - (1 + crypto_box_NONCEBYTES + crypto_box_PUBLICKEYBYTES + crypto_box_MACBYTES)) |
182 | return 1; | 182 | return 1; |
183 | 183 | ||
184 | return onion_send_1(onion, plain, len, source, packet + 1); | ||
185 | } | ||
186 | |||
187 | int onion_send_1(Onion *onion, uint8_t *plain, uint32_t len, IP_Port source, uint8_t *nonce) | ||
188 | { | ||
184 | IP_Port send_to; | 189 | IP_Port send_to; |
185 | memcpy(&send_to, plain, sizeof(IP_Port)); | 190 | memcpy(&send_to, plain, sizeof(IP_Port)); |
186 | to_host_family(&send_to.ip); | 191 | to_host_family(&send_to.ip); |
187 | 192 | ||
188 | uint8_t data[MAX_ONION_SIZE]; | 193 | uint8_t data[MAX_ONION_SIZE]; |
189 | data[0] = NET_PACKET_ONION_SEND_1; | 194 | data[0] = NET_PACKET_ONION_SEND_1; |
190 | memcpy(data + 1, packet + 1, crypto_box_NONCEBYTES); | 195 | memcpy(data + 1, nonce, crypto_box_NONCEBYTES); |
191 | memcpy(data + 1 + crypto_box_NONCEBYTES, plain + sizeof(IP_Port), len - sizeof(IP_Port)); | 196 | memcpy(data + 1 + crypto_box_NONCEBYTES, plain + sizeof(IP_Port), len - sizeof(IP_Port)); |
192 | uint32_t data_len = 1 + crypto_box_NONCEBYTES + (len - sizeof(IP_Port)); | 197 | uint32_t data_len = 1 + crypto_box_NONCEBYTES + (len - sizeof(IP_Port)); |
193 | uint8_t *ret_part = data + data_len; | 198 | uint8_t *ret_part = data + data_len; |