diff options
-rw-r--r-- | src/include/gnunet_protocols.h | 6 | ||||
-rw-r--r-- | src/include/gnunet_transport_service.h | 49 | ||||
-rw-r--r-- | src/transport/gnunet-service-transport_clients.c | 40 | ||||
-rw-r--r-- | src/transport/transport_api.c | 161 |
4 files changed, 1 insertions, 255 deletions
diff --git a/src/include/gnunet_protocols.h b/src/include/gnunet_protocols.h index 9ac749637..7ec3ceb70 100644 --- a/src/include/gnunet_protocols.h +++ b/src/include/gnunet_protocols.h | |||
@@ -1266,12 +1266,6 @@ extern "C" | |||
1266 | #define GNUNET_MESSAGE_TYPE_TRANSPORT_PONG 373 | 1266 | #define GNUNET_MESSAGE_TYPE_TRANSPORT_PONG 373 |
1267 | 1267 | ||
1268 | /** | 1268 | /** |
1269 | * Message for transport service from a client asking that a | ||
1270 | * connection be initiated with another peer. | ||
1271 | */ | ||
1272 | #define GNUNET_MESSAGE_TYPE_TRANSPORT_REQUEST_CONNECT 374 | ||
1273 | |||
1274 | /** | ||
1275 | * Transport SYN message exchanged between transport services to | 1269 | * Transport SYN message exchanged between transport services to |
1276 | * indicate that a session should be marked as 'connected'. | 1270 | * indicate that a session should be marked as 'connected'. |
1277 | */ | 1271 | */ |
diff --git a/src/include/gnunet_transport_service.h b/src/include/gnunet_transport_service.h index c2f5798ad..8a20c52a7 100644 --- a/src/include/gnunet_transport_service.h +++ b/src/include/gnunet_transport_service.h | |||
@@ -160,55 +160,6 @@ void | |||
160 | GNUNET_TRANSPORT_disconnect (struct GNUNET_TRANSPORT_Handle *handle); | 160 | GNUNET_TRANSPORT_disconnect (struct GNUNET_TRANSPORT_Handle *handle); |
161 | 161 | ||
162 | 162 | ||
163 | /* ************************* Connections *********************** */ | ||
164 | |||
165 | /** | ||
166 | * Opaque handle for a transmission-ready request. | ||
167 | */ | ||
168 | struct GNUNET_TRANSPORT_TryConnectHandle; | ||
169 | |||
170 | /** | ||
171 | * Function to call with result of the try connect request. | ||
172 | * | ||
173 | * @param cls closure | ||
174 | * @param result #GNUNET_OK if message was transmitted to transport service | ||
175 | * #GNUNET_SYSERR if message was not transmitted to transport service | ||
176 | */ | ||
177 | typedef void | ||
178 | (*GNUNET_TRANSPORT_TryConnectCallback) (void *cls, | ||
179 | int result); | ||
180 | |||
181 | |||
182 | /** | ||
183 | * Ask the transport service to establish a connection to | ||
184 | * the given peer. | ||
185 | * | ||
186 | * @param handle connection to transport service | ||
187 | * @param target who we should try to connect to | ||
188 | * @param cb callback to be called when request was transmitted to transport | ||
189 | * service | ||
190 | * @param cb_cls closure for the callback @a cb | ||
191 | * @return a `struct GNUNET_TRANSPORT_TryConnectHandle` handle or | ||
192 | * NULL on failure (@a cb will not be called) | ||
193 | * @deprecated | ||
194 | */ | ||
195 | struct GNUNET_TRANSPORT_TryConnectHandle * | ||
196 | GNUNET_TRANSPORT_try_connect (struct GNUNET_TRANSPORT_Handle *handle, | ||
197 | const struct GNUNET_PeerIdentity *target, | ||
198 | GNUNET_TRANSPORT_TryConnectCallback cb, | ||
199 | void *cb_cls); | ||
200 | |||
201 | |||
202 | /** | ||
203 | * Cancel the request to transport to try a connect | ||
204 | * Callback will not be called | ||
205 | * | ||
206 | * @param tch handle to cancel | ||
207 | */ | ||
208 | void | ||
209 | GNUNET_TRANSPORT_try_connect_cancel (struct GNUNET_TRANSPORT_TryConnectHandle *tch); | ||
210 | |||
211 | |||
212 | /* ************************* Sending *************************** */ | 163 | /* ************************* Sending *************************** */ |
213 | 164 | ||
214 | /** | 165 | /** |
diff --git a/src/transport/gnunet-service-transport_clients.c b/src/transport/gnunet-service-transport_clients.c index 86c833c5b..84de4853b 100644 --- a/src/transport/gnunet-service-transport_clients.c +++ b/src/transport/gnunet-service-transport_clients.c | |||
@@ -876,43 +876,6 @@ clients_handle_send (void *cls, | |||
876 | 876 | ||
877 | 877 | ||
878 | /** | 878 | /** |
879 | * Handle request connect message | ||
880 | * | ||
881 | * @param cls closure (always NULL) | ||
882 | * @param client identification of the client | ||
883 | * @param message the actual message | ||
884 | */ | ||
885 | static void | ||
886 | clients_handle_request_connect (void *cls, | ||
887 | struct GNUNET_SERVER_Client *client, | ||
888 | const struct GNUNET_MessageHeader *message) | ||
889 | { | ||
890 | const struct TransportRequestConnectMessage *trcm; | ||
891 | |||
892 | trcm = (const struct TransportRequestConnectMessage *) message; | ||
893 | GNUNET_break (0 == ntohl (trcm->reserved)); | ||
894 | GNUNET_STATISTICS_update (GST_stats, | ||
895 | gettext_noop | ||
896 | ("# REQUEST CONNECT messages received"), 1, | ||
897 | GNUNET_NO); | ||
898 | if (0 == memcmp (&trcm->peer, | ||
899 | &GST_my_identity, | ||
900 | sizeof (struct GNUNET_PeerIdentity))) | ||
901 | { | ||
902 | GNUNET_break (0); | ||
903 | GNUNET_SERVER_receive_done (client, | ||
904 | GNUNET_OK); | ||
905 | return; | ||
906 | } | ||
907 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
908 | "Received a request connect message for peer `%s'\n", | ||
909 | GNUNET_i2s (&trcm->peer)); | ||
910 | GST_neighbours_try_connect (&trcm->peer); | ||
911 | GNUNET_SERVER_receive_done (client, GNUNET_OK); | ||
912 | } | ||
913 | |||
914 | |||
915 | /** | ||
916 | * Take the given address and append it to the set of results sent back to | 879 | * Take the given address and append it to the set of results sent back to |
917 | * the client. This function may be called serveral times for a single | 880 | * the client. This function may be called serveral times for a single |
918 | * conversion. The last invocation will be with a @a address of | 881 | * conversion. The last invocation will be with a @a address of |
@@ -1546,9 +1509,6 @@ GST_clients_start (struct GNUNET_SERVER_Handle *server) | |||
1546 | GNUNET_MESSAGE_TYPE_HELLO, 0}, | 1509 | GNUNET_MESSAGE_TYPE_HELLO, 0}, |
1547 | {&clients_handle_send, NULL, | 1510 | {&clients_handle_send, NULL, |
1548 | GNUNET_MESSAGE_TYPE_TRANSPORT_SEND, 0}, | 1511 | GNUNET_MESSAGE_TYPE_TRANSPORT_SEND, 0}, |
1549 | {&clients_handle_request_connect, NULL, | ||
1550 | GNUNET_MESSAGE_TYPE_TRANSPORT_REQUEST_CONNECT, | ||
1551 | sizeof (struct TransportRequestConnectMessage)}, | ||
1552 | {&clients_handle_address_to_string, NULL, | 1512 | {&clients_handle_address_to_string, NULL, |
1553 | GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_TO_STRING, 0}, | 1513 | GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_TO_STRING, 0}, |
1554 | {&clients_handle_monitor_peers, NULL, | 1514 | {&clients_handle_monitor_peers, NULL, |
diff --git a/src/transport/transport_api.c b/src/transport/transport_api.c index 29416b03d..9663d4ecd 100644 --- a/src/transport/transport_api.c +++ b/src/transport/transport_api.c | |||
@@ -203,49 +203,6 @@ struct GNUNET_TRANSPORT_GetHelloHandle | |||
203 | 203 | ||
204 | 204 | ||
205 | /** | 205 | /** |
206 | * Entry in linked list for a try-connect request. | ||
207 | */ | ||
208 | struct GNUNET_TRANSPORT_TryConnectHandle | ||
209 | { | ||
210 | /** | ||
211 | * For the DLL. | ||
212 | */ | ||
213 | struct GNUNET_TRANSPORT_TryConnectHandle *prev; | ||
214 | |||
215 | /** | ||
216 | * For the DLL. | ||
217 | */ | ||
218 | struct GNUNET_TRANSPORT_TryConnectHandle *next; | ||
219 | |||
220 | /** | ||
221 | * Peer we should try to connect to. | ||
222 | */ | ||
223 | struct GNUNET_PeerIdentity pid; | ||
224 | |||
225 | /** | ||
226 | * Transport service handle this request is part of. | ||
227 | */ | ||
228 | struct GNUNET_TRANSPORT_Handle *th; | ||
229 | |||
230 | /** | ||
231 | * Message transmission request to communicate to service. | ||
232 | */ | ||
233 | struct GNUNET_TRANSPORT_TransmitHandle *tth; | ||
234 | |||
235 | /** | ||
236 | * Function to call upon completion (of request transmission). | ||
237 | */ | ||
238 | GNUNET_TRANSPORT_TryConnectCallback cb; | ||
239 | |||
240 | /** | ||
241 | * Closure for @e cb. | ||
242 | */ | ||
243 | void *cb_cls; | ||
244 | |||
245 | }; | ||
246 | |||
247 | |||
248 | /** | ||
249 | * Entry in linked list for all offer-HELLO requests. | 206 | * Entry in linked list for all offer-HELLO requests. |
250 | */ | 207 | */ |
251 | struct GNUNET_TRANSPORT_OfferHelloHandle | 208 | struct GNUNET_TRANSPORT_OfferHelloHandle |
@@ -356,16 +313,6 @@ struct GNUNET_TRANSPORT_Handle | |||
356 | struct GNUNET_TRANSPORT_GetHelloHandle *hwl_tail; | 313 | struct GNUNET_TRANSPORT_GetHelloHandle *hwl_tail; |
357 | 314 | ||
358 | /** | 315 | /** |
359 | * Linked list of pending try connect requests head | ||
360 | */ | ||
361 | struct GNUNET_TRANSPORT_TryConnectHandle *tc_head; | ||
362 | |||
363 | /** | ||
364 | * Linked list of pending try connect requests tail | ||
365 | */ | ||
366 | struct GNUNET_TRANSPORT_TryConnectHandle *tc_tail; | ||
367 | |||
368 | /** | ||
369 | * Linked list of pending offer HELLO requests head | 316 | * Linked list of pending offer HELLO requests head |
370 | */ | 317 | */ |
371 | struct GNUNET_TRANSPORT_OfferHelloHandle *oh_head; | 318 | struct GNUNET_TRANSPORT_OfferHelloHandle *oh_head; |
@@ -1353,110 +1300,6 @@ cancel_control_transmit (struct GNUNET_TRANSPORT_Handle *th, | |||
1353 | 1300 | ||
1354 | 1301 | ||
1355 | /** | 1302 | /** |
1356 | * Send #GNUNET_MESSAGE_TYPE_TRANSPORT_REQUEST_CONNECT message to the | ||
1357 | * service. | ||
1358 | * | ||
1359 | * @param cls the `struct GNUNET_TRANSPORT_TryConnectHandle` | ||
1360 | * @param size number of bytes available in @a buf | ||
1361 | * @param buf where to copy the message | ||
1362 | * @return number of bytes copied to @a buf | ||
1363 | */ | ||
1364 | static size_t | ||
1365 | send_try_connect (void *cls, | ||
1366 | size_t size, | ||
1367 | void *buf) | ||
1368 | { | ||
1369 | struct GNUNET_TRANSPORT_TryConnectHandle *tch = cls; | ||
1370 | struct TransportRequestConnectMessage msg; | ||
1371 | |||
1372 | tch->tth = NULL; | ||
1373 | if (NULL == buf) | ||
1374 | { | ||
1375 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
1376 | "Discarding REQUEST_CONNECT request to `%s' due to error in transport service connection.\n", | ||
1377 | GNUNET_i2s (&tch->pid)); | ||
1378 | if (NULL != tch->cb) | ||
1379 | tch->cb (tch->cb_cls, | ||
1380 | GNUNET_SYSERR); | ||
1381 | GNUNET_TRANSPORT_try_connect_cancel (tch); | ||
1382 | return 0; | ||
1383 | } | ||
1384 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
1385 | "Transmitting `%s' request with respect to `%s'.\n", | ||
1386 | "REQUEST_CONNECT", | ||
1387 | GNUNET_i2s (&tch->pid)); | ||
1388 | GNUNET_assert (size >= sizeof (struct TransportRequestConnectMessage)); | ||
1389 | msg.header.size = htons (sizeof (struct TransportRequestConnectMessage)); | ||
1390 | msg.header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_REQUEST_CONNECT); | ||
1391 | msg.reserved = htonl (0); | ||
1392 | msg.peer = tch->pid; | ||
1393 | memcpy (buf, &msg, sizeof (msg)); | ||
1394 | if (NULL != tch->cb) | ||
1395 | tch->cb (tch->cb_cls, GNUNET_OK); | ||
1396 | GNUNET_TRANSPORT_try_connect_cancel (tch); | ||
1397 | return sizeof (struct TransportRequestConnectMessage); | ||
1398 | } | ||
1399 | |||
1400 | |||
1401 | /** | ||
1402 | * Ask the transport service to establish a connection to | ||
1403 | * the given peer. | ||
1404 | * | ||
1405 | * @param handle connection to transport service | ||
1406 | * @param target who we should try to connect to | ||
1407 | * @param cb callback to be called when request was transmitted to transport | ||
1408 | * service | ||
1409 | * @param cb_cls closure for the callback | ||
1410 | * @return a `struct GNUNET_TRANSPORT_TryConnectHandle` handle or | ||
1411 | * NULL on failure (cb will not be called) | ||
1412 | */ | ||
1413 | struct GNUNET_TRANSPORT_TryConnectHandle * | ||
1414 | GNUNET_TRANSPORT_try_connect (struct GNUNET_TRANSPORT_Handle *handle, | ||
1415 | const struct GNUNET_PeerIdentity *target, | ||
1416 | GNUNET_TRANSPORT_TryConnectCallback cb, | ||
1417 | void *cb_cls) | ||
1418 | { | ||
1419 | struct GNUNET_TRANSPORT_TryConnectHandle *tch; | ||
1420 | |||
1421 | if (NULL == handle->client) | ||
1422 | return NULL; | ||
1423 | tch = GNUNET_new (struct GNUNET_TRANSPORT_TryConnectHandle); | ||
1424 | tch->th = handle; | ||
1425 | tch->pid = *target; | ||
1426 | tch->cb = cb; | ||
1427 | tch->cb_cls = cb_cls; | ||
1428 | tch->tth = schedule_control_transmit (handle, | ||
1429 | sizeof (struct TransportRequestConnectMessage), | ||
1430 | &send_try_connect, tch); | ||
1431 | GNUNET_CONTAINER_DLL_insert (handle->tc_head, | ||
1432 | handle->tc_tail, | ||
1433 | tch); | ||
1434 | return tch; | ||
1435 | } | ||
1436 | |||
1437 | |||
1438 | /** | ||
1439 | * Cancel the request to transport to try a connect | ||
1440 | * Callback will not be called | ||
1441 | * | ||
1442 | * @param tch the handle to cancel | ||
1443 | */ | ||
1444 | void | ||
1445 | GNUNET_TRANSPORT_try_connect_cancel (struct GNUNET_TRANSPORT_TryConnectHandle *tch) | ||
1446 | { | ||
1447 | struct GNUNET_TRANSPORT_Handle *th; | ||
1448 | |||
1449 | th = tch->th; | ||
1450 | if (NULL != tch->tth) | ||
1451 | cancel_control_transmit (th, tch->tth); | ||
1452 | GNUNET_CONTAINER_DLL_remove (th->tc_head, | ||
1453 | th->tc_tail, | ||
1454 | tch); | ||
1455 | GNUNET_free (tch); | ||
1456 | } | ||
1457 | |||
1458 | |||
1459 | /** | ||
1460 | * Send HELLO message to the service. | 1303 | * Send HELLO message to the service. |
1461 | * | 1304 | * |
1462 | * @param cls the HELLO message to send | 1305 | * @param cls the HELLO message to send |
@@ -1873,8 +1716,6 @@ GNUNET_TRANSPORT_disconnect (struct GNUNET_TRANSPORT_Handle *handle) | |||
1873 | } | 1716 | } |
1874 | GNUNET_free_non_null (handle->my_hello); | 1717 | GNUNET_free_non_null (handle->my_hello); |
1875 | handle->my_hello = NULL; | 1718 | handle->my_hello = NULL; |
1876 | GNUNET_assert (NULL == handle->tc_head); | ||
1877 | GNUNET_assert (NULL == handle->tc_tail); | ||
1878 | GNUNET_assert (NULL == handle->hwl_head); | 1719 | GNUNET_assert (NULL == handle->hwl_head); |
1879 | GNUNET_assert (NULL == handle->hwl_tail); | 1720 | GNUNET_assert (NULL == handle->hwl_tail); |
1880 | GNUNET_CONTAINER_heap_destroy (handle->ready_heap); | 1721 | GNUNET_CONTAINER_heap_destroy (handle->ready_heap); |
@@ -1916,7 +1757,7 @@ GNUNET_TRANSPORT_notify_transmit_ready (struct GNUNET_TRANSPORT_Handle *handle, | |||
1916 | n = neighbour_find (handle, target); | 1757 | n = neighbour_find (handle, target); |
1917 | if (NULL == n) | 1758 | if (NULL == n) |
1918 | { | 1759 | { |
1919 | /* use GNUNET_TRANSPORT_try_connect first, only use this function | 1760 | /* only use this function |
1920 | * once a connection has been established */ | 1761 | * once a connection has been established */ |
1921 | GNUNET_assert (0); | 1762 | GNUNET_assert (0); |
1922 | return NULL; | 1763 | return NULL; |