diff options
Diffstat (limited to 'toxcore/TCP_connection.h')
-rw-r--r-- | toxcore/TCP_connection.h | 33 |
1 files changed, 19 insertions, 14 deletions
diff --git a/toxcore/TCP_connection.h b/toxcore/TCP_connection.h index a45129a7..658ee1f4 100644 --- a/toxcore/TCP_connection.h +++ b/toxcore/TCP_connection.h | |||
@@ -51,20 +51,22 @@ | |||
51 | /* Number of TCP connections used for onion purposes. */ | 51 | /* Number of TCP connections used for onion purposes. */ |
52 | #define NUM_ONION_TCP_CONNECTIONS RECOMMENDED_FRIEND_TCP_CONNECTIONS | 52 | #define NUM_ONION_TCP_CONNECTIONS RECOMMENDED_FRIEND_TCP_CONNECTIONS |
53 | 53 | ||
54 | typedef struct { | 54 | typedef struct TCP_Conn_to { |
55 | uint32_t tcp_connection; | ||
56 | unsigned int status; | ||
57 | unsigned int connection_id; | ||
58 | } TCP_Conn_to; | ||
59 | |||
60 | typedef struct TCP_Connection_to { | ||
55 | uint8_t status; | 61 | uint8_t status; |
56 | uint8_t public_key[CRYPTO_PUBLIC_KEY_SIZE]; /* The dht public key of the peer */ | 62 | uint8_t public_key[CRYPTO_PUBLIC_KEY_SIZE]; /* The dht public key of the peer */ |
57 | 63 | ||
58 | struct { | 64 | TCP_Conn_to connections[MAX_FRIEND_TCP_CONNECTIONS]; |
59 | uint32_t tcp_connection; | ||
60 | unsigned int status; | ||
61 | unsigned int connection_id; | ||
62 | } connections[MAX_FRIEND_TCP_CONNECTIONS]; | ||
63 | 65 | ||
64 | int id; /* id used in callbacks. */ | 66 | int id; /* id used in callbacks. */ |
65 | } TCP_Connection_to; | 67 | } TCP_Connection_to; |
66 | 68 | ||
67 | typedef struct { | 69 | typedef struct TCP_con { |
68 | uint8_t status; | 70 | uint8_t status; |
69 | TCP_Client_Connection *connection; | 71 | TCP_Client_Connection *connection; |
70 | uint64_t connected_time; | 72 | uint64_t connected_time; |
@@ -124,21 +126,24 @@ int set_tcp_onion_status(TCP_Connections *tcp_c, bool status); | |||
124 | int tcp_send_oob_packet(TCP_Connections *tcp_c, unsigned int tcp_connections_number, const uint8_t *public_key, | 126 | int tcp_send_oob_packet(TCP_Connections *tcp_c, unsigned int tcp_connections_number, const uint8_t *public_key, |
125 | const uint8_t *packet, uint16_t length); | 127 | const uint8_t *packet, uint16_t length); |
126 | 128 | ||
129 | typedef int tcp_data_cb(void *object, int id, const uint8_t *data, uint16_t length, void *userdata); | ||
130 | |||
127 | /* Set the callback for TCP data packets. | 131 | /* Set the callback for TCP data packets. |
128 | */ | 132 | */ |
129 | void set_packet_tcp_connection_callback(TCP_Connections *tcp_c, int (*tcp_data_callback)(void *object, int id, | 133 | void set_packet_tcp_connection_callback(TCP_Connections *tcp_c, tcp_data_cb *tcp_data_callback, void *object); |
130 | const uint8_t *data, uint16_t length, void *userdata), void *object); | 134 | |
135 | typedef int tcp_onion_cb(void *object, const uint8_t *data, uint16_t length, void *userdata); | ||
131 | 136 | ||
132 | /* Set the callback for TCP onion packets. | 137 | /* Set the callback for TCP onion packets. |
133 | */ | 138 | */ |
134 | void set_onion_packet_tcp_connection_callback(TCP_Connections *tcp_c, int (*tcp_onion_callback)(void *object, | 139 | void set_onion_packet_tcp_connection_callback(TCP_Connections *tcp_c, tcp_onion_cb *tcp_onion_callback, void *object); |
135 | const uint8_t *data, uint16_t length, void *userdata), void *object); | 140 | |
141 | typedef int tcp_oob_cb(void *object, const uint8_t *public_key, unsigned int tcp_connections_number, | ||
142 | const uint8_t *data, uint16_t length, void *userdata); | ||
136 | 143 | ||
137 | /* Set the callback for TCP oob data packets. | 144 | /* Set the callback for TCP oob data packets. |
138 | */ | 145 | */ |
139 | void set_oob_packet_tcp_connection_callback(TCP_Connections *tcp_c, int (*tcp_oob_callback)(void *object, | 146 | void set_oob_packet_tcp_connection_callback(TCP_Connections *tcp_c, tcp_oob_cb *tcp_oob_callback, void *object); |
140 | const uint8_t *public_key, unsigned int tcp_connections_number, const uint8_t *data, uint16_t length, void *userdata), | ||
141 | void *object); | ||
142 | 147 | ||
143 | /* Create a new TCP connection to public_key. | 148 | /* Create a new TCP connection to public_key. |
144 | * | 149 | * |