aboutsummaryrefslogtreecommitdiff
path: root/src/transport
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2011-08-15 21:54:06 +0000
committerChristian Grothoff <christian@grothoff.org>2011-08-15 21:54:06 +0000
commit5746309cb4be2073d550ad7a6885e918631dbc38 (patch)
tree89455bc4aadf977816b38df13f990372cd81d71a /src/transport
parent6fd3e715cae09fa6e657c96f1c6f9711ee51f42f (diff)
downloadgnunet-5746309cb4be2073d550ad7a6885e918631dbc38.tar.gz
gnunet-5746309cb4be2073d550ad7a6885e918631dbc38.zip
indentation
Diffstat (limited to 'src/transport')
-rw-r--r--src/transport/gnunet-service-transport-new.c102
-rw-r--r--src/transport/gnunet-service-transport.c900
-rw-r--r--src/transport/gnunet-service-transport_ats.c176
-rw-r--r--src/transport/gnunet-service-transport_blacklist.c64
-rw-r--r--src/transport/gnunet-service-transport_clients.c117
-rw-r--r--src/transport/gnunet-service-transport_hello.c31
-rw-r--r--src/transport/gnunet-service-transport_neighbours.c88
-rw-r--r--src/transport/gnunet-service-transport_plugins.c15
-rw-r--r--src/transport/gnunet-service-transport_validation.c147
-rw-r--r--src/transport/gnunet-transport-certificate-creation.c17
-rw-r--r--src/transport/gnunet-transport-list-connections.c12
-rw-r--r--src/transport/gnunet-transport-wlan-helper.c66
-rw-r--r--src/transport/perf_transport_ats.c7
-rw-r--r--src/transport/plugin_transport_http.c476
-rw-r--r--src/transport/plugin_transport_smtp.c151
-rw-r--r--src/transport/plugin_transport_tcp.c398
-rw-r--r--src/transport/plugin_transport_template.c20
-rw-r--r--src/transport/plugin_transport_udp.c216
-rw-r--r--src/transport/plugin_transport_unix.c103
-rw-r--r--src/transport/plugin_transport_wlan.c289
-rw-r--r--src/transport/test_plugin_transport.c42
-rw-r--r--src/transport/test_plugin_transport_http.c160
-rw-r--r--src/transport/test_plugin_transport_https.c67
-rw-r--r--src/transport/test_plugin_transport_udp.c39
-rw-r--r--src/transport/test_plugin_transport_wlan_dummy.c22
-rw-r--r--src/transport/test_quota_compliance.c88
-rw-r--r--src/transport/test_transport_api.c51
-rw-r--r--src/transport/test_transport_api_disconnect.c65
-rw-r--r--src/transport/test_transport_api_multiaddress.c47
-rw-r--r--src/transport/test_transport_api_reliability.c79
-rw-r--r--src/transport/test_transport_api_unreliability.c88
-rw-r--r--src/transport/test_transport_ats.c29
-rw-r--r--src/transport/test_transport_ats_multiple_peers.c158
-rw-r--r--src/transport/test_transport_testing.c26
-rw-r--r--src/transport/transport-testing.c51
-rw-r--r--src/transport/transport_api.c85
-rw-r--r--src/transport/transport_api_address_iterate.c9
-rw-r--r--src/transport/transport_api_address_lookup.c15
-rw-r--r--src/transport/transport_api_blacklist.c40
-rw-r--r--src/transport/transport_api_peer_address_lookup.c9
-rw-r--r--src/transport/wlan/radiotap-parser.c17
41 files changed, 1999 insertions, 2583 deletions
diff --git a/src/transport/gnunet-service-transport-new.c b/src/transport/gnunet-service-transport-new.c
index 8ceffd86c..6c2b396dc 100644
--- a/src/transport/gnunet-service-transport-new.c
+++ b/src/transport/gnunet-service-transport-new.c
@@ -85,16 +85,13 @@ struct GNUNET_ATS_Handle *GST_ats;
85 * @param ats_count number of records in ats (unused) 85 * @param ats_count number of records in ats (unused)
86 */ 86 */
87static void 87static void
88transmit_our_hello (void *cls, 88transmit_our_hello (void *cls, const struct GNUNET_PeerIdentity *target,
89 const struct GNUNET_PeerIdentity *target,
90 const struct GNUNET_TRANSPORT_ATS_Information *ats, 89 const struct GNUNET_TRANSPORT_ATS_Information *ats,
91 uint32_t ats_count) 90 uint32_t ats_count)
92{ 91{
93 const struct GNUNET_MessageHeader *hello = cls; 92 const struct GNUNET_MessageHeader *hello = cls;
94 93
95 GST_neighbours_send (target, 94 GST_neighbours_send (target, (const char *) hello, ntohs (hello->size),
96 (const char *) hello,
97 ntohs (hello->size),
98 GST_HELLO_ADDRESS_EXPIRATION, NULL, NULL); 95 GST_HELLO_ADDRESS_EXPIRATION, NULL, NULL);
99} 96}
100 97
@@ -123,8 +120,8 @@ process_hello_update (void *cls, const struct GNUNET_MessageHeader *hello)
123 * GNUNET_NO if not 120 * GNUNET_NO if not
124 */ 121 */
125static void 122static void
126try_connect_if_allowed (void *cls, 123try_connect_if_allowed (void *cls, const struct GNUNET_PeerIdentity *peer,
127 const struct GNUNET_PeerIdentity *peer, int result) 124 int result)
128{ 125{
129 if (GNUNET_OK != result) 126 if (GNUNET_OK != result)
130 return; /* not allowed */ 127 return; /* not allowed */
@@ -156,8 +153,7 @@ try_connect_if_allowed (void *cls,
156 * (plugins that do not support this, can ignore the return value) 153 * (plugins that do not support this, can ignore the return value)
157 */ 154 */
158static struct GNUNET_TIME_Relative 155static struct GNUNET_TIME_Relative
159plugin_env_receive_callback (void *cls, 156plugin_env_receive_callback (void *cls, const struct GNUNET_PeerIdentity *peer,
160 const struct GNUNET_PeerIdentity *peer,
161 const struct GNUNET_MessageHeader *message, 157 const struct GNUNET_MessageHeader *message,
162 const struct GNUNET_TRANSPORT_ATS_Information *ats, 158 const struct GNUNET_TRANSPORT_ATS_Information *ats,
163 uint32_t ats_count, struct Session *session, 159 uint32_t ats_count, struct Session *session,
@@ -182,33 +178,29 @@ plugin_env_receive_callback (void *cls,
182 case GNUNET_MESSAGE_TYPE_TRANSPORT_PING: 178 case GNUNET_MESSAGE_TYPE_TRANSPORT_PING:
183#if DEBUG_TRANSPORT 179#if DEBUG_TRANSPORT
184 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG | GNUNET_ERROR_TYPE_BULK, 180 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG | GNUNET_ERROR_TYPE_BULK,
185 "Processing `%s' from `%s'\n", 181 "Processing `%s' from `%s'\n", "PING",
186 "PING", 182 (sender_address != NULL) ? GST_plugins_a2s (plugin_name,
187 (sender_address != NULL) 183 sender_address,
188 ? GST_plugins_a2s (plugin_name, 184 sender_address_len)
189 sender_address, 185 : "<inbound>");
190 sender_address_len) : "<inbound>");
191#endif 186#endif
192 GST_validation_handle_ping (peer, 187 GST_validation_handle_ping (peer, message, plugin_name, session,
193 message, 188 sender_address, sender_address_len);
194 plugin_name,
195 session, sender_address, sender_address_len);
196 break; 189 break;
197 case GNUNET_MESSAGE_TYPE_TRANSPORT_PONG: 190 case GNUNET_MESSAGE_TYPE_TRANSPORT_PONG:
198#if DEBUG_TRANSPORT 191#if DEBUG_TRANSPORT
199 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG | GNUNET_ERROR_TYPE_BULK, 192 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG | GNUNET_ERROR_TYPE_BULK,
200 "Processing `%s' from `%s'\n", 193 "Processing `%s' from `%s'\n", "PONG",
201 "PONG", 194 (sender_address != NULL) ? GST_plugins_a2s (plugin_name,
202 (sender_address != NULL) 195 sender_address,
203 ? GST_plugins_a2s (plugin_name, 196 sender_address_len)
204 sender_address, 197 : "<inbound>");
205 sender_address_len) : "<inbound>");
206#endif 198#endif
207 GST_validation_handle_pong (peer, message); 199 GST_validation_handle_pong (peer, message);
208 break; 200 break;
209 case GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_CONNECT: 201 case GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_CONNECT:
210 (void) GST_blacklist_test_allowed (peer, 202 (void) GST_blacklist_test_allowed (peer, NULL, &try_connect_if_allowed,
211 NULL, &try_connect_if_allowed, NULL); 203 NULL);
212 /* TODO: if 'session != NULL', maybe notify ATS that this is now the preferred 204 /* TODO: if 'session != NULL', maybe notify ATS that this is now the preferred
213 * way to communicate with this peer (other peer switched transport) */ 205 * way to communicate with this peer (other peer switched transport) */
214 break; 206 break;
@@ -223,20 +215,19 @@ plugin_env_receive_callback (void *cls,
223 default: 215 default:
224 /* should be payload */ 216 /* should be payload */
225 do_forward = GNUNET_SYSERR; 217 do_forward = GNUNET_SYSERR;
226 ret = GST_neighbours_calculate_receive_delay (peer, 218 ret =
227 (message == NULL) 219 GST_neighbours_calculate_receive_delay (peer,
228 ? 0 220 (message ==
229 : ntohs (message->size), 221 NULL) ? 0 : ntohs (message->
230 &do_forward); 222 size),
223 &do_forward);
231 if (do_forward == GNUNET_YES) 224 if (do_forward == GNUNET_YES)
232 GST_clients_broadcast (message, GNUNET_YES); 225 GST_clients_broadcast (message, GNUNET_YES);
233 break; 226 break;
234 } 227 }
235 } 228 }
236 GNUNET_ATS_address_update (GST_ats, peer, GNUNET_TIME_absolute_get (), /* valid at least until right now... */ 229 GNUNET_ATS_address_update (GST_ats, peer, GNUNET_TIME_absolute_get (), /* valid at least until right now... */
237 plugin_name, 230 plugin_name, session, sender_address,
238 session,
239 sender_address,
240 sender_address_len, ats, ats_count); 231 sender_address_len, ats, ats_count);
241 232
242 return ret; 233 return ret;
@@ -255,8 +246,7 @@ plugin_env_receive_callback (void *cls,
255 * @param addrlen length of the address 246 * @param addrlen length of the address
256 */ 247 */
257static void 248static void
258plugin_env_address_change_notification (void *cls, 249plugin_env_address_change_notification (void *cls, int add_remove,
259 int add_remove,
260 const void *addr, size_t addrlen) 250 const void *addr, size_t addrlen)
261{ 251{
262 const char *plugin_name = cls; 252 const char *plugin_name = cls;
@@ -279,8 +269,7 @@ plugin_env_address_change_notification (void *cls,
279 * @param session which session is being destoyed 269 * @param session which session is being destoyed
280 */ 270 */
281static void 271static void
282plugin_env_session_end (void *cls, 272plugin_env_session_end (void *cls, const struct GNUNET_PeerIdentity *peer,
283 const struct GNUNET_PeerIdentity *peer,
284 struct Session *session) 273 struct Session *session)
285{ 274{
286 GST_neighbours_session_terminated (peer, session); 275 GST_neighbours_session_terminated (peer, session);
@@ -303,17 +292,12 @@ plugin_env_session_end (void *cls,
303 * @param bandwidth assigned outbound bandwidth for the connection 292 * @param bandwidth assigned outbound bandwidth for the connection
304 */ 293 */
305static void 294static void
306ats_request_address_change (void *cls, 295ats_request_address_change (void *cls, const struct GNUNET_PeerIdentity *peer,
307 const struct GNUNET_PeerIdentity *peer, 296 const char *plugin_name, struct Session *session,
308 const char *plugin_name, 297 const void *plugin_addr, size_t plugin_addr_len,
309 struct Session *session,
310 const void *plugin_addr,
311 size_t plugin_addr_len,
312 struct GNUNET_BANDWIDTH_Value32NBO bandwidth) 298 struct GNUNET_BANDWIDTH_Value32NBO bandwidth)
313{ 299{
314 GST_neighbours_switch_to_address (peer, 300 GST_neighbours_switch_to_address (peer, plugin_name, plugin_addr,
315 plugin_name,
316 plugin_addr,
317 plugin_addr_len, session, NULL, 0); 301 plugin_addr_len, session, NULL, 0);
318 GST_neighbours_set_incoming_quota (peer, bandwidth); 302 GST_neighbours_set_incoming_quota (peer, bandwidth);
319} 303}
@@ -417,8 +401,7 @@ shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
417 * @param c configuration to use 401 * @param c configuration to use
418 */ 402 */
419static void 403static void
420run (void *cls, 404run (void *cls, struct GNUNET_SERVER_Handle *server,
421 struct GNUNET_SERVER_Handle *server,
422 const struct GNUNET_CONFIGURATION_Handle *c) 405 const struct GNUNET_CONFIGURATION_Handle *c)
423{ 406{
424 char *keyfile; 407 char *keyfile;
@@ -426,8 +409,8 @@ run (void *cls,
426 /* setup globals */ 409 /* setup globals */
427 GST_cfg = c; 410 GST_cfg = c;
428 if (GNUNET_OK != 411 if (GNUNET_OK !=
429 GNUNET_CONFIGURATION_get_value_filename (c, 412 GNUNET_CONFIGURATION_get_value_filename (c, "GNUNETD", "HOSTKEY",
430 "GNUNETD", "HOSTKEY", &keyfile)) 413 &keyfile))
431 { 414 {
432 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 415 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
433 _ 416 _
@@ -447,10 +430,10 @@ run (void *cls,
447 GST_stats = GNUNET_STATISTICS_create ("transport", c); 430 GST_stats = GNUNET_STATISTICS_create ("transport", c);
448 GST_peerinfo = GNUNET_PEERINFO_connect (c); 431 GST_peerinfo = GNUNET_PEERINFO_connect (c);
449 GNUNET_CRYPTO_rsa_key_get_public (GST_my_private_key, &GST_my_public_key); 432 GNUNET_CRYPTO_rsa_key_get_public (GST_my_private_key, &GST_my_public_key);
450 GNUNET_CRYPTO_hash (&GST_my_public_key, 433 GNUNET_CRYPTO_hash (&GST_my_public_key, sizeof (GST_my_public_key),
451 sizeof (GST_my_public_key), &GST_my_identity.hashPubKey); 434 &GST_my_identity.hashPubKey);
452 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, 435 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, &shutdown_task,
453 &shutdown_task, NULL); 436 NULL);
454 if (GST_peerinfo == NULL) 437 if (GST_peerinfo == NULL)
455 { 438 {
456 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 439 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
@@ -466,8 +449,7 @@ run (void *cls,
466 &plugin_env_address_change_notification, 449 &plugin_env_address_change_notification,
467 &plugin_env_session_end); 450 &plugin_env_session_end);
468 GST_ats = GNUNET_ATS_init (GST_cfg, &ats_request_address_change, NULL); 451 GST_ats = GNUNET_ATS_init (GST_cfg, &ats_request_address_change, NULL);
469 GST_neighbours_start (NULL, 452 GST_neighbours_start (NULL, &neighbours_connect_notification,
470 &neighbours_connect_notification,
471 &neighbours_disconnect_notification); 453 &neighbours_disconnect_notification);
472 GST_clients_start (server); 454 GST_clients_start (server);
473 GST_validation_start (); 455 GST_validation_start ();
@@ -485,9 +467,7 @@ int
485main (int argc, char *const *argv) 467main (int argc, char *const *argv)
486{ 468{
487 return (GNUNET_OK == 469 return (GNUNET_OK ==
488 GNUNET_SERVICE_run (argc, 470 GNUNET_SERVICE_run (argc, argv, "transport",
489 argv,
490 "transport",
491 GNUNET_SERVICE_OPTION_NONE, &run, NULL)) ? 0 : 1; 471 GNUNET_SERVICE_OPTION_NONE, &run, NULL)) ? 0 : 1;
492} 472}
493 473
diff --git a/src/transport/gnunet-service-transport.c b/src/transport/gnunet-service-transport.c
index 4f962d117..5b0a58fac 100644
--- a/src/transport/gnunet-service-transport.c
+++ b/src/transport/gnunet-service-transport.c
@@ -1065,8 +1065,7 @@ is_blacklisted (const struct GNUNET_PeerIdentity *peer,
1065 (plugin->blacklist, &peer->hashPubKey) == GNUNET_YES) 1065 (plugin->blacklist, &peer->hashPubKey) == GNUNET_YES)
1066 { 1066 {
1067#if DEBUG_BLACKLIST 1067#if DEBUG_BLACKLIST
1068 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1068 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer `%s:%s' is blacklisted!\n",
1069 "Peer `%s:%s' is blacklisted!\n",
1070 plugin->short_name, GNUNET_i2s (peer)); 1069 plugin->short_name, GNUNET_i2s (peer));
1071#endif 1070#endif
1072 if (stats != NULL) 1071 if (stats != NULL)
@@ -1097,8 +1096,7 @@ add_peer_to_blacklist (struct GNUNET_PeerIdentity *peer, char *transport_name)
1097 plugin->blacklist = 1096 plugin->blacklist =
1098 GNUNET_CONTAINER_multihashmap_create (TRANSPORT_BLACKLIST_HT_SIZE); 1097 GNUNET_CONTAINER_multihashmap_create (TRANSPORT_BLACKLIST_HT_SIZE);
1099 GNUNET_assert (plugin->blacklist != NULL); 1098 GNUNET_assert (plugin->blacklist != NULL);
1100 GNUNET_CONTAINER_multihashmap_put (plugin->blacklist, &peer->hashPubKey, 1099 GNUNET_CONTAINER_multihashmap_put (plugin->blacklist, &peer->hashPubKey, NULL,
1101 NULL,
1102 GNUNET_CONTAINER_MULTIHASHMAPOPTION_REPLACE); 1100 GNUNET_CONTAINER_MULTIHASHMAPOPTION_REPLACE);
1103} 1101}
1104 1102
@@ -1124,8 +1122,7 @@ read_blacklist_file (const struct GNUNET_CONFIGURATION_Handle *cfg)
1124 char *transport_name; 1122 char *transport_name;
1125 1123
1126 if (GNUNET_OK != 1124 if (GNUNET_OK !=
1127 GNUNET_CONFIGURATION_get_value_filename (cfg, 1125 GNUNET_CONFIGURATION_get_value_filename (cfg, "TRANSPORT",
1128 "TRANSPORT",
1129 "BLACKLIST_FILE", &fn)) 1126 "BLACKLIST_FILE", &fn))
1130 { 1127 {
1131#if DEBUG_TRANSPORT 1128#if DEBUG_TRANSPORT
@@ -1136,8 +1133,9 @@ read_blacklist_file (const struct GNUNET_CONFIGURATION_Handle *cfg)
1136 return; 1133 return;
1137 } 1134 }
1138 if (GNUNET_OK != GNUNET_DISK_file_test (fn)) 1135 if (GNUNET_OK != GNUNET_DISK_file_test (fn))
1139 GNUNET_DISK_fn_write (fn, NULL, 0, GNUNET_DISK_PERM_USER_READ 1136 GNUNET_DISK_fn_write (fn, NULL, 0,
1140 | GNUNET_DISK_PERM_USER_WRITE); 1137 GNUNET_DISK_PERM_USER_READ |
1138 GNUNET_DISK_PERM_USER_WRITE);
1141 if (0 != STAT (fn, &frstat)) 1139 if (0 != STAT (fn, &frstat))
1142 { 1140 {
1143 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 1141 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
@@ -1148,8 +1146,8 @@ read_blacklist_file (const struct GNUNET_CONFIGURATION_Handle *cfg)
1148 if (frstat.st_size == 0) 1146 if (frstat.st_size == 0)
1149 { 1147 {
1150#if DEBUG_TRANSPORT 1148#if DEBUG_TRANSPORT
1151 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1149 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, _("Blacklist file `%s' is empty.\n"),
1152 _("Blacklist file `%s' is empty.\n"), fn); 1150 fn);
1153#endif 1151#endif
1154 GNUNET_free (fn); 1152 GNUNET_free (fn);
1155 return; 1153 return;
@@ -1225,8 +1223,8 @@ read_blacklist_file (const struct GNUNET_CONFIGURATION_Handle *cfg)
1225#endif 1223#endif
1226 memcpy (&enc, &data[pos], sizeof (struct GNUNET_CRYPTO_HashAsciiEncoded)); 1224 memcpy (&enc, &data[pos], sizeof (struct GNUNET_CRYPTO_HashAsciiEncoded));
1227 if (!isspace 1225 if (!isspace
1228 ((unsigned char) 1226 ((unsigned char) enc.
1229 enc.encoding[sizeof (struct GNUNET_CRYPTO_HashAsciiEncoded) - 1])) 1227 encoding[sizeof (struct GNUNET_CRYPTO_HashAsciiEncoded) - 1]))
1230 { 1228 {
1231 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 1229 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
1232 _ 1230 _
@@ -1338,11 +1336,11 @@ transmit_to_client_callback (void *cls, size_t size, void *buf)
1338 if (NULL != q) 1336 if (NULL != q)
1339 { 1337 {
1340 GNUNET_assert (msize >= sizeof (struct GNUNET_MessageHeader)); 1338 GNUNET_assert (msize >= sizeof (struct GNUNET_MessageHeader));
1341 client->th = GNUNET_SERVER_notify_transmit_ready (client->client, 1339 client->th =
1342 msize, 1340 GNUNET_SERVER_notify_transmit_ready (client->client, msize,
1343 GNUNET_TIME_UNIT_FOREVER_REL, 1341 GNUNET_TIME_UNIT_FOREVER_REL,
1344 &transmit_to_client_callback, 1342 &transmit_to_client_callback,
1345 client); 1343 client);
1346 GNUNET_assert (client->th != NULL); 1344 GNUNET_assert (client->th != NULL);
1347 } 1345 }
1348 return tsize; 1346 return tsize;
@@ -1419,11 +1417,10 @@ timeout_hello_validation (void *cls,
1419 1417
1420 va->timeout_task = GNUNET_SCHEDULER_NO_TASK; 1418 va->timeout_task = GNUNET_SCHEDULER_NO_TASK;
1421 GNUNET_STATISTICS_update (stats, 1419 GNUNET_STATISTICS_update (stats,
1422 gettext_noop ("# address validation timeouts"), 1420 gettext_noop ("# address validation timeouts"), 1,
1423 1, GNUNET_NO); 1421 GNUNET_NO);
1424 GNUNET_CRYPTO_hash (&va->publicKey, 1422 GNUNET_CRYPTO_hash (&va->publicKey,
1425 sizeof (struct 1423 sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded),
1426 GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded),
1427 &pid.hashPubKey); 1424 &pid.hashPubKey);
1428 GNUNET_break (GNUNET_OK == 1425 GNUNET_break (GNUNET_OK ==
1429 GNUNET_CONTAINER_multihashmap_remove (validation_map, 1426 GNUNET_CONTAINER_multihashmap_remove (validation_map,
@@ -1464,8 +1461,8 @@ transmit_to_client (struct TransportClient *client,
1464 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 1461 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
1465 _ 1462 _
1466 ("Dropping message of type %u and size %u, have %u messages pending (%u is the soft limit)\n"), 1463 ("Dropping message of type %u and size %u, have %u messages pending (%u is the soft limit)\n"),
1467 ntohs (msg->type), 1464 ntohs (msg->type), ntohs (msg->size), client->message_count,
1468 ntohs (msg->size), client->message_count, MAX_PENDING); 1465 MAX_PENDING);
1469 GNUNET_STATISTICS_update (stats, 1466 GNUNET_STATISTICS_update (stats,
1470 gettext_noop 1467 gettext_noop
1471 ("# messages dropped due to slow client"), 1, 1468 ("# messages dropped due to slow client"), 1,
@@ -1481,11 +1478,11 @@ transmit_to_client (struct TransportClient *client,
1481 client->message_count++; 1478 client->message_count++;
1482 if (client->th == NULL) 1479 if (client->th == NULL)
1483 { 1480 {
1484 client->th = GNUNET_SERVER_notify_transmit_ready (client->client, 1481 client->th =
1485 msize, 1482 GNUNET_SERVER_notify_transmit_ready (client->client, msize,
1486 GNUNET_TIME_UNIT_FOREVER_REL, 1483 GNUNET_TIME_UNIT_FOREVER_REL,
1487 &transmit_to_client_callback, 1484 &transmit_to_client_callback,
1488 client); 1485 client);
1489 GNUNET_assert (client->th != NULL); 1486 GNUNET_assert (client->th != NULL);
1490 } 1487 }
1491} 1488}
@@ -1501,8 +1498,7 @@ transmit_to_client (struct TransportClient *client,
1501 * @param result status code for the transmission request 1498 * @param result status code for the transmission request
1502 */ 1499 */
1503static void 1500static void
1504transmit_send_ok (struct TransportClient *client, 1501transmit_send_ok (struct TransportClient *client, struct NeighbourMapEntry *n,
1505 struct NeighbourMapEntry *n,
1506 const struct GNUNET_PeerIdentity *target, int result) 1502 const struct GNUNET_PeerIdentity *target, int result)
1507{ 1503{
1508 struct SendOkMessage send_ok_msg; 1504 struct SendOkMessage send_ok_msg;
@@ -1561,8 +1557,7 @@ retry_transmission_task (void *cls,
1561 * more messages 1557 * more messages
1562 */ 1558 */
1563static void 1559static void
1564transmit_send_continuation (void *cls, 1560transmit_send_continuation (void *cls, const struct GNUNET_PeerIdentity *target,
1565 const struct GNUNET_PeerIdentity *target,
1566 int result) 1561 int result)
1567{ 1562{
1568 struct MessageQueue *mq = cls; 1563 struct MessageQueue *mq = cls;
@@ -1606,8 +1601,7 @@ transmit_send_continuation (void *cls,
1606 mq->specific_address->addr, 1601 mq->specific_address->addr,
1607 mq->specific_address->addrlen)); 1602 mq->specific_address->addrlen));
1608#endif 1603#endif
1609 GNUNET_STATISTICS_update (stats, 1604 GNUNET_STATISTICS_update (stats, gettext_noop ("# connected addresses"),
1610 gettext_noop ("# connected addresses"),
1611 -1, GNUNET_NO); 1605 -1, GNUNET_NO);
1612 mq->specific_address->connected = GNUNET_NO; 1606 mq->specific_address->connected = GNUNET_NO;
1613 } 1607 }
@@ -1698,13 +1692,13 @@ try_transmission_to_peer (struct NeighbourMapEntry *n)
1698 GNUNET_NO); 1692 GNUNET_NO);
1699 if (n->retry_task != GNUNET_SCHEDULER_NO_TASK) 1693 if (n->retry_task != GNUNET_SCHEDULER_NO_TASK)
1700 GNUNET_SCHEDULER_cancel (n->retry_task); 1694 GNUNET_SCHEDULER_cancel (n->retry_task);
1701 n->retry_task = GNUNET_SCHEDULER_add_delayed (timeout, 1695 n->retry_task =
1702 &retry_transmission_task, n); 1696 GNUNET_SCHEDULER_add_delayed (timeout, &retry_transmission_task, n);
1703#if DEBUG_TRANSPORT 1697#if DEBUG_TRANSPORT
1704 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1698 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1705 "No validated destination address available to transmit message of size %u to peer `%4s', will wait %llums to find an address.\n", 1699 "No validated destination address available to transmit message of size %u to peer `%4s', will wait %llums to find an address.\n",
1706 mq->message_buf_size, 1700 mq->message_buf_size, GNUNET_i2s (&mq->neighbour_id),
1707 GNUNET_i2s (&mq->neighbour_id), timeout.rel_value); 1701 timeout.rel_value);
1708#endif 1702#endif
1709 /* FIXME: might want to trigger peerinfo lookup here 1703 /* FIXME: might want to trigger peerinfo lookup here
1710 * (unless that's already pending...) */ 1704 * (unless that's already pending...) */
@@ -1720,13 +1714,11 @@ try_transmission_to_peer (struct NeighbourMapEntry *n)
1720#if DEBUG_TRANSPORT 1714#if DEBUG_TRANSPORT
1721 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1715 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1722 "Sending message of size %u for `%4s' to `%s' via plugin `%s'\n", 1716 "Sending message of size %u for `%4s' to `%s' via plugin `%s'\n",
1723 mq->message_buf_size, 1717 mq->message_buf_size, GNUNET_i2s (&n->id),
1724 GNUNET_i2s (&n->id), 1718 (mq->specific_address->addr !=
1725 (mq->specific_address->addr != NULL) 1719 NULL) ? a2s (mq->plugin->short_name, mq->specific_address->addr,
1726 ? a2s (mq->plugin->short_name, 1720 mq->specific_address->addrlen) : "<inbound>",
1727 mq->specific_address->addr, 1721 rl->plugin->short_name);
1728 mq->specific_address->addrlen)
1729 : "<inbound>", rl->plugin->short_name);
1730#endif 1722#endif
1731 GNUNET_STATISTICS_update (stats, 1723 GNUNET_STATISTICS_update (stats,
1732 gettext_noop 1724 gettext_noop
@@ -1738,16 +1730,15 @@ try_transmission_to_peer (struct NeighbourMapEntry *n)
1738 1730
1739 GNUNET_CONTAINER_DLL_insert (n->cont_head, n->cont_tail, mq); 1731 GNUNET_CONTAINER_DLL_insert (n->cont_head, n->cont_tail, mq);
1740 1732
1741 ret = rl->plugin->api->send (rl->plugin->api->cls, 1733 ret =
1742 &mq->neighbour_id, 1734 rl->plugin->api->send (rl->plugin->api->cls, &mq->neighbour_id,
1743 mq->message_buf, 1735 mq->message_buf, mq->message_buf_size,
1744 mq->message_buf_size, 1736 mq->priority,
1745 mq->priority, 1737 GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT,
1746 GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT, 1738 mq->specific_address->session,
1747 mq->specific_address->session, 1739 mq->specific_address->addr,
1748 mq->specific_address->addr, 1740 mq->specific_address->addrlen, force_address,
1749 mq->specific_address->addrlen, 1741 &transmit_send_continuation, mq);
1750 force_address, &transmit_send_continuation, mq);
1751 if (ret == -1) 1742 if (ret == -1)
1752 { 1743 {
1753 /* failure, but 'send' would not call continuation in this case, 1744 /* failure, but 'send' would not call continuation in this case,
@@ -1773,10 +1764,8 @@ try_transmission_to_peer (struct NeighbourMapEntry *n)
1773static void 1764static void
1774transmit_to_peer (struct TransportClient *client, 1765transmit_to_peer (struct TransportClient *client,
1775 struct ForeignAddressList *peer_address, 1766 struct ForeignAddressList *peer_address,
1776 unsigned int priority, 1767 unsigned int priority, struct GNUNET_TIME_Relative timeout,
1777 struct GNUNET_TIME_Relative timeout, 1768 const char *message_buf, size_t message_buf_size,
1778 const char *message_buf,
1779 size_t message_buf_size,
1780 int is_internal, struct NeighbourMapEntry *neighbour) 1769 int is_internal, struct NeighbourMapEntry *neighbour)
1781{ 1770{
1782 struct MessageQueue *mq; 1771 struct MessageQueue *mq;
@@ -1865,12 +1854,11 @@ transmit_plain_ping (struct NeighbourMapEntry *n)
1865 continue; 1854 continue;
1866 ve = GNUNET_malloc (sizeof (struct ValidationEntry)); 1855 ve = GNUNET_malloc (sizeof (struct ValidationEntry));
1867 ve->transport_name = GNUNET_strdup (plugin->short_name); 1856 ve->transport_name = GNUNET_strdup (plugin->short_name);
1868 ve->challenge = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_NONCE, 1857 ve->challenge =
1869 UINT_MAX); 1858 GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_NONCE, UINT_MAX);
1870 ve->send_time = GNUNET_TIME_absolute_get (); 1859 ve->send_time = GNUNET_TIME_absolute_get ();
1871 ve->session = fal->session; 1860 ve->session = fal->session;
1872 memcpy (&ve->publicKey, 1861 memcpy (&ve->publicKey, &n->publicKey,
1873 &n->publicKey,
1874 sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded)); 1862 sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded));
1875 ve->timeout_task = 1863 ve->timeout_task =
1876 GNUNET_SCHEDULER_add_delayed (HELLO_VERIFICATION_TIMEOUT, 1864 GNUNET_SCHEDULER_add_delayed (HELLO_VERIFICATION_TIMEOUT,
@@ -1919,8 +1907,8 @@ mark_address_connected (struct ForeignAddressList *fal)
1919 while (pos != NULL) 1907 while (pos != NULL)
1920 { 1908 {
1921 /* Already have inbound address, and this is also an inbound address, don't switch!! */ 1909 /* Already have inbound address, and this is also an inbound address, don't switch!! */
1922 if ((GNUNET_YES == pos->connected) && 1910 if ((GNUNET_YES == pos->connected) && (0 == pos->addrlen) &&
1923 (0 == pos->addrlen) && (0 == fal->addrlen)) 1911 (0 == fal->addrlen))
1924 return; 1912 return;
1925 if ((0 == pos->addrlen) && (GNUNET_YES == pos->connected)) 1913 if ((0 == pos->addrlen) && (GNUNET_YES == pos->connected))
1926 inbound = pos; 1914 inbound = pos;
@@ -1931,8 +1919,8 @@ mark_address_connected (struct ForeignAddressList *fal)
1931 while (pos != NULL) 1919 while (pos != NULL)
1932 { 1920 {
1933 /* Already have outbound address, and this is also an outbound address, don't switch!! */ 1921 /* Already have outbound address, and this is also an outbound address, don't switch!! */
1934 if ((GNUNET_YES == pos->connected) && 1922 if ((GNUNET_YES == pos->connected) && (0 < pos->addrlen) &&
1935 (0 < pos->addrlen) && (0 < fal->addrlen)) 1923 (0 < fal->addrlen))
1936 return; 1924 return;
1937 if ((0 < pos->addrlen) && (GNUNET_YES == pos->connected)) 1925 if ((0 < pos->addrlen) && (GNUNET_YES == pos->connected))
1938 outbound = pos; 1926 outbound = pos;
@@ -1949,14 +1937,11 @@ mark_address_connected (struct ForeignAddressList *fal)
1949#endif 1937#endif
1950 1938
1951 /* Have an inbound connection to this peer which is valid; our id is lower, ignore outbound connection! */ 1939 /* Have an inbound connection to this peer which is valid; our id is lower, ignore outbound connection! */
1952 if ((inbound != NULL) && (0 != fal->addrlen) && (1 1940 if ((inbound != NULL) && (0 != fal->addrlen) &&
1953 == 1941 (1 ==
1954 GNUNET_CRYPTO_hash_xorcmp 1942 GNUNET_CRYPTO_hash_xorcmp (&inbound->ready_list->neighbour->
1955 (&inbound-> 1943 id.hashPubKey, &my_identity.hashPubKey,
1956 ready_list->neighbour->id. 1944 &null_hash)))
1957 hashPubKey,
1958 &my_identity.hashPubKey,
1959 &null_hash)))
1960 { 1945 {
1961#if DEBUG_INBOUND 1946#if DEBUG_INBOUND
1962 fprintf (stderr, "Peer: %s, had inbound connection, ignoring outbound!\n", 1947 fprintf (stderr, "Peer: %s, had inbound connection, ignoring outbound!\n",
@@ -1964,13 +1949,11 @@ mark_address_connected (struct ForeignAddressList *fal)
1964#endif 1949#endif
1965 return; 1950 return;
1966 } 1951 }
1967 else if ((outbound != NULL) && (0 == fal->addrlen) && ((-1 1952 else if ((outbound != NULL) && (0 == fal->addrlen) &&
1968 == 1953 ((-1 ==
1969 GNUNET_CRYPTO_hash_xorcmp 1954 GNUNET_CRYPTO_hash_xorcmp (&outbound->ready_list->neighbour->id.
1970 (&outbound->ready_list->neighbour-> 1955 hashPubKey, &my_identity.hashPubKey,
1971 id.hashPubKey, 1956 &null_hash))))
1972 &my_identity.hashPubKey,
1973 &null_hash))))
1974 { 1957 {
1975#if DEBUG_INBOUND 1958#if DEBUG_INBOUND
1976 fprintf (stderr, "Peer: %s, have outbound connection, ignoring inbound!\n", 1959 fprintf (stderr, "Peer: %s, have outbound connection, ignoring inbound!\n",
@@ -1991,22 +1974,20 @@ mark_address_connected (struct ForeignAddressList *fal)
1991 pos->addrlen)); 1974 pos->addrlen));
1992#endif 1975#endif
1993#if DEBUG_INBOUND 1976#if DEBUG_INBOUND
1994 fprintf (stderr, 1977 fprintf (stderr, "Peer: %s, setting %s connection to disconnected.\n",
1995 "Peer: %s, setting %s connection to disconnected.\n",
1996 GNUNET_i2s (&my_identity), 1978 GNUNET_i2s (&my_identity),
1997 (0 == pos->addrlen) ? "INBOUND" : "OUTBOUND"); 1979 (0 == pos->addrlen) ? "INBOUND" : "OUTBOUND");
1998#endif 1980#endif
1999 pos->connected = GNUNET_NO; 1981 pos->connected = GNUNET_NO;
2000 GNUNET_STATISTICS_update (stats, 1982 GNUNET_STATISTICS_update (stats, gettext_noop ("# connected addresses"),
2001 gettext_noop ("# connected addresses"), -1, 1983 -1, GNUNET_NO);
2002 GNUNET_NO);
2003 } 1984 }
2004 pos = pos->next; 1985 pos = pos->next;
2005 } 1986 }
2006 GNUNET_assert (GNUNET_NO == fal->connected); 1987 GNUNET_assert (GNUNET_NO == fal->connected);
2007 fal->connected = GNUNET_YES; 1988 fal->connected = GNUNET_YES;
2008 GNUNET_STATISTICS_update (stats, gettext_noop ("# connected addresses"), 1989 GNUNET_STATISTICS_update (stats, gettext_noop ("# connected addresses"), 1,
2009 1, GNUNET_NO); 1990 GNUNET_NO);
2010} 1991}
2011 1992
2012 1993
@@ -2044,8 +2025,7 @@ find_ready_address (struct NeighbourMapEntry *neighbour)
2044 "Marking long-time inactive connection to `%4s' as down.\n", 2025 "Marking long-time inactive connection to `%4s' as down.\n",
2045 GNUNET_i2s (&neighbour->id)); 2026 GNUNET_i2s (&neighbour->id));
2046#endif 2027#endif
2047 GNUNET_STATISTICS_update (stats, 2028 GNUNET_STATISTICS_update (stats, gettext_noop ("# connected addresses"),
2048 gettext_noop ("# connected addresses"),
2049 -1, GNUNET_NO); 2029 -1, GNUNET_NO);
2050 addresses->connected = GNUNET_NO; 2030 addresses->connected = GNUNET_NO;
2051 } 2031 }
@@ -2059,14 +2039,10 @@ find_ready_address (struct NeighbourMapEntry *neighbour)
2059 if (addresses->addr != NULL) 2039 if (addresses->addr != NULL)
2060 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 2040 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
2061 "Have address `%s' for peer `%4s' (status: %d, %d, %d, %u, %llums, %u)\n", 2041 "Have address `%s' for peer `%4s' (status: %d, %d, %d, %u, %llums, %u)\n",
2062 a2s (head->plugin->short_name, 2042 a2s (head->plugin->short_name, addresses->addr,
2063 addresses->addr, 2043 addresses->addrlen), GNUNET_i2s (&neighbour->id),
2064 addresses->addrlen), 2044 addresses->connected, addresses->in_transmit,
2065 GNUNET_i2s (&neighbour->id), 2045 addresses->validated, addresses->connect_attempts,
2066 addresses->connected,
2067 addresses->in_transmit,
2068 addresses->validated,
2069 addresses->connect_attempts,
2070 (unsigned long long) addresses->timeout.abs_value, 2046 (unsigned long long) addresses->timeout.abs_value,
2071 (unsigned int) addresses->distance); 2047 (unsigned int) addresses->distance);
2072#endif 2048#endif
@@ -2077,12 +2053,13 @@ find_ready_address (struct NeighbourMapEntry *neighbour)
2077 (addresses->latency.rel_value < unix_address->latency.rel_value))) 2053 (addresses->latency.rel_value < unix_address->latency.rel_value)))
2078 unix_address = addresses; 2054 unix_address = addresses;
2079 } 2055 }
2080 if (((best_address == NULL) || 2056 if (((best_address == NULL) || (addresses->connected == GNUNET_YES) ||
2081 (addresses->connected == GNUNET_YES) ||
2082 (best_address->connected == GNUNET_NO)) && 2057 (best_address->connected == GNUNET_NO)) &&
2083 (addresses->in_transmit == GNUNET_NO) && 2058 (addresses->in_transmit == GNUNET_NO) && ((best_address == NULL) ||
2084 ((best_address == NULL) || 2059 (addresses->latency.
2085 (addresses->latency.rel_value < best_address->latency.rel_value))) 2060 rel_value <
2061 best_address->latency.
2062 rel_value)))
2086 best_address = addresses; 2063 best_address = addresses;
2087 /* FIXME: also give lower-latency addresses that are not 2064 /* FIXME: also give lower-latency addresses that are not
2088 * connected a chance some times... */ 2065 * connected a chance some times... */
@@ -2105,11 +2082,11 @@ find_ready_address (struct NeighbourMapEntry *neighbour)
2105#if DEBUG_TRANSPORT 2082#if DEBUG_TRANSPORT
2106 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 2083 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
2107 "Best address found (`%s') has latency of %llu ms.\n", 2084 "Best address found (`%s') has latency of %llu ms.\n",
2108 (best_address->addrlen > 0) 2085 (best_address->addrlen >
2109 ? a2s (best_address->ready_list->plugin->short_name, 2086 0) ? a2s (best_address->ready_list->plugin->short_name,
2110 best_address->addr, 2087 best_address->addr,
2111 best_address->addrlen) 2088 best_address->addrlen) : "<inbound>",
2112 : "<inbound>", best_address->latency.rel_value); 2089 best_address->latency.rel_value);
2113#endif 2090#endif
2114 } 2091 }
2115 else 2092 else
@@ -2154,10 +2131,10 @@ address_generator (void *cls, size_t max, void *buf)
2154 2131
2155 return 0; 2132 return 0;
2156 } 2133 }
2157 ret = GNUNET_HELLO_add_address (gc->plug_pos->short_name, 2134 ret =
2158 gc->expiration, 2135 GNUNET_HELLO_add_address (gc->plug_pos->short_name, gc->expiration,
2159 &gc->addr_pos[1], 2136 &gc->addr_pos[1], gc->addr_pos->addrlen, buf,
2160 gc->addr_pos->addrlen, buf, max); 2137 max);
2161 gc->addr_pos = gc->addr_pos->next; 2138 gc->addr_pos = gc->addr_pos->next;
2162 return ret; 2139 return ret;
2163} 2140}
@@ -2173,8 +2150,8 @@ transmit_our_hello_if_pong (void *cls, const GNUNET_HashCode * key, void *value)
2173 return GNUNET_OK; 2150 return GNUNET_OK;
2174#if DEBUG_TRANSPORT 2151#if DEBUG_TRANSPORT
2175 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG | GNUNET_ERROR_TYPE_BULK, 2152 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG | GNUNET_ERROR_TYPE_BULK,
2176 "Transmitting updated `%s' to neighbour `%4s'\n", 2153 "Transmitting updated `%s' to neighbour `%4s'\n", "HELLO",
2177 "HELLO", GNUNET_i2s (&npos->id)); 2154 GNUNET_i2s (&npos->id));
2178#endif 2155#endif
2179 GNUNET_STATISTICS_update (stats, 2156 GNUNET_STATISTICS_update (stats,
2180 gettext_noop 2157 gettext_noop
@@ -2211,15 +2188,14 @@ refresh_hello_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
2211 "Refreshed my `%s', new size is %d\n", "HELLO", 2188 "Refreshed my `%s', new size is %d\n", "HELLO",
2212 GNUNET_HELLO_size (hello)); 2189 GNUNET_HELLO_size (hello));
2213#endif 2190#endif
2214 GNUNET_STATISTICS_update (stats, 2191 GNUNET_STATISTICS_update (stats, gettext_noop ("# refreshed my HELLO"), 1,
2215 gettext_noop ("# refreshed my HELLO"), 2192 GNUNET_NO);
2216 1, GNUNET_NO);
2217 cpos = clients; 2193 cpos = clients;
2218 while (cpos != NULL) 2194 while (cpos != NULL)
2219 { 2195 {
2220 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Transmitting my HELLO to client!\n"); 2196 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Transmitting my HELLO to client!\n");
2221 transmit_to_client (cpos, 2197 transmit_to_client (cpos, (const struct GNUNET_MessageHeader *) hello,
2222 (const struct GNUNET_MessageHeader *) hello, GNUNET_NO); 2198 GNUNET_NO);
2223 cpos = cpos->next; 2199 cpos = cpos->next;
2224 } 2200 }
2225 2201
@@ -2320,9 +2296,8 @@ try_fast_reconnect (struct TransportPlugin *p, struct NeighbourMapEntry *nl)
2320 /* No reconnect, signal disconnect instead! */ 2296 /* No reconnect, signal disconnect instead! */
2321#if DEBUG_TRANSPORT 2297#if DEBUG_TRANSPORT
2322#endif 2298#endif
2323 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 2299 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Disconnecting peer `%4s', %s\n",
2324 "Disconnecting peer `%4s', %s\n", GNUNET_i2s (&nl->id), 2300 GNUNET_i2s (&nl->id), "try_fast_reconnect");
2325 "try_fast_reconnect");
2326 2301
2327 GNUNET_STATISTICS_update (stats, 2302 GNUNET_STATISTICS_update (stats,
2328 gettext_noop 2303 gettext_noop
@@ -2346,8 +2321,7 @@ try_fast_reconnect (struct TransportPlugin *p, struct NeighbourMapEntry *nl)
2346 * @param session which session is being destoyed 2321 * @param session which session is being destoyed
2347 */ 2322 */
2348static void 2323static void
2349plugin_env_session_end (void *cls, 2324plugin_env_session_end (void *cls, const struct GNUNET_PeerIdentity *peer,
2350 const struct GNUNET_PeerIdentity *peer,
2351 struct Session *session) 2325 struct Session *session)
2352{ 2326{
2353 struct TransportPlugin *p = cls; 2327 struct TransportPlugin *p = cls;
@@ -2357,8 +2331,7 @@ plugin_env_session_end (void *cls,
2357 struct ForeignAddressList *prev; 2331 struct ForeignAddressList *prev;
2358 2332
2359#if DEBUG_TRANSPORT 2333#if DEBUG_TRANSPORT
2360 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 2334 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Session ended with peer `%4s', %s\n",
2361 "Session ended with peer `%4s', %s\n",
2362 GNUNET_i2s (peer), "plugin_env_session_end"); 2335 GNUNET_i2s (peer), "plugin_env_session_end");
2363#endif 2336#endif
2364 GNUNET_CONTAINER_multihashmap_iterate (validation_map, 2337 GNUNET_CONTAINER_multihashmap_iterate (validation_map,
@@ -2435,9 +2408,8 @@ plugin_env_session_end (void *cls,
2435 if (GNUNET_YES == pos->connected) 2408 if (GNUNET_YES == pos->connected)
2436 { 2409 {
2437 pos->connected = GNUNET_NO; 2410 pos->connected = GNUNET_NO;
2438 GNUNET_STATISTICS_update (stats, 2411 GNUNET_STATISTICS_update (stats, gettext_noop ("# connected addresses"), -1,
2439 gettext_noop ("# connected addresses"), 2412 GNUNET_NO);
2440 -1, GNUNET_NO);
2441 } 2413 }
2442 if (GNUNET_SCHEDULER_NO_TASK != pos->revalidate_task) 2414 if (GNUNET_SCHEDULER_NO_TASK != pos->revalidate_task)
2443 { 2415 {
@@ -2491,16 +2463,15 @@ plugin_env_session_end (void *cls,
2491 return; 2463 return;
2492 } 2464 }
2493 pos->connected = GNUNET_NO; 2465 pos->connected = GNUNET_NO;
2494 GNUNET_STATISTICS_update (stats, 2466 GNUNET_STATISTICS_update (stats, gettext_noop ("# connected addresses"), -1,
2495 gettext_noop ("# connected addresses"), 2467 GNUNET_NO);
2496 -1, GNUNET_NO);
2497 GNUNET_free (pos); 2468 GNUNET_free (pos);
2498 2469
2499 if (nl->received_pong == GNUNET_NO) 2470 if (nl->received_pong == GNUNET_NO)
2500 { 2471 {
2501 GNUNET_STATISTICS_update (stats, 2472 GNUNET_STATISTICS_update (stats,
2502 gettext_noop ("# disconnects due to NO pong"), 2473 gettext_noop ("# disconnects due to NO pong"), 1,
2503 1, GNUNET_NO); 2474 GNUNET_NO);
2504 disconnect_neighbour (nl, GNUNET_YES); 2475 disconnect_neighbour (nl, GNUNET_YES);
2505 return; /* nothing to do, never connected... */ 2476 return; /* nothing to do, never connected... */
2506 } 2477 }
@@ -2522,8 +2493,7 @@ plugin_env_session_end (void *cls,
2522 /* no valid addresses left, signal disconnect! */ 2493 /* no valid addresses left, signal disconnect! */
2523 2494
2524#if DEBUG_TRANSPORT 2495#if DEBUG_TRANSPORT
2525 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 2496 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Disconnecting peer `%4s', %s\n",
2526 "Disconnecting peer `%4s', %s\n",
2527 GNUNET_i2s (peer), "plugin_env_session_end"); 2497 GNUNET_i2s (peer), "plugin_env_session_end");
2528#endif 2498#endif
2529 /* FIXME: This doesn't mean there are no addresses left for this PEER, 2499 /* FIXME: This doesn't mean there are no addresses left for this PEER,
@@ -2553,8 +2523,8 @@ plugin_env_session_end (void *cls,
2553 * @param addrlen length of the address 2523 * @param addrlen length of the address
2554 */ 2524 */
2555static void 2525static void
2556plugin_env_notify_address (void *cls, 2526plugin_env_notify_address (void *cls, int add_remove, const void *addr,
2557 int add_remove, const void *addr, size_t addrlen) 2527 size_t addrlen)
2558{ 2528{
2559 struct TransportPlugin *p = cls; 2529 struct TransportPlugin *p = cls;
2560 struct OwnAddressList *al; 2530 struct OwnAddressList *al;
@@ -2563,9 +2533,9 @@ plugin_env_notify_address (void *cls,
2563 GNUNET_assert (p->api != NULL); 2533 GNUNET_assert (p->api != NULL);
2564#if DEBUG_TRANSPORT 2534#if DEBUG_TRANSPORT
2565 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 2535 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
2566 (add_remove == GNUNET_YES) 2536 (add_remove ==
2567 ? "Adding `%s':%s to the set of our addresses\n" 2537 GNUNET_YES) ? "Adding `%s':%s to the set of our addresses\n" :
2568 : "Removing `%s':%s from the set of our addresses\n", 2538 "Removing `%s':%s from the set of our addresses\n",
2569 a2s (p->short_name, addr, addrlen), p->short_name); 2539 a2s (p->short_name, addr, addrlen), p->short_name);
2570#endif 2540#endif
2571 GNUNET_assert (addr != NULL); 2541 GNUNET_assert (addr != NULL);
@@ -2622,8 +2592,8 @@ notify_clients_connect (const struct GNUNET_PeerIdentity *peer,
2622 "Notifying clients about connection with `%s'\n", 2592 "Notifying clients about connection with `%s'\n",
2623 GNUNET_i2s (peer)); 2593 GNUNET_i2s (peer));
2624#endif 2594#endif
2625 GNUNET_STATISTICS_update (stats, 2595 GNUNET_STATISTICS_update (stats, gettext_noop ("# peers connected"), 1,
2626 gettext_noop ("# peers connected"), 1, GNUNET_NO); 2596 GNUNET_NO);
2627 2597
2628 ats_count = 2; 2598 ats_count = 2;
2629 size = 2599 size =
@@ -2679,8 +2649,8 @@ notify_clients_disconnect (const struct GNUNET_PeerIdentity *peer)
2679 "Notifying clients about lost connection to `%s'\n", 2649 "Notifying clients about lost connection to `%s'\n",
2680 GNUNET_i2s (peer)); 2650 GNUNET_i2s (peer));
2681#endif 2651#endif
2682 GNUNET_STATISTICS_update (stats, 2652 GNUNET_STATISTICS_update (stats, gettext_noop ("# peers connected"), -1,
2683 gettext_noop ("# peers connected"), -1, GNUNET_NO); 2653 GNUNET_NO);
2684 dim.header.size = htons (sizeof (struct DisconnectInfoMessage)); 2654 dim.header.size = htons (sizeof (struct DisconnectInfoMessage));
2685 dim.header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_DISCONNECT); 2655 dim.header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_DISCONNECT);
2686 dim.reserved = htonl (0); 2656 dim.reserved = htonl (0);
@@ -2718,8 +2688,7 @@ notify_clients_disconnect (const struct GNUNET_PeerIdentity *peer)
2718 * @return NULL if no such entry exists 2688 * @return NULL if no such entry exists
2719 */ 2689 */
2720static struct ForeignAddressList * 2690static struct ForeignAddressList *
2721find_peer_address (struct NeighbourMapEntry *neighbour, 2691find_peer_address (struct NeighbourMapEntry *neighbour, const char *tname,
2722 const char *tname,
2723 struct Session *session, const char *addr, uint16_t addrlen) 2692 struct Session *session, const char *addr, uint16_t addrlen)
2724{ 2693{
2725 struct ReadyList *head; 2694 struct ReadyList *head;
@@ -2761,8 +2730,7 @@ find_peer_address (struct NeighbourMapEntry *neighbour,
2761 * @return NULL if we do not have a transport plugin for 'tname' 2730 * @return NULL if we do not have a transport plugin for 'tname'
2762 */ 2731 */
2763static struct ForeignAddressList * 2732static struct ForeignAddressList *
2764add_peer_address (struct NeighbourMapEntry *neighbour, 2733add_peer_address (struct NeighbourMapEntry *neighbour, const char *tname,
2765 const char *tname,
2766 struct Session *session, const char *addr, uint16_t addrlen) 2734 struct Session *session, const char *addr, uint16_t addrlen)
2767{ 2735{
2768 struct ReadyList *head; 2736 struct ReadyList *head;
@@ -2841,11 +2809,13 @@ add_peer_address (struct NeighbourMapEntry *neighbour,
2841 GNUNET_malloc (available_quality_metrics * 2809 GNUNET_malloc (available_quality_metrics *
2842 sizeof (struct ATS_quality_entry)); 2810 sizeof (struct ATS_quality_entry));
2843 ret->addrlen = addrlen; 2811 ret->addrlen = addrlen;
2844 ret->expires = GNUNET_TIME_relative_to_absolute 2812 ret->expires =
2813 GNUNET_TIME_relative_to_absolute
2845 (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT); 2814 (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT);
2846 ret->latency = GNUNET_TIME_relative_get_forever (); 2815 ret->latency = GNUNET_TIME_relative_get_forever ();
2847 ret->distance = -1; 2816 ret->distance = -1;
2848 ret->timeout = GNUNET_TIME_relative_to_absolute 2817 ret->timeout =
2818 GNUNET_TIME_relative_to_absolute
2849 (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT); 2819 (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT);
2850 ret->ready_list = head; 2820 ret->ready_list = head;
2851 ret->next = head->addresses; 2821 ret->next = head->addresses;
@@ -2950,8 +2920,7 @@ check_address_exists (void *cls, const GNUNET_HashCode * key, void *value)
2950 struct CheckAddressExistsClosure *caec = cls; 2920 struct CheckAddressExistsClosure *caec = cls;
2951 struct ValidationEntry *ve = value; 2921 struct ValidationEntry *ve = value;
2952 2922
2953 if ((0 == strcmp (caec->tname, 2923 if ((0 == strcmp (caec->tname, ve->transport_name)) &&
2954 ve->transport_name)) &&
2955 (caec->addrlen == ve->addrlen) && 2924 (caec->addrlen == ve->addrlen) &&
2956 (0 == memcmp (caec->addr, ve->addr, caec->addrlen))) 2925 (0 == memcmp (caec->addr, ve->addr, caec->addrlen)))
2957 { 2926 {
@@ -2978,8 +2947,8 @@ neighbour_timeout_task (void *cls,
2978 "Neighbour `%4s' has timed out!\n", GNUNET_i2s (&n->id)); 2947 "Neighbour `%4s' has timed out!\n", GNUNET_i2s (&n->id));
2979#endif 2948#endif
2980 GNUNET_STATISTICS_update (stats, 2949 GNUNET_STATISTICS_update (stats,
2981 gettext_noop ("# disconnects due to timeout"), 2950 gettext_noop ("# disconnects due to timeout"), 1,
2982 1, GNUNET_NO); 2951 GNUNET_NO);
2983 n->timeout_task = GNUNET_SCHEDULER_NO_TASK; 2952 n->timeout_task = GNUNET_SCHEDULER_NO_TASK;
2984 disconnect_neighbour (n, GNUNET_NO); 2953 disconnect_neighbour (n, GNUNET_NO);
2985} 2954}
@@ -3006,8 +2975,7 @@ static void schedule_next_ping (struct ForeignAddressList *fal);
3006 * @return GNUNET_OK (always) 2975 * @return GNUNET_OK (always)
3007 */ 2976 */
3008static int 2977static int
3009add_to_foreign_address_list (void *cls, 2978add_to_foreign_address_list (void *cls, const char *tname,
3010 const char *tname,
3011 struct GNUNET_TIME_Absolute expiration, 2979 struct GNUNET_TIME_Absolute expiration,
3012 const void *addr, uint16_t addrlen) 2980 const void *addr, uint16_t addrlen)
3013{ 2981{
@@ -3026,8 +2994,8 @@ add_to_foreign_address_list (void *cls,
3026#if DEBUG_TRANSPORT_HELLO 2994#if DEBUG_TRANSPORT_HELLO
3027 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 2995 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
3028 "Adding address `%s' (%s) for peer `%4s' due to PEERINFO data for %llums.\n", 2996 "Adding address `%s' (%s) for peer `%4s' due to PEERINFO data for %llums.\n",
3029 a2s (tname, addr, addrlen), 2997 a2s (tname, addr, addrlen), tname, GNUNET_i2s (&n->id),
3030 tname, GNUNET_i2s (&n->id), expiration.abs_value); 2998 expiration.abs_value);
3031#endif 2999#endif
3032 fal = add_peer_address (n, tname, NULL, addr, addrlen); 3000 fal = add_peer_address (n, tname, NULL, addr, addrlen);
3033 if (fal == NULL) 3001 if (fal == NULL)
@@ -3086,8 +3054,7 @@ add_to_foreign_address_list (void *cls,
3086 * @param err_msg NULL if successful, otherwise contains error message 3054 * @param err_msg NULL if successful, otherwise contains error message
3087 */ 3055 */
3088static void 3056static void
3089add_hello_for_peer (void *cls, 3057add_hello_for_peer (void *cls, const struct GNUNET_PeerIdentity *peer,
3090 const struct GNUNET_PeerIdentity *peer,
3091 const struct GNUNET_HELLO_Message *h, const char *err_msg) 3058 const struct GNUNET_HELLO_Message *h, const char *err_msg)
3092{ 3059{
3093 struct NeighbourMapEntry *n = cls; 3060 struct NeighbourMapEntry *n = cls;
@@ -3122,8 +3089,8 @@ add_hello_for_peer (void *cls,
3122 GNUNET_HELLO_get_key (h, &n->publicKey); 3089 GNUNET_HELLO_get_key (h, &n->publicKey);
3123 n->public_key_valid = GNUNET_YES; 3090 n->public_key_valid = GNUNET_YES;
3124 } 3091 }
3125 GNUNET_HELLO_iterate_addresses (h, 3092 GNUNET_HELLO_iterate_addresses (h, GNUNET_NO, &add_to_foreign_address_list,
3126 GNUNET_NO, &add_to_foreign_address_list, n); 3093 n);
3127} 3094}
3128 3095
3129 3096
@@ -3143,15 +3110,15 @@ setup_new_neighbour (const struct GNUNET_PeerIdentity *peer, int do_hello)
3143 struct TransportPlugin *tp; 3110 struct TransportPlugin *tp;
3144 struct ReadyList *rl; 3111 struct ReadyList *rl;
3145 3112
3146 GNUNET_assert (0 != memcmp (peer, 3113 GNUNET_assert (0 !=
3147 &my_identity, 3114 memcmp (peer, &my_identity,
3148 sizeof (struct GNUNET_PeerIdentity))); 3115 sizeof (struct GNUNET_PeerIdentity)));
3149#if DEBUG_TRANSPORT 3116#if DEBUG_TRANSPORT
3150 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 3117 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Setting up state for neighbour `%4s'\n",
3151 "Setting up state for neighbour `%4s'\n", GNUNET_i2s (peer)); 3118 GNUNET_i2s (peer));
3152#endif 3119#endif
3153 GNUNET_STATISTICS_update (stats, 3120 GNUNET_STATISTICS_update (stats, gettext_noop ("# active neighbours"), 1,
3154 gettext_noop ("# active neighbours"), 1, GNUNET_NO); 3121 GNUNET_NO);
3155 n = GNUNET_malloc (sizeof (struct NeighbourMapEntry)); 3122 n = GNUNET_malloc (sizeof (struct NeighbourMapEntry));
3156 n->id = *peer; 3123 n->id = *peer;
3157 n->peer_timeout = 3124 n->peer_timeout =
@@ -3199,8 +3166,7 @@ setup_new_neighbour (const struct GNUNET_PeerIdentity *peer, int do_hello)
3199 gettext_noop ("# HELLO's sent to new neighbors"), 3166 gettext_noop ("# HELLO's sent to new neighbors"),
3200 1, GNUNET_NO); 3167 1, GNUNET_NO);
3201 if (NULL != our_hello) 3168 if (NULL != our_hello)
3202 transmit_to_peer (NULL, NULL, 0, 3169 transmit_to_peer (NULL, NULL, 0, HELLO_ADDRESS_EXPIRATION,
3203 HELLO_ADDRESS_EXPIRATION,
3204 (const char *) our_hello, GNUNET_HELLO_size (our_hello), 3170 (const char *) our_hello, GNUNET_HELLO_size (our_hello),
3205 GNUNET_NO, n); 3171 GNUNET_NO, n);
3206 } 3172 }
@@ -3329,8 +3295,8 @@ static struct BlacklistCheck *bc_tail;
3329 * @param cls the 'struct BlacklistCheck*' 3295 * @param cls the 'struct BlacklistCheck*'
3330 * @param tc unused 3296 * @param tc unused
3331 */ 3297 */
3332static void 3298static void do_blacklist_check (void *cls,
3333do_blacklist_check (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc); 3299 const struct GNUNET_SCHEDULER_TaskContext *tc);
3334 3300
3335/** 3301/**
3336 * Transmit blacklist query to the client. 3302 * Transmit blacklist query to the client.
@@ -3401,12 +3367,11 @@ do_blacklist_check (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
3401 if (bl->bc == NULL) 3367 if (bl->bc == NULL)
3402 { 3368 {
3403 bl->bc = bc; 3369 bl->bc = bc;
3404 bc->th = GNUNET_SERVER_notify_transmit_ready (bl->client, 3370 bc->th =
3405 sizeof (struct 3371 GNUNET_SERVER_notify_transmit_ready (bl->client,
3406 BlacklistMessage), 3372 sizeof (struct BlacklistMessage),
3407 GNUNET_TIME_UNIT_FOREVER_REL, 3373 GNUNET_TIME_UNIT_FOREVER_REL,
3408 &transmit_blacklist_message, 3374 &transmit_blacklist_message, bc);
3409 bc);
3410 } 3375 }
3411} 3376}
3412 3377
@@ -3425,8 +3390,8 @@ do_blacklist_check (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
3425 */ 3390 */
3426static void 3391static void
3427setup_peer_check_blacklist (const struct GNUNET_PeerIdentity *peer, 3392setup_peer_check_blacklist (const struct GNUNET_PeerIdentity *peer,
3428 int do_hello, 3393 int do_hello, SetupContinuation cont,
3429 SetupContinuation cont, void *cont_cls) 3394 void *cont_cls)
3430{ 3395{
3431 struct NeighbourMapEntry *n; 3396 struct NeighbourMapEntry *n;
3432 struct BlacklistCheck *bc; 3397 struct BlacklistCheck *bc;
@@ -3476,9 +3441,8 @@ confirm_or_drop_neighbour (void *cls, struct NeighbourMapEntry *n)
3476 if (n == NULL) 3441 if (n == NULL)
3477 { 3442 {
3478#if DEBUG_TRANSPORT 3443#if DEBUG_TRANSPORT
3479 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 3444 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Disconnecting peer `%4s', %s\n",
3480 "Disconnecting peer `%4s', %s\n", GNUNET_i2s (&orig->id), 3445 GNUNET_i2s (&orig->id), "confirm_or_drop_neighboUr");
3481 "confirm_or_drop_neighboUr");
3482#endif 3446#endif
3483 GNUNET_STATISTICS_update (stats, 3447 GNUNET_STATISTICS_update (stats,
3484 gettext_noop ("# disconnects due to blacklist"), 3448 gettext_noop ("# disconnects due to blacklist"),
@@ -3530,8 +3494,7 @@ test_connection_ok (void *cls, const GNUNET_HashCode * key, void *value)
3530 * @param message the actual message 3494 * @param message the actual message
3531 */ 3495 */
3532static void 3496static void
3533handle_blacklist_init (void *cls, 3497handle_blacklist_init (void *cls, struct GNUNET_SERVER_Client *client,
3534 struct GNUNET_SERVER_Client *client,
3535 const struct GNUNET_MessageHeader *message) 3498 const struct GNUNET_MessageHeader *message)
3536{ 3499{
3537 struct Blacklisters *bl; 3500 struct Blacklisters *bl;
@@ -3567,8 +3530,7 @@ handle_blacklist_init (void *cls,
3567 * @param message the actual message 3530 * @param message the actual message
3568 */ 3531 */
3569static void 3532static void
3570handle_blacklist_reply (void *cls, 3533handle_blacklist_reply (void *cls, struct GNUNET_SERVER_Client *client,
3571 struct GNUNET_SERVER_Client *client,
3572 const struct GNUNET_MessageHeader *message) 3534 const struct GNUNET_MessageHeader *message)
3573{ 3535{
3574 const struct BlacklistMessage *msg = 3536 const struct BlacklistMessage *msg =
@@ -3658,8 +3620,8 @@ send_periodic_ping (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
3658 caec.session = peer_address->session; 3620 caec.session = peer_address->session;
3659 caec.exists = GNUNET_NO; 3621 caec.exists = GNUNET_NO;
3660 3622
3661 GNUNET_CONTAINER_multihashmap_iterate (validation_map, 3623 GNUNET_CONTAINER_multihashmap_iterate (validation_map, &check_address_exists,
3662 &check_address_exists, &caec); 3624 &caec);
3663 if (caec.exists == GNUNET_YES) 3625 if (caec.exists == GNUNET_YES)
3664 { 3626 {
3665 /* During validation attempts we will likely trigger the other 3627 /* During validation attempts we will likely trigger the other
@@ -3669,19 +3631,19 @@ send_periodic_ping (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
3669#if DEBUG_TRANSPORT > 1 3631#if DEBUG_TRANSPORT > 1
3670 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 3632 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
3671 "Some validation of address `%s' via `%s' for peer `%4s' already in progress.\n", 3633 "Some validation of address `%s' via `%s' for peer `%4s' already in progress.\n",
3672 (peer_address->addr != NULL) 3634 (peer_address->addr != NULL) ? a2s (tp->short_name,
3673 ? a2s (tp->short_name, 3635 peer_address->addr,
3674 peer_address->addr, 3636 peer_address->
3675 peer_address->addrlen) 3637 addrlen) : "<inbound>",
3676 : "<inbound>", tp->short_name, GNUNET_i2s (&neighbour->id)); 3638 tp->short_name, GNUNET_i2s (&neighbour->id));
3677#endif 3639#endif
3678 schedule_next_ping (peer_address); 3640 schedule_next_ping (peer_address);
3679 return; 3641 return;
3680 } 3642 }
3681 va = GNUNET_malloc (sizeof (struct ValidationEntry) + peer_address->addrlen); 3643 va = GNUNET_malloc (sizeof (struct ValidationEntry) + peer_address->addrlen);
3682 va->transport_name = GNUNET_strdup (tp->short_name); 3644 va->transport_name = GNUNET_strdup (tp->short_name);
3683 va->challenge = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_NONCE, 3645 va->challenge =
3684 UINT_MAX); 3646 GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_NONCE, UINT_MAX);
3685 va->send_time = GNUNET_TIME_absolute_get (); 3647 va->send_time = GNUNET_TIME_absolute_get ();
3686 va->session = peer_address->session; 3648 va->session = peer_address->session;
3687 if (peer_address->addr != NULL) 3649 if (peer_address->addr != NULL)
@@ -3690,15 +3652,13 @@ send_periodic_ping (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
3690 memcpy (&va[1], peer_address->addr, peer_address->addrlen); 3652 memcpy (&va[1], peer_address->addr, peer_address->addrlen);
3691 va->addrlen = peer_address->addrlen; 3653 va->addrlen = peer_address->addrlen;
3692 } 3654 }
3693 memcpy (&va->publicKey, 3655 memcpy (&va->publicKey, &neighbour->publicKey,
3694 &neighbour->publicKey,
3695 sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded)); 3656 sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded));
3696 3657
3697 va->timeout_task = GNUNET_SCHEDULER_add_delayed (HELLO_VERIFICATION_TIMEOUT, 3658 va->timeout_task =
3698 &timeout_hello_validation, 3659 GNUNET_SCHEDULER_add_delayed (HELLO_VERIFICATION_TIMEOUT,
3699 va); 3660 &timeout_hello_validation, va);
3700 GNUNET_CONTAINER_multihashmap_put (validation_map, 3661 GNUNET_CONTAINER_multihashmap_put (validation_map, &neighbour->id.hashPubKey,
3701 &neighbour->id.hashPubKey,
3702 va, 3662 va,
3703 GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE); 3663 GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE);
3704 3664
@@ -3729,8 +3689,9 @@ send_periodic_ping (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
3729 3689
3730 if (peer_address->addr != NULL) 3690 if (peer_address->addr != NULL)
3731 { 3691 {
3732 ping.header.size = htons (sizeof (struct TransportPingMessage) + 3692 ping.header.size =
3733 peer_address->addrlen + slen); 3693 htons (sizeof (struct TransportPingMessage) + peer_address->addrlen +
3694 slen);
3734 memcpy (&message_buf[hello_size + sizeof (struct TransportPingMessage)], 3695 memcpy (&message_buf[hello_size + sizeof (struct TransportPingMessage)],
3735 tp->short_name, slen); 3696 tp->short_name, slen);
3736 memcpy (&message_buf 3697 memcpy (&message_buf
@@ -3742,19 +3703,18 @@ send_periodic_ping (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
3742 ping.header.size = htons (sizeof (struct TransportPingMessage)); 3703 ping.header.size = htons (sizeof (struct TransportPingMessage));
3743 } 3704 }
3744 3705
3745 memcpy (&message_buf[hello_size], 3706 memcpy (&message_buf[hello_size], &ping,
3746 &ping, sizeof (struct TransportPingMessage)); 3707 sizeof (struct TransportPingMessage));
3747 3708
3748#if DEBUG_TRANSPORT_REVALIDATION 3709#if DEBUG_TRANSPORT_REVALIDATION
3749 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 3710 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
3750 "Performing re-validation of address `%s' via `%s' for peer `%4s' sending `%s' (%u bytes) and `%s'\n", 3711 "Performing re-validation of address `%s' via `%s' for peer `%4s' sending `%s' (%u bytes) and `%s'\n",
3751 (peer_address->addr != NULL) 3712 (peer_address->addr !=
3752 ? a2s (peer_address->plugin->short_name, 3713 NULL) ? a2s (peer_address->plugin->short_name,
3753 peer_address->addr, 3714 peer_address->addr,
3754 peer_address->addrlen) 3715 peer_address->addrlen) : "<inbound>",
3755 : "<inbound>", 3716 tp->short_name, GNUNET_i2s (&neighbour->id), "HELLO", hello_size,
3756 tp->short_name, 3717 "PING");
3757 GNUNET_i2s (&neighbour->id), "HELLO", hello_size, "PING");
3758#endif 3718#endif
3759 if (peer_address->validated != GNUNET_YES) 3719 if (peer_address->validated != GNUNET_YES)
3760 GNUNET_STATISTICS_update (stats, 3720 GNUNET_STATISTICS_update (stats,
@@ -3804,8 +3764,9 @@ schedule_next_ping (struct ForeignAddressList *fal)
3804 3764
3805 if (GNUNET_YES == fal->connected) 3765 if (GNUNET_YES == fal->connected)
3806 { 3766 {
3807 delay = GNUNET_TIME_relative_min (delay, 3767 delay =
3808 CONNECTED_LATENCY_EVALUATION_MAX_DELAY); 3768 GNUNET_TIME_relative_min (delay,
3769 CONNECTED_LATENCY_EVALUATION_MAX_DELAY);
3809 } 3770 }
3810 /* FIXME: also adjust delay based on how close the last 3771 /* FIXME: also adjust delay based on how close the last
3811 * observed latency is to the latency of the best alternative */ 3772 * observed latency is to the latency of the best alternative */
@@ -3816,9 +3777,8 @@ schedule_next_ping (struct ForeignAddressList *fal)
3816 GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 1000); 3777 GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 1000);
3817 3778
3818 GNUNET_assert (fal->revalidate_task == GNUNET_SCHEDULER_NO_TASK); 3779 GNUNET_assert (fal->revalidate_task == GNUNET_SCHEDULER_NO_TASK);
3819 fal->revalidate_task = GNUNET_SCHEDULER_add_delayed (delay, 3780 fal->revalidate_task =
3820 &send_periodic_ping, 3781 GNUNET_SCHEDULER_add_delayed (delay, &send_periodic_ping, fal);
3821 fal);
3822} 3782}
3823 3783
3824 3784
@@ -3845,8 +3805,8 @@ handle_payload_message (const struct GNUNET_MessageHeader *message,
3845#if DEBUG_TRANSPORT 3805#if DEBUG_TRANSPORT
3846 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 3806 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
3847 "Received message of type %u and size %u from `%4s', but no pong yet!\n", 3807 "Received message of type %u and size %u from `%4s', but no pong yet!\n",
3848 ntohs (message->type), 3808 ntohs (message->type), ntohs (message->size),
3849 ntohs (message->size), GNUNET_i2s (&n->id)); 3809 GNUNET_i2s (&n->id));
3850#endif 3810#endif
3851 GNUNET_free_non_null (n->pre_connect_message_buffer); 3811 GNUNET_free_non_null (n->pre_connect_message_buffer);
3852 n->pre_connect_message_buffer = GNUNET_malloc (msize); 3812 n->pre_connect_message_buffer = GNUNET_malloc (msize);
@@ -3857,11 +3817,11 @@ handle_payload_message (const struct GNUNET_MessageHeader *message,
3857#if DEBUG_TRANSPORT 3817#if DEBUG_TRANSPORT
3858 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 3818 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
3859 "Received message of type %u and size %u from `%4s', sending to all clients.\n", 3819 "Received message of type %u and size %u from `%4s', sending to all clients.\n",
3860 ntohs (message->type), 3820 ntohs (message->type), ntohs (message->size),
3861 ntohs (message->size), GNUNET_i2s (&n->id)); 3821 GNUNET_i2s (&n->id));
3862#endif 3822#endif
3863 if (GNUNET_YES == GNUNET_BANDWIDTH_tracker_consume (&n->in_tracker, 3823 if (GNUNET_YES ==
3864 (ssize_t) msize)) 3824 GNUNET_BANDWIDTH_tracker_consume (&n->in_tracker, (ssize_t) msize))
3865 { 3825 {
3866 n->quota_violation_count++; 3826 n->quota_violation_count++;
3867#if DEBUG_TRANSPORT 3827#if DEBUG_TRANSPORT
@@ -3956,12 +3916,10 @@ check_pending_validation (void *cls, const GNUNET_HashCode * key, void *value)
3956 addr = (const char *) &pong[1]; 3916 addr = (const char *) &pong[1];
3957 slen = strlen (ve->transport_name) + 1; 3917 slen = strlen (ve->transport_name) + 1;
3958 if ((ps - sizeof (struct TransportPongMessage) < slen) || 3918 if ((ps - sizeof (struct TransportPongMessage) < slen) ||
3959 (ve->challenge != challenge) || 3919 (ve->challenge != challenge) || (addr[slen - 1] != '\0') ||
3960 (addr[slen - 1] != '\0') ||
3961 (0 != strcmp (addr, ve->transport_name)) || 3920 (0 != strcmp (addr, ve->transport_name)) ||
3962 (ntohl (pong->purpose.size) 3921 (ntohl (pong->purpose.size) !=
3963 != sizeof (struct GNUNET_CRYPTO_RsaSignaturePurpose) + 3922 sizeof (struct GNUNET_CRYPTO_RsaSignaturePurpose) + sizeof (uint32_t) +
3964 sizeof (uint32_t) +
3965 sizeof (struct GNUNET_TIME_AbsoluteNBO) + 3923 sizeof (struct GNUNET_TIME_AbsoluteNBO) +
3966 sizeof (struct GNUNET_PeerIdentity) + ps - 3924 sizeof (struct GNUNET_PeerIdentity) + ps -
3967 sizeof (struct TransportPongMessage))) 3925 sizeof (struct TransportPongMessage)))
@@ -3985,8 +3943,8 @@ check_pending_validation (void *cls, const GNUNET_HashCode * key, void *value)
3985 } 3943 }
3986 if (GNUNET_OK != 3944 if (GNUNET_OK !=
3987 GNUNET_CRYPTO_rsa_verify (GNUNET_SIGNATURE_PURPOSE_TRANSPORT_PONG_OWN, 3945 GNUNET_CRYPTO_rsa_verify (GNUNET_SIGNATURE_PURPOSE_TRANSPORT_PONG_OWN,
3988 &pong->purpose, 3946 &pong->purpose, &pong->signature,
3989 &pong->signature, &ve->publicKey)) 3947 &ve->publicKey))
3990 { 3948 {
3991 GNUNET_break_op (0); 3949 GNUNET_break_op (0);
3992 return GNUNET_NO; 3950 return GNUNET_NO;
@@ -3995,15 +3953,14 @@ check_pending_validation (void *cls, const GNUNET_HashCode * key, void *value)
3995#if DEBUG_TRANSPORT 3953#if DEBUG_TRANSPORT
3996 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 3954 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
3997 "Confirmed validity of address, peer `%4s' has address `%s' (%s).\n", 3955 "Confirmed validity of address, peer `%4s' has address `%s' (%s).\n",
3998 GNUNET_h2s (key), 3956 GNUNET_h2s (key), a2s (ve->transport_name,
3999 a2s (ve->transport_name, 3957 (const struct sockaddr *) ve->addr,
4000 (const struct sockaddr *) ve->addr, 3958 ve->addrlen), ve->transport_name);
4001 ve->addrlen), ve->transport_name);
4002#endif 3959#endif
4003 break; 3960 break;
4004 case GNUNET_SIGNATURE_PURPOSE_TRANSPORT_PONG_USING: 3961 case GNUNET_SIGNATURE_PURPOSE_TRANSPORT_PONG_USING:
4005 if (0 != memcmp (&pong->pid, 3962 if (0 !=
4006 &my_identity, sizeof (struct GNUNET_PeerIdentity))) 3963 memcmp (&pong->pid, &my_identity, sizeof (struct GNUNET_PeerIdentity)))
4007 { 3964 {
4008 char *peer; 3965 char *peer;
4009 3966
@@ -4050,8 +4007,8 @@ check_pending_validation (void *cls, const GNUNET_HashCode * key, void *value)
4050 } 4007 }
4051 if (GNUNET_OK != 4008 if (GNUNET_OK !=
4052 GNUNET_CRYPTO_rsa_verify (GNUNET_SIGNATURE_PURPOSE_TRANSPORT_PONG_USING, 4009 GNUNET_CRYPTO_rsa_verify (GNUNET_SIGNATURE_PURPOSE_TRANSPORT_PONG_USING,
4053 &pong->purpose, 4010 &pong->purpose, &pong->signature,
4054 &pong->signature, &ve->publicKey)) 4011 &ve->publicKey))
4055 { 4012 {
4056 GNUNET_break_op (0); 4013 GNUNET_break_op (0);
4057 return GNUNET_NO; 4014 return GNUNET_NO;
@@ -4060,9 +4017,8 @@ check_pending_validation (void *cls, const GNUNET_HashCode * key, void *value)
4060#if DEBUG_TRANSPORT 4017#if DEBUG_TRANSPORT
4061 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 4018 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
4062 "Confirmed that peer `%4s' is talking to us using address `%s' (%s) for us.\n", 4019 "Confirmed that peer `%4s' is talking to us using address `%s' (%s) for us.\n",
4063 GNUNET_h2s (key), 4020 GNUNET_h2s (key), a2s (ve->transport_name, &addr[slen], alen),
4064 a2s (ve->transport_name, 4021 ve->transport_name);
4065 &addr[slen], alen), ve->transport_name);
4066#endif 4022#endif
4067 break; 4023 break;
4068 default: 4024 default:
@@ -4077,8 +4033,8 @@ check_pending_validation (void *cls, const GNUNET_HashCode * key, void *value)
4077 return GNUNET_NO; 4033 return GNUNET_NO;
4078 } 4034 }
4079 GNUNET_STATISTICS_update (stats, 4035 GNUNET_STATISTICS_update (stats,
4080 gettext_noop ("# address validation successes"), 4036 gettext_noop ("# address validation successes"), 1,
4081 1, GNUNET_NO); 4037 GNUNET_NO);
4082 /* create the updated HELLO */ 4038 /* create the updated HELLO */
4083 GNUNET_CRYPTO_hash (&ve->publicKey, 4039 GNUNET_CRYPTO_hash (&ve->publicKey,
4084 sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded), 4040 sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded),
@@ -4096,9 +4052,9 @@ check_pending_validation (void *cls, const GNUNET_HashCode * key, void *value)
4096 { 4052 {
4097 n->publicKey = ve->publicKey; 4053 n->publicKey = ve->publicKey;
4098 n->public_key_valid = GNUNET_YES; 4054 n->public_key_valid = GNUNET_YES;
4099 fal = add_peer_address (n, 4055 fal =
4100 ve->transport_name, 4056 add_peer_address (n, ve->transport_name, ve->session, ve->addr,
4101 ve->session, ve->addr, ve->addrlen); 4057 ve->addrlen);
4102 GNUNET_assert (fal != NULL); 4058 GNUNET_assert (fal != NULL);
4103 fal->expires = GNUNET_TIME_relative_to_absolute (HELLO_ADDRESS_EXPIRATION); 4059 fal->expires = GNUNET_TIME_relative_to_absolute (HELLO_ADDRESS_EXPIRATION);
4104 fal->validated = GNUNET_YES; 4060 fal->validated = GNUNET_YES;
@@ -4109,9 +4065,8 @@ check_pending_validation (void *cls, const GNUNET_HashCode * key, void *value)
4109 GNUNET_NO); 4065 GNUNET_NO);
4110 fal->latency = GNUNET_TIME_absolute_get_duration (ve->send_time); 4066 fal->latency = GNUNET_TIME_absolute_get_duration (ve->send_time);
4111 update_addr_value (fal, 4067 update_addr_value (fal,
4112 GNUNET_TIME_absolute_get_duration (ve-> 4068 GNUNET_TIME_absolute_get_duration (ve->send_time).
4113 send_time).rel_value, 4069 rel_value, GNUNET_TRANSPORT_ATS_QUALITY_NET_DELAY);
4114 GNUNET_TRANSPORT_ATS_QUALITY_NET_DELAY);
4115 4070
4116 schedule_next_ping (fal); 4071 schedule_next_ping (fal);
4117 if (n->latency.rel_value == GNUNET_TIME_UNIT_FOREVER_REL.rel_value) 4072 if (n->latency.rel_value == GNUNET_TIME_UNIT_FOREVER_REL.rel_value)
@@ -4142,8 +4097,8 @@ check_pending_validation (void *cls, const GNUNET_HashCode * key, void *value)
4142 4097
4143 /* clean up validation entry */ 4098 /* clean up validation entry */
4144 GNUNET_assert (GNUNET_YES == 4099 GNUNET_assert (GNUNET_YES ==
4145 GNUNET_CONTAINER_multihashmap_remove (validation_map, 4100 GNUNET_CONTAINER_multihashmap_remove (validation_map, key,
4146 key, ve)); 4101 ve));
4147 abort_validation (NULL, NULL, ve); 4102 abort_validation (NULL, NULL, ve);
4148 return GNUNET_NO; 4103 return GNUNET_NO;
4149} 4104}
@@ -4166,26 +4121,24 @@ check_pending_validation (void *cls, const GNUNET_HashCode * key, void *value)
4166 */ 4121 */
4167static void 4122static void
4168handle_pong (void *cls, const struct GNUNET_MessageHeader *message, 4123handle_pong (void *cls, const struct GNUNET_MessageHeader *message,
4169 const struct GNUNET_PeerIdentity *peer, 4124 const struct GNUNET_PeerIdentity *peer, const char *sender_address,
4170 const char *sender_address, size_t sender_address_len) 4125 size_t sender_address_len)
4171{ 4126{
4172 if (0 == memcmp (peer, &my_identity, sizeof (struct GNUNET_PeerIdentity))) 4127 if (0 == memcmp (peer, &my_identity, sizeof (struct GNUNET_PeerIdentity)))
4173 { 4128 {
4174 /* PONG send to self, ignore */ 4129 /* PONG send to self, ignore */
4175 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 4130 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Receiving `%s' message from myself\n",
4176 "Receiving `%s' message from myself\n", "PONG"); 4131 "PONG");
4177 return; 4132 return;
4178 } 4133 }
4179#if DEBUG_TRANSPORT > 1 4134#if DEBUG_TRANSPORT > 1
4180 /* we get tons of these that just get discarded, only log 4135 /* we get tons of these that just get discarded, only log
4181 * if we are quite verbose */ 4136 * if we are quite verbose */
4182 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 4137 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Receiving `%s' message from `%4s'.\n",
4183 "Receiving `%s' message from `%4s'.\n", "PONG", 4138 "PONG", GNUNET_i2s (peer));
4184 GNUNET_i2s (peer));
4185#endif 4139#endif
4186 GNUNET_STATISTICS_update (stats, 4140 GNUNET_STATISTICS_update (stats, gettext_noop ("# PONG messages received"), 1,
4187 gettext_noop ("# PONG messages received"), 4141 GNUNET_NO);
4188 1, GNUNET_NO);
4189 if (GNUNET_SYSERR != 4142 if (GNUNET_SYSERR !=
4190 GNUNET_CONTAINER_multihashmap_get_multiple (validation_map, 4143 GNUNET_CONTAINER_multihashmap_get_multiple (validation_map,
4191 &peer->hashPubKey, 4144 &peer->hashPubKey,
@@ -4241,9 +4194,9 @@ transmit_hello_and_ping (void *cls, struct NeighbourMapEntry *neighbour)
4241 } 4194 }
4242 neighbour->publicKey = va->publicKey; 4195 neighbour->publicKey = va->publicKey;
4243 neighbour->public_key_valid = GNUNET_YES; 4196 neighbour->public_key_valid = GNUNET_YES;
4244 peer_address = add_peer_address (neighbour, 4197 peer_address =
4245 va->transport_name, NULL, 4198 add_peer_address (neighbour, va->transport_name, NULL,
4246 (const void *) &va[1], va->addrlen); 4199 (const void *) &va[1], va->addrlen);
4247 if (peer_address == NULL) 4200 if (peer_address == NULL)
4248 { 4201 {
4249 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 4202 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
@@ -4268,8 +4221,8 @@ transmit_hello_and_ping (void *cls, struct NeighbourMapEntry *neighbour)
4268 ping.header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_PING); 4221 ping.header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_PING);
4269 memcpy (&ping.target, &neighbour->id, sizeof (struct GNUNET_PeerIdentity)); 4222 memcpy (&ping.target, &neighbour->id, sizeof (struct GNUNET_PeerIdentity));
4270 memcpy (message_buf, our_hello, hello_size); 4223 memcpy (message_buf, our_hello, hello_size);
4271 memcpy (&message_buf[hello_size], 4224 memcpy (&message_buf[hello_size], &ping,
4272 &ping, sizeof (struct TransportPingMessage)); 4225 sizeof (struct TransportPingMessage));
4273 memcpy (&message_buf[hello_size + sizeof (struct TransportPingMessage)], 4226 memcpy (&message_buf[hello_size + sizeof (struct TransportPingMessage)],
4274 va->transport_name, slen); 4227 va->transport_name, slen);
4275 memcpy (&message_buf 4228 memcpy (&message_buf
@@ -4278,14 +4231,11 @@ transmit_hello_and_ping (void *cls, struct NeighbourMapEntry *neighbour)
4278#if DEBUG_TRANSPORT 4231#if DEBUG_TRANSPORT
4279 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 4232 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
4280 "Performing validation of address `%s' via `%s' for peer `%4s' sending `%s' (%u bytes) and `%s' (%u bytes)\n", 4233 "Performing validation of address `%s' via `%s' for peer `%4s' sending `%s' (%u bytes) and `%s' (%u bytes)\n",
4281 (va->addrlen == 0) 4234 (va->addrlen == 0) ? "<inbound>" : a2s (va->transport_name,
4282 ? "<inbound>" 4235 (const void *) &va[1],
4283 : a2s (va->transport_name, 4236 va->addrlen),
4284 (const void *) &va[1], va->addrlen), 4237 va->transport_name, GNUNET_i2s (&neighbour->id), "HELLO",
4285 va->transport_name, 4238 hello_size, "PING",
4286 GNUNET_i2s (&neighbour->id),
4287 "HELLO", hello_size,
4288 "PING",
4289 sizeof (struct TransportPingMessage) + va->addrlen + slen); 4239 sizeof (struct TransportPingMessage) + va->addrlen + slen);
4290#endif 4240#endif
4291 4241
@@ -4313,10 +4263,9 @@ transmit_hello_and_ping (void *cls, struct NeighbourMapEntry *neighbour)
4313 * @return GNUNET_OK (always) 4263 * @return GNUNET_OK (always)
4314 */ 4264 */
4315static int 4265static int
4316run_validation (void *cls, 4266run_validation (void *cls, const char *tname,
4317 const char *tname, 4267 struct GNUNET_TIME_Absolute expiration, const void *addr,
4318 struct GNUNET_TIME_Absolute expiration, 4268 uint16_t addrlen)
4319 const void *addr, uint16_t addrlen)
4320{ 4269{
4321 struct CheckHelloValidatedContext *chvc = cls; 4270 struct CheckHelloValidatedContext *chvc = cls;
4322 struct GNUNET_PeerIdentity id; 4271 struct GNUNET_PeerIdentity id;
@@ -4335,8 +4284,7 @@ run_validation (void *cls,
4335 tp = find_transport (tname); 4284 tp = find_transport (tname);
4336 if (tp == NULL) 4285 if (tp == NULL)
4337 { 4286 {
4338 GNUNET_log (GNUNET_ERROR_TYPE_INFO | 4287 GNUNET_log (GNUNET_ERROR_TYPE_INFO | GNUNET_ERROR_TYPE_BULK,
4339 GNUNET_ERROR_TYPE_BULK,
4340 _ 4288 _
4341 ("Transport `%s' not loaded, will not try to validate peer address using this transport.\n"), 4289 ("Transport `%s' not loaded, will not try to validate peer address using this transport.\n"),
4342 tname); 4290 tname);
@@ -4363,8 +4311,7 @@ run_validation (void *cls,
4363 } 4311 }
4364 GNUNET_HELLO_get_key (chvc->hello, &pk); 4312 GNUNET_HELLO_get_key (chvc->hello, &pk);
4365 GNUNET_CRYPTO_hash (&pk, 4313 GNUNET_CRYPTO_hash (&pk,
4366 sizeof (struct 4314 sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded),
4367 GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded),
4368 &id.hashPubKey); 4315 &id.hashPubKey);
4369 4316
4370 if (is_blacklisted (&id, tp)) 4317 if (is_blacklisted (&id, tp))
@@ -4382,8 +4329,8 @@ run_validation (void *cls,
4382 caec.session = NULL; 4329 caec.session = NULL;
4383 caec.tname = tname; 4330 caec.tname = tname;
4384 caec.exists = GNUNET_NO; 4331 caec.exists = GNUNET_NO;
4385 GNUNET_CONTAINER_multihashmap_iterate (validation_map, 4332 GNUNET_CONTAINER_multihashmap_iterate (validation_map, &check_address_exists,
4386 &check_address_exists, &caec); 4333 &caec);
4387 if (caec.exists == GNUNET_YES) 4334 if (caec.exists == GNUNET_YES)
4388 { 4335 {
4389 /* During validation attempts we will likely trigger the other 4336 /* During validation attempts we will likely trigger the other
@@ -4405,19 +4352,17 @@ run_validation (void *cls,
4405 va->chvc = chvc; 4352 va->chvc = chvc;
4406 chvc->ve_count++; 4353 chvc->ve_count++;
4407 va->transport_name = GNUNET_strdup (tname); 4354 va->transport_name = GNUNET_strdup (tname);
4408 va->challenge = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_NONCE, 4355 va->challenge =
4409 UINT_MAX); 4356 GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_NONCE, UINT_MAX);
4410 va->send_time = GNUNET_TIME_absolute_get (); 4357 va->send_time = GNUNET_TIME_absolute_get ();
4411 va->addr = (const void *) &va[1]; 4358 va->addr = (const void *) &va[1];
4412 memcpy (&va[1], addr, addrlen); 4359 memcpy (&va[1], addr, addrlen);
4413 va->addrlen = addrlen; 4360 va->addrlen = addrlen;
4414 GNUNET_HELLO_get_key (chvc->hello, &va->publicKey); 4361 GNUNET_HELLO_get_key (chvc->hello, &va->publicKey);
4415 va->timeout_task = GNUNET_SCHEDULER_add_delayed (HELLO_VERIFICATION_TIMEOUT, 4362 va->timeout_task =
4416 &timeout_hello_validation, 4363 GNUNET_SCHEDULER_add_delayed (HELLO_VERIFICATION_TIMEOUT,
4417 va); 4364 &timeout_hello_validation, va);
4418 GNUNET_CONTAINER_multihashmap_put (validation_map, 4365 GNUNET_CONTAINER_multihashmap_put (validation_map, &id.hashPubKey, va,
4419 &id.hashPubKey,
4420 va,
4421 GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE); 4366 GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE);
4422 setup_peer_check_blacklist (&id, GNUNET_NO, &transmit_hello_and_ping, va); 4367 setup_peer_check_blacklist (&id, GNUNET_NO, &transmit_hello_and_ping, va);
4423 return GNUNET_OK; 4368 return GNUNET_OK;
@@ -4434,8 +4379,7 @@ run_validation (void *cls,
4434 * @param err_msg NULL if successful, otherwise contains error message 4379 * @param err_msg NULL if successful, otherwise contains error message
4435 */ 4380 */
4436static void 4381static void
4437check_hello_validated (void *cls, 4382check_hello_validated (void *cls, const struct GNUNET_PeerIdentity *peer,
4438 const struct GNUNET_PeerIdentity *peer,
4439 const struct GNUNET_HELLO_Message *h, 4383 const struct GNUNET_HELLO_Message *h,
4440 const char *err_msg) 4384 const char *err_msg)
4441{ 4385{
@@ -4515,8 +4459,8 @@ check_hello_validated (void *cls,
4515 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 4459 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
4516 "Calling hello_iterate_addresses for %s!\n", GNUNET_i2s (peer)); 4460 "Calling hello_iterate_addresses for %s!\n", GNUNET_i2s (peer));
4517#endif 4461#endif
4518 GNUNET_HELLO_iterate_addresses (h, 4462 GNUNET_HELLO_iterate_addresses (h, GNUNET_NO, &add_to_foreign_address_list,
4519 GNUNET_NO, &add_to_foreign_address_list, n); 4463 n);
4520 try_transmission_to_peer (n); 4464 try_transmission_to_peer (n);
4521 } 4465 }
4522 else 4466 else
@@ -4533,8 +4477,7 @@ check_hello_validated (void *cls,
4533 GNUNET_STATISTICS_update (stats, 4477 GNUNET_STATISTICS_update (stats,
4534 gettext_noop ("# HELLO validations (update case)"), 4478 gettext_noop ("# HELLO validations (update case)"),
4535 1, GNUNET_NO); 4479 1, GNUNET_NO);
4536 GNUNET_HELLO_iterate_new_addresses (chvc->hello, 4480 GNUNET_HELLO_iterate_new_addresses (chvc->hello, h,
4537 h,
4538 GNUNET_TIME_relative_to_absolute 4481 GNUNET_TIME_relative_to_absolute
4539 (HELLO_REVALIDATION_START_TIME), 4482 (HELLO_REVALIDATION_START_TIME),
4540 &run_validation, chvc); 4483 &run_validation, chvc);
@@ -4579,8 +4522,8 @@ process_hello (struct TransportPlugin *plugin,
4579 { 4522 {
4580#if DEBUG_TRANSPORT_HELLO 4523#if DEBUG_TRANSPORT_HELLO
4581 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 4524 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
4582 "Unable to get public key from `%s' for `%4s'!\n", 4525 "Unable to get public key from `%s' for `%4s'!\n", "HELLO",
4583 "HELLO", GNUNET_i2s (&target)); 4526 GNUNET_i2s (&target));
4584#endif 4527#endif
4585 GNUNET_break_op (0); 4528 GNUNET_break_op (0);
4586 return GNUNET_SYSERR; 4529 return GNUNET_SYSERR;
@@ -4590,8 +4533,7 @@ process_hello (struct TransportPlugin *plugin,
4590 &target.hashPubKey); 4533 &target.hashPubKey);
4591 4534
4592#if DEBUG_TRANSPORT_HELLO 4535#if DEBUG_TRANSPORT_HELLO
4593 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 4536 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received `%s' message for `%4s'\n",
4594 "Received `%s' message for `%4s'\n",
4595 "HELLO", GNUNET_i2s (&target)); 4537 "HELLO", GNUNET_i2s (&target));
4596#endif 4538#endif
4597 if (0 == memcmp (&my_identity, &target, sizeof (struct GNUNET_PeerIdentity))) 4539 if (0 == memcmp (&my_identity, &target, sizeof (struct GNUNET_PeerIdentity)))
@@ -4619,8 +4561,8 @@ process_hello (struct TransportPlugin *plugin,
4619 GNUNET_NO); 4561 GNUNET_NO);
4620#if DEBUG_TRANSPORT_HELLO 4562#if DEBUG_TRANSPORT_HELLO
4621 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 4563 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
4622 "Ignoring `%s' for `%4s', load too high.\n", 4564 "Ignoring `%s' for `%4s', load too high.\n", "HELLO",
4623 "HELLO", GNUNET_i2s (&target)); 4565 GNUNET_i2s (&target));
4624#endif 4566#endif
4625 return GNUNET_OK; 4567 return GNUNET_OK;
4626 } 4568 }
@@ -4629,9 +4571,8 @@ process_hello (struct TransportPlugin *plugin,
4629 chvc = chvc_head; 4571 chvc = chvc_head;
4630 while (NULL != chvc) 4572 while (NULL != chvc)
4631 { 4573 {
4632 if (GNUNET_HELLO_equals (hello, 4574 if (GNUNET_HELLO_equals (hello, chvc->hello, GNUNET_TIME_absolute_get ()).
4633 chvc->hello, 4575 abs_value > 0)
4634 GNUNET_TIME_absolute_get ()).abs_value > 0)
4635 { 4576 {
4636#if DEBUG_TRANSPORT_HELLO > 2 4577#if DEBUG_TRANSPORT_HELLO > 2
4637 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 4578 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
@@ -4641,8 +4582,8 @@ process_hello (struct TransportPlugin *plugin,
4641 return GNUNET_OK; /* validation already pending */ 4582 return GNUNET_OK; /* validation already pending */
4642 } 4583 }
4643 if (GNUNET_HELLO_size (hello) == GNUNET_HELLO_size (chvc->hello)) 4584 if (GNUNET_HELLO_size (hello) == GNUNET_HELLO_size (chvc->hello))
4644 GNUNET_break (0 != memcmp (hello, chvc->hello, 4585 GNUNET_break (0 !=
4645 GNUNET_HELLO_size (hello))); 4586 memcmp (hello, chvc->hello, GNUNET_HELLO_size (hello)));
4646 chvc = chvc->next; 4587 chvc = chvc->next;
4647 } 4588 }
4648 4589
@@ -4663,10 +4604,8 @@ process_hello (struct TransportPlugin *plugin,
4663 my_id = GNUNET_strdup (GNUNET_i2s (plugin->env.my_identity)); 4604 my_id = GNUNET_strdup (GNUNET_i2s (plugin->env.my_identity));
4664 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 4605 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
4665 "%s: Starting validation of `%s' message for `%4s' via '%s' of size %u\n", 4606 "%s: Starting validation of `%s' message for `%4s' via '%s' of size %u\n",
4666 my_id, 4607 my_id, "HELLO", GNUNET_i2s (&target), plugin->short_name,
4667 "HELLO", 4608 GNUNET_HELLO_size (hello));
4668 GNUNET_i2s (&target),
4669 plugin->short_name, GNUNET_HELLO_size (hello));
4670 GNUNET_free (my_id); 4609 GNUNET_free (my_id);
4671#endif 4610#endif
4672 } 4611 }
@@ -4768,8 +4707,7 @@ disconnect_neighbour (struct NeighbourMapEntry *n, int check)
4768 rpos->addresses = peer_pos->next; 4707 rpos->addresses = peer_pos->next;
4769 if (peer_pos->connected == GNUNET_YES) 4708 if (peer_pos->connected == GNUNET_YES)
4770 { 4709 {
4771 GNUNET_STATISTICS_update (stats, 4710 GNUNET_STATISTICS_update (stats, gettext_noop ("# connected addresses"),
4772 gettext_noop ("# connected addresses"),
4773 -1, GNUNET_NO); 4711 -1, GNUNET_NO);
4774 peer_pos->connected = GNUNET_NO; 4712 peer_pos->connected = GNUNET_NO;
4775 } 4713 }
@@ -4804,8 +4742,9 @@ disconnect_neighbour (struct NeighbourMapEntry *n, int check)
4804 ("# bytes discarded due to disconnect"), 4742 ("# bytes discarded due to disconnect"),
4805 mq->message_buf_size, GNUNET_NO); 4743 mq->message_buf_size, GNUNET_NO);
4806 GNUNET_CONTAINER_DLL_remove (n->messages_head, n->messages_tail, mq); 4744 GNUNET_CONTAINER_DLL_remove (n->messages_head, n->messages_tail, mq);
4807 GNUNET_assert (0 == memcmp (&mq->neighbour_id, 4745 GNUNET_assert (0 ==
4808 &n->id, sizeof (struct GNUNET_PeerIdentity))); 4746 memcmp (&mq->neighbour_id, &n->id,
4747 sizeof (struct GNUNET_PeerIdentity)));
4809 GNUNET_free (mq); 4748 GNUNET_free (mq);
4810 } 4749 }
4811 4750
@@ -4813,8 +4752,9 @@ disconnect_neighbour (struct NeighbourMapEntry *n, int check)
4813 { 4752 {
4814 4753
4815 GNUNET_CONTAINER_DLL_remove (n->cont_head, n->cont_tail, mq); 4754 GNUNET_CONTAINER_DLL_remove (n->cont_head, n->cont_tail, mq);
4816 GNUNET_assert (0 == memcmp (&mq->neighbour_id, 4755 GNUNET_assert (0 ==
4817 &n->id, sizeof (struct GNUNET_PeerIdentity))); 4756 memcmp (&mq->neighbour_id, &n->id,
4757 sizeof (struct GNUNET_PeerIdentity)));
4818 GNUNET_free (mq); 4758 GNUNET_free (mq);
4819 } 4759 }
4820 4760
@@ -4842,9 +4782,8 @@ disconnect_neighbour (struct NeighbourMapEntry *n, int check)
4842 GNUNET_CONTAINER_multihashmap_remove (neighbours, 4782 GNUNET_CONTAINER_multihashmap_remove (neighbours,
4843 &n->id.hashPubKey, n)); 4783 &n->id.hashPubKey, n));
4844 /* finally, free n itself */ 4784 /* finally, free n itself */
4845 GNUNET_STATISTICS_update (stats, 4785 GNUNET_STATISTICS_update (stats, gettext_noop ("# active neighbours"), -1,
4846 gettext_noop ("# active neighbours"), 4786 GNUNET_NO);
4847 -1, GNUNET_NO);
4848 GNUNET_free_non_null (n->pre_connect_message_buffer); 4787 GNUNET_free_non_null (n->pre_connect_message_buffer);
4849 GNUNET_free (n); 4788 GNUNET_free (n);
4850} 4789}
@@ -4856,8 +4795,7 @@ disconnect_neighbour (struct NeighbourMapEntry *n, int check)
4856 */ 4795 */
4857static int 4796static int
4858handle_ping (void *cls, const struct GNUNET_MessageHeader *message, 4797handle_ping (void *cls, const struct GNUNET_MessageHeader *message,
4859 const struct GNUNET_PeerIdentity *peer, 4798 const struct GNUNET_PeerIdentity *peer, struct Session *session,
4860 struct Session *session,
4861 const char *sender_address, uint16_t sender_address_len) 4799 const char *sender_address, uint16_t sender_address_len)
4862{ 4800{
4863 struct TransportPlugin *plugin = cls; 4801 struct TransportPlugin *plugin = cls;
@@ -4880,9 +4818,9 @@ handle_ping (void *cls, const struct GNUNET_MessageHeader *message,
4880 } 4818 }
4881 4819
4882 ping = (struct TransportPingMessage *) message; 4820 ping = (struct TransportPingMessage *) message;
4883 if (0 != memcmp (&ping->target, 4821 if (0 !=
4884 plugin->env.my_identity, 4822 memcmp (&ping->target, plugin->env.my_identity,
4885 sizeof (struct GNUNET_PeerIdentity))) 4823 sizeof (struct GNUNET_PeerIdentity)))
4886 { 4824 {
4887#if DEBUG_TRANSPORT 4825#if DEBUG_TRANSPORT
4888 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 4826 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
@@ -4898,16 +4836,15 @@ handle_ping (void *cls, const struct GNUNET_MessageHeader *message,
4898 } 4836 }
4899#if DEBUG_PING_PONG 4837#if DEBUG_PING_PONG
4900 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG | GNUNET_ERROR_TYPE_BULK, 4838 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG | GNUNET_ERROR_TYPE_BULK,
4901 "Processing `%s' from `%s'\n", 4839 "Processing `%s' from `%s'\n", "PING",
4902 "PING", 4840 (sender_address != NULL) ? a2s (plugin->short_name,
4903 (sender_address != NULL) 4841 (const struct sockaddr *)
4904 ? a2s (plugin->short_name, 4842 sender_address,
4905 (const struct sockaddr *) sender_address, 4843 sender_address_len) :
4906 sender_address_len) : "<inbound>"); 4844 "<inbound>");
4907#endif 4845#endif
4908 GNUNET_STATISTICS_update (stats, 4846 GNUNET_STATISTICS_update (stats, gettext_noop ("# PING messages received"), 1,
4909 gettext_noop ("# PING messages received"), 4847 GNUNET_NO);
4910 1, GNUNET_NO);
4911 addr = (const char *) &ping[1]; 4848 addr = (const char *) &ping[1];
4912 alen = ntohs (message->size) - sizeof (struct TransportPingMessage); 4849 alen = ntohs (message->size) - sizeof (struct TransportPingMessage);
4913 slen = strlen (plugin->short_name) + 1; 4850 slen = strlen (plugin->short_name) + 1;
@@ -4930,8 +4867,8 @@ handle_ping (void *cls, const struct GNUNET_MessageHeader *message,
4930 */ 4867 */
4931 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 4868 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
4932 "Creating PONG indicating that we received a connection at our address `%s' from `%s'.\n", 4869 "Creating PONG indicating that we received a connection at our address `%s' from `%s'.\n",
4933 a2s (plugin->short_name, 4870 a2s (plugin->short_name, sender_address, sender_address_len),
4934 sender_address, sender_address_len), GNUNET_i2s (peer)); 4871 GNUNET_i2s (peer));
4935 4872
4936 pong = 4873 pong =
4937 GNUNET_malloc (sizeof (struct TransportPongMessage) + 4874 GNUNET_malloc (sizeof (struct TransportPongMessage) +
@@ -4942,8 +4879,7 @@ handle_ping (void *cls, const struct GNUNET_MessageHeader *message,
4942 pong->header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_PONG); 4879 pong->header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_PONG);
4943 pong->purpose.size = 4880 pong->purpose.size =
4944 htonl (sizeof (struct GNUNET_CRYPTO_RsaSignaturePurpose) + 4881 htonl (sizeof (struct GNUNET_CRYPTO_RsaSignaturePurpose) +
4945 sizeof (uint32_t) + 4882 sizeof (uint32_t) + sizeof (struct GNUNET_TIME_AbsoluteNBO) +
4946 sizeof (struct GNUNET_TIME_AbsoluteNBO) +
4947 sizeof (struct GNUNET_PeerIdentity) + sender_address_len + slen); 4883 sizeof (struct GNUNET_PeerIdentity) + sender_address_len + slen);
4948 pong->purpose.purpose = 4884 pong->purpose.purpose =
4949 htonl (GNUNET_SIGNATURE_PURPOSE_TRANSPORT_PONG_USING); 4885 htonl (GNUNET_SIGNATURE_PURPOSE_TRANSPORT_PONG_USING);
@@ -4953,9 +4889,8 @@ handle_ping (void *cls, const struct GNUNET_MessageHeader *message,
4953 memcpy (&pong[1], plugin->short_name, slen); 4889 memcpy (&pong[1], plugin->short_name, slen);
4954 if ((sender_address != NULL) && (sender_address_len > 0)) 4890 if ((sender_address != NULL) && (sender_address_len > 0))
4955 memcpy (&((char *) &pong[1])[slen], sender_address, sender_address_len); 4891 memcpy (&((char *) &pong[1])[slen], sender_address, sender_address_len);
4956 if (GNUNET_TIME_absolute_get_remaining 4892 if (GNUNET_TIME_absolute_get_remaining (session_header->pong_sig_expires).
4957 (session_header->pong_sig_expires).rel_value < 4893 rel_value < PONG_SIGNATURE_LIFETIME.rel_value / 4)
4958 PONG_SIGNATURE_LIFETIME.rel_value / 4)
4959 { 4894 {
4960 /* create / update cached sig */ 4895 /* create / update cached sig */
4961#if DEBUG_TRANSPORT 4896#if DEBUG_TRANSPORT
@@ -4975,8 +4910,7 @@ handle_ping (void *cls, const struct GNUNET_MessageHeader *message,
4975 pong->expiration = 4910 pong->expiration =
4976 GNUNET_TIME_absolute_hton (session_header->pong_sig_expires); 4911 GNUNET_TIME_absolute_hton (session_header->pong_sig_expires);
4977 } 4912 }
4978 memcpy (&pong->signature, 4913 memcpy (&pong->signature, &session_header->pong_signature,
4979 &session_header->pong_signature,
4980 sizeof (struct GNUNET_CRYPTO_RsaSignature)); 4914 sizeof (struct GNUNET_CRYPTO_RsaSignature));
4981 4915
4982 4916
@@ -5007,8 +4941,7 @@ handle_ping (void *cls, const struct GNUNET_MessageHeader *message,
5007 pong->header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_PONG); 4941 pong->header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_PONG);
5008 pong->purpose.size = 4942 pong->purpose.size =
5009 htonl (sizeof (struct GNUNET_CRYPTO_RsaSignaturePurpose) + 4943 htonl (sizeof (struct GNUNET_CRYPTO_RsaSignaturePurpose) +
5010 sizeof (uint32_t) + 4944 sizeof (uint32_t) + sizeof (struct GNUNET_TIME_AbsoluteNBO) +
5011 sizeof (struct GNUNET_TIME_AbsoluteNBO) +
5012 sizeof (struct GNUNET_PeerIdentity) + alen + slen); 4945 sizeof (struct GNUNET_PeerIdentity) + alen + slen);
5013 pong->purpose.purpose = htonl (GNUNET_SIGNATURE_PURPOSE_TRANSPORT_PONG_OWN); 4946 pong->purpose.purpose = htonl (GNUNET_SIGNATURE_PURPOSE_TRANSPORT_PONG_OWN);
5014 pong->challenge = ping->challenge; 4947 pong->challenge = ping->challenge;
@@ -5029,11 +4962,10 @@ handle_ping (void *cls, const struct GNUNET_MessageHeader *message,
5029 GNUNET_TIME_relative_to_absolute (PONG_SIGNATURE_LIFETIME); 4962 GNUNET_TIME_relative_to_absolute (PONG_SIGNATURE_LIFETIME);
5030 pong->expiration = GNUNET_TIME_absolute_hton (oal->pong_sig_expires); 4963 pong->expiration = GNUNET_TIME_absolute_hton (oal->pong_sig_expires);
5031 GNUNET_assert (GNUNET_OK == 4964 GNUNET_assert (GNUNET_OK ==
5032 GNUNET_CRYPTO_rsa_sign (my_private_key, 4965 GNUNET_CRYPTO_rsa_sign (my_private_key, &pong->purpose,
5033 &pong->purpose,
5034 &oal->pong_signature)); 4966 &oal->pong_signature));
5035 memcpy (&pong->signature, 4967 memcpy (&pong->signature, &oal->pong_signature,
5036 &oal->pong_signature, sizeof (struct GNUNET_CRYPTO_RsaSignature)); 4968 sizeof (struct GNUNET_CRYPTO_RsaSignature));
5037 } 4969 }
5038 else if (oal == NULL) 4970 else if (oal == NULL)
5039 { 4971 {
@@ -5049,8 +4981,8 @@ handle_ping (void *cls, const struct GNUNET_MessageHeader *message,
5049 { 4981 {
5050 /* can used cached version */ 4982 /* can used cached version */
5051 pong->expiration = GNUNET_TIME_absolute_hton (oal->pong_sig_expires); 4983 pong->expiration = GNUNET_TIME_absolute_hton (oal->pong_sig_expires);
5052 memcpy (&pong->signature, 4984 memcpy (&pong->signature, &oal->pong_signature,
5053 &oal->pong_signature, sizeof (struct GNUNET_CRYPTO_RsaSignature)); 4985 sizeof (struct GNUNET_CRYPTO_RsaSignature));
5054 } 4986 }
5055 } 4987 }
5056 n = find_neighbour (peer); 4988 n = find_neighbour (peer);
@@ -5063,15 +4995,13 @@ handle_ping (void *cls, const struct GNUNET_MessageHeader *message,
5063 fal = rl->addresses; 4995 fal = rl->addresses;
5064 while (fal != NULL) 4996 while (fal != NULL)
5065 { 4997 {
5066 if (-1 != rl->plugin->api->send (rl->plugin->api->cls, 4998 if (-1 !=
5067 peer, 4999 rl->plugin->api->send (rl->plugin->api->cls, peer,
5068 (const char *) pong, 5000 (const char *) pong, ntohs (pong->header.size),
5069 ntohs (pong->header.size), 5001 TRANSPORT_PONG_PRIORITY,
5070 TRANSPORT_PONG_PRIORITY, 5002 HELLO_VERIFICATION_TIMEOUT, fal->session,
5071 HELLO_VERIFICATION_TIMEOUT, 5003 fal->addr, fal->addrlen, GNUNET_SYSERR, NULL,
5072 fal->session, 5004 NULL))
5073 fal->addr,
5074 fal->addrlen, GNUNET_SYSERR, NULL, NULL))
5075 { 5005 {
5076 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 5006 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
5077 "Transmitted PONG to `%s' via reliable mechanism\n", 5007 "Transmitted PONG to `%s' via reliable mechanism\n",
@@ -5102,13 +5032,11 @@ handle_ping (void *cls, const struct GNUNET_MessageHeader *message,
5102 { 5032 {
5103 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 5033 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
5104 "Transmitting PONG to `%s' via unreliable mechanism `%s':%s\n", 5034 "Transmitting PONG to `%s' via unreliable mechanism `%s':%s\n",
5105 GNUNET_i2s (peer), 5035 GNUNET_i2s (peer), a2s (rl->plugin->short_name, fal->addr,
5106 a2s (rl->plugin->short_name, 5036 fal->addrlen),
5107 fal->addr, fal->addrlen), rl->plugin->short_name); 5037 rl->plugin->short_name);
5108 transmit_to_peer (NULL, fal, 5038 transmit_to_peer (NULL, fal, TRANSPORT_PONG_PRIORITY,
5109 TRANSPORT_PONG_PRIORITY, 5039 HELLO_VERIFICATION_TIMEOUT, (const char *) pong,
5110 HELLO_VERIFICATION_TIMEOUT,
5111 (const char *) pong,
5112 ntohs (pong->header.size), GNUNET_YES, n); 5040 ntohs (pong->header.size), GNUNET_YES, n);
5113 did_pong = GNUNET_YES; 5041 did_pong = GNUNET_YES;
5114 fal = fal->next; 5042 fal = fal->next;
@@ -5146,8 +5074,7 @@ static struct GNUNET_TIME_Relative
5146plugin_env_receive (void *cls, const struct GNUNET_PeerIdentity *peer, 5074plugin_env_receive (void *cls, const struct GNUNET_PeerIdentity *peer,
5147 const struct GNUNET_MessageHeader *message, 5075 const struct GNUNET_MessageHeader *message,
5148 const struct GNUNET_TRANSPORT_ATS_Information *ats_data, 5076 const struct GNUNET_TRANSPORT_ATS_Information *ats_data,
5149 uint32_t ats_count, 5077 uint32_t ats_count, struct Session *session,
5150 struct Session *session,
5151 const char *sender_address, uint16_t sender_address_len) 5078 const char *sender_address, uint16_t sender_address_len)
5152{ 5079{
5153 struct TransportPlugin *plugin = cls; 5080 struct TransportPlugin *plugin = cls;
@@ -5185,10 +5112,9 @@ plugin_env_receive (void *cls, const struct GNUNET_PeerIdentity *peer,
5185 if (message != NULL) 5112 if (message != NULL)
5186 { 5113 {
5187 if ((session != NULL) || (sender_address != NULL)) 5114 if ((session != NULL) || (sender_address != NULL))
5188 peer_address = add_peer_address (n, 5115 peer_address =
5189 plugin->short_name, 5116 add_peer_address (n, plugin->short_name, session, sender_address,
5190 session, 5117 sender_address_len);
5191 sender_address, sender_address_len);
5192 if (peer_address != NULL) 5118 if (peer_address != NULL)
5193 { 5119 {
5194 update_addr_ats (peer_address, ats_data, ats_count); 5120 update_addr_ats (peer_address, ats_data, ats_count);
@@ -5216,8 +5142,7 @@ plugin_env_receive (void *cls, const struct GNUNET_PeerIdentity *peer,
5216 GNUNET_SCHEDULER_add_now (&send_periodic_ping, peer_address); 5142 GNUNET_SCHEDULER_add_now (&send_periodic_ping, peer_address);
5217 5143
5218 } 5144 }
5219 peer_address->timeout 5145 peer_address->timeout =
5220 =
5221 GNUNET_TIME_relative_to_absolute 5146 GNUNET_TIME_relative_to_absolute
5222 (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT); 5147 (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT);
5223 } 5148 }
@@ -5239,8 +5164,7 @@ plugin_env_receive (void *cls, const struct GNUNET_PeerIdentity *peer,
5239 if (n->quota_violation_count > QUOTA_VIOLATION_DROP_THRESHOLD) 5164 if (n->quota_violation_count > QUOTA_VIOLATION_DROP_THRESHOLD)
5240 { 5165 {
5241 /* dropping message due to frequent inbound volume violations! */ 5166 /* dropping message due to frequent inbound volume violations! */
5242 GNUNET_log (GNUNET_ERROR_TYPE_WARNING | 5167 GNUNET_log (GNUNET_ERROR_TYPE_WARNING | GNUNET_ERROR_TYPE_BULK,
5243 GNUNET_ERROR_TYPE_BULK,
5244 _ 5168 _
5245 ("Dropping incoming message due to repeated bandwidth quota (%u b/s) violations (total of %u).\n"), 5169 ("Dropping incoming message due to repeated bandwidth quota (%u b/s) violations (total of %u).\n"),
5246 n->in_tracker.available_bytes_per_s__, 5170 n->in_tracker.available_bytes_per_s__,
@@ -5277,8 +5201,8 @@ plugin_env_receive (void *cls, const struct GNUNET_PeerIdentity *peer,
5277#if DEBUG_PING_PONG 5201#if DEBUG_PING_PONG
5278 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 5202 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
5279 "Received message of type %u and size %u from `%4s', sending to all clients.\n", 5203 "Received message of type %u and size %u from `%4s', sending to all clients.\n",
5280 ntohs (message->type), 5204 ntohs (message->type), ntohs (message->size),
5281 ntohs (message->size), GNUNET_i2s (peer)); 5205 GNUNET_i2s (peer));
5282#endif 5206#endif
5283 switch (ntohs (message->type)) 5207 switch (ntohs (message->type))
5284 { 5208 {
@@ -5311,13 +5235,12 @@ plugin_env_receive (void *cls, const struct GNUNET_PeerIdentity *peer,
5311#if DEBUG_TRANSPORT 5235#if DEBUG_TRANSPORT
5312 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 5236 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
5313 "Throttling read (%llu bytes excess at %u b/s), waiting %llu ms before reading more.\n", 5237 "Throttling read (%llu bytes excess at %u b/s), waiting %llu ms before reading more.\n",
5314 (unsigned long long) n-> 5238 (unsigned long long) n->in_tracker.
5315 in_tracker.consumption_since_last_update__, 5239 consumption_since_last_update__,
5316 (unsigned int) n->in_tracker.available_bytes_per_s__, 5240 (unsigned int) n->in_tracker.available_bytes_per_s__,
5317 (unsigned long long) ret.rel_value); 5241 (unsigned long long) ret.rel_value);
5318#endif 5242#endif
5319 GNUNET_STATISTICS_update (stats, 5243 GNUNET_STATISTICS_update (stats, gettext_noop ("# ms throttling suggested"),
5320 gettext_noop ("# ms throttling suggested"),
5321 (int64_t) ret.rel_value, GNUNET_NO); 5244 (int64_t) ret.rel_value, GNUNET_NO);
5322 } 5245 }
5323 return ret; 5246 return ret;
@@ -5325,8 +5248,8 @@ plugin_env_receive (void *cls, const struct GNUNET_PeerIdentity *peer,
5325 5248
5326 5249
5327static int 5250static int
5328notify_client_about_neighbour (void *cls, 5251notify_client_about_neighbour (void *cls, const GNUNET_HashCode * key,
5329 const GNUNET_HashCode * key, void *value) 5252 void *value)
5330{ 5253{
5331 struct TransportClient *c = cls; 5254 struct TransportClient *c = cls;
5332 struct NeighbourMapEntry *n = value; 5255 struct NeighbourMapEntry *n = value;
@@ -5371,8 +5294,7 @@ notify_client_about_neighbour (void *cls,
5371 * @param message the actual message 5294 * @param message the actual message
5372 */ 5295 */
5373static void 5296static void
5374handle_start (void *cls, 5297handle_start (void *cls, struct GNUNET_SERVER_Client *client,
5375 struct GNUNET_SERVER_Client *client,
5376 const struct GNUNET_MessageHeader *message) 5298 const struct GNUNET_MessageHeader *message)
5377{ 5299{
5378 const struct StartMessage *start; 5300 const struct StartMessage *start;
@@ -5380,8 +5302,8 @@ handle_start (void *cls,
5380 5302
5381 start = (const struct StartMessage *) message; 5303 start = (const struct StartMessage *) message;
5382#if DEBUG_TRANSPORT 5304#if DEBUG_TRANSPORT
5383 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 5305 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received `%s' request from client\n",
5384 "Received `%s' request from client\n", "START"); 5306 "START");
5385#endif 5307#endif
5386 c = clients; 5308 c = clients;
5387 while (c != NULL) 5309 while (c != NULL)
@@ -5396,8 +5318,9 @@ handle_start (void *cls,
5396 c = c->next; 5318 c = c->next;
5397 } 5319 }
5398 if ((GNUNET_NO != ntohl (start->do_check)) && 5320 if ((GNUNET_NO != ntohl (start->do_check)) &&
5399 (0 != memcmp (&start->self, 5321 (0 !=
5400 &my_identity, sizeof (struct GNUNET_PeerIdentity)))) 5322 memcmp (&start->self, &my_identity,
5323 sizeof (struct GNUNET_PeerIdentity))))
5401 { 5324 {
5402 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 5325 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
5403 _ 5326 _
@@ -5413,11 +5336,10 @@ handle_start (void *cls,
5413 if (our_hello != NULL) 5336 if (our_hello != NULL)
5414 { 5337 {
5415#if DEBUG_TRANSPORT 5338#if DEBUG_TRANSPORT
5416 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 5339 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending our own `%s' to new client\n",
5417 "Sending our own `%s' to new client\n", "HELLO"); 5340 "HELLO");
5418#endif 5341#endif
5419 transmit_to_client (c, 5342 transmit_to_client (c, (const struct GNUNET_MessageHeader *) our_hello,
5420 (const struct GNUNET_MessageHeader *) our_hello,
5421 GNUNET_NO); 5343 GNUNET_NO);
5422 /* tell new client about all existing connections */ 5344 /* tell new client about all existing connections */
5423 GNUNET_CONTAINER_multihashmap_iterate (neighbours, 5345 GNUNET_CONTAINER_multihashmap_iterate (neighbours,
@@ -5443,15 +5365,14 @@ handle_start (void *cls,
5443 * @param message the actual message 5365 * @param message the actual message
5444 */ 5366 */
5445static void 5367static void
5446handle_hello (void *cls, 5368handle_hello (void *cls, struct GNUNET_SERVER_Client *client,
5447 struct GNUNET_SERVER_Client *client,
5448 const struct GNUNET_MessageHeader *message) 5369 const struct GNUNET_MessageHeader *message)
5449{ 5370{
5450 int ret; 5371 int ret;
5451 5372
5452 GNUNET_STATISTICS_update (stats, 5373 GNUNET_STATISTICS_update (stats,
5453 gettext_noop ("# HELLOs received from clients"), 5374 gettext_noop ("# HELLOs received from clients"), 1,
5454 1, GNUNET_NO); 5375 GNUNET_NO);
5455 ret = process_hello (NULL, message); 5376 ret = process_hello (NULL, message);
5456 GNUNET_SERVER_receive_done (client, ret); 5377 GNUNET_SERVER_receive_done (client, ret);
5457} 5378}
@@ -5521,8 +5442,7 @@ transmit_client_message (void *cls, struct NeighbourMapEntry *n)
5521 * @param message the actual message 5442 * @param message the actual message
5522 */ 5443 */
5523static void 5444static void
5524handle_send (void *cls, 5445handle_send (void *cls, struct GNUNET_SERVER_Client *client,
5525 struct GNUNET_SERVER_Client *client,
5526 const struct GNUNET_MessageHeader *message) 5446 const struct GNUNET_MessageHeader *message)
5527{ 5447{
5528 const struct OutboundMessage *obm; 5448 const struct OutboundMessage *obm;
@@ -5560,8 +5480,8 @@ handle_send (void *cls,
5560 /* FIXME: this memcpy can be up to 7% of our total runtime */ 5480 /* FIXME: this memcpy can be up to 7% of our total runtime */
5561 memcpy (&tcmc[1], obmm, msize); 5481 memcpy (&tcmc[1], obmm, msize);
5562 GNUNET_SERVER_client_keep (client); 5482 GNUNET_SERVER_client_keep (client);
5563 setup_peer_check_blacklist (&obm->peer, GNUNET_YES, 5483 setup_peer_check_blacklist (&obm->peer, GNUNET_YES, &transmit_client_message,
5564 &transmit_client_message, tcmc); 5484 tcmc);
5565} 5485}
5566 5486
5567 5487
@@ -5573,8 +5493,7 @@ handle_send (void *cls,
5573 * @param message the actual message 5493 * @param message the actual message
5574 */ 5494 */
5575static void 5495static void
5576handle_request_connect (void *cls, 5496handle_request_connect (void *cls, struct GNUNET_SERVER_Client *client,
5577 struct GNUNET_SERVER_Client *client,
5578 const struct GNUNET_MessageHeader *message) 5497 const struct GNUNET_MessageHeader *message)
5579{ 5498{
5580 const struct TransportRequestConnectMessage *trcm = 5499 const struct TransportRequestConnectMessage *trcm =
@@ -5602,16 +5521,15 @@ handle_request_connect (void *cls,
5602 * @param message the actual message 5521 * @param message the actual message
5603 */ 5522 */
5604static void 5523static void
5605handle_set_quota (void *cls, 5524handle_set_quota (void *cls, struct GNUNET_SERVER_Client *client,
5606 struct GNUNET_SERVER_Client *client,
5607 const struct GNUNET_MessageHeader *message) 5525 const struct GNUNET_MessageHeader *message)
5608{ 5526{
5609 const struct QuotaSetMessage *qsm = (const struct QuotaSetMessage *) message; 5527 const struct QuotaSetMessage *qsm = (const struct QuotaSetMessage *) message;
5610 struct NeighbourMapEntry *n; 5528 struct NeighbourMapEntry *n;
5611 5529
5612 GNUNET_STATISTICS_update (stats, 5530 GNUNET_STATISTICS_update (stats,
5613 gettext_noop ("# SET QUOTA messages received"), 5531 gettext_noop ("# SET QUOTA messages received"), 1,
5614 1, GNUNET_NO); 5532 GNUNET_NO);
5615 n = find_neighbour (&qsm->peer); 5533 n = find_neighbour (&qsm->peer);
5616 if (n == NULL) 5534 if (n == NULL)
5617 { 5535 {
@@ -5625,8 +5543,7 @@ handle_set_quota (void *cls,
5625#if DEBUG_TRANSPORT 5543#if DEBUG_TRANSPORT
5626 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 5544 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
5627 "Received `%s' request (new quota %u, old quota %u) from client for peer `%4s'\n", 5545 "Received `%s' request (new quota %u, old quota %u) from client for peer `%4s'\n",
5628 "SET_QUOTA", 5546 "SET_QUOTA", (unsigned int) ntohl (qsm->quota.value__),
5629 (unsigned int) ntohl (qsm->quota.value__),
5630 (unsigned int) n->in_tracker.available_bytes_per_s__, 5547 (unsigned int) n->in_tracker.available_bytes_per_s__,
5631 GNUNET_i2s (&qsm->peer)); 5548 GNUNET_i2s (&qsm->peer));
5632#endif 5549#endif
@@ -5634,9 +5551,8 @@ handle_set_quota (void *cls,
5634 if (0 == ntohl (qsm->quota.value__)) 5551 if (0 == ntohl (qsm->quota.value__))
5635 { 5552 {
5636#if DEBUG_TRANSPORT 5553#if DEBUG_TRANSPORT
5637 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 5554 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Disconnecting peer `%4s', %s\n",
5638 "Disconnecting peer `%4s', %s\n", GNUNET_i2s (&n->id), 5555 GNUNET_i2s (&n->id), "SET_QUOTA");
5639 "SET_QUOTA");
5640#endif 5556#endif
5641 GNUNET_STATISTICS_update (stats, 5557 GNUNET_STATISTICS_update (stats,
5642 gettext_noop ("# disconnects due to quota of 0"), 5558 gettext_noop ("# disconnects due to quota of 0"),
@@ -5683,8 +5599,7 @@ transmit_address_to_client (void *cls, const char *address)
5683 * @param message the actual message 5599 * @param message the actual message
5684 */ 5600 */
5685static void 5601static void
5686handle_address_lookup (void *cls, 5602handle_address_lookup (void *cls, struct GNUNET_SERVER_Client *client,
5687 struct GNUNET_SERVER_Client *client,
5688 const struct GNUNET_MessageHeader *message) 5603 const struct GNUNET_MessageHeader *message)
5689{ 5604{
5690 const struct AddressLookupMessage *alum; 5605 const struct AddressLookupMessage *alum;
@@ -5734,11 +5649,8 @@ handle_address_lookup (void *cls,
5734 } 5649 }
5735 GNUNET_SERVER_disable_receive_done_warning (client); 5650 GNUNET_SERVER_disable_receive_done_warning (client);
5736 tc = GNUNET_SERVER_transmit_context_create (client); 5651 tc = GNUNET_SERVER_transmit_context_create (client);
5737 lsPlugin->api->address_pretty_printer (lsPlugin->api->cls, 5652 lsPlugin->api->address_pretty_printer (lsPlugin->api->cls, nameTransport,
5738 nameTransport, 5653 address, addressLen, numeric, rtimeout,
5739 address, addressLen,
5740 numeric,
5741 rtimeout,
5742 &transmit_address_to_client, tc); 5654 &transmit_address_to_client, tc);
5743} 5655}
5744 5656
@@ -5750,8 +5662,7 @@ handle_address_lookup (void *cls,
5750 * @param message the actual message 5662 * @param message the actual message
5751 */ 5663 */
5752static void 5664static void
5753handle_peer_address_lookup (void *cls, 5665handle_peer_address_lookup (void *cls, struct GNUNET_SERVER_Client *client,
5754 struct GNUNET_SERVER_Client *client,
5755 const struct GNUNET_MessageHeader *message) 5666 const struct GNUNET_MessageHeader *message)
5756{ 5667{
5757 const struct PeerAddressLookupMessage *peer_address_lookup; 5668 const struct PeerAddressLookupMessage *peer_address_lookup;
@@ -5804,22 +5715,20 @@ handle_peer_address_lookup (void *cls,
5804 a2s (transport_plugin->short_name, 5715 a2s (transport_plugin->short_name,
5805 foreign_address_iterator->addr, 5716 foreign_address_iterator->addr,
5806 foreign_address_iterator->addrlen), 5717 foreign_address_iterator->addrlen),
5807 (foreign_address_iterator->connected 5718 (foreign_address_iterator->connected ==
5808 == GNUNET_YES) ? "CONNECTED" 5719 GNUNET_YES) ? "CONNECTED" : "DISCONNECTED",
5809 : "DISCONNECTED", 5720 (foreign_address_iterator->validated ==
5810 (foreign_address_iterator->validated 5721 GNUNET_YES) ? "VALIDATED" : "UNVALIDATED");
5811 == GNUNET_YES) ? "VALIDATED" : "UNVALIDATED");
5812 transmit_address_to_client (tc, addr_buf); 5722 transmit_address_to_client (tc, addr_buf);
5813 GNUNET_free (addr_buf); 5723 GNUNET_free (addr_buf);
5814 } 5724 }
5815 else if (foreign_address_iterator->addrlen == 0) 5725 else if (foreign_address_iterator->addrlen == 0)
5816 { 5726 {
5817 GNUNET_asprintf (&addr_buf, "%s --- %s, %s", "<inbound>", 5727 GNUNET_asprintf (&addr_buf, "%s --- %s, %s", "<inbound>",
5818 (foreign_address_iterator->connected 5728 (foreign_address_iterator->connected ==
5819 == GNUNET_YES) ? "CONNECTED" 5729 GNUNET_YES) ? "CONNECTED" : "DISCONNECTED",
5820 : "DISCONNECTED", 5730 (foreign_address_iterator->validated ==
5821 (foreign_address_iterator->validated 5731 GNUNET_YES) ? "VALIDATED" : "UNVALIDATED");
5822 == GNUNET_YES) ? "VALIDATED" : "UNVALIDATED");
5823 transmit_address_to_client (tc, addr_buf); 5732 transmit_address_to_client (tc, addr_buf);
5824 GNUNET_free (addr_buf); 5733 GNUNET_free (addr_buf);
5825 } 5734 }
@@ -5859,24 +5768,21 @@ output_addresses (void *cls, const GNUNET_HashCode * key, void *value)
5859 a2s (transport_plugin->short_name, 5768 a2s (transport_plugin->short_name,
5860 foreign_address_iterator->addr, 5769 foreign_address_iterator->addr,
5861 foreign_address_iterator->addrlen), 5770 foreign_address_iterator->addrlen),
5862 (foreign_address_iterator->connected 5771 (foreign_address_iterator->connected ==
5863 == GNUNET_YES) ? "CONNECTED" 5772 GNUNET_YES) ? "CONNECTED" : "DISCONNECTED",
5864 : "DISCONNECTED", 5773 (foreign_address_iterator->validated ==
5865 (foreign_address_iterator->validated 5774 GNUNET_YES) ? "VALIDATED" : "UNVALIDATED");
5866 == GNUNET_YES) ? "VALIDATED" : "UNVALIDATED");
5867 transmit_address_to_client (tc, addr_buf); 5775 transmit_address_to_client (tc, addr_buf);
5868 GNUNET_free (addr_buf); 5776 GNUNET_free (addr_buf);
5869 } 5777 }
5870 else if (foreign_address_iterator->addrlen == 0) 5778 else if (foreign_address_iterator->addrlen == 0)
5871 { 5779 {
5872 GNUNET_asprintf (&addr_buf, "%s:%s --- %s, %s", 5780 GNUNET_asprintf (&addr_buf, "%s:%s --- %s, %s",
5873 GNUNET_i2s (&neighbor_iterator->id), 5781 GNUNET_i2s (&neighbor_iterator->id), "<inbound>",
5874 "<inbound>", 5782 (foreign_address_iterator->connected ==
5875 (foreign_address_iterator->connected 5783 GNUNET_YES) ? "CONNECTED" : "DISCONNECTED",
5876 == GNUNET_YES) ? "CONNECTED" 5784 (foreign_address_iterator->validated ==
5877 : "DISCONNECTED", 5785 GNUNET_YES) ? "VALIDATED" : "UNVALIDATED");
5878 (foreign_address_iterator->validated
5879 == GNUNET_YES) ? "VALIDATED" : "UNVALIDATED");
5880 transmit_address_to_client (tc, addr_buf); 5786 transmit_address_to_client (tc, addr_buf);
5881 GNUNET_free (addr_buf); 5787 GNUNET_free (addr_buf);
5882 } 5788 }
@@ -5897,8 +5803,7 @@ output_addresses (void *cls, const GNUNET_HashCode * key, void *value)
5897 * @param message the actual message 5803 * @param message the actual message
5898 */ 5804 */
5899static void 5805static void
5900handle_address_iterate (void *cls, 5806handle_address_iterate (void *cls, struct GNUNET_SERVER_Client *client,
5901 struct GNUNET_SERVER_Client *client,
5902 const struct GNUNET_MessageHeader *message) 5807 const struct GNUNET_MessageHeader *message)
5903{ 5808{
5904 struct GNUNET_SERVER_TransmitContext *tc; 5809 struct GNUNET_SERVER_TransmitContext *tc;
@@ -5954,8 +5859,8 @@ start_transport (struct GNUNET_SERVER_Handle *server, const char *name)
5954 struct TransportPlugin *plug; 5859 struct TransportPlugin *plug;
5955 char *libname; 5860 char *libname;
5956 5861
5957 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 5862 GNUNET_log (GNUNET_ERROR_TYPE_INFO, _("Loading `%s' transport plugin\n"),
5958 _("Loading `%s' transport plugin\n"), name); 5863 name);
5959 GNUNET_asprintf (&libname, "libgnunet_plugin_transport_%s", name); 5864 GNUNET_asprintf (&libname, "libgnunet_plugin_transport_%s", name);
5960 plug = GNUNET_malloc (sizeof (struct TransportPlugin)); 5865 plug = GNUNET_malloc (sizeof (struct TransportPlugin));
5961 create_environment (plug); 5866 create_environment (plug);
@@ -6062,8 +5967,8 @@ client_disconnect_notification (void *cls, struct GNUNET_SERVER_Client *client)
6062 GNUNET_free (mqe); 5967 GNUNET_free (mqe);
6063 } 5968 }
6064 if (NULL != neighbours) 5969 if (NULL != neighbours)
6065 GNUNET_CONTAINER_multihashmap_iterate (neighbours, 5970 GNUNET_CONTAINER_multihashmap_iterate (neighbours, &null_mq_client_pointers,
6066 &null_mq_client_pointers, pos); 5971 pos);
6067 if (prev == NULL) 5972 if (prev == NULL)
6068 clients = pos->next; 5973 clients = pos->next;
6069 else 5974 else
@@ -6089,8 +5994,7 @@ disconnect_all_neighbours (void *cls, const GNUNET_HashCode * key, void *value)
6089 struct NeighbourMapEntry *n = value; 5994 struct NeighbourMapEntry *n = value;
6090 5995
6091#if DEBUG_TRANSPORT 5996#if DEBUG_TRANSPORT
6092 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 5997 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Disconnecting peer `%4s', %s\n",
6093 "Disconnecting peer `%4s', %s\n",
6094 GNUNET_i2s (&n->id), "SHUTDOWN_TASK"); 5998 GNUNET_i2s (&n->id), "SHUTDOWN_TASK");
6095#endif 5999#endif
6096 disconnect_neighbour (n, GNUNET_NO); 6000 disconnect_neighbour (n, GNUNET_NO);
@@ -6113,8 +6017,8 @@ shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
6113 struct CheckHelloValidatedContext *chvc; 6017 struct CheckHelloValidatedContext *chvc;
6114 6018
6115 shutdown_in_progress = GNUNET_YES; 6019 shutdown_in_progress = GNUNET_YES;
6116 GNUNET_CONTAINER_multihashmap_iterate (neighbours, 6020 GNUNET_CONTAINER_multihashmap_iterate (neighbours, &disconnect_all_neighbours,
6117 &disconnect_all_neighbours, NULL); 6021 NULL);
6118#if DEBUG_TRANSPORT 6022#if DEBUG_TRANSPORT
6119 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 6023 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
6120 "Transport service is unloading plugins...\n"); 6024 "Transport service is unloading plugins...\n");
@@ -6141,8 +6045,8 @@ shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
6141 GNUNET_CRYPTO_rsa_key_free (my_private_key); 6045 GNUNET_CRYPTO_rsa_key_free (my_private_key);
6142 GNUNET_free_non_null (our_hello); 6046 GNUNET_free_non_null (our_hello);
6143 6047
6144 GNUNET_CONTAINER_multihashmap_iterate (validation_map, 6048 GNUNET_CONTAINER_multihashmap_iterate (validation_map, &abort_validation,
6145 &abort_validation, NULL); 6049 NULL);
6146 GNUNET_CONTAINER_multihashmap_destroy (validation_map); 6050 GNUNET_CONTAINER_multihashmap_destroy (validation_map);
6147 validation_map = NULL; 6051 validation_map = NULL;
6148 6052
@@ -6290,8 +6194,8 @@ setup_ats_problem (void *cls, const GNUNET_HashCode * key, void *value)
6290 6194
6291 6195
6292static void 6196static void
6293create_ats_information (struct ATS_peer **p, 6197create_ats_information (struct ATS_peer **p, int *c_p, struct ATS_mechanism **m,
6294 int *c_p, struct ATS_mechanism **m, int *c_m) 6198 int *c_m)
6295{ 6199{
6296 struct AtsBuildContext abc; 6200 struct AtsBuildContext abc;
6297 6201
@@ -6301,8 +6205,8 @@ create_ats_information (struct ATS_peer **p,
6301#endif 6205#endif
6302 abc.c_peers = 0; 6206 abc.c_peers = 0;
6303 abc.c_mechs = 0; 6207 abc.c_mechs = 0;
6304 GNUNET_CONTAINER_multihashmap_iterate (neighbours, 6208 GNUNET_CONTAINER_multihashmap_iterate (neighbours, &find_and_count_addresses,
6305 &find_and_count_addresses, &abc); 6209 &abc);
6306#if VERBOSE_ATS 6210#if VERBOSE_ATS
6307 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 6211 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
6308 "Found %u peers with % u transport mechanisms\n", c_peers, 6212 "Found %u peers with % u transport mechanisms\n", c_peers,
@@ -6369,8 +6273,8 @@ schedule_ats (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
6369#endif 6273#endif
6370 last_ats_execution = GNUNET_TIME_absolute_get (); 6274 last_ats_execution = GNUNET_TIME_absolute_get ();
6371 6275
6372 ats_task = GNUNET_SCHEDULER_add_delayed (ats_regular_interval, 6276 ats_task =
6373 &schedule_ats, ats); 6277 GNUNET_SCHEDULER_add_delayed (ats_regular_interval, &schedule_ats, ats);
6374} 6278}
6375#endif 6279#endif
6376 6280
@@ -6390,8 +6294,7 @@ get_preferred_ats_address (struct NeighbourMapEntry *n)
6390 * @param c configuration to use 6294 * @param c configuration to use
6391 */ 6295 */
6392static void 6296static void
6393run (void *cls, 6297run (void *cls, struct GNUNET_SERVER_Handle *server,
6394 struct GNUNET_SERVER_Handle *server,
6395 const struct GNUNET_CONFIGURATION_Handle *c) 6298 const struct GNUNET_CONFIGURATION_Handle *c)
6396{ 6299{
6397 static const struct GNUNET_SERVER_MessageHandler handlers[] = { 6300 static const struct GNUNET_SERVER_MessageHandler handlers[] = {
@@ -6436,14 +6339,11 @@ run (void *cls,
6436 neighbours = GNUNET_CONTAINER_multihashmap_create (256); 6339 neighbours = GNUNET_CONTAINER_multihashmap_create (256);
6437 /* parse configuration */ 6340 /* parse configuration */
6438 if ((GNUNET_OK != 6341 if ((GNUNET_OK !=
6439 GNUNET_CONFIGURATION_get_value_number (c, 6342 GNUNET_CONFIGURATION_get_value_number (c, "TRANSPORT", "NEIGHBOUR_LIMIT",
6440 "TRANSPORT",
6441 "NEIGHBOUR_LIMIT",
6442 &tneigh)) || 6343 &tneigh)) ||
6443 (GNUNET_OK != 6344 (GNUNET_OK !=
6444 GNUNET_CONFIGURATION_get_value_filename (c, 6345 GNUNET_CONFIGURATION_get_value_filename (c, "GNUNETD", "HOSTKEY",
6445 "GNUNETD", 6346 &keyfile)))
6446 "HOSTKEY", &keyfile)))
6447 { 6347 {
6448 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 6348 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
6449 _ 6349 _
@@ -6499,18 +6399,18 @@ run (void *cls,
6499 return; 6399 return;
6500 } 6400 }
6501 GNUNET_CRYPTO_rsa_key_get_public (my_private_key, &my_public_key); 6401 GNUNET_CRYPTO_rsa_key_get_public (my_private_key, &my_public_key);
6502 GNUNET_CRYPTO_hash (&my_public_key, 6402 GNUNET_CRYPTO_hash (&my_public_key, sizeof (my_public_key),
6503 sizeof (my_public_key), &my_identity.hashPubKey); 6403 &my_identity.hashPubKey);
6504 /* setup notification */ 6404 /* setup notification */
6505 GNUNET_SERVER_disconnect_notify (server, 6405 GNUNET_SERVER_disconnect_notify (server, &client_disconnect_notification,
6506 &client_disconnect_notification, NULL); 6406 NULL);
6507 /* load plugins... */ 6407 /* load plugins... */
6508 no_transports = 1; 6408 no_transports = 1;
6509 if (GNUNET_OK == 6409 if (GNUNET_OK ==
6510 GNUNET_CONFIGURATION_get_value_string (c, "TRANSPORT", "PLUGINS", &plugs)) 6410 GNUNET_CONFIGURATION_get_value_string (c, "TRANSPORT", "PLUGINS", &plugs))
6511 { 6411 {
6512 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 6412 GNUNET_log (GNUNET_ERROR_TYPE_INFO, _("Starting transport plugins `%s'\n"),
6513 _("Starting transport plugins `%s'\n"), plugs); 6413 plugs);
6514 pos = strtok (plugs, " "); 6414 pos = strtok (plugs, " ");
6515 while (pos != NULL) 6415 while (pos != NULL)
6516 { 6416 {
@@ -6520,8 +6420,8 @@ run (void *cls,
6520 } 6420 }
6521 GNUNET_free (plugs); 6421 GNUNET_free (plugs);
6522 } 6422 }
6523 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, 6423 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, &shutdown_task,
6524 &shutdown_task, NULL); 6424 NULL);
6525 if (no_transports) 6425 if (no_transports)
6526 refresh_hello (); 6426 refresh_hello ();
6527 6427
@@ -6547,9 +6447,9 @@ run (void *cls,
6547 GNUNET_asprintf (&section, "%s_UP", ressources[co].cfg_param); 6447 GNUNET_asprintf (&section, "%s_UP", ressources[co].cfg_param);
6548 if (GNUNET_CONFIGURATION_have_value (cfg, "transport", section)) 6448 if (GNUNET_CONFIGURATION_have_value (cfg, "transport", section))
6549 { 6449 {
6550 if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_number (cfg, 6450 if (GNUNET_OK ==
6551 "transport", 6451 GNUNET_CONFIGURATION_get_value_number (cfg, "transport", section,
6552 section, &value)) 6452 &value))
6553 { 6453 {
6554#if DEBUG_ATS 6454#if DEBUG_ATS
6555 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 6455 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
@@ -6562,9 +6462,9 @@ run (void *cls,
6562 GNUNET_asprintf (&section, "%s_DOWN", ressources[co].cfg_param); 6462 GNUNET_asprintf (&section, "%s_DOWN", ressources[co].cfg_param);
6563 if (GNUNET_CONFIGURATION_have_value (cfg, "transport", section)) 6463 if (GNUNET_CONFIGURATION_have_value (cfg, "transport", section))
6564 { 6464 {
6565 if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_number (cfg, 6465 if (GNUNET_OK ==
6566 "transport", 6466 GNUNET_CONFIGURATION_get_value_number (cfg, "transport", section,
6567 section, &value)) 6467 &value))
6568 { 6468 {
6569#if DEBUG_ATS 6469#if DEBUG_ATS
6570 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 6470 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
@@ -6576,18 +6476,16 @@ run (void *cls,
6576 GNUNET_free (section); 6476 GNUNET_free (section);
6577 } 6477 }
6578#if HAVE_LIBGLPK 6478#if HAVE_LIBGLPK
6579 ats = ats_init (D, U, R, v_b_min, v_n_min, 6479 ats =
6580 ATS_MAX_ITERATIONS, ATS_MAX_EXEC_DURATION, 6480 ats_init (D, U, R, v_b_min, v_n_min, ATS_MAX_ITERATIONS,
6581 &create_ats_information, ats_result_cb); 6481 ATS_MAX_EXEC_DURATION, &create_ats_information, ats_result_cb);
6582 ats_set_logging_options (ats, stats, cfg); 6482 ats_set_logging_options (ats, stats, cfg);
6583 GNUNET_break (GNUNET_OK == 6483 GNUNET_break (GNUNET_OK ==
6584 GNUNET_CONFIGURATION_get_value_time (cfg, 6484 GNUNET_CONFIGURATION_get_value_time (cfg, "transport",
6585 "transport",
6586 "ATS_EXEC_INTERVAL", 6485 "ATS_EXEC_INTERVAL",
6587 &ats_regular_interval)); 6486 &ats_regular_interval));
6588 GNUNET_break (GNUNET_OK == 6487 GNUNET_break (GNUNET_OK ==
6589 GNUNET_CONFIGURATION_get_value_time (cfg, 6488 GNUNET_CONFIGURATION_get_value_time (cfg, "transport",
6590 "transport",
6591 "ATS_MIN_INTERVAL", 6489 "ATS_MIN_INTERVAL",
6592 &ats_minimum_interval)); 6490 &ats_minimum_interval));
6593 if (ats != NULL) 6491 if (ats != NULL)
@@ -6617,9 +6515,7 @@ main (int argc, char *const *argv)
6617{ 6515{
6618 a2s (NULL, NULL, 0); /* make compiler happy */ 6516 a2s (NULL, NULL, 0); /* make compiler happy */
6619 return (GNUNET_OK == 6517 return (GNUNET_OK ==
6620 GNUNET_SERVICE_run (argc, 6518 GNUNET_SERVICE_run (argc, argv, "transport",
6621 argv,
6622 "transport",
6623 GNUNET_SERVICE_OPTION_NONE, &run, NULL)) ? 0 : 1; 6519 GNUNET_SERVICE_OPTION_NONE, &run, NULL)) ? 0 : 1;
6624} 6520}
6625 6521
diff --git a/src/transport/gnunet-service-transport_ats.c b/src/transport/gnunet-service-transport_ats.c
index 34d1791b9..2e859f1db 100644
--- a/src/transport/gnunet-service-transport_ats.c
+++ b/src/transport/gnunet-service-transport_ats.c
@@ -317,8 +317,8 @@ _lp_simplex (glp_prob *P, void *parm)
317} 317}
318 318
319static void 319static void
320_lp_load_matrix (glp_prob *P, int ne, const int ia[], 320_lp_load_matrix (glp_prob *P, int ne, const int ia[], const int ja[],
321 const int ja[], const double ar[]) 321 const double ar[])
322{ 322{
323#if HAVE_LIBGLPK 323#if HAVE_LIBGLPK
324 glp_load_matrix (P, ne, ia, ja, ar); 324 glp_load_matrix (P, ne, ia, ja, ar);
@@ -510,13 +510,8 @@ _dummy2 ()
510 */ 510 */
511 511
512struct ATS_Handle * 512struct ATS_Handle *
513ats_init (double D, 513ats_init (double D, double U, double R, int v_b_min, int v_n_min,
514 double U, 514 int max_iterations, struct GNUNET_TIME_Relative max_duration,
515 double R,
516 int v_b_min,
517 int v_n_min,
518 int max_iterations,
519 struct GNUNET_TIME_Relative max_duration,
520 GNUNET_TRANSPORT_ATS_AddressNotification address_not, 515 GNUNET_TRANSPORT_ATS_AddressNotification address_not,
521 GNUNET_TRANSPORT_ATS_ResultCallback res_cb) 516 GNUNET_TRANSPORT_ATS_ResultCallback res_cb)
522{ 517{
@@ -561,10 +556,9 @@ ats_init (double D,
561 * @return GNUNET_SYSERR if glpk is not available, number of mechanisms used 556 * @return GNUNET_SYSERR if glpk is not available, number of mechanisms used
562 */ 557 */
563int 558int
564ats_create_problem (struct ATS_Handle *ats, 559ats_create_problem (struct ATS_Handle *ats, struct ATS_internals *stat,
565 struct ATS_internals *stat, 560 struct ATS_peer *peers, int c_p,
566 struct ATS_peer *peers, 561 struct ATS_mechanism *mechanisms, int c_m)
567 int c_p, struct ATS_mechanism *mechanisms, int c_m)
568{ 562{
569 if ((c_p == 0) || (c_m == 0)) 563 if ((c_p == 0) || (c_m == 0))
570 return GNUNET_SYSERR; 564 return GNUNET_SYSERR;
@@ -591,8 +585,9 @@ ats_create_problem (struct ATS_Handle *ats,
591 c_p, c_m, c_c_ressources, c_q_metrics); 585 c_p, c_m, c_c_ressources, c_q_metrics);
592#endif 586#endif
593 587
594 int size = 1 + 3 + 10 * c_m + c_p + 588 int size =
595 (c_q_metrics * c_m) + c_q_metrics + c_c_ressources * c_m; 589 1 + 3 + 10 * c_m + c_p + (c_q_metrics * c_m) + c_q_metrics +
590 c_c_ressources * c_m;
596 int row_index; 591 int row_index;
597 int array_index = 1; 592 int array_index = 1;
598 int *ia = GNUNET_malloc (size * sizeof (int)); 593 int *ia = GNUNET_malloc (size * sizeof (int));
@@ -609,8 +604,8 @@ ats_create_problem (struct ATS_Handle *ats,
609 /* adding b_t cols */ 604 /* adding b_t cols */
610 for (c = 1; c <= c_m; c++) 605 for (c = 1; c <= c_m; c++)
611 { 606 {
612 GNUNET_asprintf (&name, 607 GNUNET_asprintf (&name, "p_%s_b%i",
613 "p_%s_b%i", GNUNET_i2s (&(mechanisms[c].peer->peer)), c); 608 GNUNET_i2s (&(mechanisms[c].peer->peer)), c);
614 _lp_set_col_name (ats->prob, c, name); 609 _lp_set_col_name (ats->prob, c, name);
615 GNUNET_free (name); 610 GNUNET_free (name);
616 _lp_set_col_bnds (ats->prob, c, GLP_LO, 0.0, 0.0); 611 _lp_set_col_bnds (ats->prob, c, GLP_LO, 0.0, 0.0);
@@ -621,9 +616,8 @@ ats_create_problem (struct ATS_Handle *ats,
621 /* adding n_t cols */ 616 /* adding n_t cols */
622 for (c = c_m + 1; c <= 2 * c_m; c++) 617 for (c = c_m + 1; c <= 2 * c_m; c++)
623 { 618 {
624 GNUNET_asprintf (&name, 619 GNUNET_asprintf (&name, "p_%s_n%i",
625 "p_%s_n%i", GNUNET_i2s (&(mechanisms[c - c_m].peer->peer)), 620 GNUNET_i2s (&(mechanisms[c - c_m].peer->peer)), (c - c_m));
626 (c - c_m));
627 _lp_set_col_name (ats->prob, c, name); 621 _lp_set_col_name (ats->prob, c, name);
628 GNUNET_free (name); 622 GNUNET_free (name);
629 _lp_set_col_bnds (ats->prob, c, GLP_DB, 0.0, 1.0); 623 _lp_set_col_bnds (ats->prob, c, GLP_DB, 0.0, 1.0);
@@ -653,8 +647,8 @@ ats_create_problem (struct ATS_Handle *ats,
653 ar[array_index] = 1; 647 ar[array_index] = 1;
654#if VERBOSE_ATS 648#if VERBOSE_ATS
655 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "[index]=[%i]: [%i,%i]=%f \n", 649 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "[index]=[%i]: [%i,%i]=%f \n",
656 array_index, 650 array_index, ia[array_index], ja[array_index],
657 ia[array_index], ja[array_index], ar[array_index]); 651 ar[array_index]);
658#endif 652#endif
659 array_index++; 653 array_index++;
660 m = m->next; 654 m = m->next;
@@ -754,8 +748,8 @@ ats_create_problem (struct ATS_Handle *ats,
754 ar[array_index] = value; 748 ar[array_index] = value;
755#if VERBOSE_ATS 749#if VERBOSE_ATS
756 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "[index]=[%i]: [%i,%i]=%f \n", 750 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "[index]=[%i]: [%i,%i]=%f \n",
757 array_index, ia[array_index], 751 array_index, ia[array_index], ja[array_index],
758 ja[array_index], ar[array_index]); 752 ar[array_index]);
759#endif 753#endif
760 array_index++; 754 array_index++;
761 } 755 }
@@ -893,9 +887,8 @@ ats_create_problem (struct ATS_Handle *ats,
893 ar[array_index] = (mechanisms[c2].peer->f) * value; 887 ar[array_index] = (mechanisms[c2].peer->f) * value;
894#if VERBOSE_ATS 888#if VERBOSE_ATS
895 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "[index]=[%i]: %s [%i,%i]=%f \n", 889 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "[index]=[%i]: %s [%i,%i]=%f \n",
896 array_index, 890 array_index, qm[c - 1].name, ia[array_index], ja[array_index],
897 qm[c - 1].name, 891 ar[array_index]);
898 ia[array_index], ja[array_index], ar[array_index]);
899#endif 892#endif
900 array_index++; 893 array_index++;
901 } 894 }
@@ -970,8 +963,8 @@ ats_create_problem (struct ATS_Handle *ats,
970 ar[array_index] = 1 / mechanisms[c].peer->f; 963 ar[array_index] = 1 / mechanisms[c].peer->f;
971#if VERBOSE_ATS 964#if VERBOSE_ATS
972 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "[index]=[%i]: [%i,%i]=%f \n", 965 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "[index]=[%i]: [%i,%i]=%f \n",
973 array_index, 966 array_index, ia[array_index], ja[array_index],
974 ia[array_index], ja[array_index], ar[array_index]); 967 ar[array_index]);
975#endif 968#endif
976 array_index++; 969 array_index++;
977 m = m->next; 970 m = m->next;
@@ -1076,10 +1069,8 @@ ats_modify_problem_state (struct ATS_Handle *ats, enum ATS_problem_state s)
1076} 1069}
1077 1070
1078void 1071void
1079ats_solve_problem (struct ATS_Handle *ats, 1072ats_solve_problem (struct ATS_Handle *ats, unsigned int max_it,
1080 unsigned int max_it, 1073 unsigned int max_dur, unsigned int c_peers,
1081 unsigned int max_dur,
1082 unsigned int c_peers,
1083 unsigned int c_mechs, struct ATS_internals *stat) 1074 unsigned int c_mechs, struct ATS_internals *stat)
1084{ 1075{
1085 int result = GNUNET_SYSERR; 1076 int result = GNUNET_SYSERR;
@@ -1127,8 +1118,8 @@ ats_solve_problem (struct ATS_Handle *ats,
1127 lp_solution = _lp_get_status (ats->prob); 1118 lp_solution = _lp_get_status (ats->prob);
1128 1119
1129 // TODO: Remove if this does not appear until release 1120 // TODO: Remove if this does not appear until release
1130 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "" 1121 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
1131 "EXECUTED SIMPLEX WITH PRESOLVER! %i \n", lp_solution); 1122 "" "EXECUTED SIMPLEX WITH PRESOLVER! %i \n", lp_solution);
1132 1123
1133 if (ats_evaluate_results (result, lp_solution, "LP") != GNUNET_YES) 1124 if (ats_evaluate_results (result, lp_solution, "LP") != GNUNET_YES)
1134 { 1125 {
@@ -1136,10 +1127,8 @@ ats_solve_problem (struct ATS_Handle *ats,
1136 "After execution simplex with presolver: STILL INVALID!\n"); 1127 "After execution simplex with presolver: STILL INVALID!\n");
1137 char *filename; 1128 char *filename;
1138 1129
1139 GNUNET_asprintf (&filename, 1130 GNUNET_asprintf (&filename, "ats_mlp_p%i_m%i_%llu.mlp",
1140 "ats_mlp_p%i_m%i_%llu.mlp", 1131 ats->internal.c_peers, ats->internal.c_mechs,
1141 ats->internal.c_peers,
1142 ats->internal.c_mechs,
1143 GNUNET_TIME_absolute_get ().abs_value); 1132 GNUNET_TIME_absolute_get ().abs_value);
1144 _lp_write_lp ((void *) ats->prob, NULL, filename); 1133 _lp_write_lp ((void *) ats->prob, NULL, filename);
1145 GNUNET_free (filename); 1134 GNUNET_free (filename);
@@ -1227,10 +1216,12 @@ ats_update_problem_qm (struct ATS_Handle *ats)
1227 int c, c2; 1216 int c, c2;
1228 int c_q_metrics = available_quality_metrics; 1217 int c_q_metrics = available_quality_metrics;
1229 1218
1230 int *ja = GNUNET_malloc ((1 + ats->internal.c_mechs * 2 + 3 + 1219 int *ja =
1231 available_quality_metrics) * sizeof (int)); 1220 GNUNET_malloc ((1 + ats->internal.c_mechs * 2 + 3 +
1232 double *ar = GNUNET_malloc ((1 + ats->internal.c_mechs * 2 + 3 + 1221 available_quality_metrics) * sizeof (int));
1233 available_quality_metrics) * sizeof (double)); 1222 double *ar =
1223 GNUNET_malloc ((1 + ats->internal.c_mechs * 2 + 3 +
1224 available_quality_metrics) * sizeof (double));
1234#if DEBUG_ATS 1225#if DEBUG_ATS
1235 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Updating problem quality metrics\n"); 1226 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Updating problem quality metrics\n");
1236#endif 1227#endif
@@ -1289,8 +1280,8 @@ ats_update_problem_qm (struct ATS_Handle *ats)
1289 ar[array_index] = (ats->mechanisms[c2].peer->f) * value; 1280 ar[array_index] = (ats->mechanisms[c2].peer->f) * value;
1290#if VERBOSE_ATS 1281#if VERBOSE_ATS
1291 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "[index]=[%i]: %s [%i,%i]=%f \n", 1282 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "[index]=[%i]: %s [%i,%i]=%f \n",
1292 array_index, 1283 array_index, qm[c - 1].name, row_index, ja[array_index],
1293 qm[c - 1].name, row_index, ja[array_index], ar[array_index]); 1284 ar[array_index]);
1294#endif 1285#endif
1295 array_index++; 1286 array_index++;
1296 } 1287 }
@@ -1332,8 +1323,8 @@ ats_calculate_bandwidth_distribution (struct ATS_Handle *ats)
1332 1323
1333 ats->internal.simplex_rerun_required = GNUNET_NO; 1324 ats->internal.simplex_rerun_required = GNUNET_NO;
1334 start = GNUNET_TIME_absolute_get (); 1325 start = GNUNET_TIME_absolute_get ();
1335 if ((ats->internal.recreate_problem == GNUNET_YES) || 1326 if ((ats->internal.recreate_problem == GNUNET_YES) || (ats->prob == NULL) ||
1336 (ats->prob == NULL) || (ats->internal.valid == GNUNET_NO)) 1327 (ats->internal.valid == GNUNET_NO))
1337 { 1328 {
1338 text = "new"; 1329 text = "new";
1339 ats->internal.recreate_problem = GNUNET_YES; 1330 ats->internal.recreate_problem = GNUNET_YES;
@@ -1381,10 +1372,8 @@ ats_calculate_bandwidth_distribution (struct ATS_Handle *ats)
1381 ats->internal.solution = GLP_UNDEF; 1372 ats->internal.solution = GLP_UNDEF;
1382 if (ats->internal.valid == GNUNET_YES) 1373 if (ats->internal.valid == GNUNET_YES)
1383 { 1374 {
1384 ats_solve_problem (ats, 1375 ats_solve_problem (ats, ats->max_iterations,
1385 ats->max_iterations, 1376 ats->max_exec_duration.rel_value, ats->internal.c_peers,
1386 ats->max_exec_duration.rel_value,
1387 ats->internal.c_peers,
1388 ats->internal.c_mechs, &ats->internal); 1377 ats->internal.c_mechs, &ats->internal);
1389 } 1378 }
1390 solving = 1379 solving =
@@ -1402,11 +1391,8 @@ ats_calculate_bandwidth_distribution (struct ATS_Handle *ats)
1402#endif 1391#endif
1403 GNUNET_log (msg_type, 1392 GNUNET_log (msg_type,
1404 "MLP %s: creation time: %llu, execution time: %llu, %i peers, %i mechanisms, simplex rerun: %s, solution %s\n", 1393 "MLP %s: creation time: %llu, execution time: %llu, %i peers, %i mechanisms, simplex rerun: %s, solution %s\n",
1405 text, 1394 text, creation.rel_value, solving.rel_value,
1406 creation.rel_value, 1395 ats->internal.c_peers, ats->internal.c_mechs,
1407 solving.rel_value,
1408 ats->internal.c_peers,
1409 ats->internal.c_mechs,
1410 (ats->internal.simplex_rerun_required == 1396 (ats->internal.simplex_rerun_required ==
1411 GNUNET_NO) ? "NO" : "YES", 1397 GNUNET_NO) ? "NO" : "YES",
1412 (ats->internal.solution == 5) ? "OPTIMAL" : "INVALID"); 1398 (ats->internal.solution == 5) ? "OPTIMAL" : "INVALID");
@@ -1449,9 +1435,8 @@ ats_calculate_bandwidth_distribution (struct ATS_Handle *ats)
1449 } 1435 }
1450 } 1436 }
1451 1437
1452 GNUNET_STATISTICS_set (ats->stats, 1438 GNUNET_STATISTICS_set (ats->stats, "ATS duration",
1453 "ATS duration", solving.rel_value + creation.rel_value, 1439 solving.rel_value + creation.rel_value, GNUNET_NO);
1454 GNUNET_NO);
1455 GNUNET_STATISTICS_set (ats->stats, "ATS mechanisms", ats->internal.c_mechs, 1440 GNUNET_STATISTICS_set (ats->stats, "ATS mechanisms", ats->internal.c_mechs,
1456 GNUNET_NO); 1441 GNUNET_NO);
1457 GNUNET_STATISTICS_set (ats->stats, "ATS peers", ats->internal.c_peers, 1442 GNUNET_STATISTICS_set (ats->stats, "ATS peers", ats->internal.c_peers,
@@ -1470,15 +1455,14 @@ ats_calculate_bandwidth_distribution (struct ATS_Handle *ats)
1470 if (ats->dump_overwrite == GNUNET_NO) 1455 if (ats->dump_overwrite == GNUNET_NO)
1471 { 1456 {
1472 GNUNET_asprintf (&filename, "ats_mlp_p%i_m%i_%s_%llu.mlp", 1457 GNUNET_asprintf (&filename, "ats_mlp_p%i_m%i_%s_%llu.mlp",
1473 ats->internal.c_peers, 1458 ats->internal.c_peers, ats->internal.c_mechs, text,
1474 ats->internal.c_mechs, 1459 GNUNET_TIME_absolute_get ().abs_value);
1475 text, GNUNET_TIME_absolute_get ().abs_value);
1476 _lp_write_lp ((void *) ats->prob, NULL, filename); 1460 _lp_write_lp ((void *) ats->prob, NULL, filename);
1477 } 1461 }
1478 else 1462 else
1479 { 1463 {
1480 GNUNET_asprintf (&filename, "ats_mlp_p%i_m%i.mlp", 1464 GNUNET_asprintf (&filename, "ats_mlp_p%i_m%i.mlp", ats->internal.c_peers,
1481 ats->internal.c_peers, ats->internal.c_mechs); 1465 ats->internal.c_mechs);
1482 _lp_write_lp ((void *) ats->prob, NULL, filename); 1466 _lp_write_lp ((void *) ats->prob, NULL, filename);
1483 } 1467 }
1484 GNUNET_free (filename); 1468 GNUNET_free (filename);
@@ -1492,15 +1476,14 @@ ats_calculate_bandwidth_distribution (struct ATS_Handle *ats)
1492 if (ats->dump_overwrite == GNUNET_NO) 1476 if (ats->dump_overwrite == GNUNET_NO)
1493 { 1477 {
1494 GNUNET_asprintf (&filename, "ats_mlp_p%i_m%i_%s_%llu.sol", 1478 GNUNET_asprintf (&filename, "ats_mlp_p%i_m%i_%s_%llu.sol",
1495 ats->internal.c_peers, 1479 ats->internal.c_peers, ats->internal.c_mechs, text,
1496 ats->internal.c_mechs, 1480 GNUNET_TIME_absolute_get ().abs_value);
1497 text, GNUNET_TIME_absolute_get ().abs_value);
1498 _lp_print_sol (ats->prob, filename); 1481 _lp_print_sol (ats->prob, filename);
1499 } 1482 }
1500 else 1483 else
1501 { 1484 {
1502 GNUNET_asprintf (&filename, "ats_mlp_p%i_m%i.sol", 1485 GNUNET_asprintf (&filename, "ats_mlp_p%i_m%i.sol", ats->internal.c_peers,
1503 ats->internal.c_peers, ats->internal.c_mechs); 1486 ats->internal.c_mechs);
1504 _lp_print_sol (ats->prob, filename); 1487 _lp_print_sol (ats->prob, filename);
1505 } 1488 }
1506 GNUNET_free (filename); 1489 GNUNET_free (filename);
@@ -1545,8 +1528,8 @@ ats_evaluate_results (int result, int solution, char *problem)
1545 break; 1528 break;
1546 case GLP_EITLIM: /* iteration limit exceeded */ 1529 case GLP_EITLIM: /* iteration limit exceeded */
1547#if DEBUG_ATS || VERBOSE_ATS 1530#if DEBUG_ATS || VERBOSE_ATS
1548 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 1531 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "%s Iteration limit exceeded\n",
1549 "%s Iteration limit exceeded\n", problem); 1532 problem);
1550#endif 1533#endif
1551 break; 1534 break;
1552 case GLP_ETMLIM: /* time limit exceeded */ 1535 case GLP_ETMLIM: /* time limit exceeded */
@@ -1602,8 +1585,8 @@ ats_evaluate_results (int result, int solution, char *problem)
1602 break; 1585 break;
1603 case GLP_NOFEAS: 1586 case GLP_NOFEAS:
1604#if DEBUG_ATS || VERBOSE_ATS 1587#if DEBUG_ATS || VERBOSE_ATS
1605 GNUNET_log (error_kind, "%s problem has no %sfeasible solution\n", 1588 GNUNET_log (error_kind, "%s problem has no %sfeasible solution\n", problem,
1606 problem, (0 == strcmp (problem, "LP") ? "" : "integer ")); 1589 (0 == strcmp (problem, "LP") ? "" : "integer "));
1607#endif 1590#endif
1608 break; 1591 break;
1609 case GLP_INFEAS: 1592 case GLP_INFEAS:
@@ -1629,10 +1612,12 @@ ats_update_problem_cr (struct ATS_Handle *ats)
1629 int c, c2; 1612 int c, c2;
1630 double ct_max, ct_min; 1613 double ct_max, ct_min;
1631 1614
1632 int *ja = GNUNET_malloc ((1 + ats->internal.c_mechs * 2 + 3 + 1615 int *ja =
1633 available_quality_metrics) * sizeof (int)); 1616 GNUNET_malloc ((1 + ats->internal.c_mechs * 2 + 3 +
1634 double *ar = GNUNET_malloc ((1 + ats->internal.c_mechs * 2 + 3 + 1617 available_quality_metrics) * sizeof (int));
1635 available_quality_metrics) * sizeof (double)); 1618 double *ar =
1619 GNUNET_malloc ((1 + ats->internal.c_mechs * 2 + 3 +
1620 available_quality_metrics) * sizeof (double));
1636 1621
1637 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Updating problem quality metrics\n"); 1622 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Updating problem quality metrics\n");
1638 row_index = ats->internal.begin_cr; 1623 row_index = ats->internal.begin_cr;
@@ -1685,23 +1670,19 @@ ats_set_logging_options (struct ATS_Handle *ats,
1685 1670
1686 if (ats == NULL) 1671 if (ats == NULL)
1687 return; 1672 return;
1688 log_problem = GNUNET_CONFIGURATION_get_value_yesno (cfg, 1673 log_problem =
1689 "transport", "DUMP_MLP"); 1674 GNUNET_CONFIGURATION_get_value_yesno (cfg, "transport", "DUMP_MLP");
1690 log_solution = GNUNET_CONFIGURATION_get_value_yesno (cfg, 1675 log_solution =
1691 "transport", 1676 GNUNET_CONFIGURATION_get_value_yesno (cfg, "transport", "DUMP_SOLUTION");
1692 "DUMP_SOLUTION"); 1677 overwrite_dump =
1693 overwrite_dump = GNUNET_CONFIGURATION_get_value_yesno (cfg, 1678 GNUNET_CONFIGURATION_get_value_yesno (cfg, "transport", "DUMP_OVERWRITE");
1694 "transport",
1695 "DUMP_OVERWRITE");
1696 if (GNUNET_OK == 1679 if (GNUNET_OK ==
1697 GNUNET_CONFIGURATION_get_value_number (cfg, 1680 GNUNET_CONFIGURATION_get_value_number (cfg, "transport", "DUMP_MIN_PEERS",
1698 "transport", 1681 &value))
1699 "DUMP_MIN_PEERS", &value))
1700 minimum_peers = (int) value; 1682 minimum_peers = (int) value;
1701 if (GNUNET_OK == 1683 if (GNUNET_OK ==
1702 GNUNET_CONFIGURATION_get_value_number (cfg, 1684 GNUNET_CONFIGURATION_get_value_number (cfg, "transport", "DUMP_MIN_ADDRS",
1703 "transport", 1685 &value))
1704 "DUMP_MIN_ADDRS", &value))
1705 minimum_addresses = (int) value; 1686 minimum_addresses = (int) value;
1706 1687
1707 1688
@@ -1725,10 +1706,12 @@ ats_update_problem_qm_TEST ()
1725 int old_ja[ats->internal.c_mechs + 2]; 1706 int old_ja[ats->internal.c_mechs + 2];
1726 double old_ar[ats->internal.c_mechs + 2]; 1707 double old_ar[ats->internal.c_mechs + 2];
1727 1708
1728 int *ja = GNUNET_malloc ((1 + ats->internal.c_mechs * 2 + 3 + 1709 int *ja =
1729 available_quality_metrics) * sizeof (int)); 1710 GNUNET_malloc ((1 + ats->internal.c_mechs * 2 + 3 +
1730 double *ar = GNUNET_malloc ((1 + ats->internal.c_mechs * 2 + 3 + 1711 available_quality_metrics) * sizeof (int));
1731 available_quality_metrics) * sizeof (double)); 1712 double *ar =
1713 GNUNET_malloc ((1 + ats->internal.c_mechs * 2 + 3 +
1714 available_quality_metrics) * sizeof (double));
1732#if DEBUG_ATS 1715#if DEBUG_ATS
1733 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 1716 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
1734 "Updating problem quality metrics TEST\n"); 1717 "Updating problem quality metrics TEST\n");
@@ -1753,8 +1736,7 @@ ats_update_problem_qm_TEST ()
1753 ar[c2] = old_ar[c2]; 1736 ar[c2] = old_ar[c2];
1754#if VERBOSE_ATS 1737#if VERBOSE_ATS
1755 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 1738 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
1756 "[index]=[%i]: old [%i,%i]=%f new [%i,%i]=%f\n", 1739 "[index]=[%i]: old [%i,%i]=%f new [%i,%i]=%f\n", c2,
1757 c2,
1758 row_index, old_ja[c2], old_ar[c2], row_index, ja[c2], ar[c2]); 1740 row_index, old_ja[c2], old_ar[c2], row_index, ja[c2], ar[c2]);
1759#endif 1741#endif
1760 } 1742 }
diff --git a/src/transport/gnunet-service-transport_blacklist.c b/src/transport/gnunet-service-transport_blacklist.c
index 7720e467f..abb536414 100644
--- a/src/transport/gnunet-service-transport_blacklist.c
+++ b/src/transport/gnunet-service-transport_blacklist.c
@@ -161,8 +161,8 @@ static struct GNUNET_CONTAINER_MultiHashMap *blacklist;
161 * @param cls the 'struct BlacklistCheck*' 161 * @param cls the 'struct BlacklistCheck*'
162 * @param tc unused 162 * @param tc unused
163 */ 163 */
164static void 164static void do_blacklist_check (void *cls,
165do_blacklist_check (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc); 165 const struct GNUNET_SCHEDULER_TaskContext *tc);
166 166
167 167
168/** 168/**
@@ -227,8 +227,7 @@ read_blacklist_file ()
227 char *transport_name; 227 char *transport_name;
228 228
229 if (GNUNET_OK != 229 if (GNUNET_OK !=
230 GNUNET_CONFIGURATION_get_value_filename (GST_cfg, 230 GNUNET_CONFIGURATION_get_value_filename (GST_cfg, "TRANSPORT",
231 "TRANSPORT",
232 "BLACKLIST_FILE", &fn)) 231 "BLACKLIST_FILE", &fn))
233 { 232 {
234#if DEBUG_TRANSPORT 233#if DEBUG_TRANSPORT
@@ -252,8 +251,8 @@ read_blacklist_file ()
252 if (frstat.st_size == 0) 251 if (frstat.st_size == 0)
253 { 252 {
254#if DEBUG_TRANSPORT 253#if DEBUG_TRANSPORT
255 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 254 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, _("Blacklist file `%s' is empty.\n"),
256 _("Blacklist file `%s' is empty.\n"), fn); 255 fn);
257#endif 256#endif
258 GNUNET_free (fn); 257 GNUNET_free (fn);
259 return; 258 return;
@@ -278,8 +277,7 @@ read_blacklist_file ()
278 frstat.st_size - sizeof (struct GNUNET_CRYPTO_HashAsciiEncoded))) 277 frstat.st_size - sizeof (struct GNUNET_CRYPTO_HashAsciiEncoded)))
279 { 278 {
280 colon_pos = pos; 279 colon_pos = pos;
281 while ((colon_pos < frstat.st_size) && 280 while ((colon_pos < frstat.st_size) && (data[colon_pos] != ':') &&
282 (data[colon_pos] != ':') &&
283 (!isspace ((unsigned char) data[colon_pos]))) 281 (!isspace ((unsigned char) data[colon_pos])))
284 colon_pos++; 282 colon_pos++;
285 if (colon_pos >= frstat.st_size) 283 if (colon_pos >= frstat.st_size)
@@ -330,8 +328,8 @@ read_blacklist_file ()
330#endif 328#endif
331 memcpy (&enc, &data[pos], sizeof (struct GNUNET_CRYPTO_HashAsciiEncoded)); 329 memcpy (&enc, &data[pos], sizeof (struct GNUNET_CRYPTO_HashAsciiEncoded));
332 if (!isspace 330 if (!isspace
333 ((unsigned char) 331 ((unsigned char) enc.
334 enc.encoding[sizeof (struct GNUNET_CRYPTO_HashAsciiEncoded) - 1])) 332 encoding[sizeof (struct GNUNET_CRYPTO_HashAsciiEncoded) - 1]))
335 { 333 {
336 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 334 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
337 _ 335 _
@@ -354,8 +352,8 @@ read_blacklist_file ()
354 } 352 }
355 else 353 else
356 { 354 {
357 if (0 != memcmp (&pid, 355 if (0 !=
358 &GST_my_identity, sizeof (struct GNUNET_PeerIdentity))) 356 memcmp (&pid, &GST_my_identity, sizeof (struct GNUNET_PeerIdentity)))
359 { 357 {
360 entries_found++; 358 entries_found++;
361 GST_blacklist_add_peer (&pid, transport_name); 359 GST_blacklist_add_peer (&pid, transport_name);
@@ -372,8 +370,7 @@ read_blacklist_file ()
372 while ((pos < frstat.st_size) && isspace ((unsigned char) data[pos])) 370 while ((pos < frstat.st_size) && isspace ((unsigned char) data[pos]))
373 pos++; 371 pos++;
374 } 372 }
375 GNUNET_STATISTICS_update (GST_stats, 373 GNUNET_STATISTICS_update (GST_stats, "# Transport entries blacklisted",
376 "# Transport entries blacklisted",
377 entries_found, GNUNET_NO); 374 entries_found, GNUNET_NO);
378 GNUNET_free (data); 375 GNUNET_free (data);
379 GNUNET_free (fn); 376 GNUNET_free (fn);
@@ -389,8 +386,8 @@ void
389GST_blacklist_start (struct GNUNET_SERVER_Handle *server) 386GST_blacklist_start (struct GNUNET_SERVER_Handle *server)
390{ 387{
391 read_blacklist_file (); 388 read_blacklist_file ();
392 GNUNET_SERVER_disconnect_notify (server, 389 GNUNET_SERVER_disconnect_notify (server, &client_disconnect_notification,
393 &client_disconnect_notification, NULL); 390 NULL);
394} 391}
395 392
396 393
@@ -420,8 +417,8 @@ GST_blacklist_stop ()
420{ 417{
421 if (NULL != blacklist) 418 if (NULL != blacklist)
422 { 419 {
423 GNUNET_CONTAINER_multihashmap_iterate (blacklist, 420 GNUNET_CONTAINER_multihashmap_iterate (blacklist, &free_blacklist_entry,
424 &free_blacklist_entry, NULL); 421 NULL);
425 GNUNET_CONTAINER_multihashmap_destroy (blacklist); 422 GNUNET_CONTAINER_multihashmap_destroy (blacklist);
426 blacklist = NULL; 423 blacklist = NULL;
427 } 424 }
@@ -498,12 +495,11 @@ do_blacklist_check (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
498 if ((bl->bc != NULL) || (bl->waiting_for_reply != GNUNET_NO)) 495 if ((bl->bc != NULL) || (bl->waiting_for_reply != GNUNET_NO))
499 return; /* someone else busy with this client */ 496 return; /* someone else busy with this client */
500 bl->bc = bc; 497 bl->bc = bc;
501 bc->th = GNUNET_SERVER_notify_transmit_ready (bl->client, 498 bc->th =
502 sizeof (struct 499 GNUNET_SERVER_notify_transmit_ready (bl->client,
503 BlacklistMessage), 500 sizeof (struct BlacklistMessage),
504 GNUNET_TIME_UNIT_FOREVER_REL, 501 GNUNET_TIME_UNIT_FOREVER_REL,
505 &transmit_blacklist_message, 502 &transmit_blacklist_message, bc);
506 bc);
507} 503}
508 504
509 505
@@ -517,14 +513,14 @@ do_blacklist_check (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
517 * GNUNET_NO if we must shutdown the connection 513 * GNUNET_NO if we must shutdown the connection
518 */ 514 */
519static void 515static void
520confirm_or_drop_neighbour (void *cls, 516confirm_or_drop_neighbour (void *cls, const struct GNUNET_PeerIdentity *peer,
521 const struct GNUNET_PeerIdentity *peer, int allowed) 517 int allowed)
522{ 518{
523 if (GNUNET_OK == allowed) 519 if (GNUNET_OK == allowed)
524 return; /* we're done */ 520 return; /* we're done */
525 GNUNET_STATISTICS_update (GST_stats, 521 GNUNET_STATISTICS_update (GST_stats,
526 gettext_noop ("# disconnects due to blacklist"), 522 gettext_noop ("# disconnects due to blacklist"), 1,
527 1, GNUNET_NO); 523 GNUNET_NO);
528 GST_neighbours_force_disconnect (peer); 524 GST_neighbours_force_disconnect (peer);
529} 525}
530 526
@@ -556,8 +552,7 @@ struct TestConnectionContext
556 * @param ats_count number of entries in ats (excluding 0-termination) 552 * @param ats_count number of entries in ats (excluding 0-termination)
557 */ 553 */
558static void 554static void
559test_connection_ok (void *cls, 555test_connection_ok (void *cls, const struct GNUNET_PeerIdentity *neighbour,
560 const struct GNUNET_PeerIdentity *neighbour,
561 const struct GNUNET_TRANSPORT_ATS_Information *ats, 556 const struct GNUNET_TRANSPORT_ATS_Information *ats,
562 uint32_t ats_count) 557 uint32_t ats_count)
563{ 558{
@@ -591,8 +586,7 @@ test_connection_ok (void *cls,
591 * @param message the blacklist-init message that was sent 586 * @param message the blacklist-init message that was sent
592 */ 587 */
593void 588void
594GST_blacklist_handle_init (void *cls, 589GST_blacklist_handle_init (void *cls, struct GNUNET_SERVER_Client *client,
595 struct GNUNET_SERVER_Client *client,
596 const struct GNUNET_MessageHeader *message) 590 const struct GNUNET_MessageHeader *message)
597{ 591{
598 struct Blacklisters *bl; 592 struct Blacklisters *bl;
@@ -629,8 +623,7 @@ GST_blacklist_handle_init (void *cls,
629 * @param message the blacklist-init message that was sent 623 * @param message the blacklist-init message that was sent
630 */ 624 */
631void 625void
632GST_blacklist_handle_reply (void *cls, 626GST_blacklist_handle_reply (void *cls, struct GNUNET_SERVER_Client *client,
633 struct GNUNET_SERVER_Client *client,
634 const struct GNUNET_MessageHeader *message) 627 const struct GNUNET_MessageHeader *message)
635{ 628{
636 const struct BlacklistMessage *msg = 629 const struct BlacklistMessage *msg =
@@ -752,8 +745,7 @@ GST_blacklist_test_allowed (const struct GNUNET_PeerIdentity *peer,
752 745
753 if ((blacklist != NULL) && 746 if ((blacklist != NULL) &&
754 (GNUNET_SYSERR == 747 (GNUNET_SYSERR ==
755 GNUNET_CONTAINER_multihashmap_get_multiple (blacklist, 748 GNUNET_CONTAINER_multihashmap_get_multiple (blacklist, &peer->hashPubKey,
756 &peer->hashPubKey,
757 &test_blacklisted, 749 &test_blacklisted,
758 (void *) transport_name))) 750 (void *) transport_name)))
759 { 751 {
diff --git a/src/transport/gnunet-service-transport_clients.c b/src/transport/gnunet-service-transport_clients.c
index 542e3e00b..3ad2149bb 100644
--- a/src/transport/gnunet-service-transport_clients.c
+++ b/src/transport/gnunet-service-transport_clients.c
@@ -205,8 +205,8 @@ transmit_to_client_callback (void *cls, size_t size, void *buf)
205 "Transmitting message of type %u to client.\n", 205 "Transmitting message of type %u to client.\n",
206 ntohs (msg->type)); 206 ntohs (msg->type));
207#endif 207#endif
208 GNUNET_CONTAINER_DLL_remove (tc->message_queue_head, 208 GNUNET_CONTAINER_DLL_remove (tc->message_queue_head, tc->message_queue_tail,
209 tc->message_queue_tail, q); 209 q);
210 tc->message_count--; 210 tc->message_count--;
211 memcpy (&cbuf[tsize], msg, msize); 211 memcpy (&cbuf[tsize], msg, msize);
212 GNUNET_free (q); 212 GNUNET_free (q);
@@ -215,11 +215,10 @@ transmit_to_client_callback (void *cls, size_t size, void *buf)
215 if (NULL != q) 215 if (NULL != q)
216 { 216 {
217 GNUNET_assert (msize >= sizeof (struct GNUNET_MessageHeader)); 217 GNUNET_assert (msize >= sizeof (struct GNUNET_MessageHeader));
218 tc->th = GNUNET_SERVER_notify_transmit_ready (tc->client, 218 tc->th =
219 msize, 219 GNUNET_SERVER_notify_transmit_ready (tc->client, msize,
220 GNUNET_TIME_UNIT_FOREVER_REL, 220 GNUNET_TIME_UNIT_FOREVER_REL,
221 &transmit_to_client_callback, 221 &transmit_to_client_callback, tc);
222 tc);
223 GNUNET_assert (tc->th != NULL); 222 GNUNET_assert (tc->th != NULL);
224 } 223 }
225 return tsize; 224 return tsize;
@@ -234,8 +233,8 @@ transmit_to_client_callback (void *cls, size_t size, void *buf)
234 * @param may_drop GNUNET_YES if the message can be dropped 233 * @param may_drop GNUNET_YES if the message can be dropped
235 */ 234 */
236static void 235static void
237unicast (struct TransportClient *tc, 236unicast (struct TransportClient *tc, const struct GNUNET_MessageHeader *msg,
238 const struct GNUNET_MessageHeader *msg, int may_drop) 237 int may_drop)
239{ 238{
240 struct ClientMessageQueueEntry *q; 239 struct ClientMessageQueueEntry *q;
241 uint16_t msize; 240 uint16_t msize;
@@ -262,11 +261,10 @@ unicast (struct TransportClient *tc,
262 tc->message_count++; 261 tc->message_count++;
263 if (tc->th != NULL) 262 if (tc->th != NULL)
264 return; 263 return;
265 tc->th = GNUNET_SERVER_notify_transmit_ready (tc->client, 264 tc->th =
266 msize, 265 GNUNET_SERVER_notify_transmit_ready (tc->client, msize,
267 GNUNET_TIME_UNIT_FOREVER_REL, 266 GNUNET_TIME_UNIT_FOREVER_REL,
268 &transmit_to_client_callback, 267 &transmit_to_client_callback, tc);
269 tc);
270 GNUNET_assert (tc->th != NULL); 268 GNUNET_assert (tc->th != NULL);
271} 269}
272 270
@@ -295,8 +293,8 @@ client_disconnect_notification (void *cls, struct GNUNET_SERVER_Client *client)
295#endif 293#endif
296 while (NULL != (mqe = tc->message_queue_head)) 294 while (NULL != (mqe = tc->message_queue_head))
297 { 295 {
298 GNUNET_CONTAINER_DLL_remove (tc->message_queue_head, 296 GNUNET_CONTAINER_DLL_remove (tc->message_queue_head, tc->message_queue_tail,
299 tc->message_queue_tail, mqe); 297 mqe);
300 tc->message_count--; 298 tc->message_count--;
301 GNUNET_free (mqe); 299 GNUNET_free (mqe);
302 } 300 }
@@ -339,8 +337,8 @@ notify_client_about_neighbour (void *cls,
339 cim->header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_CONNECT); 337 cim->header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_CONNECT);
340 cim->ats_count = htonl (ats_count); 338 cim->ats_count = htonl (ats_count);
341 cim->id = *peer; 339 cim->id = *peer;
342 memcpy (&cim->ats, 340 memcpy (&cim->ats, ats,
343 ats, ats_count * sizeof (struct GNUNET_TRANSPORT_ATS_Information)); 341 ats_count * sizeof (struct GNUNET_TRANSPORT_ATS_Information));
344 unicast (tc, &cim->header, GNUNET_NO); 342 unicast (tc, &cim->header, GNUNET_NO);
345 GNUNET_free (cim); 343 GNUNET_free (cim);
346} 344}
@@ -356,8 +354,7 @@ notify_client_about_neighbour (void *cls,
356 * @param message the start message that was sent 354 * @param message the start message that was sent
357 */ 355 */
358static void 356static void
359clients_handle_start (void *cls, 357clients_handle_start (void *cls, struct GNUNET_SERVER_Client *client,
360 struct GNUNET_SERVER_Client *client,
361 const struct GNUNET_MessageHeader *message) 358 const struct GNUNET_MessageHeader *message)
362{ 359{
363 const struct StartMessage *start; 360 const struct StartMessage *start;
@@ -373,8 +370,9 @@ clients_handle_start (void *cls,
373 } 370 }
374 start = (const struct StartMessage *) message; 371 start = (const struct StartMessage *) message;
375 if ((GNUNET_NO != ntohl (start->do_check)) && 372 if ((GNUNET_NO != ntohl (start->do_check)) &&
376 (0 != memcmp (&start->self, 373 (0 !=
377 &GST_my_identity, sizeof (struct GNUNET_PeerIdentity)))) 374 memcmp (&start->self, &GST_my_identity,
375 sizeof (struct GNUNET_PeerIdentity))))
378 { 376 {
379 /* client thinks this is a different peer, reject */ 377 /* client thinks this is a different peer, reject */
380 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 378 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
@@ -399,8 +397,7 @@ clients_handle_start (void *cls,
399 * @param message the HELLO message 397 * @param message the HELLO message
400 */ 398 */
401static void 399static void
402clients_handle_hello (void *cls, 400clients_handle_hello (void *cls, struct GNUNET_SERVER_Client *client,
403 struct GNUNET_SERVER_Client *client,
404 const struct GNUNET_MessageHeader *message) 401 const struct GNUNET_MessageHeader *message)
405{ 402{
406 GST_validation_handle_hello (message); 403 GST_validation_handle_hello (message);
@@ -458,8 +455,7 @@ handle_send_transmit_continuation (void *cls, int success)
458 * @param message the send message that was sent 455 * @param message the send message that was sent
459 */ 456 */
460static void 457static void
461clients_handle_send (void *cls, 458clients_handle_send (void *cls, struct GNUNET_SERVER_Client *client,
462 struct GNUNET_SERVER_Client *client,
463 const struct GNUNET_MessageHeader *message) 459 const struct GNUNET_MessageHeader *message)
464{ 460{
465 const struct OutboundMessage *obm; 461 const struct OutboundMessage *obm;
@@ -509,8 +505,7 @@ clients_handle_send (void *cls,
509 stcc->target = obm->peer; 505 stcc->target = obm->peer;
510 stcc->client = client; 506 stcc->client = client;
511 GNUNET_SERVER_client_keep (client); 507 GNUNET_SERVER_client_keep (client);
512 GST_neighbours_send (&obm->peer, 508 GST_neighbours_send (&obm->peer, obmm, msize,
513 obmm, msize,
514 GNUNET_TIME_relative_ntoh (obm->timeout), 509 GNUNET_TIME_relative_ntoh (obm->timeout),
515 &handle_send_transmit_continuation, stcc); 510 &handle_send_transmit_continuation, stcc);
516} 511}
@@ -526,8 +521,8 @@ clients_handle_send (void *cls,
526 * GNUNET_NO if not 521 * GNUNET_NO if not
527 */ 522 */
528static void 523static void
529try_connect_if_allowed (void *cls, 524try_connect_if_allowed (void *cls, const struct GNUNET_PeerIdentity *peer,
530 const struct GNUNET_PeerIdentity *peer, int result) 525 int result)
531{ 526{
532 if (GNUNET_OK != result) 527 if (GNUNET_OK != result)
533 return; /* not allowed */ 528 return; /* not allowed */
@@ -543,8 +538,7 @@ try_connect_if_allowed (void *cls,
543 * @param message the actual message 538 * @param message the actual message
544 */ 539 */
545static void 540static void
546clients_handle_request_connect (void *cls, 541clients_handle_request_connect (void *cls, struct GNUNET_SERVER_Client *client,
547 struct GNUNET_SERVER_Client *client,
548 const struct GNUNET_MessageHeader *message) 542 const struct GNUNET_MessageHeader *message)
549{ 543{
550 const struct TransportRequestConnectMessage *trcm = 544 const struct TransportRequestConnectMessage *trcm =
@@ -559,8 +553,8 @@ clients_handle_request_connect (void *cls,
559 "Received a request connect message for peer `%s'\n", 553 "Received a request connect message for peer `%s'\n",
560 GNUNET_i2s (&trcm->peer)); 554 GNUNET_i2s (&trcm->peer));
561#endif 555#endif
562 (void) GST_blacklist_test_allowed (&trcm->peer, NULL, 556 (void) GST_blacklist_test_allowed (&trcm->peer, NULL, &try_connect_if_allowed,
563 &try_connect_if_allowed, NULL); 557 NULL);
564 GNUNET_SERVER_receive_done (client, GNUNET_OK); 558 GNUNET_SERVER_receive_done (client, GNUNET_OK);
565} 559}
566 560
@@ -573,21 +567,19 @@ clients_handle_request_connect (void *cls,
573 * @param message the quota changing message 567 * @param message the quota changing message
574 */ 568 */
575static void 569static void
576clients_handle_set_quota (void *cls, 570clients_handle_set_quota (void *cls, struct GNUNET_SERVER_Client *client,
577 struct GNUNET_SERVER_Client *client,
578 const struct GNUNET_MessageHeader *message) 571 const struct GNUNET_MessageHeader *message)
579{ 572{
580 const struct QuotaSetMessage *qsm; 573 const struct QuotaSetMessage *qsm;
581 574
582 qsm = (const struct QuotaSetMessage *) message; 575 qsm = (const struct QuotaSetMessage *) message;
583 GNUNET_STATISTICS_update (GST_stats, 576 GNUNET_STATISTICS_update (GST_stats,
584 gettext_noop ("# SET QUOTA messages received"), 577 gettext_noop ("# SET QUOTA messages received"), 1,
585 1, GNUNET_NO); 578 GNUNET_NO);
586#if DEBUG_TRANSPORT 579#if DEBUG_TRANSPORT
587 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 580 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
588 "Received `%s' request (new quota %u) from client for peer `%4s'\n", 581 "Received `%s' request (new quota %u) from client for peer `%4s'\n",
589 "SET_QUOTA", 582 "SET_QUOTA", (unsigned int) ntohl (qsm->quota.value__),
590 (unsigned int) ntohl (qsm->quota.value__),
591 GNUNET_i2s (&qsm->peer)); 583 GNUNET_i2s (&qsm->peer));
592#endif 584#endif
593 GST_neighbours_set_incoming_quota (&qsm->peer, qsm->quota); 585 GST_neighbours_set_incoming_quota (&qsm->peer, qsm->quota);
@@ -614,8 +606,7 @@ transmit_address_to_client (void *cls, const char *address)
614 GNUNET_SERVER_transmit_context_run (tc, GNUNET_TIME_UNIT_FOREVER_REL); 606 GNUNET_SERVER_transmit_context_run (tc, GNUNET_TIME_UNIT_FOREVER_REL);
615 return; 607 return;
616 } 608 }
617 GNUNET_SERVER_transmit_context_append_data (tc, 609 GNUNET_SERVER_transmit_context_append_data (tc, address, strlen (address) + 1,
618 address, strlen (address) + 1,
619 GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_REPLY); 610 GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_REPLY);
620} 611}
621 612
@@ -628,8 +619,7 @@ transmit_address_to_client (void *cls, const char *address)
628 * @param message the resolution request 619 * @param message the resolution request
629 */ 620 */
630static void 621static void
631clients_handle_address_lookup (void *cls, 622clients_handle_address_lookup (void *cls, struct GNUNET_SERVER_Client *client,
632 struct GNUNET_SERVER_Client *client,
633 const struct GNUNET_MessageHeader *message) 623 const struct GNUNET_MessageHeader *message)
634{ 624{
635 const struct AddressLookupMessage *alum; 625 const struct AddressLookupMessage *alum;
@@ -659,8 +649,8 @@ clients_handle_address_lookup (void *cls,
659 } 649 }
660 address = (const char *) &alum[1]; 650 address = (const char *) &alum[1];
661 plugin_name = (const char *) &address[address_len]; 651 plugin_name = (const char *) &address[address_len];
662 if (plugin_name 652 if (plugin_name[size - sizeof (struct AddressLookupMessage) - address_len - 1]
663 [size - sizeof (struct AddressLookupMessage) - address_len - 1] != '\0') 653 != '\0')
664 { 654 {
665 GNUNET_break (0); 655 GNUNET_break (0);
666 GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); 656 GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
@@ -678,11 +668,9 @@ clients_handle_address_lookup (void *cls,
678 return; 668 return;
679 } 669 }
680 GNUNET_SERVER_disable_receive_done_warning (client); 670 GNUNET_SERVER_disable_receive_done_warning (client);
681 papi->address_pretty_printer (papi->cls, 671 papi->address_pretty_printer (papi->cls, plugin_name, address, address_len,
682 plugin_name, 672 numeric, rtimeout, &transmit_address_to_client,
683 address, address_len, 673 tc);
684 numeric,
685 rtimeout, &transmit_address_to_client, tc);
686} 674}
687 675
688 676
@@ -714,12 +702,11 @@ send_address_to_client (void *cls,
714 702
715 /* FIXME: move to a binary format!!! */ 703 /* FIXME: move to a binary format!!! */
716 GNUNET_asprintf (&addr_buf, "%s --- %s, %s", 704 GNUNET_asprintf (&addr_buf, "%s --- %s, %s",
717 GST_plugins_a2s (plugin_name, 705 GST_plugins_a2s (plugin_name, plugin_address,
718 plugin_address,
719 plugin_address_len), 706 plugin_address_len),
720 (GNUNET_YES == GST_neighbours_test_connected (target)) 707 (GNUNET_YES ==
721 ? "CONNECTED" 708 GST_neighbours_test_connected (target)) ? "CONNECTED" :
722 : "DISCONNECTED", 709 "DISCONNECTED",
723 (GNUNET_TIME_absolute_get_remaining (valid_until).rel_value > 710 (GNUNET_TIME_absolute_get_remaining (valid_until).rel_value >
724 0) ? "VALIDATED" : "UNVALIDATED"); 711 0) ? "VALIDATED" : "UNVALIDATED");
725 transmit_address_to_client (tc, addr_buf); 712 transmit_address_to_client (tc, addr_buf);
@@ -749,8 +736,7 @@ clients_handle_peer_address_lookup (void *cls,
749 tc = GNUNET_SERVER_transmit_context_create (client); 736 tc = GNUNET_SERVER_transmit_context_create (client);
750 GST_validation_get_addresses (&peer_address_lookup->peer, 737 GST_validation_get_addresses (&peer_address_lookup->peer,
751 &send_address_to_client, tc); 738 &send_address_to_client, tc);
752 GNUNET_SERVER_transmit_context_append_data (tc, 739 GNUNET_SERVER_transmit_context_append_data (tc, NULL, 0,
753 NULL, 0,
754 GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_REPLY); 740 GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_REPLY);
755 GNUNET_SERVER_transmit_context_run (tc, GNUNET_TIME_UNIT_FOREVER_REL); 741 GNUNET_SERVER_transmit_context_run (tc, GNUNET_TIME_UNIT_FOREVER_REL);
756} 742}
@@ -765,8 +751,7 @@ clients_handle_peer_address_lookup (void *cls,
765 * @param ats_count number of entries in ats (excluding 0-termination) 751 * @param ats_count number of entries in ats (excluding 0-termination)
766 */ 752 */
767static void 753static void
768output_addresses (void *cls, 754output_addresses (void *cls, const struct GNUNET_PeerIdentity *neighbour,
769 const struct GNUNET_PeerIdentity *neighbour,
770 const struct GNUNET_TRANSPORT_ATS_Information *ats, 755 const struct GNUNET_TRANSPORT_ATS_Information *ats,
771 uint32_t ats_count) 756 uint32_t ats_count)
772{ 757{
@@ -774,9 +759,8 @@ output_addresses (void *cls,
774 char *addr_buf; 759 char *addr_buf;
775 760
776 /* FIXME: move to a binary format!!! */ 761 /* FIXME: move to a binary format!!! */
777 GNUNET_asprintf (&addr_buf, 762 GNUNET_asprintf (&addr_buf, "%s: %s", GNUNET_i2s (neighbour),
778 "%s: %s", 763 GST_plugins_a2s ("FIXME", NULL, 0));
779 GNUNET_i2s (neighbour), GST_plugins_a2s ("FIXME", NULL, 0));
780 transmit_address_to_client (tc, addr_buf); 764 transmit_address_to_client (tc, addr_buf);
781 GNUNET_free (addr_buf); 765 GNUNET_free (addr_buf);
782} 766}
@@ -791,8 +775,7 @@ output_addresses (void *cls,
791 * @param message the peer address information request 775 * @param message the peer address information request
792 */ 776 */
793static void 777static void
794clients_handle_address_iterate (void *cls, 778clients_handle_address_iterate (void *cls, struct GNUNET_SERVER_Client *client,
795 struct GNUNET_SERVER_Client *client,
796 const struct GNUNET_MessageHeader *message) 779 const struct GNUNET_MessageHeader *message)
797{ 780{
798 struct GNUNET_SERVER_TransmitContext *tc; 781 struct GNUNET_SERVER_TransmitContext *tc;
@@ -843,8 +826,8 @@ GST_clients_start (struct GNUNET_SERVER_Handle *server)
843 {NULL, NULL, 0, 0} 826 {NULL, NULL, 0, 0}
844 }; 827 };
845 GNUNET_SERVER_add_handlers (server, handlers); 828 GNUNET_SERVER_add_handlers (server, handlers);
846 GNUNET_SERVER_disconnect_notify (server, 829 GNUNET_SERVER_disconnect_notify (server, &client_disconnect_notification,
847 &client_disconnect_notification, NULL); 830 NULL);
848} 831}
849 832
850 833
diff --git a/src/transport/gnunet-service-transport_hello.c b/src/transport/gnunet-service-transport_hello.c
index a2d0d966c..3c51c5df2 100644
--- a/src/transport/gnunet-service-transport_hello.c
+++ b/src/transport/gnunet-service-transport_hello.c
@@ -141,10 +141,10 @@ address_generator (void *cls, size_t max, void *buf)
141 141
142 if (NULL == gc->addr_pos) 142 if (NULL == gc->addr_pos)
143 return 0; 143 return 0;
144 ret = GNUNET_HELLO_add_address (gc->addr_pos->plugin_name, 144 ret =
145 gc->expiration, 145 GNUNET_HELLO_add_address (gc->addr_pos->plugin_name, gc->expiration,
146 &gc->addr_pos[1], 146 &gc->addr_pos[1], gc->addr_pos->addrlen, buf,
147 gc->addr_pos->addrlen, buf, max); 147 max);
148 gc->addr_pos = gc->addr_pos->next; 148 gc->addr_pos = gc->addr_pos->next;
149 return ret; 149 return ret;
150} 150}
@@ -173,15 +173,14 @@ refresh_hello_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
173 "Refreshed my `%s', new size is %d\n", "HELLO", 173 "Refreshed my `%s', new size is %d\n", "HELLO",
174 GNUNET_HELLO_size (our_hello)); 174 GNUNET_HELLO_size (our_hello));
175#endif 175#endif
176 GNUNET_STATISTICS_update (GST_stats, 176 GNUNET_STATISTICS_update (GST_stats, gettext_noop ("# refreshed my HELLO"), 1,
177 gettext_noop ("# refreshed my HELLO"), 177 GNUNET_NO);
178 1, GNUNET_NO);
179 if (NULL != hello_cb) 178 if (NULL != hello_cb)
180 hello_cb (hello_cb_cls, GST_hello_get ()); 179 hello_cb (hello_cb_cls, GST_hello_get ());
181 GNUNET_PEERINFO_add_peer (GST_peerinfo, our_hello); 180 GNUNET_PEERINFO_add_peer (GST_peerinfo, our_hello);
182 hello_task 181 hello_task =
183 = GNUNET_SCHEDULER_add_delayed (HELLO_REFRESH_PERIOD, 182 GNUNET_SCHEDULER_add_delayed (HELLO_REFRESH_PERIOD, &refresh_hello_task,
184 &refresh_hello_task, NULL); 183 NULL);
185 184
186} 185}
187 186
@@ -257,8 +256,7 @@ GST_hello_get ()
257 * @param plugin_address_len number of bytes in plugin_address 256 * @param plugin_address_len number of bytes in plugin_address
258 */ 257 */
259void 258void
260GST_hello_modify_addresses (int addremove, 259GST_hello_modify_addresses (int addremove, const char *plugin_name,
261 const char *plugin_name,
262 const void *plugin_address, 260 const void *plugin_address,
263 size_t plugin_address_len) 261 size_t plugin_address_len)
264{ 262{
@@ -266,9 +264,9 @@ GST_hello_modify_addresses (int addremove,
266 264
267#if DEBUG_TRANSPORT 265#if DEBUG_TRANSPORT
268 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 266 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
269 (add_remove == GNUNET_YES) 267 (add_remove ==
270 ? "Adding `%s':%s to the set of our addresses\n" 268 GNUNET_YES) ? "Adding `%s':%s to the set of our addresses\n" :
271 : "Removing `%s':%s from the set of our addresses\n", 269 "Removing `%s':%s from the set of our addresses\n",
272 GST_plugins_a2s (plugin_name, addr, addrlen), p->short_name); 270 GST_plugins_a2s (plugin_name, addr, addrlen), p->short_name);
273#endif 271#endif
274 GNUNET_assert (plugin_address != NULL); 272 GNUNET_assert (plugin_address != NULL);
@@ -311,8 +309,7 @@ GST_hello_modify_addresses (int addremove,
311 * GNUNET_NO if not 309 * GNUNET_NO if not
312 */ 310 */
313int 311int
314GST_hello_test_address (const char *plugin_name, 312GST_hello_test_address (const char *plugin_name, const void *plugin_address,
315 const void *plugin_address,
316 size_t plugin_address_len, 313 size_t plugin_address_len,
317 struct GNUNET_CRYPTO_RsaSignature **sig, 314 struct GNUNET_CRYPTO_RsaSignature **sig,
318 struct GNUNET_TIME_Absolute **sig_expiration) 315 struct GNUNET_TIME_Absolute **sig_expiration)
diff --git a/src/transport/gnunet-service-transport_neighbours.c b/src/transport/gnunet-service-transport_neighbours.c
index 386894d48..251b4c356 100644
--- a/src/transport/gnunet-service-transport_neighbours.c
+++ b/src/transport/gnunet-service-transport_neighbours.c
@@ -246,8 +246,8 @@ lookup_neighbour (const struct GNUNET_PeerIdentity *pid)
246 * @param cls the 'struct NeighbourMapEntry' 246 * @param cls the 'struct NeighbourMapEntry'
247 * @param tc scheduler context 247 * @param tc scheduler context
248 */ 248 */
249static void 249static void transmission_task (void *cls,
250transmission_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc); 250 const struct GNUNET_SCHEDULER_TaskContext *tc);
251 251
252 252
253/** 253/**
@@ -318,15 +318,11 @@ try_transmission_to_peer (struct NeighbourMapEntry *n)
318 GNUNET_CONTAINER_DLL_remove (n->messages_head, n->messages_tail, mq); 318 GNUNET_CONTAINER_DLL_remove (n->messages_head, n->messages_tail, mq);
319 n->is_active = mq; 319 n->is_active = mq;
320 mq->n = n; 320 mq->n = n;
321 ret = papi->send (papi->cls, 321 ret =
322 &n->id, 322 papi->send (papi->cls, &n->id, mq->message_buf, mq->message_buf_size,
323 mq->message_buf, 323 0 /* priority -- remove from plugin API? */ ,
324 mq->message_buf_size, 324 timeout, n->session, n->addr, n->addrlen, GNUNET_YES,
325 0 /* priority -- remove from plugin API? */ , 325 &transmit_send_continuation, mq);
326 timeout,
327 n->session,
328 n->addr,
329 n->addrlen, GNUNET_YES, &transmit_send_continuation, mq);
330 if (ret == -1) 326 if (ret == -1)
331 { 327 {
332 /* failure, but 'send' would not call continuation in this case, 328 /* failure, but 'send' would not call continuation in this case,
@@ -361,8 +357,7 @@ transmission_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
361 * @param disconnect_cb function to call if we disconnect from a peer 357 * @param disconnect_cb function to call if we disconnect from a peer
362 */ 358 */
363void 359void
364GST_neighbours_start (void *cls, 360GST_neighbours_start (void *cls, GNUNET_TRANSPORT_NotifyConnect connect_cb,
365 GNUNET_TRANSPORT_NotifyConnect connect_cb,
366 GNUNET_TRANSPORT_NotifyDisconnect disconnect_cb) 361 GNUNET_TRANSPORT_NotifyDisconnect disconnect_cb)
367{ 362{
368 callback_cls = cls; 363 callback_cls = cls;
@@ -466,8 +461,7 @@ disconnect_all_neighbours (void *cls, const GNUNET_HashCode * key, void *value)
466 struct NeighbourMapEntry *n = value; 461 struct NeighbourMapEntry *n = value;
467 462
468#if DEBUG_TRANSPORT 463#if DEBUG_TRANSPORT
469 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 464 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Disconnecting peer `%4s', %s\n",
470 "Disconnecting peer `%4s', %s\n",
471 GNUNET_i2s (&n->id), "SHUTDOWN_TASK"); 465 GNUNET_i2s (&n->id), "SHUTDOWN_TASK");
472#endif 466#endif
473 disconnect_neighbour (n); 467 disconnect_neighbour (n);
@@ -481,8 +475,8 @@ disconnect_all_neighbours (void *cls, const GNUNET_HashCode * key, void *value)
481void 475void
482GST_neighbours_stop () 476GST_neighbours_stop ()
483{ 477{
484 GNUNET_CONTAINER_multihashmap_iterate (neighbours, 478 GNUNET_CONTAINER_multihashmap_iterate (neighbours, &disconnect_all_neighbours,
485 &disconnect_all_neighbours, NULL); 479 NULL);
486 GNUNET_CONTAINER_multihashmap_destroy (neighbours); 480 GNUNET_CONTAINER_multihashmap_destroy (neighbours);
487 neighbours = NULL; 481 neighbours = NULL;
488 callback_cls = NULL; 482 callback_cls = NULL;
@@ -506,10 +500,8 @@ GST_neighbours_stop ()
506 */ 500 */
507void 501void
508GST_neighbours_switch_to_address (const struct GNUNET_PeerIdentity *peer, 502GST_neighbours_switch_to_address (const struct GNUNET_PeerIdentity *peer,
509 const char *plugin_name, 503 const char *plugin_name, const void *address,
510 const void *address, 504 size_t address_len, struct Session *session,
511 size_t address_len,
512 struct Session *session,
513 const struct GNUNET_TRANSPORT_ATS_Information 505 const struct GNUNET_TRANSPORT_ATS_Information
514 *ats, uint32_t ats_count) 506 *ats, uint32_t ats_count)
515{ 507{
@@ -528,8 +520,8 @@ GST_neighbours_switch_to_address (const struct GNUNET_PeerIdentity *peer,
528 n->addrlen = address_len; 520 n->addrlen = address_len;
529 n->session = session; 521 n->session = session;
530 GNUNET_array_grow (n->ats, n->ats_count, ats_count); 522 GNUNET_array_grow (n->ats, n->ats_count, ats_count);
531 memcpy (n->ats, 523 memcpy (n->ats, ats,
532 ats, ats_count * sizeof (struct GNUNET_TRANSPORT_ATS_Information)); 524 ats_count * sizeof (struct GNUNET_TRANSPORT_ATS_Information));
533 GNUNET_free_non_null (n->plugin_name); 525 GNUNET_free_non_null (n->plugin_name);
534 n->plugin_name = GNUNET_strdup (plugin_name); 526 n->plugin_name = GNUNET_strdup (plugin_name);
535 GNUNET_SCHEDULER_cancel (n->timeout_task); 527 GNUNET_SCHEDULER_cancel (n->timeout_task);
@@ -538,9 +530,7 @@ GST_neighbours_switch_to_address (const struct GNUNET_PeerIdentity *peer,
538 &neighbour_timeout_task, n); 530 &neighbour_timeout_task, n);
539 connect_msg.size = htons (sizeof (struct GNUNET_MessageHeader)); 531 connect_msg.size = htons (sizeof (struct GNUNET_MessageHeader));
540 connect_msg.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_CONNECT); 532 connect_msg.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_CONNECT);
541 GST_neighbours_send (peer, 533 GST_neighbours_send (peer, &connect_msg, sizeof (connect_msg),
542 &connect_msg,
543 sizeof (connect_msg),
544 GNUNET_TIME_UNIT_FOREVER_REL, NULL, NULL); 534 GNUNET_TIME_UNIT_FOREVER_REL, NULL, NULL);
545} 535}
546 536
@@ -558,10 +548,8 @@ GST_neighbours_switch_to_address (const struct GNUNET_PeerIdentity *peer,
558 * @param ats_count number of performance records in 'ats' 548 * @param ats_count number of performance records in 'ats'
559 */ 549 */
560static void 550static void
561try_connect_using_address (void *cls, 551try_connect_using_address (void *cls, const struct GNUNET_PeerIdentity *target,
562 const struct GNUNET_PeerIdentity *target, 552 const char *plugin_name, const void *plugin_address,
563 const char *plugin_name,
564 const void *plugin_address,
565 size_t plugin_address_len, 553 size_t plugin_address_len,
566 struct GNUNET_BANDWIDTH_Value32NBO bandwidth, 554 struct GNUNET_BANDWIDTH_Value32NBO bandwidth,
567 const struct GNUNET_TRANSPORT_ATS_Information *ats, 555 const struct GNUNET_TRANSPORT_ATS_Information *ats,
@@ -570,9 +558,7 @@ try_connect_using_address (void *cls,
570 struct NeighbourMapEntry *n = cls; 558 struct NeighbourMapEntry *n = cls;
571 559
572 n->asc = NULL; 560 n->asc = NULL;
573 GST_neighbours_switch_to_address (target, 561 GST_neighbours_switch_to_address (target, plugin_name, plugin_address,
574 plugin_name,
575 plugin_address,
576 plugin_address_len, NULL, ats, ats_count); 562 plugin_address_len, NULL, ats, ats_count);
577 if (GNUNET_YES == n->is_connected) 563 if (GNUNET_YES == n->is_connected)
578 return; 564 return;
@@ -591,9 +577,9 @@ GST_neighbours_try_connect (const struct GNUNET_PeerIdentity *target)
591{ 577{
592 struct NeighbourMapEntry *n; 578 struct NeighbourMapEntry *n;
593 579
594 GNUNET_assert (0 != memcmp (target, 580 GNUNET_assert (0 !=
595 &GST_my_identity, 581 memcmp (target, &GST_my_identity,
596 sizeof (struct GNUNET_PeerIdentity))); 582 sizeof (struct GNUNET_PeerIdentity)));
597 n = lookup_neighbour (target); 583 n = lookup_neighbour (target);
598 if ((NULL != n) && (GNUNET_YES == n->is_connected)) 584 if ((NULL != n) && (GNUNET_YES == n->is_connected))
599 return; /* already connected */ 585 return; /* already connected */
@@ -614,8 +600,9 @@ GST_neighbours_try_connect (const struct GNUNET_PeerIdentity *target)
614 } 600 }
615 if (n->asc != NULL) 601 if (n->asc != NULL)
616 return; /* already trying */ 602 return; /* already trying */
617 n->asc = GNUNET_ATS_suggest_address (GST_ats, 603 n->asc =
618 target, &try_connect_using_address, n); 604 GNUNET_ATS_suggest_address (GST_ats, target, &try_connect_using_address,
605 n);
619} 606}
620 607
621 608
@@ -684,10 +671,8 @@ GST_neighbours_session_terminated (const struct GNUNET_PeerIdentity *peer,
684 * @param cont_cls closure for 'cont' 671 * @param cont_cls closure for 'cont'
685 */ 672 */
686void 673void
687GST_neighbours_send (const struct GNUNET_PeerIdentity *target, 674GST_neighbours_send (const struct GNUNET_PeerIdentity *target, const void *msg,
688 const void *msg, 675 size_t msg_size, struct GNUNET_TIME_Relative timeout,
689 size_t msg_size,
690 struct GNUNET_TIME_Relative timeout,
691 GST_NeighbourSendContinuation cont, void *cont_cls) 676 GST_NeighbourSendContinuation cont, void *cont_cls)
692{ 677{
693 struct NeighbourMapEntry *n; 678 struct NeighbourMapEntry *n;
@@ -785,8 +770,8 @@ GST_neighbours_calculate_receive_delay (const struct GNUNET_PeerIdentity
785#if DEBUG_TRANSPORT 770#if DEBUG_TRANSPORT
786 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 771 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
787 "Throttling read (%llu bytes excess at %u b/s), waiting %llu ms before reading more.\n", 772 "Throttling read (%llu bytes excess at %u b/s), waiting %llu ms before reading more.\n",
788 (unsigned long long) n-> 773 (unsigned long long) n->in_tracker.
789 in_tracker.consumption_since_last_update__, 774 consumption_since_last_update__,
790 (unsigned int) n->in_tracker.available_bytes_per_s__, 775 (unsigned int) n->in_tracker.available_bytes_per_s__,
791 (unsigned long long) ret.rel_value); 776 (unsigned long long) ret.rel_value);
792#endif 777#endif
@@ -850,13 +835,12 @@ GST_neighbours_set_incoming_quota (const struct GNUNET_PeerIdentity *neighbour,
850 if (0 != ntohl (quota.value__)) 835 if (0 != ntohl (quota.value__))
851 return; 836 return;
852#if DEBUG_TRANSPORT 837#if DEBUG_TRANSPORT
853 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 838 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Disconnecting peer `%4s' due to `%s'\n",
854 "Disconnecting peer `%4s' due to `%s'\n",
855 GNUNET_i2s (&n->id), "SET_QUOTA"); 839 GNUNET_i2s (&n->id), "SET_QUOTA");
856#endif 840#endif
857 GNUNET_STATISTICS_update (GST_stats, 841 GNUNET_STATISTICS_update (GST_stats,
858 gettext_noop ("# disconnects due to quota of 0"), 842 gettext_noop ("# disconnects due to quota of 0"), 1,
859 1, GNUNET_NO); 843 GNUNET_NO);
860 disconnect_neighbour (n); 844 disconnect_neighbour (n);
861} 845}
862 846
@@ -939,13 +923,11 @@ GST_neighbours_force_disconnect (const struct GNUNET_PeerIdentity *target)
939 disconnect_msg.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_CONNECT); 923 disconnect_msg.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_CONNECT);
940 papi = GST_plugins_find (n->plugin_name); 924 papi = GST_plugins_find (n->plugin_name);
941 if (papi != NULL) 925 if (papi != NULL)
942 papi->send (papi->cls, 926 papi->send (papi->cls, target, (const void *) &disconnect_msg,
943 target,
944 (const void *) &disconnect_msg,
945 sizeof (struct GNUNET_MessageHeader), 927 sizeof (struct GNUNET_MessageHeader),
946 UINT32_MAX /* priority */ , 928 UINT32_MAX /* priority */ ,
947 GNUNET_TIME_UNIT_FOREVER_REL, 929 GNUNET_TIME_UNIT_FOREVER_REL, n->session, n->addr, n->addrlen,
948 n->session, n->addr, n->addrlen, GNUNET_YES, NULL, NULL); 930 GNUNET_YES, NULL, NULL);
949 } 931 }
950 disconnect_neighbour (n); 932 disconnect_neighbour (n);
951} 933}
diff --git a/src/transport/gnunet-service-transport_plugins.c b/src/transport/gnunet-service-transport_plugins.c
index 87901d2cc..c32ac3acc 100644
--- a/src/transport/gnunet-service-transport_plugins.c
+++ b/src/transport/gnunet-service-transport_plugins.c
@@ -102,8 +102,7 @@ GST_plugins_load (GNUNET_TRANSPORT_PluginReceiveCallback recv_cb,
102 char *pos; 102 char *pos;
103 103
104 if (GNUNET_OK != 104 if (GNUNET_OK !=
105 GNUNET_CONFIGURATION_get_value_number (GST_cfg, 105 GNUNET_CONFIGURATION_get_value_number (GST_cfg, "TRANSPORT",
106 "TRANSPORT",
107 "NEIGHBOUR_LIMIT", &tneigh)) 106 "NEIGHBOUR_LIMIT", &tneigh))
108 { 107 {
109 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 108 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
@@ -111,15 +110,15 @@ GST_plugins_load (GNUNET_TRANSPORT_PluginReceiveCallback recv_cb,
111 return; 110 return;
112 } 111 }
113 if (GNUNET_OK != 112 if (GNUNET_OK !=
114 GNUNET_CONFIGURATION_get_value_string (GST_cfg, 113 GNUNET_CONFIGURATION_get_value_string (GST_cfg, "TRANSPORT", "PLUGINS",
115 "TRANSPORT", "PLUGINS", &plugs)) 114 &plugs))
116 return; 115 return;
117 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 116 GNUNET_log (GNUNET_ERROR_TYPE_INFO, _("Starting transport plugins `%s'\n"),
118 _("Starting transport plugins `%s'\n"), plugs); 117 plugs);
119 for (pos = strtok (plugs, " "); pos != NULL; pos = strtok (NULL, " ")) 118 for (pos = strtok (plugs, " "); pos != NULL; pos = strtok (NULL, " "))
120 { 119 {
121 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 120 GNUNET_log (GNUNET_ERROR_TYPE_INFO, _("Loading `%s' transport plugin\n"),
122 _("Loading `%s' transport plugin\n"), pos); 121 pos);
123 GNUNET_asprintf (&libname, "libgnunet_plugin_transport_%s", pos); 122 GNUNET_asprintf (&libname, "libgnunet_plugin_transport_%s", pos);
124 plug = GNUNET_malloc (sizeof (struct TransportPlugin)); 123 plug = GNUNET_malloc (sizeof (struct TransportPlugin));
125 plug->short_name = GNUNET_strdup (pos); 124 plug->short_name = GNUNET_strdup (pos);
diff --git a/src/transport/gnunet-service-transport_validation.c b/src/transport/gnunet-service-transport_validation.c
index f618a2b1a..9a3914814 100644
--- a/src/transport/gnunet-service-transport_validation.c
+++ b/src/transport/gnunet-service-transport_validation.c
@@ -361,13 +361,11 @@ find_validation_entry (const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded
361 ve->addr = (void *) &ve[1]; 361 ve->addr = (void *) &ve[1];
362 ve->public_key = *public_key; 362 ve->public_key = *public_key;
363 ve->pid = *neighbour; 363 ve->pid = *neighbour;
364 ve->challenge = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_NONCE, 364 ve->challenge =
365 UINT32_MAX); 365 GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_NONCE, UINT32_MAX);
366 memcpy (&ve[1], addr, addrlen); 366 memcpy (&ve[1], addr, addrlen);
367 ve->addrlen = addrlen; 367 ve->addrlen = addrlen;
368 GNUNET_CONTAINER_multihashmap_put (validation_map, 368 GNUNET_CONTAINER_multihashmap_put (validation_map, &neighbour->hashPubKey, ve,
369 &neighbour->hashPubKey,
370 ve,
371 GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE); 369 GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE);
372 return ve; 370 return ve;
373} 371}
@@ -385,10 +383,9 @@ find_validation_entry (const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded
385 * @return GNUNET_OK (keep the address) 383 * @return GNUNET_OK (keep the address)
386 */ 384 */
387static int 385static int
388add_valid_address (void *cls, 386add_valid_address (void *cls, const char *tname,
389 const char *tname, 387 struct GNUNET_TIME_Absolute expiration, const void *addr,
390 struct GNUNET_TIME_Absolute expiration, 388 uint16_t addrlen)
391 const void *addr, uint16_t addrlen)
392{ 389{
393 const struct GNUNET_HELLO_Message *hello = cls; 390 const struct GNUNET_HELLO_Message *hello = cls;
394 struct ValidationEntry *ve; 391 struct ValidationEntry *ve;
@@ -397,8 +394,7 @@ add_valid_address (void *cls,
397 394
398 if (GNUNET_TIME_absolute_get_remaining (expiration).rel_value == 0) 395 if (GNUNET_TIME_absolute_get_remaining (expiration).rel_value == 0)
399 return GNUNET_OK; /* expired */ 396 return GNUNET_OK; /* expired */
400 if ((GNUNET_OK != 397 if ((GNUNET_OK != GNUNET_HELLO_get_id (hello, &pid)) ||
401 GNUNET_HELLO_get_id (hello, &pid)) ||
402 (GNUNET_OK != GNUNET_HELLO_get_key (hello, &public_key))) 398 (GNUNET_OK != GNUNET_HELLO_get_key (hello, &public_key)))
403 { 399 {
404 GNUNET_break (0); 400 GNUNET_break (0);
@@ -406,10 +402,8 @@ add_valid_address (void *cls,
406 } 402 }
407 ve = find_validation_entry (&public_key, &pid, tname, addr, addrlen); 403 ve = find_validation_entry (&public_key, &pid, tname, addr, addrlen);
408 ve->valid_until = GNUNET_TIME_absolute_max (ve->valid_until, expiration); 404 ve->valid_until = GNUNET_TIME_absolute_max (ve->valid_until, expiration);
409 GNUNET_ATS_address_update (GST_ats, 405 GNUNET_ATS_address_update (GST_ats, &pid, ve->valid_until, tname, NULL, addr,
410 &pid, 406 addrlen, NULL, 0);
411 ve->valid_until,
412 tname, NULL, addr, addrlen, NULL, 0);
413 return GNUNET_OK; 407 return GNUNET_OK;
414} 408}
415 409
@@ -423,8 +417,7 @@ add_valid_address (void *cls,
423 * @param error message 417 * @param error message
424 */ 418 */
425static void 419static void
426process_peerinfo_hello (void *cls, 420process_peerinfo_hello (void *cls, const struct GNUNET_PeerIdentity *peer,
427 const struct GNUNET_PeerIdentity *peer,
428 const struct GNUNET_HELLO_Message *hello, 421 const struct GNUNET_HELLO_Message *hello,
429 const char *err_msg) 422 const char *err_msg)
430{ 423{
@@ -432,8 +425,7 @@ process_peerinfo_hello (void *cls,
432 if (NULL == hello) 425 if (NULL == hello)
433 return; 426 return;
434 GNUNET_assert (NULL == 427 GNUNET_assert (NULL ==
435 GNUNET_HELLO_iterate_addresses (hello, 428 GNUNET_HELLO_iterate_addresses (hello, GNUNET_NO,
436 GNUNET_NO,
437 &add_valid_address, 429 &add_valid_address,
438 (void *) hello)); 430 (void *) hello));
439} 431}
@@ -517,8 +509,8 @@ timeout_hello_validation (void *cls,
517 509
518 ve->timeout_task = GNUNET_SCHEDULER_NO_TASK; 510 ve->timeout_task = GNUNET_SCHEDULER_NO_TASK;
519 GNUNET_STATISTICS_update (GST_stats, 511 GNUNET_STATISTICS_update (GST_stats,
520 gettext_noop ("# address records discarded"), 512 gettext_noop ("# address records discarded"), 1,
521 1, GNUNET_NO); 513 GNUNET_NO);
522 cleanup_validation_entry (NULL, &ve->pid.hashPubKey, ve); 514 cleanup_validation_entry (NULL, &ve->pid.hashPubKey, ve);
523} 515}
524 516
@@ -553,14 +545,9 @@ multicast_pong (void *cls,
553 papi = GST_plugins_find (plugin_name); 545 papi = GST_plugins_find (plugin_name);
554 if (papi == NULL) 546 if (papi == NULL)
555 return; 547 return;
556 (void) papi->send (papi->cls, 548 (void) papi->send (papi->cls, target, (const char *) pong,
557 target, 549 ntohs (pong->header.size), PONG_PRIORITY,
558 (const char *) pong, 550 HELLO_REVALIDATION_START_TIME, NULL, plugin_address,
559 ntohs (pong->header.size),
560 PONG_PRIORITY,
561 HELLO_REVALIDATION_START_TIME,
562 NULL,
563 plugin_address,
564 plugin_address_len, GNUNET_YES, NULL, NULL); 551 plugin_address_len, GNUNET_YES, NULL, NULL);
565} 552}
566 553
@@ -579,8 +566,7 @@ multicast_pong (void *cls,
579void 566void
580GST_validation_handle_ping (const struct GNUNET_PeerIdentity *sender, 567GST_validation_handle_ping (const struct GNUNET_PeerIdentity *sender,
581 const struct GNUNET_MessageHeader *hdr, 568 const struct GNUNET_MessageHeader *hdr,
582 const char *plugin_name, 569 const char *plugin_name, struct Session *session,
583 struct Session *session,
584 const void *sender_address, 570 const void *sender_address,
585 size_t sender_address_len) 571 size_t sender_address_len)
586{ 572{
@@ -601,15 +587,16 @@ GST_validation_handle_ping (const struct GNUNET_PeerIdentity *sender,
601 return; 587 return;
602 } 588 }
603 ping = (const struct TransportPingMessage *) hdr; 589 ping = (const struct TransportPingMessage *) hdr;
604 if (0 != memcmp (&ping->target, 590 if (0 !=
605 &GST_my_identity, sizeof (struct GNUNET_PeerIdentity))) 591 memcmp (&ping->target, &GST_my_identity,
592 sizeof (struct GNUNET_PeerIdentity)))
606 { 593 {
607 GNUNET_break_op (0); 594 GNUNET_break_op (0);
608 return; 595 return;
609 } 596 }
610 GNUNET_STATISTICS_update (GST_stats, 597 GNUNET_STATISTICS_update (GST_stats,
611 gettext_noop ("# PING messages received"), 598 gettext_noop ("# PING messages received"), 1,
612 1, GNUNET_NO); 599 GNUNET_NO);
613 addr = (const char *) &ping[1]; 600 addr = (const char *) &ping[1];
614 alen = ntohs (hdr->size) - sizeof (struct TransportPingMessage); 601 alen = ntohs (hdr->size) - sizeof (struct TransportPingMessage);
615 /* peer wants to confirm that this is one of our addresses, this is what is 602 /* peer wants to confirm that this is one of our addresses, this is what is
@@ -641,8 +628,8 @@ GST_validation_handle_ping (const struct GNUNET_PeerIdentity *sender,
641 pong->header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_PONG); 628 pong->header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_PONG);
642 pong->purpose.size = 629 pong->purpose.size =
643 htonl (sizeof (struct GNUNET_CRYPTO_RsaSignaturePurpose) + 630 htonl (sizeof (struct GNUNET_CRYPTO_RsaSignaturePurpose) +
644 sizeof (uint32_t) + 631 sizeof (uint32_t) + sizeof (struct GNUNET_TIME_AbsoluteNBO) +
645 sizeof (struct GNUNET_TIME_AbsoluteNBO) + alen + slen); 632 alen + slen);
646 pong->purpose.purpose = htonl (GNUNET_SIGNATURE_PURPOSE_TRANSPORT_PONG_OWN); 633 pong->purpose.purpose = htonl (GNUNET_SIGNATURE_PURPOSE_TRANSPORT_PONG_OWN);
647 pong->challenge = ping->challenge; 634 pong->challenge = ping->challenge;
648 pong->addrlen = htonl (alen + slen); 635 pong->addrlen = htonl (alen + slen);
@@ -659,8 +646,8 @@ GST_validation_handle_ping (const struct GNUNET_PeerIdentity *sender,
659 *sig_cache_exp = GNUNET_TIME_relative_to_absolute (PONG_SIGNATURE_LIFETIME); 646 *sig_cache_exp = GNUNET_TIME_relative_to_absolute (PONG_SIGNATURE_LIFETIME);
660 pong->expiration = GNUNET_TIME_absolute_hton (*sig_cache_exp); 647 pong->expiration = GNUNET_TIME_absolute_hton (*sig_cache_exp);
661 GNUNET_assert (GNUNET_OK == 648 GNUNET_assert (GNUNET_OK ==
662 GNUNET_CRYPTO_rsa_sign (GST_my_private_key, 649 GNUNET_CRYPTO_rsa_sign (GST_my_private_key, &pong->purpose,
663 &pong->purpose, sig_cache)); 650 sig_cache));
664 } 651 }
665 else 652 else
666 { 653 {
@@ -674,15 +661,11 @@ GST_validation_handle_ping (const struct GNUNET_PeerIdentity *sender,
674 if (papi == NULL) 661 if (papi == NULL)
675 ret = -1; 662 ret = -1;
676 else 663 else
677 ret = papi->send (papi->cls, 664 ret =
678 sender, 665 papi->send (papi->cls, sender, (const char *) pong,
679 (const char *) pong, 666 ntohs (pong->header.size), PONG_PRIORITY,
680 ntohs (pong->header.size), 667 HELLO_REVALIDATION_START_TIME, session, sender_address,
681 PONG_PRIORITY, 668 sender_address_len, GNUNET_SYSERR, NULL, NULL);
682 HELLO_REVALIDATION_START_TIME,
683 session,
684 sender_address,
685 sender_address_len, GNUNET_SYSERR, NULL, NULL);
686 if (ret != -1) 669 if (ret != -1)
687 { 670 {
688 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 671 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
@@ -733,8 +716,8 @@ struct ValidateAddressContext
733 * @param result GNUNET_OK if the connection is allowed, GNUNET_NO if not 716 * @param result GNUNET_OK if the connection is allowed, GNUNET_NO if not
734 */ 717 */
735static void 718static void
736transmit_ping_if_allowed (void *cls, 719transmit_ping_if_allowed (void *cls, const struct GNUNET_PeerIdentity *pid,
737 const struct GNUNET_PeerIdentity *pid, int result) 720 int result)
738{ 721{
739 struct ValidationEntry *ve = cls; 722 struct ValidationEntry *ve = cls;
740 struct TransportPingMessage ping; 723 struct TransportPingMessage ping;
@@ -746,8 +729,8 @@ transmit_ping_if_allowed (void *cls,
746 uint16_t hsize; 729 uint16_t hsize;
747 730
748 ve->bc = NULL; 731 ve->bc = NULL;
749 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 732 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Transmitting plain PING to `%s'\n",
750 "Transmitting plain PING to `%s'\n", GNUNET_i2s (pid)); 733 GNUNET_i2s (pid));
751 ping.header.size = htons (sizeof (struct TransportPingMessage)); 734 ping.header.size = htons (sizeof (struct TransportPingMessage));
752 ping.header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_PING); 735 ping.header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_PING);
753 ping.challenge = htonl (ve->challenge); 736 ping.challenge = htonl (ve->challenge);
@@ -780,13 +763,10 @@ transmit_ping_if_allowed (void *cls,
780 if (papi == NULL) 763 if (papi == NULL)
781 ret = -1; 764 ret = -1;
782 else 765 else
783 ret = papi->send (papi->cls, 766 ret =
784 pid, 767 papi->send (papi->cls, pid, message_buf, tsize, PING_PRIORITY,
785 message_buf, 768 HELLO_REVALIDATION_START_TIME, NULL /* no session */ ,
786 tsize, 769 ve->addr, ve->addrlen, GNUNET_YES, NULL, NULL);
787 PING_PRIORITY,
788 HELLO_REVALIDATION_START_TIME, NULL /* no session */ ,
789 ve->addr, ve->addrlen, GNUNET_YES, NULL, NULL);
790 } 770 }
791 if (-1 != ret) 771 if (-1 != ret)
792 { 772 {
@@ -811,10 +791,9 @@ transmit_ping_if_allowed (void *cls,
811 * @return GNUNET_OK (keep the address) 791 * @return GNUNET_OK (keep the address)
812 */ 792 */
813static int 793static int
814validate_address (void *cls, 794validate_address (void *cls, const char *tname,
815 const char *tname, 795 struct GNUNET_TIME_Absolute expiration, const void *addr,
816 struct GNUNET_TIME_Absolute expiration, 796 uint16_t addrlen)
817 const void *addr, uint16_t addrlen)
818{ 797{
819 const struct ValidateAddressContext *vac = cls; 798 const struct ValidateAddressContext *vac = cls;
820 const struct GNUNET_PeerIdentity *pid = &vac->pid; 799 const struct GNUNET_PeerIdentity *pid = &vac->pid;
@@ -861,18 +840,17 @@ revalidate_address (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
861 if (delay.rel_value > 0) 840 if (delay.rel_value > 0)
862 { 841 {
863 /* should wait a bit longer */ 842 /* should wait a bit longer */
864 ve->timeout_task = GNUNET_SCHEDULER_add_delayed (delay, 843 ve->timeout_task =
865 &revalidate_address, ve); 844 GNUNET_SCHEDULER_add_delayed (delay, &revalidate_address, ve);
866 return; 845 return;
867 } 846 }
868 GNUNET_STATISTICS_update (GST_stats, 847 GNUNET_STATISTICS_update (GST_stats,
869 gettext_noop ("# address revalidations started"), 848 gettext_noop ("# address revalidations started"), 1,
870 1, GNUNET_NO); 849 GNUNET_NO);
871 vac.pid = ve->pid; 850 vac.pid = ve->pid;
872 vac.public_key = ve->public_key; 851 vac.public_key = ve->public_key;
873 validate_address (&vac, 852 validate_address (&vac, ve->transport_name, ve->valid_until, ve->addr,
874 ve->transport_name, 853 (uint16_t) ve->addrlen);
875 ve->valid_until, ve->addr, (uint16_t) ve->addrlen);
876} 854}
877 855
878 856
@@ -888,8 +866,7 @@ add_valid_peer_address (void *cls, size_t max, void *buf)
888{ 866{
889 struct ValidationEntry *ve = cls; 867 struct ValidationEntry *ve = cls;
890 868
891 return GNUNET_HELLO_add_address (ve->transport_name, 869 return GNUNET_HELLO_add_address (ve->transport_name, ve->valid_until,
892 ve->valid_until,
893 ve->addr, ve->addrlen, buf, max); 870 ve->addr, ve->addrlen, buf, max);
894} 871}
895 872
@@ -921,8 +898,8 @@ GST_validation_handle_pong (const struct GNUNET_PeerIdentity *sender,
921 return; 898 return;
922 } 899 }
923 GNUNET_STATISTICS_update (GST_stats, 900 GNUNET_STATISTICS_update (GST_stats,
924 gettext_noop ("# PONG messages received"), 901 gettext_noop ("# PONG messages received"), 1,
925 1, GNUNET_NO); 902 GNUNET_NO);
926 pong = (const struct TransportPongMessage *) hdr; 903 pong = (const struct TransportPongMessage *) hdr;
927 addr = (const char *) &pong[1]; 904 addr = (const char *) &pong[1];
928 alen = ntohs (hdr->size) - sizeof (struct TransportPongMessage); 905 alen = ntohs (hdr->size) - sizeof (struct TransportPongMessage);
@@ -962,8 +939,8 @@ GST_validation_handle_pong (const struct GNUNET_PeerIdentity *sender,
962 } 939 }
963 if (GNUNET_OK != 940 if (GNUNET_OK !=
964 GNUNET_CRYPTO_rsa_verify (GNUNET_SIGNATURE_PURPOSE_TRANSPORT_PONG_OWN, 941 GNUNET_CRYPTO_rsa_verify (GNUNET_SIGNATURE_PURPOSE_TRANSPORT_PONG_OWN,
965 &pong->purpose, 942 &pong->purpose, &pong->signature,
966 &pong->signature, &ve->public_key)) 943 &ve->public_key))
967 { 944 {
968 GNUNET_break_op (0); 945 GNUNET_break_op (0);
969 return; 946 return;
@@ -983,9 +960,10 @@ GST_validation_handle_pong (const struct GNUNET_PeerIdentity *sender,
983 960
984 /* randomly delay by up to 1h to avoid synchronous validations */ 961 /* randomly delay by up to 1h to avoid synchronous validations */
985 rdelay = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 60 * 60); 962 rdelay = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 60 * 60);
986 delay = GNUNET_TIME_relative_add (HELLO_REVALIDATION_START_TIME, 963 delay =
987 GNUNET_TIME_relative_multiply 964 GNUNET_TIME_relative_add (HELLO_REVALIDATION_START_TIME,
988 (GNUNET_TIME_UNIT_SECONDS, rdelay)); 965 GNUNET_TIME_relative_multiply
966 (GNUNET_TIME_UNIT_SECONDS, rdelay));
989 ve->timeout_task = 967 ve->timeout_task =
990 GNUNET_SCHEDULER_add_delayed (delay, &revalidate_address, ve); 968 GNUNET_SCHEDULER_add_delayed (delay, &revalidate_address, ve);
991} 969}
@@ -1004,8 +982,7 @@ GST_validation_handle_hello (const struct GNUNET_MessageHeader *hello)
1004 (const struct GNUNET_HELLO_Message *) hello; 982 (const struct GNUNET_HELLO_Message *) hello;
1005 struct ValidateAddressContext vac; 983 struct ValidateAddressContext vac;
1006 984
1007 if ((GNUNET_OK != 985 if ((GNUNET_OK != GNUNET_HELLO_get_id (hm, &vac.pid)) ||
1008 GNUNET_HELLO_get_id (hm, &vac.pid)) ||
1009 (GNUNET_OK != GNUNET_HELLO_get_key (hm, &vac.public_key))) 986 (GNUNET_OK != GNUNET_HELLO_get_key (hm, &vac.public_key)))
1010 { 987 {
1011 /* malformed HELLO */ 988 /* malformed HELLO */
@@ -1013,8 +990,7 @@ GST_validation_handle_hello (const struct GNUNET_MessageHeader *hello)
1013 return; 990 return;
1014 } 991 }
1015 GNUNET_assert (NULL == 992 GNUNET_assert (NULL ==
1016 GNUNET_HELLO_iterate_addresses (hm, 993 GNUNET_HELLO_iterate_addresses (hm, GNUNET_NO,
1017 GNUNET_NO,
1018 &validate_address, &vac)); 994 &validate_address, &vac));
1019} 995}
1020 996
@@ -1051,10 +1027,7 @@ iterate_addresses (void *cls, const GNUNET_HashCode * key, void *value)
1051 struct IteratorContext *ic = cls; 1027 struct IteratorContext *ic = cls;
1052 struct ValidationEntry *ve = value; 1028 struct ValidationEntry *ve = value;
1053 1029
1054 ic->cb (ic->cb_cls, 1030 ic->cb (ic->cb_cls, &ve->public_key, &ve->pid, ve->valid_until,
1055 &ve->public_key,
1056 &ve->pid,
1057 ve->valid_until,
1058 ve->validation_block, ve->transport_name, ve->addr, ve->addrlen); 1031 ve->validation_block, ve->transport_name, ve->addr, ve->addrlen);
1059 return GNUNET_OK; 1032 return GNUNET_OK;
1060} 1033}
diff --git a/src/transport/gnunet-transport-certificate-creation.c b/src/transport/gnunet-transport-certificate-creation.c
index a63c21c60..9fd62fc9f 100644
--- a/src/transport/gnunet-transport-certificate-creation.c
+++ b/src/transport/gnunet-transport-certificate-creation.c
@@ -56,10 +56,9 @@ main (int argc, char **argv)
56 close (2); /* eliminate stderr */ 56 close (2); /* eliminate stderr */
57 /* Create RSA Private Key */ 57 /* Create RSA Private Key */
58 /* openssl genrsa -out $1 1024 2> /dev/null */ 58 /* openssl genrsa -out $1 1024 2> /dev/null */
59 openssl = GNUNET_OS_start_process (NULL, NULL, 59 openssl =
60 "openssl", 60 GNUNET_OS_start_process (NULL, NULL, "openssl", "openssl", "genrsa",
61 "openssl", 61 "-out", argv[1], "1024", NULL);
62 "genrsa", "-out", argv[1], "1024", NULL);
63 if (openssl == NULL) 62 if (openssl == NULL)
64 return 2; 63 return 2;
65 GNUNET_assert (GNUNET_OS_process_wait (openssl) == GNUNET_OK); 64 GNUNET_assert (GNUNET_OS_process_wait (openssl) == GNUNET_OK);
@@ -67,12 +66,10 @@ main (int argc, char **argv)
67 66
68 /* Create a self-signed certificate in batch mode using rsa key */ 67 /* Create a self-signed certificate in batch mode using rsa key */
69 /* openssl req -batch -days 365 -out $2 -new -x509 -key $1 2> /dev/null */ 68 /* openssl req -batch -days 365 -out $2 -new -x509 -key $1 2> /dev/null */
70 openssl = GNUNET_OS_start_process (NULL, NULL, 69 openssl =
71 "openssl", 70 GNUNET_OS_start_process (NULL, NULL, "openssl", "openssl", "req",
72 "openssl", 71 "-batch", "-days", "365", "-out", argv[2],
73 "req", "-batch", "-days", "365", 72 "-new", "-x509", "-key", argv[1], NULL);
74 "-out", argv[2], "-new", "-x509", "-key",
75 argv[1], NULL);
76 if (openssl == NULL) 73 if (openssl == NULL)
77 return 3; 74 return 3;
78 GNUNET_assert (GNUNET_OS_process_wait (openssl) == GNUNET_OK); 75 GNUNET_assert (GNUNET_OS_process_wait (openssl) == GNUNET_OK);
diff --git a/src/transport/gnunet-transport-list-connections.c b/src/transport/gnunet-transport-list-connections.c
index d68d2fedf..d31d2febb 100644
--- a/src/transport/gnunet-transport-list-connections.c
+++ b/src/transport/gnunet-transport-list-connections.c
@@ -72,9 +72,8 @@ process_address (void *cls, const char *address)
72 * @param c configuration 72 * @param c configuration
73 */ 73 */
74static void 74static void
75run (void *cls, 75run (void *cls, char *const *args, const char *cfgfile,
76 char *const *args, 76 const struct GNUNET_CONFIGURATION_Handle *c)
77 const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *c)
78{ 77{
79 78
80 cfg = c; 79 cfg = c;
@@ -84,8 +83,7 @@ run (void *cls,
84 return; 83 return;
85 } 84 }
86 85
87 GNUNET_TRANSPORT_address_iterate (cfg, 86 GNUNET_TRANSPORT_address_iterate (cfg, GNUNET_TIME_UNIT_MINUTES,
88 GNUNET_TIME_UNIT_MINUTES,
89 &process_address, NULL); 87 &process_address, NULL);
90} 88}
91 89
@@ -107,9 +105,7 @@ main (int argc, char *const *argv)
107 GNUNET_GETOPT_OPTION_END 105 GNUNET_GETOPT_OPTION_END
108 }; 106 };
109 return (GNUNET_OK == 107 return (GNUNET_OK ==
110 GNUNET_PROGRAM_run (argc, 108 GNUNET_PROGRAM_run (argc, argv, "gnunet-list-connections",
111 argv,
112 "gnunet-list-connections",
113 gettext_noop 109 gettext_noop
114 ("Print information about connected peers."), 110 ("Print information about connected peers."),
115 options, &run, NULL)) ? 0 : 1; 111 options, &run, NULL)) ? 0 : 1;
diff --git a/src/transport/gnunet-transport-wlan-helper.c b/src/transport/gnunet-transport-wlan-helper.c
index 1cfcf2c4e..b3468791d 100644
--- a/src/transport/gnunet-transport-wlan-helper.c
+++ b/src/transport/gnunet-transport-wlan-helper.c
@@ -135,10 +135,8 @@ check_crc_buf_osdep (unsigned char *buf, int len)
135 135
136 crc = calc_crc_osdep (buf, len); 136 crc = calc_crc_osdep (buf, len);
137 buf += len; 137 buf += len;
138 return (((crc) & 0xFF) == buf[0] && ((crc >> 8) & 0xFF) == buf[1] && ((crc 138 return (((crc) & 0xFF) == buf[0] && ((crc >> 8) & 0xFF) == buf[1] &&
139 >> 16) 139 ((crc >> 16) & 0xFF) == buf[2] && ((crc >> 24) & 0xFF) == buf[3]);
140 & 0xFF)
141 == buf[2] && ((crc >> 24) & 0xFF) == buf[3]);
142} 140}
143 141
144 142
@@ -387,8 +385,7 @@ openraw (struct Hardware_Infos *dev)
387 sll.sll_protocol = htons (ETH_P_ALL); 385 sll.sll_protocol = htons (ETH_P_ALL);
388 if (-1 == ioctl (dev->fd_raw, SIOCGIFHWADDR, &ifr)) 386 if (-1 == ioctl (dev->fd_raw, SIOCGIFHWADDR, &ifr))
389 { 387 {
390 fprintf (stderr, 388 fprintf (stderr, "ioctl(SIOCGIFHWADDR) on interface `%.*s' failed: %s\n",
391 "ioctl(SIOCGIFHWADDR) on interface `%.*s' failed: %s\n",
392 IFNAMSIZ, dev->iface, strerror (errno)); 389 IFNAMSIZ, dev->iface, strerror (errno));
393 return 1; 390 return 1;
394 } 391 }
@@ -408,8 +405,7 @@ openraw (struct Hardware_Infos *dev)
408 (ifr.ifr_hwaddr.sa_family != ARPHRD_IEEE80211_FULL)) || 405 (ifr.ifr_hwaddr.sa_family != ARPHRD_IEEE80211_FULL)) ||
409 (wrq.u.mode != IW_MODE_MONITOR)) 406 (wrq.u.mode != IW_MODE_MONITOR))
410 { 407 {
411 fprintf (stderr, 408 fprintf (stderr, "Error: interface `%.*s' is not in monitor mode\n",
412 "Error: interface `%.*s' is not in monitor mode\n",
413 IFNAMSIZ, dev->iface); 409 IFNAMSIZ, dev->iface);
414 return 1; 410 return 1;
415 } 411 }
@@ -432,9 +428,8 @@ openraw (struct Hardware_Infos *dev)
432 /* bind the raw socket to the interface */ 428 /* bind the raw socket to the interface */
433 if (-1 == bind (dev->fd_raw, (struct sockaddr *) &sll, sizeof (sll))) 429 if (-1 == bind (dev->fd_raw, (struct sockaddr *) &sll, sizeof (sll)))
434 { 430 {
435 fprintf (stderr, 431 fprintf (stderr, "Failed to bind interface `%.*s': %s\n", IFNAMSIZ,
436 "Failed to bind interface `%.*s': %s\n", 432 dev->iface, strerror (errno));
437 IFNAMSIZ, dev->iface, strerror (errno));
438 return 1; 433 return 1;
439 } 434 }
440 435
@@ -453,8 +448,7 @@ openraw (struct Hardware_Infos *dev)
453 (ifr.ifr_hwaddr.sa_family != ARPHRD_IEEE80211_PRISM) && 448 (ifr.ifr_hwaddr.sa_family != ARPHRD_IEEE80211_PRISM) &&
454 (ifr.ifr_hwaddr.sa_family != ARPHRD_IEEE80211_FULL)) 449 (ifr.ifr_hwaddr.sa_family != ARPHRD_IEEE80211_FULL))
455 { 450 {
456 fprintf (stderr, 451 fprintf (stderr, "Unsupported hardware link type %d on interface `%.*s'\n",
457 "Unsupported hardware link type %d on interface `%.*s'\n",
458 ifr.ifr_hwaddr.sa_family, IFNAMSIZ, dev->iface); 452 ifr.ifr_hwaddr.sa_family, IFNAMSIZ, dev->iface);
459 return 1; 453 return 1;
460 } 454 }
@@ -467,8 +461,7 @@ openraw (struct Hardware_Infos *dev)
467 setsockopt (dev->fd_raw, SOL_PACKET, PACKET_ADD_MEMBERSHIP, &mr, 461 setsockopt (dev->fd_raw, SOL_PACKET, PACKET_ADD_MEMBERSHIP, &mr,
468 sizeof (mr))) 462 sizeof (mr)))
469 { 463 {
470 fprintf (stderr, 464 fprintf (stderr, "Failed to enable promiscuous mode on interface `%.*s'\n",
471 "Failed to enable promiscuous mode on interface `%.*s'\n",
472 IFNAMSIZ, dev->iface); 465 IFNAMSIZ, dev->iface);
473 return 1; 466 return 1;
474 } 467 }
@@ -494,17 +487,16 @@ wlaninit (struct Hardware_Infos *dev, const char *iface)
494 } 487 }
495 if (dev->fd_raw >= FD_SETSIZE) 488 if (dev->fd_raw >= FD_SETSIZE)
496 { 489 {
497 fprintf (stderr, 490 fprintf (stderr, "File descriptor too large for select (%d > %d)\n",
498 "File descriptor too large for select (%d > %d)\n",
499 dev->fd_raw, FD_SETSIZE); 491 dev->fd_raw, FD_SETSIZE);
500 close (dev->fd_raw); 492 close (dev->fd_raw);
501 return 1; 493 return 1;
502 } 494 }
503 495
504 /* mac80211 stack detection */ 496 /* mac80211 stack detection */
505 ret = snprintf (strbuf, 497 ret =
506 sizeof (strbuf), 498 snprintf (strbuf, sizeof (strbuf), "/sys/class/net/%s/phy80211/subsystem",
507 "/sys/class/net/%s/phy80211/subsystem", iface); 499 iface);
508 if ((ret < 0) || (ret >= sizeof (strbuf)) || (0 != stat (strbuf, &sbuf))) 500 if ((ret < 0) || (ret >= sizeof (strbuf)) || (0 != stat (strbuf, &sbuf)))
509 { 501 {
510 fprintf (stderr, "Did not find 802.11 interface `%s'. Exiting.\n", iface); 502 fprintf (stderr, "Did not find 802.11 interface `%s'. Exiting.\n", iface);
@@ -634,8 +626,7 @@ maketest (unsigned char *buf, struct Hardware_Infos *dev)
634 static int first = 0; 626 static int first = 0;
635 627
636 const int rate = 11000000; 628 const int rate = 11000000;
637 static const char 629 static const char txt[] =
638 txt[] =
639 "Hallo1Hallo2 Hallo3 Hallo4...998877665544332211Hallo1Hallo2 Hallo3 Hallo4...998877665544332211"; 630 "Hallo1Hallo2 Hallo3 Hallo4...998877665544332211Hallo1Hallo2 Hallo3 Hallo4...998877665544332211";
640 631
641 unsigned char u8aRadiotap[] = { 0x00, 0x00, // <-- radiotap version 632 unsigned char u8aRadiotap[] = { 0x00, 0x00, // <-- radiotap version
@@ -686,14 +677,14 @@ maketest (unsigned char *buf, struct Hardware_Infos *dev)
686 } 677 }
687 678
688 tmp16 = (uint16_t *) u8aIeeeHeader.i_dur; 679 tmp16 = (uint16_t *) u8aIeeeHeader.i_dur;
689 *tmp16 680 *tmp16 =
690 =
691 (uint16_t) 681 (uint16_t)
692 htole16 ((sizeof (txt) + 682 htole16 ((sizeof (txt) +
693 sizeof (struct ieee80211_frame) * 1000000) / rate + 290); 683 sizeof (struct ieee80211_frame) * 1000000) / rate + 290);
694 tmp16 = (uint16_t *) u8aIeeeHeader.i_seq; 684 tmp16 = (uint16_t *) u8aIeeeHeader.i_seq;
695 *tmp16 = (*tmp16 & IEEE80211_SEQ_FRAG_MASK) | (htole16 (seqenz) 685 *tmp16 =
696 << IEEE80211_SEQ_SEQ_SHIFT); 686 (*tmp16 & IEEE80211_SEQ_FRAG_MASK) | (htole16 (seqenz) <<
687 IEEE80211_SEQ_SEQ_SHIFT);
697 seqenz++; 688 seqenz++;
698 689
699 memcpy (buf, u8aRadiotap, sizeof (u8aRadiotap)); 690 memcpy (buf, u8aRadiotap, sizeof (u8aRadiotap));
@@ -795,9 +786,9 @@ hardwaremode (int argc, char *argv[])
795 786
796 if (FD_ISSET (STDOUT_FILENO, &wfds)) 787 if (FD_ISSET (STDOUT_FILENO, &wfds))
797 { 788 {
798 ret = write (STDOUT_FILENO, 789 ret =
799 write_std.buf + write_std.pos, 790 write (STDOUT_FILENO, write_std.buf + write_std.pos,
800 write_std.size - write_std.pos); 791 write_std.size - write_std.pos);
801 if (0 > ret) 792 if (0 > ret)
802 { 793 {
803 fprintf (stderr, "Failed to write to STDOUT: %s\n", strerror (errno)); 794 fprintf (stderr, "Failed to write to STDOUT: %s\n", strerror (errno));
@@ -824,9 +815,8 @@ hardwaremode (int argc, char *argv[])
824 dev.write_pout.pos += ret; 815 dev.write_pout.pos += ret;
825 if ((dev.write_pout.pos != dev.write_pout.size) && (ret != 0)) 816 if ((dev.write_pout.pos != dev.write_pout.size) && (ret != 0))
826 { 817 {
827 fprintf (stderr, 818 fprintf (stderr, "Line %u: Write error, partial send: %u/%u\n",
828 "Line %u: Write error, partial send: %u/%u\n", __LINE__, 819 __LINE__, dev.write_pout.pos, dev.write_pout.size);
829 dev.write_pout.pos, dev.write_pout.size);
830 break; 820 break;
831 } 821 }
832 if (dev.write_pout.pos == dev.write_pout.size) 822 if (dev.write_pout.pos == dev.write_pout.size)
@@ -849,8 +839,8 @@ hardwaremode (int argc, char *argv[])
849 /* stop reading... */ 839 /* stop reading... */
850 stdin_open = 0; 840 stdin_open = 0;
851 } 841 }
852 GNUNET_SERVER_mst_receive (stdin_mst, NULL, 842 GNUNET_SERVER_mst_receive (stdin_mst, NULL, readbuf, ret, GNUNET_NO,
853 readbuf, ret, GNUNET_NO, GNUNET_NO); 843 GNUNET_NO);
854 } 844 }
855 845
856 if (FD_ISSET (dev.fd_raw, &rfds)) 846 if (FD_ISSET (dev.fd_raw, &rfds))
@@ -862,10 +852,10 @@ hardwaremode (int argc, char *argv[])
862 header = (struct GNUNET_MessageHeader *) write_std.buf; 852 header = (struct GNUNET_MessageHeader *) write_std.buf;
863 rxinfo = (struct Radiotap_rx *) &header[1]; 853 rxinfo = (struct Radiotap_rx *) &header[1];
864 datastart = (struct ieee80211_frame *) &rxinfo[1]; 854 datastart = (struct ieee80211_frame *) &rxinfo[1];
865 ret = linux_read (&dev, 855 ret =
866 (unsigned char *) datastart, 856 linux_read (&dev, (unsigned char *) datastart,
867 sizeof (write_std.buf) - sizeof (struct Radiotap_rx) - 857 sizeof (write_std.buf) - sizeof (struct Radiotap_rx) -
868 sizeof (struct GNUNET_MessageHeader), rxinfo); 858 sizeof (struct GNUNET_MessageHeader), rxinfo);
869 if (0 > ret) 859 if (0 > ret)
870 { 860 {
871 fprintf (stderr, "Read error from raw socket: %s\n", strerror (errno)); 861 fprintf (stderr, "Read error from raw socket: %s\n", strerror (errno));
diff --git a/src/transport/perf_transport_ats.c b/src/transport/perf_transport_ats.c
index df1ebe950..0be15d255 100644
--- a/src/transport/perf_transport_ats.c
+++ b/src/transport/perf_transport_ats.c
@@ -170,8 +170,8 @@ bench_simplex_no_optimization (char *file, int executions)
170 exec_time[c] = GNUNET_TIME_absolute_get_difference (start, end).rel_value; 170 exec_time[c] = GNUNET_TIME_absolute_get_difference (start, end).rel_value;
171 171
172 sim_no_opt_avg += exec_time[c]; 172 sim_no_opt_avg += exec_time[c];
173 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 173 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Simplex iterations %i: %llu \n", c,
174 "Simplex iterations %i: %llu \n", c, exec_time[c]); 174 exec_time[c]);
175 } 175 }
176 176
177 glp_delete_prob (prob); 177 glp_delete_prob (prob);
@@ -328,8 +328,7 @@ main (int argc, char *argv[])
328 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 328 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
329 "MLP optimization average per address: %f\n", 329 "MLP optimization average per address: %f\n",
330 ((double) mlp_with_opt_avg / EXECS) / 400); 330 ((double) mlp_with_opt_avg / EXECS) / 400);
331 GAUGER ("TRANSPORT", 331 GAUGER ("TRANSPORT", "GLPK MLP 100 peers 400 addresses with optimization",
332 "GLPK MLP 100 peers 400 addresses with optimization",
333 ((double) mlp_with_opt_avg / EXECS) / 400, "ms/address"); 332 ((double) mlp_with_opt_avg / EXECS) / 400, "ms/address");
334 (void) CLOSE (nullfd); 333 (void) CLOSE (nullfd);
335 return ret; 334 return ret;
diff --git a/src/transport/plugin_transport_http.c b/src/transport/plugin_transport_http.c
index 0c856e4ab..a6b24e73e 100644
--- a/src/transport/plugin_transport_http.c
+++ b/src/transport/plugin_transport_http.c
@@ -547,8 +547,7 @@ struct PrettyPrinterContext
547 * @param addrlen length of the address 547 * @param addrlen length of the address
548 * @return string representing the same address 548 * @return string representing the same address
549 */ 549 */
550static const char *http_plugin_address_to_string (void *cls, 550static const char *http_plugin_address_to_string (void *cls, const void *addr,
551 const void *addr,
552 size_t addrlen); 551 size_t addrlen);
553 552
554 553
@@ -618,8 +617,7 @@ create_url (struct Plugin *plugin, const void *addr, size_t addrlen, size_t id)
618 char *addr_str = (char *) http_plugin_address_to_string (NULL, addr, addrlen); 617 char *addr_str = (char *) http_plugin_address_to_string (NULL, addr, addrlen);
619 618
620 GNUNET_assert ((addr != NULL) && (addrlen != 0)); 619 GNUNET_assert ((addr != NULL) && (addrlen != 0));
621 GNUNET_asprintf (&url, 620 GNUNET_asprintf (&url, "%s://%s/%s;%u", PROTOCOL_PREFIX, addr_str,
622 "%s://%s/%s;%u", PROTOCOL_PREFIX, addr_str,
623 (char *) (&plugin->my_ascii_hash_ident), id); 621 (char *) (&plugin->my_ascii_hash_ident), id);
624 return url; 622 return url;
625} 623}
@@ -634,8 +632,8 @@ create_url (struct Plugin *plugin, const void *addr, size_t addrlen, size_t id)
634static int 632static int
635remove_http_message (struct Session *ps, struct HTTP_Message *msg) 633remove_http_message (struct Session *ps, struct HTTP_Message *msg)
636{ 634{
637 GNUNET_CONTAINER_DLL_remove (ps->pending_msgs_head, 635 GNUNET_CONTAINER_DLL_remove (ps->pending_msgs_head, ps->pending_msgs_tail,
638 ps->pending_msgs_tail, msg); 636 msg);
639 GNUNET_free (msg); 637 GNUNET_free (msg);
640 return GNUNET_OK; 638 return GNUNET_OK;
641} 639}
@@ -648,8 +646,8 @@ remove_http_message (struct Session *ps, struct HTTP_Message *msg)
648 * @return GNUNET_YES on success 646 * @return GNUNET_YES on success
649 */ 647 */
650static int 648static int
651remove_peer_context_Iterator (void *cls, 649remove_peer_context_Iterator (void *cls, const GNUNET_HashCode * key,
652 const GNUNET_HashCode * key, void *value) 650 void *value)
653{ 651{
654 struct Plugin *plugin = cls; 652 struct Plugin *plugin = cls;
655 struct HTTP_PeerContext *pc = value; 653 struct HTTP_PeerContext *pc = value;
@@ -659,8 +657,8 @@ remove_peer_context_Iterator (void *cls,
659 struct HTTP_Message *msg_tmp = NULL; 657 struct HTTP_Message *msg_tmp = NULL;
660 658
661#if DEBUG_HTTP 659#if DEBUG_HTTP
662 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 660 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Freeing context for peer `%s'\n",
663 "Freeing context for peer `%s'\n", GNUNET_i2s (&pc->identity)); 661 GNUNET_i2s (&pc->identity));
664#endif 662#endif
665 GNUNET_assert (GNUNET_YES == 663 GNUNET_assert (GNUNET_YES ==
666 GNUNET_CONTAINER_multihashmap_remove (plugin->peers, 664 GNUNET_CONTAINER_multihashmap_remove (plugin->peers,
@@ -695,8 +693,8 @@ remove_peer_context_Iterator (void *cls,
695 } 693 }
696 GNUNET_free (pc); 694 GNUNET_free (pc);
697 GNUNET_STATISTICS_update (plugin->env->stats, 695 GNUNET_STATISTICS_update (plugin->env->stats,
698 gettext_noop ("# HTTP peers active"), 696 gettext_noop ("# HTTP peers active"), -1,
699 -1, GNUNET_NO); 697 GNUNET_NO);
700 return GNUNET_YES; 698 return GNUNET_YES;
701} 699}
702 700
@@ -710,18 +708,17 @@ remove_peer_context_Iterator (void *cls,
710 * @return GNUNET_SYSERR if msg not found, GNUNET_OK on success 708 * @return GNUNET_SYSERR if msg not found, GNUNET_OK on success
711 */ 709 */
712static int 710static int
713remove_session (struct HTTP_PeerContext *pc, 711remove_session (struct HTTP_PeerContext *pc, struct Session *ps,
714 struct Session *ps, int call_msg_cont, int call_msg_cont_result) 712 int call_msg_cont, int call_msg_cont_result)
715{ 713{
716 struct HTTP_Message *msg; 714 struct HTTP_Message *msg;
717 struct Plugin *plugin = ps->peercontext->plugin; 715 struct Plugin *plugin = ps->peercontext->plugin;
718 716
719#if DEBUG_CONNECTIONS 717#if DEBUG_CONNECTIONS
720 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 718 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
721 "Connection %X: removing %s session %X with id %u\n", 719 "Connection %X: removing %s session %X with id %u\n", ps,
722 ps, 720 (ps->direction == INBOUND) ? "inbound" : "outbound", ps,
723 (ps->direction == INBOUND) 721 ps->session_id);
724 ? "inbound" : "outbound", ps, ps->session_id);
725#endif 722#endif
726 plugin->env->session_end (plugin, &pc->identity, ps); 723 plugin->env->session_end (plugin, &pc->identity, ps);
727 GNUNET_free_non_null (ps->addr); 724 GNUNET_free_non_null (ps->addr);
@@ -746,11 +743,11 @@ remove_session (struct HTTP_PeerContext *pc,
746 { 743 {
747 if ((call_msg_cont == GNUNET_YES) && (msg->transmit_cont != NULL)) 744 if ((call_msg_cont == GNUNET_YES) && (msg->transmit_cont != NULL))
748 { 745 {
749 msg->transmit_cont (msg->transmit_cont_cls, 746 msg->transmit_cont (msg->transmit_cont_cls, &pc->identity,
750 &pc->identity, call_msg_cont_result); 747 call_msg_cont_result);
751 } 748 }
752 GNUNET_CONTAINER_DLL_remove (ps->pending_msgs_head, 749 GNUNET_CONTAINER_DLL_remove (ps->pending_msgs_head, ps->pending_msgs_head,
753 ps->pending_msgs_head, msg); 750 msg);
754 GNUNET_free (msg); 751 GNUNET_free (msg);
755 msg = ps->pending_msgs_head; 752 msg = ps->pending_msgs_head;
756 } 753 }
@@ -795,8 +792,8 @@ check_localaddress (const struct sockaddr *addr, socklen_t addrlen)
795 else 792 else
796 local = GNUNET_YES; 793 local = GNUNET_YES;
797#if DEBUG_HTTP 794#if DEBUG_HTTP
798 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 795 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Checking IPv4 address `%s': %s\n",
799 "Checking IPv4 address `%s': %s\n", GNUNET_a2s (addr, addrlen), 796 GNUNET_a2s (addr, addrlen),
800 (local == GNUNET_YES) ? "local" : "global"); 797 (local == GNUNET_YES) ? "local" : "global");
801#endif 798#endif
802 break; 799 break;
@@ -809,8 +806,8 @@ check_localaddress (const struct sockaddr *addr, socklen_t addrlen)
809 else 806 else
810 local = GNUNET_NO; 807 local = GNUNET_NO;
811#if DEBUG_HTTP 808#if DEBUG_HTTP
812 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 809 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Checking IPv6 address `%s' : %s\n",
813 "Checking IPv6 address `%s' : %s\n", GNUNET_a2s (addr, addrlen), 810 GNUNET_a2s (addr, addrlen),
814 (local == GNUNET_YES) ? "local" : "global"); 811 (local == GNUNET_YES) ? "local" : "global");
815#endif 812#endif
816 break; 813 break;
@@ -832,9 +829,7 @@ check_localaddress (const struct sockaddr *addr, socklen_t addrlen)
832 * @return GNUNET_OK to continue iterating 829 * @return GNUNET_OK to continue iterating
833 */ 830 */
834static int 831static int
835process_interfaces (void *cls, 832process_interfaces (void *cls, const char *name, int isDefault,
836 const char *name,
837 int isDefault,
838 const struct sockaddr *addr, socklen_t addrlen) 833 const struct sockaddr *addr, socklen_t addrlen)
839{ 834{
840 struct Plugin *plugin = cls; 835 struct Plugin *plugin = cls;
@@ -847,8 +842,7 @@ process_interfaces (void *cls,
847 if (GNUNET_YES == check_localaddress (addr, addrlen)) 842 if (GNUNET_YES == check_localaddress (addr, addrlen))
848 { 843 {
849#if DEBUG_HTTP 844#if DEBUG_HTTP
850 GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, 845 GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, PROTOCOL_PREFIX,
851 PROTOCOL_PREFIX,
852 "Not notifying transport of address `%s' (local address)\n", 846 "Not notifying transport of address `%s' (local address)\n",
853 GNUNET_a2s (addr, addrlen)); 847 GNUNET_a2s (addr, addrlen));
854#endif 848#endif
@@ -859,8 +853,8 @@ process_interfaces (void *cls,
859 853
860 GNUNET_assert (cls != NULL); 854 GNUNET_assert (cls != NULL);
861 af = addr->sa_family; 855 af = addr->sa_family;
862 if ((af == AF_INET) && 856 if ((af == AF_INET) && (plugin->use_ipv4 == GNUNET_YES) &&
863 (plugin->use_ipv4 == GNUNET_YES) && (plugin->bind6_address == NULL)) 857 (plugin->bind6_address == NULL))
864 { 858 {
865 859
866 struct in_addr bnd_cmp = ((struct sockaddr_in *) addr)->sin_addr; 860 struct in_addr bnd_cmp = ((struct sockaddr_in *) addr)->sin_addr;
@@ -879,9 +873,8 @@ process_interfaces (void *cls,
879 { 873 {
880 GNUNET_CONTAINER_DLL_insert (plugin->ipv4_addr_head, 874 GNUNET_CONTAINER_DLL_insert (plugin->ipv4_addr_head,
881 plugin->ipv4_addr_tail, t4); 875 plugin->ipv4_addr_tail, t4);
882 plugin->env->notify_address (plugin->env->cls, 876 plugin->env->notify_address (plugin->env->cls, GNUNET_YES, t4,
883 GNUNET_YES, 877 sizeof (struct IPv4HttpAddress));
884 t4, sizeof (struct IPv4HttpAddress));
885 return GNUNET_OK; 878 return GNUNET_OK;
886 } 879 }
887 GNUNET_free (t4); 880 GNUNET_free (t4);
@@ -891,14 +884,13 @@ process_interfaces (void *cls,
891 { 884 {
892 GNUNET_CONTAINER_DLL_insert (plugin->ipv4_addr_head, 885 GNUNET_CONTAINER_DLL_insert (plugin->ipv4_addr_head,
893 plugin->ipv4_addr_tail, t4); 886 plugin->ipv4_addr_tail, t4);
894 plugin->env->notify_address (plugin->env->cls, 887 plugin->env->notify_address (plugin->env->cls, GNUNET_YES, t4,
895 GNUNET_YES, 888 sizeof (struct IPv4HttpAddress));
896 t4, sizeof (struct IPv4HttpAddress));
897 return GNUNET_OK; 889 return GNUNET_OK;
898 } 890 }
899 } 891 }
900 if ((af == AF_INET6) && 892 if ((af == AF_INET6) && (plugin->use_ipv6 == GNUNET_YES) &&
901 (plugin->use_ipv6 == GNUNET_YES) && (plugin->bind4_address == NULL)) 893 (plugin->bind4_address == NULL))
902 { 894 {
903 895
904 struct in6_addr bnd_cmp6 = ((struct sockaddr_in6 *) addr)->sin6_addr; 896 struct in6_addr bnd_cmp6 = ((struct sockaddr_in6 *) addr)->sin6_addr;
@@ -908,16 +900,15 @@ process_interfaces (void *cls,
908 900
909 if (plugin->bind6_address != NULL) 901 if (plugin->bind6_address != NULL)
910 { 902 {
911 if (0 == memcmp (&plugin->bind6_address->sin6_addr, 903 if (0 ==
912 &bnd_cmp6, sizeof (struct in6_addr))) 904 memcmp (&plugin->bind6_address->sin6_addr, &bnd_cmp6,
905 sizeof (struct in6_addr)))
913 { 906 {
914 memcpy (&t6->ipv6_addr, 907 memcpy (&t6->ipv6_addr, &((struct sockaddr_in6 *) addr)->sin6_addr,
915 &((struct sockaddr_in6 *) addr)->sin6_addr,
916 sizeof (struct in6_addr)); 908 sizeof (struct in6_addr));
917 t6->port = htons (plugin->port_inbound); 909 t6->port = htons (plugin->port_inbound);
918 plugin->env->notify_address (plugin->env->cls, 910 plugin->env->notify_address (plugin->env->cls, GNUNET_YES, t6,
919 GNUNET_YES, 911 sizeof (struct IPv6HttpAddress));
920 t6, sizeof (struct IPv6HttpAddress));
921 GNUNET_CONTAINER_DLL_insert (plugin->ipv6_addr_head, 912 GNUNET_CONTAINER_DLL_insert (plugin->ipv6_addr_head,
922 plugin->ipv6_addr_tail, t6); 913 plugin->ipv6_addr_tail, t6);
923 return GNUNET_OK; 914 return GNUNET_OK;
@@ -925,16 +916,14 @@ process_interfaces (void *cls,
925 GNUNET_free (t6); 916 GNUNET_free (t6);
926 return GNUNET_OK; 917 return GNUNET_OK;
927 } 918 }
928 memcpy (&t6->ipv6_addr, 919 memcpy (&t6->ipv6_addr, &((struct sockaddr_in6 *) addr)->sin6_addr,
929 &((struct sockaddr_in6 *) addr)->sin6_addr,
930 sizeof (struct in6_addr)); 920 sizeof (struct in6_addr));
931 t6->port = htons (plugin->port_inbound); 921 t6->port = htons (plugin->port_inbound);
932 GNUNET_CONTAINER_DLL_insert (plugin->ipv6_addr_head, plugin->ipv6_addr_tail, 922 GNUNET_CONTAINER_DLL_insert (plugin->ipv6_addr_head, plugin->ipv6_addr_tail,
933 t6); 923 t6);
934 924
935 plugin->env->notify_address (plugin->env->cls, 925 plugin->env->notify_address (plugin->env->cls, GNUNET_YES, t6,
936 GNUNET_YES, 926 sizeof (struct IPv6HttpAddress));
937 t6, sizeof (struct IPv6HttpAddress));
938 } 927 }
939 return GNUNET_OK; 928 return GNUNET_OK;
940} 929}
@@ -958,8 +947,8 @@ mhd_logger (void *arg, const char *fmt, va_list ap)
958 947
959 948
960static void 949static void
961mhd_termination_cb (void *cls, 950mhd_termination_cb (void *cls, struct MHD_Connection *connection,
962 struct MHD_Connection *connection, void **httpSessionCache) 951 void **httpSessionCache)
963{ 952{
964 struct Session *ps = *httpSessionCache; 953 struct Session *ps = *httpSessionCache;
965 954
@@ -1013,8 +1002,8 @@ mhd_termination_cb (void *cls,
1013 * @param message the message to be forwarded to transport service 1002 * @param message the message to be forwarded to transport service
1014 */ 1003 */
1015static void 1004static void
1016mhd_write_mst_cb (void *cls, 1005mhd_write_mst_cb (void *cls, void *client,
1017 void *client, const struct GNUNET_MessageHeader *message) 1006 const struct GNUNET_MessageHeader *message)
1018{ 1007{
1019 struct Session *ps = cls; 1008 struct Session *ps = cls;
1020 struct HTTP_PeerContext *pc; 1009 struct HTTP_PeerContext *pc;
@@ -1026,9 +1015,7 @@ mhd_write_mst_cb (void *cls,
1026#if DEBUG_HTTP 1015#if DEBUG_HTTP
1027 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1016 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1028 "Connection %X: Forwarding message to transport service, type %u and size %u from `%s' (`%s')\n", 1017 "Connection %X: Forwarding message to transport service, type %u and size %u from `%s' (`%s')\n",
1029 ps, 1018 ps, ntohs (message->type), ntohs (message->size),
1030 ntohs (message->type),
1031 ntohs (message->size),
1032 GNUNET_i2s (&(ps->peercontext)->identity), 1019 GNUNET_i2s (&(ps->peercontext)->identity),
1033 http_plugin_address_to_string (NULL, ps->addr, ps->addrlen)); 1020 http_plugin_address_to_string (NULL, ps->addr, ps->addrlen));
1034#endif 1021#endif
@@ -1038,12 +1025,11 @@ mhd_write_mst_cb (void *cls,
1038 distance[0].value = htonl (1); 1025 distance[0].value = htonl (1);
1039 distance[1].type = htonl (GNUNET_TRANSPORT_ATS_ARRAY_TERMINATOR); 1026 distance[1].type = htonl (GNUNET_TRANSPORT_ATS_ARRAY_TERMINATOR);
1040 distance[1].value = htonl (0); 1027 distance[1].value = htonl (0);
1041 delay = pc->plugin->env->receive (ps->peercontext->plugin->env->cls, 1028 delay =
1042 &pc->identity, 1029 pc->plugin->env->receive (ps->peercontext->plugin->env->cls,
1043 message, 1030 &pc->identity, message,
1044 (const struct 1031 (const struct GNUNET_TRANSPORT_ATS_Information
1045 GNUNET_TRANSPORT_ATS_Information *) 1032 *) &distance, 2, ps, NULL, 0);
1046 &distance, 2, ps, NULL, 0);
1047 pc->delay = delay; 1033 pc->delay = delay;
1048 if (pc->reset_task != GNUNET_SCHEDULER_NO_TASK) 1034 if (pc->reset_task != GNUNET_SCHEDULER_NO_TASK)
1049 GNUNET_SCHEDULER_cancel (pc->reset_task); 1035 GNUNET_SCHEDULER_cancel (pc->reset_task);
@@ -1142,8 +1128,8 @@ mhd_send_callback (void *cls, uint64_t pos, char *buf, size_t max)
1142 } 1128 }
1143 } 1129 }
1144#if DEBUG_CONNECTIONS 1130#if DEBUG_CONNECTIONS
1145 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1131 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Connection %X: MHD has sent %u bytes\n",
1146 "Connection %X: MHD has sent %u bytes\n", ps, bytes_read); 1132 ps, bytes_read);
1147#endif 1133#endif
1148 return bytes_read; 1134 return bytes_read;
1149} 1135}
@@ -1157,13 +1143,10 @@ mhd_send_callback (void *cls, uint64_t pos, char *buf, size_t max)
1157 * already exists and create a new one if not. 1143 * already exists and create a new one if not.
1158 */ 1144 */
1159static int 1145static int
1160mhd_access_cb (void *cls, 1146mhd_access_cb (void *cls, struct MHD_Connection *mhd_connection,
1161 struct MHD_Connection *mhd_connection, 1147 const char *url, const char *method, const char *version,
1162 const char *url, 1148 const char *upload_data, size_t * upload_data_size,
1163 const char *method, 1149 void **httpSessionCache)
1164 const char *version,
1165 const char *upload_data,
1166 size_t * upload_data_size, void **httpSessionCache)
1167{ 1150{
1168 struct Plugin *plugin = cls; 1151 struct Plugin *plugin = cls;
1169 struct MHD_Response *response; 1152 struct MHD_Response *response;
@@ -1205,9 +1188,9 @@ mhd_access_cb (void *cls,
1205 GNUNET_free (peer); 1188 GNUNET_free (peer);
1206 if (GNUNET_SYSERR == res) 1189 if (GNUNET_SYSERR == res)
1207 { 1190 {
1208 response = MHD_create_response_from_data (strlen (HTTP_ERROR_RESPONSE), 1191 response =
1209 HTTP_ERROR_RESPONSE, 1192 MHD_create_response_from_data (strlen (HTTP_ERROR_RESPONSE),
1210 MHD_NO, MHD_NO); 1193 HTTP_ERROR_RESPONSE, MHD_NO, MHD_NO);
1211 res = MHD_queue_response (mhd_connection, MHD_HTTP_NOT_FOUND, response); 1194 res = MHD_queue_response (mhd_connection, MHD_HTTP_NOT_FOUND, response);
1212 MHD_destroy_response (response); 1195 MHD_destroy_response (response);
1213#if DEBUG_CONNECTIONS 1196#if DEBUG_CONNECTIONS
@@ -1240,12 +1223,11 @@ mhd_access_cb (void *cls,
1240 pc->last_session = NULL; 1223 pc->last_session = NULL;
1241 memcpy (&pc->identity, &pi_in, sizeof (struct GNUNET_PeerIdentity)); 1224 memcpy (&pc->identity, &pi_in, sizeof (struct GNUNET_PeerIdentity));
1242 GNUNET_CONTAINER_multihashmap_put (plugin->peers, 1225 GNUNET_CONTAINER_multihashmap_put (plugin->peers,
1243 &pc->identity.hashPubKey, 1226 &pc->identity.hashPubKey, pc,
1244 pc,
1245 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY); 1227 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY);
1246 GNUNET_STATISTICS_update (plugin->env->stats, 1228 GNUNET_STATISTICS_update (plugin->env->stats,
1247 gettext_noop ("# HTTP peers active"), 1229 gettext_noop ("# HTTP peers active"), 1,
1248 1, GNUNET_NO); 1230 GNUNET_NO);
1249 } 1231 }
1250 1232
1251 conn_info = 1233 conn_info =
@@ -1329,9 +1311,7 @@ mhd_access_cb (void *cls,
1329#if DEBUG_HTTP 1311#if DEBUG_HTTP
1330 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1312 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1331 "Connection %X: HTTP Daemon has new an incoming `%s' request from peer `%s' (`%s')\n", 1313 "Connection %X: HTTP Daemon has new an incoming `%s' request from peer `%s' (`%s')\n",
1332 ps, 1314 ps, method, GNUNET_i2s (&pc->identity),
1333 method,
1334 GNUNET_i2s (&pc->identity),
1335 http_plugin_address_to_string (NULL, ps->addr, ps->addrlen)); 1315 http_plugin_address_to_string (NULL, ps->addr, ps->addrlen));
1336#endif 1316#endif
1337 } 1317 }
@@ -1365,9 +1345,9 @@ mhd_access_cb (void *cls,
1365 /* Transmission of all data complete */ 1345 /* Transmission of all data complete */
1366 if ((*upload_data_size == 0) && (ps->recv_active == GNUNET_YES)) 1346 if ((*upload_data_size == 0) && (ps->recv_active == GNUNET_YES))
1367 { 1347 {
1368 response = MHD_create_response_from_data (strlen (HTTP_PUT_RESPONSE), 1348 response =
1369 HTTP_PUT_RESPONSE, 1349 MHD_create_response_from_data (strlen (HTTP_PUT_RESPONSE),
1370 MHD_NO, MHD_NO); 1350 HTTP_PUT_RESPONSE, MHD_NO, MHD_NO);
1371 res = MHD_queue_response (mhd_connection, MHD_HTTP_OK, response); 1351 res = MHD_queue_response (mhd_connection, MHD_HTTP_OK, response);
1372#if DEBUG_CONNECTIONS 1352#if DEBUG_CONNECTIONS
1373 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1353 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
@@ -1385,12 +1365,12 @@ mhd_access_cb (void *cls,
1385 { 1365 {
1386#if DEBUG_HTTP 1366#if DEBUG_HTTP
1387 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1367 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1388 "Connection %X: PUT with %u bytes forwarded to MST\n", 1368 "Connection %X: PUT with %u bytes forwarded to MST\n", ps,
1389 ps, *upload_data_size); 1369 *upload_data_size);
1390#endif 1370#endif
1391 res = GNUNET_SERVER_mst_receive (ps->msgtok, ps, 1371 res =
1392 upload_data, *upload_data_size, 1372 GNUNET_SERVER_mst_receive (ps->msgtok, ps, upload_data,
1393 GNUNET_NO, GNUNET_NO); 1373 *upload_data_size, GNUNET_NO, GNUNET_NO);
1394 (*upload_data_size) = 0; 1374 (*upload_data_size) = 0;
1395 } 1375 }
1396 else 1376 else
@@ -1485,11 +1465,10 @@ http_server_daemon_prepare (struct Plugin *plugin,
1485 plugin->http_server_daemon_v4 = GNUNET_SCHEDULER_NO_TASK; 1465 plugin->http_server_daemon_v4 = GNUNET_SCHEDULER_NO_TASK;
1486 } 1466 }
1487 1467
1488 ret = GNUNET_SCHEDULER_add_select (GNUNET_SCHEDULER_PRIORITY_DEFAULT, 1468 ret =
1489 GNUNET_SCHEDULER_NO_TASK, 1469 GNUNET_SCHEDULER_add_select (GNUNET_SCHEDULER_PRIORITY_DEFAULT,
1490 tv, 1470 GNUNET_SCHEDULER_NO_TASK, tv, wrs, wws,
1491 wrs, 1471 &http_server_daemon_v4_run, plugin);
1492 wws, &http_server_daemon_v4_run, plugin);
1493 } 1472 }
1494 if (daemon_handle == plugin->http_server_daemon_v6) 1473 if (daemon_handle == plugin->http_server_daemon_v6)
1495 { 1474 {
@@ -1499,11 +1478,10 @@ http_server_daemon_prepare (struct Plugin *plugin,
1499 plugin->http_server_task_v6 = GNUNET_SCHEDULER_NO_TASK; 1478 plugin->http_server_task_v6 = GNUNET_SCHEDULER_NO_TASK;
1500 } 1479 }
1501 1480
1502 ret = GNUNET_SCHEDULER_add_select (GNUNET_SCHEDULER_PRIORITY_DEFAULT, 1481 ret =
1503 GNUNET_SCHEDULER_NO_TASK, 1482 GNUNET_SCHEDULER_add_select (GNUNET_SCHEDULER_PRIORITY_DEFAULT,
1504 tv, 1483 GNUNET_SCHEDULER_NO_TASK, tv, wrs, wws,
1505 wrs, 1484 &http_server_daemon_v6_run, plugin);
1506 wws, &http_server_daemon_v6_run, plugin);
1507 } 1485 }
1508 GNUNET_NETWORK_fdset_destroy (wrs); 1486 GNUNET_NETWORK_fdset_destroy (wrs);
1509 GNUNET_NETWORK_fdset_destroy (wws); 1487 GNUNET_NETWORK_fdset_destroy (wws);
@@ -1643,8 +1621,8 @@ curl_get_header_cb (void *ptr, size_t size, size_t nmemb, void *stream)
1643 if (tmp[len - 2] == 13) 1621 if (tmp[len - 2] == 13)
1644 tmp[len - 2] = '\0'; 1622 tmp[len - 2] = '\0';
1645 } 1623 }
1646 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1624 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Connection %X: Header: %s\n", ps,
1647 "Connection %X: Header: %s\n", ps, tmp); 1625 tmp);
1648 } 1626 }
1649 GNUNET_free_non_null (tmp); 1627 GNUNET_free_non_null (tmp);
1650#endif 1628#endif
@@ -1791,8 +1769,8 @@ curl_send_cb (void *stream, size_t size, size_t nmemb, void *ptr)
1791 1769
1792 1770
1793static void 1771static void
1794curl_receive_mst_cb (void *cls, 1772curl_receive_mst_cb (void *cls, void *client,
1795 void *client, const struct GNUNET_MessageHeader *message) 1773 const struct GNUNET_MessageHeader *message)
1796{ 1774{
1797 struct Session *ps = cls; 1775 struct Session *ps = cls;
1798 struct GNUNET_TIME_Relative delay; 1776 struct GNUNET_TIME_Relative delay;
@@ -1805,11 +1783,12 @@ curl_receive_mst_cb (void *cls,
1805#if DEBUG_HTTP 1783#if DEBUG_HTTP
1806 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1784 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1807 "Connection %X: Forwarding message to transport service, type %u and size %u from `%s' (`%s')\n", 1785 "Connection %X: Forwarding message to transport service, type %u and size %u from `%s' (`%s')\n",
1808 ps, 1786 ps, ntohs (message->type), ntohs (message->size),
1809 ntohs (message->type), 1787 GNUNET_i2s (&(pc->identity)), http_plugin_address_to_string (NULL,
1810 ntohs (message->size), 1788 ps->
1811 GNUNET_i2s (&(pc->identity)), 1789 addr,
1812 http_plugin_address_to_string (NULL, ps->addr, ps->addrlen)); 1790 ps->
1791 addrlen));
1813#endif 1792#endif
1814 struct GNUNET_TRANSPORT_ATS_Information distance[2]; 1793 struct GNUNET_TRANSPORT_ATS_Information distance[2];
1815 1794
@@ -1818,12 +1797,10 @@ curl_receive_mst_cb (void *cls,
1818 distance[1].type = htonl (GNUNET_TRANSPORT_ATS_ARRAY_TERMINATOR); 1797 distance[1].type = htonl (GNUNET_TRANSPORT_ATS_ARRAY_TERMINATOR);
1819 distance[1].value = htonl (0); 1798 distance[1].value = htonl (0);
1820 1799
1821 delay = pc->plugin->env->receive (pc->plugin->env->cls, 1800 delay =
1822 &pc->identity, 1801 pc->plugin->env->receive (pc->plugin->env->cls, &pc->identity, message,
1823 message, 1802 (const struct GNUNET_TRANSPORT_ATS_Information
1824 (const struct 1803 *) &distance, 2, ps, ps->addr, ps->addrlen);
1825 GNUNET_TRANSPORT_ATS_Information *)
1826 &distance, 2, ps, ps->addr, ps->addrlen);
1827 pc->delay = delay; 1804 pc->delay = delay;
1828 if (pc->reset_task != GNUNET_SCHEDULER_NO_TASK) 1805 if (pc->reset_task != GNUNET_SCHEDULER_NO_TASK)
1829 GNUNET_SCHEDULER_cancel (pc->reset_task); 1806 GNUNET_SCHEDULER_cancel (pc->reset_task);
@@ -1865,11 +1842,11 @@ curl_receive_cb (void *stream, size_t size, size_t nmemb, void *ptr)
1865 return 0; 1842 return 0;
1866 } 1843 }
1867#if DEBUG_CONNECTIONS 1844#if DEBUG_CONNECTIONS
1868 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1845 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Connection %X: %u bytes received\n", ps,
1869 "Connection %X: %u bytes received\n", ps, size * nmemb); 1846 size * nmemb);
1870#endif 1847#endif
1871 GNUNET_SERVER_mst_receive (ps->msgtok, ps, 1848 GNUNET_SERVER_mst_receive (ps->msgtok, ps, stream, size * nmemb, GNUNET_NO,
1872 stream, size * nmemb, GNUNET_NO, GNUNET_NO); 1849 GNUNET_NO);
1873 return (size * nmemb); 1850 return (size * nmemb);
1874} 1851}
1875 1852
@@ -1958,8 +1935,7 @@ curl_handle_finished (struct Plugin *plugin)
1958#if DEBUG_CONNECTIONS 1935#if DEBUG_CONNECTIONS
1959 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1936 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1960 "Connection %X: HTTP PUT connection to peer `%s' (`%s') was closed with HTTP code %u\n", 1937 "Connection %X: HTTP PUT connection to peer `%s' (`%s') was closed with HTTP code %u\n",
1961 ps, 1938 ps, GNUNET_i2s (&pc->identity),
1962 GNUNET_i2s (&pc->identity),
1963 http_plugin_address_to_string (NULL, ps->addr, 1939 http_plugin_address_to_string (NULL, ps->addr,
1964 ps->addrlen), http_result); 1940 ps->addrlen), http_result);
1965#endif 1941#endif
@@ -1995,8 +1971,7 @@ curl_handle_finished (struct Plugin *plugin)
1995#if DEBUG_CONNECTIONS 1971#if DEBUG_CONNECTIONS
1996 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1972 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1997 "Connection %X: HTTP GET connection to peer `%s' (`%s') was closed with HTTP code %u\n", 1973 "Connection %X: HTTP GET connection to peer `%s' (`%s') was closed with HTTP code %u\n",
1998 ps, 1974 ps, GNUNET_i2s (&pc->identity),
1999 GNUNET_i2s (&pc->identity),
2000 http_plugin_address_to_string (NULL, ps->addr, 1975 http_plugin_address_to_string (NULL, ps->addr,
2001 ps->addrlen), http_result); 1976 ps->addrlen), http_result);
2002#endif 1977#endif
@@ -2081,8 +2056,7 @@ curl_schedule (struct Plugin *plugin)
2081 mret = curl_multi_fdset (plugin->multi_handle, &rs, &ws, &es, &max); 2056 mret = curl_multi_fdset (plugin->multi_handle, &rs, &ws, &es, &max);
2082 if (mret != CURLM_OK) 2057 if (mret != CURLM_OK)
2083 { 2058 {
2084 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 2059 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("%s failed at %s:%d: `%s'\n"),
2085 _("%s failed at %s:%d: `%s'\n"),
2086 "curl_multi_fdset", __FILE__, __LINE__, 2060 "curl_multi_fdset", __FILE__, __LINE__,
2087 curl_multi_strerror (mret)); 2061 curl_multi_strerror (mret));
2088 return GNUNET_SYSERR; 2062 return GNUNET_SYSERR;
@@ -2090,8 +2064,7 @@ curl_schedule (struct Plugin *plugin)
2090 mret = curl_multi_timeout (plugin->multi_handle, &to); 2064 mret = curl_multi_timeout (plugin->multi_handle, &to);
2091 if (mret != CURLM_OK) 2065 if (mret != CURLM_OK)
2092 { 2066 {
2093 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 2067 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("%s failed at %s:%d: `%s'\n"),
2094 _("%s failed at %s:%d: `%s'\n"),
2095 "curl_multi_timeout", __FILE__, __LINE__, 2068 "curl_multi_timeout", __FILE__, __LINE__,
2096 curl_multi_strerror (mret)); 2069 curl_multi_strerror (mret));
2097 return GNUNET_SYSERR; 2070 return GNUNET_SYSERR;
@@ -2129,8 +2102,8 @@ curl_schedule (struct Plugin *plugin)
2129 * @return 0 2102 * @return 0
2130 */ 2103 */
2131static int 2104static int
2132curl_logger (CURL * curl, 2105curl_logger (CURL * curl, curl_infotype type, char *data, size_t size,
2133 curl_infotype type, char *data, size_t size, void *cls) 2106 void *cls)
2134{ 2107{
2135 if (type == CURLINFO_TEXT) 2108 if (type == CURLINFO_TEXT)
2136 { 2109 {
@@ -2217,8 +2190,7 @@ send_check_connections (struct Plugin *plugin, struct Session *ps)
2217 if (mret != CURLM_OK) 2190 if (mret != CURLM_OK)
2218 { 2191 {
2219 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 2192 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
2220 _("Connection: %X: %s failed at %s:%d: `%s'\n"), 2193 _("Connection: %X: %s failed at %s:%d: `%s'\n"), ps,
2221 ps,
2222 "curl_multi_add_handle", __FILE__, __LINE__, 2194 "curl_multi_add_handle", __FILE__, __LINE__,
2223 curl_multi_strerror (mret)); 2195 curl_multi_strerror (mret));
2224 return GNUNET_SYSERR; 2196 return GNUNET_SYSERR;
@@ -2330,8 +2302,7 @@ send_check_connections (struct Plugin *plugin, struct Session *ps)
2330 if (mret != CURLM_OK) 2302 if (mret != CURLM_OK)
2331 { 2303 {
2332 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 2304 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
2333 _("Connection: %X: %s failed at %s:%d: `%s'\n"), 2305 _("Connection: %X: %s failed at %s:%d: `%s'\n"), ps,
2334 ps,
2335 "curl_multi_add_handle", __FILE__, __LINE__, 2306 "curl_multi_add_handle", __FILE__, __LINE__,
2336 curl_multi_strerror (mret)); 2307 curl_multi_strerror (mret));
2337 return GNUNET_SYSERR; 2308 return GNUNET_SYSERR;
@@ -2371,9 +2342,8 @@ send_check_connections (struct Plugin *plugin, struct Session *ps)
2371 * 2342 *
2372 */ 2343 */
2373static struct Session * 2344static struct Session *
2374send_select_session (struct HTTP_PeerContext *pc, 2345send_select_session (struct HTTP_PeerContext *pc, const void *addr,
2375 const void *addr, size_t addrlen, 2346 size_t addrlen, int force_address, struct Session *session)
2376 int force_address, struct Session *session)
2377{ 2347{
2378 struct Session *tmp = NULL; 2348 struct Session *tmp = NULL;
2379 int addr_given = GNUNET_NO; 2349 int addr_given = GNUNET_NO;
@@ -2534,16 +2504,10 @@ send_select_session (struct HTTP_PeerContext *pc,
2534 * and does NOT mean that the message was not transmitted (DV) 2504 * and does NOT mean that the message was not transmitted (DV)
2535 */ 2505 */
2536static ssize_t 2506static ssize_t
2537http_plugin_send (void *cls, 2507http_plugin_send (void *cls, const struct GNUNET_PeerIdentity *target,
2538 const struct GNUNET_PeerIdentity *target, 2508 const char *msgbuf, size_t msgbuf_size, unsigned int priority,
2539 const char *msgbuf, 2509 struct GNUNET_TIME_Relative to, struct Session *session,
2540 size_t msgbuf_size, 2510 const void *addr, size_t addrlen, int force_address,
2541 unsigned int priority,
2542 struct GNUNET_TIME_Relative to,
2543 struct Session *session,
2544 const void *addr,
2545 size_t addrlen,
2546 int force_address,
2547 GNUNET_TRANSPORT_TransmitContinuation cont, void *cont_cls) 2511 GNUNET_TRANSPORT_TransmitContinuation cont, void *cont_cls)
2548{ 2512{
2549 struct Plugin *plugin = cls; 2513 struct Plugin *plugin = cls;
@@ -2566,9 +2530,7 @@ http_plugin_send (void *cls,
2566 GNUNET_assert (0); 2530 GNUNET_assert (0);
2567 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 2531 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
2568 "Transport tells me to send %u bytes to `%s' using %s (%s) and session: %X\n", 2532 "Transport tells me to send %u bytes to `%s' using %s (%s) and session: %X\n",
2569 msgbuf_size, 2533 msgbuf_size, GNUNET_i2s (target), force,
2570 GNUNET_i2s (target),
2571 force,
2572 http_plugin_address_to_string (NULL, addr, addrlen), session); 2534 http_plugin_address_to_string (NULL, addr, addrlen), session);
2573 GNUNET_free (force); 2535 GNUNET_free (force);
2574#endif 2536#endif
@@ -2582,13 +2544,12 @@ http_plugin_send (void *cls,
2582 pc->session_id_counter = 1; 2544 pc->session_id_counter = 1;
2583 pc->last_session = NULL; 2545 pc->last_session = NULL;
2584 memcpy (&pc->identity, target, sizeof (struct GNUNET_PeerIdentity)); 2546 memcpy (&pc->identity, target, sizeof (struct GNUNET_PeerIdentity));
2585 GNUNET_CONTAINER_multihashmap_put (plugin->peers, 2547 GNUNET_CONTAINER_multihashmap_put (plugin->peers, &pc->identity.hashPubKey,
2586 &pc->identity.hashPubKey,
2587 pc, 2548 pc,
2588 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY); 2549 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY);
2589 GNUNET_STATISTICS_update (plugin->env->stats, 2550 GNUNET_STATISTICS_update (plugin->env->stats,
2590 gettext_noop ("# HTTP peers active"), 2551 gettext_noop ("# HTTP peers active"), 1,
2591 1, GNUNET_NO); 2552 GNUNET_NO);
2592 } 2553 }
2593 ps = send_select_session (pc, addr, addrlen, force_address, session); 2554 ps = send_select_session (pc, addr, addrlen, force_address, session);
2594 /* session not existing, but address forced -> creating new session */ 2555 /* session not existing, but address forced -> creating new session */
@@ -2659,8 +2620,8 @@ http_plugin_send (void *cls,
2659 msg->transmit_cont = cont; 2620 msg->transmit_cont = cont;
2660 msg->transmit_cont_cls = cont_cls; 2621 msg->transmit_cont_cls = cont_cls;
2661 memcpy (msg->buf, msgbuf, msgbuf_size); 2622 memcpy (msg->buf, msgbuf, msgbuf_size);
2662 GNUNET_CONTAINER_DLL_insert (ps->pending_msgs_head, 2623 GNUNET_CONTAINER_DLL_insert (ps->pending_msgs_head, ps->pending_msgs_tail,
2663 ps->pending_msgs_tail, msg); 2624 msg);
2664 ps->queue_length_cur += msgbuf_size; 2625 ps->queue_length_cur += msgbuf_size;
2665 if (send_check_connections (plugin, ps) == GNUNET_SYSERR) 2626 if (send_check_connections (plugin, ps) == GNUNET_SYSERR)
2666 return GNUNET_SYSERR; 2627 return GNUNET_SYSERR;
@@ -2767,14 +2728,12 @@ append_port (void *cls, const char *hostname)
2767 * @param asc_cls closure for asc 2728 * @param asc_cls closure for asc
2768 */ 2729 */
2769static void 2730static void
2770http_plugin_address_pretty_printer (void *cls, 2731http_plugin_address_pretty_printer (void *cls, const char *type,
2771 const char *type, 2732 const void *addr, size_t addrlen,
2772 const void *addr,
2773 size_t addrlen,
2774 int numeric, 2733 int numeric,
2775 struct GNUNET_TIME_Relative timeout, 2734 struct GNUNET_TIME_Relative timeout,
2776 GNUNET_TRANSPORT_AddressStringCallback 2735 GNUNET_TRANSPORT_AddressStringCallback asc,
2777 asc, void *asc_cls) 2736 void *asc_cls)
2778{ 2737{
2779 struct PrettyPrinterContext *ppc; 2738 struct PrettyPrinterContext *ppc;
2780 const void *sb; 2739 const void *sb;
@@ -2963,16 +2922,15 @@ http_plugin_address_to_string (void *cls, const void *addr, size_t addrlen)
2963 * @param addrlen number of bytes in addr 2922 * @param addrlen number of bytes in addr
2964 */ 2923 */
2965static void 2924static void
2966try_connection_reversal (void *cls, 2925try_connection_reversal (void *cls, const struct sockaddr *addr,
2967 const struct sockaddr *addr, socklen_t addrlen) 2926 socklen_t addrlen)
2968{ 2927{
2969 2928
2970} 2929}
2971 2930
2972static void 2931static void
2973tcp_nat_cb_add_addr (void *cls, 2932tcp_nat_cb_add_addr (void *cls, int add_remove, const struct sockaddr *addr,
2974 int add_remove, 2933 socklen_t addrlen)
2975 const struct sockaddr *addr, socklen_t addrlen)
2976{ 2934{
2977 struct Plugin *plugin = cls; 2935 struct Plugin *plugin = cls;
2978 struct IPv4HttpAddress *t4 = NULL; 2936 struct IPv4HttpAddress *t4 = NULL;
@@ -3000,8 +2958,7 @@ tcp_nat_cb_add_addr (void *cls,
3000 { 2958 {
3001 w_t4 = GNUNET_malloc (sizeof (struct IPv4HttpAddressWrapper)); 2959 w_t4 = GNUNET_malloc (sizeof (struct IPv4HttpAddressWrapper));
3002 t4 = GNUNET_malloc (sizeof (struct IPv4HttpAddress)); 2960 t4 = GNUNET_malloc (sizeof (struct IPv4HttpAddress));
3003 memcpy (&t4->ipv4_addr, 2961 memcpy (&t4->ipv4_addr, &((struct sockaddr_in *) addr)->sin_addr,
3004 &((struct sockaddr_in *) addr)->sin_addr,
3005 sizeof (struct in_addr)); 2962 sizeof (struct in_addr));
3006 t4->port = htons (plugin->port_inbound); 2963 t4->port = htons (plugin->port_inbound);
3007 2964
@@ -3010,9 +2967,8 @@ tcp_nat_cb_add_addr (void *cls,
3010 GNUNET_CONTAINER_DLL_insert (plugin->ipv4_addr_head, 2967 GNUNET_CONTAINER_DLL_insert (plugin->ipv4_addr_head,
3011 plugin->ipv4_addr_tail, w_t4); 2968 plugin->ipv4_addr_tail, w_t4);
3012 } 2969 }
3013 plugin->env->notify_address (plugin->env->cls, 2970 plugin->env->notify_address (plugin->env->cls, add_remove, w_t4->addr,
3014 add_remove, 2971 sizeof (struct IPv4HttpAddress));
3015 w_t4->addr, sizeof (struct IPv4HttpAddress));
3016 2972
3017 break; 2973 break;
3018 case AF_INET6: 2974 case AF_INET6:
@@ -3032,8 +2988,7 @@ tcp_nat_cb_add_addr (void *cls,
3032 w_t6 = GNUNET_malloc (sizeof (struct IPv6HttpAddressWrapper)); 2988 w_t6 = GNUNET_malloc (sizeof (struct IPv6HttpAddressWrapper));
3033 t6 = GNUNET_malloc (sizeof (struct IPv6HttpAddress)); 2989 t6 = GNUNET_malloc (sizeof (struct IPv6HttpAddress));
3034 2990
3035 memcpy (&t6->ipv6_addr, 2991 memcpy (&t6->ipv6_addr, &((struct sockaddr_in6 *) addr)->sin6_addr,
3036 &((struct sockaddr_in6 *) addr)->sin6_addr,
3037 sizeof (struct in6_addr)); 2992 sizeof (struct in6_addr));
3038 t6->port = htons (plugin->port_inbound); 2993 t6->port = htons (plugin->port_inbound);
3039 2994
@@ -3042,9 +2997,8 @@ tcp_nat_cb_add_addr (void *cls,
3042 GNUNET_CONTAINER_DLL_insert (plugin->ipv6_addr_head, 2997 GNUNET_CONTAINER_DLL_insert (plugin->ipv6_addr_head,
3043 plugin->ipv6_addr_tail, w_t6); 2998 plugin->ipv6_addr_tail, w_t6);
3044 } 2999 }
3045 plugin->env->notify_address (plugin->env->cls, 3000 plugin->env->notify_address (plugin->env->cls, add_remove, w_t6->addr,
3046 add_remove, 3001 sizeof (struct IPv6HttpAddress));
3047 w_t6->addr, sizeof (struct IPv6HttpAddress));
3048 break; 3002 break;
3049 default: 3003 default:
3050 return; 3004 return;
@@ -3053,9 +3007,8 @@ tcp_nat_cb_add_addr (void *cls,
3053} 3007}
3054 3008
3055static void 3009static void
3056tcp_nat_cb_remove_addr (void *cls, 3010tcp_nat_cb_remove_addr (void *cls, int add_remove, const struct sockaddr *addr,
3057 int add_remove, 3011 socklen_t addrlen)
3058 const struct sockaddr *addr, socklen_t addrlen)
3059{ 3012{
3060 struct Plugin *plugin = cls; 3013 struct Plugin *plugin = cls;
3061 struct IPv4HttpAddressWrapper *w_t4 = NULL; 3014 struct IPv4HttpAddressWrapper *w_t4 = NULL;
@@ -3079,12 +3032,11 @@ tcp_nat_cb_remove_addr (void *cls,
3079 } 3032 }
3080 if (w_t4 == NULL) 3033 if (w_t4 == NULL)
3081 return; 3034 return;
3082 plugin->env->notify_address (plugin->env->cls, 3035 plugin->env->notify_address (plugin->env->cls, add_remove, w_t4->addr,
3083 add_remove, 3036 sizeof (struct IPv4HttpAddress));
3084 w_t4->addr, sizeof (struct IPv4HttpAddress));
3085 3037
3086 GNUNET_CONTAINER_DLL_remove (plugin->ipv4_addr_head, 3038 GNUNET_CONTAINER_DLL_remove (plugin->ipv4_addr_head, plugin->ipv4_addr_tail,
3087 plugin->ipv4_addr_tail, w_t4); 3039 w_t4);
3088 GNUNET_free (w_t4->addr); 3040 GNUNET_free (w_t4->addr);
3089 GNUNET_free (w_t4); 3041 GNUNET_free (w_t4);
3090 break; 3042 break;
@@ -3102,12 +3054,11 @@ tcp_nat_cb_remove_addr (void *cls,
3102 } 3054 }
3103 if (w_t6 == NULL) 3055 if (w_t6 == NULL)
3104 return; 3056 return;
3105 plugin->env->notify_address (plugin->env->cls, 3057 plugin->env->notify_address (plugin->env->cls, add_remove, w_t6->addr,
3106 add_remove, 3058 sizeof (struct IPv6HttpAddress));
3107 w_t6->addr, sizeof (struct IPv6HttpAddress));
3108 3059
3109 GNUNET_CONTAINER_DLL_remove (plugin->ipv6_addr_head, 3060 GNUNET_CONTAINER_DLL_remove (plugin->ipv6_addr_head, plugin->ipv6_addr_tail,
3110 plugin->ipv6_addr_tail, w_t6); 3061 w_t6);
3111 GNUNET_free (w_t6->addr); 3062 GNUNET_free (w_t6->addr);
3112 GNUNET_free (w_t6); 3063 GNUNET_free (w_t6);
3113 break; 3064 break;
@@ -3127,14 +3078,12 @@ tcp_nat_cb_remove_addr (void *cls,
3127 * @param addrlen actual lenght of the address 3078 * @param addrlen actual lenght of the address
3128 */ 3079 */
3129static void 3080static void
3130tcp_nat_port_map_callback (void *cls, 3081tcp_nat_port_map_callback (void *cls, int add_remove,
3131 int add_remove,
3132 const struct sockaddr *addr, socklen_t addrlen) 3082 const struct sockaddr *addr, socklen_t addrlen)
3133{ 3083{
3134 GNUNET_assert (cls != NULL); 3084 GNUNET_assert (cls != NULL);
3135#if DEBUG_HTTP 3085#if DEBUG_HTTP
3136 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, 3086 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "NPMC called to %s address `%s'\n",
3137 "NPMC called to %s address `%s'\n",
3138 (add_remove == GNUNET_YES) ? "remove" : "add", 3087 (add_remove == GNUNET_YES) ? "remove" : "add",
3139 GNUNET_a2s (addr, addrlen)); 3088 GNUNET_a2s (addr, addrlen));
3140#endif 3089#endif
@@ -3242,8 +3191,8 @@ LIBGNUNET_PLUGIN_TRANSPORT_DONE (void *cls)
3242 GNUNET_free (plugin); 3191 GNUNET_free (plugin);
3243 GNUNET_free (api); 3192 GNUNET_free (api);
3244#if DEBUG_HTTP 3193#if DEBUG_HTTP
3245 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 3194 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Unload %s plugin complete...\n",
3246 "Unload %s plugin complete...\n", PROTOCOL_PREFIX); 3195 PROTOCOL_PREFIX);
3247#endif 3196#endif
3248 return NULL; 3197 return NULL;
3249} 3198}
@@ -3304,8 +3253,8 @@ LIBGNUNET_PLUGIN_TRANSPORT_INIT (void *cls)
3304 3253
3305 GNUNET_assert (cls != NULL); 3254 GNUNET_assert (cls != NULL);
3306#if DEBUG_HTTP 3255#if DEBUG_HTTP
3307 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 3256 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Starting %s plugin...\n",
3308 "Starting %s plugin...\n", PROTOCOL_PREFIX); 3257 PROTOCOL_PREFIX);
3309#endif 3258#endif
3310 GNUNET_asprintf (&component_name, "transport-%s", PROTOCOL_PREFIX); 3259 GNUNET_asprintf (&component_name, "transport-%s", PROTOCOL_PREFIX);
3311 3260
@@ -3333,8 +3282,7 @@ LIBGNUNET_PLUGIN_TRANSPORT_INIT (void *cls)
3333 3282
3334 3283
3335 if (GNUNET_OK != 3284 if (GNUNET_OK !=
3336 GNUNET_CONFIGURATION_get_value_number (env->cfg, 3285 GNUNET_CONFIGURATION_get_value_number (env->cfg, component_name,
3337 component_name,
3338 "MAX_CONNECTIONS", &tneigh)) 3286 "MAX_CONNECTIONS", &tneigh))
3339 tneigh = 128; 3287 tneigh = 128;
3340 plugin->max_connect_per_transport = tneigh; 3288 plugin->max_connect_per_transport = tneigh;
@@ -3343,34 +3291,32 @@ LIBGNUNET_PLUGIN_TRANSPORT_INIT (void *cls)
3343 /* Use IPv6? */ 3291 /* Use IPv6? */
3344 if (GNUNET_CONFIGURATION_have_value (env->cfg, component_name, "USE_IPv6")) 3292 if (GNUNET_CONFIGURATION_have_value (env->cfg, component_name, "USE_IPv6"))
3345 { 3293 {
3346 plugin->use_ipv6 = GNUNET_CONFIGURATION_get_value_yesno (env->cfg, 3294 plugin->use_ipv6 =
3347 component_name, 3295 GNUNET_CONFIGURATION_get_value_yesno (env->cfg, component_name,
3348 "USE_IPv6"); 3296 "USE_IPv6");
3349 } 3297 }
3350 /* Use IPv4? */ 3298 /* Use IPv4? */
3351 if (GNUNET_CONFIGURATION_have_value (env->cfg, component_name, "USE_IPv4")) 3299 if (GNUNET_CONFIGURATION_have_value (env->cfg, component_name, "USE_IPv4"))
3352 { 3300 {
3353 plugin->use_ipv4 = GNUNET_CONFIGURATION_get_value_yesno (env->cfg, 3301 plugin->use_ipv4 =
3354 component_name, 3302 GNUNET_CONFIGURATION_get_value_yesno (env->cfg, component_name,
3355 "USE_IPv4"); 3303 "USE_IPv4");
3356 } 3304 }
3357 /* use local addresses? */ 3305 /* use local addresses? */
3358 3306
3359 if (GNUNET_CONFIGURATION_have_value (env->cfg, 3307 if (GNUNET_CONFIGURATION_have_value
3360 component_name, "USE_LOCALADDR")) 3308 (env->cfg, component_name, "USE_LOCALADDR"))
3361 { 3309 {
3362 plugin->use_localaddresses = GNUNET_CONFIGURATION_get_value_yesno (env->cfg, 3310 plugin->use_localaddresses =
3363 component_name, 3311 GNUNET_CONFIGURATION_get_value_yesno (env->cfg, component_name,
3364 "USE_LOCALADDR"); 3312 "USE_LOCALADDR");
3365 } 3313 }
3366 /* Reading port number from config file */ 3314 /* Reading port number from config file */
3367 if ((GNUNET_OK != 3315 if ((GNUNET_OK !=
3368 GNUNET_CONFIGURATION_get_value_number (env->cfg, 3316 GNUNET_CONFIGURATION_get_value_number (env->cfg, component_name, "PORT",
3369 component_name, 3317 &port)) || (port > 65535))
3370 "PORT", &port)) || (port > 65535))
3371 { 3318 {
3372 GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, 3319 GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, component_name,
3373 component_name,
3374 _ 3320 _
3375 ("Require valid port number for transport plugin `%s' in configuration!\n"), 3321 ("Require valid port number for transport plugin `%s' in configuration!\n"),
3376 PROTOCOL_PREFIX); 3322 PROTOCOL_PREFIX);
@@ -3387,7 +3333,8 @@ LIBGNUNET_PLUGIN_TRANSPORT_INIT (void *cls)
3387 GNUNET_CONFIGURATION_get_value_string (env->cfg, 3333 GNUNET_CONFIGURATION_get_value_string (env->cfg,
3388 component_name, 3334 component_name,
3389 "BINDTO4", 3335 "BINDTO4",
3390 &plugin->bind_hostname)); 3336 &plugin->
3337 bind_hostname));
3391 plugin->bind4_address = GNUNET_malloc (sizeof (struct sockaddr_in)); 3338 plugin->bind4_address = GNUNET_malloc (sizeof (struct sockaddr_in));
3392 plugin->bind4_address->sin_family = AF_INET; 3339 plugin->bind4_address->sin_family = AF_INET;
3393 plugin->bind4_address->sin_port = htons (port); 3340 plugin->bind4_address->sin_port = htons (port);
@@ -3398,8 +3345,7 @@ LIBGNUNET_PLUGIN_TRANSPORT_INIT (void *cls)
3398 (AF_INET, plugin->bind_hostname, 3345 (AF_INET, plugin->bind_hostname,
3399 &plugin->bind4_address->sin_addr) <= 0) 3346 &plugin->bind4_address->sin_addr) <= 0)
3400 { 3347 {
3401 GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, 3348 GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, component_name,
3402 component_name,
3403 _ 3349 _
3404 ("Misconfigured address to bind to in configuration!\n")); 3350 ("Misconfigured address to bind to in configuration!\n"));
3405 GNUNET_free (plugin->bind4_address); 3351 GNUNET_free (plugin->bind4_address);
@@ -3414,10 +3360,10 @@ LIBGNUNET_PLUGIN_TRANSPORT_INIT (void *cls)
3414 if ((plugin->use_ipv6 == GNUNET_YES) && 3360 if ((plugin->use_ipv6 == GNUNET_YES) &&
3415 (GNUNET_CONFIGURATION_have_value (env->cfg, component_name, "BINDTO6"))) 3361 (GNUNET_CONFIGURATION_have_value (env->cfg, component_name, "BINDTO6")))
3416 { 3362 {
3417 if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_string (env->cfg, 3363 if (GNUNET_OK ==
3418 component_name, 3364 GNUNET_CONFIGURATION_get_value_string (env->cfg, component_name,
3419 "BINDTO6", 3365 "BINDTO6",
3420 &plugin->bind_hostname)) 3366 &plugin->bind_hostname))
3421 { 3367 {
3422 plugin->bind6_address = GNUNET_malloc (sizeof (struct sockaddr_in6)); 3368 plugin->bind6_address = GNUNET_malloc (sizeof (struct sockaddr_in6));
3423 plugin->bind6_address->sin6_family = AF_INET6; 3369 plugin->bind6_address->sin6_family = AF_INET6;
@@ -3428,8 +3374,7 @@ LIBGNUNET_PLUGIN_TRANSPORT_INIT (void *cls)
3428 (AF_INET6, plugin->bind_hostname, 3374 (AF_INET6, plugin->bind_hostname,
3429 &plugin->bind6_address->sin6_addr) <= 0) 3375 &plugin->bind6_address->sin6_addr) <= 0)
3430 { 3376 {
3431 GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, 3377 GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, component_name,
3432 component_name,
3433 _ 3378 _
3434 ("Misconfigured address to bind to in configuration!\n")); 3379 ("Misconfigured address to bind to in configuration!\n"));
3435 GNUNET_free (plugin->bind6_address); 3380 GNUNET_free (plugin->bind6_address);
@@ -3445,22 +3390,17 @@ LIBGNUNET_PLUGIN_TRANSPORT_INIT (void *cls)
3445 /* Reading HTTPS crypto related configuration */ 3390 /* Reading HTTPS crypto related configuration */
3446 /* Get crypto init string from config */ 3391 /* Get crypto init string from config */
3447 if ((GNUNET_OK != 3392 if ((GNUNET_OK !=
3448 GNUNET_CONFIGURATION_get_value_string (env->cfg, 3393 GNUNET_CONFIGURATION_get_value_string (env->cfg, "transport-https",
3449 "transport-https",
3450 "CRYPTO_INIT", 3394 "CRYPTO_INIT",
3451 &plugin->crypto_init)) || 3395 &plugin->crypto_init)) ||
3452 (GNUNET_OK != 3396 (GNUNET_OK !=
3453 GNUNET_CONFIGURATION_get_value_filename (env->cfg, 3397 GNUNET_CONFIGURATION_get_value_filename (env->cfg, "transport-https",
3454 "transport-https", 3398 "KEY_FILE", &key_file)) ||
3455 "KEY_FILE",
3456 &key_file)) ||
3457 (GNUNET_OK != 3399 (GNUNET_OK !=
3458 GNUNET_CONFIGURATION_get_value_filename (env->cfg, 3400 GNUNET_CONFIGURATION_get_value_filename (env->cfg, "transport-https",
3459 "transport-https",
3460 "CERT_FILE", &cert_file))) 3401 "CERT_FILE", &cert_file)))
3461 { 3402 {
3462 GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, 3403 GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, "https",
3463 "https",
3464 _ 3404 _
3465 ("Required configuration options missing in section `%s'\n"), 3405 ("Required configuration options missing in section `%s'\n"),
3466 "transport-https"); 3406 "transport-https");
@@ -3472,8 +3412,8 @@ LIBGNUNET_PLUGIN_TRANSPORT_INIT (void *cls)
3472 } 3412 }
3473 3413
3474 /* read key & certificates from file */ 3414 /* read key & certificates from file */
3475 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 3415 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Loading TLS certificate `%s' `%s'\n",
3476 "Loading TLS certificate `%s' `%s'\n", key_file, cert_file); 3416 key_file, cert_file);
3477 3417
3478 plugin->key = load_certificate (key_file); 3418 plugin->key = load_certificate (key_file);
3479 plugin->cert = load_certificate (cert_file); 3419 plugin->cert = load_certificate (cert_file);
@@ -3491,14 +3431,14 @@ LIBGNUNET_PLUGIN_TRANSPORT_INIT (void *cls)
3491 "No usable TLS certificate found, creating certificate\n"); 3431 "No usable TLS certificate found, creating certificate\n");
3492#endif 3432#endif
3493 errno = 0; 3433 errno = 0;
3494 certcreation = GNUNET_OS_start_process (NULL, NULL, 3434 certcreation =
3495 "gnunet-transport-certificate-creation", 3435 GNUNET_OS_start_process (NULL, NULL,
3496 "gnunet-transport-certificate-creation", 3436 "gnunet-transport-certificate-creation",
3497 key_file, cert_file, NULL); 3437 "gnunet-transport-certificate-creation",
3438 key_file, cert_file, NULL);
3498 if (certcreation == NULL) 3439 if (certcreation == NULL)
3499 { 3440 {
3500 GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, 3441 GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, "https",
3501 "https",
3502 _ 3442 _
3503 ("Could not create a new TLS certificate, program `gnunet-transport-certificate-creation' could not be started!\n")); 3443 ("Could not create a new TLS certificate, program `gnunet-transport-certificate-creation' could not be started!\n"));
3504 GNUNET_free (key_file); 3444 GNUNET_free (key_file);
@@ -3514,8 +3454,7 @@ LIBGNUNET_PLUGIN_TRANSPORT_INIT (void *cls)
3514 } 3454 }
3515 if ((plugin->key == NULL) || (plugin->cert == NULL)) 3455 if ((plugin->key == NULL) || (plugin->cert == NULL))
3516 { 3456 {
3517 GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, 3457 GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, "https",
3518 "https",
3519 _ 3458 _
3520 ("No usable TLS certificate found and creating one failed!\n"), 3459 ("No usable TLS certificate found and creating one failed!\n"),
3521 "transport-https"); 3460 "transport-https");
@@ -3549,15 +3488,14 @@ LIBGNUNET_PLUGIN_TRANSPORT_INIT (void *cls)
3549#if BUILD_HTTPS 3488#if BUILD_HTTPS
3550 MHD_USE_SSL | 3489 MHD_USE_SSL |
3551#endif 3490#endif
3552 MHD_USE_IPv6, 3491 MHD_USE_IPv6, port,
3553 port,
3554 &mhd_accept_cb, plugin, 3492 &mhd_accept_cb, plugin,
3555 &mhd_access_cb, plugin, 3493 &mhd_access_cb, plugin,
3556 MHD_OPTION_SOCK_ADDR, 3494 MHD_OPTION_SOCK_ADDR,
3557 tmp, 3495 tmp,
3558 MHD_OPTION_CONNECTION_LIMIT, 3496 MHD_OPTION_CONNECTION_LIMIT,
3559 (unsigned int) 3497 (unsigned int) plugin->
3560 plugin->max_connect_per_transport, 3498 max_connect_per_transport,
3561#if BUILD_HTTPS 3499#if BUILD_HTTPS
3562 MHD_OPTION_HTTPS_PRIORITIES, 3500 MHD_OPTION_HTTPS_PRIORITIES,
3563 plugin->crypto_init, 3501 plugin->crypto_init,
@@ -3589,16 +3527,15 @@ LIBGNUNET_PLUGIN_TRANSPORT_INIT (void *cls)
3589#if BUILD_HTTPS 3527#if BUILD_HTTPS
3590 MHD_USE_SSL | 3528 MHD_USE_SSL |
3591#endif 3529#endif
3592 MHD_NO_FLAG, 3530 MHD_NO_FLAG, port,
3593 port,
3594 &mhd_accept_cb, plugin, 3531 &mhd_accept_cb, plugin,
3595 &mhd_access_cb, plugin, 3532 &mhd_access_cb, plugin,
3596 MHD_OPTION_SOCK_ADDR, 3533 MHD_OPTION_SOCK_ADDR,
3597 (struct sockaddr_in *) 3534 (struct sockaddr_in *)
3598 plugin->bind4_address, 3535 plugin->bind4_address,
3599 MHD_OPTION_CONNECTION_LIMIT, 3536 MHD_OPTION_CONNECTION_LIMIT,
3600 (unsigned int) 3537 (unsigned int) plugin->
3601 plugin->max_connect_per_transport, 3538 max_connect_per_transport,
3602#if BUILD_HTTPS 3539#if BUILD_HTTPS
3603 MHD_OPTION_HTTPS_PRIORITIES, 3540 MHD_OPTION_HTTPS_PRIORITIES,
3604 plugin->crypto_init, 3541 plugin->crypto_init,
@@ -3685,8 +3622,7 @@ LIBGNUNET_PLUGIN_TRANSPORT_INIT (void *cls)
3685 3622
3686 if (NULL == plugin->multi_handle) 3623 if (NULL == plugin->multi_handle)
3687 { 3624 {
3688 GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, 3625 GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, component_name,
3689 component_name,
3690 _ 3626 _
3691 ("Could not initialize curl multi handle, failed to start %s plugin!\n"), 3627 ("Could not initialize curl multi handle, failed to start %s plugin!\n"),
3692 PROTOCOL_PREFIX); 3628 PROTOCOL_PREFIX);
@@ -3695,19 +3631,17 @@ LIBGNUNET_PLUGIN_TRANSPORT_INIT (void *cls)
3695 return NULL; 3631 return NULL;
3696 } 3632 }
3697 3633
3698 ret = GNUNET_SERVICE_get_server_addresses (component_name, 3634 ret =
3699 env->cfg, &addrs, &addrlens); 3635 GNUNET_SERVICE_get_server_addresses (component_name, env->cfg, &addrs,
3636 &addrlens);
3700 3637
3701 if (ret != GNUNET_SYSERR) 3638 if (ret != GNUNET_SYSERR)
3702 { 3639 {
3703 plugin->nat = GNUNET_NAT_register (env->cfg, 3640 plugin->nat =
3704 GNUNET_YES, 3641 GNUNET_NAT_register (env->cfg, GNUNET_YES, port, (unsigned int) ret,
3705 port, 3642 (const struct sockaddr **) addrs, addrlens,
3706 (unsigned int) ret, 3643 &tcp_nat_port_map_callback,
3707 (const struct sockaddr **) addrs, 3644 &try_connection_reversal, plugin);
3708 addrlens,
3709 &tcp_nat_port_map_callback,
3710 &try_connection_reversal, plugin);
3711 while (ret > 0) 3645 while (ret > 0)
3712 { 3646 {
3713 ret--; 3647 ret--;
@@ -3719,11 +3653,9 @@ LIBGNUNET_PLUGIN_TRANSPORT_INIT (void *cls)
3719 } 3653 }
3720 else 3654 else
3721 { 3655 {
3722 plugin->nat = GNUNET_NAT_register (env->cfg, 3656 plugin->nat =
3723 GNUNET_YES, 3657 GNUNET_NAT_register (env->cfg, GNUNET_YES, 0, 0, NULL, NULL, NULL,
3724 0, 3658 &try_connection_reversal, plugin);
3725 0, NULL, NULL,
3726 NULL, &try_connection_reversal, plugin);
3727 } 3659 }
3728 3660
3729 plugin->peers = GNUNET_CONTAINER_multihashmap_create (10); 3661 plugin->peers = GNUNET_CONTAINER_multihashmap_create (10);
diff --git a/src/transport/plugin_transport_smtp.c b/src/transport/plugin_transport_smtp.c
index 074bc16fc..1b9f5fb72 100644
--- a/src/transport/plugin_transport_smtp.c
+++ b/src/transport/plugin_transport_smtp.c
@@ -145,8 +145,8 @@ static GNUNET_CronTime last_transmission;
145/** ******************** Base64 encoding ***********/ 145/** ******************** Base64 encoding ***********/
146 146
147#define FILLCHAR '=' 147#define FILLCHAR '='
148static char *cvt = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" 148static char *cvt =
149 "abcdefghijklmnopqrstuvwxyz" "0123456789+/"; 149 "ABCDEFGHIJKLMNOPQRSTUVWXYZ" "abcdefghijklmnopqrstuvwxyz" "0123456789+/";
150 150
151/** 151/**
152 * Encode into Base64. 152 * Encode into Base64.
@@ -171,8 +171,10 @@ base64_encode (const char *data, unsigned int len, char **output)
171 (*output)[ret++] = '\n'; \ 171 (*output)[ret++] = '\n'; \
172 } 172 }
173 ret = 0; 173 ret = 0;
174 opt = GNUNET_malloc (2 + (((len * 4 / 3) + 8) * (MAX_CHAR_PER_LINE + 2)) / 174 opt =
175 MAX_CHAR_PER_LINE); 175 GNUNET_malloc (2 +
176 (((len * 4 / 3) + 8) * (MAX_CHAR_PER_LINE +
177 2)) / MAX_CHAR_PER_LINE);
176 /* message must start with \r\n for libesmtp */ 178 /* message must start with \r\n for libesmtp */
177 *output = opt; 179 *output = opt;
178 opt[0] = '\r'; 180 opt[0] = '\r';
@@ -361,17 +363,14 @@ listenAndDistribute (void *unused)
361 if (ntohs (mp->header.size) != size) 363 if (ntohs (mp->header.size) != size)
362 { 364 {
363 GNUNET_GE_LOG (ectx, 365 GNUNET_GE_LOG (ectx,
364 GNUNET_GE_WARNING | GNUNET_GE_BULK | 366 GNUNET_GE_WARNING | GNUNET_GE_BULK | GNUNET_GE_USER,
365 GNUNET_GE_USER, 367 _("Received malformed message via %s. Ignored.\n"),
366 _
367 ("Received malformed message via %s. Ignored.\n"),
368 "SMTP"); 368 "SMTP");
369#if DEBUG_SMTP 369#if DEBUG_SMTP
370 GNUNET_GE_LOG (ectx, 370 GNUNET_GE_LOG (ectx,
371 GNUNET_GE_DEBUG | GNUNET_GE_REQUEST | 371 GNUNET_GE_DEBUG | GNUNET_GE_REQUEST | GNUNET_GE_USER,
372 GNUNET_GE_USER, 372 "Size returned by base64=%d, in the msg=%d.\n", size,
373 "Size returned by base64=%d, in the msg=%d.\n", 373 ntohl (mp->size));
374 size, ntohl (mp->size));
375#endif 374#endif
376 GNUNET_free (out); 375 GNUNET_free (out);
377 goto END; 376 goto END;
@@ -384,8 +383,7 @@ listenAndDistribute (void *unused)
384 coreMP->tsession = NULL; 383 coreMP->tsession = NULL;
385 coreMP->sender = mp->sender; 384 coreMP->sender = mp->sender;
386#if DEBUG_SMTP 385#if DEBUG_SMTP
387 GNUNET_GE_LOG (ectx, 386 GNUNET_GE_LOG (ectx, GNUNET_GE_DEBUG | GNUNET_GE_REQUEST | GNUNET_GE_USER,
388 GNUNET_GE_DEBUG | GNUNET_GE_REQUEST | GNUNET_GE_USER,
389 "SMTP message passed to the core.\n"); 387 "SMTP message passed to the core.\n");
390#endif 388#endif
391 389
@@ -393,8 +391,7 @@ listenAndDistribute (void *unused)
393 } 391 }
394END: 392END:
395#if DEBUG_SMTP 393#if DEBUG_SMTP
396 GNUNET_GE_LOG (ectx, 394 GNUNET_GE_LOG (ectx, GNUNET_GE_DEBUG | GNUNET_GE_REQUEST | GNUNET_GE_USER,
397 GNUNET_GE_DEBUG | GNUNET_GE_REQUEST | GNUNET_GE_USER,
398 "SMTP message processed.\n"); 395 "SMTP message processed.\n");
399#endif 396#endif
400 if (fdes != NULL) 397 if (fdes != NULL)
@@ -423,8 +420,9 @@ api_verify_hello (const GNUNET_MessageHello * hello)
423 maddr = (const EmailAddress *) &hello[1]; 420 maddr = (const EmailAddress *) &hello[1];
424 if ((ntohs (hello->header.size) != 421 if ((ntohs (hello->header.size) !=
425 sizeof (GNUNET_MessageHello) + ntohs (hello->senderAddressSize)) || 422 sizeof (GNUNET_MessageHello) + ntohs (hello->senderAddressSize)) ||
426 (maddr->senderAddress[ntohs (hello->senderAddressSize) - 1 - 423 (maddr->
427 FILTER_STRING_SIZE] != '\0')) 424 senderAddress[ntohs (hello->senderAddressSize) - 1 -
425 FILTER_STRING_SIZE] != '\0'))
428 { 426 {
429 GNUNET_GE_BREAK (ectx, 0); 427 GNUNET_GE_BREAK (ectx, 0);
430 return GNUNET_SYSERR; /* obviously invalid */ 428 return GNUNET_SYSERR; /* obviously invalid */
@@ -449,13 +447,11 @@ api_create_hello ()
449 EmailAddress *haddr; 447 EmailAddress *haddr;
450 int i; 448 int i;
451 449
452 GNUNET_GC_get_configuration_value_string (coreAPI->cfg, 450 GNUNET_GC_get_configuration_value_string (coreAPI->cfg, "SMTP", "FILTER",
453 "SMTP", "FILTER",
454 "X-mailer: GNUnet", &filter); 451 "X-mailer: GNUnet", &filter);
455 if (NULL == strstr (filter, ": ")) 452 if (NULL == strstr (filter, ": "))
456 { 453 {
457 GNUNET_GE_LOG (ectx, 454 GNUNET_GE_LOG (ectx, GNUNET_GE_WARNING | GNUNET_GE_BULK | GNUNET_GE_USER,
458 GNUNET_GE_WARNING | GNUNET_GE_BULK | GNUNET_GE_USER,
459 _("SMTP filter string to invalid, lacks ': '\n")); 455 _("SMTP filter string to invalid, lacks ': '\n"));
460 GNUNET_free (filter); 456 GNUNET_free (filter);
461 return NULL; 457 return NULL;
@@ -464,8 +460,7 @@ api_create_hello ()
464 if (strlen (filter) > FILTER_STRING_SIZE) 460 if (strlen (filter) > FILTER_STRING_SIZE)
465 { 461 {
466 filter[FILTER_STRING_SIZE] = '\0'; 462 filter[FILTER_STRING_SIZE] = '\0';
467 GNUNET_GE_LOG (ectx, 463 GNUNET_GE_LOG (ectx, GNUNET_GE_WARNING | GNUNET_GE_BULK | GNUNET_GE_USER,
468 GNUNET_GE_WARNING | GNUNET_GE_BULK | GNUNET_GE_USER,
469 _("SMTP filter string to long, capped to `%s'\n"), filter); 464 _("SMTP filter string to long, capped to `%s'\n"), filter);
470 } 465 }
471 i = (strlen (email) + 8) & (~7); /* make multiple of 8 */ 466 i = (strlen (email) + 8) & (~7); /* make multiple of 8 */
@@ -521,8 +516,8 @@ get_message (void **buf, int *len, void *cls)
521 * @return GNUNET_SYSERR on error, GNUNET_OK on success 516 * @return GNUNET_SYSERR on error, GNUNET_OK on success
522 */ 517 */
523static int 518static int
524api_send (GNUNET_TSession * tsession, 519api_send (GNUNET_TSession * tsession, const void *msg, const unsigned int size,
525 const void *msg, const unsigned int size, int important) 520 int important)
526{ 521{
527 const GNUNET_MessageHello *hello; 522 const GNUNET_MessageHello *hello;
528 const EmailAddress *haddr; 523 const EmailAddress *haddr;
@@ -561,10 +556,9 @@ api_send (GNUNET_TSession * tsession,
561 { 556 {
562 GNUNET_GE_LOG (ectx, 557 GNUNET_GE_LOG (ectx,
563 GNUNET_GE_ERROR | GNUNET_GE_ADMIN | GNUNET_GE_USER | 558 GNUNET_GE_ERROR | GNUNET_GE_ADMIN | GNUNET_GE_USER |
564 GNUNET_GE_IMMEDIATE, 559 GNUNET_GE_IMMEDIATE, _("SMTP: `%s' failed: %s.\n"),
565 _("SMTP: `%s' failed: %s.\n"), 560 "smtp_create_session", smtp_strerror (smtp_errno (), ebuf,
566 "smtp_create_session", 561 EBUF_LEN));
567 smtp_strerror (smtp_errno (), ebuf, EBUF_LEN));
568 GNUNET_mutex_unlock (lock); 562 GNUNET_mutex_unlock (lock);
569 return GNUNET_SYSERR; 563 return GNUNET_SYSERR;
570 } 564 }
@@ -572,10 +566,9 @@ api_send (GNUNET_TSession * tsession,
572 { 566 {
573 GNUNET_GE_LOG (ectx, 567 GNUNET_GE_LOG (ectx,
574 GNUNET_GE_ERROR | GNUNET_GE_ADMIN | GNUNET_GE_USER | 568 GNUNET_GE_ERROR | GNUNET_GE_ADMIN | GNUNET_GE_USER |
575 GNUNET_GE_IMMEDIATE, 569 GNUNET_GE_IMMEDIATE, _("SMTP: `%s' failed: %s.\n"),
576 _("SMTP: `%s' failed: %s.\n"), 570 "smtp_set_server", smtp_strerror (smtp_errno (), ebuf,
577 "smtp_set_server", 571 EBUF_LEN));
578 smtp_strerror (smtp_errno (), ebuf, EBUF_LEN));
579 smtp_destroy_session (session); 572 smtp_destroy_session (session);
580 GNUNET_mutex_unlock (lock); 573 GNUNET_mutex_unlock (lock);
581 return GNUNET_SYSERR; 574 return GNUNET_SYSERR;
@@ -586,10 +579,9 @@ api_send (GNUNET_TSession * tsession,
586 { 579 {
587 GNUNET_GE_LOG (ectx, 580 GNUNET_GE_LOG (ectx,
588 GNUNET_GE_WARNING | GNUNET_GE_ADMIN | GNUNET_GE_USER | 581 GNUNET_GE_WARNING | GNUNET_GE_ADMIN | GNUNET_GE_USER |
589 GNUNET_GE_BULK, 582 GNUNET_GE_BULK, _("SMTP: `%s' failed: %s.\n"),
590 _("SMTP: `%s' failed: %s.\n"), 583 "smtp_add_message", smtp_strerror (smtp_errno (), ebuf,
591 "smtp_add_message", 584 EBUF_LEN));
592 smtp_strerror (smtp_errno (), ebuf, EBUF_LEN));
593 smtp_destroy_session (session); 585 smtp_destroy_session (session);
594 GNUNET_mutex_unlock (lock); 586 GNUNET_mutex_unlock (lock);
595 return GNUNET_SYSERR; 587 return GNUNET_SYSERR;
@@ -606,10 +598,9 @@ api_send (GNUNET_TSession * tsession,
606 { 598 {
607 GNUNET_GE_LOG (ectx, 599 GNUNET_GE_LOG (ectx,
608 GNUNET_GE_WARNING | GNUNET_GE_ADMIN | GNUNET_GE_USER | 600 GNUNET_GE_WARNING | GNUNET_GE_ADMIN | GNUNET_GE_USER |
609 GNUNET_GE_BULK, 601 GNUNET_GE_BULK, _("SMTP: `%s' failed: %s.\n"),
610 _("SMTP: `%s' failed: %s.\n"), 602 "smtp_set_header", smtp_strerror (smtp_errno (), ebuf,
611 "smtp_set_header", 603 EBUF_LEN));
612 smtp_strerror (smtp_errno (), ebuf, EBUF_LEN));
613 smtp_destroy_session (session); 604 smtp_destroy_session (session);
614 GNUNET_mutex_unlock (lock); 605 GNUNET_mutex_unlock (lock);
615 GNUNET_free (filter); 606 GNUNET_free (filter);
@@ -630,19 +621,17 @@ api_send (GNUNET_TSession * tsession,
630 { 621 {
631 GNUNET_GE_LOG (ectx, 622 GNUNET_GE_LOG (ectx,
632 GNUNET_GE_WARNING | GNUNET_GE_ADMIN | GNUNET_GE_USER | 623 GNUNET_GE_WARNING | GNUNET_GE_ADMIN | GNUNET_GE_USER |
633 GNUNET_GE_BULK, 624 GNUNET_GE_BULK, _("SMTP: `%s' failed: %s.\n"),
634 _("SMTP: `%s' failed: %s.\n"), 625 "smtp_size_set_estimate", smtp_strerror (smtp_errno (), ebuf,
635 "smtp_size_set_estimate", 626 EBUF_LEN));
636 smtp_strerror (smtp_errno (), ebuf, EBUF_LEN));
637 } 627 }
638 if (0 == smtp_set_messagecb (message, &get_message, &gm_cls)) 628 if (0 == smtp_set_messagecb (message, &get_message, &gm_cls))
639 { 629 {
640 GNUNET_GE_LOG (ectx, 630 GNUNET_GE_LOG (ectx,
641 GNUNET_GE_WARNING | GNUNET_GE_ADMIN | GNUNET_GE_USER | 631 GNUNET_GE_WARNING | GNUNET_GE_ADMIN | GNUNET_GE_USER |
642 GNUNET_GE_BULK, 632 GNUNET_GE_BULK, _("SMTP: `%s' failed: %s.\n"),
643 _("SMTP: `%s' failed: %s.\n"), 633 "smtp_set_messagecb", smtp_strerror (smtp_errno (), ebuf,
644 "smtp_set_messagecb", 634 EBUF_LEN));
645 smtp_strerror (smtp_errno (), ebuf, EBUF_LEN));
646 smtp_destroy_session (session); 635 smtp_destroy_session (session);
647 GNUNET_mutex_unlock (lock); 636 GNUNET_mutex_unlock (lock);
648 GNUNET_free (gm_cls.ebody); 637 GNUNET_free (gm_cls.ebody);
@@ -653,10 +642,9 @@ api_send (GNUNET_TSession * tsession,
653 { 642 {
654 GNUNET_GE_LOG (ectx, 643 GNUNET_GE_LOG (ectx,
655 GNUNET_GE_WARNING | GNUNET_GE_ADMIN | GNUNET_GE_USER | 644 GNUNET_GE_WARNING | GNUNET_GE_ADMIN | GNUNET_GE_USER |
656 GNUNET_GE_BULK, 645 GNUNET_GE_BULK, _("SMTP: `%s' failed: %s.\n"),
657 _("SMTP: `%s' failed: %s.\n"), 646 "smtp_add_recipient", smtp_strerror (smtp_errno (), ebuf,
658 "smtp_add_recipient", 647 EBUF_LEN));
659 smtp_strerror (smtp_errno (), ebuf, EBUF_LEN));
660 smtp_destroy_session (session); 648 smtp_destroy_session (session);
661 GNUNET_mutex_unlock (lock); 649 GNUNET_mutex_unlock (lock);
662 return GNUNET_SYSERR; 650 return GNUNET_SYSERR;
@@ -665,10 +653,9 @@ api_send (GNUNET_TSession * tsession,
665 { 653 {
666 GNUNET_GE_LOG (ectx, 654 GNUNET_GE_LOG (ectx,
667 GNUNET_GE_WARNING | GNUNET_GE_ADMIN | GNUNET_GE_USER | 655 GNUNET_GE_WARNING | GNUNET_GE_ADMIN | GNUNET_GE_USER |
668 GNUNET_GE_BULK, 656 GNUNET_GE_BULK, _("SMTP: `%s' failed: %s.\n"),
669 _("SMTP: `%s' failed: %s.\n"), 657 "smtp_start_session", smtp_strerror (smtp_errno (), ebuf,
670 "smtp_start_session", 658 EBUF_LEN));
671 smtp_strerror (smtp_errno (), ebuf, EBUF_LEN));
672 smtp_destroy_session (session); 659 smtp_destroy_session (session);
673 GNUNET_mutex_unlock (lock); 660 GNUNET_mutex_unlock (lock);
674 GNUNET_free (gm_cls.ebody); 661 GNUNET_free (gm_cls.ebody);
@@ -694,8 +681,8 @@ api_send (GNUNET_TSession * tsession,
694 * @return GNUNET_OK on success, GNUNET_SYSERR if the operation failed 681 * @return GNUNET_OK on success, GNUNET_SYSERR if the operation failed
695 */ 682 */
696static int 683static int
697api_connect (const GNUNET_MessageHello * hello, 684api_connect (const GNUNET_MessageHello * hello, GNUNET_TSession ** tsessionPtr,
698 GNUNET_TSession ** tsessionPtr, int may_reuse) 685 int may_reuse)
699{ 686{
700 GNUNET_TSession *tsession; 687 GNUNET_TSession *tsession;
701 688
@@ -739,8 +726,8 @@ api_start_transport_server ()
739 if (dispatchThread == NULL) 726 if (dispatchThread == NULL)
740 { 727 {
741 GNUNET_GE_DIE_STRERROR (ectx, 728 GNUNET_GE_DIE_STRERROR (ectx,
742 GNUNET_GE_ADMIN | GNUNET_GE_BULK | 729 GNUNET_GE_ADMIN | GNUNET_GE_BULK | GNUNET_GE_FATAL,
743 GNUNET_GE_FATAL, "pthread_create"); 730 "pthread_create");
744 return GNUNET_SYSERR; 731 return GNUNET_SYSERR;
745 } 732 }
746 return GNUNET_OK; 733 return GNUNET_OK;
@@ -765,8 +752,8 @@ api_stop_transport_server ()
765 * Convert SMTP hello to an IP address (always fails). 752 * Convert SMTP hello to an IP address (always fails).
766 */ 753 */
767static int 754static int
768api_hello_to_address (const GNUNET_MessageHello * hello, 755api_hello_to_address (const GNUNET_MessageHello * hello, void **sa,
769 void **sa, unsigned int *sa_len) 756 unsigned int *sa_len)
770{ 757{
771 return GNUNET_SYSERR; 758 return GNUNET_SYSERR;
772} 759}
@@ -807,42 +794,34 @@ inittransport_smtp (GNUNET_CoreAPIForTransport * core)
807 ectx = core->ectx; 794 ectx = core->ectx;
808 if (!GNUNET_GC_have_configuration_value (coreAPI->cfg, "SMTP", "EMAIL")) 795 if (!GNUNET_GC_have_configuration_value (coreAPI->cfg, "SMTP", "EMAIL"))
809 { 796 {
810 GNUNET_GE_LOG (ectx, 797 GNUNET_GE_LOG (ectx, GNUNET_GE_ERROR | GNUNET_GE_BULK | GNUNET_GE_USER,
811 GNUNET_GE_ERROR | GNUNET_GE_BULK | GNUNET_GE_USER,
812 _ 798 _
813 ("No email-address specified, can not start SMTP transport.\n")); 799 ("No email-address specified, can not start SMTP transport.\n"));
814 return NULL; 800 return NULL;
815 } 801 }
816 GNUNET_GC_get_configuration_value_number (coreAPI->cfg, 802 GNUNET_GC_get_configuration_value_number (coreAPI->cfg, "SMTP", "MTU", 1200,
817 "SMTP",
818 "MTU",
819 1200,
820 SMTP_MESSAGE_SIZE, 803 SMTP_MESSAGE_SIZE,
821 SMTP_MESSAGE_SIZE, &mtu); 804 SMTP_MESSAGE_SIZE, &mtu);
822 GNUNET_GC_get_configuration_value_number (coreAPI->cfg, 805 GNUNET_GC_get_configuration_value_number (coreAPI->cfg, "SMTP", "RATELIMIT",
823 "SMTP",
824 "RATELIMIT",
825 0, 0, 1024 * 1024, &rate_limit); 806 0, 0, 1024 * 1024, &rate_limit);
826 stats = coreAPI->service_request ("stats"); 807 stats = coreAPI->service_request ("stats");
827 if (stats != NULL) 808 if (stats != NULL)
828 { 809 {
829 stat_bytesReceived 810 stat_bytesReceived =
830 = stats->create (gettext_noop ("# bytes received via SMTP")); 811 stats->create (gettext_noop ("# bytes received via SMTP"));
831 stat_bytesSent = stats->create (gettext_noop ("# bytes sent via SMTP")); 812 stat_bytesSent = stats->create (gettext_noop ("# bytes sent via SMTP"));
832 stat_bytesDropped 813 stat_bytesDropped =
833 = stats->create (gettext_noop ("# bytes dropped by SMTP (outgoing)")); 814 stats->create (gettext_noop ("# bytes dropped by SMTP (outgoing)"));
834 } 815 }
835 GNUNET_GC_get_configuration_value_filename (coreAPI->cfg, 816 GNUNET_GC_get_configuration_value_filename (coreAPI->cfg, "SMTP", "PIPE",
836 "SMTP",
837 "PIPE",
838 GNUNET_DEFAULT_DAEMON_VAR_DIRECTORY 817 GNUNET_DEFAULT_DAEMON_VAR_DIRECTORY
839 "/smtp-pipe", &pipename); 818 "/smtp-pipe", &pipename);
840 UNLINK (pipename); 819 UNLINK (pipename);
841 if (0 != mkfifo (pipename, S_IWUSR | S_IRUSR | S_IWGRP | S_IWOTH)) 820 if (0 != mkfifo (pipename, S_IWUSR | S_IRUSR | S_IWGRP | S_IWOTH))
842 { 821 {
843 GNUNET_GE_LOG_STRERROR (ectx, 822 GNUNET_GE_LOG_STRERROR (ectx,
844 GNUNET_GE_ADMIN | GNUNET_GE_BULK | 823 GNUNET_GE_ADMIN | GNUNET_GE_BULK | GNUNET_GE_FATAL,
845 GNUNET_GE_FATAL, "mkfifo"); 824 "mkfifo");
846 GNUNET_free (pipename); 825 GNUNET_free (pipename);
847 coreAPI->service_release (stats); 826 coreAPI->service_release (stats);
848 stats = NULL; 827 stats = NULL;
@@ -854,12 +833,10 @@ inittransport_smtp (GNUNET_CoreAPIForTransport * core)
854 GNUNET_GE_LOG_STRERROR (ectx, 833 GNUNET_GE_LOG_STRERROR (ectx,
855 GNUNET_GE_ADMIN | GNUNET_GE_BULK | 834 GNUNET_GE_ADMIN | GNUNET_GE_BULK |
856 GNUNET_GE_WARNING, "chmod"); 835 GNUNET_GE_WARNING, "chmod");
857 GNUNET_GC_get_configuration_value_string (coreAPI->cfg, 836 GNUNET_GC_get_configuration_value_string (coreAPI->cfg, "SMTP", "EMAIL", NULL,
858 "SMTP", "EMAIL", NULL, &email); 837 &email);
859 lock = GNUNET_mutex_create (GNUNET_NO); 838 lock = GNUNET_mutex_create (GNUNET_NO);
860 GNUNET_GC_get_configuration_value_string (coreAPI->cfg, 839 GNUNET_GC_get_configuration_value_string (coreAPI->cfg, "SMTP", "SERVER",
861 "SMTP",
862 "SERVER",
863 "localhost:25", &smtp_server_name); 840 "localhost:25", &smtp_server_name);
864 sa.sa_handler = SIG_IGN; 841 sa.sa_handler = SIG_IGN;
865 sigemptyset (&sa.sa_mask); 842 sigemptyset (&sa.sa_mask);
diff --git a/src/transport/plugin_transport_tcp.c b/src/transport/plugin_transport_tcp.c
index bd2f4aa6a..331203471 100644
--- a/src/transport/plugin_transport_tcp.c
+++ b/src/transport/plugin_transport_tcp.c
@@ -419,8 +419,7 @@ plugin_tcp_access_check (void *cls,
419 * @param addrlen actual lenght of the address 419 * @param addrlen actual lenght of the address
420 */ 420 */
421static void 421static void
422tcp_nat_port_map_callback (void *cls, 422tcp_nat_port_map_callback (void *cls, int add_remove,
423 int add_remove,
424 const struct sockaddr *addr, socklen_t addrlen) 423 const struct sockaddr *addr, socklen_t addrlen)
425{ 424{
426 struct Plugin *plugin = cls; 425 struct Plugin *plugin = cls;
@@ -429,10 +428,9 @@ tcp_nat_port_map_callback (void *cls,
429 void *arg; 428 void *arg;
430 size_t args; 429 size_t args;
431 430
432 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, 431 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "tcp",
433 "tcp", 432 "NPMC called with %d for address `%s'\n", add_remove,
434 "NPMC called with %d for address `%s'\n", 433 GNUNET_a2s (addr, addrlen));
435 add_remove, GNUNET_a2s (addr, addrlen));
436 /* convert 'addr' to our internal format */ 434 /* convert 'addr' to our internal format */
437 switch (addr->sa_family) 435 switch (addr->sa_family)
438 { 436 {
@@ -445,8 +443,7 @@ tcp_nat_port_map_callback (void *cls,
445 break; 443 break;
446 case AF_INET6: 444 case AF_INET6:
447 GNUNET_assert (addrlen == sizeof (struct sockaddr_in6)); 445 GNUNET_assert (addrlen == sizeof (struct sockaddr_in6));
448 memcpy (&t6.ipv6_addr, 446 memcpy (&t6.ipv6_addr, &((struct sockaddr_in6 *) addr)->sin6_addr,
449 &((struct sockaddr_in6 *) addr)->sin6_addr,
450 sizeof (struct in6_addr)); 447 sizeof (struct in6_addr));
451 t6.t6_port = ((struct sockaddr_in6 *) addr)->sin6_port; 448 t6.t6_port = ((struct sockaddr_in6 *) addr)->sin6_port;
452 arg = &t6; 449 arg = &t6;
@@ -503,8 +500,7 @@ tcp_address_to_string (void *cls, const void *addr, size_t addrlen)
503 } 500 }
504 else 501 else
505 { 502 {
506 GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, 503 GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, "tcp",
507 "tcp",
508 _("Unexpected address length: %u bytes\n"), 504 _("Unexpected address length: %u bytes\n"),
509 (unsigned int) addrlen); 505 (unsigned int) addrlen);
510 GNUNET_break (0); 506 GNUNET_break (0);
@@ -515,9 +511,8 @@ tcp_address_to_string (void *cls, const void *addr, size_t addrlen)
515 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "inet_ntop"); 511 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "inet_ntop");
516 return NULL; 512 return NULL;
517 } 513 }
518 GNUNET_snprintf (rbuf, 514 GNUNET_snprintf (rbuf, sizeof (rbuf), (af == AF_INET6) ? "[%s]:%u" : "%s:%u",
519 sizeof (rbuf), 515 buf, port);
520 (af == AF_INET6) ? "[%s]:%u" : "%s:%u", buf, port);
521 return rbuf; 516 return rbuf;
522} 517}
523 518
@@ -554,8 +549,7 @@ find_session_by_client (struct Plugin *plugin,
554 * @return new session object 549 * @return new session object
555 */ 550 */
556static struct Session * 551static struct Session *
557create_session (struct Plugin *plugin, 552create_session (struct Plugin *plugin, const struct GNUNET_PeerIdentity *target,
558 const struct GNUNET_PeerIdentity *target,
559 struct GNUNET_SERVER_Client *client, int is_nat) 553 struct GNUNET_SERVER_Client *client, int is_nat)
560{ 554{
561 struct Session *ret; 555 struct Session *ret;
@@ -567,8 +561,7 @@ create_session (struct Plugin *plugin,
567 else 561 else
568 GNUNET_assert (client == NULL); 562 GNUNET_assert (client == NULL);
569#if DEBUG_TCP 563#if DEBUG_TCP
570 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, 564 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "tcp",
571 "tcp",
572 "Creating new session for peer `%4s'\n", 565 "Creating new session for peer `%4s'\n",
573 GNUNET_i2s (target)); 566 GNUNET_i2s (target));
574#endif 567#endif
@@ -600,8 +593,8 @@ create_session (struct Plugin *plugin,
600 ret->pending_messages_tail, pm); 593 ret->pending_messages_tail, pm);
601 if (is_nat != GNUNET_YES) 594 if (is_nat != GNUNET_YES)
602 GNUNET_STATISTICS_update (plugin->env->stats, 595 GNUNET_STATISTICS_update (plugin->env->stats,
603 gettext_noop ("# TCP sessions active"), 596 gettext_noop ("# TCP sessions active"), 1,
604 1, GNUNET_NO); 597 GNUNET_NO);
605 return ret; 598 return ret;
606} 599}
607 600
@@ -645,8 +638,7 @@ do_transmit (void *cls, size_t size, void *buf)
645 if (buf == NULL) 638 if (buf == NULL)
646 { 639 {
647#if DEBUG_TCP 640#if DEBUG_TCP
648 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, 641 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "tcp",
649 "tcp",
650 "Timeout trying to transmit to peer `%4s', discarding message queue.\n", 642 "Timeout trying to transmit to peer `%4s', discarding message queue.\n",
651 GNUNET_i2s (&session->target)); 643 GNUNET_i2s (&session->target));
652#endif 644#endif
@@ -661,8 +653,7 @@ do_transmit (void *cls, size_t size, void *buf)
661 GNUNET_CONTAINER_DLL_remove (session->pending_messages_head, 653 GNUNET_CONTAINER_DLL_remove (session->pending_messages_head,
662 session->pending_messages_tail, pos); 654 session->pending_messages_tail, pos);
663#if DEBUG_TCP 655#if DEBUG_TCP
664 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, 656 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "tcp",
665 "tcp",
666 "Failed to transmit %u byte message to `%4s'.\n", 657 "Failed to transmit %u byte message to `%4s'.\n",
667 pos->message_size, GNUNET_i2s (&session->target)); 658 pos->message_size, GNUNET_i2s (&session->target));
668#endif 659#endif
@@ -729,15 +720,15 @@ do_transmit (void *cls, size_t size, void *buf)
729 GNUNET_assert (hd == NULL); 720 GNUNET_assert (hd == NULL);
730 GNUNET_assert (tl == NULL); 721 GNUNET_assert (tl == NULL);
731#if DEBUG_TCP > 1 722#if DEBUG_TCP > 1
732 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, 723 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "tcp", "Transmitting %u bytes\n",
733 "tcp", "Transmitting %u bytes\n", ret); 724 ret);
734#endif 725#endif
735 GNUNET_STATISTICS_update (plugin->env->stats, 726 GNUNET_STATISTICS_update (plugin->env->stats,
736 gettext_noop ("# bytes currently in TCP buffers"), 727 gettext_noop ("# bytes currently in TCP buffers"),
737 -(int64_t) ret, GNUNET_NO); 728 -(int64_t) ret, GNUNET_NO);
738 GNUNET_STATISTICS_update (plugin->env->stats, 729 GNUNET_STATISTICS_update (plugin->env->stats,
739 gettext_noop ("# bytes transmitted via TCP"), 730 gettext_noop ("# bytes transmitted via TCP"), ret,
740 ret, GNUNET_NO); 731 GNUNET_NO);
741 return ret; 732 return ret;
742} 733}
743 734
@@ -759,12 +750,11 @@ process_pending_messages (struct Session *session)
759 if (NULL == (pm = session->pending_messages_head)) 750 if (NULL == (pm = session->pending_messages_head))
760 return; 751 return;
761 752
762 session->transmit_handle 753 session->transmit_handle =
763 = GNUNET_SERVER_notify_transmit_ready (session->client, 754 GNUNET_SERVER_notify_transmit_ready (session->client, pm->message_size,
764 pm->message_size, 755 GNUNET_TIME_absolute_get_remaining
765 GNUNET_TIME_absolute_get_remaining 756 (pm->timeout), &do_transmit,
766 (pm->timeout), 757 session);
767 &do_transmit, session);
768} 758}
769 759
770 760
@@ -783,14 +773,14 @@ disconnect_session (struct Session *session)
783 struct PendingMessage *pm; 773 struct PendingMessage *pm;
784 774
785#if DEBUG_TCP 775#if DEBUG_TCP
786 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, 776 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "tcp",
787 "tcp",
788 "Disconnecting from `%4s' at %s.\n", 777 "Disconnecting from `%4s' at %s.\n",
789 GNUNET_i2s (&session->target), 778 GNUNET_i2s (&session->target),
790 (session->connect_addr != NULL) ? 779 (session->connect_addr !=
791 tcp_address_to_string (session->plugin, 780 NULL) ? tcp_address_to_string (session->plugin,
792 session->connect_addr, 781 session->connect_addr,
793 session->connect_alen) : "*"); 782 session->
783 connect_alen) : "*");
794#endif 784#endif
795 /* remove from session list */ 785 /* remove from session list */
796 prev = NULL; 786 prev = NULL;
@@ -816,11 +806,10 @@ disconnect_session (struct Session *session)
816 while (NULL != (pm = session->pending_messages_head)) 806 while (NULL != (pm = session->pending_messages_head))
817 { 807 {
818#if DEBUG_TCP 808#if DEBUG_TCP
819 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, 809 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "tcp",
820 "tcp", 810 pm->transmit_cont !=
821 pm->transmit_cont != NULL 811 NULL ? "Could not deliver message to `%4s'.\n" :
822 ? "Could not deliver message to `%4s'.\n" 812 "Could not deliver message to `%4s', notifying.\n",
823 : "Could not deliver message to `%4s', notifying.\n",
824 GNUNET_i2s (&session->target)); 813 GNUNET_i2s (&session->target));
825#endif 814#endif
826 GNUNET_STATISTICS_update (session->plugin->env->stats, 815 GNUNET_STATISTICS_update (session->plugin->env->stats,
@@ -833,8 +822,8 @@ disconnect_session (struct Session *session)
833 GNUNET_CONTAINER_DLL_remove (session->pending_messages_head, 822 GNUNET_CONTAINER_DLL_remove (session->pending_messages_head,
834 session->pending_messages_tail, pm); 823 session->pending_messages_tail, pm);
835 if (NULL != pm->transmit_cont) 824 if (NULL != pm->transmit_cont)
836 pm->transmit_cont (pm->transmit_cont_cls, 825 pm->transmit_cont (pm->transmit_cont_cls, &session->target,
837 &session->target, GNUNET_SYSERR); 826 GNUNET_SYSERR);
838 GNUNET_free (pm); 827 GNUNET_free (pm);
839 } 828 }
840 GNUNET_break (session->client != NULL); 829 GNUNET_break (session->client != NULL);
@@ -850,8 +839,8 @@ disconnect_session (struct Session *session)
850 session->client = NULL; 839 session->client = NULL;
851 } 840 }
852 GNUNET_STATISTICS_update (session->plugin->env->stats, 841 GNUNET_STATISTICS_update (session->plugin->env->stats,
853 gettext_noop ("# TCP sessions active"), 842 gettext_noop ("# TCP sessions active"), -1,
854 -1, GNUNET_NO); 843 GNUNET_NO);
855 GNUNET_free_non_null (session->connect_addr); 844 GNUNET_free_non_null (session->connect_addr);
856 GNUNET_assert (NULL == session->transmit_handle); 845 GNUNET_assert (NULL == session->transmit_handle);
857 GNUNET_free (session); 846 GNUNET_free (session);
@@ -928,16 +917,10 @@ select_better_session (struct Session *s1, struct Session *s2)
928 * and does NOT mean that the message was not transmitted (DV and NAT) 917 * and does NOT mean that the message was not transmitted (DV and NAT)
929 */ 918 */
930static ssize_t 919static ssize_t
931tcp_plugin_send (void *cls, 920tcp_plugin_send (void *cls, const struct GNUNET_PeerIdentity *target,
932 const struct GNUNET_PeerIdentity *target, 921 const char *msg, size_t msgbuf_size, uint32_t priority,
933 const char *msg, 922 struct GNUNET_TIME_Relative timeout, struct Session *session,
934 size_t msgbuf_size, 923 const void *addr, size_t addrlen, int force_address,
935 uint32_t priority,
936 struct GNUNET_TIME_Relative timeout,
937 struct Session *session,
938 const void *addr,
939 size_t addrlen,
940 int force_address,
941 GNUNET_TRANSPORT_TransmitContinuation cont, void *cont_cls) 924 GNUNET_TRANSPORT_TransmitContinuation cont, void *cont_cls)
942{ 925{
943 struct Plugin *plugin = cls; 926 struct Plugin *plugin = cls;
@@ -969,8 +952,9 @@ tcp_plugin_send (void *cls,
969 { 952 {
970 next = session->next; 953 next = session->next;
971 GNUNET_assert (session->client != NULL); 954 GNUNET_assert (session->client != NULL);
972 if (0 != memcmp (target, 955 if (0 !=
973 &session->target, sizeof (struct GNUNET_PeerIdentity))) 956 memcmp (target, &session->target,
957 sizeof (struct GNUNET_PeerIdentity)))
974 continue; 958 continue;
975 if (((GNUNET_SYSERR == force_address) && 959 if (((GNUNET_SYSERR == force_address) &&
976 (session->expecting_welcome == GNUNET_NO)) || 960 (session->expecting_welcome == GNUNET_NO)) ||
@@ -989,8 +973,8 @@ tcp_plugin_send (void *cls,
989 } 973 }
990 if ((addrlen != session->connect_alen) && (session->is_nat == GNUNET_NO)) 974 if ((addrlen != session->connect_alen) && (session->is_nat == GNUNET_NO))
991 continue; 975 continue;
992 if ((0 != memcmp (session->connect_addr, 976 if ((0 != memcmp (session->connect_addr, addr, addrlen)) &&
993 addr, addrlen)) && (session->is_nat == GNUNET_NO)) 977 (session->is_nat == GNUNET_NO))
994 continue; 978 continue;
995 cand_session = select_better_session (cand_session, session); 979 cand_session = select_better_session (cand_session, session);
996 } 980 }
@@ -999,8 +983,7 @@ tcp_plugin_send (void *cls,
999 if ((session == NULL) && (addr == NULL)) 983 if ((session == NULL) && (addr == NULL))
1000 { 984 {
1001#if DEBUG_TCP 985#if DEBUG_TCP
1002 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, 986 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "tcp",
1003 "tcp",
1004 "Asked to transmit to `%4s' without address and I have no existing connection (failing).\n", 987 "Asked to transmit to `%4s' without address and I have no existing connection (failing).\n",
1005 GNUNET_i2s (target)); 988 GNUNET_i2s (target));
1006#endif 989#endif
@@ -1046,8 +1029,8 @@ tcp_plugin_send (void *cls,
1046 } 1029 }
1047 else 1030 else
1048 { 1031 {
1049 GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, 1032 GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, "tcp",
1050 "tcp", _("Address of unexpected length: %u\n"), addrlen); 1033 _("Address of unexpected length: %u\n"), addrlen);
1051 GNUNET_break (0); 1034 GNUNET_break (0);
1052 return -1; 1035 return -1;
1053 } 1036 }
@@ -1057,15 +1040,13 @@ tcp_plugin_send (void *cls,
1057 if (0 == plugin->max_connections) 1040 if (0 == plugin->max_connections)
1058 return -1; /* saturated */ 1041 return -1; /* saturated */
1059 1042
1060 if ((is_natd == GNUNET_YES) && 1043 if ((is_natd == GNUNET_YES) && (NULL != plugin->nat) &&
1061 (NULL != plugin->nat) &&
1062 (GNUNET_NO == 1044 (GNUNET_NO ==
1063 GNUNET_CONTAINER_multihashmap_contains (plugin->nat_wait_conns, 1045 GNUNET_CONTAINER_multihashmap_contains (plugin->nat_wait_conns,
1064 &target->hashPubKey))) 1046 &target->hashPubKey)))
1065 { 1047 {
1066#if DEBUG_TCP_NAT 1048#if DEBUG_TCP_NAT
1067 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, 1049 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "tcp",
1068 "tcp",
1069 _("Found valid IPv4 NAT address (creating session)!\n")); 1050 _("Found valid IPv4 NAT address (creating session)!\n"));
1070#endif 1051#endif
1071 session = create_session (plugin, target, NULL, GNUNET_YES); 1052 session = create_session (plugin, target, NULL, GNUNET_YES);
@@ -1088,14 +1069,12 @@ tcp_plugin_send (void *cls,
1088 session->pending_messages_tail, 1069 session->pending_messages_tail,
1089 session->pending_messages_tail, pm); 1070 session->pending_messages_tail, pm);
1090 1071
1091 GNUNET_assert (GNUNET_CONTAINER_multihashmap_put (plugin->nat_wait_conns, 1072 GNUNET_assert (GNUNET_CONTAINER_multihashmap_put
1092 &target->hashPubKey, 1073 (plugin->nat_wait_conns, &target->hashPubKey, session,
1093 session, 1074 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY) ==
1094 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY) 1075 GNUNET_OK);
1095 == GNUNET_OK);
1096#if DEBUG_TCP_NAT 1076#if DEBUG_TCP_NAT
1097 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, 1077 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "tcp",
1098 "tcp",
1099 "Created NAT WAIT connection to `%4s' at `%s'\n", 1078 "Created NAT WAIT connection to `%4s' at `%s'\n",
1100 GNUNET_i2s (target), GNUNET_a2s (sb, sbs)); 1079 GNUNET_i2s (target), GNUNET_a2s (sb, sbs));
1101#endif 1080#endif
@@ -1114,8 +1093,7 @@ tcp_plugin_send (void *cls,
1114 if (sa == NULL) 1093 if (sa == NULL)
1115 { 1094 {
1116#if DEBUG_TCP 1095#if DEBUG_TCP
1117 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, 1096 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "tcp",
1118 "tcp",
1119 "Failed to create connection to `%4s' at `%s'\n", 1097 "Failed to create connection to `%4s' at `%s'\n",
1120 GNUNET_i2s (target), GNUNET_a2s (sb, sbs)); 1098 GNUNET_i2s (target), GNUNET_a2s (sb, sbs));
1121#endif 1099#endif
@@ -1128,15 +1106,14 @@ tcp_plugin_send (void *cls,
1128 GNUNET_assert (0 != plugin->max_connections); 1106 GNUNET_assert (0 != plugin->max_connections);
1129 plugin->max_connections--; 1107 plugin->max_connections--;
1130#if DEBUG_TCP_NAT 1108#if DEBUG_TCP_NAT
1131 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, 1109 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "tcp",
1132 "tcp",
1133 "Asked to transmit to `%4s', creating fresh session using address `%s'.\n", 1110 "Asked to transmit to `%4s', creating fresh session using address `%s'.\n",
1134 GNUNET_i2s (target), GNUNET_a2s (sb, sbs)); 1111 GNUNET_i2s (target), GNUNET_a2s (sb, sbs));
1135#endif 1112#endif
1136 session = create_session (plugin, 1113 session =
1137 target, 1114 create_session (plugin, target,
1138 GNUNET_SERVER_connect_socket (plugin->server, 1115 GNUNET_SERVER_connect_socket (plugin->server, sa),
1139 sa), GNUNET_NO); 1116 GNUNET_NO);
1140 session->connect_addr = GNUNET_malloc (addrlen); 1117 session->connect_addr = GNUNET_malloc (addrlen);
1141 memcpy (session->connect_addr, addr, addrlen); 1118 memcpy (session->connect_addr, addr, addrlen);
1142 session->connect_alen = addrlen; 1119 session->connect_alen = addrlen;
@@ -1177,8 +1154,7 @@ tcp_plugin_send (void *cls,
1177 session->pending_messages_tail, 1154 session->pending_messages_tail,
1178 session->pending_messages_tail, pm); 1155 session->pending_messages_tail, pm);
1179#if DEBUG_TCP 1156#if DEBUG_TCP
1180 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, 1157 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "tcp",
1181 "tcp",
1182 "Asked to transmit %u bytes to `%s', added message to list.\n", 1158 "Asked to transmit %u bytes to `%s', added message to list.\n",
1183 msgbuf_size, GNUNET_i2s (target)); 1159 msgbuf_size, GNUNET_i2s (target));
1184#endif 1160#endif
@@ -1212,16 +1188,15 @@ tcp_plugin_disconnect (void *cls, const struct GNUNET_PeerIdentity *target)
1212 struct PendingMessage *pm; 1188 struct PendingMessage *pm;
1213 1189
1214#if DEBUG_TCP 1190#if DEBUG_TCP
1215 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, 1191 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "tcp",
1216 "tcp",
1217 "Asked to cancel session with `%4s'\n", GNUNET_i2s (target)); 1192 "Asked to cancel session with `%4s'\n", GNUNET_i2s (target));
1218#endif 1193#endif
1219 next = plugin->sessions; 1194 next = plugin->sessions;
1220 while (NULL != (session = next)) 1195 while (NULL != (session = next))
1221 { 1196 {
1222 next = session->next; 1197 next = session->next;
1223 if (0 != memcmp (target, 1198 if (0 !=
1224 &session->target, sizeof (struct GNUNET_PeerIdentity))) 1199 memcmp (target, &session->target, sizeof (struct GNUNET_PeerIdentity)))
1225 continue; 1200 continue;
1226 pm = session->pending_messages_head; 1201 pm = session->pending_messages_head;
1227 while (pm != NULL) 1202 while (pm != NULL)
@@ -1300,10 +1275,8 @@ append_port (void *cls, const char *hostname)
1300 * @param asc_cls closure for asc 1275 * @param asc_cls closure for asc
1301 */ 1276 */
1302static void 1277static void
1303tcp_plugin_address_pretty_printer (void *cls, 1278tcp_plugin_address_pretty_printer (void *cls, const char *type,
1304 const char *type, 1279 const void *addr, size_t addrlen,
1305 const void *addr,
1306 size_t addrlen,
1307 int numeric, 1280 int numeric,
1308 struct GNUNET_TIME_Relative timeout, 1281 struct GNUNET_TIME_Relative timeout,
1309 GNUNET_TRANSPORT_AddressStringCallback asc, 1282 GNUNET_TRANSPORT_AddressStringCallback asc,
@@ -1408,8 +1381,8 @@ tcp_plugin_check_address (void *cls, const void *addr, size_t addrlen)
1408 if (GNUNET_OK != check_port (plugin, ntohs (v4->t4_port))) 1381 if (GNUNET_OK != check_port (plugin, ntohs (v4->t4_port)))
1409 return GNUNET_SYSERR; 1382 return GNUNET_SYSERR;
1410 if (GNUNET_OK != 1383 if (GNUNET_OK !=
1411 GNUNET_NAT_test_address (plugin->nat, 1384 GNUNET_NAT_test_address (plugin->nat, &v4->ipv4_addr,
1412 &v4->ipv4_addr, sizeof (struct in_addr))) 1385 sizeof (struct in_addr)))
1413 return GNUNET_SYSERR; 1386 return GNUNET_SYSERR;
1414 } 1387 }
1415 else 1388 else
@@ -1423,8 +1396,8 @@ tcp_plugin_check_address (void *cls, const void *addr, size_t addrlen)
1423 if (GNUNET_OK != check_port (plugin, ntohs (v6->t6_port))) 1396 if (GNUNET_OK != check_port (plugin, ntohs (v6->t6_port)))
1424 return GNUNET_SYSERR; 1397 return GNUNET_SYSERR;
1425 if (GNUNET_OK != 1398 if (GNUNET_OK !=
1426 GNUNET_NAT_test_address (plugin->nat, 1399 GNUNET_NAT_test_address (plugin->nat, &v6->ipv6_addr,
1427 &v6->ipv6_addr, sizeof (struct in6_addr))) 1400 sizeof (struct in6_addr)))
1428 return GNUNET_SYSERR; 1401 return GNUNET_SYSERR;
1429 } 1402 }
1430 return GNUNET_OK; 1403 return GNUNET_OK;
@@ -1441,8 +1414,7 @@ tcp_plugin_check_address (void *cls, const void *addr, size_t addrlen)
1441 * @param message the actual message 1414 * @param message the actual message
1442 */ 1415 */
1443static void 1416static void
1444handle_tcp_nat_probe (void *cls, 1417handle_tcp_nat_probe (void *cls, struct GNUNET_SERVER_Client *client,
1445 struct GNUNET_SERVER_Client *client,
1446 const struct GNUNET_MessageHeader *message) 1418 const struct GNUNET_MessageHeader *message)
1447{ 1419{
1448 struct Plugin *plugin = cls; 1420 struct Plugin *plugin = cls;
@@ -1472,34 +1444,36 @@ handle_tcp_nat_probe (void *cls,
1472 } 1444 }
1473 1445
1474 tcp_nat_probe = (const struct TCP_NAT_ProbeMessage *) message; 1446 tcp_nat_probe = (const struct TCP_NAT_ProbeMessage *) message;
1475 if (0 == memcmp (&tcp_nat_probe->clientIdentity, 1447 if (0 ==
1476 plugin->env->my_identity, 1448 memcmp (&tcp_nat_probe->clientIdentity, plugin->env->my_identity,
1477 sizeof (struct GNUNET_PeerIdentity))) 1449 sizeof (struct GNUNET_PeerIdentity)))
1478 { 1450 {
1479 /* refuse connections from ourselves */ 1451 /* refuse connections from ourselves */
1480 GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); 1452 GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
1481 return; 1453 return;
1482 } 1454 }
1483 1455
1484 session = GNUNET_CONTAINER_multihashmap_get (plugin->nat_wait_conns, 1456 session =
1485 &tcp_nat_probe-> 1457 GNUNET_CONTAINER_multihashmap_get (plugin->nat_wait_conns,
1486 clientIdentity.hashPubKey); 1458 &tcp_nat_probe->clientIdentity.
1459 hashPubKey);
1487 if (session == NULL) 1460 if (session == NULL)
1488 { 1461 {
1489#if DEBUG_TCP_NAT 1462#if DEBUG_TCP_NAT
1490 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, 1463 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "tcp",
1491 "tcp", "Did NOT find session for NAT probe!\n"); 1464 "Did NOT find session for NAT probe!\n");
1492#endif 1465#endif
1493 GNUNET_SERVER_receive_done (client, GNUNET_OK); 1466 GNUNET_SERVER_receive_done (client, GNUNET_OK);
1494 return; 1467 return;
1495 } 1468 }
1496#if DEBUG_TCP_NAT 1469#if DEBUG_TCP_NAT
1497 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, 1470 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "tcp",
1498 "tcp", "Found session for NAT probe!\n"); 1471 "Found session for NAT probe!\n");
1499#endif 1472#endif
1500 GNUNET_assert (GNUNET_CONTAINER_multihashmap_remove (plugin->nat_wait_conns, 1473 GNUNET_assert (GNUNET_CONTAINER_multihashmap_remove
1501 &tcp_nat_probe->clientIdentity.hashPubKey, 1474 (plugin->nat_wait_conns,
1502 session) == GNUNET_YES); 1475 &tcp_nat_probe->clientIdentity.hashPubKey,
1476 session) == GNUNET_YES);
1503 if (GNUNET_OK != GNUNET_SERVER_client_get_address (client, &vaddr, &alen)) 1477 if (GNUNET_OK != GNUNET_SERVER_client_get_address (client, &vaddr, &alen))
1504 { 1478 {
1505 GNUNET_break (0); 1479 GNUNET_break (0);
@@ -1514,8 +1488,7 @@ handle_tcp_nat_probe (void *cls,
1514 session->inbound = GNUNET_NO; 1488 session->inbound = GNUNET_NO;
1515 1489
1516#if DEBUG_TCP_NAT 1490#if DEBUG_TCP_NAT
1517 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, 1491 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "tcp",
1518 "tcp",
1519 "Found address `%s' for incoming connection\n", 1492 "Found address `%s' for incoming connection\n",
1520 GNUNET_a2s (vaddr, alen)); 1493 GNUNET_a2s (vaddr, alen));
1521#endif 1494#endif
@@ -1540,8 +1513,8 @@ handle_tcp_nat_probe (void *cls,
1540 default: 1513 default:
1541 GNUNET_break_op (0); 1514 GNUNET_break_op (0);
1542#if DEBUG_TCP_NAT 1515#if DEBUG_TCP_NAT
1543 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, 1516 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "tcp",
1544 "tcp", "Bad address for incoming connection!\n"); 1517 "Bad address for incoming connection!\n");
1545#endif 1518#endif
1546 GNUNET_free (vaddr); 1519 GNUNET_free (vaddr);
1547 GNUNET_SERVER_client_drop (client); 1520 GNUNET_SERVER_client_drop (client);
@@ -1554,8 +1527,8 @@ handle_tcp_nat_probe (void *cls,
1554 session->next = plugin->sessions; 1527 session->next = plugin->sessions;
1555 plugin->sessions = session; 1528 plugin->sessions = session;
1556 GNUNET_STATISTICS_update (plugin->env->stats, 1529 GNUNET_STATISTICS_update (plugin->env->stats,
1557 gettext_noop ("# TCP sessions active"), 1530 gettext_noop ("# TCP sessions active"), 1,
1558 1, GNUNET_NO); 1531 GNUNET_NO);
1559 process_pending_messages (session); 1532 process_pending_messages (session);
1560 GNUNET_SERVER_receive_done (client, GNUNET_OK); 1533 GNUNET_SERVER_receive_done (client, GNUNET_OK);
1561} 1534}
@@ -1570,8 +1543,7 @@ handle_tcp_nat_probe (void *cls,
1570 * @param message the actual message 1543 * @param message the actual message
1571 */ 1544 */
1572static void 1545static void
1573handle_tcp_welcome (void *cls, 1546handle_tcp_welcome (void *cls, struct GNUNET_SERVER_Client *client,
1574 struct GNUNET_SERVER_Client *client,
1575 const struct GNUNET_MessageHeader *message) 1547 const struct GNUNET_MessageHeader *message)
1576{ 1548{
1577 struct Plugin *plugin = cls; 1549 struct Plugin *plugin = cls;
@@ -1584,30 +1556,28 @@ handle_tcp_welcome (void *cls,
1584 const struct sockaddr_in *s4; 1556 const struct sockaddr_in *s4;
1585 const struct sockaddr_in6 *s6; 1557 const struct sockaddr_in6 *s6;
1586 1558
1587 if (0 == memcmp (&wm->clientIdentity, 1559 if (0 ==
1588 plugin->env->my_identity, 1560 memcmp (&wm->clientIdentity, plugin->env->my_identity,
1589 sizeof (struct GNUNET_PeerIdentity))) 1561 sizeof (struct GNUNET_PeerIdentity)))
1590 { 1562 {
1591 /* refuse connections from ourselves */ 1563 /* refuse connections from ourselves */
1592 GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); 1564 GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
1593 return; 1565 return;
1594 } 1566 }
1595#if DEBUG_TCP 1567#if DEBUG_TCP
1596 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, 1568 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "tcp",
1597 "tcp", 1569 "Received %s message from `%4s'.\n", "WELCOME",
1598 "Received %s message from `%4s'.\n", 1570 GNUNET_i2s (&wm->clientIdentity));
1599 "WELCOME", GNUNET_i2s (&wm->clientIdentity));
1600#endif 1571#endif
1601 GNUNET_STATISTICS_update (plugin->env->stats, 1572 GNUNET_STATISTICS_update (plugin->env->stats,
1602 gettext_noop ("# TCP WELCOME messages received"), 1573 gettext_noop ("# TCP WELCOME messages received"), 1,
1603 1, GNUNET_NO); 1574 GNUNET_NO);
1604 session = find_session_by_client (plugin, client); 1575 session = find_session_by_client (plugin, client);
1605 1576
1606 if (session == NULL) 1577 if (session == NULL)
1607 { 1578 {
1608#if DEBUG_TCP_NAT 1579#if DEBUG_TCP_NAT
1609 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, 1580 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "tcp",
1610 "tcp",
1611 "Received %s message from a `%4s', creating new session\n", 1581 "Received %s message from a `%4s', creating new session\n",
1612 "WELCOME", GNUNET_i2s (&wm->clientIdentity)); 1582 "WELCOME", GNUNET_i2s (&wm->clientIdentity));
1613#endif 1583#endif
@@ -1617,8 +1587,7 @@ handle_tcp_welcome (void *cls,
1617 if (GNUNET_OK == GNUNET_SERVER_client_get_address (client, &vaddr, &alen)) 1587 if (GNUNET_OK == GNUNET_SERVER_client_get_address (client, &vaddr, &alen))
1618 { 1588 {
1619#if DEBUG_TCP_NAT 1589#if DEBUG_TCP_NAT
1620 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, 1590 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "tcp",
1621 "tcp",
1622 "Found address `%s' for incoming connection\n", 1591 "Found address `%s' for incoming connection\n",
1623 GNUNET_a2s (vaddr, alen)); 1592 GNUNET_a2s (vaddr, alen));
1624#endif 1593#endif
@@ -1646,8 +1615,7 @@ handle_tcp_welcome (void *cls,
1646 else 1615 else
1647 { 1616 {
1648#if DEBUG_TCP 1617#if DEBUG_TCP
1649 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, 1618 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "tcp",
1650 "tcp",
1651 "Did not obtain TCP socket address for incoming connection\n"); 1619 "Did not obtain TCP socket address for incoming connection\n");
1652#endif 1620#endif
1653 } 1621 }
@@ -1658,8 +1626,7 @@ handle_tcp_welcome (void *cls,
1658#if DEBUG_TCP_NAT 1626#if DEBUG_TCP_NAT
1659 if (GNUNET_OK == GNUNET_SERVER_client_get_address (client, &vaddr, &alen)) 1627 if (GNUNET_OK == GNUNET_SERVER_client_get_address (client, &vaddr, &alen))
1660 { 1628 {
1661 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, 1629 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "tcp",
1662 "tcp",
1663 "Found address `%s' (already have session)\n", 1630 "Found address `%s' (already have session)\n",
1664 GNUNET_a2s (vaddr, alen)); 1631 GNUNET_a2s (vaddr, alen));
1665 GNUNET_free (vaddr); 1632 GNUNET_free (vaddr);
@@ -1695,9 +1662,10 @@ delayed_done (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
1695 struct GNUNET_TIME_Relative delay; 1662 struct GNUNET_TIME_Relative delay;
1696 1663
1697 session->receive_delay_task = GNUNET_SCHEDULER_NO_TASK; 1664 session->receive_delay_task = GNUNET_SCHEDULER_NO_TASK;
1698 delay = session->plugin->env->receive (session->plugin->env->cls, 1665 delay =
1699 &session->target, 1666 session->plugin->env->receive (session->plugin->env->cls,
1700 NULL, NULL, 0, session, NULL, 0); 1667 &session->target, NULL, NULL, 0, session,
1668 NULL, 0);
1701 if (delay.rel_value == 0) 1669 if (delay.rel_value == 0)
1702 GNUNET_SERVER_receive_done (session->client, GNUNET_OK); 1670 GNUNET_SERVER_receive_done (session->client, GNUNET_OK);
1703 else 1671 else
@@ -1715,8 +1683,7 @@ delayed_done (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
1715 * @param message the actual message 1683 * @param message the actual message
1716 */ 1684 */
1717static void 1685static void
1718handle_tcp_data (void *cls, 1686handle_tcp_data (void *cls, struct GNUNET_SERVER_Client *client,
1719 struct GNUNET_SERVER_Client *client,
1720 const struct GNUNET_MessageHeader *message) 1687 const struct GNUNET_MessageHeader *message)
1721{ 1688{
1722 struct Plugin *plugin = cls; 1689 struct Plugin *plugin = cls;
@@ -1740,8 +1707,7 @@ handle_tcp_data (void *cls,
1740 } 1707 }
1741 session->last_activity = GNUNET_TIME_absolute_get (); 1708 session->last_activity = GNUNET_TIME_absolute_get ();
1742#if DEBUG_TCP > 1 1709#if DEBUG_TCP > 1
1743 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, 1710 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "tcp",
1744 "tcp",
1745 "Passing %u bytes of type %u from `%4s' to transport service.\n", 1711 "Passing %u bytes of type %u from `%4s' to transport service.\n",
1746 (unsigned int) ntohs (message->size), 1712 (unsigned int) ntohs (message->size),
1747 (unsigned int) ntohs (message->type), 1713 (unsigned int) ntohs (message->type),
@@ -1756,14 +1722,14 @@ handle_tcp_data (void *cls,
1756 distance[0].value = htonl (1); 1722 distance[0].value = htonl (1);
1757 distance[1].type = htonl (GNUNET_TRANSPORT_ATS_ARRAY_TERMINATOR); 1723 distance[1].type = htonl (GNUNET_TRANSPORT_ATS_ARRAY_TERMINATOR);
1758 distance[1].value = htonl (0); 1724 distance[1].value = htonl (0);
1759 delay = plugin->env->receive (plugin->env->cls, &session->target, message, 1725 delay =
1760 (const struct GNUNET_TRANSPORT_ATS_Information 1726 plugin->env->receive (plugin->env->cls, &session->target, message,
1761 *) &distance, 2, session, 1727 (const struct GNUNET_TRANSPORT_ATS_Information *)
1762 (GNUNET_YES == 1728 &distance, 2, session,
1763 session-> 1729 (GNUNET_YES ==
1764 inbound) ? NULL : session->connect_addr, 1730 session->inbound) ? NULL : session->connect_addr,
1765 (GNUNET_YES == 1731 (GNUNET_YES ==
1766 session->inbound) ? 0 : session->connect_alen); 1732 session->inbound) ? 0 : session->connect_alen);
1767 if (delay.rel_value == 0) 1733 if (delay.rel_value == 0)
1768 { 1734 {
1769 GNUNET_SERVER_receive_done (client, GNUNET_OK); 1735 GNUNET_SERVER_receive_done (client, GNUNET_OK);
@@ -1771,8 +1737,7 @@ handle_tcp_data (void *cls,
1771 else 1737 else
1772 { 1738 {
1773#if DEBUG_TCP 1739#if DEBUG_TCP
1774 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, 1740 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "tcp",
1775 "tcp",
1776 "Throttling receiving from `%s' for %llu ms\n", 1741 "Throttling receiving from `%s' for %llu ms\n",
1777 GNUNET_i2s (&session->target), 1742 GNUNET_i2s (&session->target),
1778 (unsigned long long) delay.rel_value); 1743 (unsigned long long) delay.rel_value);
@@ -1804,14 +1769,14 @@ disconnect_notify (void *cls, struct GNUNET_SERVER_Client *client)
1804 if (session == NULL) 1769 if (session == NULL)
1805 return; /* unknown, nothing to do */ 1770 return; /* unknown, nothing to do */
1806#if DEBUG_TCP 1771#if DEBUG_TCP
1807 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, 1772 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "tcp",
1808 "tcp",
1809 "Destroying session of `%4s' with %s due to network-level disconnect.\n", 1773 "Destroying session of `%4s' with %s due to network-level disconnect.\n",
1810 GNUNET_i2s (&session->target), 1774 GNUNET_i2s (&session->target),
1811 (session->connect_addr != NULL) ? 1775 (session->connect_addr !=
1812 tcp_address_to_string (session->plugin, 1776 NULL) ? tcp_address_to_string (session->plugin,
1813 session->connect_addr, 1777 session->connect_addr,
1814 session->connect_alen) : "*"); 1778 session->
1779 connect_alen) : "*");
1815#endif 1780#endif
1816 GNUNET_STATISTICS_update (session->plugin->env->stats, 1781 GNUNET_STATISTICS_update (session->plugin->env->stats,
1817 gettext_noop 1782 gettext_noop
@@ -1837,8 +1802,8 @@ notify_send_probe (void *cls, size_t size, void *buf)
1837 size_t ret; 1802 size_t ret;
1838 1803
1839 tcp_probe_ctx->transmit_handle = NULL; 1804 tcp_probe_ctx->transmit_handle = NULL;
1840 GNUNET_CONTAINER_DLL_remove (plugin->probe_head, 1805 GNUNET_CONTAINER_DLL_remove (plugin->probe_head, plugin->probe_tail,
1841 plugin->probe_tail, tcp_probe_ctx); 1806 tcp_probe_ctx);
1842 if (buf == NULL) 1807 if (buf == NULL)
1843 { 1808 {
1844 GNUNET_CONNECTION_destroy (tcp_probe_ctx->sock, GNUNET_NO); 1809 GNUNET_CONNECTION_destroy (tcp_probe_ctx->sock, GNUNET_NO);
@@ -1865,8 +1830,8 @@ notify_send_probe (void *cls, size_t size, void *buf)
1865 * @param addrlen number of bytes in addr 1830 * @param addrlen number of bytes in addr
1866 */ 1831 */
1867static void 1832static void
1868try_connection_reversal (void *cls, 1833try_connection_reversal (void *cls, const struct sockaddr *addr,
1869 const struct sockaddr *addr, socklen_t addrlen) 1834 socklen_t addrlen)
1870{ 1835{
1871 struct Plugin *plugin = cls; 1836 struct Plugin *plugin = cls;
1872 struct GNUNET_CONNECTION_Handle *sock; 1837 struct GNUNET_CONNECTION_Handle *sock;
@@ -1886,23 +1851,23 @@ try_connection_reversal (void *cls,
1886 /* FIXME: do we need to track these probe context objects so that 1851 /* FIXME: do we need to track these probe context objects so that
1887 * we can clean them up on plugin unload? */ 1852 * we can clean them up on plugin unload? */
1888 tcp_probe_ctx = GNUNET_malloc (sizeof (struct TCPProbeContext)); 1853 tcp_probe_ctx = GNUNET_malloc (sizeof (struct TCPProbeContext));
1889 tcp_probe_ctx->message.header.size 1854 tcp_probe_ctx->message.header.size =
1890 = htons (sizeof (struct TCP_NAT_ProbeMessage)); 1855 htons (sizeof (struct TCP_NAT_ProbeMessage));
1891 tcp_probe_ctx->message.header.type 1856 tcp_probe_ctx->message.header.type =
1892 = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_TCP_NAT_PROBE); 1857 htons (GNUNET_MESSAGE_TYPE_TRANSPORT_TCP_NAT_PROBE);
1893 memcpy (&tcp_probe_ctx->message.clientIdentity, 1858 memcpy (&tcp_probe_ctx->message.clientIdentity, plugin->env->my_identity,
1894 plugin->env->my_identity, sizeof (struct GNUNET_PeerIdentity)); 1859 sizeof (struct GNUNET_PeerIdentity));
1895 tcp_probe_ctx->plugin = plugin; 1860 tcp_probe_ctx->plugin = plugin;
1896 tcp_probe_ctx->sock = sock; 1861 tcp_probe_ctx->sock = sock;
1897 GNUNET_CONTAINER_DLL_insert (plugin->probe_head, 1862 GNUNET_CONTAINER_DLL_insert (plugin->probe_head, plugin->probe_tail,
1898 plugin->probe_tail, tcp_probe_ctx); 1863 tcp_probe_ctx);
1899 tcp_probe_ctx->transmit_handle 1864 tcp_probe_ctx->transmit_handle =
1900 = GNUNET_CONNECTION_notify_transmit_ready (sock, 1865 GNUNET_CONNECTION_notify_transmit_ready (sock,
1901 ntohs (tcp_probe_ctx-> 1866 ntohs (tcp_probe_ctx->message.
1902 message.header.size), 1867 header.size),
1903 GNUNET_TIME_UNIT_FOREVER_REL, 1868 GNUNET_TIME_UNIT_FOREVER_REL,
1904 &notify_send_probe, 1869 &notify_send_probe,
1905 tcp_probe_ctx); 1870 tcp_probe_ctx);
1906 1871
1907} 1872}
1908 1873
@@ -1938,27 +1903,21 @@ libgnunet_plugin_transport_tcp_init (void *cls)
1938 socklen_t *addrlens; 1903 socklen_t *addrlens;
1939 1904
1940 if (GNUNET_OK != 1905 if (GNUNET_OK !=
1941 GNUNET_CONFIGURATION_get_value_number (env->cfg, 1906 GNUNET_CONFIGURATION_get_value_number (env->cfg, "transport-tcp",
1942 "transport-tcp",
1943 "MAX_CONNECTIONS", 1907 "MAX_CONNECTIONS",
1944 &max_connections)) 1908 &max_connections))
1945 max_connections = 128; 1909 max_connections = 128;
1946 1910
1947 aport = 0; 1911 aport = 0;
1948 if ((GNUNET_OK != 1912 if ((GNUNET_OK !=
1949 GNUNET_CONFIGURATION_get_value_number (env->cfg, 1913 GNUNET_CONFIGURATION_get_value_number (env->cfg, "transport-tcp", "PORT",
1950 "transport-tcp", 1914 &bport)) || (bport > 65535) ||
1951 "PORT",
1952 &bport)) ||
1953 (bport > 65535) ||
1954 ((GNUNET_OK == 1915 ((GNUNET_OK ==
1955 GNUNET_CONFIGURATION_get_value_number (env->cfg, 1916 GNUNET_CONFIGURATION_get_value_number (env->cfg, "transport-tcp",
1956 "transport-tcp", 1917 "ADVERTISED-PORT", &aport)) &&
1957 "ADVERTISED-PORT", 1918 (aport > 65535)))
1958 &aport)) && (aport > 65535)))
1959 { 1919 {
1960 GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, 1920 GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, "tcp",
1961 "tcp",
1962 _ 1921 _
1963 ("Require valid port number for service `%s' in configuration!\n"), 1922 ("Require valid port number for service `%s' in configuration!\n"),
1964 "transport-tcp"); 1923 "transport-tcp");
@@ -1973,8 +1932,8 @@ libgnunet_plugin_transport_tcp_init (void *cls)
1973 service = GNUNET_SERVICE_start ("transport-tcp", env->cfg); 1932 service = GNUNET_SERVICE_start ("transport-tcp", env->cfg);
1974 if (service == NULL) 1933 if (service == NULL)
1975 { 1934 {
1976 GNUNET_log_from (GNUNET_ERROR_TYPE_WARNING, 1935 GNUNET_log_from (GNUNET_ERROR_TYPE_WARNING, "tcp",
1977 "tcp", _("Failed to start service.\n")); 1936 _("Failed to start service.\n"));
1978 return NULL; 1937 return NULL;
1979 } 1938 }
1980 } 1939 }
@@ -1991,18 +1950,15 @@ libgnunet_plugin_transport_tcp_init (void *cls)
1991 plugin->lsock = NULL; 1950 plugin->lsock = NULL;
1992 if ((service != NULL) && 1951 if ((service != NULL) &&
1993 (GNUNET_SYSERR != 1952 (GNUNET_SYSERR !=
1994 (ret = GNUNET_SERVICE_get_server_addresses ("transport-tcp", 1953 (ret =
1995 env->cfg, 1954 GNUNET_SERVICE_get_server_addresses ("transport-tcp", env->cfg, &addrs,
1996 &addrs, &addrlens)))) 1955 &addrlens))))
1997 { 1956 {
1998 plugin->nat = GNUNET_NAT_register (env->cfg, 1957 plugin->nat =
1999 GNUNET_YES, 1958 GNUNET_NAT_register (env->cfg, GNUNET_YES, aport, (unsigned int) ret,
2000 aport, 1959 (const struct sockaddr **) addrs, addrlens,
2001 (unsigned int) ret, 1960 &tcp_nat_port_map_callback,
2002 (const struct sockaddr **) addrs, 1961 &try_connection_reversal, plugin);
2003 addrlens,
2004 &tcp_nat_port_map_callback,
2005 &try_connection_reversal, plugin);
2006 while (ret > 0) 1962 while (ret > 0)
2007 { 1963 {
2008 ret--; 1964 ret--;
@@ -2014,11 +1970,9 @@ libgnunet_plugin_transport_tcp_init (void *cls)
2014 } 1970 }
2015 else 1971 else
2016 { 1972 {
2017 plugin->nat = GNUNET_NAT_register (env->cfg, 1973 plugin->nat =
2018 GNUNET_YES, 1974 GNUNET_NAT_register (env->cfg, GNUNET_YES, 0, 0, NULL, NULL, NULL,
2019 0, 1975 &try_connection_reversal, plugin);
2020 0, NULL, NULL,
2021 NULL, &try_connection_reversal, plugin);
2022 } 1976 }
2023 api = GNUNET_malloc (sizeof (struct GNUNET_TRANSPORT_PluginFunctions)); 1977 api = GNUNET_malloc (sizeof (struct GNUNET_TRANSPORT_PluginFunctions));
2024 api->cls = plugin; 1978 api->cls = plugin;
@@ -2035,12 +1989,10 @@ libgnunet_plugin_transport_tcp_init (void *cls)
2035 else 1989 else
2036 { 1990 {
2037 if (GNUNET_OK != 1991 if (GNUNET_OK !=
2038 GNUNET_CONFIGURATION_get_value_time (env->cfg, 1992 GNUNET_CONFIGURATION_get_value_time (env->cfg, "transport-tcp",
2039 "transport-tcp",
2040 "TIMEOUT", &idle_timeout)) 1993 "TIMEOUT", &idle_timeout))
2041 { 1994 {
2042 GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, 1995 GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, "tcp",
2043 "tcp",
2044 _("Failed to find option %s in section %s!\n"), 1996 _("Failed to find option %s in section %s!\n"),
2045 "TIMEOUT", "transport-tcp"); 1997 "TIMEOUT", "transport-tcp");
2046 if (plugin->nat != NULL) 1998 if (plugin->nat != NULL)
@@ -2063,16 +2015,14 @@ libgnunet_plugin_transport_tcp_init (void *cls)
2063 GNUNET_SERVER_disconnect_notify (plugin->server, &disconnect_notify, plugin); 2015 GNUNET_SERVER_disconnect_notify (plugin->server, &disconnect_notify, plugin);
2064 plugin->nat_wait_conns = GNUNET_CONTAINER_multihashmap_create (16); 2016 plugin->nat_wait_conns = GNUNET_CONTAINER_multihashmap_create (16);
2065 if (bport != 0) 2017 if (bport != 0)
2066 GNUNET_log_from (GNUNET_ERROR_TYPE_INFO, 2018 GNUNET_log_from (GNUNET_ERROR_TYPE_INFO, "tcp",
2067 "tcp", _("TCP transport listening on port %llu\n"), bport); 2019 _("TCP transport listening on port %llu\n"), bport);
2068 else 2020 else
2069 GNUNET_log_from (GNUNET_ERROR_TYPE_INFO, 2021 GNUNET_log_from (GNUNET_ERROR_TYPE_INFO, "tcp",
2070 "tcp",
2071 _ 2022 _
2072 ("TCP transport not listening on any port (client only)\n")); 2023 ("TCP transport not listening on any port (client only)\n"));
2073 if (aport != bport) 2024 if (aport != bport)
2074 GNUNET_log_from (GNUNET_ERROR_TYPE_INFO, 2025 GNUNET_log_from (GNUNET_ERROR_TYPE_INFO, "tcp",
2075 "tcp",
2076 _ 2026 _
2077 ("TCP transport advertises itself as being on port %llu\n"), 2027 ("TCP transport advertises itself as being on port %llu\n"),
2078 aport); 2028 aport);
@@ -2102,8 +2052,8 @@ libgnunet_plugin_transport_tcp_done (void *cls)
2102 GNUNET_NAT_unregister (plugin->nat); 2052 GNUNET_NAT_unregister (plugin->nat);
2103 while (NULL != (tcp_probe = plugin->probe_head)) 2053 while (NULL != (tcp_probe = plugin->probe_head))
2104 { 2054 {
2105 GNUNET_CONTAINER_DLL_remove (plugin->probe_head, 2055 GNUNET_CONTAINER_DLL_remove (plugin->probe_head, plugin->probe_tail,
2106 plugin->probe_tail, tcp_probe); 2056 tcp_probe);
2107 GNUNET_CONNECTION_destroy (tcp_probe->sock, GNUNET_NO); 2057 GNUNET_CONNECTION_destroy (tcp_probe->sock, GNUNET_NO);
2108 GNUNET_free (tcp_probe); 2058 GNUNET_free (tcp_probe);
2109 } 2059 }
diff --git a/src/transport/plugin_transport_template.c b/src/transport/plugin_transport_template.c
index d83807a36..3ad8014c5 100644
--- a/src/transport/plugin_transport_template.c
+++ b/src/transport/plugin_transport_template.c
@@ -151,18 +151,14 @@ struct Plugin
151 * and does NOT mean that the message was not transmitted (DV) 151 * and does NOT mean that the message was not transmitted (DV)
152 */ 152 */
153static ssize_t 153static ssize_t
154template_plugin_send (void *cls, 154template_plugin_send (void *cls, const struct GNUNET_PeerIdentity *target,
155 const struct GNUNET_PeerIdentity *target, 155 const char *msgbuf, size_t msgbuf_size,
156 const char *msgbuf,
157 size_t msgbuf_size,
158 unsigned int priority, 156 unsigned int priority,
159 struct GNUNET_TIME_Relative timeout, 157 struct GNUNET_TIME_Relative timeout,
160 struct Session *session, 158 struct Session *session, const void *addr, size_t addrlen,
161 const void *addr,
162 size_t addrlen,
163 int force_address, 159 int force_address,
164 GNUNET_TRANSPORT_TransmitContinuation 160 GNUNET_TRANSPORT_TransmitContinuation cont,
165 cont, void *cont_cls) 161 void *cont_cls)
166{ 162{
167 int bytes_sent = 0; 163 int bytes_sent = 0;
168 164
@@ -203,10 +199,8 @@ template_plugin_disconnect (void *cls, const struct GNUNET_PeerIdentity *target)
203 * @param asc_cls closure for asc 199 * @param asc_cls closure for asc
204 */ 200 */
205static void 201static void
206template_plugin_address_pretty_printer (void *cls, 202template_plugin_address_pretty_printer (void *cls, const char *type,
207 const char *type, 203 const void *addr, size_t addrlen,
208 const void *addr,
209 size_t addrlen,
210 int numeric, 204 int numeric,
211 struct GNUNET_TIME_Relative timeout, 205 struct GNUNET_TIME_Relative timeout,
212 GNUNET_TRANSPORT_AddressStringCallback 206 GNUNET_TRANSPORT_AddressStringCallback
diff --git a/src/transport/plugin_transport_udp.c b/src/transport/plugin_transport_udp.c
index df8447a12..f9310fb8f 100644
--- a/src/transport/plugin_transport_udp.c
+++ b/src/transport/plugin_transport_udp.c
@@ -350,8 +350,8 @@ udp_disconnect (void *cls, const struct GNUNET_PeerIdentity *target)
350 * @return the number of bytes written 350 * @return the number of bytes written
351 */ 351 */
352static ssize_t 352static ssize_t
353udp_send (struct Plugin *plugin, 353udp_send (struct Plugin *plugin, const struct sockaddr *sa,
354 const struct sockaddr *sa, const struct GNUNET_MessageHeader *msg) 354 const struct GNUNET_MessageHeader *msg)
355{ 355{
356 ssize_t sent; 356 ssize_t sent;
357 size_t slen; 357 size_t slen;
@@ -362,18 +362,14 @@ udp_send (struct Plugin *plugin,
362 if (NULL == plugin->sockv4) 362 if (NULL == plugin->sockv4)
363 return 0; 363 return 0;
364 sent = 364 sent =
365 GNUNET_NETWORK_socket_sendto (plugin->sockv4, 365 GNUNET_NETWORK_socket_sendto (plugin->sockv4, msg, ntohs (msg->size),
366 msg,
367 ntohs (msg->size),
368 sa, slen = sizeof (struct sockaddr_in)); 366 sa, slen = sizeof (struct sockaddr_in));
369 break; 367 break;
370 case AF_INET6: 368 case AF_INET6:
371 if (NULL == plugin->sockv6) 369 if (NULL == plugin->sockv6)
372 return 0; 370 return 0;
373 sent = 371 sent =
374 GNUNET_NETWORK_socket_sendto (plugin->sockv6, 372 GNUNET_NETWORK_socket_sendto (plugin->sockv6, msg, ntohs (msg->size),
375 msg,
376 ntohs (msg->size),
377 sa, slen = sizeof (struct sockaddr_in6)); 373 sa, slen = sizeof (struct sockaddr_in6));
378 break; 374 break;
379 default: 375 default:
@@ -385,8 +381,7 @@ udp_send (struct Plugin *plugin,
385#if DEBUG_UDP 381#if DEBUG_UDP
386 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 382 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
387 "UDP transmited %u-byte message to %s (%d: %s)\n", 383 "UDP transmited %u-byte message to %s (%d: %s)\n",
388 (unsigned int) ntohs (msg->size), 384 (unsigned int) ntohs (msg->size), GNUNET_a2s (sa, slen),
389 GNUNET_a2s (sa, slen),
390 (int) sent, (sent < 0) ? STRERROR (errno) : "ok"); 385 (int) sent, (sent < 0) ? STRERROR (errno) : "ok");
391#endif 386#endif
392 return sent; 387 return sent;
@@ -437,16 +432,10 @@ send_fragment (void *cls, const struct GNUNET_MessageHeader *msg)
437 * still be transmitted later!) 432 * still be transmitted later!)
438 */ 433 */
439static ssize_t 434static ssize_t
440udp_plugin_send (void *cls, 435udp_plugin_send (void *cls, const struct GNUNET_PeerIdentity *target,
441 const struct GNUNET_PeerIdentity *target, 436 const char *msgbuf, size_t msgbuf_size, unsigned int priority,
442 const char *msgbuf, 437 struct GNUNET_TIME_Relative timeout, struct Session *session,
443 size_t msgbuf_size, 438 const void *addr, size_t addrlen, int force_address,
444 unsigned int priority,
445 struct GNUNET_TIME_Relative timeout,
446 struct Session *session,
447 const void *addr,
448 size_t addrlen,
449 int force_address,
450 GNUNET_TRANSPORT_TransmitContinuation cont, void *cont_cls) 439 GNUNET_TRANSPORT_TransmitContinuation cont, void *cont_cls)
451{ 440{
452 struct Plugin *plugin = cls; 441 struct Plugin *plugin = cls;
@@ -534,13 +523,12 @@ udp_plugin_send (void *cls,
534 &target->hashPubKey, 523 &target->hashPubKey,
535 peer_session, 524 peer_session,
536 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)); 525 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY));
537 peer_session->frag = GNUNET_FRAGMENT_context_create (plugin->env->stats, 526 peer_session->frag =
538 UDP_MTU, 527 GNUNET_FRAGMENT_context_create (plugin->env->stats, UDP_MTU,
539 &plugin->tracker, 528 &plugin->tracker,
540 plugin->last_expected_delay, 529 plugin->last_expected_delay,
541 &udp->header, 530 &udp->header, &send_fragment,
542 &send_fragment, 531 peer_session);
543 peer_session);
544 } 532 }
545 return mlen; 533 return mlen;
546} 534}
@@ -577,8 +565,7 @@ struct SourceInformation
577 * @param hdr the actual message 565 * @param hdr the actual message
578 */ 566 */
579static void 567static void
580process_inbound_tokenized_messages (void *cls, 568process_inbound_tokenized_messages (void *cls, void *client,
581 void *client,
582 const struct GNUNET_MessageHeader *hdr) 569 const struct GNUNET_MessageHeader *hdr)
583{ 570{
584 struct Plugin *plugin = cls; 571 struct Plugin *plugin = cls;
@@ -591,8 +578,8 @@ process_inbound_tokenized_messages (void *cls,
591 distance[1].type = htonl (GNUNET_TRANSPORT_ATS_ARRAY_TERMINATOR); 578 distance[1].type = htonl (GNUNET_TRANSPORT_ATS_ARRAY_TERMINATOR);
592 distance[1].value = htonl (0); 579 distance[1].value = htonl (0);
593 580
594 plugin->env->receive (plugin->env->cls, 581 plugin->env->receive (plugin->env->cls, &si->sender, hdr, distance, 2, NULL,
595 &si->sender, hdr, distance, 2, NULL, si->arg, si->args); 582 si->arg, si->args);
596} 583}
597 584
598 585
@@ -605,8 +592,7 @@ process_inbound_tokenized_messages (void *cls,
605 * @param sender_addr_len number of bytes in sender_addr 592 * @param sender_addr_len number of bytes in sender_addr
606 */ 593 */
607static void 594static void
608process_udp_message (struct Plugin *plugin, 595process_udp_message (struct Plugin *plugin, const struct UDPMessage *msg,
609 const struct UDPMessage *msg,
610 const struct sockaddr *sender_addr, 596 const struct sockaddr *sender_addr,
611 socklen_t sender_addr_len) 597 socklen_t sender_addr_len)
612{ 598{
@@ -650,21 +636,18 @@ process_udp_message (struct Plugin *plugin,
650 return; 636 return;
651 } 637 }
652#if DEBUG_UDP 638#if DEBUG_UDP
653 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, 639 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "udp",
654 "udp",
655 "Received message with %u bytes from peer `%s' at `%s'\n", 640 "Received message with %u bytes from peer `%s' at `%s'\n",
656 (unsigned int) ntohs (msg->header.size), 641 (unsigned int) ntohs (msg->header.size),
657 GNUNET_i2s (&msg->sender), 642 GNUNET_i2s (&msg->sender), GNUNET_a2s (sender_addr,
658 GNUNET_a2s (sender_addr, sender_addr_len)); 643 sender_addr_len));
659#endif 644#endif
660 645
661 /* iterate over all embedded messages */ 646 /* iterate over all embedded messages */
662 si.sender = msg->sender; 647 si.sender = msg->sender;
663 si.arg = arg; 648 si.arg = arg;
664 si.args = args; 649 si.args = args;
665 GNUNET_SERVER_mst_receive (plugin->mst, 650 GNUNET_SERVER_mst_receive (plugin->mst, &si, (const char *) &msg[1],
666 &si,
667 (const char *) &msg[1],
668 ntohs (msg->header.size) - 651 ntohs (msg->header.size) -
669 sizeof (struct UDPMessage), GNUNET_YES, GNUNET_NO); 652 sizeof (struct UDPMessage), GNUNET_YES, GNUNET_NO);
670} 653}
@@ -691,8 +674,7 @@ fragment_msg_proc (void *cls, const struct GNUNET_MessageHeader *msg)
691 GNUNET_break (0); 674 GNUNET_break (0);
692 return; 675 return;
693 } 676 }
694 process_udp_message (rc->plugin, 677 process_udp_message (rc->plugin, (const struct UDPMessage *) msg,
695 (const struct UDPMessage *) msg,
696 rc->src_addr, rc->addr_len); 678 rc->src_addr, rc->addr_len);
697} 679}
698 680
@@ -713,13 +695,11 @@ ack_proc (void *cls, uint32_t id, const struct GNUNET_MessageHeader *msg)
713 struct UDPMessage *udp; 695 struct UDPMessage *udp;
714 696
715#if DEBUG_UDP 697#if DEBUG_UDP
716 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, 698 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "udp", "Sending ACK to `%s'\n",
717 "udp",
718 "Sending ACK to `%s'\n",
719 GNUNET_a2s (rc->src_addr, 699 GNUNET_a2s (rc->src_addr,
720 (rc->src_addr->sa_family == AF_INET) 700 (rc->src_addr->sa_family ==
721 ? sizeof (struct sockaddr_in) 701 AF_INET) ? sizeof (struct sockaddr_in) :
722 : sizeof (struct sockaddr_in6))); 702 sizeof (struct sockaddr_in6)));
723#endif 703#endif
724 udp = (struct UDPMessage *) buf; 704 udp = (struct UDPMessage *) buf;
725 udp->header.size = htons ((uint16_t) msize); 705 udp->header.size = htons ((uint16_t) msize);
@@ -764,8 +744,7 @@ struct FindReceiveContext
764 * GNUNET_NO if not. 744 * GNUNET_NO if not.
765 */ 745 */
766static int 746static int
767find_receive_context (void *cls, 747find_receive_context (void *cls, struct GNUNET_CONTAINER_HeapNode *node,
768 struct GNUNET_CONTAINER_HeapNode *node,
769 void *element, GNUNET_CONTAINER_HeapCostType cost) 748 void *element, GNUNET_CONTAINER_HeapCostType cost)
770{ 749{
771 struct FindReceiveContext *frc = cls; 750 struct FindReceiveContext *frc = cls;
@@ -804,8 +783,9 @@ udp_read (struct Plugin *plugin, struct GNUNET_NETWORK_Handle *rsock)
804 783
805 fromlen = sizeof (addr); 784 fromlen = sizeof (addr);
806 memset (&addr, 0, sizeof (addr)); 785 memset (&addr, 0, sizeof (addr));
807 ret = GNUNET_NETWORK_socket_recvfrom (rsock, buf, sizeof (buf), 786 ret =
808 (struct sockaddr *) &addr, &fromlen); 787 GNUNET_NETWORK_socket_recvfrom (rsock, buf, sizeof (buf),
788 (struct sockaddr *) &addr, &fromlen);
809 if (ret < sizeof (struct GNUNET_MessageHeader)) 789 if (ret < sizeof (struct GNUNET_MessageHeader))
810 { 790 {
811 GNUNET_break_op (0); 791 GNUNET_break_op (0);
@@ -813,8 +793,7 @@ udp_read (struct Plugin *plugin, struct GNUNET_NETWORK_Handle *rsock)
813 } 793 }
814#if DEBUG_UDP 794#if DEBUG_UDP
815 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 795 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
816 "UDP received %u-byte message from `%s'\n", 796 "UDP received %u-byte message from `%s'\n", (unsigned int) ret,
817 (unsigned int) ret,
818 GNUNET_a2s ((const struct sockaddr *) addr, fromlen)); 797 GNUNET_a2s ((const struct sockaddr *) addr, fromlen));
819#endif 798#endif
820 msg = (const struct GNUNET_MessageHeader *) buf; 799 msg = (const struct GNUNET_MessageHeader *) buf;
@@ -831,8 +810,7 @@ udp_read (struct Plugin *plugin, struct GNUNET_NETWORK_Handle *rsock)
831 GNUNET_break_op (0); 810 GNUNET_break_op (0);
832 return; 811 return;
833 } 812 }
834 process_udp_message (plugin, 813 process_udp_message (plugin, (const struct UDPMessage *) msg,
835 (const struct UDPMessage *) msg,
836 (const struct sockaddr *) addr, fromlen); 814 (const struct sockaddr *) addr, fromlen);
837 return; 815 return;
838 case GNUNET_MESSAGE_TYPE_TRANSPORT_UDP_ACK: 816 case GNUNET_MESSAGE_TYPE_TRANSPORT_UDP_ACK:
@@ -857,8 +835,7 @@ udp_read (struct Plugin *plugin, struct GNUNET_NETWORK_Handle *rsock)
857#if DEBUG_UDP 835#if DEBUG_UDP
858 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 836 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
859 "UDP processes %u-byte acknowledgement from `%s' at `%s'\n", 837 "UDP processes %u-byte acknowledgement from `%s' at `%s'\n",
860 (unsigned int) ntohs (msg->size), 838 (unsigned int) ntohs (msg->size), GNUNET_i2s (&udp->sender),
861 GNUNET_i2s (&udp->sender),
862 GNUNET_a2s ((const struct sockaddr *) addr, fromlen)); 839 GNUNET_a2s ((const struct sockaddr *) addr, fromlen));
863#endif 840#endif
864 841
@@ -875,8 +852,8 @@ udp_read (struct Plugin *plugin, struct GNUNET_NETWORK_Handle *rsock)
875 return; 852 return;
876 GNUNET_assert (GNUNET_OK == 853 GNUNET_assert (GNUNET_OK ==
877 GNUNET_CONTAINER_multihashmap_remove (plugin->sessions, 854 GNUNET_CONTAINER_multihashmap_remove (plugin->sessions,
878 &udp-> 855 &udp->sender.
879 sender.hashPubKey, 856 hashPubKey,
880 peer_session)); 857 peer_session));
881 plugin->last_expected_delay = 858 plugin->last_expected_delay =
882 GNUNET_FRAGMENT_context_destroy (peer_session->frag); 859 GNUNET_FRAGMENT_context_destroy (peer_session->frag);
@@ -887,8 +864,8 @@ udp_read (struct Plugin *plugin, struct GNUNET_NETWORK_Handle *rsock)
887 frc.rc = NULL; 864 frc.rc = NULL;
888 frc.addr = (const struct sockaddr *) addr; 865 frc.addr = (const struct sockaddr *) addr;
889 frc.addr_len = fromlen; 866 frc.addr_len = fromlen;
890 GNUNET_CONTAINER_heap_iterate (plugin->defrags, 867 GNUNET_CONTAINER_heap_iterate (plugin->defrags, &find_receive_context,
891 &find_receive_context, &frc); 868 &frc);
892 now = GNUNET_TIME_absolute_get (); 869 now = GNUNET_TIME_absolute_get ();
893 rc = frc.rc; 870 rc = frc.rc;
894 if (rc == NULL) 871 if (rc == NULL)
@@ -899,16 +876,14 @@ udp_read (struct Plugin *plugin, struct GNUNET_NETWORK_Handle *rsock)
899 rc->src_addr = (const struct sockaddr *) &rc[1]; 876 rc->src_addr = (const struct sockaddr *) &rc[1];
900 rc->addr_len = fromlen; 877 rc->addr_len = fromlen;
901 rc->plugin = plugin; 878 rc->plugin = plugin;
902 rc->defrag = GNUNET_DEFRAGMENT_context_create (plugin->env->stats, 879 rc->defrag =
903 UDP_MTU, 880 GNUNET_DEFRAGMENT_context_create (plugin->env->stats, UDP_MTU,
904 UDP_MAX_MESSAGES_IN_DEFRAG, 881 UDP_MAX_MESSAGES_IN_DEFRAG, rc,
905 rc, 882 &fragment_msg_proc, &ack_proc);
906 &fragment_msg_proc, 883 rc->hnode =
907 &ack_proc); 884 GNUNET_CONTAINER_heap_insert (plugin->defrags, rc,
908 rc->hnode = GNUNET_CONTAINER_heap_insert (plugin->defrags, 885 (GNUNET_CONTAINER_HeapCostType) now.
909 rc, 886 abs_value);
910 (GNUNET_CONTAINER_HeapCostType)
911 now.abs_value);
912 } 887 }
913#if DEBUG_UDP 888#if DEBUG_UDP
914 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 889 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
@@ -920,10 +895,9 @@ udp_read (struct Plugin *plugin, struct GNUNET_NETWORK_Handle *rsock)
920 if (GNUNET_OK == GNUNET_DEFRAGMENT_process_fragment (rc->defrag, msg)) 895 if (GNUNET_OK == GNUNET_DEFRAGMENT_process_fragment (rc->defrag, msg))
921 { 896 {
922 /* keep this 'rc' from expiring */ 897 /* keep this 'rc' from expiring */
923 GNUNET_CONTAINER_heap_update_cost (plugin->defrags, 898 GNUNET_CONTAINER_heap_update_cost (plugin->defrags, rc->hnode,
924 rc->hnode, 899 (GNUNET_CONTAINER_HeapCostType) now.
925 (GNUNET_CONTAINER_HeapCostType) 900 abs_value);
926 now.abs_value);
927 } 901 }
928 if (GNUNET_CONTAINER_heap_get_size (plugin->defrags) > 902 if (GNUNET_CONTAINER_heap_get_size (plugin->defrags) >
929 UDP_MAX_SENDER_ADDRESSES_WITH_DEFRAG) 903 UDP_MAX_SENDER_ADDRESSES_WITH_DEFRAG)
@@ -1026,8 +1000,8 @@ udp_plugin_check_address (void *cls, const void *addr, size_t addrlen)
1026 if (GNUNET_OK != check_port (plugin, ntohs (v4->u4_port))) 1000 if (GNUNET_OK != check_port (plugin, ntohs (v4->u4_port)))
1027 return GNUNET_SYSERR; 1001 return GNUNET_SYSERR;
1028 if (GNUNET_OK != 1002 if (GNUNET_OK !=
1029 GNUNET_NAT_test_address (plugin->nat, 1003 GNUNET_NAT_test_address (plugin->nat, &v4->ipv4_addr,
1030 &v4->ipv4_addr, sizeof (struct in_addr))) 1004 sizeof (struct in_addr)))
1031 return GNUNET_SYSERR; 1005 return GNUNET_SYSERR;
1032 } 1006 }
1033 else 1007 else
@@ -1041,8 +1015,8 @@ udp_plugin_check_address (void *cls, const void *addr, size_t addrlen)
1041 if (GNUNET_OK != check_port (plugin, ntohs (v6->u6_port))) 1015 if (GNUNET_OK != check_port (plugin, ntohs (v6->u6_port)))
1042 return GNUNET_SYSERR; 1016 return GNUNET_SYSERR;
1043 if (GNUNET_OK != 1017 if (GNUNET_OK !=
1044 GNUNET_NAT_test_address (plugin->nat, 1018 GNUNET_NAT_test_address (plugin->nat, &v6->ipv6_addr,
1045 &v6->ipv6_addr, sizeof (struct in6_addr))) 1019 sizeof (struct in6_addr)))
1046 return GNUNET_SYSERR; 1020 return GNUNET_SYSERR;
1047 } 1021 }
1048 return GNUNET_OK; 1022 return GNUNET_OK;
@@ -1161,10 +1135,8 @@ append_port (void *cls, const char *hostname)
1161 * @param asc_cls closure for asc 1135 * @param asc_cls closure for asc
1162 */ 1136 */
1163static void 1137static void
1164udp_plugin_address_pretty_printer (void *cls, 1138udp_plugin_address_pretty_printer (void *cls, const char *type,
1165 const char *type, 1139 const void *addr, size_t addrlen,
1166 const void *addr,
1167 size_t addrlen,
1168 int numeric, 1140 int numeric,
1169 struct GNUNET_TIME_Relative timeout, 1141 struct GNUNET_TIME_Relative timeout,
1170 GNUNET_TRANSPORT_AddressStringCallback asc, 1142 GNUNET_TRANSPORT_AddressStringCallback asc,
@@ -1232,8 +1204,7 @@ udp_plugin_address_pretty_printer (void *cls,
1232 * @param addrlen actual lenght of the address 1204 * @param addrlen actual lenght of the address
1233 */ 1205 */
1234static void 1206static void
1235udp_nat_port_map_callback (void *cls, 1207udp_nat_port_map_callback (void *cls, int add_remove,
1236 int add_remove,
1237 const struct sockaddr *addr, socklen_t addrlen) 1208 const struct sockaddr *addr, socklen_t addrlen)
1238{ 1209{
1239 struct Plugin *plugin = cls; 1210 struct Plugin *plugin = cls;
@@ -1254,8 +1225,7 @@ udp_nat_port_map_callback (void *cls,
1254 break; 1225 break;
1255 case AF_INET6: 1226 case AF_INET6:
1256 GNUNET_assert (addrlen == sizeof (struct sockaddr_in6)); 1227 GNUNET_assert (addrlen == sizeof (struct sockaddr_in6));
1257 memcpy (&u6.ipv6_addr, 1228 memcpy (&u6.ipv6_addr, &((struct sockaddr_in6 *) addr)->sin6_addr,
1258 &((struct sockaddr_in6 *) addr)->sin6_addr,
1259 sizeof (struct in6_addr)); 1229 sizeof (struct in6_addr));
1260 u6.u6_port = ((struct sockaddr_in6 *) addr)->sin6_port; 1230 u6.u6_port = ((struct sockaddr_in6 *) addr)->sin6_port;
1261 arg = &u6; 1231 arg = &u6;
@@ -1296,24 +1266,22 @@ libgnunet_plugin_transport_udp_init (void *cls)
1296 unsigned long long udp_max_bps; 1266 unsigned long long udp_max_bps;
1297 1267
1298 if (GNUNET_OK != 1268 if (GNUNET_OK !=
1299 GNUNET_CONFIGURATION_get_value_number (env->cfg, 1269 GNUNET_CONFIGURATION_get_value_number (env->cfg, "transport-udp", "PORT",
1300 "transport-udp", "PORT", &port)) 1270 &port))
1301 port = 2086; 1271 port = 2086;
1302 if (GNUNET_OK != 1272 if (GNUNET_OK !=
1303 GNUNET_CONFIGURATION_get_value_number (env->cfg, 1273 GNUNET_CONFIGURATION_get_value_number (env->cfg, "transport-udp",
1304 "transport-udp",
1305 "MAX_BPS", &udp_max_bps)) 1274 "MAX_BPS", &udp_max_bps))
1306 udp_max_bps = 1024 * 1024 * 50; /* 50 MB/s == infinity for practical purposes */ 1275 udp_max_bps = 1024 * 1024 * 50; /* 50 MB/s == infinity for practical purposes */
1307 if (GNUNET_OK != 1276 if (GNUNET_OK !=
1308 GNUNET_CONFIGURATION_get_value_number (env->cfg, 1277 GNUNET_CONFIGURATION_get_value_number (env->cfg, "transport-udp",
1309 "transport-udp",
1310 "ADVERTISED_PORT", &aport)) 1278 "ADVERTISED_PORT", &aport))
1311 aport = port; 1279 aport = port;
1312 if (port > 65535) 1280 if (port > 65535)
1313 { 1281 {
1314 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 1282 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
1315 _("Given `%s' option is out of range: %llu > %u\n"), 1283 _("Given `%s' option is out of range: %llu > %u\n"), "PORT",
1316 "PORT", port, 65535); 1284 port, 65535);
1317 return NULL; 1285 return NULL;
1318 } 1286 }
1319 memset (&serverAddrv6, 0, sizeof (serverAddrv6)); 1287 memset (&serverAddrv6, 0, sizeof (serverAddrv6));
@@ -1336,10 +1304,9 @@ libgnunet_plugin_transport_udp_init (void *cls)
1336 api->address_to_string = &udp_address_to_string; 1304 api->address_to_string = &udp_address_to_string;
1337 api->check_address = &udp_plugin_check_address; 1305 api->check_address = &udp_plugin_check_address;
1338 1306
1339 if (GNUNET_YES == GNUNET_CONFIGURATION_get_value_string (env->cfg, 1307 if (GNUNET_YES ==
1340 "transport-udp", 1308 GNUNET_CONFIGURATION_get_value_string (env->cfg, "transport-udp",
1341 "BINDTO", 1309 "BINDTO", &plugin->bind4_address))
1342 &plugin->bind4_address))
1343 { 1310 {
1344 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1311 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1345 "Binding udp plugin to specific address: `%s'\n", 1312 "Binding udp plugin to specific address: `%s'\n",
@@ -1353,19 +1320,18 @@ libgnunet_plugin_transport_udp_init (void *cls)
1353 } 1320 }
1354 } 1321 }
1355 1322
1356 if (GNUNET_YES == GNUNET_CONFIGURATION_get_value_string (env->cfg, 1323 if (GNUNET_YES ==
1357 "transport-udp", 1324 GNUNET_CONFIGURATION_get_value_string (env->cfg, "transport-udp",
1358 "BINDTO6", 1325 "BINDTO6", &plugin->bind6_address))
1359 &plugin->bind6_address))
1360 { 1326 {
1361 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1327 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1362 "Binding udp plugin to specific address: `%s'\n", 1328 "Binding udp plugin to specific address: `%s'\n",
1363 plugin->bind6_address); 1329 plugin->bind6_address);
1364 if (1 != inet_pton (AF_INET6, 1330 if (1 !=
1365 plugin->bind6_address, &serverAddrv6.sin6_addr)) 1331 inet_pton (AF_INET6, plugin->bind6_address, &serverAddrv6.sin6_addr))
1366 { 1332 {
1367 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 1333 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("Invalid IPv6 address: `%s'\n"),
1368 _("Invalid IPv6 address: `%s'\n"), plugin->bind6_address); 1334 plugin->bind6_address);
1369 GNUNET_free_non_null (plugin->bind4_address); 1335 GNUNET_free_non_null (plugin->bind4_address);
1370 GNUNET_free (plugin->bind6_address); 1336 GNUNET_free (plugin->bind6_address);
1371 GNUNET_free (plugin); 1337 GNUNET_free (plugin);
@@ -1381,8 +1347,8 @@ libgnunet_plugin_transport_udp_init (void *cls)
1381 * 2); 1347 * 2);
1382 sockets_created = 0; 1348 sockets_created = 0;
1383 if ((GNUNET_YES != 1349 if ((GNUNET_YES !=
1384 GNUNET_CONFIGURATION_get_value_yesno (plugin->env->cfg, 1350 GNUNET_CONFIGURATION_get_value_yesno (plugin->env->cfg, "nat",
1385 "nat", "DISABLEV6"))) 1351 "DISABLEV6")))
1386 { 1352 {
1387 plugin->sockv6 = GNUNET_NETWORK_socket_create (PF_INET6, SOCK_DGRAM, 0); 1353 plugin->sockv6 = GNUNET_NETWORK_socket_create (PF_INET6, SOCK_DGRAM, 0);
1388 if (NULL == plugin->sockv6) 1354 if (NULL == plugin->sockv6)
@@ -1400,12 +1366,12 @@ libgnunet_plugin_transport_udp_init (void *cls)
1400 addrlen = sizeof (serverAddrv6); 1366 addrlen = sizeof (serverAddrv6);
1401 serverAddr = (struct sockaddr *) &serverAddrv6; 1367 serverAddr = (struct sockaddr *) &serverAddrv6;
1402#if DEBUG_UDP 1368#if DEBUG_UDP
1403 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1369 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Binding to IPv6 port %d\n",
1404 "Binding to IPv6 port %d\n", ntohs (serverAddrv6.sin6_port)); 1370 ntohs (serverAddrv6.sin6_port));
1405#endif 1371#endif
1406 tries = 0; 1372 tries = 0;
1407 while (GNUNET_NETWORK_socket_bind (plugin->sockv6, 1373 while (GNUNET_NETWORK_socket_bind (plugin->sockv6, serverAddr, addrlen) !=
1408 serverAddr, addrlen) != GNUNET_OK) 1374 GNUNET_OK)
1409 { 1375 {
1410 serverAddrv6.sin6_port = htons (GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_STRONG, 33537) + 32000); /* Find a good, non-root port */ 1376 serverAddrv6.sin6_port = htons (GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_STRONG, 33537) + 32000); /* Find a good, non-root port */
1411#if DEBUG_UDP 1377#if DEBUG_UDP
@@ -1430,8 +1396,8 @@ libgnunet_plugin_transport_udp_init (void *cls)
1430 } 1396 }
1431 } 1397 }
1432 1398
1433 plugin->mst = GNUNET_SERVER_mst_create (&process_inbound_tokenized_messages, 1399 plugin->mst =
1434 plugin); 1400 GNUNET_SERVER_mst_create (&process_inbound_tokenized_messages, plugin);
1435 plugin->sockv4 = GNUNET_NETWORK_socket_create (PF_INET, SOCK_DGRAM, 0); 1401 plugin->sockv4 = GNUNET_NETWORK_socket_create (PF_INET, SOCK_DGRAM, 0);
1436 if (NULL == plugin->sockv4) 1402 if (NULL == plugin->sockv4)
1437 { 1403 {
@@ -1448,8 +1414,8 @@ libgnunet_plugin_transport_udp_init (void *cls)
1448 addrlen = sizeof (serverAddrv4); 1414 addrlen = sizeof (serverAddrv4);
1449 serverAddr = (struct sockaddr *) &serverAddrv4; 1415 serverAddr = (struct sockaddr *) &serverAddrv4;
1450#if DEBUG_UDP 1416#if DEBUG_UDP
1451 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1417 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Binding to IPv4 port %d\n",
1452 "Binding to IPv4 port %d\n", ntohs (serverAddrv4.sin_port)); 1418 ntohs (serverAddrv4.sin_port));
1453#endif 1419#endif
1454 tries = 0; 1420 tries = 0;
1455 while (GNUNET_NETWORK_socket_bind (plugin->sockv4, serverAddr, addrlen) != 1421 while (GNUNET_NETWORK_socket_bind (plugin->sockv4, serverAddr, addrlen) !=
@@ -1491,12 +1457,10 @@ libgnunet_plugin_transport_udp_init (void *cls)
1491 NULL, &udp_plugin_select, plugin); 1457 NULL, &udp_plugin_select, plugin);
1492 if (sockets_created == 0) 1458 if (sockets_created == 0)
1493 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, _("Failed to open UDP sockets\n")); 1459 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, _("Failed to open UDP sockets\n"));
1494 plugin->nat = GNUNET_NAT_register (env->cfg, 1460 plugin->nat =
1495 GNUNET_NO, 1461 GNUNET_NAT_register (env->cfg, GNUNET_NO, port, sockets_created,
1496 port, 1462 (const struct sockaddr **) addrs, addrlens,
1497 sockets_created, 1463 &udp_nat_port_map_callback, NULL, plugin);
1498 (const struct sockaddr **) addrs, addrlens,
1499 &udp_nat_port_map_callback, NULL, plugin);
1500 return api; 1464 return api;
1501} 1465}
1502 1466
@@ -1534,8 +1498,8 @@ libgnunet_plugin_transport_udp_done (void *cls)
1534 struct ReceiveContext *rc; 1498 struct ReceiveContext *rc;
1535 1499
1536 /* FIXME: clean up heap and hashmap */ 1500 /* FIXME: clean up heap and hashmap */
1537 GNUNET_CONTAINER_multihashmap_iterate (plugin->sessions, 1501 GNUNET_CONTAINER_multihashmap_iterate (plugin->sessions, &destroy_session,
1538 &destroy_session, NULL); 1502 NULL);
1539 GNUNET_CONTAINER_multihashmap_destroy (plugin->sessions); 1503 GNUNET_CONTAINER_multihashmap_destroy (plugin->sessions);
1540 plugin->sessions = NULL; 1504 plugin->sessions = NULL;
1541 while (NULL != (rc = GNUNET_CONTAINER_heap_remove_root (plugin->defrags))) 1505 while (NULL != (rc = GNUNET_CONTAINER_heap_remove_root (plugin->defrags)))
diff --git a/src/transport/plugin_transport_unix.c b/src/transport/plugin_transport_unix.c
index 22dda8e8b..7193e2e8b 100644
--- a/src/transport/plugin_transport_unix.c
+++ b/src/transport/plugin_transport_unix.c
@@ -419,18 +419,16 @@ find_session (struct Plugin *plugin, const struct GNUNET_PeerIdentity *peer)
419} 419}
420 420
421/* Forward Declaration */ 421/* Forward Declaration */
422static ssize_t 422static ssize_t unix_real_send (void *cls,
423unix_real_send (void *cls, 423 struct RetrySendContext *incoming_retry_context,
424 struct RetrySendContext *incoming_retry_context, 424 struct GNUNET_NETWORK_Handle *send_handle,
425 struct GNUNET_NETWORK_Handle *send_handle, 425 const struct GNUNET_PeerIdentity *target,
426 const struct GNUNET_PeerIdentity *target, 426 const char *msgbuf, size_t msgbuf_size,
427 const char *msgbuf, 427 unsigned int priority,
428 size_t msgbuf_size, 428 struct GNUNET_TIME_Relative timeout,
429 unsigned int priority, 429 const void *addr, size_t addrlen,
430 struct GNUNET_TIME_Relative timeout, 430 GNUNET_TRANSPORT_TransmitContinuation cont,
431 const void *addr, 431 void *cont_cls);
432 size_t addrlen,
433 GNUNET_TRANSPORT_TransmitContinuation cont, void *cont_cls);
434 432
435/** 433/**
436 * Retry sending a message. 434 * Retry sending a message.
@@ -451,16 +449,12 @@ retry_send_message (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
451 return; 449 return;
452 } 450 }
453 451
454 unix_real_send (retry_ctx->plugin, 452 unix_real_send (retry_ctx->plugin, retry_ctx, retry_ctx->send_handle,
455 retry_ctx, 453 &retry_ctx->target, retry_ctx->msg, retry_ctx->msg_size,
456 retry_ctx->send_handle,
457 &retry_ctx->target,
458 retry_ctx->msg,
459 retry_ctx->msg_size,
460 retry_ctx->priority, 454 retry_ctx->priority,
461 GNUNET_TIME_absolute_get_remaining (retry_ctx->timeout), 455 GNUNET_TIME_absolute_get_remaining (retry_ctx->timeout),
462 retry_ctx->addr, 456 retry_ctx->addr, retry_ctx->addrlen, retry_ctx->cont,
463 retry_ctx->addrlen, retry_ctx->cont, retry_ctx->cont_cls); 457 retry_ctx->cont_cls);
464 return; 458 return;
465} 459}
466 460
@@ -487,17 +481,13 @@ retry_send_message (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
487 * @return the number of bytes written, -1 on errors 481 * @return the number of bytes written, -1 on errors
488 */ 482 */
489static ssize_t 483static ssize_t
490unix_real_send (void *cls, 484unix_real_send (void *cls, struct RetrySendContext *incoming_retry_context,
491 struct RetrySendContext *incoming_retry_context,
492 struct GNUNET_NETWORK_Handle *send_handle, 485 struct GNUNET_NETWORK_Handle *send_handle,
493 const struct GNUNET_PeerIdentity *target, 486 const struct GNUNET_PeerIdentity *target, const char *msgbuf,
494 const char *msgbuf, 487 size_t msgbuf_size, unsigned int priority,
495 size_t msgbuf_size, 488 struct GNUNET_TIME_Relative timeout, const void *addr,
496 unsigned int priority, 489 size_t addrlen, GNUNET_TRANSPORT_TransmitContinuation cont,
497 struct GNUNET_TIME_Relative timeout, 490 void *cont_cls)
498 const void *addr,
499 size_t addrlen,
500 GNUNET_TRANSPORT_TransmitContinuation cont, void *cont_cls)
501{ 491{
502 struct Plugin *plugin = cls; 492 struct Plugin *plugin = cls;
503 struct UNIXMessage *message; 493 struct UNIXMessage *message;
@@ -635,9 +625,8 @@ unix_real_send (void *cls,
635#if DEBUG_UNIX 625#if DEBUG_UNIX
636 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 626 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
637 "UNIX transmit %u-byte message to %s (%d: %s)\n", 627 "UNIX transmit %u-byte message to %s (%d: %s)\n",
638 (unsigned int) ssize, 628 (unsigned int) ssize, GNUNET_a2s (sb, sbs), (int) sent,
639 GNUNET_a2s (sb, sbs), 629 (sent < 0) ? STRERROR (errno) : "ok");
640 (int) sent, (sent < 0) ? STRERROR (errno) : "ok");
641#endif 630#endif
642 if (cont != NULL) 631 if (cont != NULL)
643 { 632 {
@@ -689,16 +678,10 @@ unix_real_send (void *cls,
689 * still be transmitted later!) 678 * still be transmitted later!)
690 */ 679 */
691static ssize_t 680static ssize_t
692unix_plugin_send (void *cls, 681unix_plugin_send (void *cls, const struct GNUNET_PeerIdentity *target,
693 const struct GNUNET_PeerIdentity *target, 682 const char *msgbuf, size_t msgbuf_size, unsigned int priority,
694 const char *msgbuf, 683 struct GNUNET_TIME_Relative timeout, struct Session *session,
695 size_t msgbuf_size, 684 const void *addr, size_t addrlen, int force_address,
696 unsigned int priority,
697 struct GNUNET_TIME_Relative timeout,
698 struct Session *session,
699 const void *addr,
700 size_t addrlen,
701 int force_address,
702 GNUNET_TRANSPORT_TransmitContinuation cont, void *cont_cls) 685 GNUNET_TRANSPORT_TransmitContinuation cont, void *cont_cls)
703{ 686{
704 struct Plugin *plugin = cls; 687 struct Plugin *plugin = cls;
@@ -712,12 +695,10 @@ unix_plugin_send (void *cls,
712 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Asked to send message to `%s'\n", 695 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Asked to send message to `%s'\n",
713 (char *) addr); 696 (char *) addr);
714#endif 697#endif
715 sent = unix_real_send (cls, 698 sent =
716 NULL, 699 unix_real_send (cls, NULL, plugin->unix_sock.desc, target, msgbuf,
717 plugin->unix_sock.desc, 700 msgbuf_size, priority, timeout, addr, addrlen, cont,
718 target, 701 cont_cls);
719 msgbuf, msgbuf_size,
720 priority, timeout, addr, addrlen, cont, cont_cls);
721#if DEBUG_UNIX 702#if DEBUG_UNIX
722 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sent %d bytes to `%s'\n", sent, 703 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sent %d bytes to `%s'\n", sent,
723 (char *) addr); 704 (char *) addr);
@@ -738,8 +719,7 @@ unix_plugin_send (void *cls,
738 * @param fromlen the length of the address 719 * @param fromlen the length of the address
739 */ 720 */
740static void 721static void
741unix_demultiplexer (struct Plugin *plugin, 722unix_demultiplexer (struct Plugin *plugin, struct GNUNET_PeerIdentity *sender,
742 struct GNUNET_PeerIdentity *sender,
743 const struct GNUNET_MessageHeader *currhdr, 723 const struct GNUNET_MessageHeader *currhdr,
744 const struct sockaddr_un *un, size_t fromlen) 724 const struct sockaddr_un *un, size_t fromlen)
745{ 725{
@@ -909,8 +889,8 @@ unix_transport_server_start (void *cls)
909 return GNUNET_SYSERR; 889 return GNUNET_SYSERR;
910 } 890 }
911#if DEBUG_UNIX 891#if DEBUG_UNIX
912 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, 892 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "unix", "Bound to `%s'\n",
913 "unix", "Bound to `%s'\n", &un.sun_path[0]); 893 &un.sun_path[0]);
914#endif 894#endif
915 plugin->rs = GNUNET_NETWORK_fdset_create (); 895 plugin->rs = GNUNET_NETWORK_fdset_create ();
916 GNUNET_NETWORK_fdset_zero (plugin->rs); 896 GNUNET_NETWORK_fdset_zero (plugin->rs);
@@ -990,10 +970,8 @@ append_port (void *cls, const char *hostname)
990 * @param asc_cls closure for asc 970 * @param asc_cls closure for asc
991 */ 971 */
992static void 972static void
993unix_plugin_address_pretty_printer (void *cls, 973unix_plugin_address_pretty_printer (void *cls, const char *type,
994 const char *type, 974 const void *addr, size_t addrlen,
995 const void *addr,
996 size_t addrlen,
997 int numeric, 975 int numeric,
998 struct GNUNET_TIME_Relative timeout, 976 struct GNUNET_TIME_Relative timeout,
999 GNUNET_TRANSPORT_AddressStringCallback asc, 977 GNUNET_TRANSPORT_AddressStringCallback asc,
@@ -1075,8 +1053,7 @@ address_notification (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
1075{ 1053{
1076 struct Plugin *plugin = cls; 1054 struct Plugin *plugin = cls;
1077 1055
1078 plugin->env->notify_address (plugin->env->cls, 1056 plugin->env->notify_address (plugin->env->cls, GNUNET_YES,
1079 GNUNET_YES,
1080 plugin->unix_socket_path, 1057 plugin->unix_socket_path,
1081 strlen (plugin->unix_socket_path) + 1); 1058 strlen (plugin->unix_socket_path) + 1);
1082} 1059}
@@ -1095,14 +1072,14 @@ libgnunet_plugin_transport_unix_init (void *cls)
1095 int sockets_created; 1072 int sockets_created;
1096 1073
1097 if (GNUNET_OK != 1074 if (GNUNET_OK !=
1098 GNUNET_CONFIGURATION_get_value_number (env->cfg, 1075 GNUNET_CONFIGURATION_get_value_number (env->cfg, "transport-unix", "PORT",
1099 "transport-unix", "PORT", &port)) 1076 &port))
1100 port = UNIX_NAT_DEFAULT_PORT; 1077 port = UNIX_NAT_DEFAULT_PORT;
1101 plugin = GNUNET_malloc (sizeof (struct Plugin)); 1078 plugin = GNUNET_malloc (sizeof (struct Plugin));
1102 plugin->port = port; 1079 plugin->port = port;
1103 plugin->env = env; 1080 plugin->env = env;
1104 GNUNET_asprintf (&plugin->unix_socket_path, 1081 GNUNET_asprintf (&plugin->unix_socket_path, "/tmp/unix-plugin-sock.%d",
1105 "/tmp/unix-plugin-sock.%d", plugin->port); 1082 plugin->port);
1106 1083
1107 api = GNUNET_malloc (sizeof (struct GNUNET_TRANSPORT_PluginFunctions)); 1084 api = GNUNET_malloc (sizeof (struct GNUNET_TRANSPORT_PluginFunctions));
1108 api->cls = plugin; 1085 api->cls = plugin;
diff --git a/src/transport/plugin_transport_wlan.c b/src/transport/plugin_transport_wlan.c
index 6ed367293..ad8d9a7a1 100644
--- a/src/transport/plugin_transport_wlan.c
+++ b/src/transport/plugin_transport_wlan.c
@@ -662,11 +662,10 @@ struct FragmentMessage
662 struct Radiotap_Send *radioHeader; 662 struct Radiotap_Send *radioHeader;
663}; 663};
664 664
665static void 665static void do_transmit (void *cls,
666do_transmit (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc); 666 const struct GNUNET_SCHEDULER_TaskContext *tc);
667static void 667static void free_session (struct Plugin *plugin, struct Sessionqueue *queue,
668free_session (struct Plugin *plugin, struct Sessionqueue *queue, 668 int do_free_macendpoint);
669 int do_free_macendpoint);
670static struct MacEndpoint *create_macendpoint (struct Plugin *plugin, 669static struct MacEndpoint *create_macendpoint (struct Plugin *plugin,
671 const struct MacAddress *addr); 670 const struct MacAddress *addr);
672 671
@@ -773,8 +772,9 @@ search_session (struct Plugin *plugin, const struct MacEndpoint *endpoint,
773 while (queue != NULL) 772 while (queue != NULL)
774 { 773 {
775 GNUNET_assert (queue->content != NULL); 774 GNUNET_assert (queue->content != NULL);
776 if (memcmp (peer, &queue->content->target, 775 if (memcmp
777 sizeof (struct GNUNET_PeerIdentity)) == 0) 776 (peer, &queue->content->target,
777 sizeof (struct GNUNET_PeerIdentity)) == 0)
778 return queue->content; /* session found */ 778 return queue->content; /* session found */
779 queue = queue->next; 779 queue = queue->next;
780 } 780 }
@@ -974,27 +974,29 @@ set_next_beacon_time (struct Plugin *const plugin)
974 //under 10 known peers: once a second 974 //under 10 known peers: once a second
975 if (plugin->mac_count < 10) 975 if (plugin->mac_count < 10)
976 { 976 {
977 plugin->beacon_time = GNUNET_TIME_absolute_add (GNUNET_TIME_absolute_get (), 977 plugin->beacon_time =
978 GNUNET_TIME_relative_multiply 978 GNUNET_TIME_absolute_add (GNUNET_TIME_absolute_get (),
979 (GNUNET_TIME_UNIT_SECONDS, 979 GNUNET_TIME_relative_multiply
980 HALLO_BEACON_SCALING_FACTOR)); 980 (GNUNET_TIME_UNIT_SECONDS,
981 HALLO_BEACON_SCALING_FACTOR));
981 } 982 }
982 //under 30 known peers: every 10 seconds 983 //under 30 known peers: every 10 seconds
983 else if (plugin->mac_count < 30) 984 else if (plugin->mac_count < 30)
984 { 985 {
985 plugin->beacon_time = GNUNET_TIME_absolute_add (GNUNET_TIME_absolute_get (), 986 plugin->beacon_time =
986 GNUNET_TIME_relative_multiply 987 GNUNET_TIME_absolute_add (GNUNET_TIME_absolute_get (),
987 (GNUNET_TIME_UNIT_SECONDS, 988 GNUNET_TIME_relative_multiply
988 10 * 989 (GNUNET_TIME_UNIT_SECONDS,
989 HALLO_BEACON_SCALING_FACTOR)); 990 10 * HALLO_BEACON_SCALING_FACTOR));
990 } 991 }
991 //over 30 known peers: once a minute 992 //over 30 known peers: once a minute
992 else 993 else
993 { 994 {
994 plugin->beacon_time = GNUNET_TIME_absolute_add (GNUNET_TIME_absolute_get (), 995 plugin->beacon_time =
995 GNUNET_TIME_relative_multiply 996 GNUNET_TIME_absolute_add (GNUNET_TIME_absolute_get (),
996 (GNUNET_TIME_UNIT_MINUTES, 997 GNUNET_TIME_relative_multiply
997 HALLO_BEACON_SCALING_FACTOR)); 998 (GNUNET_TIME_UNIT_MINUTES,
999 HALLO_BEACON_SCALING_FACTOR));
998 } 1000 }
999} 1001}
1000 1002
@@ -1094,10 +1096,10 @@ get_next_queue_session (struct Plugin *plugin)
1094 if (GNUNET_TIME_absolute_get_remaining (pm->timeout).rel_value > 0) 1096 if (GNUNET_TIME_absolute_get_remaining (pm->timeout).rel_value > 0)
1095 { 1097 {
1096 //check if session has no message in the fragment queue 1098 //check if session has no message in the fragment queue
1097 if ((session->mac->fragment_messages_out_count 1099 if ((session->mac->fragment_messages_out_count <
1098 < FRAGMENT_QUEUE_MESSAGES_OUT_PER_MACENDPOINT) 1100 FRAGMENT_QUEUE_MESSAGES_OUT_PER_MACENDPOINT) &&
1099 && (session->fragment_messages_out_count 1101 (session->fragment_messages_out_count <
1100 < FRAGMENT_QUEUE_MESSAGES_OUT_PER_SESSION)) 1102 FRAGMENT_QUEUE_MESSAGES_OUT_PER_SESSION))
1101 { 1103 {
1102 plugin->pendingsessions--; 1104 plugin->pendingsessions--;
1103 GNUNET_CONTAINER_DLL_remove (plugin->pending_Sessions_head, 1105 GNUNET_CONTAINER_DLL_remove (plugin->pending_Sessions_head,
@@ -1335,8 +1337,9 @@ add_message_for_send (void *cls, const struct GNUNET_MessageHeader *hdr)
1335 fm, fm->session, endpoint); 1337 fm, fm->session, endpoint);
1336#endif 1338#endif
1337 1339
1338 size = sizeof (struct GNUNET_MessageHeader) + sizeof (struct Radiotap_Send) 1340 size =
1339 + sizeof (struct ieee80211_frame) + ntohs (hdr->size); 1341 sizeof (struct GNUNET_MessageHeader) + sizeof (struct Radiotap_Send) +
1342 sizeof (struct ieee80211_frame) + ntohs (hdr->size);
1340 fm->frag = GNUNET_malloc (size); 1343 fm->frag = GNUNET_malloc (size);
1341 fm->size = size; 1344 fm->size = size;
1342 1345
@@ -1382,9 +1385,10 @@ send_hello_beacon (struct Plugin *plugin)
1382 hello = plugin->env->get_our_hello (); 1385 hello = plugin->env->get_our_hello ();
1383 hallo_size = GNUNET_HELLO_size ((struct GNUNET_HELLO_Message *) hello); 1386 hallo_size = GNUNET_HELLO_size ((struct GNUNET_HELLO_Message *) hello);
1384 GNUNET_assert (sizeof (struct WlanHeader) + hallo_size <= WLAN_MTU); 1387 GNUNET_assert (sizeof (struct WlanHeader) + hallo_size <= WLAN_MTU);
1385 size = sizeof (struct GNUNET_MessageHeader) + sizeof (struct Radiotap_Send) 1388 size =
1386 + sizeof (struct ieee80211_frame) + sizeof (struct GNUNET_MessageHeader) 1389 sizeof (struct GNUNET_MessageHeader) + sizeof (struct Radiotap_Send) +
1387 + hallo_size; 1390 sizeof (struct ieee80211_frame) + sizeof (struct GNUNET_MessageHeader) +
1391 hallo_size;
1388 1392
1389 msgheader = GNUNET_malloc (size); 1393 msgheader = GNUNET_malloc (size);
1390 msgheader->size = htons (size); 1394 msgheader->size = htons (size);
@@ -1443,16 +1447,18 @@ add_ack_for_send (void *cls, uint32_t msg_id,
1443 struct GNUNET_MessageHeader *msgheader2; 1447 struct GNUNET_MessageHeader *msgheader2;
1444 uint16_t size; 1448 uint16_t size;
1445 1449
1446 size = sizeof (struct GNUNET_MessageHeader) + sizeof (struct Radiotap_Send) 1450 size =
1447 + sizeof (struct ieee80211_frame) + ntohs (hdr->size) 1451 sizeof (struct GNUNET_MessageHeader) + sizeof (struct Radiotap_Send) +
1448 + sizeof (struct AckSendQueue); 1452 sizeof (struct ieee80211_frame) + ntohs (hdr->size) +
1453 sizeof (struct AckSendQueue);
1449 1454
1450 ack = GNUNET_malloc (size); 1455 ack = GNUNET_malloc (size);
1451 ack->message_id = msg_id; 1456 ack->message_id = msg_id;
1452 ack->endpoint = endpoint; 1457 ack->endpoint = endpoint;
1453 1458
1454 size = sizeof (struct GNUNET_MessageHeader) + sizeof (struct Radiotap_Send) 1459 size =
1455 + sizeof (struct ieee80211_frame) + ntohs (hdr->size); 1460 sizeof (struct GNUNET_MessageHeader) + sizeof (struct Radiotap_Send) +
1461 sizeof (struct ieee80211_frame) + ntohs (hdr->size);
1456 1462
1457 msgheader = (struct GNUNET_MessageHeader *) &ack[1]; 1463 msgheader = (struct GNUNET_MessageHeader *) &ack[1];
1458 ack->hdr = (struct GNUNET_MessageHeader *) &ack[1]; 1464 ack->hdr = (struct GNUNET_MessageHeader *) &ack[1];
@@ -1528,13 +1534,12 @@ check_fragment_queue (struct Plugin *plugin)
1528 fm->session = session; 1534 fm->session = session;
1529 fm->timeout.abs_value = pm->timeout.abs_value; 1535 fm->timeout.abs_value = pm->timeout.abs_value;
1530 fm->frag = NULL; 1536 fm->frag = NULL;
1531 fm->fragcontext = GNUNET_FRAGMENT_context_create (plugin->env->stats, 1537 fm->fragcontext =
1532 WLAN_MTU, 1538 GNUNET_FRAGMENT_context_create (plugin->env->stats, WLAN_MTU,
1533 &plugin->tracker, 1539 &plugin->tracker,
1534 GNUNET_TIME_UNIT_SECONDS, 1540 GNUNET_TIME_UNIT_SECONDS,
1535 &(pm->msg->header), 1541 &(pm->msg->header),
1536 &add_message_for_send, 1542 &add_message_for_send, fm);
1537 fm);
1538 fm->timeout_task = 1543 fm->timeout_task =
1539 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_absolute_get_remaining 1544 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_absolute_get_remaining
1540 (fm->timeout), fragmentmessage_timeout, 1545 (fm->timeout), fragmentmessage_timeout,
@@ -1596,8 +1601,9 @@ send_ack (struct Plugin *plugin, struct AckSendQueue *ack)
1596 getWlanHeader (ack->ieeewlanheader, &ack->endpoint->addr, plugin, 1601 getWlanHeader (ack->ieeewlanheader, &ack->endpoint->addr, plugin,
1597 ntohs (ack->hdr->size)); 1602 ntohs (ack->hdr->size));
1598 1603
1599 bytes = GNUNET_DISK_file_write (plugin->server_stdin_handle, ack->hdr, 1604 bytes =
1600 ntohs (ack->hdr->size)); 1605 GNUNET_DISK_file_write (plugin->server_stdin_handle, ack->hdr,
1606 ntohs (ack->hdr->size));
1601 if (bytes == GNUNET_SYSERR) 1607 if (bytes == GNUNET_SYSERR)
1602 { 1608 {
1603 GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, PLUGIN_LOG_NAME, 1609 GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, PLUGIN_LOG_NAME,
@@ -1632,8 +1638,9 @@ finish_sending (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
1632 GNUNET_free (finish); 1638 GNUNET_free (finish);
1633 return; 1639 return;
1634 } 1640 }
1635 bytes = GNUNET_DISK_file_write (plugin->server_stdin_handle, 1641 bytes =
1636 finish->msgheader, finish->size); 1642 GNUNET_DISK_file_write (plugin->server_stdin_handle, finish->msgheader,
1643 finish->size);
1637 GNUNET_assert (bytes != GNUNET_SYSERR); 1644 GNUNET_assert (bytes != GNUNET_SYSERR);
1638 1645
1639 if (bytes != finish->size) 1646 if (bytes != finish->size)
@@ -1713,8 +1720,9 @@ do_transmit (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
1713 getWlanHeader (fm->ieeewlanheader, &(fm->session->mac->addr), plugin, 1720 getWlanHeader (fm->ieeewlanheader, &(fm->session->mac->addr), plugin,
1714 fm->size); 1721 fm->size);
1715 1722
1716 bytes = GNUNET_DISK_file_write (plugin->server_stdin_handle, fm->frag, 1723 bytes =
1717 fm->size); 1724 GNUNET_DISK_file_write (plugin->server_stdin_handle, fm->frag,
1725 fm->size);
1718 if (bytes == GNUNET_SYSERR) 1726 if (bytes == GNUNET_SYSERR)
1719 { 1727 {
1720 GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, PLUGIN_LOG_NAME, 1728 GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, PLUGIN_LOG_NAME,
@@ -1852,9 +1860,8 @@ wlan_plugin_send (void *cls, const struct GNUNET_PeerIdentity *target,
1852 newmsg = session->pending_message_head; 1860 newmsg = session->pending_message_head;
1853 GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, PLUGIN_LOG_NAME, 1861 GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, PLUGIN_LOG_NAME,
1854 "wlan_plugin_send: a pending message is already in the queue for this client\n remaining time to send this message is %u, queued fragment messages for this mac connection %u\n", 1862 "wlan_plugin_send: a pending message is already in the queue for this client\n remaining time to send this message is %u, queued fragment messages for this mac connection %u\n",
1855 GNUNET_TIME_absolute_get_remaining (newmsg-> 1863 GNUNET_TIME_absolute_get_remaining (newmsg->timeout).
1856 timeout).rel_value, 1864 rel_value, session->mac->fragment_messages_out_count);
1857 session->mac->fragment_messages_out_count);
1858 } 1865 }
1859 1866
1860 newmsg = GNUNET_malloc (sizeof (struct PendingMessage)); 1867 newmsg = GNUNET_malloc (sizeof (struct PendingMessage));
@@ -1992,8 +1999,8 @@ free_session (struct Plugin *plugin, struct Sessionqueue *queue,
1992 pm = queue->content->pending_message_head; 1999 pm = queue->content->pending_message_head;
1993 } 2000 }
1994 2001
1995 GNUNET_CONTAINER_DLL_remove (endpoint->sessions_head, 2002 GNUNET_CONTAINER_DLL_remove (endpoint->sessions_head, endpoint->sessions_tail,
1996 endpoint->sessions_tail, queue); 2003 queue);
1997 2004
1998 if (endpoint->sessions_head == NULL && do_free_macendpoint == GNUNET_YES) 2005 if (endpoint->sessions_head == NULL && do_free_macendpoint == GNUNET_YES)
1999 { 2006 {
@@ -2033,8 +2040,9 @@ wlan_plugin_disconnect (void *cls, const struct GNUNET_PeerIdentity *target)
2033 // content is never NULL 2040 // content is never NULL
2034 GNUNET_assert (queue->content != NULL); 2041 GNUNET_assert (queue->content != NULL);
2035 queue_next = queue->next; 2042 queue_next = queue->next;
2036 if (memcmp (target, &(queue->content->target), 2043 if (memcmp
2037 sizeof (struct GNUNET_PeerIdentity)) == 0) 2044 (target, &(queue->content->target),
2045 sizeof (struct GNUNET_PeerIdentity)) == 0)
2038 { 2046 {
2039 free_session (plugin, queue, GNUNET_YES); 2047 free_session (plugin, queue, GNUNET_YES);
2040 } 2048 }
@@ -2113,8 +2121,8 @@ wlan_data_message_handler (void *cls, const struct GNUNET_MessageHeader *hdr)
2113 ntohs (hdr->size)); 2121 ntohs (hdr->size));
2114#endif 2122#endif
2115 2123
2116 if (ntohs (hdr->size) < sizeof (struct WlanHeader) 2124 if (ntohs (hdr->size) <
2117 + sizeof (struct GNUNET_MessageHeader)) 2125 sizeof (struct WlanHeader) + sizeof (struct GNUNET_MessageHeader))
2118 { 2126 {
2119 //packet not big enought 2127 //packet not big enought
2120 return; 2128 return;
@@ -2149,13 +2157,14 @@ wlan_data_message_handler (void *cls, const struct GNUNET_MessageHeader *hdr)
2149 sizeof (struct WlanHeader)); 2157 sizeof (struct WlanHeader));
2150#endif 2158#endif
2151 //try if it is a hello message 2159 //try if it is a hello message
2152 if (ntohs (wlanheader->header.size) >= ntohs (temp_hdr->size) 2160 if (ntohs (wlanheader->header.size) >=
2153 + sizeof (struct WlanHeader)) 2161 ntohs (temp_hdr->size) + sizeof (struct WlanHeader))
2154 { 2162 {
2155 if (ntohs (temp_hdr->type) == GNUNET_MESSAGE_TYPE_HELLO) 2163 if (ntohs (temp_hdr->type) == GNUNET_MESSAGE_TYPE_HELLO)
2156 { 2164 {
2157 if (GNUNET_HELLO_get_id ((const struct GNUNET_HELLO_Message *) 2165 if (GNUNET_HELLO_get_id
2158 temp_hdr, &tmpsource) == GNUNET_OK) 2166 ((const struct GNUNET_HELLO_Message *) temp_hdr,
2167 &tmpsource) == GNUNET_OK)
2159 { 2168 {
2160 session = create_session (plugin, endpoint, &tmpsource); 2169 session = create_session (plugin, endpoint, &tmpsource);
2161 } 2170 }
@@ -2186,8 +2195,9 @@ wlan_data_message_handler (void *cls, const struct GNUNET_MessageHeader *hdr)
2186 2195
2187 //"receive" the message 2196 //"receive" the message
2188 2197
2189 if (memcmp (&wlanheader->source, &session->target, 2198 if (memcmp
2190 sizeof (struct GNUNET_PeerIdentity)) != 0) 2199 (&wlanheader->source, &session->target,
2200 sizeof (struct GNUNET_PeerIdentity)) != 0)
2191 { 2201 {
2192 //wrong peer id 2202 //wrong peer id
2193#if DEBUG_wlan 2203#if DEBUG_wlan
@@ -2198,8 +2208,9 @@ wlan_data_message_handler (void *cls, const struct GNUNET_MessageHeader *hdr)
2198 return; 2208 return;
2199 } 2209 }
2200 2210
2201 if (memcmp (&wlanheader->target, plugin->env->my_identity, 2211 if (memcmp
2202 sizeof (struct GNUNET_PeerIdentity)) != 0) 2212 (&wlanheader->target, plugin->env->my_identity,
2213 sizeof (struct GNUNET_PeerIdentity)) != 0)
2203 { 2214 {
2204 //wrong peer id 2215 //wrong peer id
2205#if DEBUG_wlan 2216#if DEBUG_wlan
@@ -2252,8 +2263,8 @@ process_data (void *cls, void *client, const struct GNUNET_MessageHeader *hdr)
2252 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME, 2263 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME,
2253 "Calling plugin->env->receive for session %p; %s; size: %u\n", 2264 "Calling plugin->env->receive for session %p; %s; size: %u\n",
2254 session, wlan_plugin_address_to_string (NULL, 2265 session, wlan_plugin_address_to_string (NULL,
2255 session->mac-> 2266 session->mac->addr.
2256 addr.mac, 6), 2267 mac, 6),
2257 htons (hdr->size)); 2268 htons (hdr->size));
2258#endif 2269#endif
2259 2270
@@ -2291,22 +2302,20 @@ wlan_data_helper (void *cls, struct Session_light *session_light,
2291#if DEBUG_wlan 2302#if DEBUG_wlan
2292 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME, 2303 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME,
2293 "Func wlan_data_helper got GNUNET_MESSAGE_TYPE_WLAN_ADVERTISEMENT size: %u; %s\n", 2304 "Func wlan_data_helper got GNUNET_MESSAGE_TYPE_WLAN_ADVERTISEMENT size: %u; %s\n",
2294 ntohs (hdr->size), 2305 ntohs (hdr->size), wlan_plugin_address_to_string (NULL,
2295 wlan_plugin_address_to_string (NULL, 2306 session_light->
2296 session_light->addr.mac, 2307 addr.mac,
2297 6)); 2308 6));
2298#endif 2309#endif
2299 2310
2300 if (session_light->macendpoint == NULL) 2311 if (session_light->macendpoint == NULL)
2301 { 2312 {
2302 session_light->macendpoint = get_macendpoint (plugin, 2313 session_light->macendpoint =
2303 &session_light->addr, 2314 get_macendpoint (plugin, &session_light->addr, GNUNET_NO);
2304 GNUNET_NO);
2305 } 2315 }
2306 GNUNET_assert (GNUNET_HELLO_get_id ((const struct GNUNET_HELLO_Message *) 2316 GNUNET_assert (GNUNET_HELLO_get_id
2307 &hdr[1], 2317 ((const struct GNUNET_HELLO_Message *) &hdr[1],
2308 &(session_light->session->target)) != 2318 &(session_light->session->target)) != GNUNET_SYSERR);
2309 GNUNET_SYSERR);
2310 2319
2311 } 2320 }
2312 2321
@@ -2318,9 +2327,8 @@ wlan_data_helper (void *cls, struct Session_light *session_light,
2318 GNUNET_assert (session_light != NULL); 2327 GNUNET_assert (session_light != NULL);
2319 if (session_light->macendpoint == NULL) 2328 if (session_light->macendpoint == NULL)
2320 { 2329 {
2321 session_light->macendpoint = get_macendpoint (plugin, 2330 session_light->macendpoint =
2322 &session_light->addr, 2331 get_macendpoint (plugin, &session_light->addr, GNUNET_YES);
2323 GNUNET_YES);
2324 } 2332 }
2325 2333
2326#if DEBUG_wlan 2334#if DEBUG_wlan
@@ -2355,9 +2363,8 @@ wlan_data_helper (void *cls, struct Session_light *session_light,
2355 GNUNET_assert (session_light != NULL); 2363 GNUNET_assert (session_light != NULL);
2356 if (session_light->macendpoint == NULL) 2364 if (session_light->macendpoint == NULL)
2357 { 2365 {
2358 session_light->macendpoint = get_macendpoint (plugin, 2366 session_light->macendpoint =
2359 &session_light->addr, 2367 get_macendpoint (plugin, &session_light->addr, GNUNET_NO);
2360 GNUNET_NO);
2361 } 2368 }
2362 2369
2363 if (session_light->macendpoint == NULL) 2370 if (session_light->macendpoint == NULL)
@@ -2365,10 +2372,11 @@ wlan_data_helper (void *cls, struct Session_light *session_light,
2365#if DEBUG_wlan 2372#if DEBUG_wlan
2366 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME, 2373 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME,
2367 "Macendpoint does not exist for this GNUNET_MESSAGE_TYPE_FRAGMENT_ACK size: %u; %s\n", 2374 "Macendpoint does not exist for this GNUNET_MESSAGE_TYPE_FRAGMENT_ACK size: %u; %s\n",
2368 ntohs (hdr->size), 2375 ntohs (hdr->size), wlan_plugin_address_to_string (NULL,
2369 wlan_plugin_address_to_string (NULL, 2376 session_light->
2370 session_light->addr.mac, 2377 addr.
2371 6)); 2378 mac,
2379 6));
2372#endif 2380#endif
2373 return; 2381 return;
2374 } 2382 }
@@ -2469,16 +2477,16 @@ macendpoint_timeout (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
2469 return; 2477 return;
2470 } 2478 }
2471 if (GNUNET_TIME_absolute_get_remaining 2479 if (GNUNET_TIME_absolute_get_remaining
2472 (GNUNET_TIME_absolute_add 2480 (GNUNET_TIME_absolute_add (endpoint->last_activity, MACENDPOINT_TIMEOUT)).
2473 (endpoint->last_activity, MACENDPOINT_TIMEOUT)).rel_value == 0) 2481 rel_value == 0)
2474 { 2482 {
2475 free_macendpoint (endpoint->plugin, endpoint); 2483 free_macendpoint (endpoint->plugin, endpoint);
2476 } 2484 }
2477 else 2485 else
2478 { 2486 {
2479 endpoint->timeout_task = GNUNET_SCHEDULER_add_delayed (MACENDPOINT_TIMEOUT, 2487 endpoint->timeout_task =
2480 &macendpoint_timeout, 2488 GNUNET_SCHEDULER_add_delayed (MACENDPOINT_TIMEOUT, &macendpoint_timeout,
2481 endpoint); 2489 endpoint);
2482 } 2490 }
2483} 2491}
2484 2492
@@ -2497,16 +2505,15 @@ create_macendpoint (struct Plugin *plugin, const struct MacAddress *addr)
2497 newend->plugin = plugin; 2505 newend->plugin = plugin;
2498 newend->addr = *addr; 2506 newend->addr = *addr;
2499 newend->fragment_messages_out_count = 0; 2507 newend->fragment_messages_out_count = 0;
2500 newend->defrag = GNUNET_DEFRAGMENT_context_create (plugin->env->stats, 2508 newend->defrag =
2501 WLAN_MTU, 2509 GNUNET_DEFRAGMENT_context_create (plugin->env->stats, WLAN_MTU,
2502 MESSAGES_IN_DEFRAG_QUEUE_PER_MAC, 2510 MESSAGES_IN_DEFRAG_QUEUE_PER_MAC,
2503 newend, 2511 newend, &wlan_data_message_handler,
2504 &wlan_data_message_handler, 2512 &add_ack_for_send);
2505 &add_ack_for_send);
2506 newend->last_activity = GNUNET_TIME_absolute_get (); 2513 newend->last_activity = GNUNET_TIME_absolute_get ();
2507 newend->timeout_task = GNUNET_SCHEDULER_add_delayed (MACENDPOINT_TIMEOUT, 2514 newend->timeout_task =
2508 &macendpoint_timeout, 2515 GNUNET_SCHEDULER_add_delayed (MACENDPOINT_TIMEOUT, &macendpoint_timeout,
2509 newend); 2516 newend);
2510 2517
2511 plugin->mac_count++; 2518 plugin->mac_count++;
2512 GNUNET_CONTAINER_DLL_insert_tail (plugin->mac_head, plugin->mac_tail, newend); 2519 GNUNET_CONTAINER_DLL_insert_tail (plugin->mac_head, plugin->mac_tail, newend);
@@ -2548,15 +2555,16 @@ wlan_process_helper (void *cls, void *client,
2548#endif 2555#endif
2549 2556
2550 //call wlan_process_helper with the message inside, later with wlan: analyze signal 2557 //call wlan_process_helper with the message inside, later with wlan: analyze signal
2551 if (ntohs (hdr->size) < sizeof (struct ieee80211_frame) 2558 if (ntohs (hdr->size) <
2552 + sizeof (struct GNUNET_MessageHeader) + sizeof (struct Radiotap_rx)) 2559 sizeof (struct ieee80211_frame) + sizeof (struct GNUNET_MessageHeader) +
2560 sizeof (struct Radiotap_rx))
2553 { 2561 {
2554#if DEBUG_wlan 2562#if DEBUG_wlan
2555 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME, 2563 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME,
2556 "Size of packet is too small; size: %u min size: %u\n", 2564 "Size of packet is too small; size: %u min size: %u\n",
2557 ntohs (hdr->size), 2565 ntohs (hdr->size),
2558 sizeof (struct ieee80211_frame) 2566 sizeof (struct ieee80211_frame) +
2559 + sizeof (struct GNUNET_MessageHeader)); 2567 sizeof (struct GNUNET_MessageHeader));
2560#endif 2568#endif
2561 //GNUNET_break (0); 2569 //GNUNET_break (0);
2562 /* FIXME: restart SUID process */ 2570 /* FIXME: restart SUID process */
@@ -2568,12 +2576,14 @@ wlan_process_helper (void *cls, void *client,
2568 //process only if it is an broadcast or for this computer both with the gnunet bssid 2576 //process only if it is an broadcast or for this computer both with the gnunet bssid
2569 2577
2570 //check for bssid 2578 //check for bssid
2571 if (memcmp (&(wlanIeeeHeader->i_addr3), &mac_bssid, 2579 if (memcmp
2572 sizeof (struct MacAddress)) == 0) 2580 (&(wlanIeeeHeader->i_addr3), &mac_bssid,
2581 sizeof (struct MacAddress)) == 0)
2573 { 2582 {
2574 //check for broadcast or mac 2583 //check for broadcast or mac
2575 if (memcmp (&(wlanIeeeHeader->i_addr1), &bc_all_mac, 2584 if (memcmp
2576 sizeof (struct MacAddress) == 0) || 2585 (&(wlanIeeeHeader->i_addr1), &bc_all_mac,
2586 sizeof (struct MacAddress) == 0) ||
2577 memcmp (&(wlanIeeeHeader->i_addr1), &(plugin->mac_address), 2587 memcmp (&(wlanIeeeHeader->i_addr1), &(plugin->mac_address),
2578 sizeof (struct MacAddress)) == 0) 2588 sizeof (struct MacAddress)) == 0)
2579 { 2589 {
@@ -2581,9 +2591,9 @@ wlan_process_helper (void *cls, void *client,
2581 // process the inner data 2591 // process the inner data
2582 2592
2583 2593
2584 datasize = ntohs (hdr->size) - sizeof (struct ieee80211_frame) 2594 datasize =
2585 - sizeof (struct GNUNET_MessageHeader) 2595 ntohs (hdr->size) - sizeof (struct ieee80211_frame) -
2586 - sizeof (struct Radiotap_rx); 2596 sizeof (struct GNUNET_MessageHeader) - sizeof (struct Radiotap_rx);
2587 2597
2588 session_light = GNUNET_malloc (sizeof (struct Session_light)); 2598 session_light = GNUNET_malloc (sizeof (struct Session_light));
2589 memcpy (&session_light->addr, &(wlanIeeeHeader->i_addr2), 2599 memcpy (&session_light->addr, &(wlanIeeeHeader->i_addr2),
@@ -2670,8 +2680,9 @@ wlan_plugin_helper_read (void *cls,
2670 char mybuf[WLAN_MTU + sizeof (struct GNUNET_MessageHeader)]; 2680 char mybuf[WLAN_MTU + sizeof (struct GNUNET_MessageHeader)];
2671 ssize_t bytes; 2681 ssize_t bytes;
2672 2682
2673 bytes = GNUNET_DISK_file_read (plugin->server_stdout_handle, mybuf, 2683 bytes =
2674 sizeof (mybuf)); 2684 GNUNET_DISK_file_read (plugin->server_stdout_handle, mybuf,
2685 sizeof (mybuf));
2675 if (bytes <= 0) 2686 if (bytes <= 0)
2676 { 2687 {
2677#if DEBUG_wlan 2688#if DEBUG_wlan
@@ -2724,10 +2735,10 @@ wlan_transport_start_wlan_helper (struct Plugin *plugin, int testmode)
2724 filenamehw, plugin->interface, testmode); 2735 filenamehw, plugin->interface, testmode);
2725#endif 2736#endif
2726 2737
2727 plugin->server_proc = GNUNET_OS_start_process (plugin->server_stdin, 2738 plugin->server_proc =
2728 plugin->server_stdout, 2739 GNUNET_OS_start_process (plugin->server_stdin, plugin->server_stdout,
2729 filenamehw, filenamehw, 2740 filenamehw, filenamehw, plugin->interface,
2730 plugin->interface, NULL); 2741 NULL);
2731 } 2742 }
2732 else if (testmode == 1) 2743 else if (testmode == 1)
2733 { 2744 {
@@ -2738,10 +2749,9 @@ wlan_transport_start_wlan_helper (struct Plugin *plugin, int testmode)
2738 filenameloopback, plugin->interface, testmode); 2749 filenameloopback, plugin->interface, testmode);
2739#endif 2750#endif
2740 2751
2741 plugin->server_proc = GNUNET_OS_start_process (plugin->server_stdin, 2752 plugin->server_proc =
2742 plugin->server_stdout, 2753 GNUNET_OS_start_process (plugin->server_stdin, plugin->server_stdout,
2743 filenameloopback, 2754 filenameloopback, filenameloopback, "1", NULL);
2744 filenameloopback, "1", NULL);
2745 } 2755 }
2746 else if (testmode == 2) 2756 else if (testmode == 2)
2747 { 2757 {
@@ -2750,10 +2760,9 @@ wlan_transport_start_wlan_helper (struct Plugin *plugin, int testmode)
2750 "Starting gnunet-wlan-helper loopback 2 process cmd: %s %s %i\n", 2760 "Starting gnunet-wlan-helper loopback 2 process cmd: %s %s %i\n",
2751 filenameloopback, plugin->interface, testmode); 2761 filenameloopback, plugin->interface, testmode);
2752#endif 2762#endif
2753 plugin->server_proc = GNUNET_OS_start_process (plugin->server_stdin, 2763 plugin->server_proc =
2754 plugin->server_stdout, 2764 GNUNET_OS_start_process (plugin->server_stdin, plugin->server_stdout,
2755 filenameloopback, 2765 filenameloopback, filenameloopback, "2", NULL);
2756 filenameloopback, "2", NULL);
2757 } 2766 }
2758 if (plugin->server_proc == NULL) 2767 if (plugin->server_proc == NULL)
2759 { 2768 {
@@ -2771,10 +2780,12 @@ wlan_transport_start_wlan_helper (struct Plugin *plugin, int testmode)
2771 /* Close the read end of the write pipe */ 2780 /* Close the read end of the write pipe */
2772 GNUNET_DISK_pipe_close_end (plugin->server_stdin, GNUNET_DISK_PIPE_END_READ); 2781 GNUNET_DISK_pipe_close_end (plugin->server_stdin, GNUNET_DISK_PIPE_END_READ);
2773 2782
2774 plugin->server_stdout_handle = GNUNET_DISK_pipe_handle (plugin->server_stdout, 2783 plugin->server_stdout_handle =
2775 GNUNET_DISK_PIPE_END_READ); 2784 GNUNET_DISK_pipe_handle (plugin->server_stdout,
2776 plugin->server_stdin_handle = GNUNET_DISK_pipe_handle (plugin->server_stdin, 2785 GNUNET_DISK_PIPE_END_READ);
2777 GNUNET_DISK_PIPE_END_WRITE); 2786 plugin->server_stdin_handle =
2787 GNUNET_DISK_pipe_handle (plugin->server_stdin,
2788 GNUNET_DISK_PIPE_END_WRITE);
2778 2789
2779 GNUNET_assert (plugin->server_read_task == GNUNET_SCHEDULER_NO_TASK); 2790 GNUNET_assert (plugin->server_read_task == GNUNET_SCHEDULER_NO_TASK);
2780 2791
@@ -2880,8 +2891,8 @@ libgnunet_plugin_transport_wlan_init (void *cls)
2880 GNUNET_BANDWIDTH_value_init (100 * 1024 * 2891 GNUNET_BANDWIDTH_value_init (100 * 1024 *
2881 1024 / 8), 100); 2892 1024 / 8), 100);
2882 2893
2883 plugin->suid_tokenizer = GNUNET_SERVER_mst_create (&wlan_process_helper, 2894 plugin->suid_tokenizer =
2884 plugin); 2895 GNUNET_SERVER_mst_create (&wlan_process_helper, plugin);
2885 2896
2886 plugin->data_tokenizer = GNUNET_SERVER_mst_create (&process_data, plugin); 2897 plugin->data_tokenizer = GNUNET_SERVER_mst_create (&process_data, plugin);
2887 2898
@@ -2899,19 +2910,17 @@ libgnunet_plugin_transport_wlan_init (void *cls)
2899 2910
2900 if (GNUNET_CONFIGURATION_have_value (env->cfg, "transport-wlan", "TESTMODE")) 2911 if (GNUNET_CONFIGURATION_have_value (env->cfg, "transport-wlan", "TESTMODE"))
2901 { 2912 {
2902 if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_number (env->cfg, 2913 if (GNUNET_SYSERR ==
2903 "transport-wlan", 2914 GNUNET_CONFIGURATION_get_value_number (env->cfg, "transport-wlan",
2904 "TESTMODE", 2915 "TESTMODE", &testmode))
2905 &testmode))
2906 testmode = 0; //default value 2916 testmode = 0; //default value
2907 } 2917 }
2908 2918
2909 if (GNUNET_CONFIGURATION_have_value (env->cfg, "transport-wlan", "INTERFACE")) 2919 if (GNUNET_CONFIGURATION_have_value (env->cfg, "transport-wlan", "INTERFACE"))
2910 { 2920 {
2911 if (GNUNET_CONFIGURATION_get_value_string (env->cfg, "transport-wlan", 2921 if (GNUNET_CONFIGURATION_get_value_string
2912 "INTERFACE", 2922 (env->cfg, "transport-wlan", "INTERFACE",
2913 &(plugin->interface)) != 2923 &(plugin->interface)) != GNUNET_YES)
2914 GNUNET_YES)
2915 { 2924 {
2916 libgnunet_plugin_transport_wlan_done (api); 2925 libgnunet_plugin_transport_wlan_done (api);
2917 return NULL; 2926 return NULL;
diff --git a/src/transport/test_plugin_transport.c b/src/transport/test_plugin_transport.c
index e66e04ead..6bb187b19 100644
--- a/src/transport/test_plugin_transport.c
+++ b/src/transport/test_plugin_transport.c
@@ -87,20 +87,16 @@ static int ok;
87/** 87/**
88 */ 88 */
89static void 89static void
90receive (void *cls, 90receive (void *cls, const struct GNUNET_PeerIdentity *peer,
91 const struct GNUNET_PeerIdentity 91 const struct GNUNET_MessageHeader *message, uint32_t distance,
92 *peer, const struct GNUNET_MessageHeader *message,
93 uint32_t distance,
94 const char *sender_address, size_t sender_address_len) 92 const char *sender_address, size_t sender_address_len)
95{ 93{
96 /* do nothing */ 94 /* do nothing */
97} 95}
98 96
99void 97void
100notify_address (void *cls, 98notify_address (void *cls, const char *name, const void *addr, size_t addrlen,
101 const char *name, 99 struct GNUNET_TIME_Relative expires)
102 const void *addr,
103 size_t addrlen, struct GNUNET_TIME_Relative expires)
104{ 100{
105} 101}
106 102
@@ -161,8 +157,7 @@ test_validation ()
161 GNUNET_assert (GNUNET_OK == 157 GNUNET_assert (GNUNET_OK ==
162 api->check_address (api->cls, &soaddr, sizeof (soaddr))); 158 api->check_address (api->cls, &soaddr, sizeof (soaddr)));
163 ok = 0; 159 ok = 0;
164 GNUNET_SCHEDULER_add_continuation (&unload_task, 160 GNUNET_SCHEDULER_add_continuation (&unload_task, (void *) cfg,
165 (void *) cfg,
166 GNUNET_SCHEDULER_REASON_PREREQ_DONE); 161 GNUNET_SCHEDULER_REASON_PREREQ_DONE);
167} 162}
168 163
@@ -186,9 +181,8 @@ setup_plugin_environment ()
186 * @param c configuration to use 181 * @param c configuration to use
187 */ 182 */
188static void 183static void
189run (void *cls, 184run (void *cls, char *const *args, const char *cfgfile,
190 char *const *args, 185 const struct GNUNET_CONFIGURATION_Handle *c)
191 const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *c)
192{ 186{
193 unsigned long long tneigh; 187 unsigned long long tneigh;
194 char *keyfile; 188 char *keyfile;
@@ -197,14 +191,11 @@ run (void *cls,
197 cfg = c; 191 cfg = c;
198 /* parse configuration */ 192 /* parse configuration */
199 if ((GNUNET_OK != 193 if ((GNUNET_OK !=
200 GNUNET_CONFIGURATION_get_value_number (c, 194 GNUNET_CONFIGURATION_get_value_number (c, "TRANSPORT", "NEIGHBOUR_LIMIT",
201 "TRANSPORT",
202 "NEIGHBOUR_LIMIT",
203 &tneigh)) || 195 &tneigh)) ||
204 (GNUNET_OK != 196 (GNUNET_OK !=
205 GNUNET_CONFIGURATION_get_value_filename (c, 197 GNUNET_CONFIGURATION_get_value_filename (c, "GNUNETD", "HOSTKEY",
206 "GNUNETD", 198 &keyfile)))
207 "HOSTKEY", &keyfile)))
208 { 199 {
209 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 200 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
210 _ 201 _
@@ -223,8 +214,8 @@ run (void *cls,
223 return; 214 return;
224 } 215 }
225 GNUNET_CRYPTO_rsa_key_get_public (my_private_key, &my_public_key); 216 GNUNET_CRYPTO_rsa_key_get_public (my_private_key, &my_public_key);
226 GNUNET_CRYPTO_hash (&my_public_key, 217 GNUNET_CRYPTO_hash (&my_public_key, sizeof (my_public_key),
227 sizeof (my_public_key), &my_identity.hashPubKey); 218 &my_identity.hashPubKey);
228 219
229 220
230 221
@@ -281,11 +272,10 @@ main (int argc, char *const *argv)
281#endif 272#endif
282 NULL); 273 NULL);
283 ok = 1; /* set to fail */ 274 ok = 1; /* set to fail */
284 ret = (GNUNET_OK == 275 ret =
285 GNUNET_PROGRAM_run (5, 276 (GNUNET_OK ==
286 argv_prog, 277 GNUNET_PROGRAM_run (5, argv_prog, "test-plugin-transport", "testcase",
287 "test-plugin-transport", 278 options, &run, NULL)) ? ok : 1;
288 "testcase", options, &run, NULL)) ? ok : 1;
289 GNUNET_DISK_directory_remove ("/tmp/test-gnunetd-plugin-transport"); 279 GNUNET_DISK_directory_remove ("/tmp/test-gnunetd-plugin-transport");
290 return ret; 280 return ret;
291} 281}
diff --git a/src/transport/test_plugin_transport_http.c b/src/transport/test_plugin_transport_http.c
index 921f9ec32..f59edfb26 100644
--- a/src/transport/test_plugin_transport_http.c
+++ b/src/transport/test_plugin_transport_http.c
@@ -399,8 +399,8 @@ shutdown_clean ()
399 399
400 /* Evaluate results */ 400 /* Evaluate results */
401 fail = 0; 401 fail = 0;
402 if ((fail_notify_address == GNUNET_YES) || 402 if ((fail_notify_address == GNUNET_YES) || (fail_pretty_printer == GNUNET_YES)
403 (fail_pretty_printer == GNUNET_YES) || (fail_addr_to_str == GNUNET_YES)) 403 || (fail_addr_to_str == GNUNET_YES))
404 { 404 {
405 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 405 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
406 "Phase 0: Test plugin functions failed\n"); 406 "Phase 0: Test plugin functions failed\n");
@@ -530,15 +530,14 @@ static void run_connection_tests (int phase, void *cls);
530static struct GNUNET_TIME_Relative 530static struct GNUNET_TIME_Relative
531receive (void *cls, const struct GNUNET_PeerIdentity *peer, 531receive (void *cls, const struct GNUNET_PeerIdentity *peer,
532 const struct GNUNET_MessageHeader *message, 532 const struct GNUNET_MessageHeader *message,
533 const struct GNUNET_TRANSPORT_ATS_Information *ats, 533 const struct GNUNET_TRANSPORT_ATS_Information *ats, uint32_t ats_count,
534 uint32_t ats_count, 534 struct Session *session, const char *sender_address,
535 struct Session *session, 535 uint16_t sender_address_len)
536 const char *sender_address, uint16_t sender_address_len)
537{ 536{
538 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 537 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
539 "Testcase recieved new message from peer `%s' with type %u and length %u, session %X\n", 538 "Testcase recieved new message from peer `%s' with type %u and length %u, session %X\n",
540 GNUNET_i2s (peer), 539 GNUNET_i2s (peer), ntohs (message->type), ntohs (message->size),
541 ntohs (message->type), ntohs (message->size), session); 540 session);
542 541
543 if ((ntohs (message->type) >= 10) && (ntohs (message->type) < 20)) 542 if ((ntohs (message->type) >= 10) && (ntohs (message->type) < 20))
544 { 543 {
@@ -689,9 +688,8 @@ send_execute (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
689 688
690 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 689 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
691 _("curl failed for `%s' at %s:%d: `%s'\n"), 690 _("curl failed for `%s' at %s:%d: `%s'\n"),
692 "curl_multi_perform", 691 "curl_multi_perform", __FILE__, __LINE__,
693 __FILE__, 692 curl_easy_strerror (msg->data.result));
694 __LINE__, curl_easy_strerror (msg->data.result));
695 /* sending msg failed */ 693 /* sending msg failed */
696 curl_easy_cleanup (curl_handle); 694 curl_easy_cleanup (curl_handle);
697 curl_handle = NULL; 695 curl_handle = NULL;
@@ -792,8 +790,7 @@ send_prepare (struct HTTP_Transfer *result)
792 mret = curl_multi_fdset (multi_handle, &rs, &ws, &es, &max); 790 mret = curl_multi_fdset (multi_handle, &rs, &ws, &es, &max);
793 if (mret != CURLM_OK) 791 if (mret != CURLM_OK)
794 { 792 {
795 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 793 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("%s failed at %s:%d: `%s'\n"),
796 _("%s failed at %s:%d: `%s'\n"),
797 "curl_multi_fdset", __FILE__, __LINE__, 794 "curl_multi_fdset", __FILE__, __LINE__,
798 curl_multi_strerror (mret)); 795 curl_multi_strerror (mret));
799 return -1; 796 return -1;
@@ -801,8 +798,7 @@ send_prepare (struct HTTP_Transfer *result)
801 mret = curl_multi_timeout (multi_handle, &to); 798 mret = curl_multi_timeout (multi_handle, &to);
802 if (mret != CURLM_OK) 799 if (mret != CURLM_OK)
803 { 800 {
804 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 801 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("%s failed at %s:%d: `%s'\n"),
805 _("%s failed at %s:%d: `%s'\n"),
806 "curl_multi_timeout", __FILE__, __LINE__, 802 "curl_multi_timeout", __FILE__, __LINE__,
807 curl_multi_strerror (mret)); 803 curl_multi_strerror (mret));
808 return -1; 804 return -1;
@@ -918,13 +914,12 @@ notify_address (void *cls, int add_remove, const void *addr, size_t addrlen)
918} 914}
919 915
920static void 916static void
921plugin_env_session_end (void *cls, 917plugin_env_session_end (void *cls, const struct GNUNET_PeerIdentity *peer,
922 const struct GNUNET_PeerIdentity *peer,
923 struct Session *session) 918 struct Session *session)
924{ 919{
925 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 920 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
926 "Pluging tells me: session %X to peer `%s' ended\n", 921 "Pluging tells me: session %X to peer `%s' ended\n", session,
927 session, GNUNET_i2s (peer)); 922 GNUNET_i2s (peer));
928} 923}
929 924
930 925
@@ -967,8 +962,8 @@ pretty_printer_cb (void *cls, const char *address)
967{ 962{
968 if (NULL == address) 963 if (NULL == address)
969 return; 964 return;
970 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 965 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Plugin returned pretty address: `%s'\n",
971 "Plugin returned pretty address: `%s'\n", address); 966 address);
972 fail_pretty_printer_count++; 967 fail_pretty_printer_count++;
973} 968}
974 969
@@ -999,8 +994,8 @@ run_connection_tests (int phase, void *cls)
999 /* Connecting to peer without identification */ 994 /* Connecting to peer without identification */
1000 const char *ident = ""; 995 const char *ident = "";
1001 996
1002 GNUNET_asprintf (&host_str, 997 GNUNET_asprintf (&host_str, "%s://%s/%s", PROTOCOL_PREFIX, test_addr,
1003 "%s://%s/%s", PROTOCOL_PREFIX, test_addr, ident); 998 ident);
1004 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 999 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1005 _("Connecting to peer without any peer identification.\n")); 1000 _("Connecting to peer without any peer identification.\n"));
1006 test_no_ident.test_executed = GNUNET_YES; 1001 test_no_ident.test_executed = GNUNET_YES;
@@ -1013,8 +1008,8 @@ run_connection_tests (int phase, void *cls)
1013 const char *ident = "AAAAAAAAAA"; 1008 const char *ident = "AAAAAAAAAA";
1014 1009
1015 /* Connecting to peer with too short identification */ 1010 /* Connecting to peer with too short identification */
1016 GNUNET_asprintf (&host_str, 1011 GNUNET_asprintf (&host_str, "%s://%s/%s", PROTOCOL_PREFIX, test_addr,
1017 "%s://%s/%s", PROTOCOL_PREFIX, test_addr, ident); 1012 ident);
1018 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1013 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1019 _ 1014 _
1020 ("Connecting to peer with too short peer identification.\n")); 1015 ("Connecting to peer with too short peer identification.\n"));
@@ -1044,9 +1039,8 @@ run_connection_tests (int phase, void *cls)
1044 struct GNUNET_CRYPTO_HashAsciiEncoded ident; 1039 struct GNUNET_CRYPTO_HashAsciiEncoded ident;
1045 1040
1046 GNUNET_CRYPTO_hash_to_enc (&my_identity.hashPubKey, &ident); 1041 GNUNET_CRYPTO_hash_to_enc (&my_identity.hashPubKey, &ident);
1047 GNUNET_asprintf (&host_str, 1042 GNUNET_asprintf (&host_str, "%s://%s/%s%s", PROTOCOL_PREFIX, test_addr,
1048 "%s://%s/%s%s", 1043 (char *) &ident, ";0");
1049 PROTOCOL_PREFIX, test_addr, (char *) &ident, ";0");
1050 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1044 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1051 _("Connecting to peer with valid peer identification.\n")); 1045 _("Connecting to peer with valid peer identification.\n"));
1052 test_valid_ident.test_executed = GNUNET_YES; 1046 test_valid_ident.test_executed = GNUNET_YES;
@@ -1083,8 +1077,8 @@ run_connection_tests (int phase, void *cls)
1083 INET_ADDRSTRLEN); 1077 INET_ADDRSTRLEN);
1084 port = ntohs (((struct IPv4HttpAddress *) tmp_addr->addr)->u_port); 1078 port = ntohs (((struct IPv4HttpAddress *) tmp_addr->addr)->u_port);
1085 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1079 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1086 "Sending message to addres no. %u: `%s':%u\n", 1080 "Sending message to addres no. %u: `%s':%u\n", count,
1087 count, address, port); 1081 address, port);
1088 } 1082 }
1089 if (tmp_addr->addrlen == (sizeof (struct IPv6HttpAddress))) 1083 if (tmp_addr->addrlen == (sizeof (struct IPv6HttpAddress)))
1090 { 1084 {
@@ -1092,19 +1086,15 @@ run_connection_tests (int phase, void *cls)
1092 INET6_ADDRSTRLEN); 1086 INET6_ADDRSTRLEN);
1093 port = ntohs (((struct IPv6HttpAddress *) tmp_addr->addr)->u6_port); 1087 port = ntohs (((struct IPv6HttpAddress *) tmp_addr->addr)->u6_port);
1094 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1088 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1095 "Sending message to addres no. %u: `%s':%u\n", 1089 "Sending message to addres no. %u: `%s':%u\n", count,
1096 count, address, port); 1090 address, port);
1097 } 1091 }
1098 msg.type = htons (type); 1092 msg.type = htons (type);
1099 memcpy (tmp, &msg, sizeof (struct GNUNET_MessageHeader)); 1093 memcpy (tmp, &msg, sizeof (struct GNUNET_MessageHeader));
1100 api->send (api->cls, 1094 api->send (api->cls, &my_identity, tmp,
1101 &my_identity, 1095 sizeof (struct GNUNET_MessageHeader), 0, TIMEOUT, NULL,
1102 tmp, sizeof (struct GNUNET_MessageHeader), 1096 tmp_addr->addr, tmp_addr->addrlen, GNUNET_YES, &task_send_cont,
1103 0, TIMEOUT, 1097 &fail_msgs_transmited_to_local_addrs);
1104 NULL,
1105 tmp_addr->addr, tmp_addr->addrlen,
1106 GNUNET_YES,
1107 &task_send_cont, &fail_msgs_transmited_to_local_addrs);
1108 tmp_addr = tmp_addr->next; 1098 tmp_addr = tmp_addr->next;
1109 count++; 1099 count++;
1110 type++; 1100 type++;
@@ -1123,26 +1113,19 @@ run_connection_tests (int phase, void *cls)
1123 size = sizeof (struct GNUNET_MessageHeader); 1113 size = sizeof (struct GNUNET_MessageHeader);
1124 msg->size = htons (size); 1114 msg->size = htons (size);
1125 msg->type = htons (20); 1115 msg->type = htons (20);
1126 api->send (api->cls, 1116 api->send (api->cls, &my_identity, (const char *) msg, size, 0, TIMEOUT,
1127 &my_identity, 1117 NULL, NULL, 0, GNUNET_NO, &task_send_cont, NULL);
1128 (const char *) msg, size,
1129 0, TIMEOUT, NULL, NULL, 0, GNUNET_NO, &task_send_cont, NULL);
1130 1118
1131 msg->type = htons (21); 1119 msg->type = htons (21);
1132 api->send (api->cls, 1120 api->send (api->cls, &my_identity, (const char *) msg, size, 0, TIMEOUT,
1133 &my_identity, 1121 NULL, NULL, 0, GNUNET_SYSERR, &task_send_cont, NULL);
1134 (const char *) msg, size,
1135 0, TIMEOUT, NULL, NULL, 0, GNUNET_SYSERR, &task_send_cont, NULL);
1136 1122
1137 /* answer on session */ 1123 /* answer on session */
1138 size = sizeof (struct GNUNET_MessageHeader); 1124 size = sizeof (struct GNUNET_MessageHeader);
1139 msg->size = htons (size); 1125 msg->size = htons (size);
1140 msg->type = htons (22); 1126 msg->type = htons (22);
1141 api->send (api->cls, 1127 api->send (api->cls, &my_identity, (const char *) msg, size, 0, TIMEOUT,
1142 &my_identity, 1128 session, NULL, 0, GNUNET_SYSERR, &task_send_cont, NULL);
1143 (const char *) msg, size,
1144 0, TIMEOUT, session, NULL, 0, GNUNET_SYSERR,
1145 &task_send_cont, NULL);
1146 GNUNET_free (msg); 1129 GNUNET_free (msg);
1147 1130
1148 /* answer on session with big message not fitting in mhd send buffer */ 1131 /* answer on session with big message not fitting in mhd send buffer */
@@ -1150,10 +1133,8 @@ run_connection_tests (int phase, void *cls)
1150 msg = GNUNET_malloc (size); 1133 msg = GNUNET_malloc (size);
1151 msg->size = htons (size); 1134 msg->size = htons (size);
1152 msg->type = htons (23); 1135 msg->type = htons (23);
1153 api->send (api->cls, 1136 api->send (api->cls, &my_identity, (const char *) msg, size, 0, TIMEOUT,
1154 &my_identity, 1137 session, NULL, 0, GNUNET_NO, &task_send_cont, NULL);
1155 (const char *) msg, size,
1156 0, TIMEOUT, session, NULL, 0, GNUNET_NO, &task_send_cont, NULL);
1157 GNUNET_free (msg); 1138 GNUNET_free (msg);
1158 return; 1139 return;
1159 } 1140 }
@@ -1178,12 +1159,10 @@ run_connection_tests (int phase, void *cls)
1178 1159
1179 msg2->size = htons (2 * sizeof (struct GNUNET_MessageHeader)); 1160 msg2->size = htons (2 * sizeof (struct GNUNET_MessageHeader));
1180 msg2->type = htons (31); 1161 msg2->type = htons (31);
1181 api->send (api->cls, 1162 api->send (api->cls, &my_identity, (const char *) msg,
1182 &my_identity, 1163 4 * sizeof (struct GNUNET_MessageHeader), 0, TIMEOUT, NULL,
1183 (const char *) msg, 4 * sizeof (struct GNUNET_MessageHeader), 1164 addr_head->addr, addr_head->addrlen, GNUNET_NO, &task_send_cont,
1184 0, TIMEOUT, NULL, 1165 &fail_multiple_msgs_in_transmission);
1185 addr_head->addr, addr_head->addrlen,
1186 GNUNET_NO, &task_send_cont, &fail_multiple_msgs_in_transmission);
1187 GNUNET_free (msg); 1166 GNUNET_free (msg);
1188 /* send a message with size GNUNET_SERVER_MAX_MESSAGE_SIZE-1 */ 1167 /* send a message with size GNUNET_SERVER_MAX_MESSAGE_SIZE-1 */
1189 1168
@@ -1191,12 +1170,9 @@ run_connection_tests (int phase, void *cls)
1191 msg = GNUNET_malloc (size); 1170 msg = GNUNET_malloc (size);
1192 msg->size = htons (size); 1171 msg->size = htons (size);
1193 msg->type = htons (32); 1172 msg->type = htons (32);
1194 api->send (api->cls, 1173 api->send (api->cls, &my_identity, (const char *) msg, size, 0, TIMEOUT,
1195 &my_identity, 1174 NULL, addr_head->addr, addr_head->addrlen, GNUNET_NO,
1196 (const char *) msg, size, 1175 &task_send_cont, &fail_msg_transmited_max_size);
1197 0, TIMEOUT, NULL,
1198 addr_head->addr, addr_head->addrlen,
1199 GNUNET_NO, &task_send_cont, &fail_msg_transmited_max_size);
1200 GNUNET_free (msg); 1176 GNUNET_free (msg);
1201 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "No more tests to run\n"); 1177 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "No more tests to run\n");
1202 } 1178 }
@@ -1210,9 +1186,8 @@ run_connection_tests (int phase, void *cls)
1210 * @param c configuration to use 1186 * @param c configuration to use
1211 */ 1187 */
1212static void 1188static void
1213run (void *cls, 1189run (void *cls, char *const *args, const char *cfgfile,
1214 char *const *args, 1190 const struct GNUNET_CONFIGURATION_Handle *c)
1215 const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *c)
1216{ 1191{
1217 char *libname; 1192 char *libname;
1218 1193
@@ -1244,14 +1219,11 @@ run (void *cls,
1244 &servicehome); 1219 &servicehome);
1245 1220
1246 if ((GNUNET_OK != 1221 if ((GNUNET_OK !=
1247 GNUNET_CONFIGURATION_get_value_number (c, 1222 GNUNET_CONFIGURATION_get_value_number (c, "TRANSPORT", "NEIGHBOUR_LIMIT",
1248 "TRANSPORT",
1249 "NEIGHBOUR_LIMIT",
1250 &tneigh)) || 1223 &tneigh)) ||
1251 (GNUNET_OK != 1224 (GNUNET_OK !=
1252 GNUNET_CONFIGURATION_get_value_filename (c, 1225 GNUNET_CONFIGURATION_get_value_filename (c, "GNUNETD", "HOSTKEY",
1253 "GNUNETD", 1226 &keyfile)))
1254 "HOSTKEY", &keyfile)))
1255 { 1227 {
1256 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 1228 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
1257 _ 1229 _
@@ -1262,14 +1234,11 @@ run (void *cls,
1262 } 1234 }
1263 1235
1264 if ((GNUNET_OK != 1236 if ((GNUNET_OK !=
1265 GNUNET_CONFIGURATION_get_value_number (cfg, 1237 GNUNET_CONFIGURATION_get_value_number (cfg, "transport-http", "PORT",
1266 "transport-http", 1238 &port)) || (port > 65535) ||
1267 "PORT", 1239 (port == 0))
1268 &port)) ||
1269 (port > 65535) || (port == 0))
1270 { 1240 {
1271 GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, 1241 GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, "http",
1272 "http",
1273 _ 1242 _
1274 ("Require valid port number for transport plugin `%s' in configuration!\n"), 1243 ("Require valid port number for transport plugin `%s' in configuration!\n"),
1275 "transport-http"); 1244 "transport-http");
@@ -1297,8 +1266,8 @@ run (void *cls,
1297 /* load plugins... */ 1266 /* load plugins... */
1298 setup_plugin_environment (); 1267 setup_plugin_environment ();
1299 GNUNET_asprintf (&libname, "libgnunet_plugin_transport_http"); 1268 GNUNET_asprintf (&libname, "libgnunet_plugin_transport_http");
1300 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 1269 GNUNET_log (GNUNET_ERROR_TYPE_INFO, _("Loading HTTP transport plugin `%s'\n"),
1301 _("Loading HTTP transport plugin `%s'\n"), libname); 1270 libname);
1302 api = GNUNET_PLUGIN_load (libname, &env); 1271 api = GNUNET_PLUGIN_load (libname, &env);
1303 GNUNET_free (libname); 1272 GNUNET_free (libname);
1304 if (api == NULL) 1273 if (api == NULL)
@@ -1322,9 +1291,9 @@ run (void *cls,
1322 cur = addr_head; 1291 cur = addr_head;
1323 while (cur != NULL) 1292 while (cur != NULL)
1324 { 1293 {
1325 api->address_pretty_printer (api->cls, "http", 1294 api->address_pretty_printer (api->cls, "http", cur->addr, cur->addrlen,
1326 cur->addr, cur->addrlen, GNUNET_NO, 1295 GNUNET_NO, TEST_TIMEOUT, &pretty_printer_cb,
1327 TEST_TIMEOUT, &pretty_printer_cb, NULL); 1296 NULL);
1328 addr_str = api->address_to_string (api->cls, cur->addr, cur->addrlen); 1297 addr_str = api->address_to_string (api->cls, cur->addr, cur->addrlen);
1329 suggest_res = api->check_address (api->cls, cur->addr, cur->addrlen); 1298 suggest_res = api->check_address (api->cls, cur->addr, cur->addrlen);
1330 1299
@@ -1444,12 +1413,11 @@ main (int argc, char *const *argv)
1444 GNUNET_DISK_directory_remove (servicehome); 1413 GNUNET_DISK_directory_remove (servicehome);
1445 GNUNET_CONFIGURATION_destroy (cfg); 1414 GNUNET_CONFIGURATION_destroy (cfg);
1446 1415
1447 ret = (GNUNET_OK == 1416 ret =
1448 GNUNET_PROGRAM_run (5, 1417 (GNUNET_OK ==
1449 argv_prog, 1418 GNUNET_PROGRAM_run (5, argv_prog, "test_gnunet_transport_plugin_http",
1450 "test_gnunet_transport_plugin_http", 1419 "testcase", options, &run,
1451 "testcase", options, &run, 1420 NULL)) ? GNUNET_NO : GNUNET_YES;
1452 NULL)) ? GNUNET_NO : GNUNET_YES;
1453 1421
1454 if (servicehome != NULL) 1422 if (servicehome != NULL)
1455 { 1423 {
diff --git a/src/transport/test_plugin_transport_https.c b/src/transport/test_plugin_transport_https.c
index e6e71c7f5..5b78f89b4 100644
--- a/src/transport/test_plugin_transport_https.c
+++ b/src/transport/test_plugin_transport_https.c
@@ -559,10 +559,9 @@ static void run_connection_tests (int phase, void *cls);
559static struct GNUNET_TIME_Relative 559static struct GNUNET_TIME_Relative
560receive (void *cls, const struct GNUNET_PeerIdentity *peer, 560receive (void *cls, const struct GNUNET_PeerIdentity *peer,
561 const struct GNUNET_MessageHeader *message, 561 const struct GNUNET_MessageHeader *message,
562 const struct GNUNET_TRANSPORT_ATS_Information *ats, 562 const struct GNUNET_TRANSPORT_ATS_Information *ats, uint32_t ats_count,
563 uint32_t ats_count, 563 struct Session *session, const char *sender_address,
564 struct Session *session, 564 uint16_t sender_address_len)
565 const char *sender_address, uint16_t sender_address_len)
566{ 565{
567 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 566 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
568 "Testcase recieved new message from peer `%s' with type %u and length %u, session %X\n", 567 "Testcase recieved new message from peer `%s' with type %u and length %u, session %X\n",
@@ -723,9 +722,8 @@ send_execute (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
723 722
724 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 723 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
725 _("curl failed for `%s' at %s:%d: `%s'\n"), 724 _("curl failed for `%s' at %s:%d: `%s'\n"),
726 "curl_multi_perform", 725 "curl_multi_perform", __FILE__, __LINE__,
727 __FILE__, 726 curl_easy_strerror (msg->data.result));
728 __LINE__, curl_easy_strerror (msg->data.result));
729 /* sending msg failed */ 727 /* sending msg failed */
730 curl_easy_cleanup (curl_handle); 728 curl_easy_cleanup (curl_handle);
731 curl_handle = NULL; 729 curl_handle = NULL;
@@ -826,8 +824,7 @@ send_prepare (struct HTTP_Transfer *result)
826 mret = curl_multi_fdset (multi_handle, &rs, &ws, &es, &max); 824 mret = curl_multi_fdset (multi_handle, &rs, &ws, &es, &max);
827 if (mret != CURLM_OK) 825 if (mret != CURLM_OK)
828 { 826 {
829 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 827 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("%s failed at %s:%d: `%s'\n"),
830 _("%s failed at %s:%d: `%s'\n"),
831 "curl_multi_fdset", __FILE__, __LINE__, 828 "curl_multi_fdset", __FILE__, __LINE__,
832 curl_multi_strerror (mret)); 829 curl_multi_strerror (mret));
833 return -1; 830 return -1;
@@ -835,8 +832,7 @@ send_prepare (struct HTTP_Transfer *result)
835 mret = curl_multi_timeout (multi_handle, &to); 832 mret = curl_multi_timeout (multi_handle, &to);
836 if (mret != CURLM_OK) 833 if (mret != CURLM_OK)
837 { 834 {
838 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 835 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("%s failed at %s:%d: `%s'\n"),
839 _("%s failed at %s:%d: `%s'\n"),
840 "curl_multi_timeout", __FILE__, __LINE__, 836 "curl_multi_timeout", __FILE__, __LINE__,
841 curl_multi_strerror (mret)); 837 curl_multi_strerror (mret));
842 return -1; 838 return -1;
@@ -955,8 +951,7 @@ notify_address (void *cls, int add_remove, const void *addr, size_t addrlen)
955} 951}
956 952
957static void 953static void
958plugin_env_session_end (void *cls, 954plugin_env_session_end (void *cls, const struct GNUNET_PeerIdentity *peer,
959 const struct GNUNET_PeerIdentity *peer,
960 struct Session *session) 955 struct Session *session)
961{ 956{
962 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 957 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
@@ -1230,9 +1225,8 @@ run_connection_tests (int phase, void *cls)
1230 * @param c configuration to use 1225 * @param c configuration to use
1231 */ 1226 */
1232static void 1227static void
1233run (void *cls, 1228run (void *cls, char *const *args, const char *cfgfile,
1234 char *const *args, 1229 const struct GNUNET_CONFIGURATION_Handle *c)
1235 const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *c)
1236{ 1230{
1237 char *libname; 1231 char *libname;
1238 1232
@@ -1264,14 +1258,11 @@ run (void *cls,
1264 1258
1265 1259
1266 if ((GNUNET_OK != 1260 if ((GNUNET_OK !=
1267 GNUNET_CONFIGURATION_get_value_number (c, 1261 GNUNET_CONFIGURATION_get_value_number (c, "TRANSPORT", "NEIGHBOUR_LIMIT",
1268 "TRANSPORT",
1269 "NEIGHBOUR_LIMIT",
1270 &tneigh)) || 1262 &tneigh)) ||
1271 (GNUNET_OK != 1263 (GNUNET_OK !=
1272 GNUNET_CONFIGURATION_get_value_filename (c, 1264 GNUNET_CONFIGURATION_get_value_filename (c, "GNUNETD", "HOSTKEY",
1273 "GNUNETD", 1265 &keyfile)))
1274 "HOSTKEY", &keyfile)))
1275 { 1266 {
1276 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 1267 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
1277 _ 1268 _
@@ -1282,14 +1273,11 @@ run (void *cls,
1282 } 1273 }
1283 1274
1284 if ((GNUNET_OK != 1275 if ((GNUNET_OK !=
1285 GNUNET_CONFIGURATION_get_value_number (cfg, 1276 GNUNET_CONFIGURATION_get_value_number (cfg, "transport-https", "PORT",
1286 "transport-https", 1277 &port)) || (port > 65535) ||
1287 "PORT", 1278 (port == 0))
1288 &port)) ||
1289 (port > 65535) || (port == 0))
1290 { 1279 {
1291 GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, 1280 GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, "https",
1292 "https",
1293 _ 1281 _
1294 ("Require valid port number for transport plugin `%s' in configuration!\n"), 1282 ("Require valid port number for transport plugin `%s' in configuration!\n"),
1295 "transport-http"); 1283 "transport-http");
@@ -1298,9 +1286,8 @@ run (void *cls,
1298 /* Get private key file from config */ 1286 /* Get private key file from config */
1299 if (GNUNET_CONFIGURATION_have_value (cfg, "transport-https", "KEY_FILE")) 1287 if (GNUNET_CONFIGURATION_have_value (cfg, "transport-https", "KEY_FILE"))
1300 { 1288 {
1301 GNUNET_CONFIGURATION_get_value_string (cfg, 1289 GNUNET_CONFIGURATION_get_value_string (cfg, "transport-https", "KEY_FILE",
1302 "transport-https", 1290 &key_file);
1303 "KEY_FILE", &key_file);
1304 } 1291 }
1305 if (key_file == NULL) 1292 if (key_file == NULL)
1306 GNUNET_asprintf (&key_file, "https.key"); 1293 GNUNET_asprintf (&key_file, "https.key");
@@ -1319,9 +1306,8 @@ run (void *cls,
1319 /* Get private key file from config */ 1306 /* Get private key file from config */
1320 if (GNUNET_CONFIGURATION_have_value (cfg, "transport-https", "CERT_FILE")) 1307 if (GNUNET_CONFIGURATION_have_value (cfg, "transport-https", "CERT_FILE"))
1321 { 1308 {
1322 GNUNET_CONFIGURATION_get_value_string (cfg, 1309 GNUNET_CONFIGURATION_get_value_string (cfg, "transport-https", "CERT_FILE",
1323 "transport-https", 1310 &cert_file);
1324 "CERT_FILE", &cert_file);
1325 } 1311 }
1326 if (cert_file == NULL) 1312 if (cert_file == NULL)
1327 GNUNET_asprintf (&cert_file, "https.cert"); 1313 GNUNET_asprintf (&cert_file, "https.cert");
@@ -1511,12 +1497,11 @@ main (int argc, char *const *argv)
1511 GNUNET_DISK_directory_remove (servicehome); 1497 GNUNET_DISK_directory_remove (servicehome);
1512 GNUNET_CONFIGURATION_destroy (cfg); 1498 GNUNET_CONFIGURATION_destroy (cfg);
1513 1499
1514 ret = (GNUNET_OK == 1500 ret =
1515 GNUNET_PROGRAM_run (5, 1501 (GNUNET_OK ==
1516 argv_prog, 1502 GNUNET_PROGRAM_run (5, argv_prog, "test_gnunet_transport_plugin.https",
1517 "test_gnunet_transport_plugin.https", 1503 "testcase", options, &run,
1518 "testcase", options, &run, 1504 NULL)) ? GNUNET_NO : GNUNET_YES;
1519 NULL)) ? GNUNET_NO : GNUNET_YES;
1520 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("\ndelete\n\n")); 1505 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("\ndelete\n\n"));
1521 if (servicehome != NULL) 1506 if (servicehome != NULL)
1522 { 1507 {
diff --git a/src/transport/test_plugin_transport_udp.c b/src/transport/test_plugin_transport_udp.c
index b23d4eb67..8fbd2ab9c 100644
--- a/src/transport/test_plugin_transport_udp.c
+++ b/src/transport/test_plugin_transport_udp.c
@@ -89,20 +89,16 @@ static int ok;
89 * Initialize Environment for this plugin 89 * Initialize Environment for this plugin
90 */ 90 */
91static void 91static void
92receive (void *cls, 92receive (void *cls, const struct GNUNET_PeerIdentity *peer,
93 const struct GNUNET_PeerIdentity *peer, 93 const struct GNUNET_MessageHeader *message, uint32_t distance,
94 const struct GNUNET_MessageHeader *message,
95 uint32_t distance,
96 const char *sender_address, size_t sender_address_len) 94 const char *sender_address, size_t sender_address_len)
97{ 95{
98 /* do nothing */ 96 /* do nothing */
99} 97}
100 98
101void 99void
102notify_address (void *cls, 100notify_address (void *cls, const char *name, const void *addr, size_t addrlen,
103 const char *name, 101 struct GNUNET_TIME_Relative expires)
104 const void *addr,
105 size_t addrlen, struct GNUNET_TIME_Relative expires)
106{ 102{
107} 103}
108 104
@@ -168,9 +164,8 @@ setup_plugin_environment ()
168 * @param c configuration to use 164 * @param c configuration to use
169 */ 165 */
170static void 166static void
171run (void *cls, 167run (void *cls, char *const *args, const char *cfgfile,
172 char *const *args, 168 const struct GNUNET_CONFIGURATION_Handle *c)
173 const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *c)
174{ 169{
175 unsigned long long tneigh; 170 unsigned long long tneigh;
176 char *keyfile; 171 char *keyfile;
@@ -179,14 +174,11 @@ run (void *cls,
179 cfg = c; 174 cfg = c;
180 /* parse configuration */ 175 /* parse configuration */
181 if ((GNUNET_OK != 176 if ((GNUNET_OK !=
182 GNUNET_CONFIGURATION_get_value_number (c, 177 GNUNET_CONFIGURATION_get_value_number (c, "TRANSPORT", "NEIGHBOUR_LIMIT",
183 "TRANSPORT",
184 "NEIGHBOUR_LIMIT",
185 &tneigh)) || 178 &tneigh)) ||
186 (GNUNET_OK != 179 (GNUNET_OK !=
187 GNUNET_CONFIGURATION_get_value_filename (c, 180 GNUNET_CONFIGURATION_get_value_filename (c, "GNUNETD", "HOSTKEY",
188 "GNUNETD", 181 &keyfile)))
189 "HOSTKEY", &keyfile)))
190 { 182 {
191 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 183 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
192 _ 184 _
@@ -205,8 +197,8 @@ run (void *cls,
205 return; 197 return;
206 } 198 }
207 GNUNET_CRYPTO_rsa_key_get_public (my_private_key, &my_public_key); 199 GNUNET_CRYPTO_rsa_key_get_public (my_private_key, &my_public_key);
208 GNUNET_CRYPTO_hash (&my_public_key, 200 GNUNET_CRYPTO_hash (&my_public_key, sizeof (my_public_key),
209 sizeof (my_public_key), &my_identity.hashPubKey); 201 &my_identity.hashPubKey);
210 202
211 /* load plugins... */ 203 /* load plugins... */
212 setup_plugin_environment (); 204 setup_plugin_environment ();
@@ -261,11 +253,10 @@ main (int argc, char *const *argv)
261#endif 253#endif
262 NULL); 254 NULL);
263 ok = 1; /* set to fail */ 255 ok = 1; /* set to fail */
264 ret = (GNUNET_OK == 256 ret =
265 GNUNET_PROGRAM_run (5, 257 (GNUNET_OK ==
266 argv_prog, 258 GNUNET_PROGRAM_run (5, argv_prog, "test-plugin-transport", "testcase",
267 "test-plugin-transport", 259 options, &run, NULL)) ? ok : 1;
268 "testcase", options, &run, NULL)) ? ok : 1;
269 GNUNET_DISK_directory_remove ("/tmp/test-gnunetd-plugin-transport"); 260 GNUNET_DISK_directory_remove ("/tmp/test-gnunetd-plugin-transport");
270 return ret; 261 return ret;
271} 262}
diff --git a/src/transport/test_plugin_transport_wlan_dummy.c b/src/transport/test_plugin_transport_wlan_dummy.c
index eba4f9dbd..03dedbe4d 100644
--- a/src/transport/test_plugin_transport_wlan_dummy.c
+++ b/src/transport/test_plugin_transport_wlan_dummy.c
@@ -72,8 +72,9 @@ stdin_send (void *cls, void *client, const struct GNUNET_MessageHeader *hdr)
72 char *to_radiotap; 72 char *to_radiotap;
73 char *to_start; 73 char *to_start;
74 74
75 sendsize = ntohs (hdr->size) - sizeof (struct Radiotap_Send) 75 sendsize =
76 + sizeof (struct Radiotap_rx); 76 ntohs (hdr->size) - sizeof (struct Radiotap_Send) +
77 sizeof (struct Radiotap_rx);
77 78
78 if (GNUNET_MESSAGE_TYPE_WLAN_HELPER_DATA != ntohs (hdr->type)) 79 if (GNUNET_MESSAGE_TYPE_WLAN_HELPER_DATA != ntohs (hdr->type))
79 { 80 {
@@ -335,9 +336,9 @@ testmode (int argc, char *argv[])
335 336
336 if (FD_ISSET (STDOUT_FILENO, &wfds)) 337 if (FD_ISSET (STDOUT_FILENO, &wfds))
337 { 338 {
338 ret = write (STDOUT_FILENO, 339 ret =
339 write_std.buf + write_std.pos, 340 write (STDOUT_FILENO, write_std.buf + write_std.pos,
340 write_std.size - write_std.pos); 341 write_std.size - write_std.pos);
341 if (0 > ret) 342 if (0 > ret)
342 { 343 {
343 closeprog = 1; 344 closeprog = 1;
@@ -358,9 +359,9 @@ testmode (int argc, char *argv[])
358 359
359 if (FD_ISSET (fdpout, &wfds)) 360 if (FD_ISSET (fdpout, &wfds))
360 { 361 {
361 ret = write (fdpout, 362 ret =
362 write_pout.buf + write_pout.pos, 363 write (fdpout, write_pout.buf + write_pout.pos,
363 write_pout.size - write_pout.pos); 364 write_pout.size - write_pout.pos);
364 365
365 if (0 > ret) 366 if (0 > ret)
366 { 367 {
@@ -453,9 +454,8 @@ main (int argc, char *argv[])
453 fprintf (stderr, 454 fprintf (stderr,
454 "This program must be started with the operating mode as argument.\n"); 455 "This program must be started with the operating mode as argument.\n");
455 fprintf (stderr, 456 fprintf (stderr,
456 "Usage: options\n" 457 "Usage: options\n" "options:\n" "1 = first loopback file\n"
457 "options:\n" 458 "2 = second loopback file\n" "\n");
458 "1 = first loopback file\n" "2 = second loopback file\n" "\n");
459 return 1; 459 return 1;
460 } 460 }
461 if (strstr (argv[1], "1") || strstr (argv[1], "2")) 461 if (strstr (argv[1], "1") || strstr (argv[1], "2"))
diff --git a/src/transport/test_quota_compliance.c b/src/transport/test_quota_compliance.c
index e4638e4fc..bc2aca31b 100644
--- a/src/transport/test_quota_compliance.c
+++ b/src/transport/test_quota_compliance.c
@@ -232,8 +232,7 @@ get_size ()
232} 232}
233 233
234static void 234static void
235notify_receive_new (void *cls, 235notify_receive_new (void *cls, const struct GNUNET_PeerIdentity *peer,
236 const struct GNUNET_PeerIdentity *peer,
237 const struct GNUNET_MessageHeader *message, 236 const struct GNUNET_MessageHeader *message,
238 const struct GNUNET_TRANSPORT_ATS_Information *ats, 237 const struct GNUNET_TRANSPORT_ATS_Information *ats,
239 uint32_t ats_count) 238 uint32_t ats_count)
@@ -250,8 +249,7 @@ notify_receive_new (void *cls,
250#if DEBUG_MEASUREMENT 249#if DEBUG_MEASUREMENT
251 if (ntohl (hdr->num) % 5000 == 0) 250 if (ntohl (hdr->num) % 5000 == 0)
252 { 251 {
253 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 252 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Got message %u of size %u\n",
254 "Got message %u of size %u\n",
255 ntohl (hdr->num), ntohs (message->size)); 253 ntohl (hdr->num), ntohs (message->size));
256 } 254 }
257#endif 255#endif
@@ -309,11 +307,9 @@ notify_ready (void *cls, size_t size, void *buf)
309 break; /* sometimes pack buffer full, sometimes not */ 307 break; /* sometimes pack buffer full, sometimes not */
310 } 308 }
311 while (size - ret >= s); 309 while (size - ret >= s);
312 transmit_handle = GNUNET_TRANSPORT_notify_transmit_ready (p2.th, 310 transmit_handle =
313 &p1.id, 311 GNUNET_TRANSPORT_notify_transmit_ready (p2.th, &p1.id, s, 0, SEND_TIMEOUT,
314 s, 0, SEND_TIMEOUT, 312 &notify_ready, NULL);
315 &notify_ready,
316 NULL);
317 total_bytes_sent += s; 313 total_bytes_sent += s;
318 return ret; 314 return ret;
319} 315}
@@ -348,9 +344,9 @@ measurement_end (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
348 return; 344 return;
349 345
350 measurement_running = GNUNET_NO; 346 measurement_running = GNUNET_NO;
351 struct GNUNET_TIME_Relative duration 347 struct GNUNET_TIME_Relative duration =
352 = GNUNET_TIME_absolute_get_difference (start_time, 348 GNUNET_TIME_absolute_get_difference (start_time,
353 GNUNET_TIME_absolute_get ()); 349 GNUNET_TIME_absolute_get ());
354 350
355 351
356 if (measurement_counter_task != GNUNET_SCHEDULER_NO_TASK) 352 if (measurement_counter_task != GNUNET_SCHEDULER_NO_TASK)
@@ -435,10 +431,8 @@ measurement_end (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
435 else 431 else
436 { 432 {
437 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 433 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
438 "\nQuota compliance ok: \n" 434 "\nQuota compliance ok: \n" "Quota allowed: %10llu kB/s\n"
439 "Quota allowed: %10llu kB/s\n" 435 "Throughput : %10llu kB/s\n", (quota_allowed / (1024)),
440 "Throughput : %10llu kB/s\n",
441 (quota_allowed / (1024)),
442 (total_bytes_sent / (duration.rel_value / 1000) / 1024)); 436 (total_bytes_sent / (duration.rel_value / 1000) / 1024));
443 if (failed_measurement_counter < 2) 437 if (failed_measurement_counter < 2)
444 failed_measurement_counter++; 438 failed_measurement_counter++;
@@ -509,12 +503,10 @@ measure (unsigned long long quota_p1, unsigned long long quota_p2)
509 current_quota_p2 / 1024); 503 current_quota_p2 / 1024);
510 504
511#endif 505#endif
512 GNUNET_TRANSPORT_set_quota (p1.th, 506 GNUNET_TRANSPORT_set_quota (p1.th, &p2.id,
513 &p2.id,
514 GNUNET_BANDWIDTH_value_init (current_quota_p1), 507 GNUNET_BANDWIDTH_value_init (current_quota_p1),
515 GNUNET_BANDWIDTH_value_init (current_quota_p1)); 508 GNUNET_BANDWIDTH_value_init (current_quota_p1));
516 GNUNET_TRANSPORT_set_quota (p2.th, 509 GNUNET_TRANSPORT_set_quota (p2.th, &p1.id,
517 &p1.id,
518 GNUNET_BANDWIDTH_value_init (current_quota_p2), 510 GNUNET_BANDWIDTH_value_init (current_quota_p2),
519 GNUNET_BANDWIDTH_value_init (current_quota_p2)); 511 GNUNET_BANDWIDTH_value_init (current_quota_p2));
520 GNUNET_SCHEDULER_cancel (die_task); 512 GNUNET_SCHEDULER_cancel (die_task);
@@ -535,12 +527,10 @@ measure (unsigned long long quota_p1, unsigned long long quota_p2)
535 527
536 if (transmit_handle != NULL) 528 if (transmit_handle != NULL)
537 GNUNET_TRANSPORT_notify_transmit_ready_cancel (transmit_handle); 529 GNUNET_TRANSPORT_notify_transmit_ready_cancel (transmit_handle);
538 transmit_handle = GNUNET_TRANSPORT_notify_transmit_ready (p2.th, 530 transmit_handle =
539 &p1.id, 531 GNUNET_TRANSPORT_notify_transmit_ready (p2.th, &p1.id, get_size (), 0,
540 get_size (), 0, 532 SEND_TIMEOUT, &notify_ready,
541 SEND_TIMEOUT, 533 NULL);
542 &notify_ready,
543 NULL);
544} 534}
545 535
546 536
@@ -584,8 +574,7 @@ exchange_hello (void *cls, const struct GNUNET_MessageHeader *message)
584 574
585 575
586static void 576static void
587notify_connect (void *cls, 577notify_connect (void *cls, const struct GNUNET_PeerIdentity *peer,
588 const struct GNUNET_PeerIdentity *peer,
589 const struct GNUNET_TRANSPORT_ATS_Information *ats, 578 const struct GNUNET_TRANSPORT_ATS_Information *ats,
590 uint32_t ats_count) 579 uint32_t ats_count)
591{ 580{
@@ -593,15 +582,15 @@ notify_connect (void *cls,
593 if (cls == &p1) 582 if (cls == &p1)
594 { 583 {
595#if DEBUG_CONNECTIONS 584#if DEBUG_CONNECTIONS
596 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 585 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer 1 `%4s' connected to us (%p)!\n",
597 "Peer 1 `%4s' connected to us (%p)!\n", GNUNET_i2s (peer), cls); 586 GNUNET_i2s (peer), cls);
598#endif 587#endif
599 } 588 }
600 else 589 else
601 { 590 {
602#if DEBUG_CONNECTIONS 591#if DEBUG_CONNECTIONS
603 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 592 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer 2 `%4s' connected to us (%p)!\n",
604 "Peer 2 `%4s' connected to us (%p)!\n", GNUNET_i2s (peer), cls); 593 GNUNET_i2s (peer), cls);
605#endif 594#endif
606 } 595 }
607 if (connected == 2) 596 if (connected == 2)
@@ -636,8 +625,8 @@ notify_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer)
636 } 625 }
637 connected--; 626 connected--;
638#if DEBUG_CONNECTIONS 627#if DEBUG_CONNECTIONS
639 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 628 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer `%4s' disconnected (%p)!\n",
640 "Peer `%4s' disconnected (%p)!\n", GNUNET_i2s (peer), cls); 629 GNUNET_i2s (peer), cls);
641#endif 630#endif
642} 631}
643 632
@@ -655,19 +644,18 @@ setup_peer (struct PeerContext *p, const char *cfgname)
655 } 644 }
656 645
657#if START_ARM 646#if START_ARM
658 p->arm_proc = GNUNET_OS_start_process (NULL, NULL, 647 p->arm_proc =
659 "gnunet-service-arm", 648 GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm",
660 "gnunet-service-arm", 649 "gnunet-service-arm",
661#if VERBOSE_ARM 650#if VERBOSE_ARM
662 "-L", "DEBUG", 651 "-L", "DEBUG",
663#endif 652#endif
664 "-c", cfgname, NULL); 653 "-c", cfgname, NULL);
665#endif 654#endif
666 655
667 p->th = GNUNET_TRANSPORT_connect (p->cfg, NULL, 656 p->th =
668 p, 657 GNUNET_TRANSPORT_connect (p->cfg, NULL, p, &notify_receive_new,
669 &notify_receive_new, 658 &notify_connect, &notify_disconnect);
670 &notify_connect, &notify_disconnect);
671 GNUNET_assert (p->th != NULL); 659 GNUNET_assert (p->th != NULL);
672} 660}
673 661
@@ -680,15 +668,15 @@ try_connect (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
680#endif 668#endif
681 GNUNET_TRANSPORT_try_connect (p2.th, &p1.id); 669 GNUNET_TRANSPORT_try_connect (p2.th, &p1.id);
682 GNUNET_TRANSPORT_try_connect (p1.th, &p2.id); 670 GNUNET_TRANSPORT_try_connect (p1.th, &p2.id);
683 tct = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, 671 tct =
684 &try_connect, NULL); 672 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, &try_connect,
673 NULL);
685} 674}
686 675
687 676
688static void 677static void
689run (void *cls, 678run (void *cls, char *const *args, const char *cfgfile,
690 char *const *args, 679 const struct GNUNET_CONFIGURATION_Handle *cfg)
691 const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg)
692{ 680{
693 GNUNET_assert (ok == 1); 681 GNUNET_assert (ok == 1);
694 OKPP; 682 OKPP;
@@ -924,8 +912,8 @@ main (int argc, char *argv[])
924 GNUNET_GETOPT_OPTION_END 912 GNUNET_GETOPT_OPTION_END
925 }; 913 };
926 ok = 1; 914 ok = 1;
927 GNUNET_PROGRAM_run ((sizeof (argv1) / sizeof (char *)) - 1, 915 GNUNET_PROGRAM_run ((sizeof (argv1) / sizeof (char *)) - 1, argv1, logger,
928 argv1, logger, "nohelp", options, &run, &ok); 916 "nohelp", options, &run, &ok);
929 ret = ok; 917 ret = ok;
930 stop_arm (&p1); 918 stop_arm (&p1);
931 stop_arm (&p2); 919 stop_arm (&p2);
diff --git a/src/transport/test_transport_api.c b/src/transport/test_transport_api.c
index f9ac6a8e5..02d80d410 100644
--- a/src/transport/test_transport_api.c
+++ b/src/transport/test_transport_api.c
@@ -115,8 +115,7 @@ end_badly ()
115 115
116 116
117static void 117static void
118notify_receive (void *cls, 118notify_receive (void *cls, const struct GNUNET_PeerIdentity *peer,
119 const struct GNUNET_PeerIdentity *peer,
120 const struct GNUNET_MessageHeader *message, 119 const struct GNUNET_MessageHeader *message,
121 const struct GNUNET_TRANSPORT_ATS_Information *ats, 120 const struct GNUNET_TRANSPORT_ATS_Information *ats,
122 uint32_t ats_count) 121 uint32_t ats_count)
@@ -164,30 +163,27 @@ notify_ready (void *cls, size_t size, void *buf)
164 163
165 164
166static void 165static void
167notify_connect (void *cls, 166notify_connect (void *cls, const struct GNUNET_PeerIdentity *peer,
168 const struct GNUNET_PeerIdentity *peer,
169 const struct GNUNET_TRANSPORT_ATS_Information *ats, 167 const struct GNUNET_TRANSPORT_ATS_Information *ats,
170 uint32_t ats_count) 168 uint32_t ats_count)
171{ 169{
172 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 170 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer `%4s' connected to us (%p)!\n",
173 "Peer `%4s' connected to us (%p)!\n", GNUNET_i2s (peer), cls); 171 GNUNET_i2s (peer), cls);
174} 172}
175 173
176 174
177static void 175static void
178notify_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer) 176notify_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer)
179{ 177{
180 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 178 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer `%4s' disconnected (%p)!\n",
181 "Peer `%4s' disconnected (%p)!\n", GNUNET_i2s (peer), cls); 179 GNUNET_i2s (peer), cls);
182} 180}
183 181
184static void 182static void
185sendtask () 183sendtask ()
186{ 184{
187 th = GNUNET_TRANSPORT_notify_transmit_ready (p1->th, 185 th = GNUNET_TRANSPORT_notify_transmit_ready (p1->th, &p2->id, 256, 0, TIMEOUT,
188 &p2->id, 186 &notify_ready, &p1);
189 256, 0, TIMEOUT, &notify_ready,
190 &p1);
191} 187}
192 188
193static void 189static void
@@ -195,8 +191,8 @@ testing_connect_cb (struct PeerContext *p1, struct PeerContext *p2, void *cls)
195{ 191{
196 char *p1_c = strdup (GNUNET_i2s (&p1->id)); 192 char *p1_c = strdup (GNUNET_i2s (&p1->id));
197 193
198 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peers connected: %s <-> %s\n", 194 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peers connected: %s <-> %s\n", p1_c,
199 p1_c, GNUNET_i2s (&p2->id)); 195 GNUNET_i2s (&p2->id));
200 GNUNET_free (p1_c); 196 GNUNET_free (p1_c);
201 197
202 // FIXME: THIS IS REQUIRED! SEEMS TO BE A BUG! 198 // FIXME: THIS IS REQUIRED! SEEMS TO BE A BUG!
@@ -204,20 +200,17 @@ testing_connect_cb (struct PeerContext *p1, struct PeerContext *p2, void *cls)
204} 200}
205 201
206static void 202static void
207run (void *cls, 203run (void *cls, char *const *args, const char *cfgfile,
208 char *const *args, 204 const struct GNUNET_CONFIGURATION_Handle *cfg)
209 const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg)
210{ 205{
211 die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly, NULL); 206 die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly, NULL);
212 207
213 p1 = GNUNET_TRANSPORT_TESTING_start_peer (cfg_file_p1, 208 p1 = GNUNET_TRANSPORT_TESTING_start_peer (cfg_file_p1, &notify_receive,
214 &notify_receive, 209 &notify_connect, &notify_disconnect,
215 &notify_connect, 210 NULL);
216 &notify_disconnect, NULL); 211 p2 = GNUNET_TRANSPORT_TESTING_start_peer (cfg_file_p2, &notify_receive,
217 p2 = GNUNET_TRANSPORT_TESTING_start_peer (cfg_file_p2, 212 &notify_connect, &notify_disconnect,
218 &notify_receive, 213 NULL);
219 &notify_connect,
220 &notify_disconnect, NULL);
221 214
222 GNUNET_TRANSPORT_TESTING_connect_peers (p1, p2, &testing_connect_cb, NULL); 215 GNUNET_TRANSPORT_TESTING_connect_peers (p1, p2, &testing_connect_cb, NULL);
223} 216}
@@ -241,8 +234,8 @@ check ()
241 setTransportOptions ("test_transport_api_data.conf"); 234 setTransportOptions ("test_transport_api_data.conf");
242#endif 235#endif
243 ok = 1; 236 ok = 1;
244 GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, 237 GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, argv,
245 argv, "test-transport-api", "nohelp", options, &run, &ok); 238 "test-transport-api", "nohelp", options, &run, &ok);
246 239
247 return ok; 240 return ok;
248} 241}
@@ -332,8 +325,8 @@ check_gnunet_nat_binary (char *binary)
332 } 325 }
333 if (0 != STAT (p, &statbuf)) 326 if (0 != STAT (p, &statbuf))
334 { 327 {
335 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 328 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, _("stat (%s) failed: %s\n"), p,
336 _("stat (%s) failed: %s\n"), p, STRERROR (errno)); 329 STRERROR (errno));
337 GNUNET_free (p); 330 GNUNET_free (p);
338 return GNUNET_SYSERR; 331 return GNUNET_SYSERR;
339 } 332 }
diff --git a/src/transport/test_transport_api_disconnect.c b/src/transport/test_transport_api_disconnect.c
index 08f57b670..daae553b7 100644
--- a/src/transport/test_transport_api_disconnect.c
+++ b/src/transport/test_transport_api_disconnect.c
@@ -185,8 +185,7 @@ end_badly ()
185 185
186 186
187static void 187static void
188notify_receive (void *cls, 188notify_receive (void *cls, const struct GNUNET_PeerIdentity *peer,
189 const struct GNUNET_PeerIdentity *peer,
190 const struct GNUNET_MessageHeader *message, 189 const struct GNUNET_MessageHeader *message,
191 const struct GNUNET_TRANSPORT_ATS_Information *ats, 190 const struct GNUNET_TRANSPORT_ATS_Information *ats,
192 uint32_t ats_count) 191 uint32_t ats_count)
@@ -201,8 +200,8 @@ notify_receive (void *cls,
201 msgs_recv++; 200 msgs_recv++;
202} 201}
203 202
204static void 203static void peers_disconnect (void *cls,
205peers_disconnect (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc); 204 const struct GNUNET_SCHEDULER_TaskContext *tc);
206 205
207static size_t 206static size_t
208notify_ready (void *cls, size_t size, void *buf) 207notify_ready (void *cls, size_t size, void *buf)
@@ -231,13 +230,12 @@ notify_ready (void *cls, size_t size, void *buf)
231 230
232 231
233static void 232static void
234notify_connect (void *cls, 233notify_connect (void *cls, const struct GNUNET_PeerIdentity *peer,
235 const struct GNUNET_PeerIdentity *peer,
236 const struct GNUNET_TRANSPORT_ATS_Information *ats, 234 const struct GNUNET_TRANSPORT_ATS_Information *ats,
237 uint32_t ats_count) 235 uint32_t ats_count)
238{ 236{
239 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 237 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer `%4s' connected to us (%p)!\n",
240 "Peer `%4s' connected to us (%p)!\n", GNUNET_i2s (peer), cls); 238 GNUNET_i2s (peer), cls);
241 peers_connected++; 239 peers_connected++;
242 if (cls == &p1) 240 if (cls == &p1)
243 { 241 {
@@ -250,12 +248,10 @@ notify_connect (void *cls,
250 GNUNET_SCHEDULER_cancel (tct); 248 GNUNET_SCHEDULER_cancel (tct);
251 tct = GNUNET_SCHEDULER_NO_TASK; 249 tct = GNUNET_SCHEDULER_NO_TASK;
252 250
253 die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT_TRANSMIT, 251 die_task =
254 &end_badly, NULL); 252 GNUNET_SCHEDULER_add_delayed (TIMEOUT_TRANSMIT, &end_badly, NULL);
255 th = GNUNET_TRANSPORT_notify_transmit_ready (p1.th, 253 th = GNUNET_TRANSPORT_notify_transmit_ready (p1.th, &p2.id, 256, 0, TIMEOUT,
256 &p2.id, 254 &notify_ready, &p1);
257 256, 0, TIMEOUT, &notify_ready,
258 &p1);
259 } 255 }
260} 256}
261 257
@@ -263,8 +259,8 @@ notify_connect (void *cls,
263static void 259static void
264notify_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer) 260notify_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer)
265{ 261{
266 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 262 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer `%4s' disconnected (%p)!\n",
267 "Peer `%4s' disconnected (%p)!\n", GNUNET_i2s (peer), cls); 263 GNUNET_i2s (peer), cls);
268 peers_connected--; 264 peers_connected--;
269} 265}
270 266
@@ -282,12 +278,13 @@ setup_peer (struct PeerContext *p, const char *cfgname)
282 GNUNET_DISK_directory_remove (p->servicehome); 278 GNUNET_DISK_directory_remove (p->servicehome);
283 279
284#if START_ARM 280#if START_ARM
285 p->arm_proc = GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm", 281 p->arm_proc =
286 "gnunet-service-arm", 282 GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm",
283 "gnunet-service-arm",
287#if VERBOSE_ARM 284#if VERBOSE_ARM
288 "-L", "DEBUG", 285 "-L", "DEBUG",
289#endif 286#endif
290 "-c", cfgname, NULL); 287 "-c", cfgname, NULL);
291#endif 288#endif
292 289
293} 290}
@@ -300,8 +297,9 @@ try_connect (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
300 /* FIXME: 'pX.id' may still be all-zeros here... */ 297 /* FIXME: 'pX.id' may still be all-zeros here... */
301 GNUNET_TRANSPORT_try_connect (p2.th, &p1.id); 298 GNUNET_TRANSPORT_try_connect (p2.th, &p1.id);
302 GNUNET_TRANSPORT_try_connect (p1.th, &p2.id); 299 GNUNET_TRANSPORT_try_connect (p1.th, &p2.id);
303 tct = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, 300 tct =
304 &try_connect, NULL); 301 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, &try_connect,
302 NULL);
305} 303}
306 304
307 305
@@ -340,16 +338,14 @@ peers_connect ()
340 ITERATIONS); 338 ITERATIONS);
341 339
342 GNUNET_assert (p1.th == NULL); 340 GNUNET_assert (p1.th == NULL);
343 p1.th = GNUNET_TRANSPORT_connect (p1.cfg, 341 p1.th =
344 NULL, &p1, 342 GNUNET_TRANSPORT_connect (p1.cfg, NULL, &p1, &notify_receive,
345 &notify_receive, 343 &notify_connect, &notify_disconnect);
346 &notify_connect, &notify_disconnect);
347 344
348 GNUNET_assert (p2.th == NULL); 345 GNUNET_assert (p2.th == NULL);
349 p2.th = GNUNET_TRANSPORT_connect (p2.cfg, 346 p2.th =
350 NULL, &p2, 347 GNUNET_TRANSPORT_connect (p2.cfg, NULL, &p2, &notify_receive,
351 &notify_receive, 348 &notify_connect, &notify_disconnect);
352 &notify_connect, &notify_disconnect);
353 349
354 GNUNET_assert (p1.th != NULL); 350 GNUNET_assert (p1.th != NULL);
355 GNUNET_assert (p2.th != NULL); 351 GNUNET_assert (p2.th != NULL);
@@ -360,9 +356,8 @@ peers_connect ()
360} 356}
361 357
362static void 358static void
363run (void *cls, 359run (void *cls, char *const *args, const char *cfgfile,
364 char *const *args, 360 const struct GNUNET_CONFIGURATION_Handle *cfg)
365 const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg)
366{ 361{
367 GNUNET_assert (ok == 1); 362 GNUNET_assert (ok == 1);
368 OKPP; 363 OKPP;
@@ -393,8 +388,8 @@ check ()
393 setTransportOptions ("test_transport_api_data.conf"); 388 setTransportOptions ("test_transport_api_data.conf");
394#endif 389#endif
395 ok = 1; 390 ok = 1;
396 GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, 391 GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, argv,
397 argv, "test-transport-api", "nohelp", options, &run, &ok); 392 "test-transport-api", "nohelp", options, &run, &ok);
398 stop_arm (&p1); 393 stop_arm (&p1);
399 stop_arm (&p2); 394 stop_arm (&p2);
400 395
diff --git a/src/transport/test_transport_api_multiaddress.c b/src/transport/test_transport_api_multiaddress.c
index 63ef28862..8748e5f6c 100644
--- a/src/transport/test_transport_api_multiaddress.c
+++ b/src/transport/test_transport_api_multiaddress.c
@@ -165,13 +165,12 @@ end_normally (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
165} 165}
166 166
167static void 167static void
168notify_connect (void *cls, 168notify_connect (void *cls, const struct GNUNET_PeerIdentity *peer,
169 const struct GNUNET_PeerIdentity *peer,
170 const struct GNUNET_TRANSPORT_ATS_Information *ats, 169 const struct GNUNET_TRANSPORT_ATS_Information *ats,
171 uint32_t ats_count) 170 uint32_t ats_count)
172{ 171{
173 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 172 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer `%4s' connected to us (%p)!\n",
174 "Peer `%4s' connected to us (%p)!\n", GNUNET_i2s (peer), cls); 173 GNUNET_i2s (peer), cls);
175 if (cls == &p1) 174 if (cls == &p1)
176 { 175 {
177 GNUNET_assert (ok >= 2); 176 GNUNET_assert (ok >= 2);
@@ -182,8 +181,8 @@ notify_connect (void *cls,
182 if (GNUNET_SCHEDULER_NO_TASK != tct) 181 if (GNUNET_SCHEDULER_NO_TASK != tct)
183 GNUNET_SCHEDULER_cancel (tct); 182 GNUNET_SCHEDULER_cancel (tct);
184 tct = GNUNET_SCHEDULER_NO_TASK; 183 tct = GNUNET_SCHEDULER_NO_TASK;
185 die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT_TRANSMIT, 184 die_task =
186 &end_normally, NULL); 185 GNUNET_SCHEDULER_add_delayed (TIMEOUT_TRANSMIT, &end_normally, NULL);
187 } 186 }
188} 187}
189 188
@@ -196,8 +195,8 @@ notify_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer)
196 GNUNET_SCHEDULER_cancel (die_task); 195 GNUNET_SCHEDULER_cancel (die_task);
197 die_task = GNUNET_SCHEDULER_add_now (&end_badly, NULL); 196 die_task = GNUNET_SCHEDULER_add_now (&end_badly, NULL);
198 } 197 }
199 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 198 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer `%4s' disconnected (%p)!\n",
200 "Peer `%4s' disconnected (%p)!\n", GNUNET_i2s (peer), cls); 199 GNUNET_i2s (peer), cls);
201} 200}
202 201
203 202
@@ -210,24 +209,24 @@ setup_peer (struct PeerContext *p, const char *cfgname)
210 if (GNUNET_CONFIGURATION_have_value (p->cfg, "PATHS", "SERVICEHOME")) 209 if (GNUNET_CONFIGURATION_have_value (p->cfg, "PATHS", "SERVICEHOME"))
211 { 210 {
212 GNUNET_assert (GNUNET_OK == 211 GNUNET_assert (GNUNET_OK ==
213 GNUNET_CONFIGURATION_get_value_string (p->cfg, 212 GNUNET_CONFIGURATION_get_value_string (p->cfg, "PATHS",
214 "PATHS",
215 "SERVICEHOME", 213 "SERVICEHOME",
216 &p->servicehome)); 214 &p->servicehome));
217 GNUNET_DISK_directory_remove (p->servicehome); 215 GNUNET_DISK_directory_remove (p->servicehome);
218 } 216 }
219 217
220#if START_ARM 218#if START_ARM
221 p->arm_proc = GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm", 219 p->arm_proc =
222 "gnunet-service-arm", 220 GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm",
221 "gnunet-service-arm",
223#if VERBOSE_ARM 222#if VERBOSE_ARM
224 "-L", "DEBUG", 223 "-L", "DEBUG",
225#endif 224#endif
226 "-c", cfgname, NULL); 225 "-c", cfgname, NULL);
227#endif 226#endif
228 p->th = GNUNET_TRANSPORT_connect (p->cfg, 227 p->th =
229 NULL, p, 228 GNUNET_TRANSPORT_connect (p->cfg, NULL, p, NULL, &notify_connect,
230 NULL, &notify_connect, &notify_disconnect); 229 &notify_disconnect);
231 GNUNET_assert (p->th != NULL); 230 GNUNET_assert (p->th != NULL);
232} 231}
233 232
@@ -239,15 +238,15 @@ try_connect (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
239 /* FIXME: 'pX.id' may still be all-zeros here... */ 238 /* FIXME: 'pX.id' may still be all-zeros here... */
240 GNUNET_TRANSPORT_try_connect (p2.th, &p1.id); 239 GNUNET_TRANSPORT_try_connect (p2.th, &p1.id);
241 GNUNET_TRANSPORT_try_connect (p1.th, &p2.id); 240 GNUNET_TRANSPORT_try_connect (p1.th, &p2.id);
242 tct = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, 241 tct =
243 &try_connect, NULL); 242 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, &try_connect,
243 NULL);
244} 244}
245 245
246 246
247static void 247static void
248run (void *cls, 248run (void *cls, char *const *args, const char *cfgfile,
249 char *const *args, 249 const struct GNUNET_CONFIGURATION_Handle *cfg)
250 const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg)
251{ 250{
252 GNUNET_assert (ok == 1); 251 GNUNET_assert (ok == 1);
253 OKPP; 252 OKPP;
@@ -284,8 +283,8 @@ check ()
284 setTransportOptions ("test_transport_api_data.conf"); 283 setTransportOptions ("test_transport_api_data.conf");
285#endif 284#endif
286 ok = 1; 285 ok = 1;
287 GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, 286 GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, argv,
288 argv, "test-transport-api", "nohelp", options, &run, &ok); 287 "test-transport-api", "nohelp", options, &run, &ok);
289 stop_arm (&p1); 288 stop_arm (&p1);
290 stop_arm (&p2); 289 stop_arm (&p2);
291 290
diff --git a/src/transport/test_transport_api_reliability.c b/src/transport/test_transport_api_reliability.c
index 60191394d..008bb9019 100644
--- a/src/transport/test_transport_api_reliability.c
+++ b/src/transport/test_transport_api_reliability.c
@@ -114,8 +114,8 @@ end ()
114 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Stopping peers\n"); 114 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Stopping peers\n");
115 115
116 delta = GNUNET_TIME_absolute_get_duration (start_time).rel_value; 116 delta = GNUNET_TIME_absolute_get_duration (start_time).rel_value;
117 fprintf (stderr, 117 fprintf (stderr, "\nThroughput was %llu kb/s\n",
118 "\nThroughput was %llu kb/s\n", total_bytes * 1000 / 1024 / delta); 118 total_bytes * 1000 / 1024 / delta);
119 //GNUNET_asprintf(&value_name, "reliable_%s", test_name); 119 //GNUNET_asprintf(&value_name, "reliable_%s", test_name);
120 //GAUGER ("TRANSPORT", value_name, (int)(total_bytes * 1000 / 1024 /delta), "kb/s"); 120 //GAUGER ("TRANSPORT", value_name, (int)(total_bytes * 1000 / 1024 /delta), "kb/s");
121 //GNUNET_free(value_name); 121 //GNUNET_free(value_name);
@@ -161,8 +161,7 @@ get_size (unsigned int iter)
161 161
162 162
163static void 163static void
164notify_receive (void *cls, 164notify_receive (void *cls, const struct GNUNET_PeerIdentity *peer,
165 const struct GNUNET_PeerIdentity *peer,
166 const struct GNUNET_MessageHeader *message, 165 const struct GNUNET_MessageHeader *message,
167 const struct GNUNET_TRANSPORT_ATS_Information *ats, 166 const struct GNUNET_TRANSPORT_ATS_Information *ats,
168 uint32_t ats_count) 167 uint32_t ats_count)
@@ -204,8 +203,8 @@ notify_receive (void *cls,
204 if (0 != memcmp (cbuf, &hdr[1], s - sizeof (struct TestMessage))) 203 if (0 != memcmp (cbuf, &hdr[1], s - sizeof (struct TestMessage)))
205 { 204 {
206 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 205 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
207 "Expected message %u with bits %u, but body did not match\n", 206 "Expected message %u with bits %u, but body did not match\n", n,
208 n, (unsigned char) n); 207 (unsigned char) n);
209 if (die_task != GNUNET_SCHEDULER_NO_TASK) 208 if (die_task != GNUNET_SCHEDULER_NO_TASK)
210 GNUNET_SCHEDULER_cancel (die_task); 209 GNUNET_SCHEDULER_cancel (die_task);
211 test_failed = GNUNET_YES; 210 test_failed = GNUNET_YES;
@@ -215,8 +214,7 @@ notify_receive (void *cls,
215#if VERBOSE 214#if VERBOSE
216 if (ntohl (hdr->num) % 5000 == 0) 215 if (ntohl (hdr->num) % 5000 == 0)
217 { 216 {
218 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 217 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Got message %u of size %u\n",
219 "Got message %u of size %u\n",
220 ntohl (hdr->num), ntohs (message->size)); 218 ntohl (hdr->num), ntohs (message->size));
221 } 219 }
222#endif 220#endif
@@ -271,8 +269,8 @@ notify_ready (void *cls, size_t size, void *buf)
271#if VERBOSE 269#if VERBOSE
272 if (n % 5000 == 0) 270 if (n % 5000 == 0)
273 { 271 {
274 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 272 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending message %u of size %u\n", n,
275 "Sending message %u of size %u\n", n, s); 273 s);
276 } 274 }
277#endif 275#endif
278 n++; 276 n++;
@@ -284,10 +282,9 @@ notify_ready (void *cls, size_t size, void *buf)
284 if (n < TOTAL_MSGS) 282 if (n < TOTAL_MSGS)
285 { 283 {
286 if (th == NULL) 284 if (th == NULL)
287 th = GNUNET_TRANSPORT_notify_transmit_ready (p2->th, 285 th = GNUNET_TRANSPORT_notify_transmit_ready (p2->th, &p1->id, s, 0,
288 &p1->id, 286 TIMEOUT, &notify_ready,
289 s, 0, TIMEOUT, 287 NULL);
290 &notify_ready, NULL);
291 msg_scheduled = n; 288 msg_scheduled = n;
292 } 289 }
293 if (n % 5000 == 0) 290 if (n % 5000 == 0)
@@ -305,19 +302,17 @@ notify_ready (void *cls, size_t size, void *buf)
305 302
306 303
307static void 304static void
308notify_connect (void *cls, 305notify_connect (void *cls, const struct GNUNET_PeerIdentity *peer,
309 const struct GNUNET_PeerIdentity *peer,
310 const struct GNUNET_TRANSPORT_ATS_Information *ats, 306 const struct GNUNET_TRANSPORT_ATS_Information *ats,
311 uint32_t ats_count) 307 uint32_t ats_count)
312{ 308{
313 309
314 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 310 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer `%4s' connected to us (%p)!\n",
315 "Peer `%4s' connected to us (%p)!\n", GNUNET_i2s (peer), cls); 311 GNUNET_i2s (peer), cls);
316 312
317 if (cls == p1) 313 if (cls == p1)
318 { 314 {
319 GNUNET_TRANSPORT_set_quota (p1->th, 315 GNUNET_TRANSPORT_set_quota (p1->th, &p2->id,
320 &p2->id,
321 GNUNET_BANDWIDTH_value_init (1024 * 1024 * 316 GNUNET_BANDWIDTH_value_init (1024 * 1024 *
322 1024), 317 1024),
323 GNUNET_BANDWIDTH_value_init (1024 * 1024 * 318 GNUNET_BANDWIDTH_value_init (1024 * 1024 *
@@ -325,8 +320,7 @@ notify_connect (void *cls,
325 } 320 }
326 else if (cls == p2) 321 else if (cls == p2)
327 { 322 {
328 GNUNET_TRANSPORT_set_quota (p2->th, 323 GNUNET_TRANSPORT_set_quota (p2->th, &p1->id,
329 &p1->id,
330 GNUNET_BANDWIDTH_value_init (1024 * 1024 * 324 GNUNET_BANDWIDTH_value_init (1024 * 1024 *
331 1024), 325 1024),
332 GNUNET_BANDWIDTH_value_init (1024 * 1024 * 326 GNUNET_BANDWIDTH_value_init (1024 * 1024 *
@@ -338,18 +332,16 @@ notify_connect (void *cls,
338static void 332static void
339notify_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer) 333notify_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer)
340{ 334{
341 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 335 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer `%4s' disconnected (%p)!\n",
342 "Peer `%4s' disconnected (%p)!\n", GNUNET_i2s (peer), cls); 336 GNUNET_i2s (peer), cls);
343} 337}
344 338
345static void 339static void
346sendtask () 340sendtask ()
347{ 341{
348 start_time = GNUNET_TIME_absolute_get (); 342 start_time = GNUNET_TIME_absolute_get ();
349 th = GNUNET_TRANSPORT_notify_transmit_ready (p2->th, 343 th = GNUNET_TRANSPORT_notify_transmit_ready (p2->th, &p1->id, get_size (0), 0,
350 &p1->id, 344 TIMEOUT, &notify_ready, NULL);
351 get_size (0), 0, TIMEOUT,
352 &notify_ready, NULL);
353} 345}
354 346
355static void 347static void
@@ -357,8 +349,8 @@ testing_connect_cb (struct PeerContext *p1, struct PeerContext *p2, void *cls)
357{ 349{
358 char *p1_c = strdup (GNUNET_i2s (&p1->id)); 350 char *p1_c = strdup (GNUNET_i2s (&p1->id));
359 351
360 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peers connected: %s <-> %s\n", 352 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peers connected: %s <-> %s\n", p1_c,
361 p1_c, GNUNET_i2s (&p2->id)); 353 GNUNET_i2s (&p2->id));
362 GNUNET_free (p1_c); 354 GNUNET_free (p1_c);
363 355
364 // FIXME: THIS IS REQUIRED! SEEMS TO BE A BUG! 356 // FIXME: THIS IS REQUIRED! SEEMS TO BE A BUG!
@@ -366,20 +358,17 @@ testing_connect_cb (struct PeerContext *p1, struct PeerContext *p2, void *cls)
366} 358}
367 359
368static void 360static void
369run (void *cls, 361run (void *cls, char *const *args, const char *cfgfile,
370 char *const *args, 362 const struct GNUNET_CONFIGURATION_Handle *cfg)
371 const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg)
372{ 363{
373 die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly, NULL); 364 die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly, NULL);
374 365
375 p1 = GNUNET_TRANSPORT_TESTING_start_peer (cfg_file_p1, 366 p1 = GNUNET_TRANSPORT_TESTING_start_peer (cfg_file_p1, &notify_receive,
376 &notify_receive, 367 &notify_connect, &notify_disconnect,
377 &notify_connect, 368 NULL);
378 &notify_disconnect, NULL); 369 p2 = GNUNET_TRANSPORT_TESTING_start_peer (cfg_file_p2, &notify_receive,
379 p2 = GNUNET_TRANSPORT_TESTING_start_peer (cfg_file_p2, 370 &notify_connect, &notify_disconnect,
380 &notify_receive, 371 NULL);
381 &notify_connect,
382 &notify_disconnect, NULL);
383 372
384 GNUNET_TRANSPORT_TESTING_connect_peers (p1, p2, &testing_connect_cb, NULL); 373 GNUNET_TRANSPORT_TESTING_connect_peers (p1, p2, &testing_connect_cb, NULL);
385} 374}
@@ -403,8 +392,8 @@ check ()
403 setTransportOptions ("test_transport_api_data.conf"); 392 setTransportOptions ("test_transport_api_data.conf");
404#endif 393#endif
405 ok = 1; 394 ok = 1;
406 GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, 395 GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, argv,
407 argv, "test-transport-api", "nohelp", options, &run, &ok); 396 "test-transport-api", "nohelp", options, &run, &ok);
408 397
409 return ok; 398 return ok;
410} 399}
@@ -494,8 +483,8 @@ check_gnunet_nat_binary (char *binary)
494 } 483 }
495 if (0 != STAT (p, &statbuf)) 484 if (0 != STAT (p, &statbuf))
496 { 485 {
497 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 486 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, _("stat (%s) failed: %s\n"), p,
498 _("stat (%s) failed: %s\n"), p, STRERROR (errno)); 487 STRERROR (errno));
499 GNUNET_free (p); 488 GNUNET_free (p);
500 return GNUNET_SYSERR; 489 return GNUNET_SYSERR;
501 } 490 }
diff --git a/src/transport/test_transport_api_unreliability.c b/src/transport/test_transport_api_unreliability.c
index 88df23eb4..5eed408c0 100644
--- a/src/transport/test_transport_api_unreliability.c
+++ b/src/transport/test_transport_api_unreliability.c
@@ -193,8 +193,8 @@ end ()
193 GAUGER ("TRANSPORT", value_name, (int) (total_bytes * 1000 / 1024 / delta), 193 GAUGER ("TRANSPORT", value_name, (int) (total_bytes * 1000 / 1024 / delta),
194 "kb/s"); 194 "kb/s");
195 GNUNET_free (value_name); 195 GNUNET_free (value_name);
196 fprintf (stderr, 196 fprintf (stderr, "\nThroughput was %llu kb/s\n",
197 "\nThroughput was %llu kb/s\n", total_bytes * 1000 / 1024 / delta); 197 total_bytes * 1000 / 1024 / delta);
198 ok = result; 198 ok = result;
199 199
200} 200}
@@ -231,8 +231,8 @@ end_unreliably ()
231 "Transports disconnected, returning success!\n"); 231 "Transports disconnected, returning success!\n");
232#endif 232#endif
233 delta = GNUNET_TIME_absolute_get_duration (start_time).rel_value; 233 delta = GNUNET_TIME_absolute_get_duration (start_time).rel_value;
234 fprintf (stderr, 234 fprintf (stderr, "\nThroughput was %llu kb/s\n",
235 "\nThroughput was %llu kb/s\n", total_bytes * 1000 / 1024 / delta); 235 total_bytes * 1000 / 1024 / delta);
236 GNUNET_asprintf (&value_name, "unreliable_%s", test_name); 236 GNUNET_asprintf (&value_name, "unreliable_%s", test_name);
237 GAUGER ("TRANSPORT", value_name, (int) (total_bytes * 1000 / 1024 / delta), 237 GAUGER ("TRANSPORT", value_name, (int) (total_bytes * 1000 / 1024 / delta),
238 "kb/s"); 238 "kb/s");
@@ -355,8 +355,7 @@ get_size (unsigned int iter)
355 355
356 356
357static void 357static void
358notify_receive (void *cls, 358notify_receive (void *cls, const struct GNUNET_PeerIdentity *peer,
359 const struct GNUNET_PeerIdentity *peer,
360 const struct GNUNET_MessageHeader *message, 359 const struct GNUNET_MessageHeader *message,
361 const struct GNUNET_TRANSPORT_ATS_Information *ats, 360 const struct GNUNET_TRANSPORT_ATS_Information *ats,
362 uint32_t ats_count) 361 uint32_t ats_count)
@@ -401,8 +400,7 @@ notify_receive (void *cls,
401#if VERBOSE 400#if VERBOSE
402 if (ntohl (hdr->num) % 5 == 0) 401 if (ntohl (hdr->num) % 5 == 0)
403 { 402 {
404 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 403 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Got message %u of size %u\n",
405 "Got message %u of size %u\n",
406 ntohl (hdr->num), ntohs (message->size)); 404 ntohl (hdr->num), ntohs (message->size));
407 } 405 }
408#endif 406#endif
@@ -456,8 +454,8 @@ notify_ready (void *cls, size_t size, void *buf)
456#if VERBOSE 454#if VERBOSE
457 if (n % 5000 == 0) 455 if (n % 5000 == 0)
458 { 456 {
459 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 457 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending message %u of size %u\n", n,
460 "Sending message %u of size %u\n", n, s); 458 s);
461 } 459 }
462#endif 460#endif
463 n++; 461 n++;
@@ -468,10 +466,9 @@ notify_ready (void *cls, size_t size, void *buf)
468 while (size - ret >= s); 466 while (size - ret >= s);
469 if (n < TOTAL_MSGS) 467 if (n < TOTAL_MSGS)
470 { 468 {
471 th_p2 = GNUNET_TRANSPORT_notify_transmit_ready (p2.th, 469 th_p2 =
472 &p1.id, 470 GNUNET_TRANSPORT_notify_transmit_ready (p2.th, &p1.id, s, 0, TIMEOUT,
473 s, 0, TIMEOUT, 471 &notify_ready, NULL);
474 &notify_ready, NULL);
475 msg_scheduled = n; 472 msg_scheduled = n;
476 } 473 }
477 else 474 else
@@ -500,8 +497,8 @@ notify_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer)
500{ 497{
501 connected--; 498 connected--;
502#if VERBOSE 499#if VERBOSE
503 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 500 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer `%4s' disconnected (%p)!\n",
504 "Peer `%4s' disconnected (%p)!\n", GNUNET_i2s (peer), cls); 501 GNUNET_i2s (peer), cls);
505#endif 502#endif
506 if (th_p2 != NULL) 503 if (th_p2 != NULL)
507 { 504 {
@@ -513,17 +510,15 @@ notify_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer)
513 510
514 511
515static void 512static void
516notify_connect (void *cls, 513notify_connect (void *cls, const struct GNUNET_PeerIdentity *peer,
517 const struct GNUNET_PeerIdentity *peer,
518 const struct GNUNET_TRANSPORT_ATS_Information *ats, 514 const struct GNUNET_TRANSPORT_ATS_Information *ats,
519 uint32_t ats_count) 515 uint32_t ats_count)
520{ 516{
521 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 517 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer `%4s' connected to us (%p)!\n",
522 "Peer `%4s' connected to us (%p)!\n", GNUNET_i2s (peer), cls); 518 GNUNET_i2s (peer), cls);
523 if (cls == &p1) 519 if (cls == &p1)
524 { 520 {
525 GNUNET_TRANSPORT_set_quota (p1.th, 521 GNUNET_TRANSPORT_set_quota (p1.th, &p2.id,
526 &p2.id,
527 GNUNET_BANDWIDTH_value_init (1024 * 1024 * 522 GNUNET_BANDWIDTH_value_init (1024 * 1024 *
528 1024), 523 1024),
529 GNUNET_BANDWIDTH_value_init (1024 * 1024 * 524 GNUNET_BANDWIDTH_value_init (1024 * 1024 *
@@ -533,8 +528,7 @@ notify_connect (void *cls,
533 } 528 }
534 else 529 else
535 { 530 {
536 GNUNET_TRANSPORT_set_quota (p2.th, 531 GNUNET_TRANSPORT_set_quota (p2.th, &p1.id,
537 &p1.id,
538 GNUNET_BANDWIDTH_value_init (1024 * 1024 * 532 GNUNET_BANDWIDTH_value_init (1024 * 1024 *
539 1024), 533 1024),
540 GNUNET_BANDWIDTH_value_init (1024 * 1024 * 534 GNUNET_BANDWIDTH_value_init (1024 * 1024 *
@@ -564,10 +558,8 @@ notify_connect (void *cls,
564 } 558 }
565 559
566 die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly, NULL); 560 die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly, NULL);
567 GNUNET_TRANSPORT_notify_transmit_ready (p2.th, 561 GNUNET_TRANSPORT_notify_transmit_ready (p2.th, &p1.id, get_size (0), 0,
568 &p1.id, 562 TIMEOUT, &notify_ready, NULL);
569 get_size (0), 0, TIMEOUT,
570 &notify_ready, NULL);
571 563
572 } 564 }
573} 565}
@@ -583,8 +575,7 @@ setup_peer (struct PeerContext *p, const char *cfgname)
583 if (GNUNET_CONFIGURATION_have_value (p->cfg, "PATHS", "SERVICEHOME")) 575 if (GNUNET_CONFIGURATION_have_value (p->cfg, "PATHS", "SERVICEHOME"))
584 { 576 {
585 GNUNET_assert (GNUNET_OK == 577 GNUNET_assert (GNUNET_OK ==
586 GNUNET_CONFIGURATION_get_value_string (p->cfg, 578 GNUNET_CONFIGURATION_get_value_string (p->cfg, "PATHS",
587 "PATHS",
588 "SERVICEHOME", 579 "SERVICEHOME",
589 &p->servicehome)); 580 &p->servicehome));
590 GNUNET_DISK_directory_remove (p->servicehome); 581 GNUNET_DISK_directory_remove (p->servicehome);
@@ -592,19 +583,18 @@ setup_peer (struct PeerContext *p, const char *cfgname)
592 583
593 584
594#if START_ARM 585#if START_ARM
595 p->arm_proc = GNUNET_OS_start_process (NULL, NULL, 586 p->arm_proc =
596 "gnunet-service-arm", 587 GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm",
597 "gnunet-service-arm", 588 "gnunet-service-arm",
598#if VERBOSE_ARM 589#if VERBOSE_ARM
599 "-L", "DEBUG", 590 "-L", "DEBUG",
600#endif 591#endif
601 "-c", cfgname, NULL); 592 "-c", cfgname, NULL);
602#endif 593#endif
603 594
604 p->th = GNUNET_TRANSPORT_connect (p->cfg, NULL, 595 p->th =
605 p, 596 GNUNET_TRANSPORT_connect (p->cfg, NULL, p, &notify_receive,
606 &notify_receive, 597 &notify_connect, &notify_disconnect);
607 &notify_connect, &notify_disconnect);
608 GNUNET_assert (p->th != NULL); 598 GNUNET_assert (p->th != NULL);
609} 599}
610 600
@@ -694,8 +684,8 @@ check_gnunet_nat_binary (char *binary)
694 } 684 }
695 if (0 != STAT (p, &statbuf)) 685 if (0 != STAT (p, &statbuf))
696 { 686 {
697 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 687 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, _("stat (%s) failed: %s\n"), p,
698 _("stat (%s) failed: %s\n"), p, STRERROR (errno)); 688 STRERROR (errno));
699 GNUNET_free (p); 689 GNUNET_free (p);
700 return GNUNET_SYSERR; 690 return GNUNET_SYSERR;
701 } 691 }
@@ -727,16 +717,16 @@ try_connect (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
727 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Asking peers to connect...\n"); 717 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Asking peers to connect...\n");
728 GNUNET_TRANSPORT_try_connect (p2.th, &p1.id); 718 GNUNET_TRANSPORT_try_connect (p2.th, &p1.id);
729 GNUNET_TRANSPORT_try_connect (p1.th, &p2.id); 719 GNUNET_TRANSPORT_try_connect (p1.th, &p2.id);
730 tct = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, 720 tct =
731 &try_connect, NULL); 721 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, &try_connect,
722 NULL);
732} 723}
733 724
734 725
735 726
736static void 727static void
737run (void *cls, 728run (void *cls, char *const *args, const char *cfgfile,
738 char *const *args, 729 const struct GNUNET_CONFIGURATION_Handle *cfg)
739 const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg)
740{ 730{
741 die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly, NULL); 731 die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly, NULL);
742 if (is_tcp) 732 if (is_tcp)
@@ -814,9 +804,9 @@ check ()
814 return 0; 804 return 0;
815 } 805 }
816 806
817 GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, 807 GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, argv,
818 argv, "test-transport-api-unreliability", "nohelp", 808 "test-transport-api-unreliability", "nohelp", options,
819 options, &run, &ok); 809 &run, &ok);
820 stop_arm (&p1); 810 stop_arm (&p1);
821 stop_arm (&p2); 811 stop_arm (&p2);
822 812
diff --git a/src/transport/test_transport_ats.c b/src/transport/test_transport_ats.c
index d9e4b23d5..0d16cd1b8 100644
--- a/src/transport/test_transport_ats.c
+++ b/src/transport/test_transport_ats.c
@@ -55,8 +55,8 @@ struct TransportConfiguration
55 55
56 56
57static void 57static void
58create_ats_information (struct ATS_peer **p, int *c_p, 58create_ats_information (struct ATS_peer **p, int *c_p, struct ATS_mechanism **m,
59 struct ATS_mechanism **m, int *c_m) 59 int *c_m)
60{ 60{
61 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "ATS needs addresses\n"); 61 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "ATS needs addresses\n");
62 62
@@ -73,8 +73,8 @@ run_ats ()
73 int ret = 0; 73 int ret = 0;
74 74
75 ats_calculate_bandwidth_distribution (ats); 75 ats_calculate_bandwidth_distribution (ats);
76 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 76 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Running ATS: %s \n",
77 "Running ATS: %s \n", (ret == 0) ? "SUCCESSFUL" : "FAILED"); 77 (ret == 0) ? "SUCCESSFUL" : "FAILED");
78 return ret; 78 return ret;
79} 79}
80 80
@@ -84,12 +84,13 @@ init_ats ()
84{ 84{
85 int ret = 0; 85 int ret = 0;
86 86
87 ats = ats_init (1.0, 1.0, 1.0, 50000, 5, 10, ATS_MAX_EXEC_DURATION, 87 ats =
88 create_ats_information, ats_result_cb); 88 ats_init (1.0, 1.0, 1.0, 50000, 5, 10, ATS_MAX_EXEC_DURATION,
89 create_ats_information, ats_result_cb);
89 //GNUNET_assert (ats != NULL); 90 //GNUNET_assert (ats != NULL);
90 91
91 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 92 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Initializing ATS: %s \n",
92 "Initializing ATS: %s \n", (ret == 0) ? "SUCCESSFUL" : "FAILED"); 93 (ret == 0) ? "SUCCESSFUL" : "FAILED");
93 return ret; 94 return ret;
94} 95}
95 96
@@ -101,8 +102,8 @@ shutdown_ats ()
101 102
102 ats_delete_problem (ats); 103 ats_delete_problem (ats);
103 ats_shutdown (ats); 104 ats_shutdown (ats);
104 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 105 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Shutdown ATS: %s \n",
105 "Shutdown ATS: %s \n", (ret == 0) ? "SUCCESSFUL" : "FAILED"); 106 (ret == 0) ? "SUCCESSFUL" : "FAILED");
106 return ret; 107 return ret;
107} 108}
108 109
@@ -123,16 +124,16 @@ dummy ()
123 124
124 125
125static void 126static void
126iterate_peer_values (void *cls, 127iterate_peer_values (void *cls, const char *section, const char *option,
127 const char *section, const char *option, const char *value) 128 const char *value)
128{ 129{
129 if (strcmp (option, "f") == 0) 130 if (strcmp (option, "f") == 0)
130 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "\t %s %s\n", option, value); 131 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "\t %s %s\n", option, value);
131} 132}
132 133
133static void 134static void
134iterate_mech_values (void *cls, 135iterate_mech_values (void *cls, const char *section, const char *option,
135 const char *section, const char *option, const char *value) 136 const char *value)
136{ 137{
137 if (strcmp (option, "f") == 0) 138 if (strcmp (option, "f") == 0)
138 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "\t %s %s\n", option, value); 139 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "\t %s %s\n", option, value);
diff --git a/src/transport/test_transport_ats_multiple_peers.c b/src/transport/test_transport_ats_multiple_peers.c
index d060a4d4b..fbc148e10 100644
--- a/src/transport/test_transport_ats_multiple_peers.c
+++ b/src/transport/test_transport_ats_multiple_peers.c
@@ -215,15 +215,15 @@ evaluate_measurements ()
215 stddev[0] = 0.0; 215 stddev[0] = 0.0;
216 for (c = 0; c < c_new; c++) 216 for (c = 0; c < c_new; c++)
217 { 217 {
218 stddev[0] += (results_new[c].duration - average[0]) * 218 stddev[0] +=
219 (results_new[c].duration - average[0]); 219 (results_new[c].duration - average[0]) * (results_new[c].duration -
220 average[0]);
220 } 221 }
221 stddev[0] /= c_new; 222 stddev[0] /= c_new;
222 stddev[0] = sqrt (stddev[0]); 223 stddev[0] = sqrt (stddev[0]);
223 if (!machine_parsable) 224 if (!machine_parsable)
224 fprintf (stderr, 225 fprintf (stderr, "new, %i measurements, average: %f stddev: %f\n", c_new,
225 "new, %i measurements, average: %f stddev: %f\n", 226 average[0], stddev[0]);
226 c_new, average[0], stddev[0]);
227 227
228 average[1] = 0.0; 228 average[1] = 0.0;
229 for (c = 0; c < c_modified; c++) 229 for (c = 0; c < c_modified; c++)
@@ -235,14 +235,14 @@ evaluate_measurements ()
235 stddev[1] = 0.0; 235 stddev[1] = 0.0;
236 for (c = 0; c < c_modified; c++) 236 for (c = 0; c < c_modified; c++)
237 { 237 {
238 stddev[1] += (results_modified[c].duration - average[1]) * 238 stddev[1] +=
239 (results_modified[c].duration - average[1]); 239 (results_modified[c].duration -
240 average[1]) * (results_modified[c].duration - average[1]);
240 } 241 }
241 stddev[1] /= c_modified; 242 stddev[1] /= c_modified;
242 stddev[1] = sqrt (stddev[1]); 243 stddev[1] = sqrt (stddev[1]);
243 if (!machine_parsable) 244 if (!machine_parsable)
244 fprintf (stderr, 245 fprintf (stderr, "modified, %i measurements, average: %f stddev: %f\n",
245 "modified, %i measurements, average: %f stddev: %f\n",
246 c_modified, average[1], stddev[1]); 246 c_modified, average[1], stddev[1]);
247 247
248 average[2] = 0.0; 248 average[2] = 0.0;
@@ -254,35 +254,31 @@ evaluate_measurements ()
254 stddev[2] = 0.0; 254 stddev[2] = 0.0;
255 for (c = 0; c < c_unmodified; c++) 255 for (c = 0; c < c_unmodified; c++)
256 { 256 {
257 stddev[2] += (results_unmodified[c].duration - average[2]) * 257 stddev[2] +=
258 (results_unmodified[c].duration - average[2]); 258 (results_unmodified[c].duration -
259 average[2]) * (results_unmodified[c].duration - average[2]);
259 } 260 }
260 stddev[2] /= c_unmodified; 261 stddev[2] /= c_unmodified;
261 stddev[2] = sqrt (stddev[2]); 262 stddev[2] = sqrt (stddev[2]);
262 263
263 if (!machine_parsable) 264 if (!machine_parsable)
264 fprintf (stderr, 265 fprintf (stderr, "unmodified, %i measurements, average: %f stddev: %f\n",
265 "unmodified, %i measurements, average: %f stddev: %f\n",
266 c_unmodified, average[2], stddev[2]); 266 c_unmodified, average[2], stddev[2]);
267 267
268 if (machine_parsable) 268 if (machine_parsable)
269 fprintf (stderr, 269 fprintf (stderr,
270 "peers,%i,mechs,%llu," 270 "peers,%i,mechs,%llu," "new,%i,%f,%f," "mod,%i,%f,%f,"
271 "new,%i,%f,%f," 271 "unmod,%i,%f,%f\n", peers - 1,
272 "mod,%i,%f,%f," 272 (unsigned long long) results_unmodified[0].mechs, c_new,
273 "unmod,%i,%f,%f\n", 273 average[0], stddev[0], c_modified, average[1], stddev[1],
274 peers - 1, (unsigned long long) results_unmodified[0].mechs,
275 c_new, average[0], stddev[0],
276 c_modified, average[1], stddev[1],
277 c_unmodified, average[2], stddev[2]); 274 c_unmodified, average[2], stddev[2]);
278 shutdown_peers (); 275 shutdown_peers ();
279} 276}
280 277
281 278
282static int 279static int
283stats_cb (void *cls, 280stats_cb (void *cls, const char *subsystem, const char *name, uint64_t value,
284 const char *subsystem, 281 int is_persistent)
285 const char *name, uint64_t value, int is_persistent)
286{ 282{
287 static int printed = GNUNET_NO; 283 static int printed = GNUNET_NO;
288 284
@@ -330,8 +326,8 @@ stats_cb (void *cls,
330 s_state = NULL; 326 s_state = NULL;
331 } 327 }
332 328
333 if ((measurement_started == GNUNET_NO) && 329 if ((measurement_started == GNUNET_NO) && (0 == strcmp (name, "ATS peers")) &&
334 (0 == strcmp (name, "ATS peers")) && (value == peers - 1)) 330 (value == peers - 1))
335 { 331 {
336 measurement_started = GNUNET_YES; 332 measurement_started = GNUNET_YES;
337 count = 1; 333 count = 1;
@@ -396,12 +392,11 @@ stats_cb (void *cls,
396 } 392 }
397 count++; 393 count++;
398#if VERBOSE 394#if VERBOSE
399 fprintf (stderr, 395 fprintf (stderr, "(new: %i / modified: %i / unmodified: %i) of %i \n",
400 "(new: %i / modified: %i / unmodified: %i) of %i \n",
401 c_new, c_modified, c_unmodified, MEASUREMENTS); 396 c_new, c_modified, c_unmodified, MEASUREMENTS);
402#endif 397#endif
403 if ((c_modified >= MEASUREMENTS) && 398 if ((c_modified >= MEASUREMENTS) && (c_new >= MEASUREMENTS) &&
404 (c_new >= MEASUREMENTS) && (c_unmodified >= MEASUREMENTS)) 399 (c_unmodified >= MEASUREMENTS))
405 { 400 {
406#if !VERBOSE 401#if !VERBOSE
407 if (!machine_parsable) 402 if (!machine_parsable)
@@ -430,32 +425,32 @@ stats_cb (void *cls,
430 { 425 {
431 current.solution = value; 426 current.solution = value;
432 if (printed == GNUNET_NO) 427 if (printed == GNUNET_NO)
433 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "[%i] %s: %llu \n", 428 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "[%i] %s: %llu \n", count, name,
434 count, name, value); 429 value);
435 } 430 }
436 431
437 if (0 == strcmp (name, "ATS peers")) 432 if (0 == strcmp (name, "ATS peers"))
438 { 433 {
439 current.peers = value; 434 current.peers = value;
440 if (printed == GNUNET_NO) 435 if (printed == GNUNET_NO)
441 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "[%i] %s: %llu \n", 436 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "[%i] %s: %llu \n", count, name,
442 count, name, value); 437 value);
443 } 438 }
444 439
445 if (0 == strcmp (name, "ATS mechanisms")) 440 if (0 == strcmp (name, "ATS mechanisms"))
446 { 441 {
447 current.mechs = value; 442 current.mechs = value;
448 if (printed == GNUNET_NO) 443 if (printed == GNUNET_NO)
449 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "[%i] %s: %llu \n", 444 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "[%i] %s: %llu \n", count, name,
450 count, name, value); 445 value);
451 } 446 }
452 447
453 if (0 == strcmp (name, "ATS duration")) 448 if (0 == strcmp (name, "ATS duration"))
454 { 449 {
455 current.duration = value; 450 current.duration = value;
456 if (printed == GNUNET_NO) 451 if (printed == GNUNET_NO)
457 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "[%i] %s: %llu \n", 452 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "[%i] %s: %llu \n", count, name,
458 count, name, value); 453 value);
459 } 454 }
460 if (0 == strcmp (name, "ATS state")) 455 if (0 == strcmp (name, "ATS state"))
461 { 456 {
@@ -485,8 +480,8 @@ stats_cb (void *cls,
485 break; 480 break;
486 } 481 }
487 if (printed == GNUNET_NO) 482 if (printed == GNUNET_NO)
488 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 483 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "[%i] ATS state: %s\n", count,
489 "[%i] ATS state: %s\n", count, cont); 484 cont);
490 } 485 }
491 } 486 }
492 return GNUNET_OK; 487 return GNUNET_OK;
@@ -500,16 +495,21 @@ stats_get_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
500 if ((tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN) != 0) 495 if ((tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN) != 0)
501 return; 496 return;
502 497
503 s_time = GNUNET_STATISTICS_get (stats, "transport", "ATS timestamp", 498 s_time =
504 TIMEOUT, NULL, &stats_cb, NULL); 499 GNUNET_STATISTICS_get (stats, "transport", "ATS timestamp", TIMEOUT, NULL,
505 s_solution = GNUNET_STATISTICS_get (stats, "transport", "ATS solution", 500 &stats_cb, NULL);
506 TIMEOUT, NULL, &stats_cb, NULL); 501 s_solution =
507 s_duration = GNUNET_STATISTICS_get (stats, "transport", "ATS duration", 502 GNUNET_STATISTICS_get (stats, "transport", "ATS solution", TIMEOUT, NULL,
508 TIMEOUT, NULL, &stats_cb, NULL); 503 &stats_cb, NULL);
509 s_peers = GNUNET_STATISTICS_get (stats, "transport", "ATS peers", 504 s_duration =
510 TIMEOUT, NULL, &stats_cb, NULL); 505 GNUNET_STATISTICS_get (stats, "transport", "ATS duration", TIMEOUT, NULL,
511 s_mechs = GNUNET_STATISTICS_get (stats, "transport", "ATS mechanisms", 506 &stats_cb, NULL);
512 TIMEOUT, NULL, &stats_cb, NULL); 507 s_peers =
508 GNUNET_STATISTICS_get (stats, "transport", "ATS peers", TIMEOUT, NULL,
509 &stats_cb, NULL);
510 s_mechs =
511 GNUNET_STATISTICS_get (stats, "transport", "ATS mechanisms", TIMEOUT,
512 NULL, &stats_cb, NULL);
513 s_invalid = 513 s_invalid =
514 GNUNET_STATISTICS_get (stats, "transport", "ATS invalid solutions", 514 GNUNET_STATISTICS_get (stats, "transport", "ATS invalid solutions",
515 TIMEOUT, NULL, &stats_cb, NULL); 515 TIMEOUT, NULL, &stats_cb, NULL);
@@ -592,8 +592,7 @@ send_task_f (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
592 } 592 }
593 593
594 if (send_msg == GNUNET_YES) 594 if (send_msg == GNUNET_YES)
595 t = GNUNET_TRANSPORT_notify_transmit_ready (th, 595 t = GNUNET_TRANSPORT_notify_transmit_ready (th, &master_deamon->id,
596 &master_deamon->id,
597 sizeof (struct TestMessage), 0, 596 sizeof (struct TestMessage), 0,
598 SEND_TIMEOUT, 597 SEND_TIMEOUT,
599 &send_dummy_data_task, NULL); 598 &send_dummy_data_task, NULL);
@@ -605,8 +604,7 @@ send_task_f (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
605} 604}
606 605
607static void 606static void
608notify_connect (void *cls, 607notify_connect (void *cls, const struct GNUNET_PeerIdentity *peer,
609 const struct GNUNET_PeerIdentity *peer,
610 const struct GNUNET_TRANSPORT_ATS_Information *ats, 608 const struct GNUNET_TRANSPORT_ATS_Information *ats,
611 uint32_t ats_count) 609 uint32_t ats_count)
612{ 610{
@@ -633,10 +631,8 @@ notify_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer)
633} 631}
634 632
635static void 633static void
636daemon_connect_cb (void *cls, 634daemon_connect_cb (void *cls, const struct GNUNET_PeerIdentity *first,
637 const struct GNUNET_PeerIdentity *first, 635 const struct GNUNET_PeerIdentity *second, uint32_t distance,
638 const struct GNUNET_PeerIdentity *second,
639 uint32_t distance,
640 const struct GNUNET_CONFIGURATION_Handle *first_cfg, 636 const struct GNUNET_CONFIGURATION_Handle *first_cfg,
641 const struct GNUNET_CONFIGURATION_Handle *second_cfg, 637 const struct GNUNET_CONFIGURATION_Handle *second_cfg,
642 struct GNUNET_TESTING_Daemon *first_daemon, 638 struct GNUNET_TESTING_Daemon *first_daemon,
@@ -647,20 +643,16 @@ daemon_connect_cb (void *cls,
647 char *secondc = strdup (GNUNET_i2s (second)); 643 char *secondc = strdup (GNUNET_i2s (second));
648 644
649 connected++; 645 connected++;
650 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 646 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Connected peers `%s'<->`%s' (%i/%i)\n",
651 "Connected peers `%s'<->`%s' (%i/%i)\n",
652 firstc, secondc, connected, peers - 1); 647 firstc, secondc, connected, peers - 1);
653 GNUNET_free (firstc); 648 GNUNET_free (firstc);
654 GNUNET_free (secondc); 649 GNUNET_free (secondc);
655 650
656 if (((first_daemon == ping_deamon) || 651 if (((first_daemon == ping_deamon) || (second_daemon == ping_deamon)) &&
657 (second_daemon == ping_deamon)) &&
658 (master_deamon != NULL) && (ping_deamon != NULL)) 652 (master_deamon != NULL) && (ping_deamon != NULL))
659 { 653 {
660 th = GNUNET_TRANSPORT_connect (ping_deamon->cfg, 654 th = GNUNET_TRANSPORT_connect (ping_deamon->cfg, &ping_deamon->id, NULL,
661 &ping_deamon->id, 655 NULL, &notify_connect, &notify_disconnect);
662 NULL, NULL,
663 &notify_connect, &notify_disconnect);
664 force_q_updates = GNUNET_YES; 656 force_q_updates = GNUNET_YES;
665 send_msg = GNUNET_YES; 657 send_msg = GNUNET_YES;
666 } 658 }
@@ -669,8 +661,7 @@ daemon_connect_cb (void *cls,
669 661
670 662
671static void 663static void
672daemon_start_cb (void *cls, 664daemon_start_cb (void *cls, const struct GNUNET_PeerIdentity *id,
673 const struct GNUNET_PeerIdentity *id,
674 const struct GNUNET_CONFIGURATION_Handle *cfg, 665 const struct GNUNET_CONFIGURATION_Handle *cfg,
675 struct GNUNET_TESTING_Daemon *d, const char *emsg) 666 struct GNUNET_TESTING_Daemon *d, const char *emsg)
676{ 667{
@@ -693,8 +684,8 @@ daemon_start_cb (void *cls,
693 684
694 if (master_deamon == NULL) 685 if (master_deamon == NULL)
695 { 686 {
696 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 687 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Master peer `%s' '%s'\n",
697 "Master peer `%s' '%s'\n", GNUNET_i2s (id), d->cfgfile); 688 GNUNET_i2s (id), d->cfgfile);
698 master_deamon = d; 689 master_deamon = d;
699 stats = GNUNET_STATISTICS_create ("transport", master_deamon->cfg); 690 stats = GNUNET_STATISTICS_create ("transport", master_deamon->cfg);
700 GNUNET_assert (stats != NULL); 691 GNUNET_assert (stats != NULL);
@@ -702,13 +693,10 @@ daemon_start_cb (void *cls,
702 } 693 }
703 else 694 else
704 { 695 {
705 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 696 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Connecting peer `%s'\n",
706 "Connecting peer `%s'\n",
707 GNUNET_i2s (id), GNUNET_i2s (&master_deamon->id)); 697 GNUNET_i2s (id), GNUNET_i2s (&master_deamon->id));
708 GNUNET_TESTING_daemons_connect (d, 698 GNUNET_TESTING_daemons_connect (d, master_deamon, TIMEOUT, 0, GNUNET_YES,
709 master_deamon, 699 &daemon_connect_cb, NULL);
710 TIMEOUT,
711 0, GNUNET_YES, &daemon_connect_cb, NULL);
712 } 700 }
713 701
714 if (peers_left == 0) 702 if (peers_left == 0)
@@ -716,8 +704,8 @@ daemon_start_cb (void *cls,
716 if (ping_deamon == NULL) 704 if (ping_deamon == NULL)
717 { 705 {
718 ping_deamon = d; 706 ping_deamon = d;
719 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 707 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Ping peer `%s' '%s'\n",
720 "Ping peer `%s' '%s'\n", GNUNET_i2s (id), d->cfgfile); 708 GNUNET_i2s (id), d->cfgfile);
721 } 709 }
722 710
723 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "All peers started successfully!\n"); 711 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "All peers started successfully!\n");
@@ -735,9 +723,8 @@ daemon_start_cb (void *cls,
735 723
736 724
737static void 725static void
738run (void *cls, 726run (void *cls, char *const *args, const char *cfgfile,
739 char *const *args, 727 const struct GNUNET_CONFIGURATION_Handle *cfg)
740 const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg)
741{ 728{
742 ok = 1; 729 ok = 1;
743 measurement_started = GNUNET_NO; 730 measurement_started = GNUNET_NO;
@@ -748,9 +735,8 @@ run (void *cls,
748 pg = GNUNET_TESTING_daemons_start (cfg, peers_left, /* Total number of peers */ 735 pg = GNUNET_TESTING_daemons_start (cfg, peers_left, /* Total number of peers */
749 peers_left, /* Number of outstanding connections */ 736 peers_left, /* Number of outstanding connections */
750 peers_left, /* Number of parallel ssh connections, or peers being started at once */ 737 peers_left, /* Number of parallel ssh connections, or peers being started at once */
751 TIMEOUT, 738 TIMEOUT, NULL, NULL, &daemon_start_cb,
752 NULL, NULL, 739 NULL, NULL, NULL, NULL);
753 &daemon_start_cb, NULL, NULL, NULL, NULL);
754 GNUNET_assert (pg != NULL); 740 GNUNET_assert (pg != NULL);
755} 741}
756 742
@@ -769,9 +755,9 @@ check ()
769 struct GNUNET_GETOPT_CommandLineOption options[] = { 755 struct GNUNET_GETOPT_CommandLineOption options[] = {
770 GNUNET_GETOPT_OPTION_END 756 GNUNET_GETOPT_OPTION_END
771 }; 757 };
772 GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, 758 GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, argv,
773 argv, "test_transport_ats_multiple_peers", "nohelp", 759 "test_transport_ats_multiple_peers", "nohelp", options,
774 options, &run, &ok); 760 &run, &ok);
775 return ok; 761 return ok;
776} 762}
777 763
diff --git a/src/transport/test_transport_testing.c b/src/transport/test_transport_testing.c
index cd5d7ed2c..85c05df4b 100644
--- a/src/transport/test_transport_testing.c
+++ b/src/transport/test_transport_testing.c
@@ -86,15 +86,14 @@ testing_connect_cb (struct PeerContext *p1, struct PeerContext *p2, void *cls)
86{ 86{
87 char *p1_c = strdup (GNUNET_i2s (&p1->id)); 87 char *p1_c = strdup (GNUNET_i2s (&p1->id));
88 88
89 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Peers connected: %s <-> %s\n", 89 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Peers connected: %s <-> %s\n", p1_c,
90 p1_c, GNUNET_i2s (&p2->id)); 90 GNUNET_i2s (&p2->id));
91 GNUNET_free (p1_c); 91 GNUNET_free (p1_c);
92 end (); 92 end ();
93} 93}
94 94
95static void 95static void
96notify_connect (void *cls, 96notify_connect (void *cls, const struct GNUNET_PeerIdentity *peer,
97 const struct GNUNET_PeerIdentity *peer,
98 const struct GNUNET_TRANSPORT_ATS_Information *ats, 97 const struct GNUNET_TRANSPORT_ATS_Information *ats,
99 uint32_t ats_count) 98 uint32_t ats_count)
100{ 99{
@@ -111,8 +110,7 @@ notify_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer)
111} 110}
112 111
113static void 112static void
114notify_receive (void *cls, 113notify_receive (void *cls, const struct GNUNET_PeerIdentity *peer,
115 const struct GNUNET_PeerIdentity *peer,
116 const struct GNUNET_MessageHeader *message, 114 const struct GNUNET_MessageHeader *message,
117 const struct GNUNET_TRANSPORT_ATS_Information *ats, 115 const struct GNUNET_TRANSPORT_ATS_Information *ats,
118 uint32_t ats_count) 116 uint32_t ats_count)
@@ -122,22 +120,19 @@ notify_receive (void *cls,
122 120
123 121
124static void 122static void
125run (void *cls, 123run (void *cls, char *const *args, const char *cfgfile,
126 char *const *args, 124 const struct GNUNET_CONFIGURATION_Handle *cfg)
127 const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg)
128{ 125{
129 timeout_task = 126 timeout_task =
130 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_MINUTES, &end_badly, NULL); 127 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_MINUTES, &end_badly, NULL);
131 128
132 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Starting peer\n"); 129 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Starting peer\n");
133 p1 = GNUNET_TRANSPORT_TESTING_start_peer ("test_transport_api_tcp_peer1.conf", 130 p1 = GNUNET_TRANSPORT_TESTING_start_peer ("test_transport_api_tcp_peer1.conf",
134 &notify_receive, 131 &notify_receive, &notify_connect,
135 &notify_connect,
136 &notify_disconnect, p1); 132 &notify_disconnect, p1);
137 133
138 p2 = GNUNET_TRANSPORT_TESTING_start_peer ("test_transport_api_tcp_peer2.conf", 134 p2 = GNUNET_TRANSPORT_TESTING_start_peer ("test_transport_api_tcp_peer2.conf",
139 &notify_receive, 135 &notify_receive, &notify_connect,
140 &notify_connect,
141 &notify_disconnect, p2); 136 &notify_disconnect, p2);
142 137
143 if (p1 != NULL) 138 if (p1 != NULL)
@@ -185,9 +180,8 @@ main (int argc, char *argv[])
185 GNUNET_GETOPT_OPTION_END 180 GNUNET_GETOPT_OPTION_END
186 }; 181 };
187 182
188 GNUNET_PROGRAM_run ((sizeof (argv_1) / sizeof (char *)) - 1, 183 GNUNET_PROGRAM_run ((sizeof (argv_1) / sizeof (char *)) - 1, argv_1,
189 argv_1, "test_transport_testing", "nohelp", 184 "test_transport_testing", "nohelp", options, &run, &ret);
190 options, &run, &ret);
191 185
192 return ret; 186 return ret;
193} 187}
diff --git a/src/transport/transport-testing.c b/src/transport/transport-testing.c
index e6fcabb48..62544584c 100644
--- a/src/transport/transport-testing.c
+++ b/src/transport/transport-testing.c
@@ -41,14 +41,13 @@ struct ConnectingContext
41 int p2_c; 41 int p2_c;
42}; 42};
43 43
44static void 44static void exchange_hello_last (void *cb_cls,
45exchange_hello_last (void *cb_cls, const struct GNUNET_MessageHeader *message); 45 const struct GNUNET_MessageHeader *message);
46static void 46static void exchange_hello (void *cb_cls,
47exchange_hello (void *cb_cls, const struct GNUNET_MessageHeader *message); 47 const struct GNUNET_MessageHeader *message);
48 48
49static void 49static void
50notify_connect_internal (void *cls, 50notify_connect_internal (void *cls, const struct GNUNET_PeerIdentity *peer,
51 const struct GNUNET_PeerIdentity *peer,
52 const struct GNUNET_TRANSPORT_ATS_Information *ats, 51 const struct GNUNET_TRANSPORT_ATS_Information *ats,
53 uint32_t ats_count) 52 uint32_t ats_count)
54{ 53{
@@ -93,8 +92,7 @@ notify_connect_internal (void *cls,
93} 92}
94 93
95static void 94static void
96notify_connect (void *cls, 95notify_connect (void *cls, const struct GNUNET_PeerIdentity *peer,
97 const struct GNUNET_PeerIdentity *peer,
98 const struct GNUNET_TRANSPORT_ATS_Information *ats, 96 const struct GNUNET_TRANSPORT_ATS_Information *ats,
99 uint32_t ats_count) 97 uint32_t ats_count)
100{ 98{
@@ -118,8 +116,7 @@ notify_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer)
118} 116}
119 117
120static void 118static void
121notify_receive (void *cls, 119notify_receive (void *cls, const struct GNUNET_PeerIdentity *peer,
122 const struct GNUNET_PeerIdentity *peer,
123 const struct GNUNET_MessageHeader *message, 120 const struct GNUNET_MessageHeader *message,
124 const struct GNUNET_TRANSPORT_ATS_Information *ats, 121 const struct GNUNET_TRANSPORT_ATS_Information *ats,
125 uint32_t ats_count) 122 uint32_t ats_count)
@@ -188,8 +185,8 @@ try_connect (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
188 GNUNET_TRANSPORT_try_connect (cc->th_p1, &p2->id); 185 GNUNET_TRANSPORT_try_connect (cc->th_p1, &p2->id);
189 GNUNET_TRANSPORT_try_connect (cc->th_p2, &p1->id); 186 GNUNET_TRANSPORT_try_connect (cc->th_p2, &p1->id);
190 187
191 cc->tct = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, 188 cc->tct =
192 &try_connect, cc); 189 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, &try_connect, cc);
193} 190}
194 191
195 192
@@ -218,14 +215,15 @@ GNUNET_TRANSPORT_TESTING_start_peer (const char *cfgname,
218 &p->servicehome); 215 &p->servicehome);
219 if (NULL != p->servicehome) 216 if (NULL != p->servicehome)
220 GNUNET_DISK_directory_remove (p->servicehome); 217 GNUNET_DISK_directory_remove (p->servicehome);
221 p->arm_proc = GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm", 218 p->arm_proc =
222 "gnunet-service-arm", "-c", cfgname, 219 GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm",
220 "gnunet-service-arm", "-c", cfgname,
223#if VERBOSE_PEERS 221#if VERBOSE_PEERS
224 "-L", "DEBUG", 222 "-L", "DEBUG",
225#else 223#else
226 "-L", "ERROR", 224 "-L", "ERROR",
227#endif 225#endif
228 NULL); 226 NULL);
229 p->nc = nc; 227 p->nc = nc;
230 p->nd = nd; 228 p->nd = nd;
231 p->rec = rec; 229 p->rec = rec;
@@ -234,10 +232,9 @@ GNUNET_TRANSPORT_TESTING_start_peer (const char *cfgname,
234 else 232 else
235 p->cb_cls = p; 233 p->cb_cls = p;
236 234
237 p->th = GNUNET_TRANSPORT_connect (p->cfg, NULL, 235 p->th =
238 p, 236 GNUNET_TRANSPORT_connect (p->cfg, NULL, p, &notify_receive,
239 &notify_receive, 237 &notify_connect, &notify_disconnect);
240 &notify_connect, &notify_disconnect);
241 GNUNET_assert (p->th != NULL); 238 GNUNET_assert (p->th != NULL);
242 return p; 239 return p;
243} 240}
@@ -296,13 +293,13 @@ GNUNET_TRANSPORT_TESTING_connect_peers (struct PeerContext *p1,
296 cc->cb = cb; 293 cc->cb = cb;
297 cc->cb_cls = cb_cls; 294 cc->cb_cls = cb_cls;
298 295
299 cc->th_p1 = GNUNET_TRANSPORT_connect (cc->p1->cfg, NULL, 296 cc->th_p1 =
300 cc, 297 GNUNET_TRANSPORT_connect (cc->p1->cfg, NULL, cc, NULL,
301 NULL, &notify_connect_internal, NULL); 298 &notify_connect_internal, NULL);
302 299
303 cc->th_p2 = GNUNET_TRANSPORT_connect (cc->p2->cfg, NULL, 300 cc->th_p2 =
304 cc, 301 GNUNET_TRANSPORT_connect (cc->p2->cfg, NULL, cc, NULL,
305 NULL, &notify_connect_internal, NULL); 302 &notify_connect_internal, NULL);
306 303
307 GNUNET_assert (cc->th_p1 != NULL); 304 GNUNET_assert (cc->th_p1 != NULL);
308 GNUNET_assert (cc->th_p2 != NULL); 305 GNUNET_assert (cc->th_p2 != NULL);
diff --git a/src/transport/transport_api.c b/src/transport/transport_api.c
index 2cdaacad6..b732871ca 100644
--- a/src/transport/transport_api.c
+++ b/src/transport/transport_api.c
@@ -304,8 +304,8 @@ static void schedule_transmission (struct GNUNET_TRANSPORT_Handle *h);
304 * 304 *
305 * @param h transport service to reconnect 305 * @param h transport service to reconnect
306 */ 306 */
307static void 307static void disconnect_and_schedule_reconnect (struct GNUNET_TRANSPORT_Handle
308disconnect_and_schedule_reconnect (struct GNUNET_TRANSPORT_Handle *h); 308 *h);
309 309
310 310
311/** 311/**
@@ -335,8 +335,8 @@ neighbour_add (struct GNUNET_TRANSPORT_Handle *h,
335 struct Neighbour *n; 335 struct Neighbour *n;
336 336
337#if DEBUG_TRANSPORT 337#if DEBUG_TRANSPORT
338 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 338 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Creating entry for neighbour `%4s'.\n",
339 "Creating entry for neighbour `%4s'.\n", GNUNET_i2s (pid)); 339 GNUNET_i2s (pid));
340#endif 340#endif
341 n = GNUNET_malloc (sizeof (struct Neighbour)); 341 n = GNUNET_malloc (sizeof (struct Neighbour));
342 n->id = *pid; 342 n->id = *pid;
@@ -347,8 +347,7 @@ neighbour_add (struct GNUNET_TRANSPORT_Handle *h,
347 MAX_BANDWIDTH_CARRY_S); 347 MAX_BANDWIDTH_CARRY_S);
348 GNUNET_assert (GNUNET_OK == 348 GNUNET_assert (GNUNET_OK ==
349 GNUNET_CONTAINER_multihashmap_put (h->neighbours, 349 GNUNET_CONTAINER_multihashmap_put (h->neighbours,
350 &pid->hashPubKey, 350 &pid->hashPubKey, n,
351 n,
352 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)); 351 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY));
353 return n; 352 return n;
354} 353}
@@ -375,8 +374,8 @@ neighbour_delete (void *cls, const GNUNET_HashCode * key, void *value)
375 GNUNET_assert (NULL == n->th); 374 GNUNET_assert (NULL == n->th);
376 GNUNET_assert (NULL == n->hn); 375 GNUNET_assert (NULL == n->hn);
377 GNUNET_assert (GNUNET_YES == 376 GNUNET_assert (GNUNET_YES ==
378 GNUNET_CONTAINER_multihashmap_remove (handle->neighbours, 377 GNUNET_CONTAINER_multihashmap_remove (handle->neighbours, key,
379 key, n)); 378 n));
380 GNUNET_free (n); 379 GNUNET_free (n);
381 return GNUNET_YES; 380 return GNUNET_YES;
382} 381}
@@ -414,8 +413,8 @@ demultiplexer (void *cls, const struct GNUNET_MessageHeader *msg)
414 disconnect_and_schedule_reconnect (h); 413 disconnect_and_schedule_reconnect (h);
415 return; 414 return;
416 } 415 }
417 GNUNET_CLIENT_receive (h->client, 416 GNUNET_CLIENT_receive (h->client, &demultiplexer, h,
418 &demultiplexer, h, GNUNET_TIME_UNIT_FOREVER_REL); 417 GNUNET_TIME_UNIT_FOREVER_REL);
419 size = ntohs (msg->size); 418 size = ntohs (msg->size);
420 switch (ntohs (msg->type)) 419 switch (ntohs (msg->type))
421 { 420 {
@@ -428,8 +427,8 @@ demultiplexer (void *cls, const struct GNUNET_MessageHeader *msg)
428 } 427 }
429#if DEBUG_TRANSPORT 428#if DEBUG_TRANSPORT
430 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 429 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
431 "Receiving (my own) `%s' message, I am `%4s'.\n", 430 "Receiving (my own) `%s' message, I am `%4s'.\n", "HELLO",
432 "HELLO", GNUNET_i2s (&me)); 431 GNUNET_i2s (&me));
433#endif 432#endif
434 GNUNET_free_non_null (h->my_hello); 433 GNUNET_free_non_null (h->my_hello);
435 h->my_hello = NULL; 434 h->my_hello = NULL;
@@ -465,8 +464,7 @@ demultiplexer (void *cls, const struct GNUNET_MessageHeader *msg)
465 break; 464 break;
466 } 465 }
467#if DEBUG_TRANSPORT 466#if DEBUG_TRANSPORT
468 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 467 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Receiving `%s' message for `%4s'.\n",
469 "Receiving `%s' message for `%4s'.\n",
470 "CONNECT", GNUNET_i2s (&cim->id)); 468 "CONNECT", GNUNET_i2s (&cim->id));
471#endif 469#endif
472 n = neighbour_find (h, &cim->id); 470 n = neighbour_find (h, &cim->id);
@@ -488,8 +486,7 @@ demultiplexer (void *cls, const struct GNUNET_MessageHeader *msg)
488 dim = (const struct DisconnectInfoMessage *) msg; 486 dim = (const struct DisconnectInfoMessage *) msg;
489 GNUNET_break (ntohl (dim->reserved) == 0); 487 GNUNET_break (ntohl (dim->reserved) == 0);
490#if DEBUG_TRANSPORT_DISCONNECT 488#if DEBUG_TRANSPORT_DISCONNECT
491 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 489 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Receiving `%s' message for `%4s'.\n",
492 "Receiving `%s' message for `%4s'.\n",
493 "DISCONNECT", GNUNET_i2s (&dim->peer)); 490 "DISCONNECT", GNUNET_i2s (&dim->peer));
494#endif 491#endif
495 n = neighbour_find (h, &dim->peer); 492 n = neighbour_find (h, &dim->peer);
@@ -551,8 +548,8 @@ demultiplexer (void *cls, const struct GNUNET_MessageHeader *msg)
551 } 548 }
552#if DEBUG_TRANSPORT 549#if DEBUG_TRANSPORT
553 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 550 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
554 "Received message of type %u from `%4s'.\n", 551 "Received message of type %u from `%4s'.\n", ntohs (imm->type),
555 ntohs (imm->type), GNUNET_i2s (&im->peer)); 552 GNUNET_i2s (&im->peer));
556#endif 553#endif
557 n = neighbour_find (h, &im->peer); 554 n = neighbour_find (h, &im->peer);
558 if (n == NULL) 555 if (n == NULL)
@@ -565,8 +562,7 @@ demultiplexer (void *cls, const struct GNUNET_MessageHeader *msg)
565 break; 562 break;
566 default: 563 default:
567 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 564 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
568 _ 565 _("Received unexpected message of type %u in %s:%u\n"),
569 ("Received unexpected message of type %u in %s:%u\n"),
570 ntohs (msg->type), __FILE__, __LINE__); 566 ntohs (msg->type), __FILE__, __LINE__);
571 GNUNET_break (0); 567 GNUNET_break (0);
572 break; 568 break;
@@ -663,17 +659,17 @@ transport_notify_ready (void *cls, size_t size, void *buf)
663 th = n->th; 659 th = n->th;
664 if (th->notify_size + sizeof (struct OutboundMessage) > size) 660 if (th->notify_size + sizeof (struct OutboundMessage) > size)
665 break; /* does not fit */ 661 break; /* does not fit */
666 if (GNUNET_BANDWIDTH_tracker_get_delay 662 if (GNUNET_BANDWIDTH_tracker_get_delay (&n->out_tracker, th->notify_size).
667 (&n->out_tracker, th->notify_size).rel_value > 0) 663 rel_value > 0)
668 break; /* too early */ 664 break; /* too early */
669 GNUNET_assert (n == GNUNET_CONTAINER_heap_remove_root (h->ready_heap)); 665 GNUNET_assert (n == GNUNET_CONTAINER_heap_remove_root (h->ready_heap));
670 n->hn = NULL; 666 n->hn = NULL;
671 n->th = NULL; 667 n->th = NULL;
672 n->is_ready = GNUNET_NO; 668 n->is_ready = GNUNET_NO;
673 GNUNET_assert (size >= sizeof (struct OutboundMessage)); 669 GNUNET_assert (size >= sizeof (struct OutboundMessage));
674 mret = th->notify (th->notify_cls, 670 mret =
675 size - sizeof (struct OutboundMessage), 671 th->notify (th->notify_cls, size - sizeof (struct OutboundMessage),
676 &cbuf[ret + sizeof (struct OutboundMessage)]); 672 &cbuf[ret + sizeof (struct OutboundMessage)]);
677 GNUNET_assert (mret <= size - sizeof (struct OutboundMessage)); 673 GNUNET_assert (mret <= size - sizeof (struct OutboundMessage));
678 if (mret != 0) 674 if (mret != 0)
679 { 675 {
@@ -756,11 +752,10 @@ schedule_transmission_task (void *cls,
756 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Calling notify_transmit_ready\n"); 752 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Calling notify_transmit_ready\n");
757#endif 753#endif
758 h->cth = 754 h->cth =
759 GNUNET_CLIENT_notify_transmit_ready (h->client, 755 GNUNET_CLIENT_notify_transmit_ready (h->client, size,
760 size,
761 GNUNET_TIME_UNIT_FOREVER_REL, 756 GNUNET_TIME_UNIT_FOREVER_REL,
762 GNUNET_NO, 757 GNUNET_NO, &transport_notify_ready,
763 &transport_notify_ready, h); 758 h);
764 GNUNET_assert (NULL != h->cth); 759 GNUNET_assert (NULL != h->cth);
765} 760}
766 761
@@ -794,8 +789,8 @@ schedule_transmission (struct GNUNET_TRANSPORT_Handle *h)
794 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 789 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
795 "Scheduling next transmission to service in %llu ms\n", 790 "Scheduling next transmission to service in %llu ms\n",
796 (unsigned long long) delay.rel_value); 791 (unsigned long long) delay.rel_value);
797 h->quota_task = GNUNET_SCHEDULER_add_delayed (delay, 792 h->quota_task =
798 &schedule_transmission_task, h); 793 GNUNET_SCHEDULER_add_delayed (delay, &schedule_transmission_task, h);
799} 794}
800 795
801 796
@@ -809,8 +804,7 @@ schedule_transmission (struct GNUNET_TRANSPORT_Handle *h)
809 * @param notify_cls closure for notify 804 * @param notify_cls closure for notify
810 */ 805 */
811static void 806static void
812schedule_control_transmit (struct GNUNET_TRANSPORT_Handle *h, 807schedule_control_transmit (struct GNUNET_TRANSPORT_Handle *h, size_t size,
813 size_t size,
814 GNUNET_CONNECTION_TransmitReadyNotify notify, 808 GNUNET_CONNECTION_TransmitReadyNotify notify,
815 void *notify_cls) 809 void *notify_cls)
816{ 810{
@@ -861,8 +855,8 @@ send_start (void *cls, size_t size, void *buf)
861 s.do_check = htonl (h->check_self); 855 s.do_check = htonl (h->check_self);
862 s.self = h->self; 856 s.self = h->self;
863 memcpy (buf, &s, sizeof (struct StartMessage)); 857 memcpy (buf, &s, sizeof (struct StartMessage));
864 GNUNET_CLIENT_receive (h->client, 858 GNUNET_CLIENT_receive (h->client, &demultiplexer, h,
865 &demultiplexer, h, GNUNET_TIME_UNIT_FOREVER_REL); 859 GNUNET_TIME_UNIT_FOREVER_REL);
866 return sizeof (struct StartMessage); 860 return sizeof (struct StartMessage);
867} 861}
868 862
@@ -936,8 +930,8 @@ disconnect_and_schedule_reconnect (struct GNUNET_TRANSPORT_Handle *h)
936 "Scheduling task to reconnect to transport service in %llu ms.\n", 930 "Scheduling task to reconnect to transport service in %llu ms.\n",
937 h->reconnect_delay.rel_value); 931 h->reconnect_delay.rel_value);
938#endif 932#endif
939 h->reconnect_task 933 h->reconnect_task =
940 = GNUNET_SCHEDULER_add_delayed (h->reconnect_delay, &reconnect, h); 934 GNUNET_SCHEDULER_add_delayed (h->reconnect_delay, &reconnect, h);
941 if (h->reconnect_delay.rel_value == 0) 935 if (h->reconnect_delay.rel_value == 0)
942 { 936 {
943 h->reconnect_delay = GNUNET_TIME_UNIT_MILLISECONDS; 937 h->reconnect_delay = GNUNET_TIME_UNIT_MILLISECONDS;
@@ -945,8 +939,8 @@ disconnect_and_schedule_reconnect (struct GNUNET_TRANSPORT_Handle *h)
945 else 939 else
946 { 940 {
947 h->reconnect_delay = GNUNET_TIME_relative_multiply (h->reconnect_delay, 2); 941 h->reconnect_delay = GNUNET_TIME_relative_multiply (h->reconnect_delay, 2);
948 h->reconnect_delay = GNUNET_TIME_relative_min (GNUNET_TIME_UNIT_SECONDS, 942 h->reconnect_delay =
949 h->reconnect_delay); 943 GNUNET_TIME_relative_min (GNUNET_TIME_UNIT_SECONDS, h->reconnect_delay);
950 } 944 }
951} 945}
952 946
@@ -990,8 +984,8 @@ send_set_quota (void *cls, size_t size, void *buf)
990 } 984 }
991#if DEBUG_TRANSPORT 985#if DEBUG_TRANSPORT
992 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 986 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
993 "Transmitting `%s' request with respect to `%4s'.\n", 987 "Transmitting `%s' request with respect to `%4s'.\n", "SET_QUOTA",
994 "SET_QUOTA", GNUNET_i2s (&sqc->target)); 988 GNUNET_i2s (&sqc->target));
995#endif 989#endif
996 GNUNET_assert (size >= sizeof (struct QuotaSetMessage)); 990 GNUNET_assert (size >= sizeof (struct QuotaSetMessage));
997 msg.header.size = htons (sizeof (struct QuotaSetMessage)); 991 msg.header.size = htons (sizeof (struct QuotaSetMessage));
@@ -1038,8 +1032,7 @@ GNUNET_TRANSPORT_set_quota (struct GNUNET_TRANSPORT_Handle *handle,
1038 (unsigned int) n->out_tracker.available_bytes_per_s__, 1032 (unsigned int) n->out_tracker.available_bytes_per_s__,
1039 (unsigned int) ntohl (quota_out.value__), GNUNET_i2s (target)); 1033 (unsigned int) ntohl (quota_out.value__), GNUNET_i2s (target));
1040 else 1034 else
1041 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1035 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Quota remains at %u for peer `%s'\n",
1042 "Quota remains at %u for peer `%s'\n",
1043 (unsigned int) n->out_tracker.available_bytes_per_s__, 1036 (unsigned int) n->out_tracker.available_bytes_per_s__,
1044 GNUNET_i2s (target)); 1037 GNUNET_i2s (target));
1045#endif 1038#endif
@@ -1047,8 +1040,7 @@ GNUNET_TRANSPORT_set_quota (struct GNUNET_TRANSPORT_Handle *handle,
1047 sqc = GNUNET_malloc (sizeof (struct SetQuotaContext)); 1040 sqc = GNUNET_malloc (sizeof (struct SetQuotaContext));
1048 sqc->target = *target; 1041 sqc->target = *target;
1049 sqc->quota_in = quota_in; 1042 sqc->quota_in = quota_in;
1050 schedule_control_transmit (handle, 1043 schedule_control_transmit (handle, sizeof (struct QuotaSetMessage),
1051 sizeof (struct QuotaSetMessage),
1052 &send_set_quota, sqc); 1044 &send_set_quota, sqc);
1053} 1045}
1054 1046
@@ -1257,8 +1249,7 @@ GNUNET_TRANSPORT_get_hello_cancel (struct GNUNET_TRANSPORT_Handle *handle,
1257 */ 1249 */
1258struct GNUNET_TRANSPORT_Handle * 1250struct GNUNET_TRANSPORT_Handle *
1259GNUNET_TRANSPORT_connect (const struct GNUNET_CONFIGURATION_Handle *cfg, 1251GNUNET_TRANSPORT_connect (const struct GNUNET_CONFIGURATION_Handle *cfg,
1260 const struct GNUNET_PeerIdentity *self, 1252 const struct GNUNET_PeerIdentity *self, void *cls,
1261 void *cls,
1262 GNUNET_TRANSPORT_ReceiveCallback rec, 1253 GNUNET_TRANSPORT_ReceiveCallback rec,
1263 GNUNET_TRANSPORT_NotifyConnect nc, 1254 GNUNET_TRANSPORT_NotifyConnect nc,
1264 GNUNET_TRANSPORT_NotifyDisconnect nd) 1255 GNUNET_TRANSPORT_NotifyDisconnect nd)
diff --git a/src/transport/transport_api_address_iterate.c b/src/transport/transport_api_address_iterate.c
index 4f442fda0..833b82d7e 100644
--- a/src/transport/transport_api_address_iterate.c
+++ b/src/transport/transport_api_address_iterate.c
@@ -110,8 +110,7 @@ peer_address_response_processor (void *cls,
110 return; 110 return;
111 } 111 }
112 /* expect more replies */ 112 /* expect more replies */
113 GNUNET_CLIENT_receive (alucb->client, 113 GNUNET_CLIENT_receive (alucb->client, &peer_address_response_processor, alucb,
114 &peer_address_response_processor, alucb,
115 GNUNET_TIME_absolute_get_remaining (alucb->timeout)); 114 GNUNET_TIME_absolute_get_remaining (alucb->timeout));
116 alucb->cb (alucb->cb_cls, address); 115 alucb->cb (alucb->cb_cls, address);
117} 116}
@@ -154,10 +153,8 @@ GNUNET_TRANSPORT_address_iterate (const struct GNUNET_CONFIGURATION_Handle *cfg,
154 peer_address_lookup_cb->timeout = abs_timeout; 153 peer_address_lookup_cb->timeout = abs_timeout;
155 peer_address_lookup_cb->client = client; 154 peer_address_lookup_cb->client = client;
156 GNUNET_assert (GNUNET_OK == 155 GNUNET_assert (GNUNET_OK ==
157 GNUNET_CLIENT_transmit_and_get_response (client, 156 GNUNET_CLIENT_transmit_and_get_response (client, &msg.header,
158 &msg.header, 157 timeout, GNUNET_YES,
159 timeout,
160 GNUNET_YES,
161 &peer_address_response_processor, 158 &peer_address_response_processor,
162 peer_address_lookup_cb)); 159 peer_address_lookup_cb));
163} 160}
diff --git a/src/transport/transport_api_address_lookup.c b/src/transport/transport_api_address_lookup.c
index 4aadf10f4..1cbafdab0 100644
--- a/src/transport/transport_api_address_lookup.c
+++ b/src/transport/transport_api_address_lookup.c
@@ -97,8 +97,7 @@ address_response_processor (void *cls, const struct GNUNET_MessageHeader *msg)
97 return; 97 return;
98 } 98 }
99 /* expect more replies */ 99 /* expect more replies */
100 GNUNET_CLIENT_receive (alucb->client, 100 GNUNET_CLIENT_receive (alucb->client, &address_response_processor, alucb,
101 &address_response_processor, alucb,
102 GNUNET_TIME_absolute_get_remaining (alucb->timeout)); 101 GNUNET_TIME_absolute_get_remaining (alucb->timeout));
103 alucb->cb (alucb->cb_cls, address); 102 alucb->cb (alucb->cb_cls, address);
104} 103}
@@ -119,10 +118,8 @@ address_response_processor (void *cls, const struct GNUNET_MessageHeader *msg)
119 */ 118 */
120void 119void
121GNUNET_TRANSPORT_address_lookup (const struct GNUNET_CONFIGURATION_Handle *cfg, 120GNUNET_TRANSPORT_address_lookup (const struct GNUNET_CONFIGURATION_Handle *cfg,
122 const char *address, 121 const char *address, size_t addressLen,
123 size_t addressLen, 122 int numeric, const char *nameTrans,
124 int numeric,
125 const char *nameTrans,
126 struct GNUNET_TIME_Relative timeout, 123 struct GNUNET_TIME_Relative timeout,
127 GNUNET_TRANSPORT_AddressLookUpCallback aluc, 124 GNUNET_TRANSPORT_AddressLookUpCallback aluc,
128 void *aluc_cls) 125 void *aluc_cls)
@@ -163,10 +160,8 @@ GNUNET_TRANSPORT_address_lookup (const struct GNUNET_CONFIGURATION_Handle *cfg,
163 aluCB->timeout = GNUNET_TIME_relative_to_absolute (timeout); 160 aluCB->timeout = GNUNET_TIME_relative_to_absolute (timeout);
164 aluCB->client = client; 161 aluCB->client = client;
165 GNUNET_assert (GNUNET_OK == 162 GNUNET_assert (GNUNET_OK ==
166 GNUNET_CLIENT_transmit_and_get_response (client, 163 GNUNET_CLIENT_transmit_and_get_response (client, &msg->header,
167 &msg->header, 164 timeout, GNUNET_YES,
168 timeout,
169 GNUNET_YES,
170 &address_response_processor, 165 &address_response_processor,
171 aluCB)); 166 aluCB));
172 GNUNET_free (msg); 167 GNUNET_free (msg);
diff --git a/src/transport/transport_api_blacklist.c b/src/transport/transport_api_blacklist.c
index f8f430995..f6852ff01 100644
--- a/src/transport/transport_api_blacklist.c
+++ b/src/transport/transport_api_blacklist.c
@@ -122,8 +122,8 @@ query_handler (void *cls, const struct GNUNET_MessageHeader *msg)
122static void 122static void
123receive (struct GNUNET_TRANSPORT_Blacklist *br) 123receive (struct GNUNET_TRANSPORT_Blacklist *br)
124{ 124{
125 GNUNET_CLIENT_receive (br->client, 125 GNUNET_CLIENT_receive (br->client, &query_handler, br,
126 &query_handler, br, GNUNET_TIME_UNIT_FOREVER_REL); 126 GNUNET_TIME_UNIT_FOREVER_REL);
127} 127}
128 128
129 129
@@ -166,12 +166,12 @@ reconnect (struct GNUNET_TRANSPORT_Blacklist *br)
166 GNUNET_CLIENT_disconnect (br->client, GNUNET_NO); 166 GNUNET_CLIENT_disconnect (br->client, GNUNET_NO);
167 br->client = GNUNET_CLIENT_connect ("transport", br->cfg); 167 br->client = GNUNET_CLIENT_connect ("transport", br->cfg);
168 GNUNET_assert (br->client != NULL); 168 GNUNET_assert (br->client != NULL);
169 br->th = GNUNET_CLIENT_notify_transmit_ready (br->client, 169 br->th =
170 sizeof (struct 170 GNUNET_CLIENT_notify_transmit_ready (br->client,
171 GNUNET_MessageHeader), 171 sizeof (struct GNUNET_MessageHeader),
172 GNUNET_TIME_UNIT_FOREVER_REL, 172 GNUNET_TIME_UNIT_FOREVER_REL,
173 GNUNET_YES, 173 GNUNET_YES, &transmit_blacklist_init,
174 &transmit_blacklist_init, br); 174 br);
175} 175}
176 176
177 177
@@ -212,12 +212,12 @@ transmit_blacklist_reply (void *cls, size_t size, void *buf)
212static void 212static void
213reply (struct GNUNET_TRANSPORT_Blacklist *br) 213reply (struct GNUNET_TRANSPORT_Blacklist *br)
214{ 214{
215 br->th = GNUNET_CLIENT_notify_transmit_ready (br->client, 215 br->th =
216 sizeof (struct 216 GNUNET_CLIENT_notify_transmit_ready (br->client,
217 BlacklistMessage), 217 sizeof (struct BlacklistMessage),
218 GNUNET_TIME_UNIT_FOREVER_REL, 218 GNUNET_TIME_UNIT_FOREVER_REL,
219 GNUNET_NO, 219 GNUNET_NO, &transmit_blacklist_reply,
220 &transmit_blacklist_reply, br); 220 br);
221 if (br->th == NULL) 221 if (br->th == NULL)
222 { 222 {
223 reconnect (br); 223 reconnect (br);
@@ -253,12 +253,12 @@ GNUNET_TRANSPORT_blacklist (const struct GNUNET_CONFIGURATION_Handle *cfg,
253 ret = GNUNET_malloc (sizeof (struct GNUNET_TRANSPORT_Blacklist)); 253 ret = GNUNET_malloc (sizeof (struct GNUNET_TRANSPORT_Blacklist));
254 ret->client = client; 254 ret->client = client;
255 ret->cfg = cfg; 255 ret->cfg = cfg;
256 ret->th = GNUNET_CLIENT_notify_transmit_ready (client, 256 ret->th =
257 sizeof (struct 257 GNUNET_CLIENT_notify_transmit_ready (client,
258 GNUNET_MessageHeader), 258 sizeof (struct GNUNET_MessageHeader),
259 GNUNET_TIME_UNIT_FOREVER_REL, 259 GNUNET_TIME_UNIT_FOREVER_REL,
260 GNUNET_YES, 260 GNUNET_YES, &transmit_blacklist_init,
261 &transmit_blacklist_init, ret); 261 ret);
262 return ret; 262 return ret;
263} 263}
264 264
diff --git a/src/transport/transport_api_peer_address_lookup.c b/src/transport/transport_api_peer_address_lookup.c
index 50536b47d..c84874b4b 100644
--- a/src/transport/transport_api_peer_address_lookup.c
+++ b/src/transport/transport_api_peer_address_lookup.c
@@ -110,8 +110,7 @@ peer_address_response_processor (void *cls,
110 return; 110 return;
111 } 111 }
112 /* expect more replies */ 112 /* expect more replies */
113 GNUNET_CLIENT_receive (alucb->client, 113 GNUNET_CLIENT_receive (alucb->client, &peer_address_response_processor, alucb,
114 &peer_address_response_processor, alucb,
115 GNUNET_TIME_absolute_get_remaining (alucb->timeout)); 114 GNUNET_TIME_absolute_get_remaining (alucb->timeout));
116 alucb->cb (alucb->cb_cls, address); 115 alucb->cb (alucb->cb_cls, address);
117} 116}
@@ -155,10 +154,8 @@ GNUNET_TRANSPORT_peer_address_lookup (const struct GNUNET_CONFIGURATION_Handle
155 peer_address_lookup_cb->timeout = GNUNET_TIME_relative_to_absolute (timeout); 154 peer_address_lookup_cb->timeout = GNUNET_TIME_relative_to_absolute (timeout);
156 peer_address_lookup_cb->client = client; 155 peer_address_lookup_cb->client = client;
157 GNUNET_assert (GNUNET_OK == 156 GNUNET_assert (GNUNET_OK ==
158 GNUNET_CLIENT_transmit_and_get_response (client, 157 GNUNET_CLIENT_transmit_and_get_response (client, &msg.header,
159 &msg.header, 158 timeout, GNUNET_YES,
160 timeout,
161 GNUNET_YES,
162 &peer_address_response_processor, 159 &peer_address_response_processor,
163 peer_address_lookup_cb)); 160 peer_address_lookup_cb));
164} 161}
diff --git a/src/transport/wlan/radiotap-parser.c b/src/transport/wlan/radiotap-parser.c
index 51dfd7107..ab75524f2 100644
--- a/src/transport/wlan/radiotap-parser.c
+++ b/src/transport/wlan/radiotap-parser.c
@@ -62,14 +62,14 @@ ieee80211_radiotap_iterator_init (struct ieee80211_radiotap_iterator *iterator,
62 iterator->max_length = le16_to_cpu (radiotap_header->it_len); 62 iterator->max_length = le16_to_cpu (radiotap_header->it_len);
63 iterator->arg_index = 0; 63 iterator->arg_index = 0;
64 iterator->bitmap_shifter = le32_to_cpu (radiotap_header->it_present); 64 iterator->bitmap_shifter = le32_to_cpu (radiotap_header->it_present);
65 iterator->arg = ((u8 *) radiotap_header) + 65 iterator->arg =
66 sizeof (struct ieee80211_radiotap_header); 66 ((u8 *) radiotap_header) + sizeof (struct ieee80211_radiotap_header);
67 iterator->this_arg = 0; 67 iterator->this_arg = 0;
68 68
69 /* find payload start allowing for extended bitmap(s) */ 69 /* find payload start allowing for extended bitmap(s) */
70 70
71 if (unlikely (iterator->bitmap_shifter & 71 if (unlikely
72 IEEE80211_RADIOTAP_PRESENT_EXTEND_MASK)) 72 (iterator->bitmap_shifter & IEEE80211_RADIOTAP_PRESENT_EXTEND_MASK))
73 { 73 {
74 while (le32_to_cpu (*((u32 *) iterator->arg)) & 74 while (le32_to_cpu (*((u32 *) iterator->arg)) &
75 IEEE80211_RADIOTAP_PRESENT_EXTEND_MASK) 75 IEEE80211_RADIOTAP_PRESENT_EXTEND_MASK)
@@ -190,13 +190,14 @@ ieee80211_radiotap_iterator_next (struct ieee80211_radiotap_iterator *iterator)
190 * kind of boundary. 190 * kind of boundary.
191 */ 191 */
192 192
193 if ((((void *) iterator->arg) - ((void *) iterator->rtheader)) & 193 if ((((void *) iterator->arg) -
194 ((rt_sizes[iterator->arg_index] >> 4) - 1)) 194 ((void *) iterator->
195 rtheader)) & ((rt_sizes[iterator->arg_index] >> 4) - 1))
195 iterator->arg_index += 196 iterator->arg_index +=
196 (rt_sizes[iterator->arg_index] >> 4) - 197 (rt_sizes[iterator->arg_index] >> 4) -
197 ((((void *) iterator->arg) - 198 ((((void *) iterator->arg) -
198 ((void *) iterator->rtheader)) & 199 ((void *) iterator->
199 ((rt_sizes[iterator->arg_index] >> 4) - 1)); 200 rtheader)) & ((rt_sizes[iterator->arg_index] >> 4) - 1));
200 201
201 /* 202 /*
202 * this is what we will return to user, but we need to 203 * this is what we will return to user, but we need to