aboutsummaryrefslogtreecommitdiff
path: root/src/transport/transport_api.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/transport/transport_api.c')
-rw-r--r--src/transport/transport_api.c29
1 files changed, 15 insertions, 14 deletions
diff --git a/src/transport/transport_api.c b/src/transport/transport_api.c
index e17ba742e..8bf2cf621 100644
--- a/src/transport/transport_api.c
+++ b/src/transport/transport_api.c
@@ -138,7 +138,7 @@ struct HelloWaitList
138 /** 138 /**
139 * Callback to call once we got our HELLO. 139 * Callback to call once we got our HELLO.
140 */ 140 */
141 GNUNET_TRANSPORT_ReceiveCallback rec; 141 GNUNET_TRANSPORT_HelloUpdateCallback rec;
142 142
143 /** 143 /**
144 * Closure for rec. 144 * Closure for rec.
@@ -818,7 +818,7 @@ hello_wait_timeout (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
818 else 818 else
819 prev->next = hwl->next; 819 prev->next = hwl->next;
820 if (hwl->rec != NULL) 820 if (hwl->rec != NULL)
821 hwl->rec (hwl->rec_cls, GNUNET_TIME_UNIT_ZERO, NULL, NULL); 821 hwl->rec (hwl->rec_cls, NULL);
822 GNUNET_free (hwl); 822 GNUNET_free (hwl);
823} 823}
824 824
@@ -836,8 +836,7 @@ hello_wait_timeout (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
836 */ 836 */
837void 837void
838GNUNET_TRANSPORT_get_hello (struct GNUNET_TRANSPORT_Handle *handle, 838GNUNET_TRANSPORT_get_hello (struct GNUNET_TRANSPORT_Handle *handle,
839 struct GNUNET_TIME_Relative timeout, 839 GNUNET_TRANSPORT_HelloUpdateCallback rec,
840 GNUNET_TRANSPORT_ReceiveCallback rec,
841 void *rec_cls) 840 void *rec_cls)
842{ 841{
843 struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded pk; 842 struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded pk;
@@ -852,10 +851,14 @@ GNUNET_TRANSPORT_get_hello (struct GNUNET_TRANSPORT_Handle *handle,
852 hwl->handle = handle; 851 hwl->handle = handle;
853 hwl->rec = rec; 852 hwl->rec = rec;
854 hwl->rec_cls = rec_cls; 853 hwl->rec_cls = rec_cls;
855 hwl->timeout = GNUNET_TIME_relative_to_absolute (timeout); 854 /* hwl->timeout = GNUNET_TIME_relative_to_absolute (timeout);
855 * Timeout not needed, because we should notify on change.
856 * FIXME: set up scheduler to notify on modification?
857
856 hwl->task = GNUNET_SCHEDULER_add_delayed (handle->sched, 858 hwl->task = GNUNET_SCHEDULER_add_delayed (handle->sched,
857 timeout, 859 timeout,
858 &hello_wait_timeout, hwl); 860 &hello_wait_timeout, hwl);
861 */
859 return; 862 return;
860 } 863 }
861 GNUNET_assert (GNUNET_OK == GNUNET_HELLO_get_key (handle->my_hello, &pk)); 864 GNUNET_assert (GNUNET_OK == GNUNET_HELLO_get_key (handle->my_hello, &pk));
@@ -863,9 +866,7 @@ GNUNET_TRANSPORT_get_hello (struct GNUNET_TRANSPORT_Handle *handle,
863 sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded), 866 sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded),
864 &me.hashPubKey); 867 &me.hashPubKey);
865 868
866 rec (rec_cls, 869 rec (rec_cls, (const struct GNUNET_MessageHeader *) handle->my_hello);
867 GNUNET_TIME_UNIT_ZERO,
868 &me, (const struct GNUNET_MessageHeader *) handle->my_hello);
869} 870}
870 871
871 872
@@ -1342,6 +1343,7 @@ static void
1342add_neighbour (struct GNUNET_TRANSPORT_Handle *h, 1343add_neighbour (struct GNUNET_TRANSPORT_Handle *h,
1343 uint32_t quota_out, 1344 uint32_t quota_out,
1344 struct GNUNET_TIME_Relative latency, 1345 struct GNUNET_TIME_Relative latency,
1346 uint16_t distance,
1345 const struct GNUNET_PeerIdentity *pid) 1347 const struct GNUNET_PeerIdentity *pid)
1346{ 1348{
1347 struct NeighbourList *n; 1349 struct NeighbourList *n;
@@ -1367,7 +1369,7 @@ add_neighbour (struct GNUNET_TRANSPORT_Handle *h,
1367 n->transmit_ok = GNUNET_YES; 1369 n->transmit_ok = GNUNET_YES;
1368 h->neighbours = n; 1370 h->neighbours = n;
1369 if (h->nc_cb != NULL) 1371 if (h->nc_cb != NULL)
1370 h->nc_cb (h->cls, &n->id, latency); 1372 h->nc_cb (h->cls, &n->id, latency, distance);
1371 prev = NULL; 1373 prev = NULL;
1372 pos = h->connect_wait_head; 1374 pos = h->connect_wait_head;
1373 while (pos != NULL) 1375 while (pos != NULL)
@@ -1512,7 +1514,7 @@ GNUNET_TRANSPORT_disconnect (struct GNUNET_TRANSPORT_Handle *handle)
1512 ("Disconnect while trying to obtain `%s' from transport service.\n"), 1514 ("Disconnect while trying to obtain `%s' from transport service.\n"),
1513 "HELLO"); 1515 "HELLO");
1514 if (hwl->rec != NULL) 1516 if (hwl->rec != NULL)
1515 hwl->rec (hwl->rec_cls, GNUNET_TIME_UNIT_ZERO, NULL, NULL); 1517 hwl->rec (hwl->rec_cls, NULL);
1516 GNUNET_free (hwl); 1518 GNUNET_free (hwl);
1517 } 1519 }
1518 if (handle->reconnect_task != GNUNET_SCHEDULER_NO_TASK) 1520 if (handle->reconnect_task != GNUNET_SCHEDULER_NO_TASK)
@@ -1631,7 +1633,6 @@ demultiplexer (void *cls, const struct GNUNET_MessageHeader *msg)
1631 h->hwl_head = hwl->next; 1633 h->hwl_head = hwl->next;
1632 GNUNET_SCHEDULER_cancel (h->sched, hwl->task); 1634 GNUNET_SCHEDULER_cancel (h->sched, hwl->task);
1633 GNUNET_TRANSPORT_get_hello (h, 1635 GNUNET_TRANSPORT_get_hello (h,
1634 GNUNET_TIME_UNIT_ZERO,
1635 hwl->rec, hwl->rec_cls); 1636 hwl->rec, hwl->rec_cls);
1636 GNUNET_free (hwl); 1637 GNUNET_free (hwl);
1637 } 1638 }
@@ -1650,7 +1651,7 @@ demultiplexer (void *cls, const struct GNUNET_MessageHeader *msg)
1650#endif 1651#endif
1651 add_neighbour (h, 1652 add_neighbour (h,
1652 ntohl (cim->quota_out), 1653 ntohl (cim->quota_out),
1653 GNUNET_TIME_relative_ntoh (cim->latency), &cim->id); 1654 GNUNET_TIME_relative_ntoh (cim->latency), ntohs(cim->distance), &cim->id);
1654 break; 1655 break;
1655 case GNUNET_MESSAGE_TYPE_TRANSPORT_DISCONNECT: 1656 case GNUNET_MESSAGE_TYPE_TRANSPORT_DISCONNECT:
1656 if (size != sizeof (struct DisconnectInfoMessage)) 1657 if (size != sizeof (struct DisconnectInfoMessage))
@@ -1748,8 +1749,8 @@ demultiplexer (void *cls, const struct GNUNET_MessageHeader *msg)
1748 ntohs (imm->type), GNUNET_i2s (&im->peer)); 1749 ntohs (imm->type), GNUNET_i2s (&im->peer));
1749#endif 1750#endif
1750 if (h->rec != NULL) 1751 if (h->rec != NULL)
1751 h->rec (h->cls, 1752 h->rec (h->cls, &im->peer, imm,
1752 GNUNET_TIME_relative_ntoh (im->latency), &im->peer, imm); 1753 GNUNET_TIME_relative_ntoh (im->latency), ntohs(im->distance));
1753 break; 1754 break;
1754 } 1755 }
1755 break; 1756 break;