diff options
-rw-r--r-- | src/hello/hello.c | 2 | ||||
-rw-r--r-- | src/include/gnunet_peer_lib.h | 19 | ||||
-rw-r--r-- | src/include/gnunet_transport_service.h | 13 | ||||
-rw-r--r-- | src/transport/gnunet-service-transport.c | 63 | ||||
-rw-r--r-- | src/transport/gnunet-service-transport_ats.c | 4 | ||||
-rw-r--r-- | src/transport/gnunet-service-transport_blacklist.c | 19 | ||||
-rw-r--r-- | src/transport/gnunet-service-transport_clients.c | 8 | ||||
-rw-r--r-- | src/transport/gnunet-service-transport_neighbours.c | 181 | ||||
-rw-r--r-- | src/transport/gnunet-service-transport_neighbours.h | 32 | ||||
-rw-r--r-- | src/transport/gnunet-service-transport_plugins.c | 5 | ||||
-rw-r--r-- | src/transport/gnunet-service-transport_validation.c | 150 | ||||
-rw-r--r-- | src/transport/gnunet-service-transport_validation.h | 7 | ||||
-rw-r--r-- | src/transport/gnunet-transport.c | 34 | ||||
-rw-r--r-- | src/transport/test_transport_api_monitor_peers.c | 14 | ||||
-rw-r--r-- | src/transport/test_transport_api_monitor_validation.c | 49 | ||||
-rw-r--r-- | src/transport/transport_api_monitor_peers.c | 58 | ||||
-rw-r--r-- | src/transport/transport_api_monitor_validation.c | 88 |
17 files changed, 317 insertions, 429 deletions
diff --git a/src/hello/hello.c b/src/hello/hello.c index 22da56e88..3c836a9e4 100644 --- a/src/hello/hello.c +++ b/src/hello/hello.c | |||
@@ -539,7 +539,7 @@ GNUNET_HELLO_size (const struct GNUNET_HELLO_Message *hello) | |||
539 | * | 539 | * |
540 | * @param hello the hello message | 540 | * @param hello the hello message |
541 | * @param publicKey where to copy the public key information, can be NULL | 541 | * @param publicKey where to copy the public key information, can be NULL |
542 | * @return GNUNET_SYSERR if the HELLO was malformed | 542 | * @return #GNUNET_SYSERR if the HELLO was malformed |
543 | */ | 543 | */ |
544 | int | 544 | int |
545 | GNUNET_HELLO_get_key (const struct GNUNET_HELLO_Message *hello, | 545 | GNUNET_HELLO_get_key (const struct GNUNET_HELLO_Message *hello, |
diff --git a/src/include/gnunet_peer_lib.h b/src/include/gnunet_peer_lib.h index fbe13e2cf..30347a8ff 100644 --- a/src/include/gnunet_peer_lib.h +++ b/src/include/gnunet_peer_lib.h | |||
@@ -38,11 +38,10 @@ extern "C" | |||
38 | #endif | 38 | #endif |
39 | 39 | ||
40 | /** | 40 | /** |
41 | * A GNUNET_PEER_Id is simply a shorter | 41 | * A GNUNET_PEER_Id is simply a shorter version of a "struct |
42 | * version of a "struct GNUNET_PeerIdentifier" | 42 | * GNUNET_PeerIdentifier" that can be used inside of a GNUnet peer to |
43 | * that can be used inside of a GNUnet peer | 43 | * save memory when the same identifier needs to be used over and over |
44 | * to save memory when the same identifier | 44 | * again. |
45 | * needs to be used over and over again. | ||
46 | */ | 45 | */ |
47 | typedef unsigned int GNUNET_PEER_Id; | 46 | typedef unsigned int GNUNET_PEER_Id; |
48 | 47 | ||
@@ -82,10 +81,11 @@ GNUNET_PEER_change_rc (GNUNET_PEER_Id id, int delta); | |||
82 | * Decrement multiple RCs of peer identities by one. | 81 | * Decrement multiple RCs of peer identities by one. |
83 | * | 82 | * |
84 | * @param ids array of PIDs to decrement the RCs of | 83 | * @param ids array of PIDs to decrement the RCs of |
85 | * @param count size of the ids array | 84 | * @param count size of the @a ids array |
86 | */ | 85 | */ |
87 | void | 86 | void |
88 | GNUNET_PEER_decrement_rcs (const GNUNET_PEER_Id *ids, unsigned int count); | 87 | GNUNET_PEER_decrement_rcs (const GNUNET_PEER_Id *ids, |
88 | unsigned int count); | ||
89 | 89 | ||
90 | 90 | ||
91 | /** | 91 | /** |
@@ -95,14 +95,15 @@ GNUNET_PEER_decrement_rcs (const GNUNET_PEER_Id *ids, unsigned int count); | |||
95 | * @param pid where to write the normal peer identity | 95 | * @param pid where to write the normal peer identity |
96 | */ | 96 | */ |
97 | void | 97 | void |
98 | GNUNET_PEER_resolve (GNUNET_PEER_Id id, struct GNUNET_PeerIdentity *pid); | 98 | GNUNET_PEER_resolve (GNUNET_PEER_Id id, |
99 | struct GNUNET_PeerIdentity *pid); | ||
99 | 100 | ||
100 | 101 | ||
101 | /** | 102 | /** |
102 | * Convert an interned PID to a normal peer identity. | 103 | * Convert an interned PID to a normal peer identity. |
103 | * | 104 | * |
104 | * @param id interned PID to convert | 105 | * @param id interned PID to convert |
105 | * @return pointer to peer identity, valid as long 'id' is valid | 106 | * @return pointer to peer identity, valid as long @a id is valid |
106 | */ | 107 | */ |
107 | const struct GNUNET_PeerIdentity * | 108 | const struct GNUNET_PeerIdentity * |
108 | GNUNET_PEER_resolve2 (GNUNET_PEER_Id id); | 109 | GNUNET_PEER_resolve2 (GNUNET_PEER_Id id); |
diff --git a/src/include/gnunet_transport_service.h b/src/include/gnunet_transport_service.h index d1b341a8c..a511a0e7d 100644 --- a/src/include/gnunet_transport_service.h +++ b/src/include/gnunet_transport_service.h | |||
@@ -41,7 +41,7 @@ extern "C" | |||
41 | /** | 41 | /** |
42 | * Version number of the transport API. | 42 | * Version number of the transport API. |
43 | */ | 43 | */ |
44 | #define GNUNET_TRANSPORT_VERSION 0x00000001 | 44 | #define GNUNET_TRANSPORT_VERSION 0x00000002 |
45 | 45 | ||
46 | 46 | ||
47 | /** | 47 | /** |
@@ -672,7 +672,7 @@ struct GNUNET_TRANSPORT_PeerMonitoringContext; | |||
672 | * @param cls closure | 672 | * @param cls closure |
673 | * @param peer peer this update is about, | 673 | * @param peer peer this update is about, |
674 | * NULL if this is the final last callback for a iteration operation | 674 | * NULL if this is the final last callback for a iteration operation |
675 | * @param address address, NULL for disconnect notification in monitor mode | 675 | * @param address address, NULL if this is the final callback for iteration op |
676 | * @param state current state this peer is in | 676 | * @param state current state this peer is in |
677 | * @param state_timeout timeout for the current state of the peer | 677 | * @param state_timeout timeout for the current state of the peer |
678 | */ | 678 | */ |
@@ -789,13 +789,11 @@ enum GNUNET_TRANSPORT_ValidationState | |||
789 | * the current state of the validation entry, | 789 | * the current state of the validation entry, |
790 | * | 790 | * |
791 | * If the monitoring was called with `one_shot==GNUNET_YES`, a final callback | 791 | * If the monitoring was called with `one_shot==GNUNET_YES`, a final callback |
792 | * with `peer==NULL` and `address==NULL` is executed. | 792 | * with `address==NULL` is executed. |
793 | * | 793 | * |
794 | * @param cls closure | 794 | * @param cls closure |
795 | * @param peer peer this update is about, | 795 | * @param address address this update is about, |
796 | * NULL if this is the final last callback for a iteration operation | 796 | * NULL if this is the final last callback for a iteration operation |
797 | * @param address address, | ||
798 | * NULL for disconnect notification in monitor mode | ||
799 | * @param last_validation when was this address last validated | 797 | * @param last_validation when was this address last validated |
800 | * @param valid_until when does this address expire | 798 | * @param valid_until when does this address expire |
801 | * @param next_validation time of the next validation operation | 799 | * @param next_validation time of the next validation operation |
@@ -803,7 +801,6 @@ enum GNUNET_TRANSPORT_ValidationState | |||
803 | */ | 801 | */ |
804 | typedef void | 802 | typedef void |
805 | (*GNUNET_TRANSPORT_ValidationIterateCallback) (void *cls, | 803 | (*GNUNET_TRANSPORT_ValidationIterateCallback) (void *cls, |
806 | const struct GNUNET_PeerIdentity *peer, | ||
807 | const struct GNUNET_HELLO_Address *address, | 804 | const struct GNUNET_HELLO_Address *address, |
808 | struct GNUNET_TIME_Absolute last_validation, | 805 | struct GNUNET_TIME_Absolute last_validation, |
809 | struct GNUNET_TIME_Absolute valid_until, | 806 | struct GNUNET_TIME_Absolute valid_until, |
@@ -1061,5 +1058,3 @@ GNUNET_TRANSPORT_monitor_plugins_cancel (struct GNUNET_TRANSPORT_PluginMonitor * | |||
1061 | /* ifndef GNUNET_TRANSPORT_SERVICE_H */ | 1058 | /* ifndef GNUNET_TRANSPORT_SERVICE_H */ |
1062 | #endif | 1059 | #endif |
1063 | /* end of gnunet_transport_service.h */ | 1060 | /* end of gnunet_transport_service.h */ |
1064 | |||
1065 | |||
diff --git a/src/transport/gnunet-service-transport.c b/src/transport/gnunet-service-transport.c index 3ff5ab172..ca0f6b813 100644 --- a/src/transport/gnunet-service-transport.c +++ b/src/transport/gnunet-service-transport.c | |||
@@ -161,7 +161,7 @@ struct BlacklistCheckContext *bc_tail; | |||
161 | * Transmit our HELLO message to the given (connected) neighbour. | 161 | * Transmit our HELLO message to the given (connected) neighbour. |
162 | * | 162 | * |
163 | * @param cls the 'HELLO' message | 163 | * @param cls the 'HELLO' message |
164 | * @param target a connected neighbour | 164 | * @param peer identity of the peer |
165 | * @param address the address | 165 | * @param address the address |
166 | * @param state current state this peer is in | 166 | * @param state current state this peer is in |
167 | * @param state_timeout timeout for the current state of the peer | 167 | * @param state_timeout timeout for the current state of the peer |
@@ -169,22 +169,27 @@ struct BlacklistCheckContext *bc_tail; | |||
169 | * @param bandwidth_out outbound quota in NBO | 169 | * @param bandwidth_out outbound quota in NBO |
170 | */ | 170 | */ |
171 | static void | 171 | static void |
172 | transmit_our_hello (void *cls, const struct GNUNET_PeerIdentity *target, | 172 | transmit_our_hello (void *cls, |
173 | const struct GNUNET_HELLO_Address *address, | 173 | const struct GNUNET_PeerIdentity *peer, |
174 | enum GNUNET_TRANSPORT_PeerState state, | 174 | const struct GNUNET_HELLO_Address *address, |
175 | struct GNUNET_TIME_Absolute state_timeout, | 175 | enum GNUNET_TRANSPORT_PeerState state, |
176 | struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in, | 176 | struct GNUNET_TIME_Absolute state_timeout, |
177 | struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out) | 177 | struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in, |
178 | struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out) | ||
178 | { | 179 | { |
179 | const struct GNUNET_MessageHeader *hello = cls; | 180 | const struct GNUNET_MessageHeader *hello = cls; |
180 | 181 | ||
181 | if (GNUNET_NO == GST_neighbours_test_connected (target)) | 182 | if (GNUNET_NO == GST_neighbours_test_connected (peer)) |
182 | return; | 183 | return; |
183 | 184 | ||
184 | GST_neighbours_send (target, hello, ntohs (hello->size), hello_expiration, | 185 | GST_neighbours_send (peer, |
186 | hello, | ||
187 | ntohs (hello->size), | ||
188 | hello_expiration, | ||
185 | NULL, NULL); | 189 | NULL, NULL); |
186 | } | 190 | } |
187 | 191 | ||
192 | |||
188 | /** | 193 | /** |
189 | * My HELLO has changed. Tell everyone who should know. | 194 | * My HELLO has changed. Tell everyone who should know. |
190 | * | 195 | * |
@@ -202,7 +207,6 @@ process_hello_update (void *cls, const struct GNUNET_MessageHeader *hello) | |||
202 | /** | 207 | /** |
203 | * We received some payload. Prepare to pass it on to our clients. | 208 | * We received some payload. Prepare to pass it on to our clients. |
204 | * | 209 | * |
205 | * @param peer (claimed) identity of the other peer | ||
206 | * @param address address and (claimed) identity of the other peer | 210 | * @param address address and (claimed) identity of the other peer |
207 | * @param session identifier used for this session (NULL for plugins | 211 | * @param session identifier used for this session (NULL for plugins |
208 | * that do not offer bi-directional communication to the sender | 212 | * that do not offer bi-directional communication to the sender |
@@ -211,8 +215,7 @@ process_hello_update (void *cls, const struct GNUNET_MessageHeader *hello) | |||
211 | * @return how long the plugin should wait until receiving more data | 215 | * @return how long the plugin should wait until receiving more data |
212 | */ | 216 | */ |
213 | static struct GNUNET_TIME_Relative | 217 | static struct GNUNET_TIME_Relative |
214 | process_payload (const struct GNUNET_PeerIdentity *peer, | 218 | process_payload (const struct GNUNET_HELLO_Address *address, |
215 | const struct GNUNET_HELLO_Address *address, | ||
216 | struct Session *session, | 219 | struct Session *session, |
217 | const struct GNUNET_MessageHeader *message) | 220 | const struct GNUNET_MessageHeader *message) |
218 | { | 221 | { |
@@ -224,14 +227,16 @@ process_payload (const struct GNUNET_PeerIdentity *peer, | |||
224 | char buf[size] GNUNET_ALIGN; | 227 | char buf[size] GNUNET_ALIGN; |
225 | 228 | ||
226 | do_forward = GNUNET_SYSERR; | 229 | do_forward = GNUNET_SYSERR; |
227 | ret = GST_neighbours_calculate_receive_delay (peer, msg_size, &do_forward); | 230 | ret = GST_neighbours_calculate_receive_delay (&address->peer, |
228 | if (! GST_neighbours_test_connected (peer)) | 231 | msg_size, |
232 | &do_forward); | ||
233 | if (! GST_neighbours_test_connected (&address->peer)) | ||
229 | { | 234 | { |
230 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 235 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
231 | "Discarded %u bytes type %u payload from peer `%s'\n", | 236 | "Discarded %u bytes type %u payload from peer `%s'\n", |
232 | msg_size, | 237 | msg_size, |
233 | ntohs (message->type), | 238 | ntohs (message->type), |
234 | GNUNET_i2s (peer)); | 239 | GNUNET_i2s (&address->peer)); |
235 | GNUNET_STATISTICS_update (GST_stats, gettext_noop | 240 | GNUNET_STATISTICS_update (GST_stats, gettext_noop |
236 | ("# bytes payload discarded due to not connected peer"), | 241 | ("# bytes payload discarded due to not connected peer"), |
237 | msg_size, | 242 | msg_size, |
@@ -244,7 +249,7 @@ process_payload (const struct GNUNET_PeerIdentity *peer, | |||
244 | im = (struct InboundMessage *) buf; | 249 | im = (struct InboundMessage *) buf; |
245 | im->header.size = htons (size); | 250 | im->header.size = htons (size); |
246 | im->header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_RECV); | 251 | im->header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_RECV); |
247 | im->peer = *peer; | 252 | im->peer = address->peer; |
248 | memcpy (&im[1], message, ntohs (message->size)); | 253 | memcpy (&im[1], message, ntohs (message->size)); |
249 | GST_clients_broadcast (&im->header, GNUNET_YES); | 254 | GST_clients_broadcast (&im->header, GNUNET_YES); |
250 | return ret; | 255 | return ret; |
@@ -427,8 +432,7 @@ GST_receive_callback (void *cls, | |||
427 | gettext_noop ("# bytes total received"), | 432 | gettext_noop ("# bytes total received"), |
428 | ntohs (message->size), | 433 | ntohs (message->size), |
429 | GNUNET_NO); | 434 | GNUNET_NO); |
430 | GST_neighbours_notify_data_recv (&address->peer, | 435 | GST_neighbours_notify_data_recv (address, |
431 | address, | ||
432 | session, | 436 | session, |
433 | message); | 437 | message); |
434 | switch (type) | 438 | switch (type) |
@@ -489,7 +493,6 @@ GST_receive_callback (void *cls, | |||
489 | case GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_SYN_ACK: | 493 | case GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_SYN_ACK: |
490 | if (GNUNET_OK != | 494 | if (GNUNET_OK != |
491 | GST_neighbours_handle_session_syn_ack (message, | 495 | GST_neighbours_handle_session_syn_ack (message, |
492 | &address->peer, | ||
493 | address, | 496 | address, |
494 | session)) | 497 | session)) |
495 | { | 498 | { |
@@ -500,7 +503,6 @@ GST_receive_callback (void *cls, | |||
500 | case GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_ACK: | 503 | case GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_ACK: |
501 | if (GNUNET_OK != | 504 | if (GNUNET_OK != |
502 | GST_neighbours_handle_session_ack (message, | 505 | GST_neighbours_handle_session_ack (message, |
503 | &address->peer, | ||
504 | address, | 506 | address, |
505 | session)) | 507 | session)) |
506 | { | 508 | { |
@@ -524,12 +526,10 @@ GST_receive_callback (void *cls, | |||
524 | gettext_noop ("# bytes payload received"), | 526 | gettext_noop ("# bytes payload received"), |
525 | ntohs (message->size), | 527 | ntohs (message->size), |
526 | GNUNET_NO); | 528 | GNUNET_NO); |
527 | GST_neighbours_notify_payload_recv (&address->peer, | 529 | GST_neighbours_notify_payload_recv (address, |
528 | address, | ||
529 | session, | 530 | session, |
530 | message); | 531 | message); |
531 | ret = process_payload (&address->peer, | 532 | ret = process_payload (address, |
532 | address, | ||
533 | session, | 533 | session, |
534 | message); | 534 | message); |
535 | break; | 535 | break; |
@@ -838,8 +838,7 @@ ats_request_address_change (void *cls, | |||
838 | return; | 838 | return; |
839 | } | 839 | } |
840 | 840 | ||
841 | GST_neighbours_switch_to_address (&address->peer, | 841 | GST_neighbours_switch_to_address (address, |
842 | address, | ||
843 | session, | 842 | session, |
844 | bandwidth_in, bandwidth_out); | 843 | bandwidth_in, bandwidth_out); |
845 | } | 844 | } |
@@ -911,12 +910,12 @@ neighbours_disconnect_notification (void *cls, | |||
911 | * active address. | 910 | * active address. |
912 | * | 911 | * |
913 | * @param cls closure | 912 | * @param cls closure |
914 | * @param peer peer this update is about (never NULL) | 913 | * @param peer identity of the peer |
915 | * @param address address, NULL on disconnect | 914 | * @param address address possibly NULL if peer is not connected |
916 | * @param state current state this peer is in | 915 | * @param state current state this peer is in |
917 | * @param state_timeout timeout for the current state of the peer | 916 | * @param state_timeout timeout for the current state of the peer |
918 | * @param bandwidth_in bandwidth assigned inbound | 917 | * @param bandwidth_in bandwidth assigned inbound, 0 on disconnect |
919 | * @param bandwidth_out bandwidth assigned outbound | 918 | * @param bandwidth_out bandwidth assigned outbound, 0 on disconnect |
920 | */ | 919 | */ |
921 | static void | 920 | static void |
922 | neighbours_changed_notification (void *cls, | 921 | neighbours_changed_notification (void *cls, |
@@ -930,10 +929,10 @@ neighbours_changed_notification (void *cls, | |||
930 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 929 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
931 | "Notifying about change for peer `%s' with address `%s' in state `%s' timing out at %s\n", | 930 | "Notifying about change for peer `%s' with address `%s' in state `%s' timing out at %s\n", |
932 | GNUNET_i2s (peer), | 931 | GNUNET_i2s (peer), |
933 | (NULL != address) ? GST_plugins_a2s (address) : "<none>", | 932 | GST_plugins_a2s (address), |
934 | GNUNET_TRANSPORT_ps2s (state), | 933 | GNUNET_TRANSPORT_ps2s (state), |
935 | GNUNET_STRINGS_absolute_time_to_string (state_timeout)); | 934 | GNUNET_STRINGS_absolute_time_to_string (state_timeout)); |
936 | 935 | /* FIXME: include bandwidth in notification! */ | |
937 | GST_clients_broadcast_peer_notification (peer, | 936 | GST_clients_broadcast_peer_notification (peer, |
938 | address, | 937 | address, |
939 | state, | 938 | state, |
diff --git a/src/transport/gnunet-service-transport_ats.c b/src/transport/gnunet-service-transport_ats.c index bc20038f1..0d61365d8 100644 --- a/src/transport/gnunet-service-transport_ats.c +++ b/src/transport/gnunet-service-transport_ats.c | |||
@@ -314,7 +314,7 @@ GST_ats_add_address (const struct GNUNET_HELLO_Address *address, | |||
314 | &ai->address->peer, | 314 | &ai->address->peer, |
315 | ai, | 315 | ai, |
316 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE); | 316 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE); |
317 | publish_p2a_stat_update (); | 317 | publish_p2a_stat_update (); |
318 | } | 318 | } |
319 | 319 | ||
320 | 320 | ||
@@ -534,11 +534,11 @@ destroy_ai (void *cls, | |||
534 | { | 534 | { |
535 | struct AddressInfo *ai = value; | 535 | struct AddressInfo *ai = value; |
536 | 536 | ||
537 | GNUNET_HELLO_address_free (ai->address); | ||
538 | GNUNET_assert (GNUNET_YES == | 537 | GNUNET_assert (GNUNET_YES == |
539 | GNUNET_CONTAINER_multipeermap_remove (p2a, | 538 | GNUNET_CONTAINER_multipeermap_remove (p2a, |
540 | key, | 539 | key, |
541 | ai)); | 540 | ai)); |
541 | GNUNET_HELLO_address_free (ai->address); | ||
542 | GNUNET_free (ai); | 542 | GNUNET_free (ai); |
543 | return GNUNET_OK; | 543 | return GNUNET_OK; |
544 | } | 544 | } |
diff --git a/src/transport/gnunet-service-transport_blacklist.c b/src/transport/gnunet-service-transport_blacklist.c index f1904a5d3..d19ff2e9b 100644 --- a/src/transport/gnunet-service-transport_blacklist.c +++ b/src/transport/gnunet-service-transport_blacklist.c | |||
@@ -501,7 +501,7 @@ struct TestConnectionContext | |||
501 | * blacklisting client. | 501 | * blacklisting client. |
502 | * | 502 | * |
503 | * @param cls the `struct TestConnectionContext *` | 503 | * @param cls the `struct TestConnectionContext *` |
504 | * @param peer neighbour's identity | 504 | * @param peer identity of the peer |
505 | * @param address the address | 505 | * @param address the address |
506 | * @param state current state this peer is in | 506 | * @param state current state this peer is in |
507 | * @param state_timeout timeout for the current state of the peer | 507 | * @param state_timeout timeout for the current state of the peer |
@@ -509,18 +509,21 @@ struct TestConnectionContext | |||
509 | * @param bandwidth_out bandwidth assigned outbound | 509 | * @param bandwidth_out bandwidth assigned outbound |
510 | */ | 510 | */ |
511 | static void | 511 | static void |
512 | test_connection_ok (void *cls, const struct GNUNET_PeerIdentity *peer, | 512 | test_connection_ok (void *cls, |
513 | const struct GNUNET_HELLO_Address *address, | 513 | const struct GNUNET_PeerIdentity *peer, |
514 | enum GNUNET_TRANSPORT_PeerState state, | 514 | const struct GNUNET_HELLO_Address *address, |
515 | struct GNUNET_TIME_Absolute state_timeout, | 515 | enum GNUNET_TRANSPORT_PeerState state, |
516 | struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in, | 516 | struct GNUNET_TIME_Absolute state_timeout, |
517 | struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out) | 517 | struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in, |
518 | struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out) | ||
518 | { | 519 | { |
519 | struct TestConnectionContext *tcc = cls; | 520 | struct TestConnectionContext *tcc = cls; |
520 | struct GST_BlacklistCheck *bc; | 521 | struct GST_BlacklistCheck *bc; |
521 | 522 | ||
522 | bc = GNUNET_new (struct GST_BlacklistCheck); | 523 | bc = GNUNET_new (struct GST_BlacklistCheck); |
523 | GNUNET_CONTAINER_DLL_insert(bc_head, bc_tail, bc); | 524 | GNUNET_CONTAINER_DLL_insert (bc_head, |
525 | bc_tail, | ||
526 | bc); | ||
524 | bc->peer = *peer; | 527 | bc->peer = *peer; |
525 | bc->cont = &confirm_or_drop_neighbour; | 528 | bc->cont = &confirm_or_drop_neighbour; |
526 | bc->cont_cls = NULL; | 529 | bc->cont_cls = NULL; |
diff --git a/src/transport/gnunet-service-transport_clients.c b/src/transport/gnunet-service-transport_clients.c index 3cbd80452..35229c59d 100644 --- a/src/transport/gnunet-service-transport_clients.c +++ b/src/transport/gnunet-service-transport_clients.c | |||
@@ -1181,7 +1181,6 @@ struct IterationContext | |||
1181 | * Output information of validation entries to the given client. | 1181 | * Output information of validation entries to the given client. |
1182 | * | 1182 | * |
1183 | * @param cls the `struct IterationContext *` | 1183 | * @param cls the `struct IterationContext *` |
1184 | * @param peer identity of the neighbour | ||
1185 | * @param address the address | 1184 | * @param address the address |
1186 | * @param last_validation point in time when last validation was performed | 1185 | * @param last_validation point in time when last validation was performed |
1187 | * @param valid_until point in time how long address is valid | 1186 | * @param valid_until point in time how long address is valid |
@@ -1190,7 +1189,6 @@ struct IterationContext | |||
1190 | */ | 1189 | */ |
1191 | static void | 1190 | static void |
1192 | send_validation_information (void *cls, | 1191 | send_validation_information (void *cls, |
1193 | const struct GNUNET_PeerIdentity *peer, | ||
1194 | const struct GNUNET_HELLO_Address *address, | 1192 | const struct GNUNET_HELLO_Address *address, |
1195 | struct GNUNET_TIME_Absolute last_validation, | 1193 | struct GNUNET_TIME_Absolute last_validation, |
1196 | struct GNUNET_TIME_Absolute valid_until, | 1194 | struct GNUNET_TIME_Absolute valid_until, |
@@ -1201,13 +1199,13 @@ send_validation_information (void *cls, | |||
1201 | struct ValidationIterateResponseMessage *msg; | 1199 | struct ValidationIterateResponseMessage *msg; |
1202 | 1200 | ||
1203 | if ( (GNUNET_YES != pc->all) && | 1201 | if ( (GNUNET_YES != pc->all) && |
1204 | (0 != memcmp (peer, &pc->id, sizeof (pc->id))) ) | 1202 | (0 != memcmp (&address->peer, &pc->id, sizeof (pc->id))) ) |
1205 | return; | 1203 | return; |
1206 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1204 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1207 | "Sending information about for validation entry for peer `%s' using address `%s'\n", | 1205 | "Sending information about for validation entry for peer `%s' using address `%s'\n", |
1208 | GNUNET_i2s(peer), | 1206 | GNUNET_i2s (&address->peer), |
1209 | (NULL != address) ? GST_plugins_a2s (address) : "<none>"); | 1207 | (NULL != address) ? GST_plugins_a2s (address) : "<none>"); |
1210 | msg = compose_validation_iterate_response_message (peer, address); | 1208 | msg = compose_validation_iterate_response_message (&address->peer, address); |
1211 | msg->last_validation = GNUNET_TIME_absolute_hton(last_validation); | 1209 | msg->last_validation = GNUNET_TIME_absolute_hton(last_validation); |
1212 | msg->valid_until = GNUNET_TIME_absolute_hton(valid_until); | 1210 | msg->valid_until = GNUNET_TIME_absolute_hton(valid_until); |
1213 | msg->next_validation = GNUNET_TIME_absolute_hton(next_validation); | 1211 | msg->next_validation = GNUNET_TIME_absolute_hton(next_validation); |
diff --git a/src/transport/gnunet-service-transport_neighbours.c b/src/transport/gnunet-service-transport_neighbours.c index 48bd8cdf8..8119d4cba 100644 --- a/src/transport/gnunet-service-transport_neighbours.c +++ b/src/transport/gnunet-service-transport_neighbours.c | |||
@@ -377,7 +377,7 @@ struct NeighbourMapEntry | |||
377 | /** | 377 | /** |
378 | * Time where we should cut the connection (timeout) if we don't | 378 | * Time where we should cut the connection (timeout) if we don't |
379 | * make progress in the state machine (or get a KEEPALIVE_RESPONSE | 379 | * make progress in the state machine (or get a KEEPALIVE_RESPONSE |
380 | * if we are in S_CONNECTED). | 380 | * if we are in #S_CONNECTED). |
381 | */ | 381 | */ |
382 | struct GNUNET_TIME_Absolute timeout; | 382 | struct GNUNET_TIME_Absolute timeout; |
383 | 383 | ||
@@ -418,7 +418,7 @@ struct NeighbourMapEntry | |||
418 | * (once we have an address to use and the peer has been allowed by our | 418 | * (once we have an address to use and the peer has been allowed by our |
419 | * blacklist). Initially set to #ACK_UNDEFINED. Set to #ACK_SEND_SYN_ACK | 419 | * blacklist). Initially set to #ACK_UNDEFINED. Set to #ACK_SEND_SYN_ACK |
420 | * if we need to send a SYN_ACK. Set to #ACK_SEND_ACK if we did | 420 | * if we need to send a SYN_ACK. Set to #ACK_SEND_ACK if we did |
421 | * send a SYN_ACK and should go to 'S_CONNECTED' upon receiving a | 421 | * send a SYN_ACK and should go to #S_CONNECTED upon receiving a |
422 | * 'ACK' (regardless of what our own state machine might say). | 422 | * 'ACK' (regardless of what our own state machine might say). |
423 | */ | 423 | */ |
424 | enum GST_ACK_State ack_state; | 424 | enum GST_ACK_State ack_state; |
@@ -659,18 +659,21 @@ free_address (struct NeighbourAddress *na) | |||
659 | * @param s the new state | 659 | * @param s the new state |
660 | */ | 660 | */ |
661 | static void | 661 | static void |
662 | set_state (struct NeighbourMapEntry *n, enum GNUNET_TRANSPORT_PeerState s) | 662 | set_state (struct NeighbourMapEntry *n, |
663 | enum GNUNET_TRANSPORT_PeerState s) | ||
663 | { | 664 | { |
664 | n->state = s; | 665 | n->state = s; |
665 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Neighbour `%s' changed state to %s\n", | 666 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
666 | GNUNET_i2s (&n->id), | 667 | "Neighbour `%s' changed state to %s\n", |
667 | GNUNET_TRANSPORT_ps2s(s)); | 668 | GNUNET_i2s (&n->id), |
669 | GNUNET_TRANSPORT_ps2s(s)); | ||
668 | neighbour_change_cb (callback_cls, | 670 | neighbour_change_cb (callback_cls, |
669 | &n->id, | 671 | &n->id, |
670 | n->primary_address.address, | 672 | n->primary_address.address, |
671 | n->state, n->timeout, | 673 | n->state, |
672 | n->primary_address.bandwidth_in, | 674 | n->timeout, |
673 | n->primary_address.bandwidth_out); | 675 | n->primary_address.bandwidth_in, |
676 | n->primary_address.bandwidth_out); | ||
674 | } | 677 | } |
675 | 678 | ||
676 | 679 | ||
@@ -683,21 +686,23 @@ set_state (struct NeighbourMapEntry *n, enum GNUNET_TRANSPORT_PeerState s) | |||
683 | */ | 686 | */ |
684 | static void | 687 | static void |
685 | set_state_and_timeout (struct NeighbourMapEntry *n, | 688 | set_state_and_timeout (struct NeighbourMapEntry *n, |
686 | enum GNUNET_TRANSPORT_PeerState s, | 689 | enum GNUNET_TRANSPORT_PeerState s, |
687 | struct GNUNET_TIME_Absolute timeout) | 690 | struct GNUNET_TIME_Absolute timeout) |
688 | { | 691 | { |
689 | n->state = s; | 692 | n->state = s; |
690 | n->timeout = timeout; | 693 | n->timeout = timeout; |
691 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Neighbour `%s' changed state to %s with timeout %s\n", | 694 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
692 | GNUNET_i2s (&n->id), | 695 | "Neighbour `%s' changed state to %s with timeout %s\n", |
693 | GNUNET_TRANSPORT_ps2s(s), | 696 | GNUNET_i2s (&n->id), |
694 | GNUNET_STRINGS_absolute_time_to_string (timeout)); | 697 | GNUNET_TRANSPORT_ps2s(s), |
698 | GNUNET_STRINGS_absolute_time_to_string (timeout)); | ||
695 | neighbour_change_cb (callback_cls, | 699 | neighbour_change_cb (callback_cls, |
696 | &n->id, | 700 | &n->id, |
697 | n->primary_address.address, | 701 | n->primary_address.address, |
698 | n->state, n->timeout, | 702 | n->state, |
699 | n->primary_address.bandwidth_in, | 703 | n->timeout, |
700 | n->primary_address.bandwidth_out); | 704 | n->primary_address.bandwidth_in, |
705 | n->primary_address.bandwidth_out); | ||
701 | } | 706 | } |
702 | 707 | ||
703 | 708 | ||
@@ -709,7 +714,7 @@ set_state_and_timeout (struct NeighbourMapEntry *n, | |||
709 | */ | 714 | */ |
710 | static void | 715 | static void |
711 | set_timeout (struct NeighbourMapEntry *n, | 716 | set_timeout (struct NeighbourMapEntry *n, |
712 | struct GNUNET_TIME_Absolute timeout) | 717 | struct GNUNET_TIME_Absolute timeout) |
713 | { | 718 | { |
714 | n->timeout = timeout; | 719 | n->timeout = timeout; |
715 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 720 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
@@ -717,11 +722,11 @@ set_timeout (struct NeighbourMapEntry *n, | |||
717 | GNUNET_i2s (&n->id), | 722 | GNUNET_i2s (&n->id), |
718 | GNUNET_STRINGS_absolute_time_to_string (timeout)); | 723 | GNUNET_STRINGS_absolute_time_to_string (timeout)); |
719 | neighbour_change_cb (callback_cls, | 724 | neighbour_change_cb (callback_cls, |
720 | &n->id, | 725 | &n->id, |
721 | n->primary_address.address, | 726 | n->primary_address.address, |
722 | n->state, n->timeout, | 727 | n->state, n->timeout, |
723 | n->primary_address.bandwidth_in, | 728 | n->primary_address.bandwidth_in, |
724 | n->primary_address.bandwidth_out); | 729 | n->primary_address.bandwidth_out); |
725 | } | 730 | } |
726 | 731 | ||
727 | 732 | ||
@@ -876,7 +881,8 @@ set_primary_address (struct NeighbourMapEntry *n, | |||
876 | neighbour_change_cb (callback_cls, | 881 | neighbour_change_cb (callback_cls, |
877 | &n->id, | 882 | &n->id, |
878 | n->primary_address.address, | 883 | n->primary_address.address, |
879 | n->state, n->timeout, | 884 | n->state, |
885 | n->timeout, | ||
880 | n->primary_address.bandwidth_in, | 886 | n->primary_address.bandwidth_in, |
881 | n->primary_address.bandwidth_out); | 887 | n->primary_address.bandwidth_out); |
882 | } | 888 | } |
@@ -891,16 +897,16 @@ set_primary_address (struct NeighbourMapEntry *n, | |||
891 | static void | 897 | static void |
892 | unset_primary_address (struct NeighbourMapEntry *n) | 898 | unset_primary_address (struct NeighbourMapEntry *n) |
893 | { | 899 | { |
894 | /* Unset primary address */ | 900 | /* Notify monitoring about change */ |
895 | free_address (&n->primary_address); | ||
896 | |||
897 | /* Notify monitoring about it */ | ||
898 | neighbour_change_cb (callback_cls, | 901 | neighbour_change_cb (callback_cls, |
899 | &n->id, | 902 | &n->id, |
900 | NULL, | 903 | n->primary_address.address, |
901 | n->state, n->timeout, | 904 | n->state, |
902 | n->primary_address.bandwidth_in, | 905 | n->timeout, |
903 | n->primary_address.bandwidth_out); | 906 | GNUNET_BANDWIDTH_value_init (0), |
907 | GNUNET_BANDWIDTH_value_init (0)); | ||
908 | /* Unset primary address */ | ||
909 | free_address (&n->primary_address); | ||
904 | } | 910 | } |
905 | 911 | ||
906 | 912 | ||
@@ -1048,8 +1054,9 @@ send_with_session (struct NeighbourMapEntry *n, | |||
1048 | cont, cont_cls)))) && | 1054 | cont, cont_cls)))) && |
1049 | (NULL != cont)) | 1055 | (NULL != cont)) |
1050 | cont (cont_cls, &n->id, GNUNET_SYSERR, msgbuf_size, 0); | 1056 | cont (cont_cls, &n->id, GNUNET_SYSERR, msgbuf_size, 0); |
1051 | GST_neighbours_notify_data_sent (&n->id, | 1057 | GST_neighbours_notify_data_sent (n->primary_address.address, |
1052 | n->primary_address.address, n->primary_address.session, msgbuf_size); | 1058 | n->primary_address.session, |
1059 | msgbuf_size); | ||
1053 | GNUNET_break (NULL != papi); | 1060 | GNUNET_break (NULL != papi); |
1054 | return result; | 1061 | return result; |
1055 | } | 1062 | } |
@@ -1841,8 +1848,7 @@ send_syn (struct NeighbourAddress *na) | |||
1841 | break; | 1848 | break; |
1842 | } | 1849 | } |
1843 | } | 1850 | } |
1844 | GST_neighbours_notify_data_sent (&na->address->peer, | 1851 | GST_neighbours_notify_data_sent (na->address, |
1845 | na->address, | ||
1846 | na->session, | 1852 | na->session, |
1847 | sizeof (struct TransportSynMessage)); | 1853 | sizeof (struct TransportSynMessage)); |
1848 | } | 1854 | } |
@@ -1901,8 +1907,8 @@ send_session_connect_ack_cont (void *cls, | |||
1901 | */ | 1907 | */ |
1902 | static void | 1908 | static void |
1903 | send_connect_ack_message (const struct GNUNET_HELLO_Address *address, | 1909 | send_connect_ack_message (const struct GNUNET_HELLO_Address *address, |
1904 | struct Session *session, | 1910 | struct Session *session, |
1905 | struct GNUNET_TIME_Absolute timestamp) | 1911 | struct GNUNET_TIME_Absolute timestamp) |
1906 | { | 1912 | { |
1907 | struct GNUNET_TRANSPORT_PluginFunctions *papi; | 1913 | struct GNUNET_TRANSPORT_PluginFunctions *papi; |
1908 | struct TransportSynMessage connect_msg; | 1914 | struct TransportSynMessage connect_msg; |
@@ -2738,7 +2744,6 @@ switch_address_bl_check_cont (void *cls, | |||
2738 | * Before accepting this addresses and actively using it, a blacklist check | 2744 | * Before accepting this addresses and actively using it, a blacklist check |
2739 | * is performed. If this blacklist check fails the address will be destroyed. | 2745 | * is performed. If this blacklist check fails the address will be destroyed. |
2740 | * | 2746 | * |
2741 | * @param peer identity of the peer to switch the address for | ||
2742 | * @param address address of the other peer, | 2747 | * @param address address of the other peer, |
2743 | * @param session session to use or NULL if transport should initiate a session | 2748 | * @param session session to use or NULL if transport should initiate a session |
2744 | * @param bandwidth_in inbound quota to be used when connection is up, | 2749 | * @param bandwidth_in inbound quota to be used when connection is up, |
@@ -2747,8 +2752,7 @@ switch_address_bl_check_cont (void *cls, | |||
2747 | * 0 to disconnect from peer | 2752 | * 0 to disconnect from peer |
2748 | */ | 2753 | */ |
2749 | void | 2754 | void |
2750 | GST_neighbours_switch_to_address (const struct GNUNET_PeerIdentity *peer, | 2755 | GST_neighbours_switch_to_address (const struct GNUNET_HELLO_Address *address, |
2751 | const struct GNUNET_HELLO_Address *address, | ||
2752 | struct Session *session, | 2756 | struct Session *session, |
2753 | struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in, | 2757 | struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in, |
2754 | struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out) | 2758 | struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out) |
@@ -2759,13 +2763,13 @@ GST_neighbours_switch_to_address (const struct GNUNET_PeerIdentity *peer, | |||
2759 | 2763 | ||
2760 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 2764 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
2761 | "ATS has decided on an address for peer %s\n", | 2765 | "ATS has decided on an address for peer %s\n", |
2762 | GNUNET_i2s (peer)); | 2766 | GNUNET_i2s (&address->peer)); |
2763 | GNUNET_assert (NULL != address->transport_name); | 2767 | GNUNET_assert (NULL != address->transport_name); |
2764 | if (NULL == (n = lookup_neighbour (peer))) | 2768 | if (NULL == (n = lookup_neighbour (&address->peer))) |
2765 | { | 2769 | { |
2766 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 2770 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
2767 | "Peer %s is unknown, suggestion ignored\n", | 2771 | "Peer %s is unknown, suggestion ignored\n", |
2768 | GNUNET_i2s (peer)); | 2772 | GNUNET_i2s (&address->peer)); |
2769 | return; | 2773 | return; |
2770 | } | 2774 | } |
2771 | 2775 | ||
@@ -2786,12 +2790,15 @@ GST_neighbours_switch_to_address (const struct GNUNET_PeerIdentity *peer, | |||
2786 | } | 2790 | } |
2787 | 2791 | ||
2788 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 2792 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
2789 | "ATS suggests %s address '%s' session %p for " | 2793 | "ATS suggests %s address '%s' session %p for " |
2790 | "peer `%s' in state %s/%s \n", | 2794 | "peer `%s' in state %s/%s \n", |
2791 | GNUNET_HELLO_address_check_option (address, | 2795 | GNUNET_HELLO_address_check_option (address, |
2792 | GNUNET_HELLO_ADDRESS_INFO_INBOUND) ? "inbound" : "outbound", | 2796 | GNUNET_HELLO_ADDRESS_INFO_INBOUND) ? "inbound" : "outbound", |
2793 | GST_plugins_a2s (address), session, GNUNET_i2s (peer), | 2797 | GST_plugins_a2s (address), |
2794 | GNUNET_TRANSPORT_ps2s (n->state), print_ack_state (n->ack_state)); | 2798 | session, |
2799 | GNUNET_i2s (&address->peer), | ||
2800 | GNUNET_TRANSPORT_ps2s (n->state), | ||
2801 | print_ack_state (n->ack_state)); | ||
2795 | 2802 | ||
2796 | /* Perform blacklist check */ | 2803 | /* Perform blacklist check */ |
2797 | blc_ctx = GNUNET_new (struct BlacklistCheckSwitchContext); | 2804 | blc_ctx = GNUNET_new (struct BlacklistCheckSwitchContext); |
@@ -2802,7 +2809,7 @@ GST_neighbours_switch_to_address (const struct GNUNET_PeerIdentity *peer, | |||
2802 | GNUNET_CONTAINER_DLL_insert (pending_bc_head, | 2809 | GNUNET_CONTAINER_DLL_insert (pending_bc_head, |
2803 | pending_bc_tail, | 2810 | pending_bc_tail, |
2804 | blc_ctx); | 2811 | blc_ctx); |
2805 | if (NULL != (blc = GST_blacklist_test_allowed (peer, | 2812 | if (NULL != (blc = GST_blacklist_test_allowed (&address->peer, |
2806 | address->transport_name, | 2813 | address->transport_name, |
2807 | &switch_address_bl_check_cont, | 2814 | &switch_address_bl_check_cont, |
2808 | blc_ctx))) | 2815 | blc_ctx))) |
@@ -2908,14 +2915,13 @@ utilization_transmission (void *cls, | |||
2908 | 2915 | ||
2909 | 2916 | ||
2910 | void | 2917 | void |
2911 | GST_neighbours_notify_data_recv (const struct GNUNET_PeerIdentity *peer, | 2918 | GST_neighbours_notify_data_recv (const struct GNUNET_HELLO_Address *address, |
2912 | const struct GNUNET_HELLO_Address *address, | ||
2913 | struct Session *session, | 2919 | struct Session *session, |
2914 | const struct GNUNET_MessageHeader *message) | 2920 | const struct GNUNET_MessageHeader *message) |
2915 | { | 2921 | { |
2916 | struct NeighbourMapEntry *n; | 2922 | struct NeighbourMapEntry *n; |
2917 | 2923 | ||
2918 | n = lookup_neighbour (peer); | 2924 | n = lookup_neighbour (&address->peer); |
2919 | if (NULL == n) | 2925 | if (NULL == n) |
2920 | return; | 2926 | return; |
2921 | n->util_total_bytes_recv += ntohs(message->size); | 2927 | n->util_total_bytes_recv += ntohs(message->size); |
@@ -2923,13 +2929,13 @@ GST_neighbours_notify_data_recv (const struct GNUNET_PeerIdentity *peer, | |||
2923 | 2929 | ||
2924 | 2930 | ||
2925 | void | 2931 | void |
2926 | GST_neighbours_notify_payload_recv (const struct GNUNET_PeerIdentity *peer, | 2932 | GST_neighbours_notify_payload_recv (const struct GNUNET_HELLO_Address *address, |
2927 | const struct GNUNET_HELLO_Address *address, | ||
2928 | struct Session *session, | 2933 | struct Session *session, |
2929 | const struct GNUNET_MessageHeader *message) | 2934 | const struct GNUNET_MessageHeader *message) |
2930 | { | 2935 | { |
2931 | struct NeighbourMapEntry *n; | 2936 | struct NeighbourMapEntry *n; |
2932 | n = lookup_neighbour (peer); | 2937 | |
2938 | n = lookup_neighbour (&address->peer); | ||
2933 | if (NULL == n) | 2939 | if (NULL == n) |
2934 | return; | 2940 | return; |
2935 | n->util_payload_bytes_recv += ntohs(message->size); | 2941 | n->util_payload_bytes_recv += ntohs(message->size); |
@@ -2937,13 +2943,13 @@ GST_neighbours_notify_payload_recv (const struct GNUNET_PeerIdentity *peer, | |||
2937 | 2943 | ||
2938 | 2944 | ||
2939 | void | 2945 | void |
2940 | GST_neighbours_notify_data_sent (const struct GNUNET_PeerIdentity *peer, | 2946 | GST_neighbours_notify_data_sent (const struct GNUNET_HELLO_Address *address, |
2941 | const struct GNUNET_HELLO_Address *address, | ||
2942 | struct Session *session, | 2947 | struct Session *session, |
2943 | size_t size) | 2948 | size_t size) |
2944 | { | 2949 | { |
2945 | struct NeighbourMapEntry *n; | 2950 | struct NeighbourMapEntry *n; |
2946 | n = lookup_neighbour (peer); | 2951 | |
2952 | n = lookup_neighbour (&address->peer); | ||
2947 | if (NULL == n) | 2953 | if (NULL == n) |
2948 | return; | 2954 | return; |
2949 | if (n->primary_address.session != session) | 2955 | if (n->primary_address.session != session) |
@@ -3154,9 +3160,8 @@ send_session_ack_message (struct NeighbourMapEntry *n) | |||
3154 | */ | 3160 | */ |
3155 | int | 3161 | int |
3156 | GST_neighbours_handle_session_syn_ack (const struct GNUNET_MessageHeader *message, | 3162 | GST_neighbours_handle_session_syn_ack (const struct GNUNET_MessageHeader *message, |
3157 | const struct GNUNET_PeerIdentity *peer, | 3163 | const struct GNUNET_HELLO_Address *address, |
3158 | const struct GNUNET_HELLO_Address *address, | 3164 | struct Session *session) |
3159 | struct Session *session) | ||
3160 | { | 3165 | { |
3161 | const struct TransportSynMessage *scm; | 3166 | const struct TransportSynMessage *scm; |
3162 | struct GNUNET_TIME_Absolute ts; | 3167 | struct GNUNET_TIME_Absolute ts; |
@@ -3164,7 +3169,7 @@ GST_neighbours_handle_session_syn_ack (const struct GNUNET_MessageHeader *messag | |||
3164 | 3169 | ||
3165 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 3170 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
3166 | "Received SYN_ACK message from peer `%s'\n", | 3171 | "Received SYN_ACK message from peer `%s'\n", |
3167 | GNUNET_i2s (peer)); | 3172 | GNUNET_i2s (&address->peer)); |
3168 | 3173 | ||
3169 | if (ntohs (message->size) != sizeof (struct TransportSynMessage)) | 3174 | if (ntohs (message->size) != sizeof (struct TransportSynMessage)) |
3170 | { | 3175 | { |
@@ -3177,7 +3182,7 @@ GST_neighbours_handle_session_syn_ack (const struct GNUNET_MessageHeader *messag | |||
3177 | 1, GNUNET_NO); | 3182 | 1, GNUNET_NO); |
3178 | scm = (const struct TransportSynMessage *) message; | 3183 | scm = (const struct TransportSynMessage *) message; |
3179 | GNUNET_break_op (ntohl (scm->reserved) == 0); | 3184 | GNUNET_break_op (ntohl (scm->reserved) == 0); |
3180 | if (NULL == (n = lookup_neighbour (peer))) | 3185 | if (NULL == (n = lookup_neighbour (&address->peer))) |
3181 | { | 3186 | { |
3182 | GNUNET_STATISTICS_update (GST_stats, | 3187 | GNUNET_STATISTICS_update (GST_stats, |
3183 | gettext_noop | 3188 | gettext_noop |
@@ -3211,7 +3216,8 @@ GST_neighbours_handle_session_syn_ack (const struct GNUNET_MessageHeader *messag | |||
3211 | gettext_noop ("# peers connected"), | 3216 | gettext_noop ("# peers connected"), |
3212 | ++neighbours_connected, | 3217 | ++neighbours_connected, |
3213 | GNUNET_NO); | 3218 | GNUNET_NO); |
3214 | connect_notify_cb (callback_cls, &n->id, | 3219 | connect_notify_cb (callback_cls, |
3220 | &n->id, | ||
3215 | n->primary_address.bandwidth_in, | 3221 | n->primary_address.bandwidth_in, |
3216 | n->primary_address.bandwidth_out); | 3222 | n->primary_address.bandwidth_out); |
3217 | /* Tell ATS that the outbound session we created to send SYN was successful */ | 3223 | /* Tell ATS that the outbound session we created to send SYN was successful */ |
@@ -3433,15 +3439,12 @@ GST_neighbours_session_terminated (const struct GNUNET_PeerIdentity *peer, | |||
3433 | * connected. Otherwise, do nothing. | 3439 | * connected. Otherwise, do nothing. |
3434 | * | 3440 | * |
3435 | * @param message possibly a 'struct SessionConnectMessage' (check format) | 3441 | * @param message possibly a 'struct SessionConnectMessage' (check format) |
3436 | * @param peer identity of the peer to switch the address for | 3442 | * @param address address of the other peer |
3437 | * @param address address of the other peer, NULL if other peer | ||
3438 | * connected to us | ||
3439 | * @param session session to use (or NULL) | 3443 | * @param session session to use (or NULL) |
3440 | * @return #GNUNET_OK if the message was fine, #GNUNET_SYSERR on serious error | 3444 | * @return #GNUNET_OK if the message was fine, #GNUNET_SYSERR on serious error |
3441 | */ | 3445 | */ |
3442 | int | 3446 | int |
3443 | GST_neighbours_handle_session_ack (const struct GNUNET_MessageHeader *message, | 3447 | GST_neighbours_handle_session_ack (const struct GNUNET_MessageHeader *message, |
3444 | const struct GNUNET_PeerIdentity *peer, | ||
3445 | const struct GNUNET_HELLO_Address *address, | 3448 | const struct GNUNET_HELLO_Address *address, |
3446 | struct Session *session) | 3449 | struct Session *session) |
3447 | { | 3450 | { |
@@ -3449,7 +3452,7 @@ GST_neighbours_handle_session_ack (const struct GNUNET_MessageHeader *message, | |||
3449 | 3452 | ||
3450 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 3453 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
3451 | "Received ACK message from peer `%s'\n", | 3454 | "Received ACK message from peer `%s'\n", |
3452 | GNUNET_i2s (peer)); | 3455 | GNUNET_i2s (&address->peer)); |
3453 | if (ntohs (message->size) != sizeof (struct GNUNET_MessageHeader)) | 3456 | if (ntohs (message->size) != sizeof (struct GNUNET_MessageHeader)) |
3454 | { | 3457 | { |
3455 | GNUNET_break_op (0); | 3458 | GNUNET_break_op (0); |
@@ -3459,7 +3462,7 @@ GST_neighbours_handle_session_ack (const struct GNUNET_MessageHeader *message, | |||
3459 | gettext_noop | 3462 | gettext_noop |
3460 | ("# ACK messages received"), | 3463 | ("# ACK messages received"), |
3461 | 1, GNUNET_NO); | 3464 | 1, GNUNET_NO); |
3462 | if (NULL == (n = lookup_neighbour (peer))) | 3465 | if (NULL == (n = lookup_neighbour (&address->peer))) |
3463 | { | 3466 | { |
3464 | GNUNET_break_op (0); | 3467 | GNUNET_break_op (0); |
3465 | return GNUNET_SYSERR; | 3468 | return GNUNET_SYSERR; |
@@ -3468,7 +3471,7 @@ GST_neighbours_handle_session_ack (const struct GNUNET_MessageHeader *message, | |||
3468 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 3471 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
3469 | "Received %s for peer `%s' in state %s/%s\n", | 3472 | "Received %s for peer `%s' in state %s/%s\n", |
3470 | "ACK", | 3473 | "ACK", |
3471 | GNUNET_i2s (peer), | 3474 | GNUNET_i2s (&address->peer), |
3472 | GNUNET_TRANSPORT_ps2s (n->state), | 3475 | GNUNET_TRANSPORT_ps2s (n->state), |
3473 | print_ack_state (n->ack_state)); | 3476 | print_ack_state (n->ack_state)); |
3474 | 3477 | ||
@@ -3488,7 +3491,7 @@ GST_neighbours_handle_session_ack (const struct GNUNET_MessageHeader *message, | |||
3488 | { | 3491 | { |
3489 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 3492 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
3490 | "Received unexpected ACK message from peer `%s' in state %s/%s\n", | 3493 | "Received unexpected ACK message from peer `%s' in state %s/%s\n", |
3491 | GNUNET_i2s (peer), | 3494 | GNUNET_i2s (&address->peer), |
3492 | GNUNET_TRANSPORT_ps2s (n->state), | 3495 | GNUNET_TRANSPORT_ps2s (n->state), |
3493 | print_ack_state (n->ack_state)); | 3496 | print_ack_state (n->ack_state)); |
3494 | 3497 | ||
@@ -3502,14 +3505,14 @@ GST_neighbours_handle_session_ack (const struct GNUNET_MessageHeader *message, | |||
3502 | if (GNUNET_NO == GST_neighbours_test_connected(&n->id)) | 3505 | if (GNUNET_NO == GST_neighbours_test_connected(&n->id)) |
3503 | { | 3506 | { |
3504 | /* Notify about connection */ | 3507 | /* Notify about connection */ |
3505 | connect_notify_cb (callback_cls, &n->id, | 3508 | connect_notify_cb (callback_cls, |
3506 | n->primary_address.bandwidth_in, | 3509 | &n->id, |
3507 | n->primary_address.bandwidth_out);\ | 3510 | n->primary_address.bandwidth_in, |
3508 | 3511 | n->primary_address.bandwidth_out); | |
3509 | GNUNET_STATISTICS_set (GST_stats, | 3512 | GNUNET_STATISTICS_set (GST_stats, |
3510 | gettext_noop ("# peers connected"), | 3513 | gettext_noop ("# peers connected"), |
3511 | ++neighbours_connected, | 3514 | ++neighbours_connected, |
3512 | GNUNET_NO); | 3515 | GNUNET_NO); |
3513 | } | 3516 | } |
3514 | 3517 | ||
3515 | if (GNUNET_TRANSPORT_PS_SWITCH_SYN_SENT == n->state) | 3518 | if (GNUNET_TRANSPORT_PS_SWITCH_SYN_SENT == n->state) |
@@ -3673,7 +3676,7 @@ GST_neighbours_handle_disconnect_message (const struct GNUNET_PeerIdentity *peer | |||
3673 | 3676 | ||
3674 | 3677 | ||
3675 | /** | 3678 | /** |
3676 | * Closure for the neighbours_iterate function. | 3679 | * Closure for the #neighbours_iterate() function. |
3677 | */ | 3680 | */ |
3678 | struct IteratorContext | 3681 | struct IteratorContext |
3679 | { | 3682 | { |
@@ -3683,7 +3686,7 @@ struct IteratorContext | |||
3683 | GST_NeighbourIterator cb; | 3686 | GST_NeighbourIterator cb; |
3684 | 3687 | ||
3685 | /** | 3688 | /** |
3686 | * Closure for 'cb'. | 3689 | * Closure for @e cb. |
3687 | */ | 3690 | */ |
3688 | void *cb_cls; | 3691 | void *cb_cls; |
3689 | }; | 3692 | }; |
diff --git a/src/transport/gnunet-service-transport_neighbours.h b/src/transport/gnunet-service-transport_neighbours.h index 744a3b913..0c07557d0 100644 --- a/src/transport/gnunet-service-transport_neighbours.h +++ b/src/transport/gnunet-service-transport_neighbours.h | |||
@@ -201,8 +201,8 @@ GST_neighbours_force_disconnect (const struct GNUNET_PeerIdentity *target); | |||
201 | * Function called for each neighbour. | 201 | * Function called for each neighbour. |
202 | * | 202 | * |
203 | * @param cls closure | 203 | * @param cls closure |
204 | * @param neighbour identity of the neighbour | 204 | * @param peer identity of the neighbour |
205 | * @param address the address (or NULL) | 205 | * @param address the address of the neighbour |
206 | * @param state current state the peer is in | 206 | * @param state current state the peer is in |
207 | * @param state_timeout timeout for this state | 207 | * @param state_timeout timeout for this state |
208 | * @param bandwidth_in inbound quota in NBO | 208 | * @param bandwidth_in inbound quota in NBO |
@@ -210,7 +210,7 @@ GST_neighbours_force_disconnect (const struct GNUNET_PeerIdentity *target); | |||
210 | */ | 210 | */ |
211 | typedef void | 211 | typedef void |
212 | (*GST_NeighbourIterator) (void *cls, | 212 | (*GST_NeighbourIterator) (void *cls, |
213 | const struct GNUNET_PeerIdentity *neighbour, | 213 | const struct GNUNET_PeerIdentity *peer, |
214 | const struct GNUNET_HELLO_Address *address, | 214 | const struct GNUNET_HELLO_Address *address, |
215 | enum GNUNET_TRANSPORT_PeerState state, | 215 | enum GNUNET_TRANSPORT_PeerState state, |
216 | struct GNUNET_TIME_Absolute state_timeout, | 216 | struct GNUNET_TIME_Absolute state_timeout, |
@@ -245,8 +245,7 @@ GST_neighbours_session_terminated (const struct GNUNET_PeerIdentity *peer, | |||
245 | * FIXME | 245 | * FIXME |
246 | */ | 246 | */ |
247 | void | 247 | void |
248 | GST_neighbours_notify_data_recv (const struct GNUNET_PeerIdentity *peer, | 248 | GST_neighbours_notify_data_recv (const struct GNUNET_HELLO_Address *address, |
249 | const struct GNUNET_HELLO_Address *address, | ||
250 | struct Session *session, | 249 | struct Session *session, |
251 | const struct GNUNET_MessageHeader *message); | 250 | const struct GNUNET_MessageHeader *message); |
252 | 251 | ||
@@ -255,8 +254,7 @@ GST_neighbours_notify_data_recv (const struct GNUNET_PeerIdentity *peer, | |||
255 | * FIXME | 254 | * FIXME |
256 | */ | 255 | */ |
257 | void | 256 | void |
258 | GST_neighbours_notify_payload_recv (const struct GNUNET_PeerIdentity *peer, | 257 | GST_neighbours_notify_payload_recv (const struct GNUNET_HELLO_Address *address, |
259 | const struct GNUNET_HELLO_Address *address, | ||
260 | struct Session *session, | 258 | struct Session *session, |
261 | const struct GNUNET_MessageHeader *message); | 259 | const struct GNUNET_MessageHeader *message); |
262 | 260 | ||
@@ -273,8 +271,7 @@ GST_neighbours_notify_payload_sent (const struct GNUNET_PeerIdentity *peer, | |||
273 | * FIXME | 271 | * FIXME |
274 | */ | 272 | */ |
275 | void | 273 | void |
276 | GST_neighbours_notify_data_sent (const struct GNUNET_PeerIdentity *peer, | 274 | GST_neighbours_notify_data_sent (const struct GNUNET_HELLO_Address *address, |
277 | const struct GNUNET_HELLO_Address *address, | ||
278 | struct Session *session, | 275 | struct Session *session, |
279 | size_t size); | 276 | size_t size); |
280 | 277 | ||
@@ -283,16 +280,13 @@ GST_neighbours_notify_data_sent (const struct GNUNET_PeerIdentity *peer, | |||
283 | * For an existing neighbour record, set the active connection to | 280 | * For an existing neighbour record, set the active connection to |
284 | * use the given address. | 281 | * use the given address. |
285 | * | 282 | * |
286 | * @param peer identity of the peer to switch the address for | 283 | * @param address address of the other peer to start using |
287 | * @param address address of the other peer, NULL if other peer | ||
288 | * connected to us | ||
289 | * @param session session to use (or NULL) | 284 | * @param session session to use (or NULL) |
290 | * @param bandwidth_in inbound quota to be used when connection is up | 285 | * @param bandwidth_in inbound quota to be used when connection is up |
291 | * @param bandwidth_out outbound quota to be used when connection is up | 286 | * @param bandwidth_out outbound quota to be used when connection is up |
292 | */ | 287 | */ |
293 | void | 288 | void |
294 | GST_neighbours_switch_to_address (const struct GNUNET_PeerIdentity *peer, | 289 | GST_neighbours_switch_to_address (const struct GNUNET_HELLO_Address *address, |
295 | const struct GNUNET_HELLO_Address *address, | ||
296 | struct Session *session, | 290 | struct Session *session, |
297 | struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in, | 291 | struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in, |
298 | struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out); | 292 | struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out); |
@@ -316,15 +310,12 @@ GST_neighbours_handle_session_syn (const struct GNUNET_MessageHeader *message, | |||
316 | * Consider switching to it. | 310 | * Consider switching to it. |
317 | * | 311 | * |
318 | * @param message possibly a `struct SessionConnectMessage` (check format) | 312 | * @param message possibly a `struct SessionConnectMessage` (check format) |
319 | * @param peer identity of the peer to switch the address for | 313 | * @param address address of the other peer |
320 | * @param address address of the other peer, NULL if other peer | ||
321 | * connected to us | ||
322 | * @param session session to use (or NULL) | 314 | * @param session session to use (or NULL) |
323 | * @return #GNUNET_OK if the message was fine, #GNUNET_SYSERR on serious error | 315 | * @return #GNUNET_OK if the message was fine, #GNUNET_SYSERR on serious error |
324 | */ | 316 | */ |
325 | int | 317 | int |
326 | GST_neighbours_handle_session_syn_ack (const struct GNUNET_MessageHeader *message, | 318 | GST_neighbours_handle_session_syn_ack (const struct GNUNET_MessageHeader *message, |
327 | const struct GNUNET_PeerIdentity *peer, | ||
328 | const struct GNUNET_HELLO_Address *address, | 319 | const struct GNUNET_HELLO_Address *address, |
329 | struct Session *session); | 320 | struct Session *session); |
330 | 321 | ||
@@ -335,15 +326,12 @@ GST_neighbours_handle_session_syn_ack (const struct GNUNET_MessageHeader *messag | |||
335 | * connected. Otherwise, do nothing. | 326 | * connected. Otherwise, do nothing. |
336 | * | 327 | * |
337 | * @param message possibly a 'struct SessionConnectMessage' (check format) | 328 | * @param message possibly a 'struct SessionConnectMessage' (check format) |
338 | * @param peer identity of the peer to switch the address for | 329 | * @param address address of the other peer |
339 | * @param address address of the other peer, NULL if other peer | ||
340 | * connected to us | ||
341 | * @param session session to use (or NULL) | 330 | * @param session session to use (or NULL) |
342 | * @return #GNUNET_OK if the message was fine, #GNUNET_SYSERR on serious error | 331 | * @return #GNUNET_OK if the message was fine, #GNUNET_SYSERR on serious error |
343 | */ | 332 | */ |
344 | int | 333 | int |
345 | GST_neighbours_handle_session_ack (const struct GNUNET_MessageHeader *message, | 334 | GST_neighbours_handle_session_ack (const struct GNUNET_MessageHeader *message, |
346 | const struct GNUNET_PeerIdentity *peer, | ||
347 | const struct GNUNET_HELLO_Address *address, | 335 | const struct GNUNET_HELLO_Address *address, |
348 | struct Session *session); | 336 | struct Session *session); |
349 | 337 | ||
diff --git a/src/transport/gnunet-service-transport_plugins.c b/src/transport/gnunet-service-transport_plugins.c index 44e6a2a65..e8b795f9d 100644 --- a/src/transport/gnunet-service-transport_plugins.c +++ b/src/transport/gnunet-service-transport_plugins.c | |||
@@ -356,10 +356,7 @@ GST_plugins_a2s (const struct GNUNET_HELLO_Address *address) | |||
356 | static const char *s; | 356 | static const char *s; |
357 | 357 | ||
358 | if (NULL == address) | 358 | if (NULL == address) |
359 | { | 359 | return "<NULL>"; |
360 | GNUNET_break (0); /* a HELLO address cannot be NULL */ | ||
361 | return "<invalid>"; | ||
362 | } | ||
363 | if (0 == address->address_length) | 360 | if (0 == address->address_length) |
364 | return TRANSPORT_SESSION_INBOUND_STRING; /* Addresse with length 0 are inbound, address->address itself may be NULL */ | 361 | return TRANSPORT_SESSION_INBOUND_STRING; /* Addresse with length 0 are inbound, address->address itself may be NULL */ |
365 | api = GST_plugins_printer_find (address->transport_name); | 362 | api = GST_plugins_printer_find (address->transport_name); |
diff --git a/src/transport/gnunet-service-transport_validation.c b/src/transport/gnunet-service-transport_validation.c index 59b99b8fc..d0a731789 100644 --- a/src/transport/gnunet-service-transport_validation.c +++ b/src/transport/gnunet-service-transport_validation.c | |||
@@ -190,11 +190,6 @@ struct ValidationEntry | |||
190 | struct GST_BlacklistCheck *bc; | 190 | struct GST_BlacklistCheck *bc; |
191 | 191 | ||
192 | /** | 192 | /** |
193 | * Public key of the peer. | ||
194 | */ | ||
195 | struct GNUNET_CRYPTO_EddsaPublicKey public_key; | ||
196 | |||
197 | /** | ||
198 | * Cached PONG signature | 193 | * Cached PONG signature |
199 | */ | 194 | */ |
200 | struct GNUNET_CRYPTO_EddsaSignature pong_sig_cache; | 195 | struct GNUNET_CRYPTO_EddsaSignature pong_sig_cache; |
@@ -388,7 +383,7 @@ validation_entry_match (void *cls, | |||
388 | struct ValidationEntryMatchContext *vemc = cls; | 383 | struct ValidationEntryMatchContext *vemc = cls; |
389 | struct ValidationEntry *ve = value; | 384 | struct ValidationEntry *ve = value; |
390 | 385 | ||
391 | if (0 == GNUNET_HELLO_address_cmp (ve->address, | 386 | if (0 == GNUNET_HELLO_address_cmp (ve->address, |
392 | vemc->address)) | 387 | vemc->address)) |
393 | { | 388 | { |
394 | vemc->ve = ve; | 389 | vemc->ve = ve; |
@@ -447,7 +442,7 @@ cleanup_validation_entry (void *cls, | |||
447 | } | 442 | } |
448 | GNUNET_break (GNUNET_OK == | 443 | GNUNET_break (GNUNET_OK == |
449 | GNUNET_CONTAINER_multipeermap_remove (validation_map, | 444 | GNUNET_CONTAINER_multipeermap_remove (validation_map, |
450 | &ve->address->peer, | 445 | &ve->address->peer, |
451 | ve)); | 446 | ve)); |
452 | if (GNUNET_YES == ve->known_to_ats) | 447 | if (GNUNET_YES == ve->known_to_ats) |
453 | { | 448 | { |
@@ -585,10 +580,10 @@ transmit_ping_if_allowed (void *cls, | |||
585 | * [HELLO][TransportPingMessage][Transport name][Address] */ | 580 | * [HELLO][TransportPingMessage][Transport name][Address] */ |
586 | memcpy (message_buf, hello, hsize); | 581 | memcpy (message_buf, hello, hsize); |
587 | memcpy (&message_buf[hsize], | 582 | memcpy (&message_buf[hsize], |
588 | &ping, | 583 | &ping, |
589 | sizeof (struct TransportPingMessage)); | 584 | sizeof (struct TransportPingMessage)); |
590 | memcpy (&message_buf[sizeof (struct TransportPingMessage) + hsize], | 585 | memcpy (&message_buf[sizeof (struct TransportPingMessage) + hsize], |
591 | ve->address->transport_name, | 586 | ve->address->transport_name, |
592 | slen); | 587 | slen); |
593 | memcpy (&message_buf[sizeof (struct TransportPingMessage) + slen + hsize], | 588 | memcpy (&message_buf[sizeof (struct TransportPingMessage) + slen + hsize], |
594 | ve->address->address, | 589 | ve->address->address, |
@@ -624,7 +619,7 @@ transmit_ping_if_allowed (void *cls, | |||
624 | GST_plugins_a2s (ve->address)); | 619 | GST_plugins_a2s (ve->address)); |
625 | GNUNET_break(0); | 620 | GNUNET_break(0); |
626 | } | 621 | } |
627 | GST_neighbours_notify_data_sent (pid, ve->address, session, tsize); | 622 | GST_neighbours_notify_data_sent (ve->address, session, tsize); |
628 | } | 623 | } |
629 | else | 624 | else |
630 | { | 625 | { |
@@ -709,7 +704,7 @@ revalidate_address (void *cls, | |||
709 | ve->revalidation_task = | 704 | ve->revalidation_task = |
710 | GNUNET_SCHEDULER_add_delayed (delay, | 705 | GNUNET_SCHEDULER_add_delayed (delay, |
711 | &revalidate_address, ve); | 706 | &revalidate_address, ve); |
712 | ve->next_validation = GNUNET_TIME_relative_to_absolute (delay); | 707 | ve->next_validation = GNUNET_TIME_relative_to_absolute (delay); |
713 | return; | 708 | return; |
714 | } | 709 | } |
715 | /* check if globally we have too many active validations at a | 710 | /* check if globally we have too many active validations at a |
@@ -726,7 +721,7 @@ revalidate_address (void *cls, | |||
726 | GST_plugins_a2s (ve->address)); | 721 | GST_plugins_a2s (ve->address)); |
727 | ve->revalidation_task = | 722 | ve->revalidation_task = |
728 | GNUNET_SCHEDULER_add_delayed (blocked_for, &revalidate_address, ve); | 723 | GNUNET_SCHEDULER_add_delayed (blocked_for, &revalidate_address, ve); |
729 | ve->next_validation = GNUNET_TIME_relative_to_absolute (blocked_for); | 724 | ve->next_validation = GNUNET_TIME_relative_to_absolute (blocked_for); |
730 | return; | 725 | return; |
731 | } | 726 | } |
732 | 727 | ||
@@ -769,14 +764,12 @@ revalidate_address (void *cls, | |||
769 | * the given address and transport. If none exists, create one (but | 764 | * the given address and transport. If none exists, create one (but |
770 | * without starting any validation). | 765 | * without starting any validation). |
771 | * | 766 | * |
772 | * @param public_key public key of the peer, NULL for unknown | ||
773 | * @param address address to find | 767 | * @param address address to find |
774 | * @return validation entry matching the given specifications, NULL | 768 | * @return validation entry matching the given specifications, NULL |
775 | * if we don't have an existing entry and no public key was given | 769 | * if we don't have an existing entry and no public key was given |
776 | */ | 770 | */ |
777 | static struct ValidationEntry * | 771 | static struct ValidationEntry * |
778 | find_validation_entry (const struct GNUNET_CRYPTO_EddsaPublicKey *public_key, | 772 | find_validation_entry (const struct GNUNET_HELLO_Address *address) |
779 | const struct GNUNET_HELLO_Address *address) | ||
780 | { | 773 | { |
781 | struct ValidationEntryMatchContext vemc; | 774 | struct ValidationEntryMatchContext vemc; |
782 | struct ValidationEntry *ve; | 775 | struct ValidationEntry *ve; |
@@ -788,12 +781,9 @@ find_validation_entry (const struct GNUNET_CRYPTO_EddsaPublicKey *public_key, | |||
788 | &validation_entry_match, &vemc); | 781 | &validation_entry_match, &vemc); |
789 | if (NULL != (ve = vemc.ve)) | 782 | if (NULL != (ve = vemc.ve)) |
790 | return ve; | 783 | return ve; |
791 | if (NULL == public_key) | ||
792 | return NULL; | ||
793 | ve = GNUNET_new (struct ValidationEntry); | 784 | ve = GNUNET_new (struct ValidationEntry); |
794 | ve->in_use = GNUNET_SYSERR; /* not defined */ | 785 | ve->in_use = GNUNET_SYSERR; /* not defined */ |
795 | ve->address = GNUNET_HELLO_address_copy (address); | 786 | ve->address = GNUNET_HELLO_address_copy (address); |
796 | ve->public_key = *public_key; | ||
797 | ve->pong_sig_valid_until = GNUNET_TIME_absolute_get_zero_(); | 787 | ve->pong_sig_valid_until = GNUNET_TIME_absolute_get_zero_(); |
798 | memset (&ve->pong_sig_cache, '\0', sizeof (struct GNUNET_CRYPTO_EddsaSignature)); | 788 | memset (&ve->pong_sig_cache, '\0', sizeof (struct GNUNET_CRYPTO_EddsaSignature)); |
799 | ve->latency = GNUNET_TIME_UNIT_FOREVER_REL; | 789 | ve->latency = GNUNET_TIME_UNIT_FOREVER_REL; |
@@ -828,12 +818,10 @@ add_valid_address (void *cls, | |||
828 | struct ValidationEntry *ve; | 818 | struct ValidationEntry *ve; |
829 | struct GNUNET_PeerIdentity pid; | 819 | struct GNUNET_PeerIdentity pid; |
830 | struct GNUNET_ATS_Information ats; | 820 | struct GNUNET_ATS_Information ats; |
831 | struct GNUNET_CRYPTO_EddsaPublicKey public_key; | ||
832 | 821 | ||
833 | if (0 == GNUNET_TIME_absolute_get_remaining (expiration).rel_value_us) | 822 | if (0 == GNUNET_TIME_absolute_get_remaining (expiration).rel_value_us) |
834 | return GNUNET_OK; /* expired */ | 823 | return GNUNET_OK; /* expired */ |
835 | if ((GNUNET_OK != GNUNET_HELLO_get_id (hello, &pid)) || | 824 | if (GNUNET_OK != GNUNET_HELLO_get_id (hello, &pid)) |
836 | (GNUNET_OK != GNUNET_HELLO_get_key (hello, &public_key))) | ||
837 | { | 825 | { |
838 | GNUNET_break (0); | 826 | GNUNET_break (0); |
839 | return GNUNET_OK; /* invalid HELLO !? */ | 827 | return GNUNET_OK; /* invalid HELLO !? */ |
@@ -852,7 +840,7 @@ add_valid_address (void *cls, | |||
852 | return GNUNET_OK; | 840 | return GNUNET_OK; |
853 | } | 841 | } |
854 | 842 | ||
855 | ve = find_validation_entry (&public_key, address); | 843 | ve = find_validation_entry (address); |
856 | ve->valid_until = GNUNET_TIME_absolute_max (ve->valid_until, | 844 | ve->valid_until = GNUNET_TIME_absolute_max (ve->valid_until, |
857 | expiration); | 845 | expiration); |
858 | if (NULL == ve->revalidation_task) | 846 | if (NULL == ve->revalidation_task) |
@@ -967,7 +955,6 @@ GST_validation_stop () | |||
967 | * Send the given PONG to the given address. | 955 | * Send the given PONG to the given address. |
968 | * | 956 | * |
969 | * @param cls the PONG message | 957 | * @param cls the PONG message |
970 | * @param public_key public key for the peer, never NULL | ||
971 | * @param valid_until is ZERO if we never validated the address, | 958 | * @param valid_until is ZERO if we never validated the address, |
972 | * otherwise a time up to when we consider it (or was) valid | 959 | * otherwise a time up to when we consider it (or was) valid |
973 | * @param validation_block is FOREVER if the address is for an unsupported plugin (from PEERINFO) | 960 | * @param validation_block is FOREVER if the address is for an unsupported plugin (from PEERINFO) |
@@ -977,7 +964,6 @@ GST_validation_stop () | |||
977 | */ | 964 | */ |
978 | static void | 965 | static void |
979 | multicast_pong (void *cls, | 966 | multicast_pong (void *cls, |
980 | const struct GNUNET_CRYPTO_EddsaPublicKey *public_key, | ||
981 | struct GNUNET_TIME_Absolute valid_until, | 967 | struct GNUNET_TIME_Absolute valid_until, |
982 | struct GNUNET_TIME_Absolute validation_block, | 968 | struct GNUNET_TIME_Absolute validation_block, |
983 | const struct GNUNET_HELLO_Address *address) | 969 | const struct GNUNET_HELLO_Address *address) |
@@ -1005,8 +991,7 @@ multicast_pong (void *cls, | |||
1005 | PONG_PRIORITY, | 991 | PONG_PRIORITY, |
1006 | ACCEPTABLE_PING_DELAY, | 992 | ACCEPTABLE_PING_DELAY, |
1007 | NULL, NULL); | 993 | NULL, NULL); |
1008 | GST_neighbours_notify_data_sent (&address->peer, | 994 | GST_neighbours_notify_data_sent (address, |
1009 | address, | ||
1010 | session, | 995 | session, |
1011 | pong->header.size); | 996 | pong->header.size); |
1012 | 997 | ||
@@ -1234,12 +1219,13 @@ GST_validation_handle_ping (const struct GNUNET_PeerIdentity *sender, | |||
1234 | else | 1219 | else |
1235 | { | 1220 | { |
1236 | ret = papi->send (papi->cls, session, | 1221 | ret = papi->send (papi->cls, session, |
1237 | (const char *) pong, ntohs (pong->header.size), | 1222 | (const char *) pong, |
1223 | ntohs (pong->header.size), | ||
1238 | PONG_PRIORITY, ACCEPTABLE_PING_DELAY, | 1224 | PONG_PRIORITY, ACCEPTABLE_PING_DELAY, |
1239 | NULL, NULL); | 1225 | NULL, NULL); |
1240 | if (-1 != ret) | 1226 | if (-1 != ret) |
1241 | GST_neighbours_notify_data_sent (sender, | 1227 | GST_neighbours_notify_data_sent (sender_address, |
1242 | sender_address, session, | 1228 | session, |
1243 | pong->header.size); | 1229 | pong->header.size); |
1244 | } | 1230 | } |
1245 | } | 1231 | } |
@@ -1270,28 +1256,10 @@ GST_validation_handle_ping (const struct GNUNET_PeerIdentity *sender, | |||
1270 | 1256 | ||
1271 | 1257 | ||
1272 | /** | 1258 | /** |
1273 | * Context for the #validate_address_iterator() function | ||
1274 | */ | ||
1275 | struct ValidateAddressContext | ||
1276 | { | ||
1277 | /** | ||
1278 | * Hash of the public key of the peer whose address is being validated. | ||
1279 | */ | ||
1280 | struct GNUNET_PeerIdentity pid; | ||
1281 | |||
1282 | /** | ||
1283 | * Public key of the peer whose address is being validated. | ||
1284 | */ | ||
1285 | struct GNUNET_CRYPTO_EddsaPublicKey public_key; | ||
1286 | |||
1287 | }; | ||
1288 | |||
1289 | |||
1290 | /** | ||
1291 | * Iterator callback to go over all addresses and try to validate them | 1259 | * Iterator callback to go over all addresses and try to validate them |
1292 | * (unless blocked or already validated). | 1260 | * (unless blocked or already validated). |
1293 | * | 1261 | * |
1294 | * @param cls pointer to a `struct ValidateAddressContext *` | 1262 | * @param cls NULL |
1295 | * @param address the address | 1263 | * @param address the address |
1296 | * @param expiration expiration time | 1264 | * @param expiration expiration time |
1297 | * @return #GNUNET_OK (keep the address) | 1265 | * @return #GNUNET_OK (keep the address) |
@@ -1301,10 +1269,8 @@ validate_address_iterator (void *cls, | |||
1301 | const struct GNUNET_HELLO_Address *address, | 1269 | const struct GNUNET_HELLO_Address *address, |
1302 | struct GNUNET_TIME_Absolute expiration) | 1270 | struct GNUNET_TIME_Absolute expiration) |
1303 | { | 1271 | { |
1304 | const struct ValidateAddressContext *vac = cls; | ||
1305 | struct GNUNET_TRANSPORT_PluginFunctions * papi; | 1272 | struct GNUNET_TRANSPORT_PluginFunctions * papi; |
1306 | struct ValidationEntry *ve; | 1273 | struct ValidationEntry *ve; |
1307 | struct GNUNET_TIME_Relative canonical_delay; | ||
1308 | 1274 | ||
1309 | if (0 == GNUNET_TIME_absolute_get_remaining (expiration).rel_value_us) | 1275 | if (0 == GNUNET_TIME_absolute_get_remaining (expiration).rel_value_us) |
1310 | { | 1276 | { |
@@ -1312,34 +1278,13 @@ validate_address_iterator (void *cls, | |||
1312 | "Skipping expired address from HELLO\n"); | 1278 | "Skipping expired address from HELLO\n"); |
1313 | return GNUNET_OK; /* expired */ | 1279 | return GNUNET_OK; /* expired */ |
1314 | } | 1280 | } |
1315 | ve = find_validation_entry (&vac->public_key, address); | 1281 | papi = GST_plugins_find (address->transport_name); |
1316 | 1282 | if (NULL == papi) | |
1317 | papi = GST_plugins_find (ve->address->transport_name); | ||
1318 | if (papi == NULL) | ||
1319 | { | 1283 | { |
1320 | /* This plugin is currently unvailable ... retry later */ | 1284 | /* This plugin is currently unvailable ... ignore */ |
1321 | if (NULL == ve->revalidation_task) | ||
1322 | { | ||
1323 | if (GNUNET_YES == ve->in_use) | ||
1324 | canonical_delay = CONNECTED_PING_FREQUENCY; | ||
1325 | else if (GNUNET_TIME_absolute_get_remaining (ve->valid_until).rel_value_us > 0) | ||
1326 | canonical_delay = VALIDATED_PING_FREQUENCY; | ||
1327 | else | ||
1328 | canonical_delay = UNVALIDATED_PING_KEEPALIVE; | ||
1329 | |||
1330 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
1331 | "Plugin `%s' unavailable, validation process for peer `%s' delayed for %llu ms\n", | ||
1332 | ve->address->transport_name, | ||
1333 | GNUNET_i2s (&ve->address->peer), | ||
1334 | (long long unsigned) canonical_delay.rel_value_us / 1000); | ||
1335 | |||
1336 | ve->revalidation_task = GNUNET_SCHEDULER_add_delayed (canonical_delay, | ||
1337 | &revalidate_address, ve); | ||
1338 | } | ||
1339 | return GNUNET_OK; | 1285 | return GNUNET_OK; |
1340 | } | 1286 | } |
1341 | 1287 | ve = find_validation_entry (address); | |
1342 | |||
1343 | if (NULL == ve->revalidation_task) | 1288 | if (NULL == ve->revalidation_task) |
1344 | { | 1289 | { |
1345 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 1290 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
@@ -1427,7 +1372,7 @@ GST_validation_handle_pong (const struct GNUNET_PeerIdentity *sender, | |||
1427 | address.address_length = addrlen; | 1372 | address.address_length = addrlen; |
1428 | address.transport_name = tname; | 1373 | address.transport_name = tname; |
1429 | address.local_info = GNUNET_HELLO_ADDRESS_INFO_NONE; | 1374 | address.local_info = GNUNET_HELLO_ADDRESS_INFO_NONE; |
1430 | ve = find_validation_entry (NULL, &address); | 1375 | ve = find_validation_entry (&address); |
1431 | if ((NULL == ve) || (GNUNET_NO == ve->expecting_pong)) | 1376 | if ((NULL == ve) || (GNUNET_NO == ve->expecting_pong)) |
1432 | { | 1377 | { |
1433 | GNUNET_STATISTICS_update (GST_stats, | 1378 | GNUNET_STATISTICS_update (GST_stats, |
@@ -1437,8 +1382,8 @@ GST_validation_handle_pong (const struct GNUNET_PeerIdentity *sender, | |||
1437 | return GNUNET_OK; | 1382 | return GNUNET_OK; |
1438 | } | 1383 | } |
1439 | /* now check that PONG is well-formed */ | 1384 | /* now check that PONG is well-formed */ |
1440 | if (0 != memcmp (&ve->address->peer, | 1385 | if (0 != memcmp (&ve->address->peer, |
1441 | sender, | 1386 | sender, |
1442 | sizeof (struct GNUNET_PeerIdentity))) | 1387 | sizeof (struct GNUNET_PeerIdentity))) |
1443 | { | 1388 | { |
1444 | GNUNET_break_op (0); | 1389 | GNUNET_break_op (0); |
@@ -1479,7 +1424,7 @@ GST_validation_handle_pong (const struct GNUNET_PeerIdentity *sender, | |||
1479 | /* Do expensive verification */ | 1424 | /* Do expensive verification */ |
1480 | sig_res = GNUNET_CRYPTO_eddsa_verify (GNUNET_SIGNATURE_PURPOSE_TRANSPORT_PONG_OWN, | 1425 | sig_res = GNUNET_CRYPTO_eddsa_verify (GNUNET_SIGNATURE_PURPOSE_TRANSPORT_PONG_OWN, |
1481 | &pong->purpose, &pong->signature, | 1426 | &pong->purpose, &pong->signature, |
1482 | &ve->public_key); | 1427 | &ve->address->peer.public_key); |
1483 | if (sig_res == GNUNET_SYSERR) | 1428 | if (sig_res == GNUNET_SYSERR) |
1484 | { | 1429 | { |
1485 | GNUNET_break_op (0); | 1430 | GNUNET_break_op (0); |
@@ -1549,7 +1494,7 @@ GST_validation_handle_pong (const struct GNUNET_PeerIdentity *sender, | |||
1549 | 1494 | ||
1550 | /* build HELLO to store in PEERINFO */ | 1495 | /* build HELLO to store in PEERINFO */ |
1551 | ve->copied = GNUNET_NO; | 1496 | ve->copied = GNUNET_NO; |
1552 | hello = GNUNET_HELLO_create (&ve->public_key, | 1497 | hello = GNUNET_HELLO_create (&ve->address->peer.public_key, |
1553 | &add_valid_peer_address, ve, | 1498 | &add_valid_peer_address, ve, |
1554 | GNUNET_NO); | 1499 | GNUNET_NO); |
1555 | GNUNET_PEERINFO_add_peer (GST_peerinfo, hello, NULL, NULL); | 1500 | GNUNET_PEERINFO_add_peer (GST_peerinfo, hello, NULL, NULL); |
@@ -1570,41 +1515,43 @@ GST_validation_handle_hello (const struct GNUNET_MessageHeader *hello) | |||
1570 | { | 1515 | { |
1571 | const struct GNUNET_HELLO_Message *hm = | 1516 | const struct GNUNET_HELLO_Message *hm = |
1572 | (const struct GNUNET_HELLO_Message *) hello; | 1517 | (const struct GNUNET_HELLO_Message *) hello; |
1573 | struct ValidateAddressContext vac; | 1518 | struct GNUNET_PeerIdentity pid; |
1574 | struct GNUNET_HELLO_Message *h; | 1519 | struct GNUNET_HELLO_Message *h; |
1575 | int friend; | 1520 | int friend; |
1576 | 1521 | ||
1577 | friend = GNUNET_HELLO_is_friend_only (hm); | 1522 | friend = GNUNET_HELLO_is_friend_only (hm); |
1578 | if ( ( (GNUNET_YES != friend) && | 1523 | if ( ( (GNUNET_YES != friend) && |
1579 | (GNUNET_NO != friend) ) || | 1524 | (GNUNET_NO != friend) ) || |
1580 | (GNUNET_OK != GNUNET_HELLO_get_id (hm, &vac.pid)) || | 1525 | (GNUNET_OK != GNUNET_HELLO_get_id (hm, &pid)) ) |
1581 | (GNUNET_OK != GNUNET_HELLO_get_key (hm, &vac.public_key))) | ||
1582 | { | 1526 | { |
1583 | /* malformed HELLO */ | 1527 | /* malformed HELLO */ |
1584 | GNUNET_break_op (0); | 1528 | GNUNET_break_op (0); |
1585 | return GNUNET_SYSERR; | 1529 | return GNUNET_SYSERR; |
1586 | } | 1530 | } |
1587 | if (0 == | 1531 | if (0 == |
1588 | memcmp (&GST_my_identity, &vac.pid, sizeof (struct GNUNET_PeerIdentity))) | 1532 | memcmp (&GST_my_identity, |
1533 | &pid, | ||
1534 | sizeof (struct GNUNET_PeerIdentity))) | ||
1589 | return GNUNET_OK; | 1535 | return GNUNET_OK; |
1590 | /* Add peer identity without addresses to peerinfo service */ | 1536 | /* Add peer identity without addresses to peerinfo service */ |
1591 | h = GNUNET_HELLO_create (&vac.public_key, NULL, NULL, friend); | 1537 | h = GNUNET_HELLO_create (&pid.public_key, NULL, NULL, friend); |
1592 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 1538 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
1593 | _("Validation received new %s message for peer `%s' with size %u\n"), | 1539 | _("Validation received new %s message for peer `%s' with size %u\n"), |
1594 | "HELLO", | 1540 | "HELLO", |
1595 | GNUNET_i2s (&vac.pid), | 1541 | GNUNET_i2s (&pid), |
1596 | ntohs (hello->size)); | 1542 | ntohs (hello->size)); |
1597 | GNUNET_PEERINFO_add_peer (GST_peerinfo, h, NULL, NULL); | 1543 | GNUNET_PEERINFO_add_peer (GST_peerinfo, h, NULL, NULL); |
1598 | 1544 | ||
1599 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1545 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1600 | _("Adding `%s' without addresses for peer `%s'\n"), "HELLO", | 1546 | _("Adding `%s' without addresses for peer `%s'\n"), "HELLO", |
1601 | GNUNET_i2s (&vac.pid)); | 1547 | GNUNET_i2s (&pid)); |
1602 | 1548 | ||
1603 | GNUNET_free (h); | 1549 | GNUNET_free (h); |
1604 | GNUNET_assert (NULL == | 1550 | GNUNET_assert (NULL == |
1605 | GNUNET_HELLO_iterate_addresses (hm, GNUNET_NO, | 1551 | GNUNET_HELLO_iterate_addresses (hm, |
1552 | GNUNET_NO, | ||
1606 | &validate_address_iterator, | 1553 | &validate_address_iterator, |
1607 | &vac)); | 1554 | NULL)); |
1608 | return GNUNET_OK; | 1555 | return GNUNET_OK; |
1609 | } | 1556 | } |
1610 | 1557 | ||
@@ -1644,7 +1591,6 @@ iterate_addresses (void *cls, | |||
1644 | struct ValidationEntry *ve = value; | 1591 | struct ValidationEntry *ve = value; |
1645 | 1592 | ||
1646 | ic->cb (ic->cb_cls, | 1593 | ic->cb (ic->cb_cls, |
1647 | &ve->public_key, | ||
1648 | ve->valid_until, | 1594 | ve->valid_until, |
1649 | ve->revalidation_block, | 1595 | ve->revalidation_block, |
1650 | ve->address); | 1596 | ve->address); |
@@ -1662,7 +1608,8 @@ iterate_addresses (void *cls, | |||
1662 | */ | 1608 | */ |
1663 | void | 1609 | void |
1664 | GST_validation_get_addresses (const struct GNUNET_PeerIdentity *target, | 1610 | GST_validation_get_addresses (const struct GNUNET_PeerIdentity *target, |
1665 | GST_ValidationAddressCallback cb, void *cb_cls) | 1611 | GST_ValidationAddressCallback cb, |
1612 | void *cb_cls) | ||
1666 | { | 1613 | { |
1667 | struct IteratorContext ic; | 1614 | struct IteratorContext ic; |
1668 | 1615 | ||
@@ -1691,8 +1638,11 @@ GST_validation_set_address_use (const struct GNUNET_HELLO_Address *address, | |||
1691 | { | 1638 | { |
1692 | struct ValidationEntry *ve; | 1639 | struct ValidationEntry *ve; |
1693 | 1640 | ||
1641 | if (GNUNET_HELLO_address_check_option (address, | ||
1642 | GNUNET_HELLO_ADDRESS_INFO_INBOUND)) | ||
1643 | return; /* ignore inbound for validation */ | ||
1694 | if (NULL != address) | 1644 | if (NULL != address) |
1695 | ve = find_validation_entry (NULL, address); | 1645 | ve = find_validation_entry (address); |
1696 | else | 1646 | else |
1697 | ve = NULL; /* FIXME: lookup based on session... */ | 1647 | ve = NULL; /* FIXME: lookup based on session... */ |
1698 | if (NULL == ve) | 1648 | if (NULL == ve) |
@@ -1721,7 +1671,8 @@ GST_validation_set_address_use (const struct GNUNET_HELLO_Address *address, | |||
1721 | if (in_use == GNUNET_YES) | 1671 | if (in_use == GNUNET_YES) |
1722 | { | 1672 | { |
1723 | /* from now on, higher frequeny, so reschedule now */ | 1673 | /* from now on, higher frequeny, so reschedule now */ |
1724 | GNUNET_SCHEDULER_cancel (ve->revalidation_task); | 1674 | if (NULL != ve->revalidation_task) |
1675 | GNUNET_SCHEDULER_cancel (ve->revalidation_task); | ||
1725 | ve->revalidation_task = GNUNET_SCHEDULER_add_now (&revalidate_address, ve); | 1676 | ve->revalidation_task = GNUNET_SCHEDULER_add_now (&revalidate_address, ve); |
1726 | } | 1677 | } |
1727 | } | 1678 | } |
@@ -1731,15 +1682,13 @@ GST_validation_set_address_use (const struct GNUNET_HELLO_Address *address, | |||
1731 | * Query validation about the latest observed latency on a given | 1682 | * Query validation about the latest observed latency on a given |
1732 | * address. | 1683 | * address. |
1733 | * | 1684 | * |
1734 | * @param sender peer | ||
1735 | * @param address the address | 1685 | * @param address the address |
1736 | * @param session session | 1686 | * @param session session |
1737 | * @return observed latency of the address, FOREVER if the address was | 1687 | * @return observed latency of the address, FOREVER if the address was |
1738 | * never successfully validated | 1688 | * never successfully validated |
1739 | */ | 1689 | */ |
1740 | struct GNUNET_TIME_Relative | 1690 | struct GNUNET_TIME_Relative |
1741 | GST_validation_get_address_latency (const struct GNUNET_PeerIdentity *sender, | 1691 | GST_validation_get_address_latency (const struct GNUNET_HELLO_Address *address, |
1742 | const struct GNUNET_HELLO_Address *address, | ||
1743 | struct Session *session) | 1692 | struct Session *session) |
1744 | { | 1693 | { |
1745 | struct ValidationEntry *ve; | 1694 | struct ValidationEntry *ve; |
@@ -1749,7 +1698,7 @@ GST_validation_get_address_latency (const struct GNUNET_PeerIdentity *sender, | |||
1749 | GNUNET_break (0); // FIXME: support having latency only with session... | 1698 | GNUNET_break (0); // FIXME: support having latency only with session... |
1750 | return GNUNET_TIME_UNIT_FOREVER_REL; | 1699 | return GNUNET_TIME_UNIT_FOREVER_REL; |
1751 | } | 1700 | } |
1752 | ve = find_validation_entry (NULL, address); | 1701 | ve = find_validation_entry (address); |
1753 | if (NULL == ve) | 1702 | if (NULL == ve) |
1754 | return GNUNET_TIME_UNIT_FOREVER_REL; | 1703 | return GNUNET_TIME_UNIT_FOREVER_REL; |
1755 | return ve->latency; | 1704 | return ve->latency; |
@@ -1790,13 +1739,12 @@ validation_entries_iterate (void *cls, | |||
1790 | struct ValidationIteratorContext *ic = cls; | 1739 | struct ValidationIteratorContext *ic = cls; |
1791 | struct ValidationEntry *ve = value; | 1740 | struct ValidationEntry *ve = value; |
1792 | 1741 | ||
1793 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1742 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1794 | "Notifying about validation entry for peer `%s' address `%s' \n", | 1743 | "Notifying about validation entry for peer `%s' address `%s' \n", |
1795 | GNUNET_i2s (&ve->address->peer), | 1744 | GNUNET_i2s (&ve->address->peer), |
1796 | GST_plugins_a2s (ve->address)); | 1745 | GST_plugins_a2s (ve->address)); |
1797 | ic->cb (ic->cb_cls, | 1746 | ic->cb (ic->cb_cls, |
1798 | &ve->address->peer, | 1747 | ve->address, |
1799 | ve->address, | ||
1800 | ve->send_time, | 1748 | ve->send_time, |
1801 | ve->valid_until, | 1749 | ve->valid_until, |
1802 | ve->next_validation, | 1750 | ve->next_validation, |
diff --git a/src/transport/gnunet-service-transport_validation.h b/src/transport/gnunet-service-transport_validation.h index df2ef0ee8..ce5c427a1 100644 --- a/src/transport/gnunet-service-transport_validation.h +++ b/src/transport/gnunet-service-transport_validation.h | |||
@@ -67,15 +67,13 @@ GST_validation_set_address_use (const struct GNUNET_HELLO_Address *address, | |||
67 | * Query validation about the latest observed latency on a given | 67 | * Query validation about the latest observed latency on a given |
68 | * address. | 68 | * address. |
69 | * | 69 | * |
70 | * @param sender peer | ||
71 | * @param address the address | 70 | * @param address the address |
72 | * @param session session | 71 | * @param session session |
73 | * @return observed latency of the address, FOREVER if the address was | 72 | * @return observed latency of the address, FOREVER if the address was |
74 | * never successfully validated | 73 | * never successfully validated |
75 | */ | 74 | */ |
76 | struct GNUNET_TIME_Relative | 75 | struct GNUNET_TIME_Relative |
77 | GST_validation_get_address_latency (const struct GNUNET_PeerIdentity *sender, | 76 | GST_validation_get_address_latency (const struct GNUNET_HELLO_Address *address, |
78 | const struct GNUNET_HELLO_Address *address, | ||
79 | struct Session *session); | 77 | struct Session *session); |
80 | 78 | ||
81 | 79 | ||
@@ -84,7 +82,6 @@ GST_validation_get_address_latency (const struct GNUNET_PeerIdentity *sender, | |||
84 | * active address. | 82 | * active address. |
85 | * | 83 | * |
86 | * @param cls closure | 84 | * @param cls closure |
87 | * @param peer peer this update is about (never NULL) | ||
88 | * @param address address (never NULL) | 85 | * @param address address (never NULL) |
89 | * @param last_validation point in time when last validation was performed | 86 | * @param last_validation point in time when last validation was performed |
90 | * @param valid_until point in time how long address is valid | 87 | * @param valid_until point in time how long address is valid |
@@ -93,7 +90,6 @@ GST_validation_get_address_latency (const struct GNUNET_PeerIdentity *sender, | |||
93 | */ | 90 | */ |
94 | typedef void | 91 | typedef void |
95 | (*GST_ValidationChangedCallback) (void *cls, | 92 | (*GST_ValidationChangedCallback) (void *cls, |
96 | const struct GNUNET_PeerIdentity *peer, | ||
97 | const struct GNUNET_HELLO_Address *address, | 93 | const struct GNUNET_HELLO_Address *address, |
98 | struct GNUNET_TIME_Absolute last_validation, | 94 | struct GNUNET_TIME_Absolute last_validation, |
99 | struct GNUNET_TIME_Absolute valid_until, | 95 | struct GNUNET_TIME_Absolute valid_until, |
@@ -166,7 +162,6 @@ GST_validation_handle_hello (const struct GNUNET_MessageHeader *hello); | |||
166 | */ | 162 | */ |
167 | typedef void | 163 | typedef void |
168 | (*GST_ValidationAddressCallback) (void *cls, | 164 | (*GST_ValidationAddressCallback) (void *cls, |
169 | const struct GNUNET_CRYPTO_EddsaPublicKey *public_key, | ||
170 | struct GNUNET_TIME_Absolute valid_until, | 165 | struct GNUNET_TIME_Absolute valid_until, |
171 | struct GNUNET_TIME_Absolute validation_block, | 166 | struct GNUNET_TIME_Absolute validation_block, |
172 | const struct GNUNET_HELLO_Address *address); | 167 | const struct GNUNET_HELLO_Address *address); |
diff --git a/src/transport/gnunet-transport.c b/src/transport/gnunet-transport.c index f20e11852..f90ce9005 100644 --- a/src/transport/gnunet-transport.c +++ b/src/transport/gnunet-transport.c | |||
@@ -67,11 +67,6 @@ struct ValidationResolutionContext | |||
67 | struct ValidationResolutionContext *prev; | 67 | struct ValidationResolutionContext *prev; |
68 | 68 | ||
69 | /** | 69 | /** |
70 | * Peer identity | ||
71 | */ | ||
72 | struct GNUNET_PeerIdentity id; | ||
73 | |||
74 | /** | ||
75 | * Address to resolve | 70 | * Address to resolve |
76 | */ | 71 | */ |
77 | struct GNUNET_HELLO_Address *addrcp; | 72 | struct GNUNET_HELLO_Address *addrcp; |
@@ -745,7 +740,6 @@ result_callback (void *cls, | |||
745 | /** | 740 | /** |
746 | * Resolve address we got a validation state for to a string. | 741 | * Resolve address we got a validation state for to a string. |
747 | * | 742 | * |
748 | * @param id peer identity the address is for | ||
749 | * @param address the address itself | 743 | * @param address the address itself |
750 | * @param numeric #GNUNET_YES to disable DNS, #GNUNET_NO to try reverse lookup | 744 | * @param numeric #GNUNET_YES to disable DNS, #GNUNET_NO to try reverse lookup |
751 | * @param last_validation when was the address validated last | 745 | * @param last_validation when was the address validated last |
@@ -754,8 +748,7 @@ result_callback (void *cls, | |||
754 | * @param state where are we in the validation state machine | 748 | * @param state where are we in the validation state machine |
755 | */ | 749 | */ |
756 | static void | 750 | static void |
757 | resolve_validation_address (const struct GNUNET_PeerIdentity *id, | 751 | resolve_validation_address (const struct GNUNET_HELLO_Address *address, |
758 | const struct GNUNET_HELLO_Address *address, | ||
759 | int numeric, | 752 | int numeric, |
760 | struct GNUNET_TIME_Absolute last_validation, | 753 | struct GNUNET_TIME_Absolute last_validation, |
761 | struct GNUNET_TIME_Absolute valid_until, | 754 | struct GNUNET_TIME_Absolute valid_until, |
@@ -795,7 +788,7 @@ process_validation_string (void *cls, | |||
795 | { | 788 | { |
796 | FPRINTF (stderr, | 789 | FPRINTF (stderr, |
797 | "Failed to convert address for peer `%s' plugin `%s' length %u to string \n", | 790 | "Failed to convert address for peer `%s' plugin `%s' length %u to string \n", |
798 | GNUNET_i2s (&vc->id), | 791 | GNUNET_i2s (&vc->addrcp->peer), |
799 | vc->addrcp->transport_name, | 792 | vc->addrcp->transport_name, |
800 | (unsigned int) vc->addrcp->address_length); | 793 | (unsigned int) vc->addrcp->address_length); |
801 | } | 794 | } |
@@ -816,7 +809,7 @@ process_validation_string (void *cls, | |||
816 | 809 | ||
817 | FPRINTF (stdout, | 810 | FPRINTF (stdout, |
818 | _("Peer `%s' %s %s\n\t%s%s\n\t%s%s\n\t%s%s\n"), | 811 | _("Peer `%s' %s %s\n\t%s%s\n\t%s%s\n\t%s%s\n"), |
819 | GNUNET_i2s (&vc->id), | 812 | GNUNET_i2s (&vc->addrcp->peer), |
820 | (GNUNET_OK == res) ? address : "<invalid address>", | 813 | (GNUNET_OK == res) ? address : "<invalid address>", |
821 | (monitor_validation) ? GNUNET_TRANSPORT_vs2s (vc->state) : "", | 814 | (monitor_validation) ? GNUNET_TRANSPORT_vs2s (vc->state) : "", |
822 | "Valid until : ", s_valid, | 815 | "Valid until : ", s_valid, |
@@ -840,8 +833,7 @@ process_validation_string (void *cls, | |||
840 | (note: this should be unnecessary, as | 833 | (note: this should be unnecessary, as |
841 | transport should fallback to numeric lookup | 834 | transport should fallback to numeric lookup |
842 | internally if DNS takes too long anyway) */ | 835 | internally if DNS takes too long anyway) */ |
843 | resolve_validation_address (&vc->id, | 836 | resolve_validation_address (vc->addrcp, |
844 | vc->addrcp, | ||
845 | GNUNET_NO, | 837 | GNUNET_NO, |
846 | vc->last_validation, | 838 | vc->last_validation, |
847 | vc->valid_until, | 839 | vc->valid_until, |
@@ -852,7 +844,7 @@ process_validation_string (void *cls, | |||
852 | { | 844 | { |
853 | FPRINTF (stdout, | 845 | FPRINTF (stdout, |
854 | _("Peer `%s' %s `%s' \n"), | 846 | _("Peer `%s' %s `%s' \n"), |
855 | GNUNET_i2s (&vc->id), | 847 | GNUNET_i2s (&vc->addrcp->peer), |
856 | "<unable to resolve address>", | 848 | "<unable to resolve address>", |
857 | GNUNET_TRANSPORT_vs2s (vc->state)); | 849 | GNUNET_TRANSPORT_vs2s (vc->state)); |
858 | } | 850 | } |
@@ -882,7 +874,6 @@ process_validation_string (void *cls, | |||
882 | /** | 874 | /** |
883 | * Resolve address we got a validation state for to a string. | 875 | * Resolve address we got a validation state for to a string. |
884 | * | 876 | * |
885 | * @param id peer identity the address is for | ||
886 | * @param address the address itself | 877 | * @param address the address itself |
887 | * @param numeric #GNUNET_YES to disable DNS, #GNUNET_NO to try reverse lookup | 878 | * @param numeric #GNUNET_YES to disable DNS, #GNUNET_NO to try reverse lookup |
888 | * @param last_validation when was the address validated last | 879 | * @param last_validation when was the address validated last |
@@ -891,8 +882,7 @@ process_validation_string (void *cls, | |||
891 | * @param state where are we in the validation state machine | 882 | * @param state where are we in the validation state machine |
892 | */ | 883 | */ |
893 | static void | 884 | static void |
894 | resolve_validation_address (const struct GNUNET_PeerIdentity *id, | 885 | resolve_validation_address (const struct GNUNET_HELLO_Address *address, |
895 | const struct GNUNET_HELLO_Address *address, | ||
896 | int numeric, | 886 | int numeric, |
897 | struct GNUNET_TIME_Absolute last_validation, | 887 | struct GNUNET_TIME_Absolute last_validation, |
898 | struct GNUNET_TIME_Absolute valid_until, | 888 | struct GNUNET_TIME_Absolute valid_until, |
@@ -906,7 +896,6 @@ resolve_validation_address (const struct GNUNET_PeerIdentity *id, | |||
906 | GNUNET_CONTAINER_DLL_insert(vc_head, vc_tail, vc); | 896 | GNUNET_CONTAINER_DLL_insert(vc_head, vc_tail, vc); |
907 | address_resolutions++; | 897 | address_resolutions++; |
908 | 898 | ||
909 | vc->id = (*id); | ||
910 | vc->transport = GNUNET_strdup(address->transport_name); | 899 | vc->transport = GNUNET_strdup(address->transport_name); |
911 | vc->addrcp = GNUNET_HELLO_address_copy (address); | 900 | vc->addrcp = GNUNET_HELLO_address_copy (address); |
912 | vc->printed = GNUNET_NO; | 901 | vc->printed = GNUNET_NO; |
@@ -928,7 +917,6 @@ resolve_validation_address (const struct GNUNET_PeerIdentity *id, | |||
928 | * Resolve address we got a validation state for to a string. | 917 | * Resolve address we got a validation state for to a string. |
929 | * | 918 | * |
930 | * @param cls NULL | 919 | * @param cls NULL |
931 | * @param peer peer identity the address is for | ||
932 | * @param address the address itself | 920 | * @param address the address itself |
933 | * @param last_validation when was the address validated last | 921 | * @param last_validation when was the address validated last |
934 | * @param valid_until until when is the address valid | 922 | * @param valid_until until when is the address valid |
@@ -937,14 +925,13 @@ resolve_validation_address (const struct GNUNET_PeerIdentity *id, | |||
937 | */ | 925 | */ |
938 | static void | 926 | static void |
939 | process_validation_cb (void *cls, | 927 | process_validation_cb (void *cls, |
940 | const struct GNUNET_PeerIdentity *peer, | ||
941 | const struct GNUNET_HELLO_Address *address, | 928 | const struct GNUNET_HELLO_Address *address, |
942 | struct GNUNET_TIME_Absolute last_validation, | 929 | struct GNUNET_TIME_Absolute last_validation, |
943 | struct GNUNET_TIME_Absolute valid_until, | 930 | struct GNUNET_TIME_Absolute valid_until, |
944 | struct GNUNET_TIME_Absolute next_validation, | 931 | struct GNUNET_TIME_Absolute next_validation, |
945 | enum GNUNET_TRANSPORT_ValidationState state) | 932 | enum GNUNET_TRANSPORT_ValidationState state) |
946 | { | 933 | { |
947 | if ((NULL == peer) && (NULL == address)) | 934 | if (NULL == address) |
948 | { | 935 | { |
949 | if (monitor_validation) | 936 | if (monitor_validation) |
950 | { | 937 | { |
@@ -961,7 +948,7 @@ process_validation_cb (void *cls, | |||
961 | end = GNUNET_SCHEDULER_add_now (&shutdown_task, NULL); | 948 | end = GNUNET_SCHEDULER_add_now (&shutdown_task, NULL); |
962 | return; | 949 | return; |
963 | } | 950 | } |
964 | if ((NULL == peer) || (NULL == address)) | 951 | if (NULL == address) |
965 | { | 952 | { |
966 | /* invalid response */ | 953 | /* invalid response */ |
967 | vic = NULL; | 954 | vic = NULL; |
@@ -970,8 +957,7 @@ process_validation_cb (void *cls, | |||
970 | end = GNUNET_SCHEDULER_add_now (&shutdown_task, NULL); | 957 | end = GNUNET_SCHEDULER_add_now (&shutdown_task, NULL); |
971 | return; | 958 | return; |
972 | } | 959 | } |
973 | resolve_validation_address (peer, | 960 | resolve_validation_address (address, |
974 | address, | ||
975 | numeric, | 961 | numeric, |
976 | last_validation, | 962 | last_validation, |
977 | valid_until, | 963 | valid_until, |
@@ -1451,7 +1437,7 @@ resolve_peer_address (const struct GNUNET_PeerIdentity *id, | |||
1451 | GNUNET_CONTAINER_DLL_insert(rc_head, rc_tail, rc); | 1437 | GNUNET_CONTAINER_DLL_insert(rc_head, rc_tail, rc); |
1452 | address_resolutions++; | 1438 | address_resolutions++; |
1453 | 1439 | ||
1454 | rc->id = (*id); | 1440 | rc->id = *id; |
1455 | rc->transport = GNUNET_strdup(address->transport_name); | 1441 | rc->transport = GNUNET_strdup(address->transport_name); |
1456 | rc->addrcp = GNUNET_HELLO_address_copy (address); | 1442 | rc->addrcp = GNUNET_HELLO_address_copy (address); |
1457 | rc->printed = GNUNET_NO; | 1443 | rc->printed = GNUNET_NO; |
diff --git a/src/transport/test_transport_api_monitor_peers.c b/src/transport/test_transport_api_monitor_peers.c index 81d2f0478..536507c47 100644 --- a/src/transport/test_transport_api_monitor_peers.c +++ b/src/transport/test_transport_api_monitor_peers.c | |||
@@ -386,20 +386,19 @@ start_cb (struct PeerContext *p, void *cls) | |||
386 | 386 | ||
387 | static void | 387 | static void |
388 | monitor1_cb (void *cls, | 388 | monitor1_cb (void *cls, |
389 | const struct GNUNET_PeerIdentity *peer, | ||
390 | const struct GNUNET_HELLO_Address *address, | 389 | const struct GNUNET_HELLO_Address *address, |
391 | enum GNUNET_TRANSPORT_PeerState state, | 390 | enum GNUNET_TRANSPORT_PeerState state, |
392 | struct GNUNET_TIME_Absolute state_timeout) | 391 | struct GNUNET_TIME_Absolute state_timeout) |
393 | { | 392 | { |
394 | if ((NULL == peer) || (NULL == p1)) | 393 | if ((NULL == address) || (NULL == p1)) |
395 | return; | 394 | return; |
396 | 395 | ||
397 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 396 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
398 | "Monitor 1: %s %s %s\n", | 397 | "Monitor 1: %s %s %s\n", |
399 | GNUNET_i2s (peer), | 398 | GNUNET_i2s (&address->peer), |
400 | GNUNET_TRANSPORT_ps2s (state), | 399 | GNUNET_TRANSPORT_ps2s (state), |
401 | GNUNET_STRINGS_absolute_time_to_string(state_timeout)); | 400 | GNUNET_STRINGS_absolute_time_to_string(state_timeout)); |
402 | if ((0 == memcmp (peer, &p2->id, sizeof (p2->id)) && | 401 | if ((0 == memcmp (&address->peer, &p2->id, sizeof (p2->id)) && |
403 | (GNUNET_YES == GNUNET_TRANSPORT_is_connected(state)) && | 402 | (GNUNET_YES == GNUNET_TRANSPORT_is_connected(state)) && |
404 | GNUNET_NO == p1_c) ) | 403 | GNUNET_NO == p1_c) ) |
405 | { | 404 | { |
@@ -412,20 +411,19 @@ monitor1_cb (void *cls, | |||
412 | 411 | ||
413 | static void | 412 | static void |
414 | monitor2_cb (void *cls, | 413 | monitor2_cb (void *cls, |
415 | const struct GNUNET_PeerIdentity *peer, | ||
416 | const struct GNUNET_HELLO_Address *address, | 414 | const struct GNUNET_HELLO_Address *address, |
417 | enum GNUNET_TRANSPORT_PeerState state, | 415 | enum GNUNET_TRANSPORT_PeerState state, |
418 | struct GNUNET_TIME_Absolute state_timeout) | 416 | struct GNUNET_TIME_Absolute state_timeout) |
419 | { | 417 | { |
420 | if ((NULL == peer) || (NULL == p2)) | 418 | if ((NULL == address) || (NULL == p2)) |
421 | return; | 419 | return; |
422 | 420 | ||
423 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 421 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
424 | "Monitor 2: %s %s %s\n", | 422 | "Monitor 2: %s %s %s\n", |
425 | GNUNET_i2s (peer), | 423 | GNUNET_i2s (&address->peer), |
426 | GNUNET_TRANSPORT_ps2s (state), | 424 | GNUNET_TRANSPORT_ps2s (state), |
427 | GNUNET_STRINGS_absolute_time_to_string(state_timeout)); | 425 | GNUNET_STRINGS_absolute_time_to_string(state_timeout)); |
428 | if ((0 == memcmp (peer, &p1->id, sizeof (p1->id)) && | 426 | if ((0 == memcmp (&address->peer, &p1->id, sizeof (p1->id)) && |
429 | (GNUNET_YES == GNUNET_TRANSPORT_is_connected(state)) && | 427 | (GNUNET_YES == GNUNET_TRANSPORT_is_connected(state)) && |
430 | GNUNET_NO == p2_c) ) | 428 | GNUNET_NO == p2_c) ) |
431 | { | 429 | { |
diff --git a/src/transport/test_transport_api_monitor_validation.c b/src/transport/test_transport_api_monitor_validation.c index 261f1a7d0..12be8584e 100644 --- a/src/transport/test_transport_api_monitor_validation.c +++ b/src/transport/test_transport_api_monitor_validation.c | |||
@@ -392,43 +392,50 @@ start_cb (struct PeerContext *p, void *cls) | |||
392 | 392 | ||
393 | static void | 393 | static void |
394 | monitor1_cb (void *cls, | 394 | monitor1_cb (void *cls, |
395 | const struct GNUNET_PeerIdentity *peer, | 395 | const struct GNUNET_HELLO_Address *address, |
396 | const struct GNUNET_HELLO_Address *address, | 396 | struct GNUNET_TIME_Absolute last_validation, |
397 | struct GNUNET_TIME_Absolute last_validation, | 397 | struct GNUNET_TIME_Absolute valid_until, |
398 | struct GNUNET_TIME_Absolute valid_until, | 398 | struct GNUNET_TIME_Absolute next_validation, |
399 | struct GNUNET_TIME_Absolute next_validation, | 399 | enum GNUNET_TRANSPORT_ValidationState state) |
400 | enum GNUNET_TRANSPORT_ValidationState state) | ||
401 | { | 400 | { |
402 | if ((NULL == peer) || (NULL == p1)) | 401 | if ((NULL == address) || (NULL == p1)) |
403 | return; | 402 | return; |
404 | 403 | ||
405 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Monitor 1: %s %s %s\n", | 404 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
406 | GNUNET_i2s (peer), GNUNET_TRANSPORT_vs2s(state), GNUNET_STRINGS_absolute_time_to_string(valid_until)); | 405 | "Monitor 1: %s %s %s\n", |
407 | if (0 == memcmp (peer, &p2->id, sizeof (p2->id))) | 406 | GNUNET_i2s (&address->peer), |
407 | GNUNET_TRANSPORT_vs2s (state), | ||
408 | GNUNET_STRINGS_absolute_time_to_string(valid_until)); | ||
409 | if (0 == memcmp (&address->peer, | ||
410 | &p2->id, | ||
411 | sizeof (p2->id))) | ||
408 | p1_c++; | 412 | p1_c++; |
409 | } | 413 | } |
410 | 414 | ||
411 | 415 | ||
412 | static void | 416 | static void |
413 | monitor2_cb (void *cls, | 417 | monitor2_cb (void *cls, |
414 | const struct GNUNET_PeerIdentity *peer, | 418 | const struct GNUNET_HELLO_Address *address, |
415 | const struct GNUNET_HELLO_Address *address, | 419 | struct GNUNET_TIME_Absolute last_validation, |
416 | struct GNUNET_TIME_Absolute last_validation, | 420 | struct GNUNET_TIME_Absolute valid_until, |
417 | struct GNUNET_TIME_Absolute valid_until, | 421 | struct GNUNET_TIME_Absolute next_validation, |
418 | struct GNUNET_TIME_Absolute next_validation, | 422 | enum GNUNET_TRANSPORT_ValidationState state) |
419 | enum GNUNET_TRANSPORT_ValidationState state) | ||
420 | { | 423 | { |
421 | if ((NULL == peer) || (NULL == p2)) | 424 | if ((NULL == address) || (NULL == p2)) |
422 | return; | 425 | return; |
423 | 426 | ||
424 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Monitor 2: %s %s %s\n", | 427 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
425 | GNUNET_i2s (peer), GNUNET_TRANSPORT_vs2s(state), GNUNET_STRINGS_absolute_time_to_string(valid_until)); | 428 | "Monitor 2: %s %s %s\n", |
426 | if (0 == memcmp (peer, &p1->id, sizeof (p1->id))) | 429 | GNUNET_i2s (&address->peer), |
430 | GNUNET_TRANSPORT_vs2s(state), | ||
431 | GNUNET_STRINGS_absolute_time_to_string(valid_until)); | ||
432 | if (0 == memcmp (&address->peer, | ||
433 | &p1->id, | ||
434 | sizeof (p1->id))) | ||
427 | p2_c++; | 435 | p2_c++; |
428 | } | 436 | } |
429 | 437 | ||
430 | 438 | ||
431 | |||
432 | static void | 439 | static void |
433 | run (void *cls, char *const *args, const char *cfgfile, | 440 | run (void *cls, char *const *args, const char *cfgfile, |
434 | const struct GNUNET_CONFIGURATION_Handle *cfg) | 441 | const struct GNUNET_CONFIGURATION_Handle *cfg) |
diff --git a/src/transport/transport_api_monitor_peers.c b/src/transport/transport_api_monitor_peers.c index aaf1000f6..5b3fd64b8 100644 --- a/src/transport/transport_api_monitor_peers.c +++ b/src/transport/transport_api_monitor_peers.c | |||
@@ -333,49 +333,39 @@ peer_response_processor (void *cls, | |||
333 | return; | 333 | return; |
334 | } | 334 | } |
335 | 335 | ||
336 | if ( (0 == tlen) && (0 == alen) ) | 336 | if (0 == tlen) |
337 | { | 337 | { |
338 | /* No address available */ | 338 | GNUNET_break (0); /* This must not happen: address without plugin */ |
339 | pal_ctx->cb (pal_ctx->cb_cls, &pir_msg->peer, NULL, | 339 | return; |
340 | ntohl(pir_msg->state), | ||
341 | GNUNET_TIME_absolute_ntoh (pir_msg->state_timeout)); | ||
342 | } | 340 | } |
343 | else | 341 | addr = (const char *) &pir_msg[1]; |
342 | transport_name = &addr[alen]; | ||
343 | |||
344 | if (transport_name[tlen - 1] != '\0') | ||
344 | { | 345 | { |
345 | if (0 == tlen) | 346 | /* Corrupt plugin name */ |
347 | GNUNET_break (0); | ||
348 | if (pal_ctx->one_shot) | ||
346 | { | 349 | { |
347 | GNUNET_break (0); /* This must not happen: address without plugin */ | 350 | pal_ctx->cb (pal_ctx->cb_cls, NULL, NULL, |
348 | return; | 351 | GNUNET_TRANSPORT_PS_NOT_CONNECTED, GNUNET_TIME_UNIT_ZERO_ABS); |
352 | GNUNET_TRANSPORT_monitor_peers_cancel (pal_ctx); | ||
349 | } | 353 | } |
350 | addr = (const char *) &pir_msg[1]; | 354 | else |
351 | transport_name = &addr[alen]; | ||
352 | |||
353 | if (transport_name[tlen - 1] != '\0') | ||
354 | { | 355 | { |
355 | /* Corrupt plugin name */ | 356 | reconnect_peer_ctx (pal_ctx); |
356 | GNUNET_break (0); | ||
357 | if (pal_ctx->one_shot) | ||
358 | { | ||
359 | pal_ctx->cb (pal_ctx->cb_cls, NULL, NULL, | ||
360 | GNUNET_TRANSPORT_PS_NOT_CONNECTED, GNUNET_TIME_UNIT_ZERO_ABS); | ||
361 | GNUNET_TRANSPORT_monitor_peers_cancel (pal_ctx); | ||
362 | } | ||
363 | else | ||
364 | { | ||
365 | reconnect_peer_ctx (pal_ctx); | ||
366 | } | ||
367 | return; | ||
368 | } | 357 | } |
358 | return; | ||
359 | } | ||
369 | 360 | ||
370 | /* notify client */ | 361 | /* notify client */ |
371 | address = GNUNET_HELLO_address_allocate (&pir_msg->peer, | 362 | address = GNUNET_HELLO_address_allocate (&pir_msg->peer, |
372 | transport_name, addr, alen, ntohl(pir_msg->local_address_info)); | 363 | transport_name, addr, alen, ntohl(pir_msg->local_address_info)); |
373 | pal_ctx->cb (pal_ctx->cb_cls, &pir_msg->peer, address, | 364 | pal_ctx->cb (pal_ctx->cb_cls, &pir_msg->peer, address, |
374 | ntohl(pir_msg->state), | 365 | ntohl(pir_msg->state), |
375 | GNUNET_TIME_absolute_ntoh (pir_msg->state_timeout)); | 366 | GNUNET_TIME_absolute_ntoh (pir_msg->state_timeout)); |
376 | GNUNET_HELLO_address_free (address); | 367 | GNUNET_HELLO_address_free (address); |
377 | 368 | ||
378 | } | ||
379 | 369 | ||
380 | /* expect more replies */ | 370 | /* expect more replies */ |
381 | GNUNET_CLIENT_receive (pal_ctx->client, &peer_response_processor, | 371 | GNUNET_CLIENT_receive (pal_ctx->client, &peer_response_processor, |
diff --git a/src/transport/transport_api_monitor_validation.c b/src/transport/transport_api_monitor_validation.c index a82e3c156..a52aee129 100644 --- a/src/transport/transport_api_monitor_validation.c +++ b/src/transport/transport_api_monitor_validation.c | |||
@@ -181,7 +181,7 @@ reconnect_val_ctx (struct GNUNET_TRANSPORT_ValidationMonitoringContext *val_ctx) | |||
181 | GNUNET_CLIENT_disconnect (val_ctx->client); | 181 | GNUNET_CLIENT_disconnect (val_ctx->client); |
182 | val_ctx->client = NULL; | 182 | val_ctx->client = NULL; |
183 | /* notify clients about (re)connect */ | 183 | /* notify clients about (re)connect */ |
184 | val_ctx->cb (val_ctx->cb_cls, NULL, NULL, | 184 | val_ctx->cb (val_ctx->cb_cls, NULL, |
185 | GNUNET_TIME_UNIT_ZERO_ABS, GNUNET_TIME_UNIT_ZERO_ABS, | 185 | GNUNET_TIME_UNIT_ZERO_ABS, GNUNET_TIME_UNIT_ZERO_ABS, |
186 | GNUNET_TIME_UNIT_ZERO_ABS, GNUNET_TRANSPORT_VS_TIMEOUT); | 186 | GNUNET_TIME_UNIT_ZERO_ABS, GNUNET_TRANSPORT_VS_TIMEOUT); |
187 | val_ctx->backoff = GNUNET_TIME_STD_BACKOFF (val_ctx->backoff); | 187 | val_ctx->backoff = GNUNET_TIME_STD_BACKOFF (val_ctx->backoff); |
@@ -216,7 +216,7 @@ val_response_processor (void *cls, | |||
216 | if (val_ctx->one_shot) | 216 | if (val_ctx->one_shot) |
217 | { | 217 | { |
218 | /* Disconnect */ | 218 | /* Disconnect */ |
219 | val_ctx->cb (val_ctx->cb_cls, NULL, NULL, | 219 | val_ctx->cb (val_ctx->cb_cls, NULL, |
220 | GNUNET_TIME_UNIT_ZERO_ABS, GNUNET_TIME_UNIT_ZERO_ABS, | 220 | GNUNET_TIME_UNIT_ZERO_ABS, GNUNET_TIME_UNIT_ZERO_ABS, |
221 | GNUNET_TIME_UNIT_ZERO_ABS, GNUNET_TRANSPORT_VS_TIMEOUT); | 221 | GNUNET_TIME_UNIT_ZERO_ABS, GNUNET_TRANSPORT_VS_TIMEOUT); |
222 | GNUNET_TRANSPORT_monitor_validation_entries_cancel (val_ctx); | 222 | GNUNET_TRANSPORT_monitor_validation_entries_cancel (val_ctx); |
@@ -236,7 +236,7 @@ val_response_processor (void *cls, | |||
236 | /* Done! */ | 236 | /* Done! */ |
237 | if (val_ctx->one_shot) | 237 | if (val_ctx->one_shot) |
238 | { | 238 | { |
239 | val_ctx->cb (val_ctx->cb_cls, NULL, NULL, | 239 | val_ctx->cb (val_ctx->cb_cls, NULL, |
240 | GNUNET_TIME_UNIT_ZERO_ABS, GNUNET_TIME_UNIT_ZERO_ABS, | 240 | GNUNET_TIME_UNIT_ZERO_ABS, GNUNET_TIME_UNIT_ZERO_ABS, |
241 | GNUNET_TIME_UNIT_ZERO_ABS, GNUNET_TRANSPORT_VS_NONE); | 241 | GNUNET_TIME_UNIT_ZERO_ABS, GNUNET_TRANSPORT_VS_NONE); |
242 | GNUNET_TRANSPORT_monitor_validation_entries_cancel (val_ctx); | 242 | GNUNET_TRANSPORT_monitor_validation_entries_cancel (val_ctx); |
@@ -254,7 +254,7 @@ val_response_processor (void *cls, | |||
254 | GNUNET_break (0); | 254 | GNUNET_break (0); |
255 | if (val_ctx->one_shot) | 255 | if (val_ctx->one_shot) |
256 | { | 256 | { |
257 | val_ctx->cb (val_ctx->cb_cls, NULL, NULL, | 257 | val_ctx->cb (val_ctx->cb_cls, NULL, |
258 | GNUNET_TIME_UNIT_ZERO_ABS, GNUNET_TIME_UNIT_ZERO_ABS, | 258 | GNUNET_TIME_UNIT_ZERO_ABS, GNUNET_TIME_UNIT_ZERO_ABS, |
259 | GNUNET_TIME_UNIT_ZERO_ABS, GNUNET_TRANSPORT_VS_NONE); | 259 | GNUNET_TIME_UNIT_ZERO_ABS, GNUNET_TRANSPORT_VS_NONE); |
260 | GNUNET_TRANSPORT_monitor_validation_entries_cancel (val_ctx); | 260 | GNUNET_TRANSPORT_monitor_validation_entries_cancel (val_ctx); |
@@ -275,7 +275,7 @@ val_response_processor (void *cls, | |||
275 | GNUNET_break (0); | 275 | GNUNET_break (0); |
276 | if (val_ctx->one_shot) | 276 | if (val_ctx->one_shot) |
277 | { | 277 | { |
278 | val_ctx->cb (val_ctx->cb_cls, NULL, NULL, | 278 | val_ctx->cb (val_ctx->cb_cls, NULL, |
279 | GNUNET_TIME_UNIT_ZERO_ABS, GNUNET_TIME_UNIT_ZERO_ABS, | 279 | GNUNET_TIME_UNIT_ZERO_ABS, GNUNET_TIME_UNIT_ZERO_ABS, |
280 | GNUNET_TIME_UNIT_ZERO_ABS, GNUNET_TRANSPORT_VS_NONE); | 280 | GNUNET_TIME_UNIT_ZERO_ABS, GNUNET_TRANSPORT_VS_NONE); |
281 | GNUNET_TRANSPORT_monitor_validation_entries_cancel (val_ctx); | 281 | GNUNET_TRANSPORT_monitor_validation_entries_cancel (val_ctx); |
@@ -286,14 +286,26 @@ val_response_processor (void *cls, | |||
286 | } | 286 | } |
287 | return; | 287 | return; |
288 | } | 288 | } |
289 | if ( (0 == tlen) && (0 == alen) ) | 289 | if (0 == tlen) |
290 | { | 290 | { |
291 | GNUNET_break (0); /* This must not happen: address without plugin */ | ||
292 | return; | ||
293 | } | ||
294 | addr = (const char *) &vr_msg[1]; | ||
295 | transport_name = &addr[alen]; | ||
296 | |||
297 | if (transport_name[tlen - 1] != '\0') | ||
298 | { | ||
299 | /* Corrupt plugin name */ | ||
291 | GNUNET_break (0); | 300 | GNUNET_break (0); |
292 | if (val_ctx->one_shot) | 301 | if (val_ctx->one_shot) |
293 | { | 302 | { |
294 | val_ctx->cb (val_ctx->cb_cls, NULL, NULL, | 303 | val_ctx->cb (val_ctx->cb_cls, |
295 | GNUNET_TIME_UNIT_ZERO_ABS, GNUNET_TIME_UNIT_ZERO_ABS, | 304 | NULL, |
296 | GNUNET_TIME_UNIT_ZERO_ABS, GNUNET_TRANSPORT_VS_NONE); | 305 | GNUNET_TIME_UNIT_ZERO_ABS, |
306 | GNUNET_TIME_UNIT_ZERO_ABS, | ||
307 | GNUNET_TIME_UNIT_ZERO_ABS, | ||
308 | GNUNET_TRANSPORT_VS_NONE); | ||
297 | GNUNET_TRANSPORT_monitor_validation_entries_cancel (val_ctx); | 309 | GNUNET_TRANSPORT_monitor_validation_entries_cancel (val_ctx); |
298 | } | 310 | } |
299 | else | 311 | else |
@@ -302,51 +314,19 @@ val_response_processor (void *cls, | |||
302 | } | 314 | } |
303 | return; | 315 | return; |
304 | } | 316 | } |
305 | else | 317 | |
306 | { | 318 | /* notify client */ |
307 | if (0 == tlen) | 319 | address = GNUNET_HELLO_address_allocate (&vr_msg->peer, |
308 | { | 320 | transport_name, |
309 | GNUNET_break (0); /* This must not happen: address without plugin */ | 321 | addr, alen, |
310 | return; | 322 | ntohl (vr_msg->local_address_info)); |
311 | } | 323 | val_ctx->cb (val_ctx->cb_cls, |
312 | addr = (const char *) &vr_msg[1]; | 324 | address, |
313 | transport_name = &addr[alen]; | 325 | GNUNET_TIME_absolute_ntoh (vr_msg->last_validation), |
314 | 326 | GNUNET_TIME_absolute_ntoh (vr_msg->valid_until), | |
315 | if (transport_name[tlen - 1] != '\0') | 327 | GNUNET_TIME_absolute_ntoh (vr_msg->next_validation), |
316 | { | 328 | ntohl(vr_msg->state)); |
317 | /* Corrupt plugin name */ | 329 | GNUNET_HELLO_address_free (address); |
318 | GNUNET_break (0); | ||
319 | if (val_ctx->one_shot) | ||
320 | { | ||
321 | val_ctx->cb (val_ctx->cb_cls, | ||
322 | NULL, NULL, | ||
323 | GNUNET_TIME_UNIT_ZERO_ABS, | ||
324 | GNUNET_TIME_UNIT_ZERO_ABS, | ||
325 | GNUNET_TIME_UNIT_ZERO_ABS, | ||
326 | GNUNET_TRANSPORT_VS_NONE); | ||
327 | GNUNET_TRANSPORT_monitor_validation_entries_cancel (val_ctx); | ||
328 | } | ||
329 | else | ||
330 | { | ||
331 | reconnect_val_ctx (val_ctx); | ||
332 | } | ||
333 | return; | ||
334 | } | ||
335 | |||
336 | /* notify client */ | ||
337 | address = GNUNET_HELLO_address_allocate (&vr_msg->peer, | ||
338 | transport_name, | ||
339 | addr, alen, | ||
340 | ntohl (vr_msg->local_address_info)); | ||
341 | val_ctx->cb (val_ctx->cb_cls, | ||
342 | &vr_msg->peer, | ||
343 | address, | ||
344 | GNUNET_TIME_absolute_ntoh (vr_msg->last_validation), | ||
345 | GNUNET_TIME_absolute_ntoh (vr_msg->valid_until), | ||
346 | GNUNET_TIME_absolute_ntoh (vr_msg->next_validation), | ||
347 | ntohl(vr_msg->state)); | ||
348 | GNUNET_HELLO_address_free (address); | ||
349 | } | ||
350 | /* expect more replies */ | 330 | /* expect more replies */ |
351 | GNUNET_CLIENT_receive (val_ctx->client, | 331 | GNUNET_CLIENT_receive (val_ctx->client, |
352 | &val_response_processor, | 332 | &val_response_processor, |