aboutsummaryrefslogtreecommitdiff
path: root/src/transport
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2011-11-08 23:20:42 +0000
committerChristian Grothoff <christian@grothoff.org>2011-11-08 23:20:42 +0000
commita983a0267109b1b6a8e16e476e2f2956a8771b94 (patch)
tree79bcae73cdb7b87b4f55d4396e79baea76ef53a6 /src/transport
parenta3f8ef5b89dc44fc3acfb8f081a502f3409e4224 (diff)
downloadgnunet-a983a0267109b1b6a8e16e476e2f2956a8771b94.tar.gz
gnunet-a983a0267109b1b6a8e16e476e2f2956a8771b94.zip
refactoring how we handle peer addresses in peerinfo/ats/transport/hello subsystems -- use a struct instead of 3--4 arguments
Diffstat (limited to 'src/transport')
-rw-r--r--src/transport/gnunet-service-transport.c74
-rw-r--r--src/transport/gnunet-service-transport_blacklist.c8
-rw-r--r--src/transport/gnunet-service-transport_clients.c42
-rw-r--r--src/transport/gnunet-service-transport_hello.c55
-rw-r--r--src/transport/gnunet-service-transport_hello.h17
-rw-r--r--src/transport/gnunet-service-transport_neighbours.c337
-rw-r--r--src/transport/gnunet-service-transport_neighbours.h52
-rw-r--r--src/transport/gnunet-service-transport_plugins.c16
-rw-r--r--src/transport/gnunet-service-transport_plugins.h7
-rw-r--r--src/transport/gnunet-service-transport_validation.c203
-rw-r--r--src/transport/gnunet-service-transport_validation.h44
11 files changed, 340 insertions, 515 deletions
diff --git a/src/transport/gnunet-service-transport.c b/src/transport/gnunet-service-transport.c
index 11a8e23ae..542eb743e 100644
--- a/src/transport/gnunet-service-transport.c
+++ b/src/transport/gnunet-service-transport.c
@@ -25,6 +25,7 @@
25 */ 25 */
26#include "platform.h" 26#include "platform.h"
27#include "gnunet_util_lib.h" 27#include "gnunet_util_lib.h"
28#include "gnunet_hello_lib.h"
28#include "gnunet_statistics_service.h" 29#include "gnunet_statistics_service.h"
29#include "gnunet_transport_service.h" 30#include "gnunet_transport_service.h"
30#include "gnunet_peerinfo_service.h" 31#include "gnunet_peerinfo_service.h"
@@ -83,15 +84,13 @@ struct GNUNET_ATS_SchedulingHandle *GST_ats;
83 * @param target a connected neighbour 84 * @param target a connected neighbour
84 * @param ats performance information (unused) 85 * @param ats performance information (unused)
85 * @param ats_count number of records in ats (unused) 86 * @param ats_count number of records in ats (unused)
86 * @param transport plugin 87 * @param address the address
87 * @param addr address
88 * @param addrlen address length
89 */ 88 */
90static void 89static void
91transmit_our_hello (void *cls, const struct GNUNET_PeerIdentity *target, 90transmit_our_hello (void *cls, const struct GNUNET_PeerIdentity *target,
92 const struct GNUNET_ATS_Information *ats, 91 const struct GNUNET_ATS_Information *ats,
93 uint32_t ats_count, const char *transport, const void *addr, 92 uint32_t ats_count,
94 size_t addrlen) 93 const struct GNUNET_HELLO_Address *address)
95{ 94{
96 const struct GNUNET_MessageHeader *hello = cls; 95 const struct GNUNET_MessageHeader *hello = cls;
97 96
@@ -200,7 +199,8 @@ process_payload (const struct GNUNET_PeerIdentity *peer,
200 * (plugins that do not support this, can ignore the return value) 199 * (plugins that do not support this, can ignore the return value)
201 */ 200 */
202static struct GNUNET_TIME_Relative 201static struct GNUNET_TIME_Relative
203plugin_env_receive_callback (void *cls, const struct GNUNET_PeerIdentity *peer, 202plugin_env_receive_callback (void *cls,
203 const struct GNUNET_PeerIdentity *peer,
204 const struct GNUNET_MessageHeader *message, 204 const struct GNUNET_MessageHeader *message,
205 const struct GNUNET_ATS_Information *ats, 205 const struct GNUNET_ATS_Information *ats,
206 uint32_t ats_count, struct Session *session, 206 uint32_t ats_count, struct Session *session,
@@ -209,8 +209,13 @@ plugin_env_receive_callback (void *cls, const struct GNUNET_PeerIdentity *peer,
209{ 209{
210 const char *plugin_name = cls; 210 const char *plugin_name = cls;
211 struct GNUNET_TIME_Relative ret; 211 struct GNUNET_TIME_Relative ret;
212 struct GNUNET_HELLO_Address address;
212 uint16_t type; 213 uint16_t type;
213 214
215 address.peer = *peer;
216 address.address = sender_address;
217 address.address_length = sender_address_len;
218 address.transport_name = plugin_name;
214 ret = GNUNET_TIME_UNIT_ZERO; 219 ret = GNUNET_TIME_UNIT_ZERO;
215 if (NULL == message) 220 if (NULL == message)
216 goto end; 221 goto end;
@@ -229,37 +234,29 @@ plugin_env_receive_callback (void *cls, const struct GNUNET_PeerIdentity *peer,
229#if DEBUG_TRANSPORT 234#if DEBUG_TRANSPORT
230 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG | GNUNET_ERROR_TYPE_BULK, 235 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG | GNUNET_ERROR_TYPE_BULK,
231 "Processing `%s' from `%s'\n", "PING", 236 "Processing `%s' from `%s'\n", "PING",
232 (sender_address != NULL) ? GST_plugins_a2s (plugin_name, 237 (sender_address != NULL) ? GST_plugins_a2s (&address)
233 sender_address,
234 sender_address_len)
235 : "<inbound>"); 238 : "<inbound>");
236#endif 239#endif
237 GST_validation_handle_ping (peer, message, plugin_name, session, 240 GST_validation_handle_ping (peer, message, &address, session);
238 sender_address, sender_address_len);
239 break; 241 break;
240 case GNUNET_MESSAGE_TYPE_TRANSPORT_PONG: 242 case GNUNET_MESSAGE_TYPE_TRANSPORT_PONG:
241#if DEBUG_TRANSPORT 243#if DEBUG_TRANSPORT
242 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG | GNUNET_ERROR_TYPE_BULK, 244 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG | GNUNET_ERROR_TYPE_BULK,
243 "Processing `%s' from `%s'\n", "PONG", 245 "Processing `%s' from `%s'\n", "PONG",
244 (sender_address != NULL) ? GST_plugins_a2s (plugin_name, 246 (sender_address != NULL) ? GST_plugins_a2s (&address)
245 sender_address,
246 sender_address_len)
247 : "<inbound>"); 247 : "<inbound>");
248#endif 248#endif
249 GST_validation_handle_pong (peer, message); 249 GST_validation_handle_pong (peer, message);
250 break; 250 break;
251 case GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_CONNECT: 251 case GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_CONNECT:
252 GST_neighbours_handle_connect (message, peer, plugin_name, sender_address, 252 GST_neighbours_handle_connect (message, peer, &address, session, ats, ats_count);
253 sender_address_len, session, ats, ats_count);
254 break; 253 break;
255 case GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_CONNECT_ACK: 254 case GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_CONNECT_ACK:
256 GST_neighbours_handle_connect_ack (message, peer, plugin_name, 255 GST_neighbours_handle_connect_ack (message, peer, &address,
257 sender_address, sender_address_len,
258 session, ats, ats_count); 256 session, ats, ats_count);
259 break; 257 break;
260 case GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_ACK: 258 case GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_ACK:
261 GST_neighbours_handle_ack (message, peer, plugin_name, sender_address, 259 GST_neighbours_handle_ack (message, peer, &address, session, ats, ats_count);
262 sender_address_len, session, ats, ats_count);
263 break; 260 break;
264 case GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_DISCONNECT: 261 case GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_DISCONNECT:
265 GST_neighbours_handle_disconnect_message (peer, message); 262 GST_neighbours_handle_disconnect_message (peer, message);
@@ -276,8 +273,7 @@ end:
276#if 1 273#if 1
277 /* FIXME: this should not be needed, and not sure it's good to have it, but without 274 /* FIXME: this should not be needed, and not sure it's good to have it, but without
278 * this connections seem to go extra-slow */ 275 * this connections seem to go extra-slow */
279 GNUNET_ATS_address_update (GST_ats, peer, plugin_name, sender_address, 276 GNUNET_ATS_address_update (GST_ats, &address, session, ats, ats_count);
280 sender_address_len, session, ats, ats_count);
281#endif 277#endif
282#if DEBUG_TRANSPORT 278#if DEBUG_TRANSPORT
283 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 279 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
@@ -304,8 +300,13 @@ plugin_env_address_change_notification (void *cls, int add_remove,
304 const void *addr, size_t addrlen) 300 const void *addr, size_t addrlen)
305{ 301{
306 const char *plugin_name = cls; 302 const char *plugin_name = cls;
303 struct GNUNET_HELLO_Address address;
307 304
308 GST_hello_modify_addresses (add_remove, plugin_name, addr, addrlen); 305 address.peer = GST_my_identity;
306 address.transport_name = plugin_name;
307 address.address = addr;
308 address.address_length = addrlen;
309 GST_hello_modify_addresses (add_remove, &address);
309} 310}
310 311
311 312
@@ -326,6 +327,8 @@ static void
326plugin_env_session_end (void *cls, const struct GNUNET_PeerIdentity *peer, 327plugin_env_session_end (void *cls, const struct GNUNET_PeerIdentity *peer,
327 struct Session *session) 328 struct Session *session)
328{ 329{
330 struct GNUNET_HELLO_Address address;
331
329#if DEBUG_TRANSPORT 332#if DEBUG_TRANSPORT
330 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Session %X to peer `%s' ended \n", 333 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Session %X to peer `%s' ended \n",
331 session, GNUNET_i2s (peer)); 334 session, GNUNET_i2s (peer));
@@ -335,7 +338,11 @@ plugin_env_session_end (void *cls, const struct GNUNET_PeerIdentity *peer,
335 "transport-ats", 338 "transport-ats",
336 "Telling ATS to destroy session %p from peer %s\n", 339 "Telling ATS to destroy session %p from peer %s\n",
337 session, GNUNET_i2s (peer)); 340 session, GNUNET_i2s (peer));
338 GNUNET_ATS_address_destroyed (GST_ats, peer, NULL, NULL, 0, session); 341 address.peer = *peer;
342 address.address = NULL;
343 address.address_length = 0;
344 address.transport_name = cls;
345 GNUNET_ATS_address_destroyed (GST_ats, &address, session);
339 GST_neighbours_session_terminated (peer, session); 346 GST_neighbours_session_terminated (peer, session);
340} 347}
341 348
@@ -348,18 +355,15 @@ plugin_env_session_end (void *cls, const struct GNUNET_PeerIdentity *peer,
348 * actually happened. 355 * actually happened.
349 * 356 *
350 * @param cls closure 357 * @param cls closure
351 * @param peer identity of the peer 358 * @param address address to use (for peer given in address)
352 * @param plugin_name name of the transport plugin, NULL to disconnect
353 * @param session session to use (if available) 359 * @param session session to use (if available)
354 * @param plugin_addr address to use (if available)
355 * @param plugin_addr_len number of bytes in addr
356 * @param bandwidth_out assigned outbound bandwidth for the connection, 0 to disconnect from peer 360 * @param bandwidth_out assigned outbound bandwidth for the connection, 0 to disconnect from peer
357 * @param bandwidth_in assigned inbound bandwidth for the connection, 0 to disconnect from peer 361 * @param bandwidth_in assigned inbound bandwidth for the connection, 0 to disconnect from peer
358 */ 362 */
359static void 363static void
360ats_request_address_change (void *cls, const struct GNUNET_PeerIdentity *peer, 364ats_request_address_change (void *cls,
361 const char *plugin_name, const void *plugin_addr, 365 const struct GNUNET_HELLO_Address *address,
362 size_t plugin_addr_len, struct Session *session, 366 struct Session *session,
363 struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out, 367 struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out,
364 struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in, 368 struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in,
365 const struct GNUNET_ATS_Information *ats, 369 const struct GNUNET_ATS_Information *ats,
@@ -374,14 +378,14 @@ ats_request_address_change (void *cls, const struct GNUNET_PeerIdentity *peer,
374#if DEBUG_TRANSPORT 378#if DEBUG_TRANSPORT
375 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 379 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
376 "ATS tells me to disconnect from peer `%s'\n", 380 "ATS tells me to disconnect from peer `%s'\n",
377 GNUNET_i2s (peer)); 381 GNUNET_i2s (&address->peer));
378#endif 382#endif
379 GST_neighbours_force_disconnect (peer); 383 GST_neighbours_force_disconnect (&address->peer);
380 return; 384 return;
381 } 385 }
382 /* will never return GNUNET_YES since connection is to be established */ 386 /* will never return GNUNET_YES since connection is to be established */
383 GST_neighbours_switch_to_address_3way (peer, plugin_name, plugin_addr, 387 GST_neighbours_switch_to_address_3way (&address->peer,
384 plugin_addr_len, session, ats, 388 address, session, ats,
385 ats_count, bandwidth_in, 389 ats_count, bandwidth_in,
386 bandwidth_out); 390 bandwidth_out);
387} 391}
diff --git a/src/transport/gnunet-service-transport_blacklist.c b/src/transport/gnunet-service-transport_blacklist.c
index 78eea2ff9..b3edc01db 100644
--- a/src/transport/gnunet-service-transport_blacklist.c
+++ b/src/transport/gnunet-service-transport_blacklist.c
@@ -550,15 +550,13 @@ struct TestConnectionContext
550 * @param neighbour neighbour's identity 550 * @param neighbour neighbour's identity
551 * @param ats performance data 551 * @param ats performance data
552 * @param ats_count number of entries in ats (excluding 0-termination) 552 * @param ats_count number of entries in ats (excluding 0-termination)
553 * @param transport plugin 553 * @param address the address
554 * @param addr address
555 * @param addrlen address length
556 */ 554 */
557static void 555static void
558test_connection_ok (void *cls, const struct GNUNET_PeerIdentity *neighbour, 556test_connection_ok (void *cls, const struct GNUNET_PeerIdentity *neighbour,
559 const struct GNUNET_ATS_Information *ats, 557 const struct GNUNET_ATS_Information *ats,
560 uint32_t ats_count, const char *transport, const void *addr, 558 uint32_t ats_count,
561 size_t addrlen) 559 const struct GNUNET_HELLO_Address *address)
562{ 560{
563 struct TestConnectionContext *tcc = cls; 561 struct TestConnectionContext *tcc = cls;
564 struct GST_BlacklistCheck *bc; 562 struct GST_BlacklistCheck *bc;
diff --git a/src/transport/gnunet-service-transport_clients.c b/src/transport/gnunet-service-transport_clients.c
index ebab72db6..aee592d29 100644
--- a/src/transport/gnunet-service-transport_clients.c
+++ b/src/transport/gnunet-service-transport_clients.c
@@ -325,16 +325,14 @@ client_disconnect_notification (void *cls, struct GNUNET_SERVER_Client *client)
325 * @param peer identity of the neighbour 325 * @param peer identity of the neighbour
326 * @param ats performance data 326 * @param ats performance data
327 * @param ats_count number of entries in ats (excluding 0-termination) 327 * @param ats_count number of entries in ats (excluding 0-termination)
328 * @param transport plugin 328 * @param address the address
329 * @param addr address
330 * @param addrlen address length
331 */ 329 */
332static void 330static void
333notify_client_about_neighbour (void *cls, 331notify_client_about_neighbour (void *cls,
334 const struct GNUNET_PeerIdentity *peer, 332 const struct GNUNET_PeerIdentity *peer,
335 const struct GNUNET_ATS_Information *ats, 333 const struct GNUNET_ATS_Information *ats,
336 uint32_t ats_count, const char *transport, 334 uint32_t ats_count,
337 const void *addr, size_t addrlen) 335 const struct GNUNET_HELLO_Address *address)
338{ 336{
339 struct TransportClient *tc = cls; 337 struct TransportClient *tc = cls;
340 struct ConnectInfoMessage *cim; 338 struct ConnectInfoMessage *cim;
@@ -719,33 +717,28 @@ clients_handle_address_lookup (void *cls, struct GNUNET_SERVER_Client *client,
719 * 717 *
720 * @param cls our 'struct GNUNET_SERVER_TransmitContext' (for sending) 718 * @param cls our 'struct GNUNET_SERVER_TransmitContext' (for sending)
721 * @param public_key public key for the peer, never NULL 719 * @param public_key public key for the peer, never NULL
722 * @param target peer this change is about, never NULL
723 * @param valid_until until what time do we consider the address valid? 720 * @param valid_until until what time do we consider the address valid?
724 * @param validation_block is FOREVER if the address is for an unsupported plugin (from PEERINFO) 721 * @param validation_block is FOREVER if the address is for an unsupported plugin (from PEERINFO)
725 * is ZERO if the address is considered valid (no validation needed) 722 * is ZERO if the address is considered valid (no validation needed)
726 * is a time in the future if we're currently denying re-validation 723 * is a time in the future if we're currently denying re-validation
727 * @param plugin_name name of the plugin 724 * @param address address to transmit
728 * @param plugin_address binary address
729 * @param plugin_address_len length of address
730 */ 725 */
731static void 726static void
732send_address_to_client (void *cls, 727send_address_to_client (void *cls,
733 const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded 728 const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded
734 *public_key, const struct GNUNET_PeerIdentity *target, 729 *public_key,
735 struct GNUNET_TIME_Absolute valid_until, 730 struct GNUNET_TIME_Absolute valid_until,
736 struct GNUNET_TIME_Absolute validation_block, 731 struct GNUNET_TIME_Absolute validation_block,
737 const char *plugin_name, const void *plugin_address, 732 const struct GNUNET_HELLO_Address *address)
738 size_t plugin_address_len)
739{ 733{
740 struct GNUNET_SERVER_TransmitContext *tc = cls; 734 struct GNUNET_SERVER_TransmitContext *tc = cls;
741 char *addr_buf; 735 char *addr_buf;
742 736
743 /* FIXME: move to a binary format!!! */ 737 /* FIXME: move to a binary format!!! */
744 GNUNET_asprintf (&addr_buf, "%s --- %s, %s", 738 GNUNET_asprintf (&addr_buf, "%s --- %s, %s",
745 GST_plugins_a2s (plugin_name, plugin_address, 739 GST_plugins_a2s (address),
746 plugin_address_len),
747 (GNUNET_YES == 740 (GNUNET_YES ==
748 GST_neighbours_test_connected (target)) ? "CONNECTED" : 741 GST_neighbours_test_connected (&address->peer)) ? "CONNECTED" :
749 "DISCONNECTED", 742 "DISCONNECTED",
750 (GNUNET_TIME_absolute_get_remaining (valid_until).rel_value > 743 (GNUNET_TIME_absolute_get_remaining (valid_until).rel_value >
751 0) ? "VALIDATED" : "UNVALIDATED"); 744 0) ? "VALIDATED" : "UNVALIDATED");
@@ -789,27 +782,26 @@ clients_handle_peer_address_lookup (void *cls,
789 * @param neighbour identity of the neighbour 782 * @param neighbour identity of the neighbour
790 * @param ats performance data 783 * @param ats performance data
791 * @param ats_count number of entries in ats (excluding 0-termination) 784 * @param ats_count number of entries in ats (excluding 0-termination)
792 * @param transport plugin 785 * @param address the address
793 * @param addr address
794 * @param addrlen address length
795 */ 786 */
796static void 787static void
797output_addresses (void *cls, const struct GNUNET_PeerIdentity *peer, 788output_addresses (void *cls, const struct GNUNET_PeerIdentity *peer,
798 const struct GNUNET_ATS_Information *ats, uint32_t ats_count, 789 const struct GNUNET_ATS_Information *ats, uint32_t ats_count,
799 const char *transport, const void *addr, size_t addrlen) 790 const struct GNUNET_HELLO_Address *address)
800{ 791{
801 struct GNUNET_SERVER_TransmitContext *tc = cls; 792 struct GNUNET_SERVER_TransmitContext *tc = cls;
802 struct AddressIterateResponseMessage *msg; 793 struct AddressIterateResponseMessage *msg;
803 size_t size; 794 size_t size;
795 size_t slen;
804 796
805 size = 797 slen = strlen (address->transport_name) + 1;
806 (sizeof (struct AddressIterateResponseMessage) + strlen (transport) + 1); 798 size = (sizeof (struct AddressIterateResponseMessage) + slen);
807 msg = GNUNET_malloc (size); 799 msg = GNUNET_malloc (size);
808 memcpy (&msg->peer, peer, sizeof (struct GNUNET_PeerIdentity)); 800 memcpy (&msg->peer, peer, sizeof (struct GNUNET_PeerIdentity));
809 memcpy (&msg[0], transport, strlen (transport) + 1); 801 memcpy (&msg[0], address->transport_name, slen);
810 msg->addrlen = ntohs (addrlen); 802 msg->addrlen = ntohs (address->address_length);
811 msg->pluginlen = ntohs (strlen (transport) + 1); 803 msg->pluginlen = ntohs (slen);
812 804 // FIXME: what about 'address->address'!?
813 transmit_binary_to_client (tc, msg, size); 805 transmit_binary_to_client (tc, msg, size);
814 GNUNET_free (msg); 806 GNUNET_free (msg);
815} 807}
diff --git a/src/transport/gnunet-service-transport_hello.c b/src/transport/gnunet-service-transport_hello.c
index 45fdf0a26..8b38a673e 100644
--- a/src/transport/gnunet-service-transport_hello.c
+++ b/src/transport/gnunet-service-transport_hello.c
@@ -56,9 +56,9 @@ struct OwnAddressList
56 struct OwnAddressList *prev; 56 struct OwnAddressList *prev;
57 57
58 /** 58 /**
59 * Name of the plugin. 59 * The address.
60 */ 60 */
61 char *plugin_name; 61 struct GNUNET_HELLO_Address *address;
62 62
63 /** 63 /**
64 * How long until the current signature expires? (ZERO if the 64 * How long until the current signature expires? (ZERO if the
@@ -71,11 +71,6 @@ struct OwnAddressList
71 */ 71 */
72 struct GNUNET_CRYPTO_RsaSignature pong_signature; 72 struct GNUNET_CRYPTO_RsaSignature pong_signature;
73 73
74 /**
75 * Length of addr.
76 */
77 size_t addrlen;
78
79}; 74};
80 75
81 76
@@ -143,9 +138,8 @@ address_generator (void *cls, size_t max, void *buf)
143 if (NULL == gc->addr_pos) 138 if (NULL == gc->addr_pos)
144 return 0; 139 return 0;
145 ret = 140 ret =
146 GNUNET_HELLO_add_address (gc->addr_pos->plugin_name, gc->expiration, 141 GNUNET_HELLO_add_address (gc->addr_pos->address, gc->expiration,
147 &gc->addr_pos[1], gc->addr_pos->addrlen, buf, 142 buf, max);
148 max);
149 gc->addr_pos = gc->addr_pos->next; 143 gc->addr_pos = gc->addr_pos->next;
150 return ret; 144 return ret;
151} 145}
@@ -253,14 +247,11 @@ GST_hello_get ()
253 * Add or remove an address from this peer's HELLO message. 247 * Add or remove an address from this peer's HELLO message.
254 * 248 *
255 * @param addremove GNUNET_YES to add, GNUNET_NO to remove 249 * @param addremove GNUNET_YES to add, GNUNET_NO to remove
256 * @param plugin_name name of the plugin for which this is an address 250 * @param address address to add or remove
257 * @param plugin_address address in a plugin-specific format
258 * @param plugin_address_len number of bytes in plugin_address
259 */ 251 */
260void 252void
261GST_hello_modify_addresses (int addremove, const char *plugin_name, 253GST_hello_modify_addresses (int addremove,
262 const void *plugin_address, 254 const struct GNUNET_HELLO_Address *address)
263 size_t plugin_address_len)
264{ 255{
265 struct OwnAddressList *al; 256 struct OwnAddressList *al;
266 257
@@ -269,18 +260,18 @@ GST_hello_modify_addresses (int addremove, const char *plugin_name,
269 (add_remove == 260 (add_remove ==
270 GNUNET_YES) ? "Adding `%s':%s to the set of our addresses\n" : 261 GNUNET_YES) ? "Adding `%s':%s to the set of our addresses\n" :
271 "Removing `%s':%s from the set of our addresses\n", 262 "Removing `%s':%s from the set of our addresses\n",
272 GST_plugins_a2s (plugin_name, addr, addrlen), p->short_name); 263 GST_plugins_a2s (address), p->short_name);
273#endif 264#endif
274 GNUNET_assert (plugin_address != NULL); 265 GNUNET_assert (address != NULL);
275 if (GNUNET_NO == addremove) 266 if (GNUNET_NO == addremove)
276 { 267 {
277 for (al = oal_head; al != NULL; al = al->next) 268 for (al = oal_head; al != NULL; al = al->next)
278 if ((plugin_address_len == al->addrlen) && 269 if (0 ==
279 (0 == strcmp (al->plugin_name, plugin_name)) && 270 GNUNET_HELLO_address_cmp (address,
280 (0 == memcmp (plugin_address, &al[1], plugin_address_len))) 271 al->address))
281 { 272 {
282 GNUNET_CONTAINER_DLL_remove (oal_head, oal_tail, al); 273 GNUNET_CONTAINER_DLL_remove (oal_head, oal_tail, al);
283 GNUNET_free (al->plugin_name); 274 GNUNET_HELLO_address_free (al->address);
284 GNUNET_free (al); 275 GNUNET_free (al);
285 refresh_hello (); 276 refresh_hello ();
286 return; 277 return;
@@ -289,11 +280,9 @@ GST_hello_modify_addresses (int addremove, const char *plugin_name,
289 GNUNET_break (0); 280 GNUNET_break (0);
290 return; 281 return;
291 } 282 }
292 al = GNUNET_malloc (sizeof (struct OwnAddressList) + plugin_address_len); 283 al = GNUNET_malloc (sizeof (struct OwnAddressList));
293 GNUNET_CONTAINER_DLL_insert (oal_head, oal_tail, al); 284 GNUNET_CONTAINER_DLL_insert (oal_head, oal_tail, al);
294 al->plugin_name = GNUNET_strdup (plugin_name); 285 al->address = GNUNET_HELLO_address_copy (address);
295 al->addrlen = plugin_address_len;
296 memcpy (&al[1], plugin_address, plugin_address_len);
297 refresh_hello (); 286 refresh_hello ();
298} 287}
299 288
@@ -301,9 +290,7 @@ GST_hello_modify_addresses (int addremove, const char *plugin_name,
301/** 290/**
302 * Test if a particular address is one of ours. 291 * Test if a particular address is one of ours.
303 * 292 *
304 * @param plugin_name name of the plugin for which this is an address 293 * @param address address to test
305 * @param plugin_address address in a plugin-specific format
306 * @param plugin_address_len number of bytes in plugin_address
307 * @param sig location where to cache PONG signatures for this address [set] 294 * @param sig location where to cache PONG signatures for this address [set]
308 * @param sig_expiration how long until the current 'sig' expires? 295 * @param sig_expiration how long until the current 'sig' expires?
309 * (ZERO if sig was never created) [set] 296 * (ZERO if sig was never created) [set]
@@ -311,17 +298,15 @@ GST_hello_modify_addresses (int addremove, const char *plugin_name,
311 * GNUNET_NO if not 298 * GNUNET_NO if not
312 */ 299 */
313int 300int
314GST_hello_test_address (const char *plugin_name, const void *plugin_address, 301GST_hello_test_address (const struct GNUNET_HELLO_Address *address,
315 size_t plugin_address_len,
316 struct GNUNET_CRYPTO_RsaSignature **sig, 302 struct GNUNET_CRYPTO_RsaSignature **sig,
317 struct GNUNET_TIME_Absolute **sig_expiration) 303 struct GNUNET_TIME_Absolute **sig_expiration)
318{ 304{
319 struct OwnAddressList *al; 305 struct OwnAddressList *al;
320 306
321 for (al = oal_head; al != NULL; al = al->next) 307 for (al = oal_head; al != NULL; al = al->next)
322 if ((plugin_address_len == al->addrlen) && 308 if (0 == GNUNET_HELLO_address_cmp (address,
323 (0 == strcmp (al->plugin_name, plugin_name)) && 309 al->address))
324 (0 == memcmp (plugin_address, &al[1], plugin_address_len)))
325 { 310 {
326 *sig = &al->pong_signature; 311 *sig = &al->pong_signature;
327 *sig_expiration = &al->pong_sig_expires; 312 *sig_expiration = &al->pong_sig_expires;
diff --git a/src/transport/gnunet-service-transport_hello.h b/src/transport/gnunet-service-transport_hello.h
index 8d15ec6b5..168dd4364 100644
--- a/src/transport/gnunet-service-transport_hello.h
+++ b/src/transport/gnunet-service-transport_hello.h
@@ -29,6 +29,7 @@
29#include "gnunet_statistics_service.h" 29#include "gnunet_statistics_service.h"
30#include "gnunet_transport_service.h" 30#include "gnunet_transport_service.h"
31#include "gnunet_util_lib.h" 31#include "gnunet_util_lib.h"
32#include "gnunet_hello_lib.h"
32 33
33 34
34 35
@@ -72,22 +73,17 @@ GST_hello_get (void);
72 * Add or remove an address from this peer's HELLO message. 73 * Add or remove an address from this peer's HELLO message.
73 * 74 *
74 * @param addremove GNUNET_YES to add, GNUNET_NO to remove 75 * @param addremove GNUNET_YES to add, GNUNET_NO to remove
75 * @param plugin_name name of the plugin for which this is an address 76 * @param address address to add or remove
76 * @param plugin_address address in a plugin-specific format
77 * @param plugin_address_len number of bytes in plugin_address
78 */ 77 */
79void 78void
80GST_hello_modify_addresses (int addremove, const char *plugin_name, 79GST_hello_modify_addresses (int addremove,
81 const void *plugin_address, 80 const struct GNUNET_HELLO_Address *address);
82 size_t plugin_address_len);
83 81
84 82
85/** 83/**
86 * Test if a particular address is one of ours. 84 * Test if a particular address is one of ours.
87 * 85 *
88 * @param plugin_name name of the plugin for which this is an address 86 * @param address the address to test
89 * @param plugin_address address in a plugin-specific format
90 * @param plugin_address_len number of bytes in plugin_address
91 * @param sig location where to cache PONG signatures for this address [set] 87 * @param sig location where to cache PONG signatures for this address [set]
92 * @param sig_expiration how long until the current 'sig' expires? 88 * @param sig_expiration how long until the current 'sig' expires?
93 * (ZERO if sig was never created) [set] 89 * (ZERO if sig was never created) [set]
@@ -95,8 +91,7 @@ GST_hello_modify_addresses (int addremove, const char *plugin_name,
95 * GNUNET_NO if not 91 * GNUNET_NO if not
96 */ 92 */
97int 93int
98GST_hello_test_address (const char *plugin_name, const void *plugin_address, 94GST_hello_test_address (const struct GNUNET_HELLO_Address *address,
99 size_t plugin_address_len,
100 struct GNUNET_CRYPTO_RsaSignature **sig, 95 struct GNUNET_CRYPTO_RsaSignature **sig,
101 struct GNUNET_TIME_Absolute **sig_expiration); 96 struct GNUNET_TIME_Absolute **sig_expiration);
102 97
diff --git a/src/transport/gnunet-service-transport_neighbours.c b/src/transport/gnunet-service-transport_neighbours.c
index e6b298f4f..a127209dd 100644
--- a/src/transport/gnunet-service-transport_neighbours.c
+++ b/src/transport/gnunet-service-transport_neighbours.c
@@ -234,19 +234,9 @@ struct NeighbourMapEntry
234 struct Session *session; 234 struct Session *session;
235 235
236 /** 236 /**
237 * Name of the plugin we currently use. 237 * Address we currently use.
238 */ 238 */
239 char *plugin_name; 239 struct GNUNET_HELLO_Address *address;
240
241 /**
242 * Address used for communicating with the peer, NULL for inbound connections.
243 */
244 void *addr;
245
246 /**
247 * Number of bytes in 'addr'.
248 */
249 size_t addrlen;
250 240
251 /** 241 /**
252 * Identity of this neighbour. 242 * Identity of this neighbour.
@@ -432,8 +422,7 @@ reset_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
432 */ 422 */
433 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 423 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
434 "Information for developers: Connection to peer `%s' %s failed in state `%s', resetting connection attempt \n", 424 "Information for developers: Connection to peer `%s' %s failed in state `%s', resetting connection attempt \n",
435 GNUNET_i2s (&n->id), GST_plugins_a2s (n->plugin_name, n->addr, 425 GNUNET_i2s (&n->id), GST_plugins_a2s (n->address),
436 n->addrlen),
437 print_state (n->state)); 426 print_state (n->state));
438 427
439 GNUNET_STATISTICS_update (GST_stats, 428 GNUNET_STATISTICS_update (GST_stats,
@@ -445,8 +434,7 @@ reset_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
445 n->state = S_NOT_CONNECTED; 434 n->state = S_NOT_CONNECTED;
446 435
447 /* destroying address */ 436 /* destroying address */
448 GNUNET_ATS_address_destroyed (GST_ats, &n->id, n->plugin_name, n->addr, 437 GNUNET_ATS_address_destroyed (GST_ats, n->address, NULL);
449 n->addrlen, NULL);
450 438
451 /* request new address */ 439 /* request new address */
452 if (n->ats_suggest != GNUNET_SCHEDULER_NO_TASK) 440 if (n->ats_suggest != GNUNET_SCHEDULER_NO_TASK)
@@ -496,8 +484,7 @@ change (struct NeighbourMapEntry *n, int state, int line)
496#if DEBUG_TRANSPORT 484#if DEBUG_TRANSPORT
497 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 485 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
498 "Removed reset task for peer `%s' %s failed in state transition `%s' -> `%s' \n", 486 "Removed reset task for peer `%s' %s failed in state transition `%s' -> `%s' \n",
499 GNUNET_i2s (&n->id), GST_plugins_a2s (n->plugin_name, 487 GNUNET_i2s (&n->id), GST_plugins_a2s (n->address),
500 n->addr, n->addrlen),
501 print_state (n->state), print_state (state)); 488 print_state (n->state), print_state (state));
502#endif 489#endif
503 GNUNET_assert (n->state_reset != GNUNET_SCHEDULER_NO_TASK); 490 GNUNET_assert (n->state_reset != GNUNET_SCHEDULER_NO_TASK);
@@ -520,8 +507,7 @@ change (struct NeighbourMapEntry *n, int state, int line)
520#if DEBUG_TRANSPORT 507#if DEBUG_TRANSPORT
521 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 508 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
522 "Removed reset task for peer `%s' %s failed in state transition `%s' -> `%s' \n", 509 "Removed reset task for peer `%s' %s failed in state transition `%s' -> `%s' \n",
523 GNUNET_i2s (&n->id), GST_plugins_a2s (n->plugin_name, 510 GNUNET_i2s (&n->id), GST_plugins_a2s (n->address),
524 n->addr, n->addrlen),
525 print_state (n->state), print_state (state)); 511 print_state (n->state), print_state (state));
526#endif 512#endif
527 GNUNET_assert (n->state_reset != GNUNET_SCHEDULER_NO_TASK); 513 GNUNET_assert (n->state_reset != GNUNET_SCHEDULER_NO_TASK);
@@ -580,7 +566,7 @@ static ssize_t
580send_with_plugin (const struct GNUNET_PeerIdentity *target, const char *msgbuf, 566send_with_plugin (const struct GNUNET_PeerIdentity *target, const char *msgbuf,
581 size_t msgbuf_size, uint32_t priority, 567 size_t msgbuf_size, uint32_t priority,
582 struct GNUNET_TIME_Relative timeout, struct Session *session, 568 struct GNUNET_TIME_Relative timeout, struct Session *session,
583 const char *plugin_name, const void *addr, size_t addrlen, 569 const struct GNUNET_HELLO_Address *address,
584 int force_address, GNUNET_TRANSPORT_TransmitContinuation cont, 570 int force_address, GNUNET_TRANSPORT_TransmitContinuation cont,
585 void *cont_cls) 571 void *cont_cls)
586{ 572{
@@ -588,21 +574,21 @@ send_with_plugin (const struct GNUNET_PeerIdentity *target, const char *msgbuf,
588 size_t ret = GNUNET_SYSERR; 574 size_t ret = GNUNET_SYSERR;
589 575
590 /* FIXME : ats returns an address with all values 0 */ 576 /* FIXME : ats returns an address with all values 0 */
591 if (plugin_name == NULL) 577 if (address == NULL)
592 { 578 {
593 if (cont != NULL) 579 if (cont != NULL)
594 cont (cont_cls, target, GNUNET_SYSERR); 580 cont (cont_cls, target, GNUNET_SYSERR);
595 return GNUNET_SYSERR; 581 return GNUNET_SYSERR;
596 } 582 }
597 583
598 if ((session == NULL) && (addr == NULL) && (addrlen == 0)) 584 if ((session == NULL) && (address == NULL))
599 { 585 {
600 if (cont != NULL) 586 if (cont != NULL)
601 cont (cont_cls, target, GNUNET_SYSERR); 587 cont (cont_cls, target, GNUNET_SYSERR);
602 return GNUNET_SYSERR; 588 return GNUNET_SYSERR;
603 } 589 }
604 590
605 papi = GST_plugins_find (plugin_name); 591 papi = GST_plugins_find (address->transport_name);
606 if (papi == NULL) 592 if (papi == NULL)
607 { 593 {
608 if (cont != NULL) 594 if (cont != NULL)
@@ -612,7 +598,8 @@ send_with_plugin (const struct GNUNET_PeerIdentity *target, const char *msgbuf,
612 598
613 ret = 599 ret =
614 papi->send (papi->cls, target, msgbuf, msgbuf_size, 0, timeout, session, 600 papi->send (papi->cls, target, msgbuf, msgbuf_size, 0, timeout, session,
615 addr, addrlen, GNUNET_YES, cont, cont_cls); 601 address->address,
602 address->address_length, GNUNET_YES, cont, cont_cls);
616 603
617 if (ret == -1) 604 if (ret == -1)
618 { 605 {
@@ -706,7 +693,7 @@ try_transmission_to_peer (struct NeighbourMapEntry *n)
706 if (NULL == mq) 693 if (NULL == mq)
707 return; /* no more messages */ 694 return; /* no more messages */
708 695
709 if (GST_plugins_find (n->plugin_name) == NULL) 696 if (GST_plugins_find (n->address->transport_name) == NULL)
710 { 697 {
711 GNUNET_break (0); 698 GNUNET_break (0);
712 return; 699 return;
@@ -715,9 +702,10 @@ try_transmission_to_peer (struct NeighbourMapEntry *n)
715 n->is_active = mq; 702 n->is_active = mq;
716 mq->n = n; 703 mq->n = n;
717 704
718 if ((n->session == NULL) && (n->addr == NULL) && (n->addrlen == 0)) 705 if ( (n->session == NULL) && (NULL == n->address) )
719 { 706 {
720 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "No address for peer `%s'\n", 707 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
708 "No address for peer `%s'\n",
721 GNUNET_i2s (&n->id)); 709 GNUNET_i2s (&n->id));
722 transmit_send_continuation (mq, &n->id, GNUNET_SYSERR); 710 transmit_send_continuation (mq, &n->id, GNUNET_SYSERR);
723 GNUNET_assert (n->transmission_task == GNUNET_SCHEDULER_NO_TASK); 711 GNUNET_assert (n->transmission_task == GNUNET_SCHEDULER_NO_TASK);
@@ -727,8 +715,8 @@ try_transmission_to_peer (struct NeighbourMapEntry *n)
727 715
728 ret = 716 ret =
729 send_with_plugin (&n->id, mq->message_buf, mq->message_buf_size, 0, 717 send_with_plugin (&n->id, mq->message_buf, mq->message_buf_size, 0,
730 timeout, n->session, n->plugin_name, n->addr, 718 timeout, n->session, n->address,
731 n->addrlen, GNUNET_YES, &transmit_send_continuation, 719 GNUNET_YES, &transmit_send_continuation,
732 mq); 720 mq);
733 if (ret == -1) 721 if (ret == -1)
734 { 722 {
@@ -789,8 +777,8 @@ send_disconnect_cont (void *cls, const struct GNUNET_PeerIdentity *target,
789 777
790static int 778static int
791send_disconnect (const struct GNUNET_PeerIdentity *target, 779send_disconnect (const struct GNUNET_PeerIdentity *target,
792 const char *plugin_name, const char *sender_address, 780 const struct GNUNET_HELLO_Address *address,
793 uint16_t sender_address_len, struct Session *session) 781 struct Session *session)
794{ 782{
795 size_t ret; 783 size_t ret;
796 struct SessionDisconnectMessage disconnect_msg; 784 struct SessionDisconnectMessage disconnect_msg;
@@ -821,8 +809,8 @@ send_disconnect (const struct GNUNET_PeerIdentity *target,
821 ret = 809 ret =
822 send_with_plugin (target, (const char *) &disconnect_msg, 810 send_with_plugin (target, (const char *) &disconnect_msg,
823 sizeof (disconnect_msg), UINT32_MAX, 811 sizeof (disconnect_msg), UINT32_MAX,
824 GNUNET_TIME_UNIT_FOREVER_REL, session, plugin_name, 812 GNUNET_TIME_UNIT_FOREVER_REL, session, address,
825 sender_address, sender_address_len, GNUNET_YES, 813 GNUNET_YES,
826 &send_disconnect_cont, NULL); 814 &send_disconnect_cont, NULL);
827 815
828 if (ret == GNUNET_SYSERR) 816 if (ret == GNUNET_SYSERR)
@@ -850,7 +838,7 @@ disconnect_neighbour (struct NeighbourMapEntry *n)
850 if (is_connected (n) || is_connecting (n)) 838 if (is_connected (n) || is_connecting (n))
851 { 839 {
852 if (GNUNET_OK == 840 if (GNUNET_OK ==
853 send_disconnect (&n->id, n->plugin_name, n->addr, n->addrlen, 841 send_disconnect (&n->id, n->address,
854 n->session)) 842 n->session))
855 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sent DISCONNECT_MSG to `%s'\n", 843 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sent DISCONNECT_MSG to `%s'\n",
856 GNUNET_i2s (&n->id)); 844 GNUNET_i2s (&n->id));
@@ -862,8 +850,7 @@ disconnect_neighbour (struct NeighbourMapEntry *n)
862 850
863 if (is_connected(n)) 851 if (is_connected(n))
864 { 852 {
865 GNUNET_ATS_address_in_use (GST_ats, &n->id, n->plugin_name, 853 GNUNET_ATS_address_in_use (GST_ats, n->address, n->session, GNUNET_NO);
866 n->addr, n->addrlen, n->session, GNUNET_NO);
867 } 854 }
868 855
869 856
@@ -871,16 +858,14 @@ disconnect_neighbour (struct NeighbourMapEntry *n)
871 return; 858 return;
872 change_state (n, S_DISCONNECT); 859 change_state (n, S_DISCONNECT);
873 GST_validation_set_address_use (&n->id, 860 GST_validation_set_address_use (&n->id,
874 n->plugin_name, 861 n->address,
875 n->session, 862 n->session,
876 n->addr,
877 n->addrlen,
878 GNUNET_NO); 863 GNUNET_NO);
879 864
880 if (n->plugin_name != NULL) 865 if (n->address != NULL)
881 { 866 {
882 struct GNUNET_TRANSPORT_PluginFunctions *papi; 867 struct GNUNET_TRANSPORT_PluginFunctions *papi;
883 papi = GST_plugins_find (n->plugin_name); 868 papi = GST_plugins_find (n->address->transport_name);
884 if (papi != NULL) 869 if (papi != NULL)
885 papi->disconnect (papi->cls, &n->id); 870 papi->disconnect (papi->cls, &n->id);
886 } 871 }
@@ -926,16 +911,10 @@ disconnect_neighbour (struct NeighbourMapEntry *n)
926 GNUNET_SCHEDULER_cancel (n->transmission_task); 911 GNUNET_SCHEDULER_cancel (n->transmission_task);
927 n->transmission_task = GNUNET_SCHEDULER_NO_TASK; 912 n->transmission_task = GNUNET_SCHEDULER_NO_TASK;
928 } 913 }
929 if (NULL != n->plugin_name) 914 if (NULL != n->address)
930 {
931 GNUNET_free (n->plugin_name);
932 n->plugin_name = NULL;
933 }
934 if (NULL != n->addr)
935 { 915 {
936 GNUNET_free (n->addr); 916 GNUNET_HELLO_address_free (n->address);
937 n->addr = NULL; 917 n->address = NULL;
938 n->addrlen = 0;
939 } 918 }
940 n->session = NULL; 919 n->session = NULL;
941 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Deleting peer `%4s', %X\n", 920 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Deleting peer `%4s', %X\n",
@@ -990,8 +969,8 @@ neighbour_keepalive_task (void *cls,
990 969
991 send_with_plugin (&n->id, (const void *) &m, sizeof (m), 970 send_with_plugin (&n->id, (const void *) &m, sizeof (m),
992 UINT32_MAX /* priority */ , 971 UINT32_MAX /* priority */ ,
993 GNUNET_TIME_UNIT_FOREVER_REL, n->session, n->plugin_name, 972 GNUNET_TIME_UNIT_FOREVER_REL, n->session, n->address,
994 n->addr, n->addrlen, GNUNET_YES, NULL, NULL); 973 GNUNET_YES, NULL, NULL);
995} 974}
996 975
997 976
@@ -1083,14 +1062,12 @@ send_connect_continuation (void *cls, const struct GNUNET_PeerIdentity *target,
1083#if DEBUG_TRANSPORT 1062#if DEBUG_TRANSPORT
1084 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1063 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1085 "Failed to send CONNECT_MSG to peer `%4s' with plugin `%s' address '%s' session %X, asking ATS for new address \n", 1064 "Failed to send CONNECT_MSG to peer `%4s' with plugin `%s' address '%s' session %X, asking ATS for new address \n",
1086 GNUNET_i2s (&n->id), n->plugin_name, 1065 GNUNET_i2s (&n->id), n->address->transport_name,
1087 (n->addrlen == 1066 (n->addrlen ==
1088 0) ? "<inbound>" : GST_plugins_a2s (n->plugin_name, n->addr, 1067 0) ? "<inbound>" : GST_plugins_a2s (n->address), n->session);
1089 n->addrlen), n->session);
1090#endif 1068#endif
1091 1069
1092 GNUNET_ATS_address_destroyed (GST_ats, &n->id, n->plugin_name, n->addr, 1070 GNUNET_ATS_address_destroyed (GST_ats, n->address, NULL);
1093 n->addrlen, NULL);
1094 1071
1095 change_state (n, S_NOT_CONNECTED); 1072 change_state (n, S_NOT_CONNECTED);
1096 1073
@@ -1131,14 +1108,12 @@ send_switch_address_continuation (void *cls,
1131#if DEBUG_TRANSPORT 1108#if DEBUG_TRANSPORT
1132 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1109 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1133 "Failed to switch connected peer `%s' to plugin `%s' address '%s' session %X, asking ATS for new address \n", 1110 "Failed to switch connected peer `%s' to plugin `%s' address '%s' session %X, asking ATS for new address \n",
1134 GNUNET_i2s (&n->id), n->plugin_name, 1111 GNUNET_i2s (&n->id), n->address->transport_name,
1135 (n->addrlen == 1112 (n->addrlen ==
1136 0) ? "<inbound>" : GST_plugins_a2s (n->plugin_name, n->addr, 1113 0) ? "<inbound>" : GST_plugins_a2s (n->address), n->session);
1137 n->addrlen), n->session);
1138#endif 1114#endif
1139 1115
1140 GNUNET_ATS_address_destroyed (GST_ats, &n->id, n->plugin_name, n->addr, 1116 GNUNET_ATS_address_destroyed (GST_ats, n->address, NULL);
1141 n->addrlen, NULL);
1142 1117
1143 if (n->ats_suggest != GNUNET_SCHEDULER_NO_TASK) 1118 if (n->ats_suggest != GNUNET_SCHEDULER_NO_TASK)
1144 GNUNET_SCHEDULER_cancel (n->ats_suggest); 1119 GNUNET_SCHEDULER_cancel (n->ats_suggest);
@@ -1149,8 +1124,7 @@ send_switch_address_continuation (void *cls,
1149 return; 1124 return;
1150 } 1125 }
1151 /* Tell ATS that switching addresses was successful */ 1126 /* Tell ATS that switching addresses was successful */
1152 GNUNET_ATS_address_in_use (GST_ats, &n->id, n->plugin_name, n->addr, 1127 GNUNET_ATS_address_in_use (GST_ats, n->address, n->session, GNUNET_YES);
1153 n->addrlen, n->addr, GNUNET_YES);
1154} 1128}
1155 1129
1156/** 1130/**
@@ -1177,16 +1151,13 @@ send_connect_ack_continuation (void *cls,
1177#if DEBUG_TRANSPORT 1151#if DEBUG_TRANSPORT
1178 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1152 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1179 "Failed to send CONNECT_MSG to peer `%4s' with plugin `%s' address '%s' session %X, asking ATS for new address \n", 1153 "Failed to send CONNECT_MSG to peer `%4s' with plugin `%s' address '%s' session %X, asking ATS for new address \n",
1180 GNUNET_i2s (&n->id), n->plugin_name, 1154 GNUNET_i2s (&n->id), n->address->transport_name,
1181 (n->addrlen == 0) ? "<inbound>" : GST_plugins_a2s (n->plugin_name, 1155 (n->addrlen == 0) ? "<inbound>" : GST_plugins_a2s (n->address),
1182 n->addr,
1183 n->addrlen),
1184 n->session); 1156 n->session);
1185#endif 1157#endif
1186 change_state (n, S_NOT_CONNECTED); 1158 change_state (n, S_NOT_CONNECTED);
1187 1159
1188 GNUNET_ATS_address_destroyed (GST_ats, &n->id, n->plugin_name, n->addr, 1160 GNUNET_ATS_address_destroyed (GST_ats, n->address, NULL);
1189 n->addrlen, NULL);
1190 1161
1191 if (n->ats_suggest != GNUNET_SCHEDULER_NO_TASK) 1162 if (n->ats_suggest != GNUNET_SCHEDULER_NO_TASK)
1192 GNUNET_SCHEDULER_cancel (n->ats_suggest); 1163 GNUNET_SCHEDULER_cancel (n->ats_suggest);
@@ -1201,10 +1172,8 @@ send_connect_ack_continuation (void *cls,
1201 * the given address. 1172 * the given address.
1202 * 1173 *
1203 * @param peer identity of the peer to switch the address for 1174 * @param peer identity of the peer to switch the address for
1204 * @param plugin_name name of transport that delivered the PONG
1205 * @param address address of the other peer, NULL if other peer 1175 * @param address address of the other peer, NULL if other peer
1206 * connected to us 1176 * connected to us
1207 * @param address_len number of bytes in address
1208 * @param session session to use (or NULL) 1177 * @param session session to use (or NULL)
1209 * @param ats performance data 1178 * @param ats performance data
1210 * @param ats_count number of entries in ats 1179 * @param ats_count number of entries in ats
@@ -1213,8 +1182,7 @@ send_connect_ack_continuation (void *cls,
1213 */ 1182 */
1214int 1183int
1215GST_neighbours_switch_to_address_3way (const struct GNUNET_PeerIdentity *peer, 1184GST_neighbours_switch_to_address_3way (const struct GNUNET_PeerIdentity *peer,
1216 const char *plugin_name, 1185 const struct GNUNET_HELLO_Address *address,
1217 const void *address, size_t address_len,
1218 struct Session *session, 1186 struct Session *session,
1219 const struct GNUNET_ATS_Information *ats, 1187 const struct GNUNET_ATS_Information *ats,
1220 uint32_t ats_count, 1188 uint32_t ats_count,
@@ -1237,14 +1205,14 @@ GST_neighbours_switch_to_address_3way (const struct GNUNET_PeerIdentity *peer,
1237 1205
1238 checks_failed = GNUNET_NO; 1206 checks_failed = GNUNET_NO;
1239 1207
1240 if (plugin_name == NULL) 1208 if (address == NULL)
1241 { 1209 {
1242 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 1210 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
1243 "ATS offered suggested us empty address: plugin NULL"); 1211 "ATS offered suggested us empty address: plugin NULL");
1244 GNUNET_break_op (0); 1212 GNUNET_break_op (0);
1245 checks_failed = GNUNET_YES; 1213 checks_failed = GNUNET_YES;
1246 } 1214 }
1247 if ((address == NULL) && (address_len == 0) && (session == NULL)) 1215 if ( (session == NULL) && (address == NULL) )
1248 { 1216 {
1249 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 1217 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
1250 "ATS offered suggested us empty address: address NULL & session NULL"); 1218 "ATS offered suggested us empty address: address NULL & session NULL");
@@ -1258,8 +1226,7 @@ GST_neighbours_switch_to_address_3way (const struct GNUNET_PeerIdentity *peer,
1258 1226
1259 if (checks_failed == GNUNET_YES) 1227 if (checks_failed == GNUNET_YES)
1260 { 1228 {
1261 GNUNET_ATS_address_destroyed (GST_ats, peer, plugin_name, address, 1229 GNUNET_ATS_address_destroyed (GST_ats, address, session);
1262 address_len, session);
1263 if (n != NULL) 1230 if (n != NULL)
1264 GNUNET_ATS_suggest_address (GST_ats, peer); 1231 GNUNET_ATS_suggest_address (GST_ats, peer);
1265 return GNUNET_NO; 1232 return GNUNET_NO;
@@ -1269,10 +1236,8 @@ GST_neighbours_switch_to_address_3way (const struct GNUNET_PeerIdentity *peer,
1269#if DEBUG_TRANSPORT 1236#if DEBUG_TRANSPORT
1270 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1237 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1271 "ATS tells us to switch to plugin `%s' address '%s' session %X for %s peer `%s'\n", 1238 "ATS tells us to switch to plugin `%s' address '%s' session %X for %s peer `%s'\n",
1272 plugin_name, 1239 address->transport_name,
1273 (address_len == 0) ? "<inbound>" : GST_plugins_a2s (plugin_name, 1240 (address_len == 0) ? "<inbound>" : GST_plugins_a2s (address),
1274 address,
1275 address_len),
1276 session, (is_connected (n) ? "CONNECTED" : "NOT CONNECTED"), 1241 session, (is_connected (n) ? "CONNECTED" : "NOT CONNECTED"),
1277 GNUNET_i2s (peer)); 1242 GNUNET_i2s (peer));
1278#endif 1243#endif
@@ -1284,66 +1249,57 @@ GST_neighbours_switch_to_address_3way (const struct GNUNET_PeerIdentity *peer,
1284 } 1249 }
1285 1250
1286 // do not switch addresses just update quotas 1251 // do not switch addresses just update quotas
1287 if ((is_connected (n)) && (address_len == n->addrlen)) 1252 if ( (is_connected (n)) &&
1253 (0 == GNUNET_HELLO_address_cmp (address,
1254 n->address)) &&
1255 (n->session == session) )
1288 { 1256 {
1289 if ((0 == memcmp (address, n->addr, address_len)) && 1257 struct QuotaSetMessage q_msg;
1290 (n->session == session)) 1258
1291 {
1292 struct QuotaSetMessage q_msg;
1293
1294#if DEBUG_TRANSPORT 1259#if DEBUG_TRANSPORT
1295 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1260 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1296 "Sending outbound quota of %u Bps and inbound quota of %u Bps for peer `%s' to all clients\n", 1261 "Sending outbound quota of %u Bps and inbound quota of %u Bps for peer `%s' to all clients\n",
1297 ntohl (n->bandwidth_out.value__), 1262 ntohl (n->bandwidth_out.value__),
1298 ntohl (n->bandwidth_in.value__), GNUNET_i2s (peer)); 1263 ntohl (n->bandwidth_in.value__), GNUNET_i2s (peer));
1299#endif 1264#endif
1300 1265
1301 n->bandwidth_in = bandwidth_in; 1266 n->bandwidth_in = bandwidth_in;
1302 n->bandwidth_out = bandwidth_out; 1267 n->bandwidth_out = bandwidth_out;
1303 GST_neighbours_set_incoming_quota (&n->id, n->bandwidth_in); 1268 GST_neighbours_set_incoming_quota (&n->id, n->bandwidth_in);
1304 1269
1305 q_msg.header.size = htons (sizeof (struct QuotaSetMessage)); 1270 q_msg.header.size = htons (sizeof (struct QuotaSetMessage));
1306 q_msg.header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_SET_QUOTA); 1271 q_msg.header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_SET_QUOTA);
1307 q_msg.quota = n->bandwidth_out; 1272 q_msg.quota = n->bandwidth_out;
1308 q_msg.peer = (*peer); 1273 q_msg.peer = (*peer);
1309 GST_clients_broadcast (&q_msg.header, GNUNET_NO); 1274 GST_clients_broadcast (&q_msg.header, GNUNET_NO);
1310 return GNUNET_NO; 1275 return GNUNET_NO;
1311 }
1312 } 1276 }
1313 if (n->state == S_CONNECTED) 1277 if (n->state == S_CONNECTED)
1314 GST_validation_set_address_use (&n->id, 1278 GST_validation_set_address_use (&n->id,
1315 n->plugin_name, 1279 n->address,
1316 n->session, 1280 n->session,
1317 n->addr,
1318 n->addrlen,
1319 GNUNET_NO); 1281 GNUNET_NO);
1320 /* This will be a connection switch, tell ATS about it */ 1282 /* This will be a connection switch, tell ATS about it */
1321 if (n->state == S_CONNECTED) 1283 if (n->state == S_CONNECTED)
1322 { 1284 {
1323 GNUNET_ATS_address_in_use (GST_ats, &n->id, n->plugin_name, n->addr, 1285 GNUNET_ATS_address_in_use (GST_ats, n->address, n->session, GNUNET_NO);
1324 n->addrlen, n->addr, GNUNET_NO);
1325 } 1286 }
1326 1287
1327 /* set new address */ 1288 /* set new address */
1328 GNUNET_free_non_null (n->addr); 1289 if (NULL != n->address)
1329 n->addr = GNUNET_malloc (address_len); 1290 GNUNET_HELLO_address_free (n->address);
1330 memcpy (n->addr, address, address_len); 1291 n->address = GNUNET_HELLO_address_copy (address);
1331 n->bandwidth_in = bandwidth_in; 1292 n->bandwidth_in = bandwidth_in;
1332 n->bandwidth_out = bandwidth_out; 1293 n->bandwidth_out = bandwidth_out;
1333 n->addrlen = address_len;
1334 n->session = session; 1294 n->session = session;
1335 GNUNET_free_non_null (n->plugin_name);
1336 n->plugin_name = GNUNET_strdup (plugin_name);
1337 GNUNET_SCHEDULER_cancel (n->timeout_task); 1295 GNUNET_SCHEDULER_cancel (n->timeout_task);
1338 n->timeout_task = 1296 n->timeout_task =
1339 GNUNET_SCHEDULER_add_delayed (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT, 1297 GNUNET_SCHEDULER_add_delayed (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT,
1340 &neighbour_timeout_task, n); 1298 &neighbour_timeout_task, n);
1341 if (n->state == S_CONNECTED) 1299 if (n->state == S_CONNECTED)
1342 GST_validation_set_address_use (&n->id, 1300 GST_validation_set_address_use (&n->id,
1343 n->plugin_name, 1301 n->address,
1344 n->session, 1302 n->session,
1345 n->addr,
1346 n->addrlen,
1347 GNUNET_YES); 1303 GNUNET_YES);
1348 1304
1349 1305
@@ -1368,7 +1324,7 @@ GST_neighbours_switch_to_address_3way (const struct GNUNET_PeerIdentity *peer,
1368 ret = 1324 ret =
1369 send_with_plugin (peer, (const char *) &connect_msg, msg_len, 1325 send_with_plugin (peer, (const char *) &connect_msg, msg_len,
1370 UINT32_MAX, GNUNET_TIME_UNIT_FOREVER_REL, session, 1326 UINT32_MAX, GNUNET_TIME_UNIT_FOREVER_REL, session,
1371 plugin_name, address, address_len, GNUNET_YES, 1327 address, GNUNET_YES,
1372 &send_connect_continuation, n); 1328 &send_connect_continuation, n);
1373 1329
1374 1330
@@ -1388,7 +1344,7 @@ GST_neighbours_switch_to_address_3way (const struct GNUNET_PeerIdentity *peer,
1388 ret = 1344 ret =
1389 send_with_plugin (&n->id, (const void *) &connect_msg, msg_len, 1345 send_with_plugin (&n->id, (const void *) &connect_msg, msg_len,
1390 UINT32_MAX, GNUNET_TIME_UNIT_FOREVER_REL, session, 1346 UINT32_MAX, GNUNET_TIME_UNIT_FOREVER_REL, session,
1391 plugin_name, address, address_len, GNUNET_YES, 1347 address, GNUNET_YES,
1392 &send_connect_ack_continuation, n); 1348 &send_connect_ack_continuation, n);
1393 return GNUNET_NO; 1349 return GNUNET_NO;
1394 } 1350 }
@@ -1406,16 +1362,14 @@ GST_neighbours_switch_to_address_3way (const struct GNUNET_PeerIdentity *peer,
1406 ret = 1362 ret =
1407 send_with_plugin (peer, (const char *) &connect_msg, msg_len, 1363 send_with_plugin (peer, (const char *) &connect_msg, msg_len,
1408 UINT32_MAX, GNUNET_TIME_UNIT_FOREVER_REL, session, 1364 UINT32_MAX, GNUNET_TIME_UNIT_FOREVER_REL, session,
1409 plugin_name, address, address_len, GNUNET_YES, 1365 address, GNUNET_YES,
1410 &send_switch_address_continuation, n); 1366 &send_switch_address_continuation, n);
1411 if (ret == GNUNET_SYSERR) 1367 if (ret == GNUNET_SYSERR)
1412 { 1368 {
1413 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1369 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1414 "Failed to send CONNECT_MESSAGE to `%4s' using plugin `%s' address '%s' session %X\n", 1370 "Failed to send CONNECT_MESSAGE to `%4s' using address '%s' session %X\n",
1415 GNUNET_i2s (peer), plugin_name, 1371 GNUNET_i2s (peer),
1416 (address_len == 1372 GST_plugins_a2s (address), session);
1417 0) ? "<inbound>" : GST_plugins_a2s (plugin_name, address,
1418 address_len), session);
1419 } 1373 }
1420 return GNUNET_NO; 1374 return GNUNET_NO;
1421 } 1375 }
@@ -1446,10 +1400,8 @@ GST_neighbour_get_latency (const struct GNUNET_PeerIdentity *peer)
1446 if (NULL == n) 1400 if (NULL == n)
1447 return GNUNET_TIME_UNIT_FOREVER_REL; 1401 return GNUNET_TIME_UNIT_FOREVER_REL;
1448 return GST_validation_get_address_latency (peer, 1402 return GST_validation_get_address_latency (peer,
1449 n->plugin_name, 1403 n->address,
1450 n->session, 1404 n->session);
1451 n->addr,
1452 n->addrlen);
1453} 1405}
1454 1406
1455 1407
@@ -1587,9 +1539,11 @@ GST_neighbours_session_terminated (const struct GNUNET_PeerIdentity *peer,
1587 return; /* doesn't affect us */ 1539 return; /* doesn't affect us */
1588 1540
1589 n->session = NULL; 1541 n->session = NULL;
1590 GNUNET_free (n->addr); 1542 if (NULL != n->address)
1591 n->addr = NULL; 1543 {
1592 n->addrlen = 0; 1544 GNUNET_HELLO_address_free (n->address);
1545 n->address = NULL;
1546 }
1593 1547
1594 /* not connected anymore anyway, shouldn't matter */ 1548 /* not connected anymore anyway, shouldn't matter */
1595 if ((!is_connected (n)) && (!is_connecting (n))) 1549 if ((!is_connected (n)) && (!is_connecting (n)))
@@ -1656,7 +1610,7 @@ GST_neighbours_send (const struct GNUNET_PeerIdentity *target, const void *msg,
1656 return; 1610 return;
1657 } 1611 }
1658 1612
1659 if ((n->session == NULL) && (n->addr == NULL) && (n->addrlen == 0)) 1613 if ((n->session == NULL) && (n->address == NULL) )
1660 { 1614 {
1661 GNUNET_STATISTICS_update (GST_stats, 1615 GNUNET_STATISTICS_update (GST_stats,
1662 gettext_noop 1616 gettext_noop
@@ -1898,7 +1852,7 @@ neighbours_iterate (void *cls, const GNUNET_HashCode * key, void *value)
1898 if (!is_connected (n)) 1852 if (!is_connected (n))
1899 return GNUNET_OK; 1853 return GNUNET_OK;
1900 1854
1901 ic->cb (ic->cb_cls, &n->id, NULL, 0, n->plugin_name, n->addr, n->addrlen); 1855 ic->cb (ic->cb_cls, &n->id, NULL, 0, n->address);
1902 return GNUNET_OK; 1856 return GNUNET_OK;
1903} 1857}
1904 1858
@@ -1946,7 +1900,7 @@ GST_neighbours_force_disconnect (const struct GNUNET_PeerIdentity *target)
1946 return; /* not active */ 1900 return; /* not active */
1947 if (is_connected (n)) 1901 if (is_connected (n))
1948 { 1902 {
1949 send_disconnect (&n->id, n->plugin_name, n->addr, n->addrlen, n->session); 1903 send_disconnect (&n->id, n->address, n->session);
1950 1904
1951 n = lookup_neighbour (target); 1905 n = lookup_neighbour (target);
1952 if (NULL == n) 1906 if (NULL == n)
@@ -2028,26 +1982,23 @@ GST_neighbours_handle_disconnect_message (const struct GNUNET_PeerIdentity
2028 GST_neighbours_force_disconnect (peer); 1982 GST_neighbours_force_disconnect (peer);
2029} 1983}
2030 1984
1985
2031/** 1986/**
2032 * We received a 'SESSION_CONNECT_ACK' message from the other peer. 1987 * We received a 'SESSION_CONNECT_ACK' message from the other peer.
2033 * Consider switching to it. 1988 * Consider switching to it.
2034 * 1989 *
2035 * @param message possibly a 'struct SessionConnectMessage' (check format) 1990 * @param message possibly a 'struct SessionConnectMessage' (check format)
2036 * @param peer identity of the peer to switch the address for 1991 * @param peer identity of the peer to switch the address for
2037 * @param plugin_name name of transport that delivered the PONG
2038 * @param address address of the other peer, NULL if other peer 1992 * @param address address of the other peer, NULL if other peer
2039 * connected to us 1993 * connected to us
2040 * @param address_len number of bytes in address
2041 * @param session session to use (or NULL) 1994 * @param session session to use (or NULL)
2042 * @param ats performance data 1995 * @param ats performance data
2043 * @param ats_count number of entries in ats 1996 * @param ats_count number of entries in ats
2044 */ 1997 */
2045void 1998void
2046GST_neighbours_handle_connect_ack (const struct GNUNET_MessageHeader *message, 1999GST_neighbours_handle_connect_ack (const struct GNUNET_MessageHeader *message,
2047 const struct GNUNET_PeerIdentity *peer, 2000 const struct GNUNET_PeerIdentity *peer,
2048 const char *plugin_name, 2001 const struct GNUNET_HELLO_Address *address,
2049 const char *sender_address,
2050 uint16_t sender_address_len,
2051 struct Session *session, 2002 struct Session *session,
2052 const struct GNUNET_ATS_Information *ats, 2003 const struct GNUNET_ATS_Information *ats,
2053 uint32_t ats_count) 2004 uint32_t ats_count)
@@ -2090,24 +2041,20 @@ GST_neighbours_handle_connect_ack (const struct GNUNET_MessageHeader *message,
2090 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG | GNUNET_ERROR_TYPE_BULK, 2041 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG | GNUNET_ERROR_TYPE_BULK,
2091 "transport-ats", 2042 "transport-ats",
2092 "Giving ATS session %p of plugin %s for peer %s\n", 2043 "Giving ATS session %p of plugin %s for peer %s\n",
2093 session, plugin_name, GNUNET_i2s (peer)); 2044 session, address->transport_name, GNUNET_i2s (peer));
2094 GNUNET_ATS_address_update (GST_ats, peer, plugin_name, sender_address, 2045 GNUNET_ATS_address_update (GST_ats, address, session, ats, ats_count);
2095 sender_address_len, session, ats, ats_count);
2096 2046
2097 was_connected = is_connected (n); 2047 was_connected = is_connected (n);
2098 if (!is_connected (n)) 2048 if (!is_connected (n))
2099 { 2049 {
2100 change_state (n, S_CONNECTED); 2050 change_state (n, S_CONNECTED);
2101 GST_validation_set_address_use (&n->id, 2051 GST_validation_set_address_use (&n->id,
2102 n->plugin_name, 2052 n->address,
2103 n->session, 2053 n->session,
2104 n->addr,
2105 n->addrlen,
2106 GNUNET_YES); 2054 GNUNET_YES);
2107 } 2055 }
2108 2056
2109 GNUNET_ATS_address_in_use (GST_ats, &n->id, n->plugin_name, n->addr, 2057 GNUNET_ATS_address_in_use (GST_ats, n->address, NULL, GNUNET_YES);
2110 n->addrlen, n->addr, GNUNET_YES);
2111 2058
2112#if DEBUG_TRANSPORT 2059#if DEBUG_TRANSPORT
2113 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 2060 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
@@ -2124,16 +2071,14 @@ GST_neighbours_handle_connect_ack (const struct GNUNET_MessageHeader *message,
2124 ret = 2071 ret =
2125 send_with_plugin (&n->id, (const char *) &msg, msg_len, UINT32_MAX, 2072 send_with_plugin (&n->id, (const char *) &msg, msg_len, UINT32_MAX,
2126 GNUNET_TIME_UNIT_FOREVER_REL, n->session, 2073 GNUNET_TIME_UNIT_FOREVER_REL, n->session,
2127 n->plugin_name, n->addr, n->addrlen, GNUNET_YES, NULL, 2074 n->address, GNUNET_YES, NULL,
2128 NULL); 2075 NULL);
2129 2076
2130 if (ret == GNUNET_SYSERR) 2077 if (ret == GNUNET_SYSERR)
2131 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 2078 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
2132 "Failed to send SESSION_ACK to `%4s' using plugin `%s' address '%s' session %X\n", 2079 "Failed to send SESSION_ACK to `%4s' using address '%s' session %X\n",
2133 GNUNET_i2s (&n->id), n->plugin_name, 2080 GNUNET_i2s (&n->id),
2134 (n->addrlen == 2081 GST_plugins_a2s (n->address), n->session);
2135 0) ? "<inbound>" : GST_plugins_a2s (n->plugin_name, n->addr,
2136 n->addrlen), n->session);
2137 2082
2138 2083
2139 if (!was_connected) 2084 if (!was_connected)
@@ -2148,11 +2093,9 @@ GST_neighbours_handle_connect_ack (const struct GNUNET_MessageHeader *message,
2148 GNUNET_NO); 2093 GNUNET_NO);
2149#if DEBUG_TRANSPORT 2094#if DEBUG_TRANSPORT
2150 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 2095 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
2151 "Notify about connect of `%4s' using plugin `%s' address '%s' session %X LINE %u\n", 2096 "Notify about connect of `%4s' using address '%s' session %X LINE %u\n",
2152 GNUNET_i2s (&n->id), n->plugin_name, 2097 GNUNET_i2s (&n->id),
2153 (n->addrlen == 2098 GST_plugins_a2s (n->address), n->session,
2154 0) ? "<inbound>" : GST_plugins_a2s (n->plugin_name, n->addr,
2155 n->addrlen), n->session,
2156 __LINE__); 2099 __LINE__);
2157#endif 2100#endif
2158 connect_notify_cb (callback_cls, &n->id, ats, ats_count); 2101 connect_notify_cb (callback_cls, &n->id, ats, ats_count);
@@ -2174,8 +2117,8 @@ GST_neighbours_handle_connect_ack (const struct GNUNET_MessageHeader *message,
2174void 2117void
2175GST_neighbours_handle_ack (const struct GNUNET_MessageHeader *message, 2118GST_neighbours_handle_ack (const struct GNUNET_MessageHeader *message,
2176 const struct GNUNET_PeerIdentity *peer, 2119 const struct GNUNET_PeerIdentity *peer,
2177 const char *plugin_name, const char *sender_address, 2120 const struct GNUNET_HELLO_Address *address,
2178 uint16_t sender_address_len, struct Session *session, 2121 struct Session *session,
2179 const struct GNUNET_ATS_Information *ats, 2122 const struct GNUNET_ATS_Information *ats,
2180 uint32_t ats_count) 2123 uint32_t ats_count)
2181{ 2124{
@@ -2197,7 +2140,7 @@ GST_neighbours_handle_ack (const struct GNUNET_MessageHeader *message,
2197 n = lookup_neighbour (peer); 2140 n = lookup_neighbour (peer);
2198 if (NULL == n) 2141 if (NULL == n)
2199 { 2142 {
2200 send_disconnect (peer, plugin_name, sender_address, sender_address_len, 2143 send_disconnect (peer, address,
2201 session); 2144 session);
2202 GNUNET_break (0); 2145 GNUNET_break (0);
2203 return; 2146 return;
@@ -2217,15 +2160,13 @@ GST_neighbours_handle_ack (const struct GNUNET_MessageHeader *message,
2217 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG | GNUNET_ERROR_TYPE_BULK, 2160 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG | GNUNET_ERROR_TYPE_BULK,
2218 "transport-ats", 2161 "transport-ats",
2219 "Giving ATS session %p of plugin %s for peer %s\n", 2162 "Giving ATS session %p of plugin %s for peer %s\n",
2220 session, plugin_name, GNUNET_i2s (peer)); 2163 session, address->transport_name, GNUNET_i2s (peer));
2221 GNUNET_ATS_address_update (GST_ats, peer, plugin_name, sender_address, 2164 GNUNET_ATS_address_update (GST_ats, address, session, ats, ats_count);
2222 sender_address_len, session, ats, ats_count);
2223 2165
2224 was_connected = is_connected (n); 2166 was_connected = is_connected (n);
2225 change_state (n, S_CONNECTED); 2167 change_state (n, S_CONNECTED);
2226 2168
2227 GNUNET_ATS_address_in_use (GST_ats, &n->id, n->plugin_name, n->addr, 2169 GNUNET_ATS_address_in_use (GST_ats, n->address, n->session, GNUNET_YES);
2228 n->addrlen, n->addr, GNUNET_YES);
2229 2170
2230 GST_neighbours_set_incoming_quota (&n->id, n->bandwidth_in); 2171 GST_neighbours_set_incoming_quota (&n->id, n->bandwidth_in);
2231 2172
@@ -2237,10 +2178,8 @@ GST_neighbours_handle_ack (const struct GNUNET_MessageHeader *message,
2237 if (!was_connected) 2178 if (!was_connected)
2238 { 2179 {
2239 GST_validation_set_address_use (&n->id, 2180 GST_validation_set_address_use (&n->id,
2240 n->plugin_name, 2181 n->address,
2241 n->session, 2182 n->session,
2242 n->addr,
2243 n->addrlen,
2244 GNUNET_YES); 2183 GNUNET_YES);
2245 neighbours_connected++; 2184 neighbours_connected++;
2246 GNUNET_STATISTICS_update (GST_stats, gettext_noop ("# peers connected"), 1, 2185 GNUNET_STATISTICS_update (GST_stats, gettext_noop ("# peers connected"), 1,
@@ -2248,11 +2187,9 @@ GST_neighbours_handle_ack (const struct GNUNET_MessageHeader *message,
2248 2187
2249#if DEBUG_TRANSPORT 2188#if DEBUG_TRANSPORT
2250 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 2189 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
2251 "Notify about connect of `%4s' using plugin `%s' address '%s' session %X LINE %u\n", 2190 "Notify about connect of `%4s' using address '%s' session %X LINE %u\n",
2252 GNUNET_i2s (&n->id), n->plugin_name, 2191 GNUNET_i2s (&n->id),
2253 (n->addrlen == 2192 GST_plugins_a2s (n->address), n->session,
2254 0) ? "<inbound>" : GST_plugins_a2s (n->plugin_name, n->addr,
2255 n->addrlen), n->session,
2256 __LINE__); 2193 __LINE__);
2257#endif 2194#endif
2258 connect_notify_cb (callback_cls, &n->id, ats, ats_count); 2195 connect_notify_cb (callback_cls, &n->id, ats, ats_count);
@@ -2277,11 +2214,7 @@ struct BlackListCheckContext
2277 2214
2278 struct Session *session; 2215 struct Session *session;
2279 2216
2280 char *sender_address; 2217 struct GNUNET_HELLO_Address *address;
2281
2282 uint16_t sender_address_len;
2283
2284 char *plugin_name;
2285 2218
2286 struct GNUNET_TIME_Absolute ts; 2219 struct GNUNET_TIME_Absolute ts;
2287}; 2220};
@@ -2305,6 +2238,7 @@ handle_connect_blacklist_cont (void *cls,
2305 /* not allowed */ 2238 /* not allowed */
2306 if (GNUNET_OK != result) 2239 if (GNUNET_OK != result)
2307 { 2240 {
2241 GNUNET_HELLO_address_free (bcc->address);
2308 GNUNET_free (bcc); 2242 GNUNET_free (bcc);
2309 return; 2243 return;
2310 } 2244 }
@@ -2318,13 +2252,11 @@ handle_connect_blacklist_cont (void *cls,
2318 if (NULL != bcc->session) 2252 if (NULL != bcc->session)
2319 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG | GNUNET_ERROR_TYPE_BULK, 2253 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG | GNUNET_ERROR_TYPE_BULK,
2320 "transport-ats", 2254 "transport-ats",
2321 "Giving ATS session %p of plugin %s address `%s' for peer %s\n", 2255 "Giving ATS session %p of address `%s' for peer %s\n",
2322 bcc->session, bcc->plugin_name, 2256 bcc->session,
2323 GST_plugins_a2s (bcc->plugin_name, bcc->sender_address, 2257 GST_plugins_a2s (bcc->address),
2324 bcc->sender_address_len),
2325 GNUNET_i2s (peer)); 2258 GNUNET_i2s (peer));
2326 GNUNET_ATS_address_update (GST_ats, peer, bcc->plugin_name, 2259 GNUNET_ATS_address_update (GST_ats, bcc->address,
2327 bcc->sender_address, bcc->sender_address_len,
2328 bcc->session, bcc->ats, bcc->ats_count); 2260 bcc->session, bcc->ats, bcc->ats_count);
2329 n->connect_ts = bcc->ts; 2261 n->connect_ts = bcc->ts;
2330 } 2262 }
@@ -2349,20 +2281,16 @@ handle_connect_blacklist_cont (void *cls,
2349 * 2281 *
2350 * @param message possibly a 'struct SessionConnectMessage' (check format) 2282 * @param message possibly a 'struct SessionConnectMessage' (check format)
2351 * @param peer identity of the peer to switch the address for 2283 * @param peer identity of the peer to switch the address for
2352 * @param plugin_name name of transport that delivered the PONG
2353 * @param address address of the other peer, NULL if other peer 2284 * @param address address of the other peer, NULL if other peer
2354 * connected to us 2285 * connected to us
2355 * @param address_len number of bytes in address
2356 * @param session session to use (or NULL) 2286 * @param session session to use (or NULL)
2357 * @param ats performance data 2287 * @param ats performance data
2358 * @param ats_count number of entries in ats (excluding 0-termination) 2288 * @param ats_count number of entries in ats (excluding 0-termination)
2359 */ 2289 */
2360void 2290void
2361GST_neighbours_handle_connect (const struct GNUNET_MessageHeader *message, 2291GST_neighbours_handle_connect (const struct GNUNET_MessageHeader *message,
2362 const struct GNUNET_PeerIdentity *peer, 2292 const struct GNUNET_PeerIdentity *peer,
2363 const char *plugin_name, 2293 const struct GNUNET_HELLO_Address *address,
2364 const char *sender_address,
2365 uint16_t sender_address_len,
2366 struct Session *session, 2294 struct Session *session,
2367 const struct GNUNET_ATS_Information *ats, 2295 const struct GNUNET_ATS_Information *ats,
2368 uint32_t ats_count) 2296 uint32_t ats_count)
@@ -2391,8 +2319,7 @@ GST_neighbours_handle_connect (const struct GNUNET_MessageHeader *message,
2391 /* connected peer switches addresses */ 2319 /* connected peer switches addresses */
2392 if (is_connected (n)) 2320 if (is_connected (n))
2393 { 2321 {
2394 GNUNET_ATS_address_update (GST_ats, peer, plugin_name, sender_address, 2322 GNUNET_ATS_address_update (GST_ats, address, session, ats, ats_count);
2395 sender_address_len, session, ats, ats_count);
2396 return; 2323 return;
2397 } 2324 }
2398 } 2325 }
@@ -2401,26 +2328,16 @@ GST_neighbours_handle_connect (const struct GNUNET_MessageHeader *message,
2401 /* do blacklist check */ 2328 /* do blacklist check */
2402 bcc = 2329 bcc =
2403 GNUNET_malloc (sizeof (struct BlackListCheckContext) + 2330 GNUNET_malloc (sizeof (struct BlackListCheckContext) +
2404 sizeof (struct GNUNET_ATS_Information) * (ats_count + 1) + 2331 sizeof (struct GNUNET_ATS_Information) * (ats_count + 1));
2405 sender_address_len + strlen (plugin_name) + 1);
2406
2407 bcc->ts = GNUNET_TIME_absolute_ntoh (scm->timestamp); 2332 bcc->ts = GNUNET_TIME_absolute_ntoh (scm->timestamp);
2408
2409 bcc->ats_count = ats_count + 1; 2333 bcc->ats_count = ats_count + 1;
2410 bcc->sender_address_len = sender_address_len; 2334 bcc->address = GNUNET_HELLO_address_copy (address);
2411 bcc->session = session; 2335 bcc->session = session;
2412
2413 bcc->ats = (struct GNUNET_ATS_Information *) &bcc[1]; 2336 bcc->ats = (struct GNUNET_ATS_Information *) &bcc[1];
2414 memcpy (bcc->ats, ats, sizeof (struct GNUNET_ATS_Information) * ats_count); 2337 memcpy (bcc->ats, ats, sizeof (struct GNUNET_ATS_Information) * ats_count);
2415 bcc->ats[ats_count].type = htonl (GNUNET_ATS_QUALITY_NET_DELAY); 2338 bcc->ats[ats_count].type = htonl (GNUNET_ATS_QUALITY_NET_DELAY);
2416 bcc->ats[ats_count].value = htonl ((uint32_t) GST_neighbour_get_latency (peer).rel_value); 2339 bcc->ats[ats_count].value = htonl ((uint32_t) GST_neighbour_get_latency (peer).rel_value);
2417 bcc->sender_address = (char *) &bcc->ats[ats_count + 1]; 2340 GST_blacklist_test_allowed (peer, address->transport_name, handle_connect_blacklist_cont,
2418 memcpy (bcc->sender_address, sender_address, sender_address_len);
2419
2420 bcc->plugin_name = &bcc->sender_address[sender_address_len];
2421 strcpy (bcc->plugin_name, plugin_name);
2422
2423 GST_blacklist_test_allowed (peer, plugin_name, handle_connect_blacklist_cont,
2424 bcc); 2341 bcc);
2425} 2342}
2426 2343
diff --git a/src/transport/gnunet-service-transport_neighbours.h b/src/transport/gnunet-service-transport_neighbours.h
index 48e54e656..72ced636d 100644
--- a/src/transport/gnunet-service-transport_neighbours.h
+++ b/src/transport/gnunet-service-transport_neighbours.h
@@ -152,17 +152,14 @@ GST_neighbours_force_disconnect (const struct GNUNET_PeerIdentity *target);
152 * @param neighbour identity of the neighbour 152 * @param neighbour identity of the neighbour
153 * @param ats performance data 153 * @param ats performance data
154 * @param ats_count number of entries in ats (including 0-termination) 154 * @param ats_count number of entries in ats (including 0-termination)
155 * @param transport plugin 155 * @param address the address (or NULL)
156 * @param addr address
157 * @param addrlen address length
158 */ 156 */
159typedef void (*GST_NeighbourIterator) (void *cls, 157typedef void (*GST_NeighbourIterator) (void *cls,
160 const struct GNUNET_PeerIdentity * 158 const struct GNUNET_PeerIdentity *
161 neighbour, 159 neighbour,
162 const struct GNUNET_ATS_Information * 160 const struct GNUNET_ATS_Information *
163 ats, uint32_t ats_count, 161 ats, uint32_t ats_count,
164 const char *transport, const void *addr, 162 const struct GNUNET_HELLO_Address *address);
165 size_t addrlen);
166 163
167 164
168/** 165/**
@@ -191,10 +188,8 @@ GST_neighbours_session_terminated (const struct GNUNET_PeerIdentity *peer,
191 * use the given address. 188 * use the given address.
192 * 189 *
193 * @param peer identity of the peer to switch the address for 190 * @param peer identity of the peer to switch the address for
194 * @param plugin_name name of transport that delivered the PONG
195 * @param address address of the other peer, NULL if other peer 191 * @param address address of the other peer, NULL if other peer
196 * connected to us 192 * connected to us
197 * @param address_len number of bytes in address
198 * @param session session to use (or NULL) 193 * @param session session to use (or NULL)
199 * @param ats performance data 194 * @param ats performance data
200 * @param ats_count number of entries in ats 195 * @param ats_count number of entries in ats
@@ -204,19 +199,11 @@ GST_neighbours_session_terminated (const struct GNUNET_PeerIdentity *peer,
204 * connection is not up (yet) 199 * connection is not up (yet)
205 */ 200 */
206int 201int
207GST_neighbours_switch_to_address (const struct GNUNET_PeerIdentity *peer,
208 const char *plugin_name, const void *address,
209 size_t address_len, struct Session *session,
210 const struct GNUNET_ATS_Information *ats,
211 uint32_t ats_count);
212
213int
214GST_neighbours_switch_to_address_3way (const struct GNUNET_PeerIdentity *peer, 202GST_neighbours_switch_to_address_3way (const struct GNUNET_PeerIdentity *peer,
215 const char *plugin_name, 203 const struct GNUNET_HELLO_Address *address,
216 const void *address, size_t address_len, 204 struct Session *session,
217 struct Session *session, 205 const struct GNUNET_ATS_Information *ats,
218 const struct GNUNET_ATS_Information *ats, 206 uint32_t ats_count,
219 uint32_t ats_count,
220 struct GNUNET_BANDWIDTH_Value32NBO 207 struct GNUNET_BANDWIDTH_Value32NBO
221 bandwidth_in, 208 bandwidth_in,
222 struct GNUNET_BANDWIDTH_Value32NBO 209 struct GNUNET_BANDWIDTH_Value32NBO
@@ -229,10 +216,8 @@ GST_neighbours_switch_to_address_3way (const struct GNUNET_PeerIdentity *peer,
229 * 216 *
230 * @param message possibly a 'struct SessionConnectMessage' (check format) 217 * @param message possibly a 'struct SessionConnectMessage' (check format)
231 * @param peer identity of the peer to switch the address for 218 * @param peer identity of the peer to switch the address for
232 * @param plugin_name name of transport that delivered the PONG
233 * @param address address of the other peer, NULL if other peer 219 * @param address address of the other peer, NULL if other peer
234 * connected to us 220 * connected to us
235 * @param address_len number of bytes in address
236 * @param session session to use (or NULL) 221 * @param session session to use (or NULL)
237 * @param ats performance data 222 * @param ats performance data
238 * @param ats_count number of entries in ats (excluding 0-termination) 223 * @param ats_count number of entries in ats (excluding 0-termination)
@@ -240,19 +225,28 @@ GST_neighbours_switch_to_address_3way (const struct GNUNET_PeerIdentity *peer,
240void 225void
241GST_neighbours_handle_connect (const struct GNUNET_MessageHeader *message, 226GST_neighbours_handle_connect (const struct GNUNET_MessageHeader *message,
242 const struct GNUNET_PeerIdentity *peer, 227 const struct GNUNET_PeerIdentity *peer,
243 const char *plugin_name, 228 const struct GNUNET_HELLO_Address *address,
244 const char *sender_address,
245 uint16_t sender_address_len,
246 struct Session *session, 229 struct Session *session,
247 const struct GNUNET_ATS_Information *ats, 230 const struct GNUNET_ATS_Information *ats,
248 uint32_t ats_count); 231 uint32_t ats_count);
249 232
233
234/**
235 * We received a 'SESSION_CONNECT_ACK' message from the other peer.
236 * Consider switching to it.
237 *
238 * @param message possibly a 'struct SessionConnectMessage' (check format)
239 * @param peer identity of the peer to switch the address for
240 * @param address address of the other peer, NULL if other peer
241 * connected to us
242 * @param session session to use (or NULL)
243 * @param ats performance data
244 * @param ats_count number of entries in ats
245 */
250void 246void
251GST_neighbours_handle_connect_ack (const struct GNUNET_MessageHeader *message, 247GST_neighbours_handle_connect_ack (const struct GNUNET_MessageHeader *message,
252 const struct GNUNET_PeerIdentity *peer, 248 const struct GNUNET_PeerIdentity *peer,
253 const char *plugin_name, 249 const struct GNUNET_HELLO_Address *address,
254 const char *sender_address,
255 uint16_t sender_address_len,
256 struct Session *session, 250 struct Session *session,
257 const struct GNUNET_ATS_Information *ats, 251 const struct GNUNET_ATS_Information *ats,
258 uint32_t ats_count); 252 uint32_t ats_count);
@@ -260,8 +254,8 @@ GST_neighbours_handle_connect_ack (const struct GNUNET_MessageHeader *message,
260void 254void
261GST_neighbours_handle_ack (const struct GNUNET_MessageHeader *message, 255GST_neighbours_handle_ack (const struct GNUNET_MessageHeader *message,
262 const struct GNUNET_PeerIdentity *peer, 256 const struct GNUNET_PeerIdentity *peer,
263 const char *plugin_name, const char *sender_address, 257 const struct GNUNET_HELLO_Address *address,
264 uint16_t sender_address_len, struct Session *session, 258 struct Session *session,
265 const struct GNUNET_ATS_Information *ats, 259 const struct GNUNET_ATS_Information *ats,
266 uint32_t ats_count); 260 uint32_t ats_count);
267 261
diff --git a/src/transport/gnunet-service-transport_plugins.c b/src/transport/gnunet-service-transport_plugins.c
index 52fcf661d..3c4466753 100644
--- a/src/transport/gnunet-service-transport_plugins.c
+++ b/src/transport/gnunet-service-transport_plugins.c
@@ -189,22 +189,20 @@ GST_plugins_find (const char *name)
189 * Convert a given address to a human-readable format. Note that the 189 * Convert a given address to a human-readable format. Note that the
190 * return value will be overwritten on the next call to this function. 190 * return value will be overwritten on the next call to this function.
191 * 191 *
192 * @param name plugin name 192 * @param address the address to convert
193 * @param addr binary address in plugin-specific format
194 * @param addrlen number of bytes in 'addr'
195 * @return statically allocated (!) human-readable address 193 * @return statically allocated (!) human-readable address
196 */ 194 */
197const char * 195const char *
198GST_plugins_a2s (const char *name, const void *addr, size_t addrlen) 196GST_plugins_a2s (const struct GNUNET_HELLO_Address *address)
199{ 197{
200 struct GNUNET_TRANSPORT_PluginFunctions *api; 198 struct GNUNET_TRANSPORT_PluginFunctions *api;
201 199
202 if (name == NULL) 200 if (address == NULL)
201 return "<inbound>";
202 api = GST_plugins_find (address->transport_name);
203 if ((api == NULL) || (address->address_length == 0) || (address->address == NULL))
203 return NULL; 204 return NULL;
204 api = GST_plugins_find (name); 205 return api->address_to_string (NULL, address->address, address->address_length);
205 if ((api == NULL) || (addrlen == 0) || (addr == NULL))
206 return NULL;
207 return api->address_to_string (NULL, addr, addrlen);
208} 206}
209 207
210 208
diff --git a/src/transport/gnunet-service-transport_plugins.h b/src/transport/gnunet-service-transport_plugins.h
index 3a49f004f..3cca3ce10 100644
--- a/src/transport/gnunet-service-transport_plugins.h
+++ b/src/transport/gnunet-service-transport_plugins.h
@@ -30,6 +30,7 @@
30#include "gnunet_transport_service.h" 30#include "gnunet_transport_service.h"
31#include "gnunet_transport_plugin.h" 31#include "gnunet_transport_plugin.h"
32#include "gnunet_util_lib.h" 32#include "gnunet_util_lib.h"
33#include "gnunet_hello_lib.h"
33 34
34 35
35/** 36/**
@@ -69,13 +70,11 @@ GST_plugins_find (const char *name);
69 * Convert a given address to a human-readable format. Note that the 70 * Convert a given address to a human-readable format. Note that the
70 * return value will be overwritten on the next call to this function. 71 * return value will be overwritten on the next call to this function.
71 * 72 *
72 * @param name plugin name 73 * @param address address to convert
73 * @param addr binary address in plugin-specific format
74 * @param addrlen number of bytes in 'addr'
75 * @return statically allocated (!) human-readable address 74 * @return statically allocated (!) human-readable address
76 */ 75 */
77const char * 76const char *
78GST_plugins_a2s (const char *name, const void *addr, size_t addrlen); 77GST_plugins_a2s (const struct GNUNET_HELLO_Address *address);
79 78
80 79
81#endif 80#endif
diff --git a/src/transport/gnunet-service-transport_validation.c b/src/transport/gnunet-service-transport_validation.c
index afc35a3a6..9b93c7508 100644
--- a/src/transport/gnunet-service-transport_validation.c
+++ b/src/transport/gnunet-service-transport_validation.c
@@ -175,15 +175,9 @@ struct ValidationEntry
175{ 175{
176 176
177 /** 177 /**
178 * Name of the transport. 178 * The address.
179 */ 179 */
180 char *transport_name; 180 struct GNUNET_HELLO_Address *address;
181
182 /**
183 * The address, actually a pointer to the end
184 * of this struct. Do not free!
185 */
186 const void *addr;
187 181
188 /** 182 /**
189 * Handle to the blacklist check (if we're currently in it). 183 * Handle to the blacklist check (if we're currently in it).
@@ -196,7 +190,7 @@ struct ValidationEntry
196 struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded public_key; 190 struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded public_key;
197 191
198 /** 192 /**
199 * The identity of the peer. 193 * The identity of the peer. FIXME: duplicated (also in 'address')
200 */ 194 */
201 struct GNUNET_PeerIdentity pid; 195 struct GNUNET_PeerIdentity pid;
202 196
@@ -241,11 +235,6 @@ struct ValidationEntry
241 uint32_t challenge; 235 uint32_t challenge;
242 236
243 /** 237 /**
244 * Length of addr.
245 */
246 size_t addrlen;
247
248 /**
249 * When passing the address in 'add_valid_peer_address', did we 238 * When passing the address in 'add_valid_peer_address', did we
250 * copy the address to the HELLO yet? 239 * copy the address to the HELLO yet?
251 */ 240 */
@@ -318,19 +307,10 @@ struct ValidationEntryMatchContext
318 struct ValidationEntry *ve; 307 struct ValidationEntry *ve;
319 308
320 /** 309 /**
321 * Transport name we're looking for.
322 */
323 const char *transport_name;
324
325 /**
326 * Address we're interested in. 310 * Address we're interested in.
327 */ 311 */
328 const char *addr; 312 const struct GNUNET_HELLO_Address *address;
329 313
330 /**
331 * Number of bytes in 'addr'.
332 */
333 size_t addrlen;
334}; 314};
335 315
336 316
@@ -349,9 +329,9 @@ validation_entry_match (void *cls, const GNUNET_HashCode * key, void *value)
349 struct ValidationEntryMatchContext *vemc = cls; 329 struct ValidationEntryMatchContext *vemc = cls;
350 struct ValidationEntry *ve = value; 330 struct ValidationEntry *ve = value;
351 331
352 if ((ve->addrlen == vemc->addrlen) && 332 if (0 ==
353 (0 == memcmp (ve->addr, vemc->addr, ve->addrlen)) && 333 GNUNET_HELLO_address_cmp (ve->address,
354 (0 == strcmp (ve->transport_name, vemc->transport_name))) 334 vemc->address))
355 { 335 {
356 vemc->ve = ve; 336 vemc->ve = ve;
357 return GNUNET_NO; 337 return GNUNET_NO;
@@ -381,7 +361,7 @@ cleanup_validation_entry (void *cls, const GNUNET_HashCode * key, void *value)
381 GNUNET_break (GNUNET_OK == 361 GNUNET_break (GNUNET_OK ==
382 GNUNET_CONTAINER_multihashmap_remove (validation_map, 362 GNUNET_CONTAINER_multihashmap_remove (validation_map,
383 &ve->pid.hashPubKey, ve)); 363 &ve->pid.hashPubKey, ve));
384 GNUNET_free (ve->transport_name); 364 GNUNET_HELLO_address_free (ve->address);
385 if (GNUNET_SCHEDULER_NO_TASK != ve->timeout_task) 365 if (GNUNET_SCHEDULER_NO_TASK != ve->timeout_task)
386 { 366 {
387 GNUNET_SCHEDULER_cancel (ve->timeout_task); 367 GNUNET_SCHEDULER_cancel (ve->timeout_task);
@@ -454,16 +434,15 @@ transmit_ping_if_allowed (void *cls, const struct GNUNET_PeerIdentity *pid,
454 434
455 ve->bc = NULL; 435 ve->bc = NULL;
456 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Transmitting plain PING to `%s' %s\n", 436 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Transmitting plain PING to `%s' %s\n",
457 GNUNET_i2s (pid), GST_plugins_a2s (ve->transport_name, ve->addr, 437 GNUNET_i2s (pid), GST_plugins_a2s (ve->address));
458 ve->addrlen));
459 438
460 slen = strlen (ve->transport_name) + 1; 439 slen = strlen (ve->address->transport_name) + 1;
461 hello = GST_hello_get (); 440 hello = GST_hello_get ();
462 hsize = ntohs (hello->size); 441 hsize = ntohs (hello->size);
463 tsize = sizeof (struct TransportPingMessage) + ve->addrlen + slen + hsize; 442 tsize = sizeof (struct TransportPingMessage) + ve->address->address_length + slen + hsize;
464 443
465 ping.header.size = 444 ping.header.size =
466 htons (sizeof (struct TransportPingMessage) + ve->addrlen + slen); 445 htons (sizeof (struct TransportPingMessage) + ve->address->address_length + slen);
467 ping.header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_PING); 446 ping.header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_PING);
468 ping.challenge = htonl (ve->challenge); 447 ping.challenge = htonl (ve->challenge);
469 ping.target = *pid; 448 ping.target = *pid;
@@ -476,7 +455,7 @@ transmit_ping_if_allowed (void *cls, const struct GNUNET_PeerIdentity *pid,
476 "HELLO", "PING", (unsigned int) tsize); 455 "HELLO", "PING", (unsigned int) tsize);
477 /* message too big (!?), get rid of HELLO */ 456 /* message too big (!?), get rid of HELLO */
478 hsize = 0; 457 hsize = 0;
479 tsize = sizeof (struct TransportPingMessage) + ve->addrlen + slen + hsize; 458 tsize = sizeof (struct TransportPingMessage) + ve->address->address_length + slen + hsize;
480 } 459 }
481 { 460 {
482 char message_buf[tsize]; 461 char message_buf[tsize];
@@ -486,10 +465,10 @@ transmit_ping_if_allowed (void *cls, const struct GNUNET_PeerIdentity *pid,
486 memcpy (message_buf, hello, hsize); 465 memcpy (message_buf, hello, hsize);
487 memcpy (&message_buf[hsize], &ping, sizeof (struct TransportPingMessage)); 466 memcpy (&message_buf[hsize], &ping, sizeof (struct TransportPingMessage));
488 memcpy (&message_buf[sizeof (struct TransportPingMessage) + hsize], 467 memcpy (&message_buf[sizeof (struct TransportPingMessage) + hsize],
489 ve->transport_name, slen); 468 ve->address->transport_name, slen);
490 memcpy (&message_buf[sizeof (struct TransportPingMessage) + slen + hsize], 469 memcpy (&message_buf[sizeof (struct TransportPingMessage) + slen + hsize],
491 ve->addr, ve->addrlen); 470 ve->address, ve->address->address_length);
492 papi = GST_plugins_find (ve->transport_name); 471 papi = GST_plugins_find (ve->address->transport_name);
493 if (papi == NULL) 472 if (papi == NULL)
494 ret = -1; 473 ret = -1;
495 else 474 else
@@ -498,7 +477,8 @@ transmit_ping_if_allowed (void *cls, const struct GNUNET_PeerIdentity *pid,
498 ret = 477 ret =
499 papi->send (papi->cls, pid, message_buf, tsize, PING_PRIORITY, 478 papi->send (papi->cls, pid, message_buf, tsize, PING_PRIORITY,
500 ACCEPTABLE_PING_DELAY, NULL /* no session */ , 479 ACCEPTABLE_PING_DELAY, NULL /* no session */ ,
501 ve->addr, ve->addrlen, GNUNET_YES, NULL, NULL); 480 ve->address->address, ve->address->address_length,
481 GNUNET_YES, NULL, NULL);
502 } 482 }
503 } 483 }
504 if (-1 != ret) 484 if (-1 != ret)
@@ -566,7 +546,8 @@ revalidate_address (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
566 GNUNET_STATISTICS_update (GST_stats, 546 GNUNET_STATISTICS_update (GST_stats,
567 gettext_noop ("# address revalidations started"), 1, 547 gettext_noop ("# address revalidations started"), 1,
568 GNUNET_NO); 548 GNUNET_NO);
569 bc = GST_blacklist_test_allowed (&ve->pid, ve->transport_name, &transmit_ping_if_allowed, ve); 549 bc = GST_blacklist_test_allowed (&ve->pid, ve->address->transport_name,
550 &transmit_ping_if_allowed, ve);
570 if (NULL != bc) 551 if (NULL != bc)
571 ve->bc = bc; /* only set 'bc' if 'transmit_ping_if_allowed' was not already 552 ve->bc = bc; /* only set 'bc' if 'transmit_ping_if_allowed' was not already
572 called... */ 553 called... */
@@ -579,45 +560,36 @@ revalidate_address (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
579 * without starting any validation). 560 * without starting any validation).
580 * 561 *
581 * @param public_key public key of the peer, NULL for unknown 562 * @param public_key public key of the peer, NULL for unknown
582 * @param neighbour which peer we care about 563 * @param address address to find
583 * @param tname name of the transport plugin
584 * @param addr binary address
585 * @param addrlen length of addr
586 * @return validation entry matching the given specifications, NULL 564 * @return validation entry matching the given specifications, NULL
587 * if we don't have an existing entry and no public key was given 565 * if we don't have an existing entry and no public key was given
588 */ 566 */
589static struct ValidationEntry * 567static struct ValidationEntry *
590find_validation_entry (const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded 568find_validation_entry (const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded
591 *public_key, const struct GNUNET_PeerIdentity *neighbour, 569 *public_key, const struct GNUNET_HELLO_Address *address)
592 const char *tname, const char *addr, size_t addrlen)
593{ 570{
594 struct ValidationEntryMatchContext vemc; 571 struct ValidationEntryMatchContext vemc;
595 struct ValidationEntry *ve; 572 struct ValidationEntry *ve;
596 573
597 vemc.ve = NULL; 574 vemc.ve = NULL;
598 vemc.transport_name = tname; 575 vemc.address = address;
599 vemc.addr = addr;
600 vemc.addrlen = addrlen;
601 GNUNET_CONTAINER_multihashmap_get_multiple (validation_map, 576 GNUNET_CONTAINER_multihashmap_get_multiple (validation_map,
602 &neighbour->hashPubKey, 577 &address->peer.hashPubKey,
603 &validation_entry_match, &vemc); 578 &validation_entry_match, &vemc);
604 if (NULL != (ve = vemc.ve)) 579 if (NULL != (ve = vemc.ve))
605 return ve; 580 return ve;
606 if (public_key == NULL) 581 if (public_key == NULL)
607 return NULL; 582 return NULL;
608 ve = GNUNET_malloc (sizeof (struct ValidationEntry) + addrlen); 583 ve = GNUNET_malloc (sizeof (struct ValidationEntry));
609 ve->transport_name = GNUNET_strdup (tname); 584 ve->address = GNUNET_HELLO_address_copy (address);
610 ve->addr = (void *) &ve[1];
611 ve->public_key = *public_key; 585 ve->public_key = *public_key;
612 ve->pid = *neighbour; 586 ve->pid = address->peer;
613 ve->latency = GNUNET_TIME_UNIT_FOREVER_REL; 587 ve->latency = GNUNET_TIME_UNIT_FOREVER_REL;
614 ve->challenge = 588 ve->challenge =
615 GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_NONCE, UINT32_MAX); 589 GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_NONCE, UINT32_MAX);
616 ve->timeout_task = GNUNET_SCHEDULER_add_delayed (UNVALIDATED_PING_KEEPALIVE, 590 ve->timeout_task = GNUNET_SCHEDULER_add_delayed (UNVALIDATED_PING_KEEPALIVE,
617 &timeout_hello_validation, ve); 591 &timeout_hello_validation, ve);
618 memcpy (&ve[1], addr, addrlen); 592 GNUNET_CONTAINER_multihashmap_put (validation_map, &address->peer.hashPubKey, ve,
619 ve->addrlen = addrlen;
620 GNUNET_CONTAINER_multihashmap_put (validation_map, &neighbour->hashPubKey, ve,
621 GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE); 593 GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE);
622 return ve; 594 return ve;
623} 595}
@@ -628,16 +600,14 @@ find_validation_entry (const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded
628 * addresses. 600 * addresses.
629 * 601 *
630 * @param cls original HELLO message 602 * @param cls original HELLO message
631 * @param tname name of the transport 603 * @param address the address
632 * @param expiration expiration time 604 * @param expiration expiration time
633 * @param addr the address
634 * @param addrlen length of the address
635 * @return GNUNET_OK (keep the address) 605 * @return GNUNET_OK (keep the address)
636 */ 606 */
637static int 607static int
638add_valid_address (void *cls, const char *tname, 608add_valid_address (void *cls,
639 struct GNUNET_TIME_Absolute expiration, const void *addr, 609 const struct GNUNET_HELLO_Address *address,
640 uint16_t addrlen) 610 struct GNUNET_TIME_Absolute expiration)
641{ 611{
642 const struct GNUNET_HELLO_Message *hello = cls; 612 const struct GNUNET_HELLO_Message *hello = cls;
643 struct ValidationEntry *ve; 613 struct ValidationEntry *ve;
@@ -652,11 +622,11 @@ add_valid_address (void *cls, const char *tname,
652 GNUNET_break (0); 622 GNUNET_break (0);
653 return GNUNET_OK; /* invalid HELLO !? */ 623 return GNUNET_OK; /* invalid HELLO !? */
654 } 624 }
655 ve = find_validation_entry (&public_key, &pid, tname, addr, addrlen); 625 ve = find_validation_entry (&public_key, address);
656 ve->valid_until = GNUNET_TIME_absolute_max (ve->valid_until, expiration); 626 ve->valid_until = GNUNET_TIME_absolute_max (ve->valid_until, expiration);
657 if (GNUNET_SCHEDULER_NO_TASK == ve->revalidation_task) 627 if (GNUNET_SCHEDULER_NO_TASK == ve->revalidation_task)
658 ve->revalidation_task = GNUNET_SCHEDULER_add_now (&revalidate_address, ve); 628 ve->revalidation_task = GNUNET_SCHEDULER_add_now (&revalidate_address, ve);
659 GNUNET_ATS_address_update (GST_ats, &pid, tname, addr, addrlen, NULL, NULL, 629 GNUNET_ATS_address_update (GST_ats, address, NULL, NULL,
660 0); 630 0);
661 return GNUNET_OK; 631 return GNUNET_OK;
662} 632}
@@ -728,29 +698,27 @@ GST_validation_stop ()
728 * @param validation_block is FOREVER if the address is for an unsupported plugin (from PEERINFO) 698 * @param validation_block is FOREVER if the address is for an unsupported plugin (from PEERINFO)
729 * is ZERO if the address is considered valid (no validation needed) 699 * is ZERO if the address is considered valid (no validation needed)
730 * otherwise a time in the future if we're currently denying re-validation 700 * otherwise a time in the future if we're currently denying re-validation
731 * @param plugin_name name of the plugin 701 * @param adress target address
732 * @param plugin_address binary address
733 * @param plugin_address_len length of address
734 */ 702 */
735static void 703static void
736multicast_pong (void *cls, 704multicast_pong (void *cls,
737 const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded 705 const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded
738 *public_key, const struct GNUNET_PeerIdentity *target, 706 *public_key,
739 struct GNUNET_TIME_Absolute valid_until, 707 struct GNUNET_TIME_Absolute valid_until,
740 struct GNUNET_TIME_Absolute validation_block, 708 struct GNUNET_TIME_Absolute validation_block,
741 const char *plugin_name, const void *plugin_address, 709 const struct GNUNET_HELLO_Address *address)
742 size_t plugin_address_len)
743{ 710{
744 struct TransportPongMessage *pong = cls; 711 struct TransportPongMessage *pong = cls;
745 struct GNUNET_TRANSPORT_PluginFunctions *papi; 712 struct GNUNET_TRANSPORT_PluginFunctions *papi;
746 713
747 papi = GST_plugins_find (plugin_name); 714 papi = GST_plugins_find (address->transport_name);
748 if (papi == NULL) 715 if (papi == NULL)
749 return; 716 return;
750 (void) papi->send (papi->cls, target, (const char *) pong, 717 (void) papi->send (papi->cls, &address->peer, (const char *) pong,
751 ntohs (pong->header.size), PONG_PRIORITY, 718 ntohs (pong->header.size), PONG_PRIORITY,
752 ACCEPTABLE_PING_DELAY, NULL, plugin_address, 719 ACCEPTABLE_PING_DELAY, NULL,
753 plugin_address_len, GNUNET_YES, NULL, NULL); 720 address->address,
721 address->address_length, GNUNET_YES, NULL, NULL);
754} 722}
755 723
756 724
@@ -759,18 +727,14 @@ multicast_pong (void *cls,
759 * 727 *
760 * @param sender peer sending the PING 728 * @param sender peer sending the PING
761 * @param hdr the PING 729 * @param hdr the PING
730 * @param sender_address the sender address as we got it
762 * @param session session we got the PING from 731 * @param session session we got the PING from
763 * @param plugin_name name of plugin that received the PING
764 * @param sender_address address of the sender as known to the plugin, NULL
765 * if we did not initiate the connection
766 * @param sender_address_len number of bytes in sender_address
767 */ 732 */
768void 733void
769GST_validation_handle_ping (const struct GNUNET_PeerIdentity *sender, 734GST_validation_handle_ping (const struct GNUNET_PeerIdentity *sender,
770 const struct GNUNET_MessageHeader *hdr, 735 const struct GNUNET_MessageHeader *hdr,
771 const char *plugin_name, struct Session *session, 736 const struct GNUNET_HELLO_Address *sender_address,
772 const void *sender_address, 737 struct Session *session)
773 size_t sender_address_len)
774{ 738{
775 const struct TransportPingMessage *ping; 739 const struct TransportPingMessage *ping;
776 struct TransportPongMessage *pong; 740 struct TransportPongMessage *pong;
@@ -782,6 +746,7 @@ GST_validation_handle_ping (const struct GNUNET_PeerIdentity *sender,
782 size_t alen; 746 size_t alen;
783 size_t slen; 747 size_t slen;
784 ssize_t ret; 748 ssize_t ret;
749 struct GNUNET_HELLO_Address address;
785 750
786 if (ntohs (hdr->size) < sizeof (struct TransportPingMessage)) 751 if (ntohs (hdr->size) < sizeof (struct TransportPingMessage))
787 { 752 {
@@ -821,15 +786,18 @@ GST_validation_handle_ping (const struct GNUNET_PeerIdentity *sender,
821 addrend++; 786 addrend++;
822 slen = strlen (addr) + 1; 787 slen = strlen (addr) + 1;
823 alen -= slen; 788 alen -= slen;
824 789 address.address = addrend;
790 address.address_length = alen;
791 address.transport_name = addr;
792 address.peer = *sender;
825 if (GNUNET_YES != 793 if (GNUNET_YES !=
826 GST_hello_test_address (addr, addrend, alen, &sig_cache, 794 GST_hello_test_address (&address, &sig_cache,
827 &sig_cache_exp)) 795 &sig_cache_exp))
828 { 796 {
829 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 797 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
830 _ 798 _
831 ("Not confirming PING with address `%s' since I cannot confirm having this address.\n"), 799 ("Not confirming PING with address `%s' since I cannot confirm having this address.\n"),
832 GST_plugins_a2s (addr, addrend, alen)); 800 GST_plugins_a2s (&address));
833 return; 801 return;
834 } 802 }
835 } 803 }
@@ -879,15 +847,17 @@ GST_validation_handle_ping (const struct GNUNET_PeerIdentity *sender,
879 847
880 /* first see if the session we got this PING from can be used to transmit 848 /* first see if the session we got this PING from can be used to transmit
881 * a response reliably */ 849 * a response reliably */
882 papi = GST_plugins_find (plugin_name); 850 papi = GST_plugins_find (sender_address->transport_name);
883 if (papi == NULL) 851 if (papi == NULL)
884 ret = -1; 852 ret = -1;
885 else 853 else
886 ret = 854 ret =
887 papi->send (papi->cls, sender, (const char *) pong, 855 papi->send (papi->cls, sender, (const char *) pong,
888 ntohs (pong->header.size), PONG_PRIORITY, 856 ntohs (pong->header.size), PONG_PRIORITY,
889 ACCEPTABLE_PING_DELAY, session, sender_address, 857 ACCEPTABLE_PING_DELAY, session,
890 sender_address_len, GNUNET_SYSERR, NULL, NULL); 858 sender_address->address,
859 sender_address->address_length,
860 GNUNET_SYSERR, NULL, NULL);
891 if (ret != -1) 861 if (ret != -1)
892 { 862 {
893 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 863 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
@@ -934,24 +904,21 @@ struct ValidateAddressContext
934 * (unless blocked or already validated). 904 * (unless blocked or already validated).
935 * 905 *
936 * @param cls pointer to a 'struct ValidateAddressContext' 906 * @param cls pointer to a 'struct ValidateAddressContext'
937 * @param tname name of the transport 907 * @param address the address
938 * @param expiration expiration time 908 * @param expiration expiration time
939 * @param addr the address
940 * @param addrlen length of the address
941 * @return GNUNET_OK (keep the address) 909 * @return GNUNET_OK (keep the address)
942 */ 910 */
943static int 911static int
944validate_address_iterator (void *cls, const char *tname, 912validate_address_iterator (void *cls,
945 struct GNUNET_TIME_Absolute expiration, const void *addr, 913 const struct GNUNET_HELLO_Address *address,
946 uint16_t addrlen) 914 struct GNUNET_TIME_Absolute expiration)
947{ 915{
948 const struct ValidateAddressContext *vac = cls; 916 const struct ValidateAddressContext *vac = cls;
949 const struct GNUNET_PeerIdentity *pid = &vac->pid;
950 struct ValidationEntry *ve; 917 struct ValidationEntry *ve;
951 918
952 if (GNUNET_TIME_absolute_get_remaining (expiration).rel_value == 0) 919 if (GNUNET_TIME_absolute_get_remaining (expiration).rel_value == 0)
953 return GNUNET_OK; /* expired */ 920 return GNUNET_OK; /* expired */
954 ve = find_validation_entry (&vac->public_key, pid, tname, addr, addrlen); 921 ve = find_validation_entry (&vac->public_key, address);
955 if (GNUNET_SCHEDULER_NO_TASK == ve->revalidation_task) 922 if (GNUNET_SCHEDULER_NO_TASK == ve->revalidation_task)
956 ve->revalidation_task = GNUNET_SCHEDULER_add_now (&revalidate_address, 923 ve->revalidation_task = GNUNET_SCHEDULER_add_now (&revalidate_address,
957 ve); 924 ve);
@@ -976,8 +943,8 @@ add_valid_peer_address (void *cls, size_t max, void *buf)
976 if (GNUNET_YES == ve->copied) 943 if (GNUNET_YES == ve->copied)
977 return 0; /* terminate */ 944 return 0; /* terminate */
978 ve->copied = GNUNET_YES; 945 ve->copied = GNUNET_YES;
979 return GNUNET_HELLO_add_address (ve->transport_name, ve->valid_until, 946 return GNUNET_HELLO_add_address (ve->address, ve->valid_until,
980 ve->addr, ve->addrlen, buf, max); 947 buf, max);
981} 948}
982 949
983 950
@@ -1000,6 +967,7 @@ GST_validation_handle_pong (const struct GNUNET_PeerIdentity *sender,
1000 size_t slen; 967 size_t slen;
1001 size_t size; 968 size_t size;
1002 struct GNUNET_HELLO_Message *hello; 969 struct GNUNET_HELLO_Message *hello;
970 struct GNUNET_HELLO_Address address;
1003 971
1004 if (ntohs (hdr->size) < sizeof (struct TransportPongMessage)) 972 if (ntohs (hdr->size) < sizeof (struct TransportPongMessage))
1005 { 973 {
@@ -1022,8 +990,11 @@ GST_validation_handle_pong (const struct GNUNET_PeerIdentity *sender,
1022 addr++; 990 addr++;
1023 slen = strlen (tname) + 1; 991 slen = strlen (tname) + 1;
1024 addrlen = size - slen; 992 addrlen = size - slen;
1025 993 address.peer = *sender;
1026 ve = find_validation_entry (NULL, sender, tname, addr, addrlen); 994 address.address = addr;
995 address.address_length = addrlen;
996 address.transport_name = tname;
997 ve = find_validation_entry (NULL, &address);
1027 if (NULL == ve) 998 if (NULL == ve)
1028 { 999 {
1029 GNUNET_STATISTICS_update (GST_stats, 1000 GNUNET_STATISTICS_update (GST_stats,
@@ -1071,8 +1042,7 @@ GST_validation_handle_pong (const struct GNUNET_PeerIdentity *sender,
1071 1042
1072 ats.type = htonl (GNUNET_ATS_QUALITY_NET_DELAY); 1043 ats.type = htonl (GNUNET_ATS_QUALITY_NET_DELAY);
1073 ats.value = htonl ((uint32_t) ve->latency.rel_value); 1044 ats.value = htonl ((uint32_t) ve->latency.rel_value);
1074 GNUNET_ATS_address_update (GST_ats, &ve->pid, ve->transport_name, ve->addr, 1045 GNUNET_ATS_address_update (GST_ats, ve->address, NULL, &ats, 1);
1075 ve->addrlen, NULL, &ats, 1);
1076 } 1046 }
1077 /* build HELLO to store in PEERINFO */ 1047 /* build HELLO to store in PEERINFO */
1078 ve->copied = GNUNET_NO; 1048 ve->copied = GNUNET_NO;
@@ -1153,8 +1123,8 @@ iterate_addresses (void *cls, const GNUNET_HashCode * key, void *value)
1153 struct IteratorContext *ic = cls; 1123 struct IteratorContext *ic = cls;
1154 struct ValidationEntry *ve = value; 1124 struct ValidationEntry *ve = value;
1155 1125
1156 ic->cb (ic->cb_cls, &ve->public_key, &ve->pid, ve->valid_until, 1126 ic->cb (ic->cb_cls, &ve->public_key, ve->valid_until,
1157 ve->revalidation_block, ve->transport_name, ve->addr, ve->addrlen); 1127 ve->revalidation_block, ve->address);
1158 return GNUNET_OK; 1128 return GNUNET_OK;
1159} 1129}
1160 1130
@@ -1186,25 +1156,20 @@ GST_validation_get_addresses (const struct GNUNET_PeerIdentity *target,
1186 * Based on this, the validation module will measure latency for the 1156 * Based on this, the validation module will measure latency for the
1187 * address more or less often. 1157 * address more or less often.
1188 * 1158 *
1189 * @param sender peer 1159 * @param sender peer FIXME: redundant!
1190 * @param plugin_name name of plugin 1160 * @param address the address
1191 * @param session session
1192 * @param sender_address address of the sender as known to the plugin, NULL
1193 * if we did not initiate the connection
1194 * @param sender_address_len number of bytes in sender_address
1195 * @param in_use GNUNET_YES if we are now using the address for a connection, 1161 * @param in_use GNUNET_YES if we are now using the address for a connection,
1196 * GNUNET_NO if we are no longer using the address for a connection 1162 * GNUNET_NO if we are no longer using the address for a connection
1197 */ 1163 */
1198void 1164void
1199GST_validation_set_address_use (const struct GNUNET_PeerIdentity *sender, 1165GST_validation_set_address_use (const struct GNUNET_PeerIdentity *sender,
1200 const char *plugin_name, struct Session *session, 1166 const struct GNUNET_HELLO_Address *address,
1201 const void *sender_address, 1167 struct Session *session,
1202 size_t sender_address_len,
1203 int in_use) 1168 int in_use)
1204{ 1169{
1205 struct ValidationEntry *ve; 1170 struct ValidationEntry *ve;
1206 1171
1207 ve = find_validation_entry (NULL, sender, plugin_name, sender_address, sender_address_len); 1172 ve = find_validation_entry (NULL, address);
1208 if (NULL == ve) 1173 if (NULL == ve)
1209 { 1174 {
1210 /* FIXME: this can happen for inbound connections (sender_address_len == 0); 1175 /* FIXME: this can happen for inbound connections (sender_address_len == 0);
@@ -1231,23 +1196,19 @@ GST_validation_set_address_use (const struct GNUNET_PeerIdentity *sender,
1231 * address. 1196 * address.
1232 * 1197 *
1233 * @param sender peer 1198 * @param sender peer
1234 * @param plugin_name name of plugin 1199 * @param address the address
1235 * @param session session 1200 * @param session session
1236 * @param sender_address address of the sender as known to the plugin, NULL
1237 * if we did not initiate the connection
1238 * @param sender_address_len number of bytes in sender_address
1239 * @return observed latency of the address, FOREVER if the address was 1201 * @return observed latency of the address, FOREVER if the address was
1240 * never successfully validated 1202 * never successfully validated
1241 */ 1203 */
1242struct GNUNET_TIME_Relative 1204struct GNUNET_TIME_Relative
1243GST_validation_get_address_latency (const struct GNUNET_PeerIdentity *sender, 1205GST_validation_get_address_latency (const struct GNUNET_PeerIdentity *sender,
1244 const char *plugin_name, struct Session *session, 1206 const struct GNUNET_HELLO_Address *address,
1245 const void *sender_address, 1207 struct Session *session)
1246 size_t sender_address_len)
1247{ 1208{
1248 struct ValidationEntry *ve; 1209 struct ValidationEntry *ve;
1249 1210
1250 ve = find_validation_entry (NULL, sender, plugin_name, sender_address, sender_address_len); 1211 ve = find_validation_entry (NULL, address);
1251 if (NULL == ve) 1212 if (NULL == ve)
1252 return GNUNET_TIME_UNIT_FOREVER_REL; 1213 return GNUNET_TIME_UNIT_FOREVER_REL;
1253 return ve->latency; 1214 return ve->latency;
diff --git a/src/transport/gnunet-service-transport_validation.h b/src/transport/gnunet-service-transport_validation.h
index 2d93e508e..a3692e3cf 100644
--- a/src/transport/gnunet-service-transport_validation.h
+++ b/src/transport/gnunet-service-transport_validation.h
@@ -29,6 +29,7 @@
29#include "gnunet_statistics_service.h" 29#include "gnunet_statistics_service.h"
30#include "gnunet_transport_plugin.h" 30#include "gnunet_transport_plugin.h"
31#include "gnunet_util_lib.h" 31#include "gnunet_util_lib.h"
32#include "gnunet_hello_lib.h"
32 33
33 34
34/** 35/**
@@ -50,20 +51,16 @@ GST_validation_stop (void);
50 * Based on this, the validation module will measure latency for the 51 * Based on this, the validation module will measure latency for the
51 * address more or less often. 52 * address more or less often.
52 * 53 *
53 * @param sender peer 54 * @param sender peer FIXME: redundant!
54 * @param plugin_name name of plugin 55 * @param address the address
55 * @param session session 56 * @param session session
56 * @param sender_address address of the sender as known to the plugin, NULL
57 * if we did not initiate the connection
58 * @param sender_address_len number of bytes in sender_address
59 * @param in_use GNUNET_YES if we are now using the address for a connection, 57 * @param in_use GNUNET_YES if we are now using the address for a connection,
60 * GNUNET_NO if we are no longer using the address for a connection 58 * GNUNET_NO if we are no longer using the address for a connection
61 */ 59 */
62void 60void
63GST_validation_set_address_use (const struct GNUNET_PeerIdentity *sender, 61GST_validation_set_address_use (const struct GNUNET_PeerIdentity *sender,
64 const char *plugin_name, struct Session *session, 62 const struct GNUNET_HELLO_Address *address,
65 const void *sender_address, 63 struct Session *session,
66 size_t sender_address_len,
67 int in_use); 64 int in_use);
68 65
69 66
@@ -72,19 +69,15 @@ GST_validation_set_address_use (const struct GNUNET_PeerIdentity *sender,
72 * address. 69 * address.
73 * 70 *
74 * @param sender peer 71 * @param sender peer
75 * @param plugin_name name of plugin 72 * @param address the address
76 * @param session session 73 * @param session session
77 * @param sender_address address of the sender as known to the plugin, NULL
78 * if we did not initiate the connection
79 * @param sender_address_len number of bytes in sender_address
80 * @return observed latency of the address, FOREVER if the address was 74 * @return observed latency of the address, FOREVER if the address was
81 * never successfully validated 75 * never successfully validated
82 */ 76 */
83struct GNUNET_TIME_Relative 77struct GNUNET_TIME_Relative
84GST_validation_get_address_latency (const struct GNUNET_PeerIdentity *sender, 78GST_validation_get_address_latency (const struct GNUNET_PeerIdentity *sender,
85 const char *plugin_name, struct Session *session, 79 const struct GNUNET_HELLO_Address *address,
86 const void *sender_address, 80 struct Session *session);
87 size_t sender_address_len);
88 81
89 82
90/** 83/**
@@ -92,18 +85,14 @@ GST_validation_get_address_latency (const struct GNUNET_PeerIdentity *sender,
92 * 85 *
93 * @param sender peer sending the PING 86 * @param sender peer sending the PING
94 * @param hdr the PING 87 * @param hdr the PING
95 * @param plugin_name name of plugin that received the PING 88 * @param sender_address address of the sender, NULL if we did not initiate
96 * @param session session we got the PING from 89 * @param session session we got the PING from
97 * @param sender_address address of the sender as known to the plugin, NULL
98 * if we did not initiate the connection
99 * @param sender_address_len number of bytes in sender_address
100 */ 90 */
101void 91void
102GST_validation_handle_ping (const struct GNUNET_PeerIdentity *sender, 92GST_validation_handle_ping (const struct GNUNET_PeerIdentity *sender,
103 const struct GNUNET_MessageHeader *hdr, 93 const struct GNUNET_MessageHeader *hdr,
104 const char *plugin_name, struct Session *session, 94 const struct GNUNET_HELLO_Address *sender_address,
105 const void *sender_address, 95 struct Session *session);
106 size_t sender_address_len);
107 96
108 97
109/** 98/**
@@ -134,29 +123,22 @@ GST_validation_handle_hello (const struct GNUNET_MessageHeader *hello);
134 * 123 *
135 * @param cls closure 124 * @param cls closure
136 * @param public_key public key for the peer, never NULL 125 * @param public_key public key for the peer, never NULL
137 * @param target peer this change is about, never NULL
138 * @param valid_until is ZERO if we never validated the address, 126 * @param valid_until is ZERO if we never validated the address,
139 * otherwise a time up to when we consider it (or was) valid 127 * otherwise a time up to when we consider it (or was) valid
140 * @param validation_block is FOREVER if the address is for an unsupported plugin (from PEERINFO) 128 * @param validation_block is FOREVER if the address is for an unsupported plugin (from PEERINFO)
141 * is ZERO if the address is considered valid (no validation needed) 129 * is ZERO if the address is considered valid (no validation needed)
142 * otherwise a time in the future if we're currently denying re-validation 130 * otherwise a time in the future if we're currently denying re-validation
143 * @param plugin_name name of the plugin 131 * @param address the address
144 * @param plugin_address binary address
145 * @param plugin_address_len length of address
146 */ 132 */
147typedef void (*GST_ValidationAddressCallback) (void *cls, 133typedef void (*GST_ValidationAddressCallback) (void *cls,
148 const struct 134 const struct
149 GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded 135 GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded
150 * public_key, 136 * public_key,
151 const struct GNUNET_PeerIdentity
152 * target,
153 struct GNUNET_TIME_Absolute 137 struct GNUNET_TIME_Absolute
154 valid_until, 138 valid_until,
155 struct GNUNET_TIME_Absolute 139 struct GNUNET_TIME_Absolute
156 validation_block, 140 validation_block,
157 const char *plugin_name, 141 const struct GNUNET_HELLO_Address *address);
158 const void *plugin_address,
159 size_t plugin_address_len);
160 142
161 143
162/** 144/**