aboutsummaryrefslogtreecommitdiff
path: root/src/transport
diff options
context:
space:
mode:
authorNathan S. Evans <evans@in.tum.de>2010-01-21 14:07:41 +0000
committerNathan S. Evans <evans@in.tum.de>2010-01-21 14:07:41 +0000
commite7006a361e7df7f32cb02db78ef1c31b376842a3 (patch)
treeca76593cd5ee039117ff6c3b55c2c0e7d9d97242 /src/transport
parent87b254030acd37b6714565c5ac2e803da743d777 (diff)
downloadgnunet-e7006a361e7df7f32cb02db78ef1c31b376842a3.tar.gz
gnunet-e7006a361e7df7f32cb02db78ef1c31b376842a3.zip
it compiles, but definitely doesn't work
Diffstat (limited to 'src/transport')
-rw-r--r--src/transport/plugin_transport_tcp.c12
-rw-r--r--src/transport/plugin_transport_udp.c5
-rw-r--r--src/transport/transport.h10
-rw-r--r--src/transport/transport_api.c29
4 files changed, 33 insertions, 23 deletions
diff --git a/src/transport/plugin_transport_tcp.c b/src/transport/plugin_transport_tcp.c
index 8b9a2b695..481c52ba8 100644
--- a/src/transport/plugin_transport_tcp.c
+++ b/src/transport/plugin_transport_tcp.c
@@ -513,10 +513,11 @@ disconnect_session (struct Session *session)
513 know about this one, so we need to 513 know about this one, so we need to
514 notify transport service about disconnect */ 514 notify transport service about disconnect */
515 session->plugin->env->receive (session->plugin->env->cls, 515 session->plugin->env->receive (session->plugin->env->cls,
516 1, 516 NULL,
517 &session->target,
518 1,
517 session->connect_addr, 519 session->connect_addr,
518 session->connect_alen, 520 session->connect_alen);
519 &session->target, NULL);
520 } 521 }
521 if (session->client != NULL) 522 if (session->client != NULL)
522 { 523 {
@@ -1089,10 +1090,9 @@ handle_tcp_data (void *cls,
1089 (unsigned int) msize, 1090 (unsigned int) msize,
1090 (unsigned int) ntohs (msg->type)); 1091 (unsigned int) ntohs (msg->type));
1091#endif 1092#endif
1092 plugin->env->receive (plugin->env->cls, 1, 1093 plugin->env->receive (plugin->env->cls, message, &session->target, 1,
1093 session->connect_addr, 1094 session->connect_addr,
1094 session->connect_alen, 1095 session->connect_alen);
1095 &session->target, message);
1096 /* update bandwidth used */ 1096 /* update bandwidth used */
1097 session->last_received += msize; 1097 session->last_received += msize;
1098 update_quota (session, GNUNET_NO); 1098 update_quota (session, GNUNET_NO);
diff --git a/src/transport/plugin_transport_udp.c b/src/transport/plugin_transport_udp.c
index c3f97aed5..e9e243969 100644
--- a/src/transport/plugin_transport_udp.c
+++ b/src/transport/plugin_transport_udp.c
@@ -330,9 +330,8 @@ udp_plugin_select (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
330 ("msg reports message type of %d\n"), 330 ("msg reports message type of %d\n"),
331 ntohs (hdr->type)); 331 ntohs (hdr->type));
332#endif 332#endif
333 333 plugin->env->receive (plugin->env->cls,
334 plugin->env->receive (plugin->env->cls, UDP_DIRECT_DISTANCE,(char *)&addr, fromlen, sender, 334 &msg->header, sender, UDP_DIRECT_DISTANCE, (char *)&addr, fromlen);
335 &msg->header);
336 335
337 GNUNET_free (sender); 336 GNUNET_free (sender);
338 GNUNET_free (buf); 337 GNUNET_free (buf);
diff --git a/src/transport/transport.h b/src/transport/transport.h
index edbf16685..0970b3648 100644
--- a/src/transport/transport.h
+++ b/src/transport/transport.h
@@ -64,6 +64,11 @@ struct ConnectInfoMessage
64 */ 64 */
65 struct GNUNET_TIME_RelativeNBO latency; 65 struct GNUNET_TIME_RelativeNBO latency;
66 66
67 /*
68 * Transport distance metric (i.e. hops for DV)
69 */
70 uint16_t distance;
71
67 /** 72 /**
68 * Identity of the new neighbour. 73 * Identity of the new neighbour.
69 */ 74 */
@@ -175,6 +180,11 @@ struct InboundMessage
175 */ 180 */
176 struct GNUNET_PeerIdentity peer; 181 struct GNUNET_PeerIdentity peer;
177 182
183 /*
184 * Distance metric.
185 */
186 uint16_t distance;
187
178}; 188};
179 189
180 190
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;