aboutsummaryrefslogtreecommitdiff
path: root/src/nse/gnunet-service-nse.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2013-09-30 21:03:31 +0000
committerChristian Grothoff <christian@grothoff.org>2013-09-30 21:03:31 +0000
commit6d5b099541c60303b664547f18f4aaa864e33d68 (patch)
tree3169f571d3f66ec23ab540d17c012f00103688f2 /src/nse/gnunet-service-nse.c
parenta0ba5b741b56036bd35bd9ba88164324b2ff7ada (diff)
downloadgnunet-6d5b099541c60303b664547f18f4aaa864e33d68.tar.gz
gnunet-6d5b099541c60303b664547f18f4aaa864e33d68.zip
-getting core, nse, testbed, ats-tool and peerinfo-tool to compile again (part of #3047)
Diffstat (limited to 'src/nse/gnunet-service-nse.c')
-rw-r--r--src/nse/gnunet-service-nse.c68
1 files changed, 34 insertions, 34 deletions
diff --git a/src/nse/gnunet-service-nse.c b/src/nse/gnunet-service-nse.c
index 98ace893e..2453c7e11 100644
--- a/src/nse/gnunet-service-nse.c
+++ b/src/nse/gnunet-service-nse.c
@@ -189,7 +189,7 @@ struct GNUNET_NSE_FloodMessage
189 /** 189 /**
190 * Public key of the originator. 190 * Public key of the originator.
191 */ 191 */
192 struct GNUNET_CRYPTO_EccPublicSignKey pkey; 192 struct GNUNET_PeerIdentity origin;
193 193
194 /** 194 /**
195 * Proof of work, causing leading zeros when hashed with pkey. 195 * Proof of work, causing leading zeros when hashed with pkey.
@@ -221,7 +221,7 @@ static struct GNUNET_CORE_Handle *coreAPI;
221/** 221/**
222 * Map of all connected peers. 222 * Map of all connected peers.
223 */ 223 */
224static struct GNUNET_CONTAINER_MultiHashMap *peers; 224static struct GNUNET_CONTAINER_MultiPeerMap *peers;
225 225
226/** 226/**
227 * The current network size estimate. Number of bits matching on 227 * The current network size estimate. Number of bits matching on
@@ -286,11 +286,6 @@ static struct GNUNET_TIME_Absolute next_timestamp;
286static struct GNUNET_TIME_Absolute current_timestamp; 286static struct GNUNET_TIME_Absolute current_timestamp;
287 287
288/** 288/**
289 * The public key of this peer.
290 */
291static struct GNUNET_CRYPTO_EccPublicSignKey my_public_key;
292
293/**
294 * The private key of this peer. 289 * The private key of this peer.
295 */ 290 */
296static struct GNUNET_CRYPTO_EccPrivateKey *my_private_key; 291static struct GNUNET_CRYPTO_EccPrivateKey *my_private_key;
@@ -392,7 +387,7 @@ setup_estimate_message (struct GNUNET_NSE_ClientMessage *em)
392 em->reserved = htonl (0); 387 em->reserved = htonl (0);
393 em->timestamp = GNUNET_TIME_absolute_hton (GNUNET_TIME_absolute_get ()); 388 em->timestamp = GNUNET_TIME_absolute_hton (GNUNET_TIME_absolute_get ());
394 double se = mean - 0.332747; 389 double se = mean - 0.332747;
395 nsize = log2 (GNUNET_CONTAINER_multihashmap_size (peers) + 1); 390 nsize = log2 (GNUNET_CONTAINER_multipeermap_size (peers) + 1);
396 em->size_estimate = GNUNET_hton_double (GNUNET_MAX (se, nsize)); 391 em->size_estimate = GNUNET_hton_double (GNUNET_MAX (se, nsize));
397 em->std_deviation = GNUNET_hton_double (std_dev); 392 em->std_deviation = GNUNET_hton_double (std_dev);
398 GNUNET_STATISTICS_set (stats, "# nodes in the network (estimate)", 393 GNUNET_STATISTICS_set (stats, "# nodes in the network (estimate)",
@@ -510,10 +505,12 @@ get_matching_bits (struct GNUNET_TIME_Absolute timestamp,
510 const struct GNUNET_PeerIdentity *id) 505 const struct GNUNET_PeerIdentity *id)
511{ 506{
512 struct GNUNET_HashCode timestamp_hash; 507 struct GNUNET_HashCode timestamp_hash;
508 struct GNUNET_HashCode pid_hash;
513 509
514 GNUNET_CRYPTO_hash (&timestamp.abs_value_us, sizeof (timestamp.abs_value_us), 510 GNUNET_CRYPTO_hash (&timestamp.abs_value_us, sizeof (timestamp.abs_value_us),
515 &timestamp_hash); 511 &timestamp_hash);
516 return GNUNET_CRYPTO_hash_matching_bits (&timestamp_hash, &id->hashPubKey); 512 GNUNET_CRYPTO_hash (id, sizeof (struct GNUNET_PeerIdentity), &pid_hash);
513 return GNUNET_CRYPTO_hash_matching_bits (&timestamp_hash, &pid_hash);
517} 514}
518 515
519 516
@@ -716,7 +713,7 @@ setup_flood_message (unsigned int slot,
716 sizeof (struct GNUNET_CRYPTO_EccSignature)); 713 sizeof (struct GNUNET_CRYPTO_EccSignature));
717 fm->matching_bits = htonl (matching_bits); 714 fm->matching_bits = htonl (matching_bits);
718 fm->timestamp = GNUNET_TIME_absolute_hton (ts); 715 fm->timestamp = GNUNET_TIME_absolute_hton (ts);
719 fm->pkey = my_public_key; 716 fm->origin = my_identity;
720 fm->proof_of_work = my_proof; 717 fm->proof_of_work = my_proof;
721 if (nse_work_required > 0) 718 if (nse_work_required > 0)
722 GNUNET_assert (GNUNET_OK == 719 GNUNET_assert (GNUNET_OK ==
@@ -738,7 +735,7 @@ setup_flood_message (unsigned int slot,
738 */ 735 */
739static int 736static int
740schedule_current_round (void *cls, 737schedule_current_round (void *cls,
741 const struct GNUNET_HashCode * key, 738 const struct GNUNET_PeerIdentity * key,
742 void *value) 739 void *value)
743{ 740{
744 struct NSEPeerEntry *peer_entry = value; 741 struct NSEPeerEntry *peer_entry = value;
@@ -817,7 +814,7 @@ update_flood_message (void *cls,
817 for (i = 0; i < HISTORY_SIZE; i++) 814 for (i = 0; i < HISTORY_SIZE; i++)
818 hop_count_max = 815 hop_count_max =
819 GNUNET_MAX (ntohl (size_estimate_messages[i].hop_count), hop_count_max); 816 GNUNET_MAX (ntohl (size_estimate_messages[i].hop_count), hop_count_max);
820 GNUNET_CONTAINER_multihashmap_iterate (peers, &schedule_current_round, NULL); 817 GNUNET_CONTAINER_multipeermap_iterate (peers, &schedule_current_round, NULL);
821 flood_task = 818 flood_task =
822 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_absolute_get_remaining 819 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_absolute_get_remaining
823 (next_timestamp), &update_flood_message, 820 (next_timestamp), &update_flood_message,
@@ -907,8 +904,8 @@ find_proof (void *cls,
907 unsigned int i; 904 unsigned int i;
908 905
909 proof_task = GNUNET_SCHEDULER_NO_TASK; 906 proof_task = GNUNET_SCHEDULER_NO_TASK;
910 memcpy (&buf[sizeof (uint64_t)], &my_public_key, 907 memcpy (&buf[sizeof (uint64_t)], &my_identity,
911 sizeof (struct GNUNET_CRYPTO_EccPublicSignKey)); 908 sizeof (struct GNUNET_PeerIdentity));
912 i = 0; 909 i = 0;
913 counter = my_proof; 910 counter = my_proof;
914 while ((counter != UINT64_MAX) && (i < ROUND_SIZE)) 911 while ((counter != UINT64_MAX) && (i < ROUND_SIZE))
@@ -959,7 +956,7 @@ static int
959verify_message_crypto (const struct GNUNET_NSE_FloodMessage *incoming_flood) 956verify_message_crypto (const struct GNUNET_NSE_FloodMessage *incoming_flood)
960{ 957{
961 if (GNUNET_YES != 958 if (GNUNET_YES !=
962 check_proof_of_work (&incoming_flood->pkey, 959 check_proof_of_work (&incoming_flood->origin.public_key,
963 incoming_flood->proof_of_work)) 960 incoming_flood->proof_of_work))
964 { 961 {
965 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Proof of work invalid: %llu!\n", 962 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Proof of work invalid: %llu!\n",
@@ -973,7 +970,7 @@ verify_message_crypto (const struct GNUNET_NSE_FloodMessage *incoming_flood)
973 GNUNET_CRYPTO_ecc_verify (GNUNET_SIGNATURE_PURPOSE_NSE_SEND, 970 GNUNET_CRYPTO_ecc_verify (GNUNET_SIGNATURE_PURPOSE_NSE_SEND,
974 &incoming_flood->purpose, 971 &incoming_flood->purpose,
975 &incoming_flood->signature, 972 &incoming_flood->signature,
976 &incoming_flood->pkey))) 973 &incoming_flood->origin.public_key)))
977 { 974 {
978 GNUNET_break_op (0); 975 GNUNET_break_op (0);
979 return GNUNET_NO; 976 return GNUNET_NO;
@@ -993,7 +990,7 @@ verify_message_crypto (const struct GNUNET_NSE_FloodMessage *incoming_flood)
993 */ 990 */
994static int 991static int
995update_flood_times (void *cls, 992update_flood_times (void *cls,
996 const struct GNUNET_HashCode *key, 993 const struct GNUNET_PeerIdentity *key,
997 void *value) 994 void *value)
998{ 995{
999 struct NSEPeerEntry *exclude = cls; 996 struct NSEPeerEntry *exclude = cls;
@@ -1062,11 +1059,14 @@ handle_p2p_size_estimate (void *cls,
1062 char pred[5]; 1059 char pred[5];
1063 struct GNUNET_PeerIdentity os; 1060 struct GNUNET_PeerIdentity os;
1064 1061
1065 GNUNET_CRYPTO_hash (&incoming_flood->pkey, 1062 GNUNET_snprintf (origin,
1066 sizeof (struct GNUNET_CRYPTO_EccPublicSignKey), 1063 sizeof (origin),
1067 &os.hashPubKey); 1064 "%4s",
1068 GNUNET_snprintf (origin, sizeof (origin), "%s", GNUNET_i2s (&os)); 1065 GNUNET_i2s (&incoming_flood->origin));
1069 GNUNET_snprintf (pred, sizeof (pred), "%s", GNUNET_i2s (peer)); 1066 GNUNET_snprintf (pred,
1067 sizeof (pred),
1068 "%4s",
1069 GNUNET_i2s (peer));
1070 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1070 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1071 "Flood at %s from `%s' via `%s' at `%s' with bits %u\n", 1071 "Flood at %s from `%s' via `%s' at `%s' with bits %u\n",
1072 GNUNET_STRINGS_absolute_time_to_string (GNUNET_TIME_absolute_ntoh (incoming_flood->timestamp)), 1072 GNUNET_STRINGS_absolute_time_to_string (GNUNET_TIME_absolute_ntoh (incoming_flood->timestamp)),
@@ -1075,7 +1075,7 @@ handle_p2p_size_estimate (void *cls,
1075 } 1075 }
1076#endif 1076#endif
1077 1077
1078 peer_entry = GNUNET_CONTAINER_multihashmap_get (peers, &peer->hashPubKey); 1078 peer_entry = GNUNET_CONTAINER_multipeermap_get (peers, peer);
1079 if (NULL == peer_entry) 1079 if (NULL == peer_entry)
1080 { 1080 {
1081 GNUNET_break (0); 1081 GNUNET_break (0);
@@ -1117,7 +1117,8 @@ handle_p2p_size_estimate (void *cls,
1117 { 1117 {
1118 /* send to self, update our own estimate IF this also comes from us! */ 1118 /* send to self, update our own estimate IF this also comes from us! */
1119 if (0 == 1119 if (0 ==
1120 memcmp (&incoming_flood->pkey, &my_public_key, sizeof (my_public_key))) 1120 memcmp (&incoming_flood->origin,
1121 &my_identity, sizeof (my_identity)))
1121 update_network_size_estimate (); 1122 update_network_size_estimate ();
1122 return GNUNET_OK; 1123 return GNUNET_OK;
1123 } 1124 }
@@ -1205,7 +1206,7 @@ handle_p2p_size_estimate (void *cls,
1205 update_network_size_estimate (); 1206 update_network_size_estimate ();
1206 1207
1207 /* flood to rest */ 1208 /* flood to rest */
1208 GNUNET_CONTAINER_multihashmap_iterate (peers, &update_flood_times, 1209 GNUNET_CONTAINER_multipeermap_iterate (peers, &update_flood_times,
1209 peer_entry); 1210 peer_entry);
1210 return GNUNET_OK; 1211 return GNUNET_OK;
1211} 1212}
@@ -1230,7 +1231,7 @@ handle_core_connect (void *cls,
1230 peer_entry = GNUNET_new (struct NSEPeerEntry); 1231 peer_entry = GNUNET_new (struct NSEPeerEntry);
1231 peer_entry->id = *peer; 1232 peer_entry->id = *peer;
1232 GNUNET_assert (GNUNET_OK == 1233 GNUNET_assert (GNUNET_OK ==
1233 GNUNET_CONTAINER_multihashmap_put (peers, &peer->hashPubKey, 1234 GNUNET_CONTAINER_multipeermap_put (peers, peer,
1234 peer_entry, 1235 peer_entry,
1235 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)); 1236 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY));
1236 peer_entry->transmit_task = 1237 peer_entry->transmit_task =
@@ -1256,14 +1257,14 @@ handle_core_disconnect (void *cls,
1256 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1257 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1257 "Peer `%s' disconnected from us\n", 1258 "Peer `%s' disconnected from us\n",
1258 GNUNET_i2s (peer)); 1259 GNUNET_i2s (peer));
1259 pos = GNUNET_CONTAINER_multihashmap_get (peers, &peer->hashPubKey); 1260 pos = GNUNET_CONTAINER_multipeermap_get (peers, peer);
1260 if (NULL == pos) 1261 if (NULL == pos)
1261 { 1262 {
1262 GNUNET_break (0); 1263 GNUNET_break (0);
1263 return; 1264 return;
1264 } 1265 }
1265 GNUNET_assert (GNUNET_YES == 1266 GNUNET_assert (GNUNET_YES ==
1266 GNUNET_CONTAINER_multihashmap_remove (peers, &peer->hashPubKey, 1267 GNUNET_CONTAINER_multipeermap_remove (peers, peer,
1267 pos)); 1268 pos));
1268 if (pos->transmit_task != GNUNET_SCHEDULER_NO_TASK) { 1269 if (pos->transmit_task != GNUNET_SCHEDULER_NO_TASK) {
1269 GNUNET_SCHEDULER_cancel (pos->transmit_task); 1270 GNUNET_SCHEDULER_cancel (pos->transmit_task);
@@ -1335,7 +1336,7 @@ shutdown_task (void *cls,
1335 } 1336 }
1336 if (NULL != peers) 1337 if (NULL != peers)
1337 { 1338 {
1338 GNUNET_CONTAINER_multihashmap_destroy (peers); 1339 GNUNET_CONTAINER_multipeermap_destroy (peers);
1339 peers = NULL; 1340 peers = NULL;
1340 } 1341 }
1341 if (NULL != my_private_key) 1342 if (NULL != my_private_key)
@@ -1381,7 +1382,7 @@ core_init (void *cls,
1381 GNUNET_TIME_absolute_add (current_timestamp, gnunet_nse_interval); 1382 GNUNET_TIME_absolute_add (current_timestamp, gnunet_nse_interval);
1382 estimate_index = HISTORY_SIZE - 1; 1383 estimate_index = HISTORY_SIZE - 1;
1383 estimate_count = 0; 1384 estimate_count = 0;
1384 if (GNUNET_YES == check_proof_of_work (&my_public_key, my_proof)) 1385 if (GNUNET_YES == check_proof_of_work (&my_identity.public_key, my_proof))
1385 { 1386 {
1386 int idx = (estimate_index + HISTORY_SIZE - 1) % HISTORY_SIZE; 1387 int idx = (estimate_index + HISTORY_SIZE - 1) % HISTORY_SIZE;
1387 prev_time.abs_value_us = 1388 prev_time.abs_value_us =
@@ -1476,9 +1477,8 @@ run (void *cls,
1476 pk = GNUNET_CRYPTO_ecc_key_create_from_configuration (cfg); 1477 pk = GNUNET_CRYPTO_ecc_key_create_from_configuration (cfg);
1477 GNUNET_assert (NULL != pk); 1478 GNUNET_assert (NULL != pk);
1478 my_private_key = pk; 1479 my_private_key = pk;
1479 GNUNET_CRYPTO_ecc_key_get_public_for_signature (my_private_key, &my_public_key); 1480 GNUNET_CRYPTO_ecc_key_get_public_for_signature (my_private_key,
1480 GNUNET_CRYPTO_hash (&my_public_key, sizeof (my_public_key), 1481 &my_identity.public_key);
1481 &my_identity.hashPubKey);
1482 if (GNUNET_OK != 1482 if (GNUNET_OK !=
1483 GNUNET_CONFIGURATION_get_value_filename (cfg, "NSE", "PROOFFILE", &proof)) 1483 GNUNET_CONFIGURATION_get_value_filename (cfg, "NSE", "PROOFFILE", &proof))
1484 { 1484 {
@@ -1499,7 +1499,7 @@ run (void *cls,
1499 GNUNET_SCHEDULER_add_with_priority (GNUNET_SCHEDULER_PRIORITY_IDLE, 1499 GNUNET_SCHEDULER_add_with_priority (GNUNET_SCHEDULER_PRIORITY_IDLE,
1500 &find_proof, NULL); 1500 &find_proof, NULL);
1501 1501
1502 peers = GNUNET_CONTAINER_multihashmap_create (128, GNUNET_NO); 1502 peers = GNUNET_CONTAINER_multipeermap_create (128, GNUNET_NO);
1503 GNUNET_SERVER_add_handlers (srv, handlers); 1503 GNUNET_SERVER_add_handlers (srv, handlers);
1504 nc = GNUNET_SERVER_notification_context_create (srv, 1); 1504 nc = GNUNET_SERVER_notification_context_create (srv, 1);
1505 /* Connect to core service and register core handlers */ 1505 /* Connect to core service and register core handlers */