summaryrefslogtreecommitdiff
path: root/toxcore/onion.h
diff options
context:
space:
mode:
Diffstat (limited to 'toxcore/onion.h')
-rw-r--r--toxcore/onion.h12
1 files changed, 12 insertions, 0 deletions
diff --git a/toxcore/onion.h b/toxcore/onion.h
index 9577f019..4e363724 100644
--- a/toxcore/onion.h
+++ b/toxcore/onion.h
@@ -34,6 +34,9 @@ typedef struct {
34 Shared_Keys shared_keys_1; 34 Shared_Keys shared_keys_1;
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
38 int (*recv_1_function)(void *, IP_Port, uint8_t *, uint16_t);
39 void *callback_object;
37} Onion; 40} Onion;
38 41
39#define ONION_RETURN_1 (crypto_secretbox_NONCEBYTES + sizeof(IP_Port) + crypto_secretbox_MACBYTES) 42#define ONION_RETURN_1 (crypto_secretbox_NONCEBYTES + sizeof(IP_Port) + crypto_secretbox_MACBYTES)
@@ -92,9 +95,18 @@ int send_onion_response(Networking_Core *net, IP_Port dest, uint8_t *data, uint3
92 * return 1 on failure. 95 * return 1 on failure.
93 * 96 *
94 * Used to handle these packets that are received in a non traditional way (by TCP for example). 97 * Used to handle these packets that are received in a non traditional way (by TCP for example).
98 *
99 * Source family must be set to something else than AF_INET6 or AF_INET so that the callback gets called
100 * when the response is received.
95 */ 101 */
96int onion_send_1(Onion *onion, uint8_t *plain, uint32_t len, IP_Port source, uint8_t *nonce); 102int onion_send_1(Onion *onion, uint8_t *plain, uint32_t len, IP_Port source, uint8_t *nonce);
97 103
104/* Set the callback to be called when the dest ip_port doesn't have AF_INET6 or AF_INET as the family.
105 *
106 * Format: function(void *object, IP_Port dest, uint8_t *data, uint32_t length)
107 */
108void set_callback_handle_recv_1(Onion *onion, int (*function)(void *, IP_Port, uint8_t *, uint16_t), void *object);
109
98Onion *new_onion(DHT *dht); 110Onion *new_onion(DHT *dht);
99 111
100void kill_onion(Onion *onion); 112void kill_onion(Onion *onion);