diff options
author | irungentoo <irungentoo@gmail.com> | 2015-04-13 19:29:45 -0400 |
---|---|---|
committer | irungentoo <irungentoo@gmail.com> | 2015-04-13 19:29:45 -0400 |
commit | 4b29aff04a1653781485d224de330d144e0819ff (patch) | |
tree | 93261d6e0d9e57bf936b4719340769f3f77489f9 /toxcore/TCP_connection.h | |
parent | d05e39274ca4ce27ddb02c0ec15c0ed1c46000a3 (diff) |
TCP connection mostly done.
Only thing left is testing and integrating it in net_crypto.
Diffstat (limited to 'toxcore/TCP_connection.h')
-rw-r--r-- | toxcore/TCP_connection.h | 67 |
1 files changed, 67 insertions, 0 deletions
diff --git a/toxcore/TCP_connection.h b/toxcore/TCP_connection.h index 94213814..fc7925a3 100644 --- a/toxcore/TCP_connection.h +++ b/toxcore/TCP_connection.h | |||
@@ -78,6 +78,73 @@ typedef struct { | |||
78 | TCP_Proxy_Info proxy_info; | 78 | TCP_Proxy_Info proxy_info; |
79 | } TCP_Connections; | 79 | } TCP_Connections; |
80 | 80 | ||
81 | /* Send a packet to the TCP connection. | ||
82 | * | ||
83 | * return -1 on failure. | ||
84 | * return 0 on success. | ||
85 | */ | ||
86 | int send_packet_tcp_connection(TCP_Connections *tcp_c, int connections_number, uint8_t *packet, uint16_t length); | ||
87 | |||
88 | /* Return a random TCP connection number for use in send_tcp_onion_request. | ||
89 | * | ||
90 | * TODO: This number is just the index of an array that the elements can | ||
91 | * change without warning. | ||
92 | * | ||
93 | * return TCP connection number on success. | ||
94 | * return -1 on failure. | ||
95 | */ | ||
96 | int get_random_tcp_conn_number(TCP_Connections *tcp_c); | ||
97 | |||
98 | /* Send an onion packet via the TCP relay corresponding to tcp_connections_number. | ||
99 | * | ||
100 | * return 0 on success. | ||
101 | * return -1 on failure. | ||
102 | */ | ||
103 | int tcp_send_onion_request(TCP_Connections *tcp_c, unsigned int tcp_connections_number, const uint8_t *data, | ||
104 | uint16_t length); | ||
105 | |||
106 | /* Set the callback for TCP data packets. | ||
107 | */ | ||
108 | void set_packet_tcp_connection_callback(TCP_Connections *tcp_c, int (*tcp_data_callback)(void *object, int id, | ||
109 | const uint8_t *data, uint16_t length), void *object); | ||
110 | |||
111 | /* Set the callback for TCP oob data packets. | ||
112 | */ | ||
113 | void set_onion_packet_tcp_connection_callback(TCP_Connections *tcp_c, int (*tcp_onion_callback)(void *object, | ||
114 | const uint8_t *data, uint16_t length), void *object); | ||
115 | |||
116 | /* Set the callback for TCP oob data packets. | ||
117 | */ | ||
118 | void set_oob_packet_tcp_connection_callback(TCP_Connections *tcp_c, int (*tcp_oob_callback)(void *object, | ||
119 | const uint8_t *public_key, const uint8_t *relay_pk, const uint8_t *data, uint16_t length), void *object); | ||
120 | |||
121 | /* Create a new TCP connection to public_key. | ||
122 | * | ||
123 | * id is the id in the callbacks for that connection. | ||
124 | * | ||
125 | * return connections_number on success. | ||
126 | * return -1 on failure. | ||
127 | */ | ||
128 | int new_tcp_connection_to(TCP_Connections *tcp_c, const uint8_t *public_key, int id); | ||
129 | |||
130 | /* return 0 on success. | ||
131 | * return -1 on failure. | ||
132 | */ | ||
133 | int kill_tcp_connection_to(TCP_Connections *tcp_c, int connections_number); | ||
134 | |||
135 | /* Add a TCP relay tied to a connection. | ||
136 | * | ||
137 | * return 0 on success. | ||
138 | * return -1 on failure. | ||
139 | */ | ||
140 | int add_tcp_relay_connection(TCP_Connections *tcp_c, int connections_number, IP_Port ip_port, const uint8_t *relay_pk); | ||
141 | |||
142 | /* Add a TCP relay to the instance. | ||
143 | * | ||
144 | * return 0 on success. | ||
145 | * return -1 on failure. | ||
146 | */ | ||
147 | int add_tcp_relay_global(TCP_Connections *tcp_c, IP_Port ip_port, const uint8_t *relay_pk); | ||
81 | 148 | ||
82 | 149 | ||
83 | TCP_Connections *new_tcp_connections(DHT *dht); | 150 | TCP_Connections *new_tcp_connections(DHT *dht); |