summaryrefslogtreecommitdiff
path: root/toxcore/onion.h
diff options
context:
space:
mode:
authorirungentoo <irungentoo@gmail.com>2014-03-29 22:19:03 -0400
committerirungentoo <irungentoo@gmail.com>2014-03-29 22:19:03 -0400
commit98cba889a70c62847da9127832e3aece8722e235 (patch)
treee202670f64c706b63e4a9d59b6c69da1388058c4 /toxcore/onion.h
parent8aaa5fe996e44a0c68c069b8e70649264f5e8a56 (diff)
TCP server now has onion functionality.
All the IP/Port related structs now have __attribute__ ((__packed__))
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);