diff options
-rw-r--r-- | src/transport/Makefile.am | 2 | ||||
-rw-r--r-- | src/transport/gnunet-service-transport.c | 4 | ||||
-rw-r--r-- | src/transport/gnunet-service-transport_clients.c | 121 | ||||
-rw-r--r-- | src/transport/gnunet-service-transport_clients.h | 13 | ||||
-rw-r--r-- | src/transport/gnunet-service-transport_neighbours.c | 12 | ||||
-rw-r--r-- | src/transport/gnunet-service-transport_neighbours.h | 12 | ||||
-rw-r--r-- | src/transport/gnunet-service-transport_validation.c | 143 | ||||
-rw-r--r-- | src/transport/gnunet-service-transport_validation.h | 61 | ||||
-rw-r--r-- | src/transport/transport.h | 19 | ||||
-rw-r--r-- | src/transport/transport_api_peer_address_lookup.c | 7 |
10 files changed, 369 insertions, 25 deletions
diff --git a/src/transport/Makefile.am b/src/transport/Makefile.am index 395823724..63edcb15a 100644 --- a/src/transport/Makefile.am +++ b/src/transport/Makefile.am | |||
@@ -154,7 +154,7 @@ gnunet_service_transport_new_SOURCES = \ | |||
154 | gnunet-service-transport_hello.h gnunet-service-transport_hello.c \ | 154 | gnunet-service-transport_hello.h gnunet-service-transport_hello.c \ |
155 | gnunet-service-transport_neighbours.h gnunet-service-transport_neighbours.c \ | 155 | gnunet-service-transport_neighbours.h gnunet-service-transport_neighbours.c \ |
156 | gnunet-service-transport_plugins.h gnunet-service-transport_plugins.c \ | 156 | gnunet-service-transport_plugins.h gnunet-service-transport_plugins.c \ |
157 | gnunet-service-transport_validation.h | 157 | gnunet-service-transport_validation.h gnunet-service-transport_validation.c |
158 | gnunet_service_transport_new_LDADD = \ | 158 | gnunet_service_transport_new_LDADD = \ |
159 | $(top_builddir)/src/hello/libgnunethello.la \ | 159 | $(top_builddir)/src/hello/libgnunethello.la \ |
160 | $(top_builddir)/src/peerinfo/libgnunetpeerinfo.la \ | 160 | $(top_builddir)/src/peerinfo/libgnunetpeerinfo.la \ |
diff --git a/src/transport/gnunet-service-transport.c b/src/transport/gnunet-service-transport.c index 6fd17e72d..ea7ce98db 100644 --- a/src/transport/gnunet-service-transport.c +++ b/src/transport/gnunet-service-transport.c | |||
@@ -5963,7 +5963,6 @@ handle_peer_address_lookup (void *cls, | |||
5963 | 5963 | ||
5964 | uint16_t size; | 5964 | uint16_t size; |
5965 | struct GNUNET_SERVER_TransmitContext *tc; | 5965 | struct GNUNET_SERVER_TransmitContext *tc; |
5966 | struct GNUNET_TIME_Absolute timeout; | ||
5967 | struct GNUNET_TIME_Relative rtimeout; | 5966 | struct GNUNET_TIME_Relative rtimeout; |
5968 | char *addr_buf; | 5967 | char *addr_buf; |
5969 | 5968 | ||
@@ -5976,8 +5975,7 @@ handle_peer_address_lookup (void *cls, | |||
5976 | } | 5975 | } |
5977 | peer_address_lookup = (const struct PeerAddressLookupMessage *) message; | 5976 | peer_address_lookup = (const struct PeerAddressLookupMessage *) message; |
5978 | 5977 | ||
5979 | timeout = GNUNET_TIME_absolute_ntoh (peer_address_lookup->timeout); | 5978 | rtimeout = GNUNET_TIME_relative_ntoh (peer_address_lookup->timeout); |
5980 | rtimeout = GNUNET_TIME_absolute_get_remaining (timeout); | ||
5981 | 5979 | ||
5982 | neighbor_iterator = find_neighbour (&peer_address_lookup->peer); | 5980 | neighbor_iterator = find_neighbour (&peer_address_lookup->peer); |
5983 | 5981 | ||
diff --git a/src/transport/gnunet-service-transport_clients.c b/src/transport/gnunet-service-transport_clients.c index 1ef28ad90..3b42c7a79 100644 --- a/src/transport/gnunet-service-transport_clients.c +++ b/src/transport/gnunet-service-transport_clients.c | |||
@@ -28,6 +28,7 @@ | |||
28 | #include "gnunet-service-transport_hello.h" | 28 | #include "gnunet-service-transport_hello.h" |
29 | #include "gnunet-service-transport_neighbours.h" | 29 | #include "gnunet-service-transport_neighbours.h" |
30 | #include "gnunet-service-transport_plugins.h" | 30 | #include "gnunet-service-transport_plugins.h" |
31 | #include "gnunet-service-transport_validation.h" | ||
31 | #include "gnunet-service-transport.h" | 32 | #include "gnunet-service-transport.h" |
32 | #include "transport.h" | 33 | #include "transport.h" |
33 | 34 | ||
@@ -427,6 +428,23 @@ GST_clients_handle_start (void *cls, | |||
427 | 428 | ||
428 | 429 | ||
429 | /** | 430 | /** |
431 | * Client sent us a HELLO. Process the request. | ||
432 | * | ||
433 | * @param cls unused | ||
434 | * @param client the client | ||
435 | * @param message the HELLO message | ||
436 | */ | ||
437 | void | ||
438 | GST_clients_handle_hello (void *cls, | ||
439 | struct GNUNET_SERVER_Client *client, | ||
440 | const struct GNUNET_MessageHeader *message) | ||
441 | { | ||
442 | GST_validation_handle_hello (message); | ||
443 | GNUNET_SERVER_receive_done (client, GNUNET_OK); | ||
444 | } | ||
445 | |||
446 | |||
447 | /** | ||
430 | * Client asked for transmission to a peer. Process the request. | 448 | * Client asked for transmission to a peer. Process the request. |
431 | * | 449 | * |
432 | * @param cls unused | 450 | * @param cls unused |
@@ -438,6 +456,8 @@ GST_clients_handle_send (void *cls, | |||
438 | struct GNUNET_SERVER_Client *client, | 456 | struct GNUNET_SERVER_Client *client, |
439 | const struct GNUNET_MessageHeader *message) | 457 | const struct GNUNET_MessageHeader *message) |
440 | { | 458 | { |
459 | /* FIXME */ | ||
460 | GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); | ||
441 | } | 461 | } |
442 | 462 | ||
443 | 463 | ||
@@ -568,8 +588,52 @@ GST_clients_handle_address_lookup (void *cls, | |||
568 | 588 | ||
569 | 589 | ||
570 | /** | 590 | /** |
591 | * Send an address to the client. | ||
592 | * | ||
593 | * @param cls our 'struct GNUNET_SERVER_TransmitContext' (for sending) | ||
594 | * @param target peer this change is about, never NULL | ||
595 | * @param last_validated_at is FOREVER if the address has not been validated (we're currently checking) | ||
596 | * is ZERO if the address was validated a long time ago (from PEERINFO) | ||
597 | * is a time in the past if this process validated the address | ||
598 | * @param validation_block is FOREVER if the address is for an unsupported plugin (from PEERINFO) | ||
599 | * is ZERO if the address is considered valid (no validation needed) | ||
600 | * is a time in the future if we're currently denying re-validation | ||
601 | * @param plugin_name name of the plugin | ||
602 | * @param plugin_address binary address | ||
603 | * @param plugin_address_len length of address | ||
604 | */ | ||
605 | static void | ||
606 | send_address_to_client (void *cls, | ||
607 | const struct GNUNET_PeerIdentity *target, | ||
608 | struct GNUNET_TIME_Absolute last_validated_at, | ||
609 | struct GNUNET_TIME_Absolute validation_block, | ||
610 | const char *plugin_name, | ||
611 | const void *plugin_address, | ||
612 | size_t plugin_address_len) | ||
613 | { | ||
614 | struct GNUNET_SERVER_TransmitContext *tc = cls; | ||
615 | char *addr_buf; | ||
616 | |||
617 | /* FIXME: move to a binary format!!! */ | ||
618 | GNUNET_asprintf (&addr_buf, "%s --- %s, %s", | ||
619 | GST_plugins_a2s (plugin_name, | ||
620 | plugin_address, | ||
621 | plugin_address_len), | ||
622 | (GNUNET_YES == GST_neighbours_test_connected (target)) | ||
623 | ? "CONNECTED" | ||
624 | : "DISCONNECTED", | ||
625 | (last_validated_at.abs_value < GNUNET_TIME_UNIT_FOREVER_ABS.abs_value) | ||
626 | ? "VALIDATED" | ||
627 | : "UNVALIDATED"); | ||
628 | transmit_address_to_client (tc, addr_buf); | ||
629 | GNUNET_free (addr_buf); | ||
630 | } | ||
631 | |||
632 | |||
633 | /** | ||
571 | * Client asked to obtain information about a peer's addresses. | 634 | * Client asked to obtain information about a peer's addresses. |
572 | * Process the request. | 635 | * Process the request. |
636 | * FIXME: use better name! | ||
573 | * | 637 | * |
574 | * @param cls unused | 638 | * @param cls unused |
575 | * @param client the client | 639 | * @param client the client |
@@ -580,12 +644,54 @@ GST_clients_handle_peer_address_lookup (void *cls, | |||
580 | struct GNUNET_SERVER_Client *client, | 644 | struct GNUNET_SERVER_Client *client, |
581 | const struct GNUNET_MessageHeader *message) | 645 | const struct GNUNET_MessageHeader *message) |
582 | { | 646 | { |
647 | const struct PeerAddressLookupMessage *peer_address_lookup; | ||
648 | struct GNUNET_SERVER_TransmitContext *tc; | ||
649 | |||
650 | peer_address_lookup = (const struct PeerAddressLookupMessage *) message; | ||
651 | GNUNET_break (ntohl (peer_address_lookup->reserved) == 0); | ||
652 | tc = GNUNET_SERVER_transmit_context_create (client); | ||
653 | (void) GST_validation_get_addresses (&peer_address_lookup->peer, | ||
654 | GNUNET_YES, | ||
655 | &send_address_to_client, | ||
656 | tc); | ||
657 | GNUNET_SERVER_transmit_context_append_data (tc, | ||
658 | NULL, 0, | ||
659 | GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_REPLY); | ||
660 | GNUNET_SERVER_transmit_context_run (tc, | ||
661 | GNUNET_TIME_UNIT_FOREVER_REL); | ||
583 | } | 662 | } |
584 | 663 | ||
585 | 664 | ||
586 | /** | 665 | /** |
587 | * Client asked to obtain information about all addresses. | 666 | * Output the active address of connected neighbours to the given client. |
588 | * Process the request. | 667 | * |
668 | * @param cls the 'struct GNUNET_SERVER_TransmitContext' for transmission to the client | ||
669 | * @param neighbour identity of the neighbour | ||
670 | * @param ats performance data | ||
671 | * @param ats_count number of entries in ats (excluding 0-termination) | ||
672 | */ | ||
673 | static void | ||
674 | output_addresses (void *cls, | ||
675 | const struct GNUNET_PeerIdentity *neighbour, | ||
676 | const struct GNUNET_TRANSPORT_ATS_Information *ats, | ||
677 | uint32_t ats_count) | ||
678 | { | ||
679 | struct GNUNET_SERVER_TransmitContext *tc = cls; | ||
680 | char *addr_buf; | ||
681 | |||
682 | /* FIXME: move to a binary format!!! */ | ||
683 | GNUNET_asprintf (&addr_buf, | ||
684 | "%s: %s", | ||
685 | GNUNET_i2s(neighbour), | ||
686 | GST_plugins_a2s ("FIXME", NULL, 0)); | ||
687 | transmit_address_to_client (tc, addr_buf); | ||
688 | GNUNET_free (addr_buf); | ||
689 | } | ||
690 | |||
691 | |||
692 | /** | ||
693 | * Client asked to obtain information about all actively used addresses. | ||
694 | * Process the request. FIXME: use better name! | ||
589 | * | 695 | * |
590 | * @param cls unused | 696 | * @param cls unused |
591 | * @param client the client | 697 | * @param client the client |
@@ -595,7 +701,16 @@ void | |||
595 | GST_clients_handle_address_iterate (void *cls, | 701 | GST_clients_handle_address_iterate (void *cls, |
596 | struct GNUNET_SERVER_Client *client, | 702 | struct GNUNET_SERVER_Client *client, |
597 | const struct GNUNET_MessageHeader *message) | 703 | const struct GNUNET_MessageHeader *message) |
598 | { | 704 | { |
705 | struct GNUNET_SERVER_TransmitContext *tc; | ||
706 | |||
707 | GNUNET_SERVER_disable_receive_done_warning (client); | ||
708 | tc = GNUNET_SERVER_transmit_context_create (client); | ||
709 | GST_neighbours_iterate (&output_addresses, | ||
710 | tc); | ||
711 | GNUNET_SERVER_transmit_context_append_data (tc, NULL, 0, | ||
712 | GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_REPLY); | ||
713 | GNUNET_SERVER_transmit_context_run (tc, GNUNET_TIME_UNIT_FOREVER_REL); | ||
599 | } | 714 | } |
600 | 715 | ||
601 | 716 | ||
diff --git a/src/transport/gnunet-service-transport_clients.h b/src/transport/gnunet-service-transport_clients.h index c18c051fb..a8ae14a53 100644 --- a/src/transport/gnunet-service-transport_clients.h +++ b/src/transport/gnunet-service-transport_clients.h | |||
@@ -62,6 +62,19 @@ GST_clients_handle_start (void *cls, | |||
62 | 62 | ||
63 | 63 | ||
64 | /** | 64 | /** |
65 | * Client sent us a HELLO. Process the request. | ||
66 | * | ||
67 | * @param cls unused | ||
68 | * @param client the client | ||
69 | * @param message the HELLO message | ||
70 | */ | ||
71 | void | ||
72 | GST_clients_handle_hello (void *cls, | ||
73 | struct GNUNET_SERVER_Client *client, | ||
74 | const struct GNUNET_MessageHeader *message); | ||
75 | |||
76 | |||
77 | /** | ||
65 | * Client asked for transmission to a peer. Process the request. | 78 | * Client asked for transmission to a peer. Process the request. |
66 | * | 79 | * |
67 | * @param cls unused | 80 | * @param cls unused |
diff --git a/src/transport/gnunet-service-transport_neighbours.c b/src/transport/gnunet-service-transport_neighbours.c index 4c25be39c..f961ea4f2 100644 --- a/src/transport/gnunet-service-transport_neighbours.c +++ b/src/transport/gnunet-service-transport_neighbours.c | |||
@@ -174,6 +174,8 @@ GST_neighbours_iterate (GST_NeighbourIterator cb, | |||
174 | * @param sender_address address of the other peer, NULL if other peer | 174 | * @param sender_address address of the other peer, NULL if other peer |
175 | * connected to us | 175 | * connected to us |
176 | * @param sender_address_len number of bytes in sender_address | 176 | * @param sender_address_len number of bytes in sender_address |
177 | * @param ats performance data | ||
178 | * @param ats_count number of entries in ats (excluding 0-termination) | ||
177 | * @return GNUNET_OK if the message was well-formed, GNUNET_SYSERR if not | 179 | * @return GNUNET_OK if the message was well-formed, GNUNET_SYSERR if not |
178 | */ | 180 | */ |
179 | int | 181 | int |
@@ -181,7 +183,9 @@ GST_neighbours_handle_pong (const struct GNUNET_PeerIdentity *sender, | |||
181 | const struct GNUNET_MessageHeader *hdr, | 183 | const struct GNUNET_MessageHeader *hdr, |
182 | const char *plugin_name, | 184 | const char *plugin_name, |
183 | const void *sender_address, | 185 | const void *sender_address, |
184 | size_t sender_address_len) | 186 | size_t sender_address_len, |
187 | const struct GNUNET_TRANSPORT_ATS_Information *ats, | ||
188 | uint32_t ats_count) | ||
185 | { | 189 | { |
186 | return GNUNET_SYSERR; | 190 | return GNUNET_SYSERR; |
187 | } | 191 | } |
@@ -196,6 +200,8 @@ GST_neighbours_handle_pong (const struct GNUNET_PeerIdentity *sender, | |||
196 | * @param sender_address address of the other peer, NULL if other peer | 200 | * @param sender_address address of the other peer, NULL if other peer |
197 | * connected to us | 201 | * connected to us |
198 | * @param sender_address_len number of bytes in sender_address | 202 | * @param sender_address_len number of bytes in sender_address |
203 | * @param ats performance data | ||
204 | * @param ats_count number of entries in ats (excluding 0-termination) | ||
199 | * @return GNUNET_OK if the message was well-formed, GNUNET_SYSERR if not | 205 | * @return GNUNET_OK if the message was well-formed, GNUNET_SYSERR if not |
200 | */ | 206 | */ |
201 | int | 207 | int |
@@ -203,7 +209,9 @@ GST_neighbours_handle_connect (const struct GNUNET_PeerIdentity *sender, | |||
203 | const struct GNUNET_MessageHeader *hdr, | 209 | const struct GNUNET_MessageHeader *hdr, |
204 | const char *plugin_name, | 210 | const char *plugin_name, |
205 | const void *sender_address, | 211 | const void *sender_address, |
206 | size_t sender_address_len) | 212 | size_t sender_address_len, |
213 | const struct GNUNET_TRANSPORT_ATS_Information *ats, | ||
214 | uint32_t ats_count) | ||
207 | { | 215 | { |
208 | return GNUNET_SYSERR; | 216 | return GNUNET_SYSERR; |
209 | } | 217 | } |
diff --git a/src/transport/gnunet-service-transport_neighbours.h b/src/transport/gnunet-service-transport_neighbours.h index 26b3a11b8..9c64f79ec 100644 --- a/src/transport/gnunet-service-transport_neighbours.h +++ b/src/transport/gnunet-service-transport_neighbours.h | |||
@@ -152,6 +152,8 @@ GST_neighbours_iterate (GST_NeighbourIterator cb, | |||
152 | * @param sender_address address of the other peer, NULL if other peer | 152 | * @param sender_address address of the other peer, NULL if other peer |
153 | * connected to us | 153 | * connected to us |
154 | * @param sender_address_len number of bytes in sender_address | 154 | * @param sender_address_len number of bytes in sender_address |
155 | * @param ats performance data | ||
156 | * @param ats_count number of entries in ats (excluding 0-termination) | ||
155 | * @return GNUNET_OK if the message was well-formed, GNUNET_SYSERR if not | 157 | * @return GNUNET_OK if the message was well-formed, GNUNET_SYSERR if not |
156 | */ | 158 | */ |
157 | int | 159 | int |
@@ -159,7 +161,9 @@ GST_neighbours_handle_pong (const struct GNUNET_PeerIdentity *sender, | |||
159 | const struct GNUNET_MessageHeader *hdr, | 161 | const struct GNUNET_MessageHeader *hdr, |
160 | const char *plugin_name, | 162 | const char *plugin_name, |
161 | const void *sender_address, | 163 | const void *sender_address, |
162 | size_t sender_address_len); | 164 | size_t sender_address_len, |
165 | const struct GNUNET_TRANSPORT_ATS_Information *ats, | ||
166 | uint32_t ats_count); | ||
163 | 167 | ||
164 | 168 | ||
165 | /** | 169 | /** |
@@ -171,6 +175,8 @@ GST_neighbours_handle_pong (const struct GNUNET_PeerIdentity *sender, | |||
171 | * @param sender_address address of the other peer, NULL if other peer | 175 | * @param sender_address address of the other peer, NULL if other peer |
172 | * connected to us | 176 | * connected to us |
173 | * @param sender_address_len number of bytes in sender_address | 177 | * @param sender_address_len number of bytes in sender_address |
178 | * @param ats performance data | ||
179 | * @param ats_count number of entries in ats (excluding 0-termination) | ||
174 | * @return GNUNET_OK if the message was well-formed, GNUNET_SYSERR if not | 180 | * @return GNUNET_OK if the message was well-formed, GNUNET_SYSERR if not |
175 | */ | 181 | */ |
176 | int | 182 | int |
@@ -178,7 +184,9 @@ GST_neighbours_handle_connect (const struct GNUNET_PeerIdentity *sender, | |||
178 | const struct GNUNET_MessageHeader *hdr, | 184 | const struct GNUNET_MessageHeader *hdr, |
179 | const char *plugin_name, | 185 | const char *plugin_name, |
180 | const void *sender_address, | 186 | const void *sender_address, |
181 | size_t sender_address_len); | 187 | size_t sender_address_len, |
188 | const struct GNUNET_TRANSPORT_ATS_Information *ats, | ||
189 | uint32_t ats_count); | ||
182 | 190 | ||
183 | 191 | ||
184 | /** | 192 | /** |
diff --git a/src/transport/gnunet-service-transport_validation.c b/src/transport/gnunet-service-transport_validation.c new file mode 100644 index 000000000..6cdd99e25 --- /dev/null +++ b/src/transport/gnunet-service-transport_validation.c | |||
@@ -0,0 +1,143 @@ | |||
1 | /* | ||
2 | This file is part of GNUnet. | ||
3 | (C) 2010,2011 Christian Grothoff (and other contributing authors) | ||
4 | |||
5 | GNUnet is free software; you can redistribute it and/or modify | ||
6 | it under the terms of the GNU General Public License as published | ||
7 | by the Free Software Foundation; either version 3, or (at your | ||
8 | option) any later version. | ||
9 | |||
10 | GNUnet is distributed in the hope that it will be useful, but | ||
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13 | General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU General Public License | ||
16 | along with GNUnet; see the file COPYING. If not, write to the | ||
17 | Free Software Foundation, Inc., 59 Temple Place - Suite 330, | ||
18 | Boston, MA 02111-1307, USA. | ||
19 | */ | ||
20 | |||
21 | /** | ||
22 | * @file transport/gnunet-service-transport_validation.c | ||
23 | * @brief address validation subsystem | ||
24 | * @author Christian Grothoff | ||
25 | */ | ||
26 | #include "platform.h" | ||
27 | #include "gnunet-service-transport_validation.h" | ||
28 | |||
29 | |||
30 | /** | ||
31 | * Start the validation subsystem. | ||
32 | */ | ||
33 | void | ||
34 | GST_validation_start () | ||
35 | { | ||
36 | } | ||
37 | |||
38 | |||
39 | /** | ||
40 | * Stop the validation subsystem. | ||
41 | */ | ||
42 | void | ||
43 | GST_validation_stop () | ||
44 | { | ||
45 | } | ||
46 | |||
47 | |||
48 | /** | ||
49 | * We've received a PING. If appropriate, generate a PONG. | ||
50 | * | ||
51 | * @param sender peer sending the PING | ||
52 | * @param hdr the PING | ||
53 | * @param plugin_name name of plugin that received the PING | ||
54 | * @param sender_address address of the sender as known to the plugin, NULL | ||
55 | * if we did not initiate the connection | ||
56 | * @param sender_address_len number of bytes in sender_address | ||
57 | */ | ||
58 | void | ||
59 | GST_validation_handle_ping (const struct GNUNET_PeerIdentity *sender, | ||
60 | const struct GNUNET_MessageHeader *hdr, | ||
61 | const char *plugin_name, | ||
62 | const void *sender_address, | ||
63 | size_t sender_address_len) | ||
64 | { | ||
65 | } | ||
66 | |||
67 | |||
68 | /** | ||
69 | * We've received a PONG. Check if it matches a pending PING and | ||
70 | * mark the respective address as confirmed. | ||
71 | * | ||
72 | * @param sender peer sending the PONG | ||
73 | * @param hdr the PONG | ||
74 | * @param plugin_name name of plugin that received the PONG | ||
75 | * @param sender_address address of the sender as known to the plugin, NULL | ||
76 | * if we did not initiate the connection | ||
77 | * @param sender_address_len number of bytes in sender_address | ||
78 | */ | ||
79 | void | ||
80 | GST_validation_handle_pong (const struct GNUNET_PeerIdentity *sender, | ||
81 | const struct GNUNET_MessageHeader *hdr, | ||
82 | const char *plugin_name, | ||
83 | const void *sender_address, | ||
84 | size_t sender_address_len) | ||
85 | { | ||
86 | } | ||
87 | |||
88 | |||
89 | /** | ||
90 | * We've received a HELLO, check which addresses are new and trigger | ||
91 | * validation. | ||
92 | * | ||
93 | * @param hello the HELLO we received | ||
94 | */ | ||
95 | void | ||
96 | GST_validation_handle_hello (const struct GNUNET_MessageHeader *hello) | ||
97 | { | ||
98 | } | ||
99 | |||
100 | |||
101 | /** | ||
102 | * Opaque handle to stop incremental validation address callbacks. | ||
103 | */ | ||
104 | struct GST_ValidationIteratorContext | ||
105 | { | ||
106 | }; | ||
107 | |||
108 | |||
109 | /** | ||
110 | * Call the given function for each address for the given target. | ||
111 | * Can either give a snapshot (synchronous API) or be continuous. | ||
112 | * | ||
113 | * @param target peer information is requested for | ||
114 | * @param snapshot_only GNUNET_YES to iterate over addresses once, GNUNET_NO to | ||
115 | * continue to give information about addresses as it evolves | ||
116 | * @param cb function to call; will not be called after this function returns | ||
117 | * if snapshot_only is GNUNET_YES | ||
118 | * @param cb_cls closure for 'cb' | ||
119 | * @return context to cancel, NULL if 'snapshot_only' is GNUNET_YES | ||
120 | */ | ||
121 | struct GST_ValidationIteratorContext * | ||
122 | GST_validation_get_addresses (const struct GNUNET_PeerIdentity *target, | ||
123 | int snapshot_only, | ||
124 | GST_ValidationAddressCallback cb, | ||
125 | void *cb_cls) | ||
126 | { | ||
127 | return NULL; | ||
128 | } | ||
129 | |||
130 | |||
131 | /** | ||
132 | * Cancel an active validation address iteration. | ||
133 | * | ||
134 | * @param ctx the context of the operation that is cancelled | ||
135 | */ | ||
136 | void | ||
137 | GST_validation_get_addresses_cancel (struct GST_ValidationIteratorContext *ctx) | ||
138 | { | ||
139 | GNUNET_break (0); | ||
140 | } | ||
141 | |||
142 | |||
143 | /* end of file gnunet-service-transport_validation.c */ | ||
diff --git a/src/transport/gnunet-service-transport_validation.h b/src/transport/gnunet-service-transport_validation.h index 9768c425e..0d6e0ef5a 100644 --- a/src/transport/gnunet-service-transport_validation.h +++ b/src/transport/gnunet-service-transport_validation.h | |||
@@ -20,7 +20,7 @@ | |||
20 | 20 | ||
21 | /** | 21 | /** |
22 | * @file transport/gnunet-service-transport_validation.h | 22 | * @file transport/gnunet-service-transport_validation.h |
23 | * @brief plugin management API | 23 | * @brief address validation API |
24 | * @author Christian Grothoff | 24 | * @author Christian Grothoff |
25 | */ | 25 | */ |
26 | #ifndef GNUNET_SERVICE_TRANSPORT_VALIDATION_H | 26 | #ifndef GNUNET_SERVICE_TRANSPORT_VALIDATION_H |
@@ -31,33 +31,49 @@ | |||
31 | 31 | ||
32 | 32 | ||
33 | /** | 33 | /** |
34 | * | 34 | * Start the validation subsystem. |
35 | */ | 35 | */ |
36 | void | 36 | void |
37 | GST_validation_start (void); | 37 | GST_validation_start (void); |
38 | 38 | ||
39 | 39 | ||
40 | /** | 40 | /** |
41 | * | 41 | * Stop the validation subsystem. |
42 | */ | 42 | */ |
43 | void | 43 | void |
44 | GST_validation_stop (void); | 44 | GST_validation_stop (void); |
45 | 45 | ||
46 | 46 | ||
47 | /** | 47 | /** |
48 | * We've received a PING. If appropriate, generate a PONG. | ||
48 | * | 49 | * |
50 | * @param sender peer sending the PING | ||
51 | * @param hdr the PING | ||
52 | * @param plugin_name name of plugin that received the PING | ||
53 | * @param sender_address address of the sender as known to the plugin, NULL | ||
54 | * if we did not initiate the connection | ||
55 | * @param sender_address_len number of bytes in sender_address | ||
49 | */ | 56 | */ |
50 | int | 57 | void |
51 | GST_validation_handle_ping (const struct GNUNET_PeerIdentity *sender, | 58 | GST_validation_handle_ping (const struct GNUNET_PeerIdentity *sender, |
52 | const struct GNUNET_MessageHeader *hdr, | 59 | const struct GNUNET_MessageHeader *hdr, |
53 | const char *plugin_name, | 60 | const char *plugin_name, |
54 | const void *sender_address, | 61 | const void *sender_address, |
55 | size_t sender_address_len); | 62 | size_t sender_address_len); |
56 | 63 | ||
64 | |||
57 | /** | 65 | /** |
66 | * We've received a PONG. Check if it matches a pending PING and | ||
67 | * mark the respective address as confirmed. | ||
58 | * | 68 | * |
69 | * @param sender peer sending the PONG | ||
70 | * @param hdr the PONG | ||
71 | * @param plugin_name name of plugin that received the PONG | ||
72 | * @param sender_address address of the sender as known to the plugin, NULL | ||
73 | * if we did not initiate the connection | ||
74 | * @param sender_address_len number of bytes in sender_address | ||
59 | */ | 75 | */ |
60 | int | 76 | void |
61 | GST_validation_handle_pong (const struct GNUNET_PeerIdentity *sender, | 77 | GST_validation_handle_pong (const struct GNUNET_PeerIdentity *sender, |
62 | const struct GNUNET_MessageHeader *hdr, | 78 | const struct GNUNET_MessageHeader *hdr, |
63 | const char *plugin_name, | 79 | const char *plugin_name, |
@@ -66,21 +82,36 @@ GST_validation_handle_pong (const struct GNUNET_PeerIdentity *sender, | |||
66 | 82 | ||
67 | 83 | ||
68 | /** | 84 | /** |
85 | * We've received a HELLO, check which addresses are new and trigger | ||
86 | * validation. | ||
69 | * | 87 | * |
88 | * @param hello the HELLO we received | ||
70 | */ | 89 | */ |
71 | void | 90 | void |
72 | GST_validation_handle_hello (const struct GNUNET_MessageHeader *hello); | 91 | GST_validation_handle_hello (const struct GNUNET_MessageHeader *hello); |
73 | 92 | ||
74 | 93 | ||
94 | /** | ||
95 | * Opaque handle to stop incremental validation address callbacks. | ||
96 | */ | ||
75 | struct GST_ValidationIteratorContext; | 97 | struct GST_ValidationIteratorContext; |
76 | 98 | ||
99 | |||
77 | /** | 100 | /** |
101 | * Function called for each address (or address status change) that | ||
102 | * the validation module is aware of (for the given target). | ||
103 | * | ||
104 | * @param cls closure | ||
105 | * @param target peer this change is about, never NULL | ||
78 | * @param last_validated_at is FOREVER if the address has not been validated (we're currently checking) | 106 | * @param last_validated_at is FOREVER if the address has not been validated (we're currently checking) |
79 | * is ZERO if the address was validated a long time ago (from PEERINFO) | 107 | * is ZERO if the address was validated a long time ago (from PEERINFO) |
80 | * is a time in the past if this process validated the address | 108 | * is a time in the past if this process validated the address |
81 | * @param validation_block is FOREVER if the address is for an unsupported plugin (from PEERINFO) | 109 | * @param validation_block is FOREVER if the address is for an unsupported plugin (from PEERINFO) |
82 | * is ZERO if the address is considered valid (no validation needed) | 110 | * is ZERO if the address is considered valid (no validation needed) |
83 | * is a time in the future if we're currently denying re-validation | 111 | * is a time in the future if we're currently denying re-validation |
112 | * @param plugin_name name of the plugin | ||
113 | * @param plugin_address binary address | ||
114 | * @param plugin_address_len length of address | ||
84 | */ | 115 | */ |
85 | typedef void (*GST_ValidationAddressCallback)(void *cls, | 116 | typedef void (*GST_ValidationAddressCallback)(void *cls, |
86 | const struct GNUNET_PeerIdentity *target, | 117 | const struct GNUNET_PeerIdentity *target, |
@@ -90,13 +121,31 @@ typedef void (*GST_ValidationAddressCallback)(void *cls, | |||
90 | const void *plugin_address, | 121 | const void *plugin_address, |
91 | size_t plugin_address_len); | 122 | size_t plugin_address_len); |
92 | 123 | ||
124 | |||
125 | /** | ||
126 | * Call the given function for each address for the given target. | ||
127 | * Can either give a snapshot (synchronous API) or be continuous. | ||
128 | * | ||
129 | * @param target peer information is requested for | ||
130 | * @param snapshot_only GNUNET_YES to iterate over addresses once, GNUNET_NO to | ||
131 | * continue to give information about addresses as it evolves | ||
132 | * @param cb function to call; will not be called after this function returns | ||
133 | * if snapshot_only is GNUNET_YES | ||
134 | * @param cb_cls closure for 'cb' | ||
135 | * @return context to cancel, NULL if 'snapshot_only' is GNUNET_YES | ||
136 | */ | ||
93 | struct GST_ValidationIteratorContext * | 137 | struct GST_ValidationIteratorContext * |
94 | GST_validation_get_addresses (const struct GNUNET_PeerIdentity *target, | 138 | GST_validation_get_addresses (const struct GNUNET_PeerIdentity *target, |
139 | int snapshot_only, | ||
95 | GST_ValidationAddressCallback cb, | 140 | GST_ValidationAddressCallback cb, |
96 | void *cb_cls); | 141 | void *cb_cls); |
97 | 142 | ||
98 | 143 | ||
99 | 144 | /** | |
145 | * Cancel an active validation address iteration. | ||
146 | * | ||
147 | * @param ctx the context of the operation that is cancelled | ||
148 | */ | ||
100 | void | 149 | void |
101 | GST_validation_get_addresses_cancel (struct GST_ValidationIteratorContext *ctx); | 150 | GST_validation_get_addresses_cancel (struct GST_ValidationIteratorContext *ctx); |
102 | 151 | ||
diff --git a/src/transport/transport.h b/src/transport/transport.h index 5384e7395..4d1d370d9 100644 --- a/src/transport/transport.h +++ b/src/transport/transport.h | |||
@@ -322,6 +322,7 @@ struct AddressLookupMessage | |||
322 | followed by the 0-terminated name of the transport */ | 322 | followed by the 0-terminated name of the transport */ |
323 | }; | 323 | }; |
324 | 324 | ||
325 | |||
325 | /** | 326 | /** |
326 | * Message from the library to the transport service | 327 | * Message from the library to the transport service |
327 | * asking for human readable addresses known for a peer. | 328 | * asking for human readable addresses known for a peer. |
@@ -334,9 +335,14 @@ struct PeerAddressLookupMessage | |||
334 | struct GNUNET_MessageHeader header; | 335 | struct GNUNET_MessageHeader header; |
335 | 336 | ||
336 | /** | 337 | /** |
337 | * timeout to give up. | 338 | * For alignment. |
338 | */ | 339 | */ |
339 | struct GNUNET_TIME_AbsoluteNBO timeout; | 340 | uint32_t reserved; |
341 | |||
342 | /** | ||
343 | * timeout to give up. FIXME: remove in the future. | ||
344 | */ | ||
345 | struct GNUNET_TIME_RelativeNBO timeout; | ||
340 | 346 | ||
341 | /** | 347 | /** |
342 | * The identity of the peer to look up. | 348 | * The identity of the peer to look up. |
@@ -344,6 +350,7 @@ struct PeerAddressLookupMessage | |||
344 | struct GNUNET_PeerIdentity peer; | 350 | struct GNUNET_PeerIdentity peer; |
345 | }; | 351 | }; |
346 | 352 | ||
353 | |||
347 | /** | 354 | /** |
348 | * Message from the library to the transport service | 355 | * Message from the library to the transport service |
349 | * asking for human readable addresses known for a peer. | 356 | * asking for human readable addresses known for a peer. |
@@ -356,11 +363,17 @@ struct AddressIterateMessage | |||
356 | struct GNUNET_MessageHeader header; | 363 | struct GNUNET_MessageHeader header; |
357 | 364 | ||
358 | /** | 365 | /** |
359 | * timeout to give up. | 366 | * For alignment. |
367 | */ | ||
368 | uint32_t reserved; | ||
369 | |||
370 | /** | ||
371 | * timeout to give up. FIXME: remove in the future | ||
360 | */ | 372 | */ |
361 | struct GNUNET_TIME_AbsoluteNBO timeout; | 373 | struct GNUNET_TIME_AbsoluteNBO timeout; |
362 | }; | 374 | }; |
363 | 375 | ||
376 | |||
364 | /** | 377 | /** |
365 | * Change in blacklisting (either request or notification, | 378 | * Change in blacklisting (either request or notification, |
366 | * depending on which direction it is going). | 379 | * depending on which direction it is going). |
diff --git a/src/transport/transport_api_peer_address_lookup.c b/src/transport/transport_api_peer_address_lookup.c index 2da4b6c69..c63856d4a 100644 --- a/src/transport/transport_api_peer_address_lookup.c +++ b/src/transport/transport_api_peer_address_lookup.c | |||
@@ -134,7 +134,6 @@ GNUNET_TRANSPORT_peer_address_lookup (const struct GNUNET_CONFIGURATION_Handle * | |||
134 | void *peer_address_callback_cls) | 134 | void *peer_address_callback_cls) |
135 | { | 135 | { |
136 | struct PeerAddressLookupMessage msg; | 136 | struct PeerAddressLookupMessage msg; |
137 | struct GNUNET_TIME_Absolute abs_timeout; | ||
138 | struct AddressLookupCtx *peer_address_lookup_cb; | 137 | struct AddressLookupCtx *peer_address_lookup_cb; |
139 | struct GNUNET_CLIENT_Connection *client; | 138 | struct GNUNET_CLIENT_Connection *client; |
140 | 139 | ||
@@ -144,16 +143,14 @@ GNUNET_TRANSPORT_peer_address_lookup (const struct GNUNET_CONFIGURATION_Handle * | |||
144 | peer_address_callback (peer_address_callback_cls, NULL); | 143 | peer_address_callback (peer_address_callback_cls, NULL); |
145 | return; | 144 | return; |
146 | } | 145 | } |
147 | abs_timeout = GNUNET_TIME_relative_to_absolute (timeout); | ||
148 | |||
149 | msg.header.size = htons (sizeof(struct PeerAddressLookupMessage)); | 146 | msg.header.size = htons (sizeof(struct PeerAddressLookupMessage)); |
150 | msg.header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_PEER_ADDRESS_LOOKUP); | 147 | msg.header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_PEER_ADDRESS_LOOKUP); |
151 | msg.timeout = GNUNET_TIME_absolute_hton (abs_timeout); | 148 | msg.timeout = GNUNET_TIME_relative_hton (timeout); |
152 | memcpy(&msg.peer, peer, sizeof(struct GNUNET_PeerIdentity)); | 149 | memcpy(&msg.peer, peer, sizeof(struct GNUNET_PeerIdentity)); |
153 | peer_address_lookup_cb = GNUNET_malloc (sizeof (struct AddressLookupCtx)); | 150 | peer_address_lookup_cb = GNUNET_malloc (sizeof (struct AddressLookupCtx)); |
154 | peer_address_lookup_cb->cb = peer_address_callback; | 151 | peer_address_lookup_cb->cb = peer_address_callback; |
155 | peer_address_lookup_cb->cb_cls = peer_address_callback_cls; | 152 | peer_address_lookup_cb->cb_cls = peer_address_callback_cls; |
156 | peer_address_lookup_cb->timeout = abs_timeout; | 153 | peer_address_lookup_cb->timeout = GNUNET_TIME_relative_to_absolute (timeout); |
157 | peer_address_lookup_cb->client = client; | 154 | peer_address_lookup_cb->client = client; |
158 | GNUNET_assert (GNUNET_OK == | 155 | GNUNET_assert (GNUNET_OK == |
159 | GNUNET_CLIENT_transmit_and_get_response (client, | 156 | GNUNET_CLIENT_transmit_and_get_response (client, |