diff options
author | Nathan S. Evans <evans@in.tum.de> | 2010-09-05 10:04:49 +0000 |
---|---|---|
committer | Nathan S. Evans <evans@in.tum.de> | 2010-09-05 10:04:49 +0000 |
commit | 8d70c6db692b3119ff140bbf0d7cd39263b56fa8 (patch) | |
tree | 2db43c15553bab26c8dcccd74c56d8d7b7640624 /src/transport/transport_api.c | |
parent | 89de3fe552fcf8206e6981fc81cc179c97e5ac65 (diff) | |
download | gnunet-8d70c6db692b3119ff140bbf0d7cd39263b56fa8.tar.gz gnunet-8d70c6db692b3119ff140bbf0d7cd39263b56fa8.zip |
allow transport api to send multiple request connect messages
Diffstat (limited to 'src/transport/transport_api.c')
-rw-r--r-- | src/transport/transport_api.c | 45 |
1 files changed, 35 insertions, 10 deletions
diff --git a/src/transport/transport_api.c b/src/transport/transport_api.c index 4809981f5..093c00bef 100644 --- a/src/transport/transport_api.c +++ b/src/transport/transport_api.c | |||
@@ -1289,6 +1289,28 @@ send_transport_request_connect (void *cls, size_t size, void *buf) | |||
1289 | } | 1289 | } |
1290 | 1290 | ||
1291 | /** | 1291 | /** |
1292 | * Create and send a request connect message to | ||
1293 | * the transport service for a particular peer. | ||
1294 | * | ||
1295 | * @param h handle to the transport service | ||
1296 | * @param n the neighbor to send the request connect message about | ||
1297 | * | ||
1298 | */ | ||
1299 | static void send_request_connect_message(struct GNUNET_TRANSPORT_Handle *h, struct NeighbourList *n) | ||
1300 | { | ||
1301 | struct TransportRequestConnectMessage *trcm; | ||
1302 | |||
1303 | trcm = GNUNET_malloc(sizeof(struct TransportRequestConnectMessage)); | ||
1304 | trcm->header.type = htons(GNUNET_MESSAGE_TYPE_TRANSPORT_REQUEST_CONNECT); | ||
1305 | trcm->header.size = htons(sizeof(struct TransportRequestConnectMessage)); | ||
1306 | memcpy(&trcm->peer, &n->id, sizeof(struct GNUNET_PeerIdentity)); | ||
1307 | schedule_control_transmit (h, | ||
1308 | sizeof (struct TransportRequestConnectMessage), | ||
1309 | GNUNET_NO, | ||
1310 | GNUNET_TIME_UNIT_FOREVER_REL, &send_transport_request_connect, trcm); | ||
1311 | } | ||
1312 | |||
1313 | /** | ||
1292 | * Add neighbour to our list | 1314 | * Add neighbour to our list |
1293 | * | 1315 | * |
1294 | * @return NULL if this API is currently disconnecting from the service | 1316 | * @return NULL if this API is currently disconnecting from the service |
@@ -1298,7 +1320,6 @@ neighbour_add (struct GNUNET_TRANSPORT_Handle *h, | |||
1298 | const struct GNUNET_PeerIdentity *pid) | 1320 | const struct GNUNET_PeerIdentity *pid) |
1299 | { | 1321 | { |
1300 | struct NeighbourList *n; | 1322 | struct NeighbourList *n; |
1301 | struct TransportRequestConnectMessage *trcm; | ||
1302 | 1323 | ||
1303 | if (GNUNET_YES == h->in_disconnect) | 1324 | if (GNUNET_YES == h->in_disconnect) |
1304 | return NULL; | 1325 | return NULL; |
@@ -1322,14 +1343,7 @@ neighbour_add (struct GNUNET_TRANSPORT_Handle *h, | |||
1322 | n->h = h; | 1343 | n->h = h; |
1323 | h->neighbours = n; | 1344 | h->neighbours = n; |
1324 | 1345 | ||
1325 | trcm = GNUNET_malloc(sizeof(struct TransportRequestConnectMessage)); | 1346 | |
1326 | trcm->header.type = htons(GNUNET_MESSAGE_TYPE_TRANSPORT_REQUEST_CONNECT); | ||
1327 | trcm->header.size = htons(sizeof(struct TransportRequestConnectMessage)); | ||
1328 | memcpy(&trcm->peer, pid, sizeof(struct GNUNET_PeerIdentity)); | ||
1329 | schedule_control_transmit (h, | ||
1330 | sizeof (struct TransportRequestConnectMessage), | ||
1331 | GNUNET_NO, | ||
1332 | GNUNET_TIME_UNIT_FOREVER_REL, &send_transport_request_connect, trcm); | ||
1333 | return n; | 1347 | return n; |
1334 | } | 1348 | } |
1335 | 1349 | ||
@@ -1796,6 +1810,17 @@ GNUNET_TRANSPORT_notify_transmit_ready (struct GNUNET_TRANSPORT_Handle | |||
1796 | n = neighbour_add (handle, target); | 1810 | n = neighbour_add (handle, target); |
1797 | 1811 | ||
1798 | } | 1812 | } |
1813 | |||
1814 | /** | ||
1815 | * Send a request connect message if not connected, | ||
1816 | * otherwise we will never send anything to | ||
1817 | * transport service | ||
1818 | */ | ||
1819 | if (n->is_connected == GNUNET_NO) | ||
1820 | { | ||
1821 | send_request_connect_message(handle, n); | ||
1822 | } | ||
1823 | |||
1799 | if (n == NULL) | 1824 | if (n == NULL) |
1800 | { | 1825 | { |
1801 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1826 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
@@ -1830,7 +1855,7 @@ GNUNET_TRANSPORT_notify_transmit_ready (struct GNUNET_TRANSPORT_Handle | |||
1830 | th->priority = priority; | 1855 | th->priority = priority; |
1831 | th->notify_delay_task | 1856 | th->notify_delay_task |
1832 | = GNUNET_SCHEDULER_add_delayed (handle->sched, timeout, | 1857 | = GNUNET_SCHEDULER_add_delayed (handle->sched, timeout, |
1833 | &peer_transmit_timeout, th); | 1858 | &peer_transmit_timeout, th); |
1834 | schedule_transmission (handle); | 1859 | schedule_transmission (handle); |
1835 | return th; | 1860 | return th; |
1836 | } | 1861 | } |