diff options
author | Christian Grothoff <christian@grothoff.org> | 2010-07-21 20:48:40 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2010-07-21 20:48:40 +0000 |
commit | b05f920bfa907476b618a24bd78487db8873d2a1 (patch) | |
tree | fad22297a66787044837faa4c2c3459f48d6bb85 | |
parent | afec51a8dd5d9f77a00d902acd7b5efc04675298 (diff) | |
download | gnunet-b05f920bfa907476b618a24bd78487db8873d2a1.tar.gz gnunet-b05f920bfa907476b618a24bd78487db8873d2a1.zip |
add code to enable checking if transport's idea of our peer identity matches that of core, etc -- might help diagnose certain bugs
-rw-r--r-- | TODO | 24 | ||||
-rw-r--r-- | src/core/gnunet-service-core.c | 1 | ||||
-rw-r--r-- | src/core/test_core_api.c | 2 | ||||
-rw-r--r-- | src/core/test_core_api_reliability.c | 2 | ||||
-rw-r--r-- | src/dht/gnunet-service-dht.c | 3 | ||||
-rw-r--r-- | src/hostlist/hostlist-client.c | 2 | ||||
-rw-r--r-- | src/hostlist/test_gnunet_daemon_hostlist.c | 2 | ||||
-rw-r--r-- | src/include/gnunet_transport_service.h | 6 | ||||
-rw-r--r-- | src/testing/testing.c | 12 | ||||
-rw-r--r-- | src/topology/gnunet-daemon-topology.c | 1 | ||||
-rw-r--r-- | src/transport/gnunet-service-transport.c | 15 | ||||
-rw-r--r-- | src/transport/test_transport_api.c | 2 | ||||
-rw-r--r-- | src/transport/test_transport_api_reliability.c | 2 | ||||
-rw-r--r-- | src/transport/transport.h | 27 | ||||
-rw-r--r-- | src/transport/transport_api.c | 38 |
15 files changed, 107 insertions, 32 deletions
@@ -22,15 +22,6 @@ | |||
22 | * DHT: [Nate] | 22 | * DHT: [Nate] |
23 | - implement DHT service | 23 | - implement DHT service |
24 | - implement performance tests | 24 | - implement performance tests |
25 | * FS: [CG] | ||
26 | - service: | ||
27 | + trust: do not charge when "idle" / load considerations (migration, routing) | ||
28 | + artificial delays | ||
29 | + active reply route caching design & implementation; gap extension! | ||
30 | - non-anonymous FS service (needs DHT) | ||
31 | + DHT integration for search | ||
32 | + CS-DHT-functions (DHT-put of LOC) | ||
33 | + P2P-functions (DHT-get) | ||
34 | * GNUNET-GTK: [CG] | 25 | * GNUNET-GTK: [CG] |
35 | - implement publish dialog details: | 26 | - implement publish dialog details: |
36 | + open (import directory structure) | 27 | + open (import directory structure) |
@@ -92,9 +83,18 @@ | |||
92 | - datacache | 83 | - datacache |
93 | - datastore | 84 | - datastore |
94 | * FS: [CG] | 85 | * FS: [CG] |
95 | - reconstruct IBLOCKS from DBLOCKS if possible (during download; see FIXME in fs_download) | 86 | - library: |
96 | - add support for pushing "already seen" search results to FS service for bloomfilter (can wait) | 87 | + reconstruct IBLOCKS from DBLOCKS if possible (during download; see FIXME in fs_download) |
97 | - use different 'priority' for probe downloads vs. normal downloads | 88 | + add support for pushing "already seen" search results to FS service for bloomfilter (can wait) |
89 | + use different 'priority' for probe downloads vs. normal downloads | ||
90 | - service: | ||
91 | + trust: do not charge when "idle" / load considerations (migration, routing) | ||
92 | + artificial delays | ||
93 | + active reply route caching design & implementation; gap extension! | ||
94 | - non-anonymous FS service (needs DHT) | ||
95 | + DHT integration for search | ||
96 | + CS-DHT-functions (DHT-put of LOC) | ||
97 | + P2P-functions (DHT-get) | ||
98 | - implement FS performance tests | 98 | - implement FS performance tests |
99 | + insert | 99 | + insert |
100 | + download | 100 | + download |
diff --git a/src/core/gnunet-service-core.c b/src/core/gnunet-service-core.c index df3342ce0..2ad197e58 100644 --- a/src/core/gnunet-service-core.c +++ b/src/core/gnunet-service-core.c | |||
@@ -3878,6 +3878,7 @@ run (void *cls, | |||
3878 | /* setup transport connection */ | 3878 | /* setup transport connection */ |
3879 | transport = GNUNET_TRANSPORT_connect (sched, | 3879 | transport = GNUNET_TRANSPORT_connect (sched, |
3880 | cfg, | 3880 | cfg, |
3881 | &my_identity, | ||
3881 | NULL, | 3882 | NULL, |
3882 | &handle_transport_receive, | 3883 | &handle_transport_receive, |
3883 | &handle_transport_notify_connect, | 3884 | &handle_transport_notify_connect, |
diff --git a/src/core/test_core_api.c b/src/core/test_core_api.c index ad82d0a1d..b04430eea 100644 --- a/src/core/test_core_api.c +++ b/src/core/test_core_api.c | |||
@@ -297,7 +297,7 @@ setup_peer (struct PeerContext *p, const char *cfgname) | |||
297 | "-c", cfgname, NULL); | 297 | "-c", cfgname, NULL); |
298 | #endif | 298 | #endif |
299 | GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname)); | 299 | GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname)); |
300 | p->th = GNUNET_TRANSPORT_connect (sched, p->cfg, p, NULL, NULL, NULL); | 300 | p->th = GNUNET_TRANSPORT_connect (sched, p->cfg, NULL, p, NULL, NULL, NULL); |
301 | GNUNET_assert (p->th != NULL); | 301 | GNUNET_assert (p->th != NULL); |
302 | GNUNET_TRANSPORT_get_hello (p->th, &process_hello, p); | 302 | GNUNET_TRANSPORT_get_hello (p->th, &process_hello, p); |
303 | } | 303 | } |
diff --git a/src/core/test_core_api_reliability.c b/src/core/test_core_api_reliability.c index e8e1ad0f6..b9fba21c6 100644 --- a/src/core/test_core_api_reliability.c +++ b/src/core/test_core_api_reliability.c | |||
@@ -444,7 +444,7 @@ setup_peer (struct PeerContext *p, const char *cfgname) | |||
444 | "-c", cfgname, NULL); | 444 | "-c", cfgname, NULL); |
445 | #endif | 445 | #endif |
446 | GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname)); | 446 | GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname)); |
447 | p->th = GNUNET_TRANSPORT_connect (sched, p->cfg, p, NULL, NULL, NULL); | 447 | p->th = GNUNET_TRANSPORT_connect (sched, p->cfg, NULL, p, NULL, NULL, NULL); |
448 | GNUNET_assert (p->th != NULL); | 448 | GNUNET_assert (p->th != NULL); |
449 | GNUNET_TRANSPORT_get_hello (p->th, &process_hello, p); | 449 | GNUNET_TRANSPORT_get_hello (p->th, &process_hello, p); |
450 | } | 450 | } |
diff --git a/src/dht/gnunet-service-dht.c b/src/dht/gnunet-service-dht.c index 9cd4c2909..31ceff773 100644 --- a/src/dht/gnunet-service-dht.c +++ b/src/dht/gnunet-service-dht.c | |||
@@ -2445,7 +2445,8 @@ run (void *cls, | |||
2445 | 2445 | ||
2446 | if (coreAPI == NULL) | 2446 | if (coreAPI == NULL) |
2447 | return; | 2447 | return; |
2448 | transport_handle = GNUNET_TRANSPORT_connect(sched, cfg, NULL, NULL, NULL, NULL); | 2448 | transport_handle = GNUNET_TRANSPORT_connect(sched, cfg, |
2449 | NULL, NULL, NULL, NULL, NULL); | ||
2449 | if (transport_handle != NULL) | 2450 | if (transport_handle != NULL) |
2450 | GNUNET_TRANSPORT_get_hello (transport_handle, &process_hello, NULL); | 2451 | GNUNET_TRANSPORT_get_hello (transport_handle, &process_hello, NULL); |
2451 | else | 2452 | else |
diff --git a/src/hostlist/hostlist-client.c b/src/hostlist/hostlist-client.c index 26b68390c..b4d86e052 100644 --- a/src/hostlist/hostlist-client.c +++ b/src/hostlist/hostlist-client.c | |||
@@ -1528,7 +1528,7 @@ GNUNET_HOSTLIST_client_start (const struct GNUNET_CONFIGURATION_Handle *c, | |||
1528 | GNUNET_break (0); | 1528 | GNUNET_break (0); |
1529 | return GNUNET_SYSERR; | 1529 | return GNUNET_SYSERR; |
1530 | } | 1530 | } |
1531 | transport = GNUNET_TRANSPORT_connect (s, c, NULL, NULL, NULL, NULL); | 1531 | transport = GNUNET_TRANSPORT_connect (s, c, NULL, NULL, NULL, NULL, NULL); |
1532 | if (NULL == transport) | 1532 | if (NULL == transport) |
1533 | { | 1533 | { |
1534 | curl_global_cleanup (); | 1534 | curl_global_cleanup (); |
diff --git a/src/hostlist/test_gnunet_daemon_hostlist.c b/src/hostlist/test_gnunet_daemon_hostlist.c index 85138ebf1..899a2eb44 100644 --- a/src/hostlist/test_gnunet_daemon_hostlist.c +++ b/src/hostlist/test_gnunet_daemon_hostlist.c | |||
@@ -143,7 +143,7 @@ setup_peer (struct PeerContext *p, const char *cfgname) | |||
143 | "-c", cfgname, NULL); | 143 | "-c", cfgname, NULL); |
144 | #endif | 144 | #endif |
145 | GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname)); | 145 | GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname)); |
146 | p->th = GNUNET_TRANSPORT_connect (sched, p->cfg, p, NULL, | 146 | p->th = GNUNET_TRANSPORT_connect (sched, p->cfg, NULL, p, NULL, |
147 | ¬ify_connect, NULL); | 147 | ¬ify_connect, NULL); |
148 | GNUNET_assert (p->th != NULL); | 148 | GNUNET_assert (p->th != NULL); |
149 | GNUNET_TRANSPORT_get_hello (p->th, &process_hello, p); | 149 | GNUNET_TRANSPORT_get_hello (p->th, &process_hello, p); |
diff --git a/src/include/gnunet_transport_service.h b/src/include/gnunet_transport_service.h index 7cb4df5a6..2ee9fb718 100644 --- a/src/include/gnunet_transport_service.h +++ b/src/include/gnunet_transport_service.h | |||
@@ -120,6 +120,8 @@ typedef void | |||
120 | * | 120 | * |
121 | * @param sched scheduler to use | 121 | * @param sched scheduler to use |
122 | * @param cfg configuration to use | 122 | * @param cfg configuration to use |
123 | * @param self our own identity (API should check that it matches | ||
124 | * the identity found by transport), or NULL (no check) | ||
123 | * @param cls closure for the callbacks | 125 | * @param cls closure for the callbacks |
124 | * @param rec receive function to call | 126 | * @param rec receive function to call |
125 | * @param nc function to call on connect events | 127 | * @param nc function to call on connect events |
@@ -131,7 +133,9 @@ struct GNUNET_TRANSPORT_Handle *GNUNET_TRANSPORT_connect (struct | |||
131 | *sched, | 133 | *sched, |
132 | const struct | 134 | const struct |
133 | GNUNET_CONFIGURATION_Handle | 135 | GNUNET_CONFIGURATION_Handle |
134 | *cfg, void *cls, | 136 | *cfg, |
137 | const struct GNUNET_PeerIdentity *self, | ||
138 | void *cls, | ||
135 | GNUNET_TRANSPORT_ReceiveCallback | 139 | GNUNET_TRANSPORT_ReceiveCallback |
136 | rec, | 140 | rec, |
137 | GNUNET_TRANSPORT_NotifyConnect | 141 | GNUNET_TRANSPORT_NotifyConnect |
diff --git a/src/testing/testing.c b/src/testing/testing.c index d12892fcc..3bc6c98da 100644 --- a/src/testing/testing.c +++ b/src/testing/testing.c | |||
@@ -161,7 +161,9 @@ testing_init (void *cls, | |||
161 | 161 | ||
162 | 162 | ||
163 | d->th = GNUNET_TRANSPORT_connect (d->sched, | 163 | d->th = GNUNET_TRANSPORT_connect (d->sched, |
164 | d->cfg, d, NULL, NULL, NULL); | 164 | d->cfg, |
165 | &d->id, | ||
166 | d, NULL, NULL, NULL); | ||
165 | if (d->th == NULL) | 167 | if (d->th == NULL) |
166 | { | 168 | { |
167 | if (GNUNET_YES == d->dead) | 169 | if (GNUNET_YES == d->dead) |
@@ -1402,7 +1404,9 @@ GNUNET_TESTING_daemons_connect (struct GNUNET_TESTING_Daemon *d1, | |||
1402 | #endif | 1404 | #endif |
1403 | 1405 | ||
1404 | ctx->d2th = GNUNET_TRANSPORT_connect (d2->sched, | 1406 | ctx->d2th = GNUNET_TRANSPORT_connect (d2->sched, |
1405 | d2->cfg, d2, NULL, NULL, NULL); | 1407 | d2->cfg, |
1408 | &d2->id, | ||
1409 | d2, NULL, NULL, NULL); | ||
1406 | if (ctx->d2th == NULL) | 1410 | if (ctx->d2th == NULL) |
1407 | { | 1411 | { |
1408 | GNUNET_CORE_disconnect(ctx->d1core); | 1412 | GNUNET_CORE_disconnect(ctx->d1core); |
@@ -1455,7 +1459,9 @@ reattempt_daemons_connect (void *cls, const struct GNUNET_SCHEDULER_TaskContext | |||
1455 | } | 1459 | } |
1456 | 1460 | ||
1457 | ctx->d2th = GNUNET_TRANSPORT_connect (ctx->d2->sched, | 1461 | ctx->d2th = GNUNET_TRANSPORT_connect (ctx->d2->sched, |
1458 | ctx->d2->cfg, ctx->d2, NULL, NULL, NULL); | 1462 | ctx->d2->cfg, |
1463 | &ctx->d2->id, | ||
1464 | ctx->d2, NULL, NULL, NULL); | ||
1459 | if (ctx->d2th == NULL) | 1465 | if (ctx->d2th == NULL) |
1460 | { | 1466 | { |
1461 | GNUNET_CORE_disconnect(ctx->d1core); | 1467 | GNUNET_CORE_disconnect(ctx->d1core); |
diff --git a/src/topology/gnunet-daemon-topology.c b/src/topology/gnunet-daemon-topology.c index d39c89d36..3686f2018 100644 --- a/src/topology/gnunet-daemon-topology.c +++ b/src/topology/gnunet-daemon-topology.c | |||
@@ -1395,6 +1395,7 @@ run (void *cls, | |||
1395 | NULL, | 1395 | NULL, |
1396 | NULL, | 1396 | NULL, |
1397 | NULL, | 1397 | NULL, |
1398 | NULL, | ||
1398 | NULL); | 1399 | NULL); |
1399 | handle = GNUNET_CORE_connect (sched, | 1400 | handle = GNUNET_CORE_connect (sched, |
1400 | cfg, | 1401 | cfg, |
diff --git a/src/transport/gnunet-service-transport.c b/src/transport/gnunet-service-transport.c index 0d33ac5ca..c1dc60fd0 100644 --- a/src/transport/gnunet-service-transport.c +++ b/src/transport/gnunet-service-transport.c | |||
@@ -4673,10 +4673,12 @@ handle_start (void *cls, | |||
4673 | struct GNUNET_SERVER_Client *client, | 4673 | struct GNUNET_SERVER_Client *client, |
4674 | const struct GNUNET_MessageHeader *message) | 4674 | const struct GNUNET_MessageHeader *message) |
4675 | { | 4675 | { |
4676 | const struct StartMessage *start; | ||
4676 | struct TransportClient *c; | 4677 | struct TransportClient *c; |
4677 | struct ConnectInfoMessage cim; | 4678 | struct ConnectInfoMessage cim; |
4678 | struct NeighbourList *n; | 4679 | struct NeighbourList *n; |
4679 | 4680 | ||
4681 | start = (const struct StartMessage*) message; | ||
4680 | #if DEBUG_TRANSPORT | 4682 | #if DEBUG_TRANSPORT |
4681 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 4683 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
4682 | "Received `%s' request from client\n", "START"); | 4684 | "Received `%s' request from client\n", "START"); |
@@ -4693,6 +4695,17 @@ handle_start (void *cls, | |||
4693 | } | 4695 | } |
4694 | c = c->next; | 4696 | c = c->next; |
4695 | } | 4697 | } |
4698 | if ( (GNUNET_NO != ntohl (start->do_check)) && | ||
4699 | (0 != memcmp (&start->self, | ||
4700 | &my_identity, | ||
4701 | sizeof (struct GNUNET_PeerIdentity))) ) | ||
4702 | { | ||
4703 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
4704 | _("Rejecting control connection from peer `%s', which is not me!\n"), | ||
4705 | GNUNET_i2s (&start->self)); | ||
4706 | GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); | ||
4707 | return; | ||
4708 | } | ||
4696 | c = GNUNET_malloc (sizeof (struct TransportClient)); | 4709 | c = GNUNET_malloc (sizeof (struct TransportClient)); |
4697 | c->next = clients; | 4710 | c->next = clients; |
4698 | clients = c; | 4711 | clients = c; |
@@ -5239,7 +5252,7 @@ run (void *cls, | |||
5239 | { | 5252 | { |
5240 | static const struct GNUNET_SERVER_MessageHandler handlers[] = { | 5253 | static const struct GNUNET_SERVER_MessageHandler handlers[] = { |
5241 | {&handle_start, NULL, | 5254 | {&handle_start, NULL, |
5242 | GNUNET_MESSAGE_TYPE_TRANSPORT_START, 0}, | 5255 | GNUNET_MESSAGE_TYPE_TRANSPORT_START, sizeof (struct StartMessage)}, |
5243 | {&handle_hello, NULL, | 5256 | {&handle_hello, NULL, |
5244 | GNUNET_MESSAGE_TYPE_HELLO, 0}, | 5257 | GNUNET_MESSAGE_TYPE_HELLO, 0}, |
5245 | {&handle_send, NULL, | 5258 | {&handle_send, NULL, |
diff --git a/src/transport/test_transport_api.c b/src/transport/test_transport_api.c index 52b9282de..7aa81bff8 100644 --- a/src/transport/test_transport_api.c +++ b/src/transport/test_transport_api.c | |||
@@ -220,7 +220,7 @@ setup_peer (struct PeerContext *p, const char *cfgname) | |||
220 | GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname)); | 220 | GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname)); |
221 | 221 | ||
222 | p->th = GNUNET_TRANSPORT_connect (sched, p->cfg, | 222 | p->th = GNUNET_TRANSPORT_connect (sched, p->cfg, |
223 | p, | 223 | NULL, p, |
224 | ¬ify_receive, | 224 | ¬ify_receive, |
225 | ¬ify_connect, ¬ify_disconnect); | 225 | ¬ify_connect, ¬ify_disconnect); |
226 | GNUNET_assert (p->th != NULL); | 226 | GNUNET_assert (p->th != NULL); |
diff --git a/src/transport/test_transport_api_reliability.c b/src/transport/test_transport_api_reliability.c index dc4867f84..c86b582b9 100644 --- a/src/transport/test_transport_api_reliability.c +++ b/src/transport/test_transport_api_reliability.c | |||
@@ -366,7 +366,7 @@ setup_peer (struct PeerContext *p, const char *cfgname) | |||
366 | "-c", cfgname, NULL); | 366 | "-c", cfgname, NULL); |
367 | #endif | 367 | #endif |
368 | GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname)); | 368 | GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname)); |
369 | p->th = GNUNET_TRANSPORT_connect (sched, p->cfg, | 369 | p->th = GNUNET_TRANSPORT_connect (sched, p->cfg, NULL, |
370 | p, | 370 | p, |
371 | ¬ify_receive, | 371 | ¬ify_receive, |
372 | ¬ify_connect, | 372 | ¬ify_connect, |
diff --git a/src/transport/transport.h b/src/transport/transport.h index 0f2d5c6c9..aa934c944 100644 --- a/src/transport/transport.h +++ b/src/transport/transport.h | |||
@@ -48,6 +48,33 @@ | |||
48 | 48 | ||
49 | /** | 49 | /** |
50 | * Message from the transport service to the library | 50 | * Message from the transport service to the library |
51 | * asking to check if both processes agree about this | ||
52 | * peers identity. | ||
53 | */ | ||
54 | struct StartMessage | ||
55 | { | ||
56 | |||
57 | /** | ||
58 | * Type will be GNUNET_MESSAGE_TYPE_TRANSPORT_START | ||
59 | */ | ||
60 | struct GNUNET_MessageHeader header; | ||
61 | |||
62 | /** | ||
63 | * Should the 'self' field be checked? | ||
64 | */ | ||
65 | uint32_t do_check; | ||
66 | |||
67 | /** | ||
68 | * Identity we think we have. If it does not match, the | ||
69 | * receiver should print out an error message and disconnect. | ||
70 | */ | ||
71 | struct GNUNET_PeerIdentity self; | ||
72 | |||
73 | }; | ||
74 | |||
75 | |||
76 | /** | ||
77 | * Message from the transport service to the library | ||
51 | * informing about neighbors. | 78 | * informing about neighbors. |
52 | */ | 79 | */ |
53 | struct ConnectInfoMessage | 80 | struct ConnectInfoMessage |
diff --git a/src/transport/transport_api.c b/src/transport/transport_api.c index eb8868d98..db96d1800 100644 --- a/src/transport/transport_api.c +++ b/src/transport/transport_api.c | |||
@@ -278,7 +278,7 @@ struct GNUNET_TRANSPORT_Handle | |||
278 | /** | 278 | /** |
279 | * Closure for the callbacks. | 279 | * Closure for the callbacks. |
280 | */ | 280 | */ |
281 | void *cls; | 281 | void *cls; |
282 | 282 | ||
283 | /** | 283 | /** |
284 | * Function to call for received data. | 284 | * Function to call for received data. |
@@ -342,6 +342,11 @@ struct GNUNET_TRANSPORT_Handle | |||
342 | struct NeighbourList *neighbours; | 342 | struct NeighbourList *neighbours; |
343 | 343 | ||
344 | /** | 344 | /** |
345 | * Peer identity as assumed by this process, or all zeros. | ||
346 | */ | ||
347 | struct GNUNET_PeerIdentity self; | ||
348 | |||
349 | /** | ||
345 | * ID of the task trying to reconnect to the service. | 350 | * ID of the task trying to reconnect to the service. |
346 | */ | 351 | */ |
347 | GNUNET_SCHEDULER_TaskIdentifier reconnect_task; | 352 | GNUNET_SCHEDULER_TaskIdentifier reconnect_task; |
@@ -363,6 +368,11 @@ struct GNUNET_TRANSPORT_Handle | |||
363 | */ | 368 | */ |
364 | int in_disconnect; | 369 | int in_disconnect; |
365 | 370 | ||
371 | /** | ||
372 | * Should we check that 'self' matches what the service thinks? | ||
373 | * (if GNUNET_NO, then 'self' is all zeros!). | ||
374 | */ | ||
375 | int check_self; | ||
366 | }; | 376 | }; |
367 | 377 | ||
368 | 378 | ||
@@ -1038,7 +1048,8 @@ GNUNET_TRANSPORT_offer_hello (struct GNUNET_TRANSPORT_Handle *handle, | |||
1038 | static size_t | 1048 | static size_t |
1039 | send_start (void *cls, size_t size, void *buf) | 1049 | send_start (void *cls, size_t size, void *buf) |
1040 | { | 1050 | { |
1041 | struct GNUNET_MessageHeader *s = buf; | 1051 | struct GNUNET_TRANSPORT_Handle *h = cls; |
1052 | struct StartMessage s; | ||
1042 | 1053 | ||
1043 | if (buf == NULL) | 1054 | if (buf == NULL) |
1044 | { | 1055 | { |
@@ -1054,10 +1065,13 @@ send_start (void *cls, size_t size, void *buf) | |||
1054 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1065 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1055 | "Transmitting `%s' request.\n", "START"); | 1066 | "Transmitting `%s' request.\n", "START"); |
1056 | #endif | 1067 | #endif |
1057 | GNUNET_assert (size >= sizeof (struct GNUNET_MessageHeader)); | 1068 | GNUNET_assert (size >= sizeof (struct StartMessage)); |
1058 | s->size = htons (sizeof (struct GNUNET_MessageHeader)); | 1069 | s.header.size = htons (sizeof (struct StartMessage)); |
1059 | s->type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_START); | 1070 | s.header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_START); |
1060 | return sizeof (struct GNUNET_MessageHeader); | 1071 | s.do_check = htonl (h->check_self); |
1072 | s.self = h->self; | ||
1073 | memcpy (buf, &s, sizeof (struct StartMessage)); | ||
1074 | return sizeof (struct StartMessage); | ||
1061 | } | 1075 | } |
1062 | 1076 | ||
1063 | 1077 | ||
@@ -1192,9 +1206,9 @@ reconnect (void *cls, | |||
1192 | pos = pos->next; | 1206 | pos = pos->next; |
1193 | } | 1207 | } |
1194 | schedule_control_transmit (h, | 1208 | schedule_control_transmit (h, |
1195 | sizeof (struct GNUNET_MessageHeader), | 1209 | sizeof (struct StartMessage), |
1196 | GNUNET_YES, | 1210 | GNUNET_YES, |
1197 | GNUNET_TIME_UNIT_FOREVER_REL, &send_start, NULL); | 1211 | GNUNET_TIME_UNIT_FOREVER_REL, &send_start, h); |
1198 | GNUNET_CLIENT_receive (h->client, | 1212 | GNUNET_CLIENT_receive (h->client, |
1199 | &demultiplexer, h, GNUNET_TIME_UNIT_FOREVER_REL); | 1213 | &demultiplexer, h, GNUNET_TIME_UNIT_FOREVER_REL); |
1200 | } | 1214 | } |
@@ -1274,6 +1288,8 @@ neighbour_add (struct GNUNET_TRANSPORT_Handle *h, | |||
1274 | * | 1288 | * |
1275 | * @param sched scheduler to use | 1289 | * @param sched scheduler to use |
1276 | * @param cfg configuration to use | 1290 | * @param cfg configuration to use |
1291 | * @param self our own identity (API should check that it matches | ||
1292 | * the identity found by transport), or NULL (no check) | ||
1277 | * @param cls closure for the callbacks | 1293 | * @param cls closure for the callbacks |
1278 | * @param rec receive function to call | 1294 | * @param rec receive function to call |
1279 | * @param nc function to call on connect events | 1295 | * @param nc function to call on connect events |
@@ -1282,6 +1298,7 @@ neighbour_add (struct GNUNET_TRANSPORT_Handle *h, | |||
1282 | struct GNUNET_TRANSPORT_Handle * | 1298 | struct GNUNET_TRANSPORT_Handle * |
1283 | GNUNET_TRANSPORT_connect (struct GNUNET_SCHEDULER_Handle *sched, | 1299 | GNUNET_TRANSPORT_connect (struct GNUNET_SCHEDULER_Handle *sched, |
1284 | const struct GNUNET_CONFIGURATION_Handle *cfg, | 1300 | const struct GNUNET_CONFIGURATION_Handle *cfg, |
1301 | const struct GNUNET_PeerIdentity *self, | ||
1285 | void *cls, | 1302 | void *cls, |
1286 | GNUNET_TRANSPORT_ReceiveCallback rec, | 1303 | GNUNET_TRANSPORT_ReceiveCallback rec, |
1287 | GNUNET_TRANSPORT_NotifyConnect nc, | 1304 | GNUNET_TRANSPORT_NotifyConnect nc, |
@@ -1290,6 +1307,11 @@ GNUNET_TRANSPORT_connect (struct GNUNET_SCHEDULER_Handle *sched, | |||
1290 | struct GNUNET_TRANSPORT_Handle *ret; | 1307 | struct GNUNET_TRANSPORT_Handle *ret; |
1291 | 1308 | ||
1292 | ret = GNUNET_malloc (sizeof (struct GNUNET_TRANSPORT_Handle)); | 1309 | ret = GNUNET_malloc (sizeof (struct GNUNET_TRANSPORT_Handle)); |
1310 | if (self != NULL) | ||
1311 | { | ||
1312 | ret->self = *self; | ||
1313 | ret->check_self = GNUNET_YES; | ||
1314 | } | ||
1293 | ret->sched = sched; | 1315 | ret->sched = sched; |
1294 | ret->cfg = cfg; | 1316 | ret->cfg = cfg; |
1295 | ret->cls = cls; | 1317 | ret->cls = cls; |