diff options
Diffstat (limited to 'src')
28 files changed, 330 insertions, 407 deletions
diff --git a/src/abd/abd_api.c b/src/abd/abd_api.c index 57f831e85..0b3b4f61f 100644 --- a/src/abd/abd_api.c +++ b/src/abd/abd_api.c | |||
@@ -26,7 +26,6 @@ | |||
26 | #include "gnunet_util_lib.h" | 26 | #include "gnunet_util_lib.h" |
27 | #include "gnunet_constants.h" | 27 | #include "gnunet_constants.h" |
28 | #include "gnunet_arm_service.h" | 28 | #include "gnunet_arm_service.h" |
29 | #include "gnunet_hello_lib.h" | ||
30 | #include "gnunet_protocols.h" | 29 | #include "gnunet_protocols.h" |
31 | #include "gnunet_signatures.h" | 30 | #include "gnunet_signatures.h" |
32 | #include "abd.h" | 31 | #include "abd.h" |
diff --git a/src/cadet/Makefile.am b/src/cadet/Makefile.am index 6cd4b812d..dec43b516 100644 --- a/src/cadet/Makefile.am +++ b/src/cadet/Makefile.am | |||
@@ -69,7 +69,7 @@ gnunet_service_cadet_LDADD = \ | |||
69 | $(top_builddir)/src/dht/libgnunetdht.la \ | 69 | $(top_builddir)/src/dht/libgnunetdht.la \ |
70 | $(top_builddir)/src/statistics/libgnunetstatistics.la \ | 70 | $(top_builddir)/src/statistics/libgnunetstatistics.la \ |
71 | $(top_builddir)/src/transport/libgnunettransportapplication.la \ | 71 | $(top_builddir)/src/transport/libgnunettransportapplication.la \ |
72 | $(top_builddir)/src/peerinfo/libgnunetpeerinfo.la \ | 72 | $(top_builddir)/src/peerstore/libgnunetpeerstore.la \ |
73 | $(top_builddir)/src/hello/libgnunethello.la \ | 73 | $(top_builddir)/src/hello/libgnunethello.la \ |
74 | $(top_builddir)/src/block/libgnunetblock.la | 74 | $(top_builddir)/src/block/libgnunetblock.la |
75 | if LINUX | 75 | if LINUX |
diff --git a/src/cadet/gnunet-service-cadet_hello.c b/src/cadet/gnunet-service-cadet_hello.c index e1850d60a..7a33b0e05 100644 --- a/src/cadet/gnunet-service-cadet_hello.c +++ b/src/cadet/gnunet-service-cadet_hello.c | |||
@@ -26,9 +26,8 @@ | |||
26 | */ | 26 | */ |
27 | #include "platform.h" | 27 | #include "platform.h" |
28 | #include "gnunet_util_lib.h" | 28 | #include "gnunet_util_lib.h" |
29 | |||
30 | #include "gnunet_statistics_service.h" | 29 | #include "gnunet_statistics_service.h" |
31 | #include "gnunet_peerinfo_service.h" | 30 | #include "gnunet_peerstore_service.h" |
32 | #include "cadet_protocol.h" | 31 | #include "cadet_protocol.h" |
33 | #include "gnunet-service-cadet.h" | 32 | #include "gnunet-service-cadet.h" |
34 | #include "gnunet-service-cadet_dht.h" | 33 | #include "gnunet-service-cadet_dht.h" |
@@ -40,17 +39,18 @@ | |||
40 | /** | 39 | /** |
41 | * Hello message of local peer. | 40 | * Hello message of local peer. |
42 | */ | 41 | */ |
43 | static struct GNUNET_HELLO_Message *mine; | 42 | static struct GNUNET_MessageHeader *mine; |
44 | 43 | ||
45 | /** | 44 | /** |
46 | * Handle to peerinfo service. | 45 | * Handle to the PEERSTORE service. |
47 | */ | 46 | */ |
48 | static struct GNUNET_PEERINFO_Handle *peerinfo; | 47 | static struct GNUNET_PEERSTORE_Handle *peerstore; |
49 | 48 | ||
50 | /** | 49 | /** |
51 | * Iterator context. | 50 | * Our peerstore notification context. We use notification |
51 | * to instantly learn about new peers as they are discovered. | ||
52 | */ | 52 | */ |
53 | static struct GNUNET_PEERINFO_NotifyContext *nc; | 53 | static struct GNUNET_PEERSTORE_NotifyContext *peerstore_notify; |
54 | 54 | ||
55 | 55 | ||
56 | /** | 56 | /** |
@@ -64,10 +64,11 @@ static struct GNUNET_PEERINFO_NotifyContext *nc; | |||
64 | static void | 64 | static void |
65 | got_hello (void *cls, | 65 | got_hello (void *cls, |
66 | const struct GNUNET_PeerIdentity *id, | 66 | const struct GNUNET_PeerIdentity *id, |
67 | const struct GNUNET_HELLO_Message *hello, | 67 | const struct GNUNET_MessageHeader *hello, |
68 | const char *err_msg) | 68 | const char *err_msg) |
69 | { | 69 | { |
70 | struct CadetPeer *peer; | 70 | struct CadetPeer *peer; |
71 | struct GNUNET_HELLO_Builder *builder = GNUNET_HELLO_builder_from_msg (hello); | ||
71 | 72 | ||
72 | if ((NULL == id) || | 73 | if ((NULL == id) || |
73 | (NULL == hello)) | 74 | (NULL == hello)) |
@@ -76,21 +77,23 @@ got_hello (void *cls, | |||
76 | &my_full_id)) | 77 | &my_full_id)) |
77 | { | 78 | { |
78 | GNUNET_free (mine); | 79 | GNUNET_free (mine); |
79 | mine = (struct GNUNET_HELLO_Message *) GNUNET_copy_message (&hello->header); | 80 | mine = GNUNET_copy_message (hello); |
80 | GCD_hello_update (); | 81 | GCD_hello_update (); |
81 | return; | 82 | return; |
82 | } | 83 | } |
83 | 84 | ||
84 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 85 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
85 | "Hello for %s (%d bytes), expires on %s\n", | 86 | "Hello for %s (%d bytes), expires on %s\n", |
86 | GNUNET_i2s (id), | 87 | GNUNET_i2s (id), |
87 | GNUNET_HELLO_size (hello), | 88 | sizeof (hello), |
88 | GNUNET_STRINGS_absolute_time_to_string ( | 89 | GNUNET_STRINGS_absolute_time_to_string ( |
89 | GNUNET_HELLO_get_last_expiration (hello))); | 90 | GNUNET_HELLO_builder_get_expiration_time (builder, |
91 | hello))); | ||
90 | peer = GCP_get (id, | 92 | peer = GCP_get (id, |
91 | GNUNET_YES); | 93 | GNUNET_YES); |
92 | GCP_set_hello (peer, | 94 | GCP_set_hello (peer, |
93 | hello); | 95 | hello); |
96 | GNUNET_HELLO_builder_free (builder); | ||
94 | } | 97 | } |
95 | 98 | ||
96 | 99 | ||
@@ -102,12 +105,11 @@ got_hello (void *cls, | |||
102 | void | 105 | void |
103 | GCH_init (const struct GNUNET_CONFIGURATION_Handle *c) | 106 | GCH_init (const struct GNUNET_CONFIGURATION_Handle *c) |
104 | { | 107 | { |
105 | GNUNET_assert (NULL == nc); | 108 | GNUNET_assert (NULL == peerstore_notify); |
106 | peerinfo = GNUNET_PEERINFO_connect (c); | 109 | peerstore = GNUNET_PEERSTORE_connect (c); |
107 | nc = GNUNET_PEERINFO_notify (c, | 110 | peerstore_notify = |
108 | GNUNET_NO, | 111 | GNUNET_PEERSTORE_hello_changed_notify (peerstore, GNUNET_NO, &got_hello, |
109 | &got_hello, | 112 | NULL); |
110 | NULL); | ||
111 | } | 113 | } |
112 | 114 | ||
113 | 115 | ||
@@ -117,15 +119,15 @@ GCH_init (const struct GNUNET_CONFIGURATION_Handle *c) | |||
117 | void | 119 | void |
118 | GCH_shutdown () | 120 | GCH_shutdown () |
119 | { | 121 | { |
120 | if (NULL != nc) | 122 | if (NULL != peerstore_notify) |
121 | { | 123 | { |
122 | GNUNET_PEERINFO_notify_cancel (nc); | 124 | GNUNET_PEERSTORE_hello_changed_notify_cancel (peerstore_notify); |
123 | nc = NULL; | 125 | peerstore_notify = NULL; |
124 | } | 126 | } |
125 | if (NULL != peerinfo) | 127 | if (NULL != peerstore) |
126 | { | 128 | { |
127 | GNUNET_PEERINFO_disconnect (peerinfo); | 129 | GNUNET_PEERSTORE_disconnect (peerstore, GNUNET_YES); |
128 | peerinfo = NULL; | 130 | peerstore = NULL; |
129 | } | 131 | } |
130 | if (NULL != mine) | 132 | if (NULL != mine) |
131 | { | 133 | { |
@@ -140,7 +142,7 @@ GCH_shutdown () | |||
140 | * | 142 | * |
141 | * @return Own hello message. | 143 | * @return Own hello message. |
142 | */ | 144 | */ |
143 | const struct GNUNET_HELLO_Message * | 145 | const struct GNUNET_MessageHeader * |
144 | GCH_get_mine (void) | 146 | GCH_get_mine (void) |
145 | { | 147 | { |
146 | return mine; | 148 | return mine; |
diff --git a/src/cadet/gnunet-service-cadet_hello.h b/src/cadet/gnunet-service-cadet_hello.h index 2cb444b4a..88c955bb9 100644 --- a/src/cadet/gnunet-service-cadet_hello.h +++ b/src/cadet/gnunet-service-cadet_hello.h | |||
@@ -40,7 +40,7 @@ extern "C" | |||
40 | 40 | ||
41 | #include "platform.h" | 41 | #include "platform.h" |
42 | #include "gnunet_util_lib.h" | 42 | #include "gnunet_util_lib.h" |
43 | #include "gnunet_hello_lib.h" | 43 | #include "gnunet_hello_uri_lib.h" |
44 | 44 | ||
45 | 45 | ||
46 | /** | 46 | /** |
@@ -64,7 +64,7 @@ GCH_shutdown (void); | |||
64 | * | 64 | * |
65 | * @return Own hello message. | 65 | * @return Own hello message. |
66 | */ | 66 | */ |
67 | const struct GNUNET_HELLO_Message * | 67 | const struct GNUNET_MessageHeader * |
68 | GCH_get_mine (void); | 68 | GCH_get_mine (void); |
69 | 69 | ||
70 | 70 | ||
diff --git a/src/cadet/gnunet-service-cadet_peer.c b/src/cadet/gnunet-service-cadet_peer.c index 6d6288e8d..c46e968dc 100644 --- a/src/cadet/gnunet-service-cadet_peer.c +++ b/src/cadet/gnunet-service-cadet_peer.c | |||
@@ -33,7 +33,7 @@ | |||
33 | #include "platform.h" | 33 | #include "platform.h" |
34 | #include "gnunet_time_lib.h" | 34 | #include "gnunet_time_lib.h" |
35 | #include "gnunet_util_lib.h" | 35 | #include "gnunet_util_lib.h" |
36 | #include "gnunet_hello_lib.h" | 36 | #include "gnunet_hello_uri_lib.h" |
37 | #include "gnunet_signatures.h" | 37 | #include "gnunet_signatures.h" |
38 | #include "gnunet_transport_application_service.h" | 38 | #include "gnunet_transport_application_service.h" |
39 | #include "gnunet_ats_service.h" | 39 | #include "gnunet_ats_service.h" |
@@ -186,7 +186,7 @@ struct CadetPeer | |||
186 | /** | 186 | /** |
187 | * Hello message of the peer. | 187 | * Hello message of the peer. |
188 | */ | 188 | */ |
189 | struct GNUNET_HELLO_Message *hello; | 189 | struct GNUNET_MessageHeader *hello; |
190 | 190 | ||
191 | /** | 191 | /** |
192 | * Handle to us offering the HELLO to the transport. | 192 | * Handle to us offering the HELLO to the transport. |
@@ -491,12 +491,15 @@ consider_peer_destroy (struct CadetPeer *cp) | |||
491 | return; /* still relevant! */ | 491 | return; /* still relevant! */ |
492 | if (NULL != cp->hello) | 492 | if (NULL != cp->hello) |
493 | { | 493 | { |
494 | struct GNUNET_HELLO_Builder *builder = GNUNET_HELLO_builder_from_msg (cp->hello); | ||
495 | |||
494 | /* relevant only until HELLO expires */ | 496 | /* relevant only until HELLO expires */ |
495 | exp = GNUNET_TIME_absolute_get_remaining (GNUNET_HELLO_get_last_expiration ( | 497 | exp = GNUNET_TIME_absolute_get_remaining (GNUNET_HELLO_builder_get_expiration_time (builder, |
496 | cp->hello)); | 498 | cp->hello)); |
497 | cp->destroy_task = GNUNET_SCHEDULER_add_delayed (exp, | 499 | cp->destroy_task = GNUNET_SCHEDULER_add_delayed (exp, |
498 | &destroy_peer, | 500 | &destroy_peer, |
499 | cp); | 501 | cp); |
502 | GNUNET_HELLO_builder_free (builder); | ||
500 | return; | 503 | return; |
501 | } | 504 | } |
502 | cp->destroy_task = GNUNET_SCHEDULER_add_delayed (IDLE_PEER_TIMEOUT, | 505 | cp->destroy_task = GNUNET_SCHEDULER_add_delayed (IDLE_PEER_TIMEOUT, |
@@ -1307,26 +1310,43 @@ GCP_get_tunnel (struct CadetPeer *cp, | |||
1307 | 1310 | ||
1308 | void | 1311 | void |
1309 | GCP_set_hello (struct CadetPeer *cp, | 1312 | GCP_set_hello (struct CadetPeer *cp, |
1310 | const struct GNUNET_HELLO_Message *hello) | 1313 | const struct GNUNET_MessageHeader *hello) |
1311 | { | 1314 | { |
1312 | struct GNUNET_HELLO_Message *mrg; | 1315 | struct GNUNET_HELLO_Message *mrg; |
1313 | struct GNUNET_BANDWIDTH_Value32NBO bw; | 1316 | struct GNUNET_BANDWIDTH_Value32NBO bw; |
1317 | uint16_t size = sizeof (hello); | ||
1314 | 1318 | ||
1315 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 1319 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
1316 | "Got %u byte HELLO for peer %s\n", | 1320 | "Got %u byte HELLO for peer %s\n", |
1317 | (unsigned int) GNUNET_HELLO_size (hello), | 1321 | (unsigned int) size, |
1318 | GCP_2s (cp)); | 1322 | GCP_2s (cp)); |
1319 | if (NULL != cp->hello) | 1323 | if (NULL != cp->hello) |
1320 | { | 1324 | { |
1321 | mrg = GNUNET_HELLO_merge (hello, | 1325 | struct GNUNET_TIME_Absolute now = GNUNET_TIME_absolute_get (); |
1322 | cp->hello); | 1326 | struct GNUNET_HELLO_Builder *builder = GNUNET_HELLO_builder_from_msg (hello); |
1323 | GNUNET_free (cp->hello); | 1327 | struct GNUNET_HELLO_Builder *cp_builder = GNUNET_HELLO_builder_from_msg (cp->hello); |
1324 | cp->hello = mrg; | 1328 | struct GNUNET_TIME_Absolute new_hello_exp = GNUNET_HELLO_builder_get_expiration_time (builder, |
1329 | hello); | ||
1330 | struct GNUNET_TIME_Absolute old_hello_exp = GNUNET_HELLO_builder_get_expiration_time (cp_builder, | ||
1331 | cp->hello); | ||
1332 | |||
1333 | if (GNUNET_TIME_absolute_cmp (new_hello_exp, > , now) && GNUNET_TIME_absolute_cmp (new_hello_exp, > , old_hello_exp)) | ||
1334 | { | ||
1335 | GNUNET_free (cp->hello); | ||
1336 | cp->hello = GNUNET_malloc (size); | ||
1337 | GNUNET_memcpy (cp->hello, hello, size); | ||
1338 | } | ||
1339 | else | ||
1340 | { | ||
1341 | return; | ||
1342 | } | ||
1343 | GNUNET_HELLO_builder_free (builder); | ||
1344 | GNUNET_HELLO_builder_free (cp_builder); | ||
1325 | } | 1345 | } |
1326 | else | 1346 | else |
1327 | { | 1347 | { |
1328 | cp->hello = GNUNET_memdup (hello, | 1348 | cp->hello = GNUNET_memdup (hello, |
1329 | GNUNET_HELLO_size (hello)); | 1349 | size); |
1330 | } | 1350 | } |
1331 | if (NULL != cp->ash) | 1351 | if (NULL != cp->ash) |
1332 | GNUNET_TRANSPORT_application_suggest_cancel (cp->ash); | 1352 | GNUNET_TRANSPORT_application_suggest_cancel (cp->ash); |
diff --git a/src/cadet/gnunet-service-cadet_peer.h b/src/cadet/gnunet-service-cadet_peer.h index 69436d766..4c5ad4252 100644 --- a/src/cadet/gnunet-service-cadet_peer.h +++ b/src/cadet/gnunet-service-cadet_peer.h | |||
@@ -28,7 +28,7 @@ | |||
28 | #define GNUNET_SERVICE_CADET_PEER_H | 28 | #define GNUNET_SERVICE_CADET_PEER_H |
29 | 29 | ||
30 | #include "gnunet-service-cadet.h" | 30 | #include "gnunet-service-cadet.h" |
31 | #include "gnunet_hello_lib.h" | 31 | #include "gnunet_util_lib.h" |
32 | 32 | ||
33 | 33 | ||
34 | /** | 34 | /** |
@@ -292,7 +292,7 @@ GCP_remove_connection (struct CadetPeer *cp, | |||
292 | */ | 292 | */ |
293 | void | 293 | void |
294 | GCP_set_hello (struct CadetPeer *cp, | 294 | GCP_set_hello (struct CadetPeer *cp, |
295 | const struct GNUNET_HELLO_Message *hello); | 295 | const struct GNUNET_MessageHeader *hello); |
296 | 296 | ||
297 | 297 | ||
298 | /** | 298 | /** |
diff --git a/src/dht/dht_api.c b/src/dht/dht_api.c index e31ac596c..62a8dd0fd 100644 --- a/src/dht/dht_api.c +++ b/src/dht/dht_api.c | |||
@@ -26,7 +26,6 @@ | |||
26 | */ | 26 | */ |
27 | 27 | ||
28 | #include "platform.h" | 28 | #include "platform.h" |
29 | #include "gnunet_util_lib.h" | ||
30 | #include "gnunet_constants.h" | 29 | #include "gnunet_constants.h" |
31 | #include "gnunet_signatures.h" | 30 | #include "gnunet_signatures.h" |
32 | #include "gnunet_arm_service.h" | 31 | #include "gnunet_arm_service.h" |
diff --git a/src/dht/gnunet-service-dht.c b/src/dht/gnunet-service-dht.c index 0766bea62..c3ce2f284 100644 --- a/src/dht/gnunet-service-dht.c +++ b/src/dht/gnunet-service-dht.c | |||
@@ -27,7 +27,6 @@ | |||
27 | #include "platform.h" | 27 | #include "platform.h" |
28 | #include "gnunet_block_lib.h" | 28 | #include "gnunet_block_lib.h" |
29 | #include "gnunet_util_lib.h" | 29 | #include "gnunet_util_lib.h" |
30 | #include "gnunet_hello_lib.h" | ||
31 | #include "gnunet_hello_uri_lib.h" | 30 | #include "gnunet_hello_uri_lib.h" |
32 | #include "gnunet_dht_service.h" | 31 | #include "gnunet_dht_service.h" |
33 | #include "gnunet_statistics_service.h" | 32 | #include "gnunet_statistics_service.h" |
diff --git a/src/dht/gnunet-service-dht_neighbours.c b/src/dht/gnunet-service-dht_neighbours.c index b0a71de95..e3a9bd3a1 100644 --- a/src/dht/gnunet-service-dht_neighbours.c +++ b/src/dht/gnunet-service-dht_neighbours.c | |||
@@ -28,7 +28,6 @@ | |||
28 | #include "gnunet_constants.h" | 28 | #include "gnunet_constants.h" |
29 | #include "gnunet_protocols.h" | 29 | #include "gnunet_protocols.h" |
30 | #include "gnunet_signatures.h" | 30 | #include "gnunet_signatures.h" |
31 | #include "gnunet_hello_lib.h" | ||
32 | #include "gnunet_hello_uri_lib.h" | 31 | #include "gnunet_hello_uri_lib.h" |
33 | #include "gnunet-service-dht.h" | 32 | #include "gnunet-service-dht.h" |
34 | #include "gnunet-service-dht_neighbours.h" | 33 | #include "gnunet-service-dht_neighbours.h" |
diff --git a/src/dht/plugin_block_dht.c b/src/dht/plugin_block_dht.c index 6375fa272..aa5ffc719 100644 --- a/src/dht/plugin_block_dht.c +++ b/src/dht/plugin_block_dht.c | |||
@@ -27,7 +27,6 @@ | |||
27 | */ | 27 | */ |
28 | #include "platform.h" | 28 | #include "platform.h" |
29 | #include "gnunet_constants.h" | 29 | #include "gnunet_constants.h" |
30 | #include "gnunet_hello_lib.h" | ||
31 | #include "gnunet_hello_uri_lib.h" | 30 | #include "gnunet_hello_uri_lib.h" |
32 | #include "gnunet_block_plugin.h" | 31 | #include "gnunet_block_plugin.h" |
33 | #include "gnunet_block_group_lib.h" | 32 | #include "gnunet_block_group_lib.h" |
@@ -105,13 +104,6 @@ block_plugin_dht_check_query (void *cls, | |||
105 | { | 104 | { |
106 | switch (type) | 105 | switch (type) |
107 | { | 106 | { |
108 | case GNUNET_BLOCK_TYPE_LEGACY_HELLO: | ||
109 | if (0 != xquery_size) | ||
110 | { | ||
111 | GNUNET_break_op (0); | ||
112 | return GNUNET_NO; | ||
113 | } | ||
114 | return GNUNET_OK; | ||
115 | case GNUNET_BLOCK_TYPE_DHT_HELLO: | 107 | case GNUNET_BLOCK_TYPE_DHT_HELLO: |
116 | if (0 != xquery_size) | 108 | if (0 != xquery_size) |
117 | { | 109 | { |
@@ -143,33 +135,6 @@ block_plugin_dht_check_block (void *cls, | |||
143 | { | 135 | { |
144 | switch (type) | 136 | switch (type) |
145 | { | 137 | { |
146 | case GNUNET_BLOCK_TYPE_LEGACY_HELLO: | ||
147 | { | ||
148 | const struct GNUNET_HELLO_Message *hello; | ||
149 | struct GNUNET_PeerIdentity pid; | ||
150 | const struct GNUNET_MessageHeader *msg; | ||
151 | |||
152 | if (block_size < sizeof(struct GNUNET_MessageHeader)) | ||
153 | { | ||
154 | GNUNET_break_op (0); | ||
155 | return GNUNET_NO; | ||
156 | } | ||
157 | msg = block; | ||
158 | if (block_size != ntohs (msg->size)) | ||
159 | { | ||
160 | GNUNET_break_op (0); | ||
161 | return GNUNET_NO; | ||
162 | } | ||
163 | hello = block; | ||
164 | if (GNUNET_OK != | ||
165 | GNUNET_HELLO_get_id (hello, | ||
166 | &pid)) | ||
167 | { | ||
168 | GNUNET_break_op (0); | ||
169 | return GNUNET_NO; | ||
170 | } | ||
171 | return GNUNET_OK; | ||
172 | } | ||
173 | case GNUNET_BLOCK_TYPE_DHT_HELLO: | 138 | case GNUNET_BLOCK_TYPE_DHT_HELLO: |
174 | { | 139 | { |
175 | struct GNUNET_HELLO_Builder *b; | 140 | struct GNUNET_HELLO_Builder *b; |
@@ -228,28 +193,6 @@ block_plugin_dht_check_reply ( | |||
228 | { | 193 | { |
229 | switch (type) | 194 | switch (type) |
230 | { | 195 | { |
231 | case GNUNET_BLOCK_TYPE_LEGACY_HELLO: | ||
232 | { | ||
233 | /* LEGACY */ | ||
234 | const struct GNUNET_MessageHeader *msg = reply_block; | ||
235 | const struct GNUNET_HELLO_Message *hello = reply_block; | ||
236 | struct GNUNET_PeerIdentity pid; | ||
237 | struct GNUNET_HashCode phash; | ||
238 | |||
239 | GNUNET_assert (reply_block_size >= sizeof(struct GNUNET_MessageHeader)); | ||
240 | GNUNET_assert (reply_block_size == ntohs (msg->size)); | ||
241 | GNUNET_assert (GNUNET_OK == | ||
242 | GNUNET_HELLO_get_id (hello, | ||
243 | &pid)); | ||
244 | GNUNET_CRYPTO_hash (&pid, | ||
245 | sizeof(pid), | ||
246 | &phash); | ||
247 | if (GNUNET_YES == | ||
248 | GNUNET_BLOCK_GROUP_bf_test_and_set (group, | ||
249 | &phash)) | ||
250 | return GNUNET_BLOCK_REPLY_OK_DUPLICATE; | ||
251 | return GNUNET_BLOCK_REPLY_OK_MORE; | ||
252 | } | ||
253 | case GNUNET_BLOCK_TYPE_DHT_HELLO: | 196 | case GNUNET_BLOCK_TYPE_DHT_HELLO: |
254 | { | 197 | { |
255 | struct GNUNET_HELLO_Builder *b; | 198 | struct GNUNET_HELLO_Builder *b; |
@@ -298,47 +241,6 @@ block_plugin_dht_get_key (void *cls, | |||
298 | { | 241 | { |
299 | switch (type) | 242 | switch (type) |
300 | { | 243 | { |
301 | case GNUNET_BLOCK_TYPE_LEGACY_HELLO: | ||
302 | { | ||
303 | /* LEGACY */ | ||
304 | const struct GNUNET_MessageHeader *msg; | ||
305 | const struct GNUNET_HELLO_Message *hello; | ||
306 | struct GNUNET_PeerIdentity *pid; | ||
307 | |||
308 | if (block_size < sizeof(struct GNUNET_MessageHeader)) | ||
309 | { | ||
310 | GNUNET_break_op (0); | ||
311 | memset (key, | ||
312 | 0, | ||
313 | sizeof (*key)); | ||
314 | return GNUNET_OK; | ||
315 | } | ||
316 | msg = block; | ||
317 | if (block_size != ntohs (msg->size)) | ||
318 | { | ||
319 | GNUNET_break_op (0); | ||
320 | memset (key, | ||
321 | 0, | ||
322 | sizeof (*key)); | ||
323 | return GNUNET_OK; | ||
324 | } | ||
325 | hello = block; | ||
326 | memset (key, | ||
327 | 0, | ||
328 | sizeof(*key)); | ||
329 | pid = (struct GNUNET_PeerIdentity *) key; | ||
330 | if (GNUNET_OK != | ||
331 | GNUNET_HELLO_get_id (hello, | ||
332 | pid)) | ||
333 | { | ||
334 | GNUNET_break_op (0); | ||
335 | memset (key, | ||
336 | 0, | ||
337 | sizeof (*key)); | ||
338 | return GNUNET_OK; | ||
339 | } | ||
340 | return GNUNET_OK; | ||
341 | } | ||
342 | case GNUNET_BLOCK_TYPE_DHT_HELLO: | 244 | case GNUNET_BLOCK_TYPE_DHT_HELLO: |
343 | { | 245 | { |
344 | struct GNUNET_HELLO_Builder *b; | 246 | struct GNUNET_HELLO_Builder *b; |
@@ -377,7 +279,6 @@ void * | |||
377 | libgnunet_plugin_block_dht_init (void *cls) | 279 | libgnunet_plugin_block_dht_init (void *cls) |
378 | { | 280 | { |
379 | static enum GNUNET_BLOCK_Type types[] = { | 281 | static enum GNUNET_BLOCK_Type types[] = { |
380 | GNUNET_BLOCK_TYPE_LEGACY_HELLO, | ||
381 | GNUNET_BLOCK_TYPE_DHT_HELLO, | 282 | GNUNET_BLOCK_TYPE_DHT_HELLO, |
382 | GNUNET_BLOCK_TYPE_ANY /* end of list */ | 283 | GNUNET_BLOCK_TYPE_ANY /* end of list */ |
383 | }; | 284 | }; |
diff --git a/src/dhtu/Makefile.am b/src/dhtu/Makefile.am index f014b1505..2b0712dcf 100644 --- a/src/dhtu/Makefile.am +++ b/src/dhtu/Makefile.am | |||
@@ -35,7 +35,7 @@ libgnunet_plugin_dhtu_gnunet_la_SOURCES = \ | |||
35 | libgnunet_plugin_dhtu_gnunet_la_LIBADD = \ | 35 | libgnunet_plugin_dhtu_gnunet_la_LIBADD = \ |
36 | $(top_builddir)/src/ats/libgnunetats.la \ | 36 | $(top_builddir)/src/ats/libgnunetats.la \ |
37 | $(top_builddir)/src/core/libgnunetcore.la \ | 37 | $(top_builddir)/src/core/libgnunetcore.la \ |
38 | $(top_builddir)/src/peerinfo/libgnunetpeerinfo.la \ | 38 | $(top_builddir)/src/peerstore/libgnunetpeerstore.la \ |
39 | $(top_builddir)/src/transport/libgnunettransportapplication.la \ | 39 | $(top_builddir)/src/transport/libgnunettransportapplication.la \ |
40 | $(top_builddir)/src/hello/libgnunethello.la \ | 40 | $(top_builddir)/src/hello/libgnunethello.la \ |
41 | $(top_builddir)/src/nse/libgnunetnse.la \ | 41 | $(top_builddir)/src/nse/libgnunetnse.la \ |
diff --git a/src/dhtu/plugin_dhtu_gnunet.c b/src/dhtu/plugin_dhtu_gnunet.c index 6a79e70f3..665db4545 100644 --- a/src/dhtu/plugin_dhtu_gnunet.c +++ b/src/dhtu/plugin_dhtu_gnunet.c | |||
@@ -28,11 +28,10 @@ | |||
28 | #include "gnunet_dhtu_plugin.h" | 28 | #include "gnunet_dhtu_plugin.h" |
29 | #include "gnunet_core_service.h" | 29 | #include "gnunet_core_service.h" |
30 | #include "gnunet_transport_application_service.h" | 30 | #include "gnunet_transport_application_service.h" |
31 | #include "gnunet_hello_lib.h" | 31 | #include "gnunet_hello_uri_lib.h" |
32 | #include "gnunet_peerinfo_service.h" | 32 | #include "gnunet_peerstore_service.h" |
33 | #include "gnunet_nse_service.h" | 33 | #include "gnunet_nse_service.h" |
34 | 34 | ||
35 | |||
36 | /** | 35 | /** |
37 | * Opaque handle that the underlay offers for our address to be used when | 36 | * Opaque handle that the underlay offers for our address to be used when |
38 | * sending messages to another peer. | 37 | * sending messages to another peer. |
@@ -139,6 +138,11 @@ struct Plugin | |||
139 | struct GNUNET_DHTU_PluginEnvironment *env; | 138 | struct GNUNET_DHTU_PluginEnvironment *env; |
140 | 139 | ||
141 | /** | 140 | /** |
141 | * Handle to the PEERSTORE service. | ||
142 | */ | ||
143 | struct GNUNET_PEERSTORE_Handle *peerstore; | ||
144 | |||
145 | /** | ||
142 | * Handle to the CORE service. | 146 | * Handle to the CORE service. |
143 | */ | 147 | */ |
144 | struct GNUNET_CORE_Handle *core; | 148 | struct GNUNET_CORE_Handle *core; |
@@ -154,15 +158,21 @@ struct Plugin | |||
154 | struct GNUNET_NSE_Handle *nse; | 158 | struct GNUNET_NSE_Handle *nse; |
155 | 159 | ||
156 | /** | 160 | /** |
157 | * Watching for our address to change. | 161 | * Our peerstore notification context. We use notification |
162 | * to instantly learn about new peers as they are discovered. | ||
158 | */ | 163 | */ |
159 | struct GNUNET_PEERINFO_NotifyContext *nc; | 164 | struct GNUNET_PEERSTORE_NotifyContext *peerstore_notify; |
160 | 165 | ||
161 | /** | 166 | /** |
162 | * Identity of this peer. | 167 | * Identity of this peer. |
163 | */ | 168 | */ |
164 | struct GNUNET_PeerIdentity my_identity; | 169 | struct GNUNET_PeerIdentity my_identity; |
165 | 170 | ||
171 | /** | ||
172 | * Our private key. | ||
173 | */ | ||
174 | struct GNUNET_CRYPTO_EddsaPrivateKey *my_priv; | ||
175 | |||
166 | }; | 176 | }; |
167 | 177 | ||
168 | 178 | ||
@@ -361,10 +371,11 @@ core_disconnect_cb (void *cls, | |||
361 | static void | 371 | static void |
362 | peerinfo_cb (void *cls, | 372 | peerinfo_cb (void *cls, |
363 | const struct GNUNET_PeerIdentity *peer, | 373 | const struct GNUNET_PeerIdentity *peer, |
364 | const struct GNUNET_HELLO_Message *hello, | 374 | const struct GNUNET_MessageHeader *hello, |
365 | const char *err_msg) | 375 | const char *emsg) |
366 | { | 376 | { |
367 | struct Plugin *plugin = cls; | 377 | struct Plugin *plugin = cls; |
378 | struct GNUNET_HELLO_Builder *builder; | ||
368 | char *addr; | 379 | char *addr; |
369 | 380 | ||
370 | if (NULL == hello) | 381 | if (NULL == hello) |
@@ -375,8 +386,9 @@ peerinfo_cb (void *cls, | |||
375 | GNUNET_memcmp (peer, | 386 | GNUNET_memcmp (peer, |
376 | &plugin->my_identity)) | 387 | &plugin->my_identity)) |
377 | return; | 388 | return; |
378 | addr = GNUNET_HELLO_compose_uri (hello, | 389 | builder = GNUNET_HELLO_builder_from_msg (hello); |
379 | &GPI_plugins_find); | 390 | addr = GNUNET_HELLO_builder_to_url (builder, |
391 | plugin->my_priv); | ||
380 | if (NULL == addr) | 392 | if (NULL == addr) |
381 | return; | 393 | return; |
382 | plugin->env->address_add_cb (plugin->env->cls, | 394 | plugin->env->address_add_cb (plugin->env->cls, |
@@ -384,6 +396,7 @@ peerinfo_cb (void *cls, | |||
384 | &plugin->src, | 396 | &plugin->src, |
385 | &plugin->src.app_ctx); | 397 | &plugin->src.app_ctx); |
386 | GNUNET_free (addr); | 398 | GNUNET_free (addr); |
399 | GNUNET_HELLO_Builder_free (builder); | ||
387 | } | 400 | } |
388 | 401 | ||
389 | 402 | ||
@@ -400,16 +413,17 @@ peerinfo_cb (void *cls, | |||
400 | * @param my_identity ID of this peer, NULL if we failed | 413 | * @param my_identity ID of this peer, NULL if we failed |
401 | */ | 414 | */ |
402 | static void | 415 | static void |
403 | core_init_cb (void *cls, | 416 | core_init_cb (void *cls, |
404 | const struct GNUNET_PeerIdentity *my_identity) | 417 | const struct GNUNET_PeerIdentity *my_identity) |
405 | { | 418 | { |
406 | struct Plugin *plugin = cls; | 419 | struct Plugin *plugin = cls; |
407 | 420 | ||
408 | plugin->my_identity = *my_identity; | 421 | plugin->my_identity = *my_identity; |
409 | plugin->nc = GNUNET_PEERINFO_notify (plugin->env->cfg, | 422 | plugin->peerstore_notify = |
410 | GNUNET_NO, | 423 | GNUNET_PEERSTORE_hello_changed_notify (plugin->peerstore, |
411 | &peerinfo_cb, | 424 | GNUNET_NO, |
412 | plugin); | 425 | &peerinfo_cb, |
426 | plugin); | ||
413 | } | 427 | } |
414 | 428 | ||
415 | 429 | ||
@@ -498,9 +512,12 @@ libgnunet_plugin_dhtu_gnunet_done (void *cls) | |||
498 | GNUNET_CORE_disconnect (plugin->core); | 512 | GNUNET_CORE_disconnect (plugin->core); |
499 | if (NULL != plugin->transport) | 513 | if (NULL != plugin->transport) |
500 | GNUNET_TRANSPORT_application_done (plugin->transport); | 514 | GNUNET_TRANSPORT_application_done (plugin->transport); |
501 | if (NULL != plugin->nc) | 515 | if (NULL != plugin->peerstore_notify) |
502 | GNUNET_PEERINFO_notify_cancel (plugin->nc); | 516 | GNUNET_PEERSTORE_hello_changed_notify_cancel (plugin->peerstore_notify); |
517 | if (NULL != plugin->peerstore) | ||
518 | GNUNET_PEERSTORE_disconnect (peerstore, GNUNET_YES); | ||
503 | GPI_plugins_unload (); | 519 | GPI_plugins_unload (); |
520 | GNUNET_free (plugin->my_priv); | ||
504 | GNUNET_free (plugin); | 521 | GNUNET_free (plugin); |
505 | GNUNET_free (api); | 522 | GNUNET_free (api); |
506 | return NULL; | 523 | return NULL; |
@@ -527,6 +544,7 @@ libgnunet_plugin_dhtu_gnunet_init (void *cls) | |||
527 | GNUNET_MQ_handler_end () | 544 | GNUNET_MQ_handler_end () |
528 | }; | 545 | }; |
529 | 546 | ||
547 | plugin->my_priv = GNUNET_CRYPTO_eddsa_key_create_from_configuration (env->cfg); | ||
530 | plugin = GNUNET_new (struct Plugin); | 548 | plugin = GNUNET_new (struct Plugin); |
531 | plugin->env = env; | 549 | plugin->env = env; |
532 | api = GNUNET_new (struct GNUNET_DHTU_PluginFunctions); | 550 | api = GNUNET_new (struct GNUNET_DHTU_PluginFunctions); |
@@ -535,6 +553,7 @@ libgnunet_plugin_dhtu_gnunet_init (void *cls) | |||
535 | api->hold = &gnunet_hold; | 553 | api->hold = &gnunet_hold; |
536 | api->drop = &gnunet_drop; | 554 | api->drop = &gnunet_drop; |
537 | api->send = &gnunet_send; | 555 | api->send = &gnunet_send; |
556 | plugin->peerstore = GNUNET_PEERSTORE_connect (env->cfg); | ||
538 | plugin->transport = GNUNET_TRANSPORT_application_init (env->cfg); | 557 | plugin->transport = GNUNET_TRANSPORT_application_init (env->cfg); |
539 | plugin->core = GNUNET_CORE_connect (env->cfg, | 558 | plugin->core = GNUNET_CORE_connect (env->cfg, |
540 | plugin, | 559 | plugin, |
diff --git a/src/gns/gns_api.c b/src/gns/gns_api.c index 9e25154ef..2e5ddc2b7 100644 --- a/src/gns/gns_api.c +++ b/src/gns/gns_api.c | |||
@@ -27,7 +27,6 @@ | |||
27 | #include "gnunet_util_lib.h" | 27 | #include "gnunet_util_lib.h" |
28 | #include "gnunet_constants.h" | 28 | #include "gnunet_constants.h" |
29 | #include "gnunet_arm_service.h" | 29 | #include "gnunet_arm_service.h" |
30 | #include "gnunet_hello_lib.h" | ||
31 | #include "gnunet_protocols.h" | 30 | #include "gnunet_protocols.h" |
32 | #include "gnunet_dht_service.h" | 31 | #include "gnunet_dht_service.h" |
33 | #include "gns.h" | 32 | #include "gns.h" |
diff --git a/src/gns/gns_tld_api.c b/src/gns/gns_tld_api.c index c88ce776e..78a70f14e 100644 --- a/src/gns/gns_tld_api.c +++ b/src/gns/gns_tld_api.c | |||
@@ -28,7 +28,6 @@ | |||
28 | #include "gnunet_constants.h" | 28 | #include "gnunet_constants.h" |
29 | #include "gnunet_arm_service.h" | 29 | #include "gnunet_arm_service.h" |
30 | #include "gnunet_identity_service.h" | 30 | #include "gnunet_identity_service.h" |
31 | #include "gnunet_hello_lib.h" | ||
32 | #include "gnunet_protocols.h" | 31 | #include "gnunet_protocols.h" |
33 | #include "gnunet_dht_service.h" | 32 | #include "gnunet_dht_service.h" |
34 | #include "gns.h" | 33 | #include "gns.h" |
diff --git a/src/hello/hello-uri.c b/src/hello/hello-uri.c index 9e8d6909d..fb35ee353 100644 --- a/src/hello/hello-uri.c +++ b/src/hello/hello-uri.c | |||
@@ -445,91 +445,13 @@ GNUNET_HELLO_builder_from_block (const void *block, | |||
445 | } | 445 | } |
446 | 446 | ||
447 | 447 | ||
448 | static void | 448 | struct GNUNET_TIME_Absolute |
449 | merge_hellos2 (void *cls, const char *address_uri2) | 449 | GNUNET_HELLO_builder_get_expiration_time (struct GNUNET_HELLO_Builder *builder, |
450 | { | 450 | const struct GNUNET_MessageHeader *msg) |
451 | struct AddressUriMergeResult *aumr = cls; | ||
452 | const char *address_uri1 = aumr->address_uri; | ||
453 | |||
454 | if (GNUNET_NO == aumr->found && 0 != GNUNET_memcmp (address_uri1, | ||
455 | address_uri2)) | ||
456 | { | ||
457 | aumr->found = GNUNET_YES; | ||
458 | } | ||
459 | } | ||
460 | |||
461 | |||
462 | static void | ||
463 | merge_hellos1 (void *cls, const char *address_uri1) | ||
464 | { | ||
465 | struct AddressUriMergeResult *aumr = cls; | ||
466 | struct GNUNET_HELLO_Builder *builder2 = aumr->builder; | ||
467 | struct GNUNET_PeerIdentity *peer2 = GNUNET_HELLO_builder_get_id (builder2); | ||
468 | |||
469 | aumr->address_uri = address_uri1; | ||
470 | GNUNET_HELLO_builder_iterate (builder2, peer2, &merge_hellos2, aumr); | ||
471 | if (GNUNET_YES == aumr->found) | ||
472 | { | ||
473 | GNUNET_HELLO_builder_add_address (builder2, address_uri1); | ||
474 | aumr->merged = GNUNET_YES; | ||
475 | } | ||
476 | aumr->found = GNUNET_NO; | ||
477 | } | ||
478 | |||
479 | |||
480 | struct GNUNET_MQ_Envelope * | ||
481 | GNUNET_HELLO_builder_merge_hellos (const struct GNUNET_MessageHeader *msg1, | ||
482 | const struct GNUNET_MessageHeader *msg2, | ||
483 | const struct | ||
484 | GNUNET_CRYPTO_EddsaPrivateKey *priv) | ||
485 | { | 451 | { |
486 | struct HelloUriMessage *hum1 = (struct HelloUriMessage *) msg1; | 452 | struct BlockHeader *bh = (struct BlockHeader *) &msg[1]; |
487 | struct BlockHeader *bh1 = (struct BlockHeader *) &msg1[1]; | ||
488 | struct GNUNET_TIME_Absolute expiration_time1 = GNUNET_TIME_absolute_ntoh ( | ||
489 | bh1->expiration_time); | ||
490 | struct HelloUriMessage *hum2 = (struct HelloUriMessage *) msg2; | ||
491 | struct BlockHeader *bh2 = (struct BlockHeader *) &msg2[1]; | ||
492 | struct GNUNET_TIME_Absolute expiration_time2 = GNUNET_TIME_absolute_ntoh ( | ||
493 | bh1->expiration_time); | ||
494 | struct GNUNET_HELLO_Builder *builder1 = GNUNET_HELLO_builder_from_msg (msg1); | ||
495 | struct GNUNET_HELLO_Builder *builder2 = GNUNET_HELLO_builder_from_msg (msg2); | ||
496 | struct AddressUriMergeResult *aumr = GNUNET_new (struct | ||
497 | AddressUriMergeResult); | ||
498 | struct GNUNET_PeerIdentity *peer1 = GNUNET_HELLO_builder_get_id (builder1); | ||
499 | struct GNUNET_MQ_Envelope *env; | ||
500 | struct GNUNET_TIME_Absolute expiration_time; | ||
501 | |||
502 | aumr->builder = builder2; | ||
503 | GNUNET_HELLO_builder_iterate (builder1, peer1, &merge_hellos1, aumr); | ||
504 | 453 | ||
505 | if (GNUNET_YES == aumr->merged) | 454 | return GNUNET_TIME_absolute_ntoh (bh->expiration_time); |
506 | { | ||
507 | if (expiration_time1.abs_value_us < expiration_time2.abs_value_us) | ||
508 | expiration_time = expiration_time1; | ||
509 | else | ||
510 | expiration_time = expiration_time2; | ||
511 | env = GNUNET_HELLO_builder_to_env (builder2, | ||
512 | priv, | ||
513 | GNUNET_TIME_absolute_get_remaining ( | ||
514 | expiration_time)); | ||
515 | } | ||
516 | else if (expiration_time1.abs_value_us != expiration_time2.abs_value_us) | ||
517 | { | ||
518 | if (expiration_time1.abs_value_us < expiration_time2.abs_value_us) | ||
519 | expiration_time = expiration_time2; | ||
520 | else | ||
521 | expiration_time = expiration_time1; | ||
522 | env = GNUNET_HELLO_builder_to_env (builder2, | ||
523 | priv, | ||
524 | GNUNET_TIME_absolute_get_remaining ( | ||
525 | expiration_time)); | ||
526 | } | ||
527 | |||
528 | GNUNET_HELLO_builder_free (builder1); | ||
529 | GNUNET_HELLO_builder_free (builder2); | ||
530 | GNUNET_free (aumr); | ||
531 | |||
532 | return env; | ||
533 | } | 455 | } |
534 | 456 | ||
535 | 457 | ||
diff --git a/src/hostlist/Makefile.am b/src/hostlist/Makefile.am index 77c9eb1de..c58147dce 100644 --- a/src/hostlist/Makefile.am +++ b/src/hostlist/Makefile.am | |||
@@ -28,7 +28,7 @@ gnunet_daemon_hostlist_SOURCES = \ | |||
28 | gnunet_daemon_hostlist_LDADD = \ | 28 | gnunet_daemon_hostlist_LDADD = \ |
29 | $(top_builddir)/src/core/libgnunetcore.la \ | 29 | $(top_builddir)/src/core/libgnunetcore.la \ |
30 | $(top_builddir)/src/hello/libgnunethello.la \ | 30 | $(top_builddir)/src/hello/libgnunethello.la \ |
31 | $(top_builddir)/src/peerinfo/libgnunetpeerinfo.la \ | 31 | $(top_builddir)/src/peerstore/libgnunetpeerstore.la \ |
32 | $(top_builddir)/src/statistics/libgnunetstatistics.la \ | 32 | $(top_builddir)/src/statistics/libgnunetstatistics.la \ |
33 | $(top_builddir)/src/transport/libgnunettransport.la \ | 33 | $(top_builddir)/src/transport/libgnunettransport.la \ |
34 | $(top_builddir)/src/util/libgnunetutil.la \ | 34 | $(top_builddir)/src/util/libgnunetutil.la \ |
diff --git a/src/hostlist/gnunet-daemon-hostlist_client.c b/src/hostlist/gnunet-daemon-hostlist_client.c index 2caf61a1b..2932df07c 100644 --- a/src/hostlist/gnunet-daemon-hostlist_client.c +++ b/src/hostlist/gnunet-daemon-hostlist_client.c | |||
@@ -25,9 +25,9 @@ | |||
25 | */ | 25 | */ |
26 | #include "platform.h" | 26 | #include "platform.h" |
27 | #include "gnunet-daemon-hostlist_client.h" | 27 | #include "gnunet-daemon-hostlist_client.h" |
28 | #include "gnunet_hello_lib.h" | 28 | #include "gnunet_util_lib.h" |
29 | #include "gnunet_statistics_service.h" | 29 | #include "gnunet_statistics_service.h" |
30 | #include "gnunet_peerinfo_service.h" | 30 | #include "gnunet_peerstore_service.h" |
31 | #include "gnunet-daemon-hostlist.h" | 31 | #include "gnunet-daemon-hostlist.h" |
32 | /* Just included for the right curl.h */ | 32 | /* Just included for the right curl.h */ |
33 | #include "gnunet_curl_lib.h" | 33 | #include "gnunet_curl_lib.h" |
@@ -305,9 +305,16 @@ static unsigned int stat_hellos_obtained; | |||
305 | static unsigned int stat_connection_count; | 305 | static unsigned int stat_connection_count; |
306 | 306 | ||
307 | /** | 307 | /** |
308 | * Handle to peerinfo service. | 308 | * Handle to the PEERSTORE service. |
309 | */ | 309 | */ |
310 | static struct GNUNET_PEERINFO_Handle *pi; | 310 | static struct GNUNET_PEERSTORE_Handle *peerstore; |
311 | |||
312 | |||
313 | static void | ||
314 | shc_cont (void *cls, int success) | ||
315 | { | ||
316 | GNUNET_free (cls); | ||
317 | } | ||
311 | 318 | ||
312 | 319 | ||
313 | /** | 320 | /** |
@@ -323,6 +330,7 @@ static size_t | |||
323 | callback_download (void *ptr, size_t size, size_t nmemb, void *ctx) | 330 | callback_download (void *ptr, size_t size, size_t nmemb, void *ctx) |
324 | { | 331 | { |
325 | static char download_buffer[GNUNET_MAX_MESSAGE_SIZE - 1]; | 332 | static char download_buffer[GNUNET_MAX_MESSAGE_SIZE - 1]; |
333 | struct GNUNET_PEERSTORE_StoreHelloContext *shc; | ||
326 | const char *cbuf = ptr; | 334 | const char *cbuf = ptr; |
327 | const struct GNUNET_MessageHeader *msg; | 335 | const struct GNUNET_MessageHeader *msg; |
328 | size_t total; | 336 | size_t total; |
@@ -377,7 +385,7 @@ callback_download (void *ptr, size_t size, size_t nmemb, void *ctx) | |||
377 | GNUNET_assert (left == 0); | 385 | GNUNET_assert (left == 0); |
378 | break; | 386 | break; |
379 | } | 387 | } |
380 | if (GNUNET_HELLO_size ((const struct GNUNET_HELLO_Message *) msg) == msize) | 388 | if (sizeof (msg) == msize) |
381 | { | 389 | { |
382 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 390 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
383 | "Received valid `%s' message from hostlist server.\n", | 391 | "Received valid `%s' message from hostlist server.\n", |
@@ -388,11 +396,10 @@ callback_download (void *ptr, size_t size, size_t nmemb, void *ctx) | |||
388 | 1, | 396 | 1, |
389 | GNUNET_NO); | 397 | GNUNET_NO); |
390 | stat_hellos_obtained++; | 398 | stat_hellos_obtained++; |
391 | (void) | 399 | shc = GNUNET_PEERSTORE_hello_add (peerstore, |
392 | GNUNET_PEERINFO_add_peer (pi, | 400 | msg, |
393 | (const struct GNUNET_HELLO_Message *) msg, | 401 | shc_cont, |
394 | NULL, | 402 | shc); |
395 | NULL); | ||
396 | } | 403 | } |
397 | else | 404 | else |
398 | { | 405 | { |
@@ -1592,7 +1599,7 @@ GNUNET_HOSTLIST_client_start (const struct GNUNET_CONFIGURATION_Handle *c, | |||
1592 | stats = st; | 1599 | stats = st; |
1593 | 1600 | ||
1594 | /* Read proxy configuration */ | 1601 | /* Read proxy configuration */ |
1595 | pi = GNUNET_PEERINFO_connect (c); | 1602 | peerstore = GNUNET_PEERSTORE_connect (c); |
1596 | if (GNUNET_OK == | 1603 | if (GNUNET_OK == |
1597 | GNUNET_CONFIGURATION_get_value_string (cfg, "HOSTLIST", "PROXY", &proxy)) | 1604 | GNUNET_CONFIGURATION_get_value_string (cfg, "HOSTLIST", "PROXY", &proxy)) |
1598 | { | 1605 | { |
@@ -1788,10 +1795,10 @@ GNUNET_HOSTLIST_client_stop () | |||
1788 | proxy_username = NULL; | 1795 | proxy_username = NULL; |
1789 | GNUNET_free (proxy_password); | 1796 | GNUNET_free (proxy_password); |
1790 | proxy_password = NULL; | 1797 | proxy_password = NULL; |
1791 | if (NULL != pi) | 1798 | if (NULL != peerstore) |
1792 | { | 1799 | { |
1793 | GNUNET_PEERINFO_disconnect (pi); | 1800 | GNUNET_PEERSTORE_disconnect (peerstore, GNUNET_YES); |
1794 | pi = NULL; | 1801 | peerstore = NULL; |
1795 | } | 1802 | } |
1796 | cfg = NULL; | 1803 | cfg = NULL; |
1797 | } | 1804 | } |
diff --git a/src/hostlist/gnunet-daemon-hostlist_server.c b/src/hostlist/gnunet-daemon-hostlist_server.c index 46b18b266..4c276ce80 100644 --- a/src/hostlist/gnunet-daemon-hostlist_server.c +++ b/src/hostlist/gnunet-daemon-hostlist_server.c | |||
@@ -28,8 +28,8 @@ | |||
28 | #include "platform.h" | 28 | #include "platform.h" |
29 | #include <microhttpd.h> | 29 | #include <microhttpd.h> |
30 | #include "gnunet-daemon-hostlist_server.h" | 30 | #include "gnunet-daemon-hostlist_server.h" |
31 | #include "gnunet_hello_lib.h" | 31 | #include "gnunet_hello_uri_lib.h" |
32 | #include "gnunet_peerinfo_service.h" | 32 | #include "gnunet_peerstore_service.h" |
33 | #include "gnunet-daemon-hostlist.h" | 33 | #include "gnunet-daemon-hostlist.h" |
34 | #include "gnunet_resolver_service.h" | 34 | #include "gnunet_resolver_service.h" |
35 | #include "gnunet_mhd_compat.h" | 35 | #include "gnunet_mhd_compat.h" |
@@ -69,9 +69,10 @@ static struct GNUNET_STATISTICS_Handle *stats; | |||
69 | static struct GNUNET_CORE_Handle *core; | 69 | static struct GNUNET_CORE_Handle *core; |
70 | 70 | ||
71 | /** | 71 | /** |
72 | * Handle to the peerinfo notify service (NULL until we've connected to it). | 72 | * Our peerstore notification context. We use notification |
73 | * to instantly learn about new peers as they are discovered. | ||
73 | */ | 74 | */ |
74 | static struct GNUNET_PEERINFO_NotifyContext *notify; | 75 | static struct GNUNET_PEERSTORE_NotifyContext *peerstore_notify; |
75 | 76 | ||
76 | /** | 77 | /** |
77 | * Our primary task for IPv4. | 78 | * Our primary task for IPv4. |
@@ -89,9 +90,9 @@ static struct GNUNET_SCHEDULER_Task *hostlist_task_v6; | |||
89 | static struct MHD_Response *response; | 90 | static struct MHD_Response *response; |
90 | 91 | ||
91 | /** | 92 | /** |
92 | * Handle for accessing peerinfo service. | 93 | * Handle to the PEERSTORE service. |
93 | */ | 94 | */ |
94 | static struct GNUNET_PEERINFO_Handle *peerinfo; | 95 | static struct GNUNET_PEERSTORE_Handle *peerstore; |
95 | 96 | ||
96 | /** | 97 | /** |
97 | * Set if we are allowed to advertise our hostlist to others. | 98 | * Set if we are allowed to advertise our hostlist to others. |
@@ -112,7 +113,7 @@ struct HostSet | |||
112 | /** | 113 | /** |
113 | * Iterator used to build @e data (NULL when done). | 114 | * Iterator used to build @e data (NULL when done). |
114 | */ | 115 | */ |
115 | struct GNUNET_PEERINFO_IteratorContext *pitr; | 116 | struct GNUNET_PEERSTORE_IterateContext *pitr; |
116 | 117 | ||
117 | /** | 118 | /** |
118 | * Place where we accumulate all of the HELLO messages. | 119 | * Place where we accumulate all of the HELLO messages. |
@@ -179,34 +180,6 @@ finish_response () | |||
179 | 180 | ||
180 | 181 | ||
181 | /** | 182 | /** |
182 | * Set @a cls to #GNUNET_YES (we have an address!). | ||
183 | * | ||
184 | * @param cls closure, an `int *` | ||
185 | * @param address the address (ignored) | ||
186 | * @param expiration expiration time (call is ignored if this is in the past) | ||
187 | * @return #GNUNET_SYSERR to stop iterating (unless expiration has occurred) | ||
188 | */ | ||
189 | static int | ||
190 | check_has_addr (void *cls, | ||
191 | const struct GNUNET_HELLO_Address *address, | ||
192 | struct GNUNET_TIME_Absolute expiration) | ||
193 | { | ||
194 | int *arg = cls; | ||
195 | |||
196 | if (0 == GNUNET_TIME_absolute_get_remaining (expiration).rel_value_us) | ||
197 | { | ||
198 | GNUNET_STATISTICS_update (stats, | ||
199 | gettext_noop ("expired addresses encountered"), | ||
200 | 1, | ||
201 | GNUNET_YES); | ||
202 | return GNUNET_YES; /* ignore this address */ | ||
203 | } | ||
204 | *arg = GNUNET_YES; | ||
205 | return GNUNET_SYSERR; | ||
206 | } | ||
207 | |||
208 | |||
209 | /** | ||
210 | * Callback that processes each of the known HELLOs for the | 183 | * Callback that processes each of the known HELLOs for the |
211 | * hostlist response construction. | 184 | * hostlist response construction. |
212 | * | 185 | * |
@@ -217,55 +190,65 @@ check_has_addr (void *cls, | |||
217 | */ | 190 | */ |
218 | static void | 191 | static void |
219 | host_processor (void *cls, | 192 | host_processor (void *cls, |
220 | const struct GNUNET_PeerIdentity *peer, | 193 | const struct GNUNET_PEERSTORE_Record *record, |
221 | const struct GNUNET_HELLO_Message *hello, | 194 | const char *emsg) |
222 | const char *err_msg) | ||
223 | { | 195 | { |
224 | size_t old; | 196 | size_t old; |
225 | size_t s; | 197 | size_t s; |
226 | int has_addr; | 198 | struct GNUNET_HELLO_Builder *hello_builder; |
227 | 199 | struct GNUNET_MessageHeader *hello; | |
228 | if (NULL != err_msg) | 200 | struct GNUNET_TIME_Absolute now = GNUNET_TIME_absolute_get (); |
229 | { | 201 | struct GNUNET_TIME_Absolute hello_exp; |
230 | GNUNET_assert (NULL == peer); | 202 | |
203 | if (NULL != emsg) | ||
204 | { | ||
205 | GNUNET_assert (NULL == &record->peer); | ||
231 | builder->pitr = NULL; | 206 | builder->pitr = NULL; |
232 | GNUNET_free (builder->data); | 207 | GNUNET_free (builder->data); |
233 | GNUNET_free (builder); | 208 | GNUNET_free (builder); |
234 | builder = NULL; | 209 | builder = NULL; |
235 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 210 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
236 | _ ("Error in communication with PEERINFO service: %s\n"), | 211 | _ ("Error in communication with PEERSTORE service: %s\n"), |
237 | err_msg); | 212 | emsg); |
238 | return; | 213 | return; |
239 | } | 214 | } |
240 | if (NULL == peer) | 215 | if (NULL == record) |
241 | { | 216 | { |
242 | builder->pitr = NULL; | 217 | builder->pitr = NULL; |
243 | finish_response (); | 218 | finish_response (); |
244 | return; | 219 | return; |
245 | } | 220 | } |
246 | if (NULL == hello) | 221 | else |
247 | return; | ||
248 | has_addr = GNUNET_NO; | ||
249 | GNUNET_HELLO_iterate_addresses (hello, GNUNET_NO, &check_has_addr, &has_addr); | ||
250 | if (GNUNET_NO == has_addr) | ||
251 | { | 222 | { |
252 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 223 | hello = record->value; |
253 | "HELLO for peer `%4s' has no address, not suitable for hostlist!\n", | 224 | if ((0 == record->value_size)) |
254 | GNUNET_i2s (peer)); | 225 | { |
255 | GNUNET_STATISTICS_update (stats, | 226 | GNUNET_break (0); |
256 | gettext_noop ( | 227 | return; |
257 | "HELLOs without addresses encountered (ignored)"), | 228 | } |
258 | 1, | 229 | hello_builder = GNUNET_HELLO_builder_new (&record->peer); |
259 | GNUNET_NO); | 230 | hello_exp = GNUNET_HELLO_builder_get_expiration_time (hello_builder, hello); |
260 | return; | 231 | if (GNUNET_TIME_absolute_cmp (hello_exp, < , now)) |
232 | { | ||
233 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
234 | "HELLO for peer `%4s' has expired address, not suitable for hostlist!\n", | ||
235 | GNUNET_i2s (&record->peer)); | ||
236 | GNUNET_STATISTICS_update (stats, | ||
237 | gettext_noop ( | ||
238 | "Expired HELLO encountered (ignored)"), | ||
239 | 1, | ||
240 | GNUNET_NO); | ||
241 | GNUNET_HELLO_builder_free (hello_builder); | ||
242 | return; | ||
243 | } | ||
261 | } | 244 | } |
262 | old = builder->size; | 245 | old = builder->size; |
263 | s = GNUNET_HELLO_size (hello); | 246 | s = sizeof (hello); |
264 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 247 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
265 | "Received %u bytes of `%s' from peer `%s' for hostlist.\n", | 248 | "Received %u bytes of `%s' from peer `%s' for hostlist.\n", |
266 | (unsigned int) s, | 249 | (unsigned int) s, |
267 | "HELLO", | 250 | "HELLO", |
268 | GNUNET_i2s (peer)); | 251 | GNUNET_i2s (&record->peer)); |
269 | if ((old + s >= GNUNET_MAX_MALLOC_CHECKED) || | 252 | if ((old + s >= GNUNET_MAX_MALLOC_CHECKED) || |
270 | (old + s >= MAX_BYTES_PER_HOSTLISTS)) | 253 | (old + s >= MAX_BYTES_PER_HOSTLISTS)) |
271 | { | 254 | { |
@@ -275,14 +258,16 @@ host_processor (void *cls, | |||
275 | "bytes not included in hostlist (size limit)"), | 258 | "bytes not included in hostlist (size limit)"), |
276 | s, | 259 | s, |
277 | GNUNET_NO); | 260 | GNUNET_NO); |
261 | GNUNET_HELLO_builder_free (hello_builder); | ||
278 | return; | 262 | return; |
279 | } | 263 | } |
280 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 264 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
281 | "Adding peer `%s' to hostlist (%u bytes)\n", | 265 | "Adding peer `%s' to hostlist (%u bytes)\n", |
282 | GNUNET_i2s (peer), | 266 | GNUNET_i2s (&record->peer), |
283 | (unsigned int) s); | 267 | (unsigned int) s); |
284 | GNUNET_array_grow (builder->data, builder->size, old + s); | 268 | GNUNET_array_grow (builder->data, builder->size, old + s); |
285 | GNUNET_memcpy (&builder->data[old], hello, s); | 269 | GNUNET_memcpy (&builder->data[old], hello, s); |
270 | GNUNET_HELLO_builder_free (hello_builder); | ||
286 | } | 271 | } |
287 | 272 | ||
288 | 273 | ||
@@ -506,7 +491,7 @@ connect_handler (void *cls, | |||
506 | 491 | ||
507 | 492 | ||
508 | /** | 493 | /** |
509 | * PEERINFO calls this function to let us know about a possible peer | 494 | * PEERSTORE calls this function to let us know about a possible peer |
510 | * that we might want to connect to. | 495 | * that we might want to connect to. |
511 | * | 496 | * |
512 | * @param cls closure (not used) | 497 | * @param cls closure (not used) |
@@ -517,21 +502,21 @@ connect_handler (void *cls, | |||
517 | static void | 502 | static void |
518 | process_notify (void *cls, | 503 | process_notify (void *cls, |
519 | const struct GNUNET_PeerIdentity *peer, | 504 | const struct GNUNET_PeerIdentity *peer, |
520 | const struct GNUNET_HELLO_Message *hello, | 505 | const struct GNUNET_MessageHeader *hello, |
521 | const char *err_msg) | 506 | const char *err_msg) |
522 | { | 507 | { |
523 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 508 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
524 | "Peerinfo is notifying us to rebuild our hostlist\n"); | 509 | "Peerstore is notifying us to rebuild our hostlist\n"); |
525 | if (NULL != err_msg) | 510 | if (NULL != err_msg) |
526 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 511 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
527 | _ ("Error in communication with PEERINFO service: %s\n"), | 512 | _ ("Error in communication with PEERSTORE service: %s\n"), |
528 | err_msg); | 513 | err_msg); |
529 | if (NULL != builder) | 514 | if (NULL != builder) |
530 | { | 515 | { |
531 | /* restart re-build already in progress ... */ | 516 | /* restart re-build already in progress ... */ |
532 | if (NULL != builder->pitr) | 517 | if (NULL != builder->pitr) |
533 | { | 518 | { |
534 | GNUNET_PEERINFO_iterate_cancel (builder->pitr); | 519 | GNUNET_PEERSTORE_iterate_cancel (builder->pitr); |
535 | builder->pitr = NULL; | 520 | builder->pitr = NULL; |
536 | } | 521 | } |
537 | GNUNET_free (builder->data); | 522 | GNUNET_free (builder->data); |
@@ -542,9 +527,9 @@ process_notify (void *cls, | |||
542 | { | 527 | { |
543 | builder = GNUNET_new (struct HostSet); | 528 | builder = GNUNET_new (struct HostSet); |
544 | } | 529 | } |
545 | GNUNET_assert (NULL != peerinfo); | 530 | GNUNET_assert (NULL != peerstore); |
546 | builder->pitr = | 531 | builder->pitr = |
547 | GNUNET_PEERINFO_iterate (peerinfo, GNUNET_NO, NULL, &host_processor, NULL); | 532 | GNUNET_PEERSTORE_iterate (peerstore, "hostlist", NULL, GNUNET_PEERSTORE_HELLO_KEY, &host_processor, NULL); |
548 | } | 533 | } |
549 | 534 | ||
550 | 535 | ||
@@ -667,11 +652,11 @@ GNUNET_HOSTLIST_server_start (const struct GNUNET_CONFIGURATION_Handle *c, | |||
667 | } | 652 | } |
668 | cfg = c; | 653 | cfg = c; |
669 | stats = st; | 654 | stats = st; |
670 | peerinfo = GNUNET_PEERINFO_connect (cfg); | 655 | peerstore = GNUNET_PEERSTORE_connect (cfg); |
671 | if (NULL == peerinfo) | 656 | if (NULL == peerstore) |
672 | { | 657 | { |
673 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 658 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
674 | _ ("Could not access PEERINFO service. Exiting.\n")); | 659 | _ ("Could not access PEERSTORE service. Exiting.\n")); |
675 | return GNUNET_SYSERR; | 660 | return GNUNET_SYSERR; |
676 | } | 661 | } |
677 | if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_number (cfg, | 662 | if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_number (cfg, |
@@ -837,7 +822,7 @@ GNUNET_HOSTLIST_server_start (const struct GNUNET_CONFIGURATION_Handle *c, | |||
837 | hostlist_task_v4 = prepare_daemon (daemon_handle_v4); | 822 | hostlist_task_v4 = prepare_daemon (daemon_handle_v4); |
838 | if (NULL != daemon_handle_v6) | 823 | if (NULL != daemon_handle_v6) |
839 | hostlist_task_v6 = prepare_daemon (daemon_handle_v6); | 824 | hostlist_task_v6 = prepare_daemon (daemon_handle_v6); |
840 | notify = GNUNET_PEERINFO_notify (cfg, GNUNET_NO, &process_notify, NULL); | 825 | peerstore_notify = GNUNET_PEERSTORE_hello_changed_notify (peerstore, GNUNET_NO, &process_notify, NULL); |
841 | return GNUNET_OK; | 826 | return GNUNET_OK; |
842 | } | 827 | } |
843 | 828 | ||
@@ -874,26 +859,26 @@ GNUNET_HOSTLIST_server_stop () | |||
874 | MHD_destroy_response (response); | 859 | MHD_destroy_response (response); |
875 | response = NULL; | 860 | response = NULL; |
876 | } | 861 | } |
877 | if (NULL != notify) | 862 | if (NULL != peerstore_notify) |
878 | { | 863 | { |
879 | GNUNET_PEERINFO_notify_cancel (notify); | 864 | GNUNET_PEERSTORE_hello_changed_notify_cancel (peerstore_notify); |
880 | notify = NULL; | 865 | peerstore_notify = NULL; |
881 | } | 866 | } |
882 | if (NULL != builder) | 867 | if (NULL != builder) |
883 | { | 868 | { |
884 | if (NULL != builder->pitr) | 869 | if (NULL != builder->pitr) |
885 | { | 870 | { |
886 | GNUNET_PEERINFO_iterate_cancel (builder->pitr); | 871 | GNUNET_PEERSTORE_iterate_cancel (builder->pitr); |
887 | builder->pitr = NULL; | 872 | builder->pitr = NULL; |
888 | } | 873 | } |
889 | GNUNET_free (builder->data); | 874 | GNUNET_free (builder->data); |
890 | GNUNET_free (builder); | 875 | GNUNET_free (builder); |
891 | builder = NULL; | 876 | builder = NULL; |
892 | } | 877 | } |
893 | if (NULL != peerinfo) | 878 | if (NULL != peerstore) |
894 | { | 879 | { |
895 | GNUNET_PEERINFO_disconnect (peerinfo); | 880 | GNUNET_PEERSTORE_disconnect (peerstore, GNUNET_YES); |
896 | peerinfo = NULL; | 881 | peerstore = NULL; |
897 | } | 882 | } |
898 | cfg = NULL; | 883 | cfg = NULL; |
899 | stats = NULL; | 884 | stats = NULL; |
diff --git a/src/include/gnunet_hello_uri_lib.h b/src/include/gnunet_hello_uri_lib.h index 3aa07d760..ec84f35b0 100644 --- a/src/include/gnunet_hello_uri_lib.h +++ b/src/include/gnunet_hello_uri_lib.h | |||
@@ -118,13 +118,15 @@ GNUNET_HELLO_builder_from_url (const char *url); | |||
118 | 118 | ||
119 | 119 | ||
120 | /** | 120 | /** |
121 | * Merge to hello uris. | 121 | * Get the expiration time for this HELLO. |
122 | * | ||
123 | * @param builder builder to serialize | ||
124 | * @param msg The hello msg. | ||
125 | * @return The expiration time. | ||
122 | */ | 126 | */ |
123 | struct GNUNET_MQ_Envelope * | 127 | struct GNUNET_TIME_Absolute |
124 | GNUNET_HELLO_builder_merge_hellos (const struct GNUNET_MessageHeader *msg1, | 128 | GNUNET_HELLO_builder_get_expiration_time (struct GNUNET_HELLO_Builder *builder, |
125 | const struct GNUNET_MessageHeader *msg2, | 129 | const struct GNUNET_MessageHeader *msg); |
126 | const struct | ||
127 | GNUNET_CRYPTO_EddsaPrivateKey *priv); | ||
128 | 130 | ||
129 | 131 | ||
130 | /** | 132 | /** |
diff --git a/src/include/gnunet_peerstore_service.h b/src/include/gnunet_peerstore_service.h index 6196d8202..1cb60cb04 100644 --- a/src/include/gnunet_peerstore_service.h +++ b/src/include/gnunet_peerstore_service.h | |||
@@ -246,7 +246,6 @@ GNUNET_PEERSTORE_hello_changed_notify_cancel (struct | |||
246 | struct GNUNET_PEERSTORE_StoreHelloContext * | 246 | struct GNUNET_PEERSTORE_StoreHelloContext * |
247 | GNUNET_PEERSTORE_hello_add (struct GNUNET_PEERSTORE_Handle *h, | 247 | GNUNET_PEERSTORE_hello_add (struct GNUNET_PEERSTORE_Handle *h, |
248 | const struct GNUNET_MessageHeader *msg, | 248 | const struct GNUNET_MessageHeader *msg, |
249 | const struct GNUNET_CRYPTO_EddsaPrivateKey *priv, | ||
250 | GNUNET_PEERSTORE_Continuation cont, | 249 | GNUNET_PEERSTORE_Continuation cont, |
251 | void *cont_cls); | 250 | void *cont_cls); |
252 | 251 | ||
@@ -352,7 +351,8 @@ GNUNET_PEERSTORE_iterate_cancel (struct GNUNET_PEERSTORE_IterateContext *ic); | |||
352 | 351 | ||
353 | /** | 352 | /** |
354 | * Request watching a given key | 353 | * Request watching a given key |
355 | * User will be notified with any new values added to key. | 354 | * User will be notified with any new values added to key, |
355 | * all existing entries are supplied beforehand. | ||
356 | * | 356 | * |
357 | * @param h handle to the PEERSTORE service | 357 | * @param h handle to the PEERSTORE service |
358 | * @param sub_system name of sub system | 358 | * @param sub_system name of sub system |
diff --git a/src/nse/nse_api.c b/src/nse/nse_api.c index 23daa7f12..7f3e03b98 100644 --- a/src/nse/nse_api.c +++ b/src/nse/nse_api.c | |||
@@ -26,7 +26,6 @@ | |||
26 | #include "platform.h" | 26 | #include "platform.h" |
27 | #include "gnunet_constants.h" | 27 | #include "gnunet_constants.h" |
28 | #include "gnunet_arm_service.h" | 28 | #include "gnunet_arm_service.h" |
29 | #include "gnunet_hello_lib.h" | ||
30 | #include "gnunet_protocols.h" | 29 | #include "gnunet_protocols.h" |
31 | #include "gnunet_util_lib.h" | 30 | #include "gnunet_util_lib.h" |
32 | #include "gnunet_nse_service.h" | 31 | #include "gnunet_nse_service.h" |
diff --git a/src/peerstore/Makefile.am b/src/peerstore/Makefile.am index b73bd2477..7220492f2 100644 --- a/src/peerstore/Makefile.am +++ b/src/peerstore/Makefile.am | |||
@@ -38,6 +38,7 @@ gnunet_service_peerstore_SOURCES = \ | |||
38 | gnunet_service_peerstore_CFLAGS = $(AM_CFLAGS) | 38 | gnunet_service_peerstore_CFLAGS = $(AM_CFLAGS) |
39 | gnunet_service_peerstore_LDADD = \ | 39 | gnunet_service_peerstore_LDADD = \ |
40 | $(top_builddir)/src/util/libgnunetutil.la \ | 40 | $(top_builddir)/src/util/libgnunetutil.la \ |
41 | $(top_builddir)/src/hello/libgnunethello.la \ | ||
41 | $(GN_LIBINTL) | 42 | $(GN_LIBINTL) |
42 | 43 | ||
43 | libgnunetpeerstore_la_SOURCES = \ | 44 | libgnunetpeerstore_la_SOURCES = \ |
diff --git a/src/peerstore/peerstore_api.c b/src/peerstore/peerstore_api.c index 1bac046f2..246bd24b4 100644 --- a/src/peerstore/peerstore_api.c +++ b/src/peerstore/peerstore_api.c | |||
@@ -358,11 +358,6 @@ struct GNUNET_PEERSTORE_StoreHelloContext | |||
358 | const struct GNUNET_MessageHeader *hello; | 358 | const struct GNUNET_MessageHeader *hello; |
359 | 359 | ||
360 | /** | 360 | /** |
361 | * Key to sign merged hello. | ||
362 | */ | ||
363 | const struct GNUNET_CRYPTO_EddsaPrivateKey *priv; | ||
364 | |||
365 | /** | ||
366 | * Was this request successful. | 361 | * Was this request successful. |
367 | */ | 362 | */ |
368 | int success; | 363 | int success; |
@@ -1296,9 +1291,12 @@ store_hello (struct GNUNET_PEERSTORE_StoreHelloContext *huc, | |||
1296 | struct GNUNET_PeerIdentity *pid; | 1291 | struct GNUNET_PeerIdentity *pid; |
1297 | struct GNUNET_PEERSTORE_StoreContext *sc; | 1292 | struct GNUNET_PEERSTORE_StoreContext *sc; |
1298 | struct StoreHelloCls *shu_cls = GNUNET_new (struct StoreHelloCls); | 1293 | struct StoreHelloCls *shu_cls = GNUNET_new (struct StoreHelloCls); |
1294 | struct GNUNET_TIME_Absolute hello_exp; | ||
1299 | 1295 | ||
1300 | shu_cls->huc = huc; | 1296 | shu_cls->huc = huc; |
1301 | builder = GNUNET_HELLO_builder_from_msg (hello); | 1297 | builder = GNUNET_HELLO_builder_from_msg (hello); |
1298 | hello_exp = GNUNET_HELLO_builder_get_expiration_time (builder, | ||
1299 | hello); | ||
1302 | pid = GNUNET_HELLO_builder_get_id (builder); | 1300 | pid = GNUNET_HELLO_builder_get_id (builder); |
1303 | sc = GNUNET_PEERSTORE_store (h, | 1301 | sc = GNUNET_PEERSTORE_store (h, |
1304 | "peerstore", | 1302 | "peerstore", |
@@ -1306,7 +1304,7 @@ store_hello (struct GNUNET_PEERSTORE_StoreHelloContext *huc, | |||
1306 | GNUNET_PEERSTORE_HELLO_KEY, | 1304 | GNUNET_PEERSTORE_HELLO_KEY, |
1307 | hello, | 1305 | hello, |
1308 | sizeof(hello), | 1306 | sizeof(hello), |
1309 | GNUNET_TIME_UNIT_FOREVER_ABS, | 1307 | hello_exp, |
1310 | GNUNET_PEERSTORE_STOREOPTION_REPLACE, | 1308 | GNUNET_PEERSTORE_STOREOPTION_REPLACE, |
1311 | merge_success, | 1309 | merge_success, |
1312 | shu_cls); | 1310 | shu_cls); |
@@ -1325,8 +1323,8 @@ merge_uri (void *cls, | |||
1325 | struct GNUNET_PEERSTORE_Handle *h = huc->h; | 1323 | struct GNUNET_PEERSTORE_Handle *h = huc->h; |
1326 | struct GNUNET_PEERSTORE_WatchContext *wc; | 1324 | struct GNUNET_PEERSTORE_WatchContext *wc; |
1327 | struct GNUNET_MessageHeader *hello; | 1325 | struct GNUNET_MessageHeader *hello; |
1328 | const struct GNUNET_MessageHeader *merged_hello; | 1326 | struct GNUNET_TIME_Absolute huc_hello_exp_time; |
1329 | struct GNUNET_MQ_Envelope *env; | 1327 | struct GNUNET_TIME_Absolute record_hello_exp_time; |
1330 | const char *val; | 1328 | const char *val; |
1331 | 1329 | ||
1332 | if (NULL != emsg) | 1330 | if (NULL != emsg) |
@@ -1352,20 +1350,28 @@ merge_uri (void *cls, | |||
1352 | 1350 | ||
1353 | if (NULL != record) | 1351 | if (NULL != record) |
1354 | { | 1352 | { |
1353 | struct GNUNET_HELLO_Builder *builder; | ||
1354 | struct GNUNET_HELLO_Builder *huc_builder; | ||
1355 | |||
1355 | hello = record->value; | 1356 | hello = record->value; |
1356 | if ((0 == record->value_size) || ('\0' != val[record->value_size - 1])) | 1357 | builder = GNUNET_HELLO_builder_from_msg (hello); |
1358 | huc_builder = GNUNET_HELLO_builder_from_msg (huc->hello); | ||
1359 | if ((0 == record->value_size)) | ||
1357 | { | 1360 | { |
1358 | GNUNET_break (0); | 1361 | GNUNET_break (0); |
1359 | return; | 1362 | return; |
1360 | } | 1363 | } |
1361 | 1364 | ||
1362 | env = GNUNET_HELLO_builder_merge_hellos (huc->hello, hello, huc->priv); | 1365 | huc_hello_exp_time = GNUNET_HELLO_builder_get_expiration_time (huc_builder, |
1363 | merged_hello = GNUNET_MQ_env_get_msg (env); | 1366 | huc->hello); |
1364 | if (NULL != merged_hello) | 1367 | record_hello_exp_time = GNUNET_HELLO_builder_get_expiration_time (builder, |
1365 | store_hello (huc, merged_hello); | 1368 | hello); |
1366 | 1369 | ||
1367 | GNUNET_free (env); | 1370 | if (GNUNET_TIME_absolute_cmp (huc_hello_exp_time, >, record_hello_exp_time)) |
1371 | store_hello (huc, huc->hello); | ||
1368 | 1372 | ||
1373 | GNUNET_HELLO_builder_free (builder); | ||
1374 | GNUNET_HELLO_builder_free (huc_builder); | ||
1369 | } | 1375 | } |
1370 | else | 1376 | else |
1371 | { | 1377 | { |
@@ -1377,23 +1383,26 @@ merge_uri (void *cls, | |||
1377 | struct GNUNET_PEERSTORE_StoreHelloContext * | 1383 | struct GNUNET_PEERSTORE_StoreHelloContext * |
1378 | GNUNET_PEERSTORE_hello_add (struct GNUNET_PEERSTORE_Handle *h, | 1384 | GNUNET_PEERSTORE_hello_add (struct GNUNET_PEERSTORE_Handle *h, |
1379 | const struct GNUNET_MessageHeader *msg, | 1385 | const struct GNUNET_MessageHeader *msg, |
1380 | const struct GNUNET_CRYPTO_EddsaPrivateKey *priv, | ||
1381 | GNUNET_PEERSTORE_Continuation cont, | 1386 | GNUNET_PEERSTORE_Continuation cont, |
1382 | void *cont_cls) | 1387 | void *cont_cls) |
1383 | { | 1388 | { |
1384 | struct GNUNET_HELLO_Builder *builder; | 1389 | struct GNUNET_HELLO_Builder *builder = GNUNET_HELLO_builder_from_msg (msg); |
1385 | struct GNUNET_PEERSTORE_StoreHelloContext *huc; | 1390 | struct GNUNET_PEERSTORE_StoreHelloContext *huc; |
1386 | struct GNUNET_PEERSTORE_IterateContext *ic; | 1391 | struct GNUNET_PEERSTORE_IterateContext *ic; |
1387 | struct GNUNET_PeerIdentity *pid; | 1392 | struct GNUNET_PeerIdentity *pid; |
1393 | struct GNUNET_TIME_Absolute now = GNUNET_TIME_absolute_get (); | ||
1394 | struct GNUNET_TIME_Absolute hello_exp = | ||
1395 | GNUNET_HELLO_builder_get_expiration_time (builder, | ||
1396 | msg); | ||
1397 | |||
1398 | if (GNUNET_TIME_absolute_cmp (hello_exp, <, now)) | ||
1399 | return NULL; | ||
1388 | 1400 | ||
1389 | huc = GNUNET_new (struct GNUNET_PEERSTORE_StoreHelloContext); | 1401 | huc = GNUNET_new (struct GNUNET_PEERSTORE_StoreHelloContext); |
1390 | huc->h = h; | 1402 | huc->h = h; |
1391 | huc->cont = cont; | 1403 | huc->cont = cont; |
1392 | huc->cont_cls = cont_cls; | 1404 | huc->cont_cls = cont_cls; |
1393 | huc->hello = msg; | 1405 | huc->hello = msg; |
1394 | huc->priv = priv; | ||
1395 | |||
1396 | builder = GNUNET_HELLO_builder_from_msg (msg); | ||
1397 | pid = GNUNET_HELLO_builder_get_id (builder); | 1406 | pid = GNUNET_HELLO_builder_get_id (builder); |
1398 | ic = GNUNET_PEERSTORE_iterate (h, | 1407 | ic = GNUNET_PEERSTORE_iterate (h, |
1399 | "peerstore", | 1408 | "peerstore", |
diff --git a/src/rps/Makefile.am b/src/rps/Makefile.am index 3d6214cd0..8f7c104f9 100644 --- a/src/rps/Makefile.am +++ b/src/rps/Makefile.am | |||
@@ -61,9 +61,8 @@ gnunet_service_rps_SOURCES = \ | |||
61 | gnunet_service_rps_LDADD = \ | 61 | gnunet_service_rps_LDADD = \ |
62 | libgnunetrps.la \ | 62 | libgnunetrps.la \ |
63 | $(top_builddir)/src/util/libgnunetutil.la \ | 63 | $(top_builddir)/src/util/libgnunetutil.la \ |
64 | $(top_builddir)/src/peerinfo/libgnunetpeerinfo.la \ | 64 | $(top_builddir)/src/peerstore/libgnunetpeerstore.la \ |
65 | $(top_builddir)/src/cadet/libgnunetcadet.la \ | 65 | $(top_builddir)/src/cadet/libgnunetcadet.la \ |
66 | $(top_builddir)/src/peerinfo/libgnunetpeerinfo.la \ | ||
67 | $(top_builddir)/src/nse/libgnunetnse.la \ | 66 | $(top_builddir)/src/nse/libgnunetnse.la \ |
68 | $(top_builddir)/src/statistics/libgnunetstatistics.la \ | 67 | $(top_builddir)/src/statistics/libgnunetstatistics.la \ |
69 | $(top_builddir)/src/core/libgnunetcore.la \ | 68 | $(top_builddir)/src/core/libgnunetcore.la \ |
diff --git a/src/rps/gnunet-service-rps.c b/src/rps/gnunet-service-rps.c index fc11591a0..76e33c87b 100644 --- a/src/rps/gnunet-service-rps.c +++ b/src/rps/gnunet-service-rps.c | |||
@@ -28,7 +28,7 @@ | |||
28 | #include "gnunet_util_lib.h" | 28 | #include "gnunet_util_lib.h" |
29 | #include "gnunet_cadet_service.h" | 29 | #include "gnunet_cadet_service.h" |
30 | #include "gnunet_core_service.h" | 30 | #include "gnunet_core_service.h" |
31 | #include "gnunet_peerinfo_service.h" | 31 | #include "gnunet_peerstore_service.h" |
32 | #include "gnunet_nse_service.h" | 32 | #include "gnunet_nse_service.h" |
33 | #include "gnunet_statistics_service.h" | 33 | #include "gnunet_statistics_service.h" |
34 | #include "rps.h" | 34 | #include "rps.h" |
@@ -499,14 +499,15 @@ static float beta; | |||
499 | static struct GNUNET_NSE_Handle *nse; | 499 | static struct GNUNET_NSE_Handle *nse; |
500 | 500 | ||
501 | /** | 501 | /** |
502 | * Handler to PEERINFO. | 502 | * Handle to the PEERSTORE service. |
503 | */ | 503 | */ |
504 | static struct GNUNET_PEERINFO_Handle *peerinfo_handle; | 504 | static struct GNUNET_PEERSTORE_Handle *peerstore; |
505 | 505 | ||
506 | /** | 506 | /** |
507 | * Handle for cancellation of iteration over peers. | 507 | * Our peerstore notification context. We use notification |
508 | * to instantly learn about new peers as they are discovered. | ||
508 | */ | 509 | */ |
509 | static struct GNUNET_PEERINFO_NotifyContext *peerinfo_notify_handle; | 510 | static struct GNUNET_PEERSTORE_NotifyContext *peerstore_notify; |
510 | 511 | ||
511 | 512 | ||
512 | #if ENABLE_MALICIOUS | 513 | #if ENABLE_MALICIOUS |
@@ -4697,13 +4698,13 @@ valid_peers_iterator (void *cls, | |||
4697 | void | 4698 | void |
4698 | process_peerinfo_peers (void *cls, | 4699 | process_peerinfo_peers (void *cls, |
4699 | const struct GNUNET_PeerIdentity *peer, | 4700 | const struct GNUNET_PeerIdentity *peer, |
4700 | const struct GNUNET_HELLO_Message *hello, | 4701 | const struct GNUNET_MessageHeader *hello, |
4701 | const char *err_msg) | 4702 | const char *emsg) |
4702 | { | 4703 | { |
4703 | struct Sub *sub = cls; | 4704 | struct Sub *sub = cls; |
4704 | 4705 | ||
4705 | (void) hello; | 4706 | (void) hello; |
4706 | (void) err_msg; | 4707 | (void) emsg; |
4707 | 4708 | ||
4708 | if (NULL != peer) | 4709 | if (NULL != peer) |
4709 | { | 4710 | { |
@@ -4743,9 +4744,9 @@ shutdown_task (void *cls) | |||
4743 | } | 4744 | } |
4744 | 4745 | ||
4745 | /* Disconnect from other services */ | 4746 | /* Disconnect from other services */ |
4746 | GNUNET_PEERINFO_notify_cancel (peerinfo_notify_handle); | 4747 | GNUNET_PEERSTORE_hello_changed_notify_cancel (peerstore_notify); |
4747 | GNUNET_PEERINFO_disconnect (peerinfo_handle); | 4748 | GNUNET_PEERSTORE_disconnect (peerstore, GNUNET_YES); |
4748 | peerinfo_handle = NULL; | 4749 | peerstore = NULL; |
4749 | GNUNET_NSE_disconnect (nse); | 4750 | GNUNET_NSE_disconnect (nse); |
4750 | if (NULL != map_single_hop) | 4751 | if (NULL != map_single_hop) |
4751 | { | 4752 | { |
@@ -4935,7 +4936,7 @@ run (void *cls, | |||
4935 | round_interval); | 4936 | round_interval); |
4936 | 4937 | ||
4937 | 4938 | ||
4938 | peerinfo_handle = GNUNET_PEERINFO_connect (cfg); | 4939 | peerstore = GNUNET_PEERSTORE_connect (cfg); |
4939 | 4940 | ||
4940 | /* connect to NSE */ | 4941 | /* connect to NSE */ |
4941 | nse = GNUNET_NSE_connect (cfg, nse_callback, NULL); | 4942 | nse = GNUNET_NSE_connect (cfg, nse_callback, NULL); |
@@ -4947,10 +4948,10 @@ run (void *cls, | |||
4947 | restore_valid_peers (msub); | 4948 | restore_valid_peers (msub); |
4948 | get_valid_peers (msub->valid_peers, valid_peers_iterator, msub); | 4949 | get_valid_peers (msub->valid_peers, valid_peers_iterator, msub); |
4949 | 4950 | ||
4950 | peerinfo_notify_handle = GNUNET_PEERINFO_notify (cfg, | 4951 | peerstore_notify = GNUNET_PEERSTORE_hello_changed_notify (peerstore, |
4951 | GNUNET_NO, | 4952 | GNUNET_NO, |
4952 | process_peerinfo_peers, | 4953 | process_peerinfo_peers, |
4953 | msub); | 4954 | msub); |
4954 | 4955 | ||
4955 | LOG (GNUNET_ERROR_TYPE_INFO, "Ready to receive requests from clients\n"); | 4956 | LOG (GNUNET_ERROR_TYPE_INFO, "Ready to receive requests from clients\n"); |
4956 | 4957 | ||
diff --git a/src/topology/gnunet-daemon-topology.c b/src/topology/gnunet-daemon-topology.c index 8b2278897..b28269a77 100644 --- a/src/topology/gnunet-daemon-topology.c +++ b/src/topology/gnunet-daemon-topology.c | |||
@@ -324,7 +324,7 @@ attempt_connect (struct Peer *pos) | |||
324 | gettext_noop ("# connect requests issued to ATS"), | 324 | gettext_noop ("# connect requests issued to ATS"), |
325 | 1, | 325 | 1, |
326 | GNUNET_NO); | 326 | GNUNET_NO); |
327 | //TODO Use strength somehow. | 327 | // TODO Use strength somehow. |
328 | pos->ash = GNUNET_TRANSPORT_application_suggest (transport, | 328 | pos->ash = GNUNET_TRANSPORT_application_suggest (transport, |
329 | &pos->pid, | 329 | &pos->pid, |
330 | GNUNET_MQ_PRIO_BEST_EFFORT, | 330 | GNUNET_MQ_PRIO_BEST_EFFORT, |
@@ -438,11 +438,11 @@ find_advertisable_hello (void *cls, | |||
438 | "find_advertisable_hello\n"); | 438 | "find_advertisable_hello\n"); |
439 | if (pos == fah->peer) | 439 | if (pos == fah->peer) |
440 | return GNUNET_YES; | 440 | return GNUNET_YES; |
441 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 441 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
442 | "find_advertisable_hello 2\n"); | 442 | "find_advertisable_hello 2\n"); |
443 | if (pos->hello == NULL) | 443 | if (pos->hello == NULL) |
444 | return GNUNET_YES; | 444 | return GNUNET_YES; |
445 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 445 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
446 | "find_advertisable_hello 3\n"); | 446 | "find_advertisable_hello 3\n"); |
447 | rst_time = GNUNET_TIME_absolute_get_remaining (pos->filter_expiration); | 447 | rst_time = GNUNET_TIME_absolute_get_remaining (pos->filter_expiration); |
448 | if (0 == rst_time.rel_value_us) | 448 | if (0 == rst_time.rel_value_us) |
@@ -455,7 +455,7 @@ find_advertisable_hello (void *cls, | |||
455 | hs = pos->hello->size; | 455 | hs = pos->hello->size; |
456 | if (hs > fah->max_size) | 456 | if (hs > fah->max_size) |
457 | return GNUNET_YES; | 457 | return GNUNET_YES; |
458 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 458 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
459 | "find_advertisable_hello 4\n"); | 459 | "find_advertisable_hello 4\n"); |
460 | GNUNET_CRYPTO_hash (&fah->peer->pid, | 460 | GNUNET_CRYPTO_hash (&fah->peer->pid, |
461 | sizeof(struct GNUNET_PeerIdentity), | 461 | sizeof(struct GNUNET_PeerIdentity), |
@@ -482,7 +482,7 @@ schedule_next_hello (void *cls) | |||
482 | struct GNUNET_TIME_Relative delay; | 482 | struct GNUNET_TIME_Relative delay; |
483 | struct GNUNET_HashCode hc; | 483 | struct GNUNET_HashCode hc; |
484 | 484 | ||
485 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 485 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
486 | "schedule_next_hello\n"); | 486 | "schedule_next_hello\n"); |
487 | pl->hello_delay_task = NULL; | 487 | pl->hello_delay_task = NULL; |
488 | GNUNET_assert (NULL != pl->mq); | 488 | GNUNET_assert (NULL != pl->mq); |
@@ -752,14 +752,26 @@ consider_for_advertising (const struct GNUNET_MessageHeader *hello) | |||
752 | 752 | ||
753 | if (NULL != peer->hello) | 753 | if (NULL != peer->hello) |
754 | { | 754 | { |
755 | 755 | struct GNUNET_TIME_Absolute now = GNUNET_TIME_absolute_get (); | |
756 | env = GNUNET_HELLO_builder_merge_hellos (hello, peer->hello, my_private_key); | 756 | struct GNUNET_TIME_Absolute new_hello_exp = GNUNET_HELLO_builder_get_expiration_time (builder, |
757 | nh = GNUNET_MQ_env_get_msg (env); | 757 | hello); |
758 | if (NULL == nh) | 758 | struct GNUNET_HELLO_Builder *peer_builder = GNUNET_HELLO_builder_from_msg (peer->hello); |
759 | struct GNUNET_TIME_Absolute old_hello_exp = GNUNET_HELLO_builder_get_expiration_time (peer_builder, | ||
760 | peer->hello); | ||
761 | |||
762 | if (GNUNET_TIME_absolute_cmp (new_hello_exp, > , now) && GNUNET_TIME_absolute_cmp (new_hello_exp, > , old_hello_exp)) | ||
763 | { | ||
764 | GNUNET_free (peer->hello); | ||
765 | size = sizeof (hello); | ||
766 | peer->hello = GNUNET_malloc (size); | ||
767 | GNUNET_memcpy (peer->hello, hello, size); | ||
768 | } | ||
769 | else | ||
770 | { | ||
759 | return; | 771 | return; |
760 | GNUNET_free (peer->hello); | 772 | } |
761 | GNUNET_memcpy (peer->hello, nh, sizeof (nh)); | 773 | GNUNET_HELLO_builder_free (builder); |
762 | GNUNET_free (env); | 774 | GNUNET_HELLO_builder_free (peer_builder); |
763 | } | 775 | } |
764 | else | 776 | else |
765 | { | 777 | { |
@@ -806,7 +818,8 @@ process_peer (void *cls, | |||
806 | err_msg); | 818 | err_msg); |
807 | GNUNET_PEERSTORE_hello_changed_notify_cancel (peerstore_notify); | 819 | GNUNET_PEERSTORE_hello_changed_notify_cancel (peerstore_notify); |
808 | peerstore_notify = | 820 | peerstore_notify = |
809 | GNUNET_PEERSTORE_hello_changed_notify (ps, GNUNET_NO, &process_peer, NULL); | 821 | GNUNET_PEERSTORE_hello_changed_notify (ps, GNUNET_NO, &process_peer, |
822 | NULL); | ||
810 | return; | 823 | return; |
811 | } | 824 | } |
812 | GNUNET_assert (NULL != peer); | 825 | GNUNET_assert (NULL != peer); |
@@ -939,7 +952,8 @@ read_friends_file (const struct GNUNET_CONFIGURATION_Handle *cfg) | |||
939 | static int | 952 | static int |
940 | check_hello (void *cls, const struct GNUNET_MessageHeader *message) | 953 | check_hello (void *cls, const struct GNUNET_MessageHeader *message) |
941 | { | 954 | { |
942 | struct GNUNET_HELLO_Builder *builder = GNUNET_HELLO_builder_from_msg (message); | 955 | struct GNUNET_HELLO_Builder *builder = GNUNET_HELLO_builder_from_msg ( |
956 | message); | ||
943 | struct GNUNET_PeerIdentity *pid = GNUNET_HELLO_builder_get_id (builder); | 957 | struct GNUNET_PeerIdentity *pid = GNUNET_HELLO_builder_get_id (builder); |
944 | 958 | ||
945 | if (NULL == pid) | 959 | if (NULL == pid) |
@@ -951,6 +965,13 @@ check_hello (void *cls, const struct GNUNET_MessageHeader *message) | |||
951 | } | 965 | } |
952 | 966 | ||
953 | 967 | ||
968 | static void | ||
969 | shc_cont (void *cls, int success) | ||
970 | { | ||
971 | GNUNET_free (cls); | ||
972 | } | ||
973 | |||
974 | |||
954 | /** | 975 | /** |
955 | * This function is called whenever an encrypted HELLO message is | 976 | * This function is called whenever an encrypted HELLO message is |
956 | * received. | 977 | * received. |
@@ -961,9 +982,11 @@ check_hello (void *cls, const struct GNUNET_MessageHeader *message) | |||
961 | static void | 982 | static void |
962 | handle_hello (void *cls, const struct GNUNET_MessageHeader *message) | 983 | handle_hello (void *cls, const struct GNUNET_MessageHeader *message) |
963 | { | 984 | { |
985 | struct GNUNET_PEERSTORE_StoreHelloContext *shc; | ||
964 | const struct GNUNET_PeerIdentity *other = cls; | 986 | const struct GNUNET_PeerIdentity *other = cls; |
965 | struct Peer *peer; | 987 | struct Peer *peer; |
966 | struct GNUNET_HELLO_Builder *builder = GNUNET_HELLO_builder_from_msg (message); | 988 | struct GNUNET_HELLO_Builder *builder = GNUNET_HELLO_builder_from_msg ( |
989 | message); | ||
967 | struct GNUNET_PeerIdentity *pid = GNUNET_HELLO_builder_get_id (builder); | 990 | struct GNUNET_PeerIdentity *pid = GNUNET_HELLO_builder_get_id (builder); |
968 | 991 | ||
969 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 992 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
@@ -987,7 +1010,8 @@ handle_hello (void *cls, const struct GNUNET_MessageHeader *message) | |||
987 | (friend_count < minimum_friend_count)) | 1010 | (friend_count < minimum_friend_count)) |
988 | return; | 1011 | return; |
989 | } | 1012 | } |
990 | (void) GNUNET_PEERSTORE_hello_add (ps, message, my_private_key, NULL, NULL); | 1013 | GNUNET_HELLO_builder_from_msg (message); |
1014 | shc = GNUNET_PEERSTORE_hello_add (ps, message, &shc_cont, shc); | ||
991 | GNUNET_HELLO_builder_free (builder); | 1015 | GNUNET_HELLO_builder_free (builder); |
992 | } | 1016 | } |
993 | 1017 | ||
diff --git a/src/transport/gnunet-service-tng.c b/src/transport/gnunet-service-tng.c index b6039a2ae..5f2504c70 100644 --- a/src/transport/gnunet-service-tng.c +++ b/src/transport/gnunet-service-tng.c | |||
@@ -78,6 +78,7 @@ | |||
78 | #include "gnunet_transport_monitor_service.h" | 78 | #include "gnunet_transport_monitor_service.h" |
79 | #include "gnunet_peerstore_service.h" | 79 | #include "gnunet_peerstore_service.h" |
80 | #include "gnunet_hello_lib.h" | 80 | #include "gnunet_hello_lib.h" |
81 | #include "gnunet_hello_uri_lib.h" | ||
81 | #include "gnunet_signatures.h" | 82 | #include "gnunet_signatures.h" |
82 | #include "transport.h" | 83 | #include "transport.h" |
83 | 84 | ||
@@ -2766,6 +2767,11 @@ static const struct GNUNET_CONFIGURATION_Handle *GST_cfg; | |||
2766 | static struct GNUNET_PeerIdentity GST_my_identity; | 2767 | static struct GNUNET_PeerIdentity GST_my_identity; |
2767 | 2768 | ||
2768 | /** | 2769 | /** |
2770 | * Our HELLO | ||
2771 | */ | ||
2772 | struct GNUNET_HELLO_Builder *GST_my_hello; | ||
2773 | |||
2774 | /** | ||
2769 | * Our private key. | 2775 | * Our private key. |
2770 | */ | 2776 | */ |
2771 | static struct GNUNET_CRYPTO_EddsaPrivateKey *GST_my_private_key; | 2777 | static struct GNUNET_CRYPTO_EddsaPrivateKey *GST_my_private_key; |
@@ -5517,6 +5523,13 @@ peerstore_store_own_cb (void *cls, int success) | |||
5517 | } | 5523 | } |
5518 | 5524 | ||
5519 | 5525 | ||
5526 | static void | ||
5527 | shc_cont (void *cls, int success) | ||
5528 | { | ||
5529 | GNUNET_free (cls); | ||
5530 | } | ||
5531 | |||
5532 | |||
5520 | /** | 5533 | /** |
5521 | * Ask peerstore to store our address. | 5534 | * Ask peerstore to store our address. |
5522 | * | 5535 | * |
@@ -5526,9 +5539,13 @@ static void | |||
5526 | store_pi (void *cls) | 5539 | store_pi (void *cls) |
5527 | { | 5540 | { |
5528 | struct AddressListEntry *ale = cls; | 5541 | struct AddressListEntry *ale = cls; |
5542 | struct GNUNET_PEERSTORE_StoreHelloContext *shc; | ||
5529 | void *addr; | 5543 | void *addr; |
5530 | size_t addr_len; | 5544 | size_t addr_len; |
5531 | struct GNUNET_TIME_Absolute expiration; | 5545 | struct GNUNET_TIME_Absolute expiration; |
5546 | enum GNUNET_GenericReturnValue add_result; | ||
5547 | struct GNUNET_MQ_Envelope *env; | ||
5548 | const struct GNUNET_MessageHeader *msg = GNUNET_MQ_env_get_msg (env); | ||
5532 | 5549 | ||
5533 | ale->st = NULL; | 5550 | ale->st = NULL; |
5534 | expiration = GNUNET_TIME_relative_to_absolute (ale->expiration); | 5551 | expiration = GNUNET_TIME_relative_to_absolute (ale->expiration); |
@@ -5536,6 +5553,20 @@ store_pi (void *cls) | |||
5536 | "Storing our address `%s' in peerstore until %s!\n", | 5553 | "Storing our address `%s' in peerstore until %s!\n", |
5537 | ale->address, | 5554 | ale->address, |
5538 | GNUNET_STRINGS_absolute_time_to_string (expiration)); | 5555 | GNUNET_STRINGS_absolute_time_to_string (expiration)); |
5556 | add_result = GNUNET_HELLO_builder_add_address (GST_my_hello, | ||
5557 | ale->address); | ||
5558 | env = GNUNET_HELLO_builder_to_env (GST_my_hello, | ||
5559 | GST_my_private_key, | ||
5560 | GNUNET_TIME_UNIT_ZERO); | ||
5561 | if (GNUNET_YES == add_result) | ||
5562 | shc = GNUNET_PEERSTORE_hello_add (peerstore, | ||
5563 | msg, | ||
5564 | shc_cont, | ||
5565 | shc); | ||
5566 | else if (GNUNET_SYSERR == add_result) | ||
5567 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
5568 | "Error adding address to peerstore hello!\n"); | ||
5569 | |||
5539 | GNUNET_HELLO_sign_address (ale->address, | 5570 | GNUNET_HELLO_sign_address (ale->address, |
5540 | ale->nt, | 5571 | ale->nt, |
5541 | hello_mono_time, | 5572 | hello_mono_time, |
@@ -5553,6 +5584,7 @@ store_pi (void *cls) | |||
5553 | &peerstore_store_own_cb, | 5584 | &peerstore_store_own_cb, |
5554 | ale); | 5585 | ale); |
5555 | GNUNET_free (addr); | 5586 | GNUNET_free (addr); |
5587 | GNUNET_free (env); | ||
5556 | if (NULL == ale->sc) | 5588 | if (NULL == ale->sc) |
5557 | { | 5589 | { |
5558 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 5590 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
@@ -8733,7 +8765,7 @@ handle_validation_challenge ( | |||
8733 | ir->wc = GNUNET_PEERSTORE_watch (peerstore, | 8765 | ir->wc = GNUNET_PEERSTORE_watch (peerstore, |
8734 | "transport", | 8766 | "transport", |
8735 | &ir->pid, | 8767 | &ir->pid, |
8736 | GNUNET_PEERSTORE_TRANSPORT_URLADDRESS_KEY, | 8768 | GNUNET_PEERSTORE_HELLO_KEY, |
8737 | &handle_hello_for_incoming, | 8769 | &handle_hello_for_incoming, |
8738 | ir); | 8770 | ir); |
8739 | ir_total++; | 8771 | ir_total++; |
@@ -11259,7 +11291,7 @@ handle_suggest (void *cls, const struct ExpressPreferenceMessage *msg) | |||
11259 | pr->wc = GNUNET_PEERSTORE_watch (peerstore, | 11291 | pr->wc = GNUNET_PEERSTORE_watch (peerstore, |
11260 | "transport", | 11292 | "transport", |
11261 | &pr->pid, | 11293 | &pr->pid, |
11262 | GNUNET_PEERSTORE_TRANSPORT_URLADDRESS_KEY, | 11294 | GNUNET_PEERSTORE_HELLO_KEY, |
11263 | &handle_hello_for_client, | 11295 | &handle_hello_for_client, |
11264 | pr); | 11296 | pr); |
11265 | GNUNET_SERVICE_client_continue (tc->client); | 11297 | GNUNET_SERVICE_client_continue (tc->client); |
@@ -11445,6 +11477,11 @@ do_shutdown (void *cls) | |||
11445 | GNUNET_STATISTICS_destroy (GST_stats, GNUNET_NO); | 11477 | GNUNET_STATISTICS_destroy (GST_stats, GNUNET_NO); |
11446 | GST_stats = NULL; | 11478 | GST_stats = NULL; |
11447 | } | 11479 | } |
11480 | if (NULL != GST_my_hello) | ||
11481 | { | ||
11482 | GNUNET_HELLO_builder_free (GST_my_hello); | ||
11483 | GST_my_hello = NULL; | ||
11484 | } | ||
11448 | if (NULL != GST_my_private_key) | 11485 | if (NULL != GST_my_private_key) |
11449 | { | 11486 | { |
11450 | GNUNET_free (GST_my_private_key); | 11487 | GNUNET_free (GST_my_private_key); |
@@ -11555,6 +11592,7 @@ run (void *cls, | |||
11555 | GNUNET_CONTAINER_heap_create (GNUNET_CONTAINER_HEAP_ORDER_MIN); | 11592 | GNUNET_CONTAINER_heap_create (GNUNET_CONTAINER_HEAP_ORDER_MIN); |
11556 | GST_my_private_key = | 11593 | GST_my_private_key = |
11557 | GNUNET_CRYPTO_eddsa_key_create_from_configuration (GST_cfg); | 11594 | GNUNET_CRYPTO_eddsa_key_create_from_configuration (GST_cfg); |
11595 | GST_my_hello = GNUNET_HELLO_builder_new (&GST_my_identity); | ||
11558 | if (NULL == GST_my_private_key) | 11596 | if (NULL == GST_my_private_key) |
11559 | { | 11597 | { |
11560 | GNUNET_log ( | 11598 | GNUNET_log ( |
diff --git a/src/transport/plugin_transport_tcp.c b/src/transport/plugin_transport_tcp.c index ceae64709..e359185b6 100644 --- a/src/transport/plugin_transport_tcp.c +++ b/src/transport/plugin_transport_tcp.c | |||
@@ -1509,7 +1509,7 @@ tcp_nat_port_map_callback (void *cls, | |||
1509 | static const char * | 1509 | static const char * |
1510 | tcp_plugin_address_to_string (void *cls, const void *addr, size_t addrlen) | 1510 | tcp_plugin_address_to_string (void *cls, const void *addr, size_t addrlen) |
1511 | { | 1511 | { |
1512 | static char rbuf[INET6_ADDRSTRLEN + 12]; | 1512 | static char rbuf[INET6_ADDRSTRLEN + 16]; |
1513 | char buf[INET6_ADDRSTRLEN]; | 1513 | char buf[INET6_ADDRSTRLEN]; |
1514 | const void *sb; | 1514 | const void *sb; |
1515 | struct in_addr a4; | 1515 | struct in_addr a4; |