aboutsummaryrefslogtreecommitdiff
path: root/src/transport/gnunet-service-tng.c
diff options
context:
space:
mode:
authort3sserakt <t3ss@posteo.de>2021-11-29 13:24:29 +0100
committert3sserakt <t3ss@posteo.de>2021-11-29 13:24:29 +0100
commit297ee1c85e3b8a1745193c854df2dec1126b7b99 (patch)
tree862872c1f89059dc9a43d21111eba4c932caf15a /src/transport/gnunet-service-tng.c
parentfdb9fc3b6f1333a05e093ed1a8aee63d6308ced1 (diff)
downloadgnunet-297ee1c85e3b8a1745193c854df2dec1126b7b99.tar.gz
gnunet-297ee1c85e3b8a1745193c854df2dec1126b7b99.zip
- added number of unintentional connects to connect cmd, fixed bugs in tcp communicator and tng service, added method to get a cmd not restricted to future or past cmds
Diffstat (limited to 'src/transport/gnunet-service-tng.c')
-rw-r--r--src/transport/gnunet-service-tng.c67
1 files changed, 60 insertions, 7 deletions
diff --git a/src/transport/gnunet-service-tng.c b/src/transport/gnunet-service-tng.c
index 4483536f0..f67bc0db5 100644
--- a/src/transport/gnunet-service-tng.c
+++ b/src/transport/gnunet-service-tng.c
@@ -5381,7 +5381,7 @@ handle_raw_message (void *cls, const struct GNUNET_MessageHeader *mh)
5381 int have_core; 5381 int have_core;
5382 5382
5383 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 5383 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
5384 "Handling message of type %u with %u bytes\n", 5384 "Handling raw message of type %u with %u bytes\n",
5385 (unsigned int) ntohs (mh->type), 5385 (unsigned int) ntohs (mh->type),
5386 (unsigned int) ntohs (mh->size)); 5386 (unsigned int) ntohs (mh->size));
5387 5387
@@ -6633,11 +6633,10 @@ forward_dv_learn (const struct GNUNET_PeerIdentity *next_hop,
6633 struct DvHopPS dhp = { 6633 struct DvHopPS dhp = {
6634 .purpose.purpose = htonl (GNUNET_SIGNATURE_PURPOSE_TRANSPORT_DV_HOP), 6634 .purpose.purpose = htonl (GNUNET_SIGNATURE_PURPOSE_TRANSPORT_DV_HOP),
6635 .purpose.size = htonl (sizeof(dhp)), 6635 .purpose.size = htonl (sizeof(dhp)),
6636 .pred = dhops[nhops - 1].hop, 6636 .pred = (0 == nhops) ? msg->initiator : dhops[nhops - 1].hop,
6637 .succ = *next_hop, 6637 .succ = *next_hop,
6638 .challenge = msg->challenge 6638 .challenge = msg->challenge
6639 }; 6639 };
6640
6641 GNUNET_CRYPTO_eddsa_sign (GST_my_private_key, 6640 GNUNET_CRYPTO_eddsa_sign (GST_my_private_key,
6642 &dhp, 6641 &dhp,
6643 &dhops[nhops].hop_sig); 6642 &dhops[nhops].hop_sig);
@@ -6940,7 +6939,14 @@ handle_dv_learn (void *cls, const struct TransportDVLearnMessage *dvl)
6940 struct GNUNET_TIME_Absolute in_time; 6939 struct GNUNET_TIME_Absolute in_time;
6941 struct Neighbour *n; 6940 struct Neighbour *n;
6942 6941
6943 nhops = ntohs (dvl->bidirectional); /* 0 = sender is initiator */ 6942 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
6943 "handle dv learn message from %s\n",
6944 GNUNET_i2s (&dvl->initiator));
6945 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
6946 "handle dv learn message sender %s\n",
6947 GNUNET_i2s (&cmc->im.sender));
6948
6949 nhops = ntohs (dvl->num_hops); /* 0 = sender is initiator */
6944 bi_history = ntohs (dvl->bidirectional); 6950 bi_history = ntohs (dvl->bidirectional);
6945 hops = (const struct DVPathEntryP *) &dvl[1]; 6951 hops = (const struct DVPathEntryP *) &dvl[1];
6946 if (0 == nhops) 6952 if (0 == nhops)
@@ -6955,6 +6961,9 @@ handle_dv_learn (void *cls, const struct TransportDVLearnMessage *dvl)
6955 } 6961 }
6956 else 6962 else
6957 { 6963 {
6964 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
6965 "handle dv learn message last hop %s\n",
6966 GNUNET_i2s (&hops[nhops - 1].hop));
6958 /* sanity check */ 6967 /* sanity check */
6959 if (0 != GNUNET_memcmp (&hops[nhops - 1].hop, &cmc->im.sender)) 6968 if (0 != GNUNET_memcmp (&hops[nhops - 1].hop, &cmc->im.sender))
6960 { 6969 {
@@ -6970,6 +6979,10 @@ handle_dv_learn (void *cls, const struct TransportDVLearnMessage *dvl)
6970 cc); // FIXME: add bi-directional flag to cc? 6979 cc); // FIXME: add bi-directional flag to cc?
6971 in_time = GNUNET_TIME_absolute_get (); 6980 in_time = GNUNET_TIME_absolute_get ();
6972 6981
6982 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
6983 "2 handle dv learn message from %s\n",
6984 GNUNET_i2s (&dvl->initiator));
6985
6973 /* continue communicator here, everything else can happen asynchronous! */ 6986 /* continue communicator here, everything else can happen asynchronous! */
6974 finish_cmc_handling (cmc); 6987 finish_cmc_handling (cmc);
6975 6988
@@ -6980,6 +6993,9 @@ handle_dv_learn (void *cls, const struct TransportDVLearnMessage *dvl)
6980 (GNUNET_TIME_absolute_ntoh (dvl->monotonic_time).abs_value_us < 6993 (GNUNET_TIME_absolute_ntoh (dvl->monotonic_time).abs_value_us <
6981 n->last_dv_learn_monotime.abs_value_us)) 6994 n->last_dv_learn_monotime.abs_value_us))
6982 { 6995 {
6996 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
6997 "DV learn from %s discarded due to time travel",
6998 GNUNET_i2s (&dvl->initiator));
6983 GNUNET_STATISTICS_update (GST_stats, 6999 GNUNET_STATISTICS_update (GST_stats,
6984 "# DV learn discarded due to time travel", 7000 "# DV learn discarded due to time travel",
6985 1, 7001 1,
@@ -6991,6 +7007,9 @@ handle_dv_learn (void *cls, const struct TransportDVLearnMessage *dvl)
6991 &dvl->challenge, 7007 &dvl->challenge,
6992 &dvl->init_sig)) 7008 &dvl->init_sig))
6993 { 7009 {
7010 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
7011 "DV learn signature from %s invalid",
7012 GNUNET_i2s (&dvl->initiator));
6994 GNUNET_break_op (0); 7013 GNUNET_break_op (0);
6995 return; 7014 return;
6996 } 7015 }
@@ -7012,6 +7031,9 @@ handle_dv_learn (void *cls, const struct TransportDVLearnMessage *dvl)
7012 n); 7031 n);
7013 } 7032 }
7014 } 7033 }
7034 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
7035 "3 handle dv learn message from %s\n",
7036 GNUNET_i2s (&dvl->initiator));
7015 /* OPTIMIZE-FIXME: asynchronously (!) verify signatures!, 7037 /* OPTIMIZE-FIXME: asynchronously (!) verify signatures!,
7016 If signature verification load too high, implement random drop strategy */ 7038 If signature verification load too high, implement random drop strategy */
7017 for (unsigned int i = 0; i < nhops; i++) 7039 for (unsigned int i = 0; i < nhops; i++)
@@ -7030,11 +7052,29 @@ handle_dv_learn (void *cls, const struct TransportDVLearnMessage *dvl)
7030 &hops[i].hop_sig, 7052 &hops[i].hop_sig,
7031 &hops[i].hop.public_key)) 7053 &hops[i].hop.public_key))
7032 { 7054 {
7055 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
7056 "DV learn from %s signature of hop %u invalid\n",
7057 GNUNET_i2s (&dvl->initiator),
7058 i);
7059 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
7060 "signature of hop %s invalid\n",
7061 GNUNET_i2s (&hops[i].hop));
7062 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
7063 "pred %s\n",
7064 GNUNET_i2s (&dhp.pred));
7065 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
7066 "succ %s\n",
7067 GNUNET_i2s (&dhp.succ));
7068 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
7069 "hash %s\n",
7070 GNUNET_sh2s (&dhp.challenge.value));
7033 GNUNET_break_op (0); 7071 GNUNET_break_op (0);
7034 return; 7072 return;
7035 } 7073 }
7036 } 7074 }
7037 7075 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
7076 "4 handle dv learn message from %s\n",
7077 GNUNET_i2s (&dvl->initiator));
7038 if (GNUNET_EXTRA_LOGGING > 0) 7078 if (GNUNET_EXTRA_LOGGING > 0)
7039 { 7079 {
7040 char *path; 7080 char *path;
@@ -7059,7 +7099,9 @@ handle_dv_learn (void *cls, const struct TransportDVLearnMessage *dvl)
7059 GNUNET_i2s (&GST_my_identity)); 7099 GNUNET_i2s (&GST_my_identity));
7060 GNUNET_free (path); 7100 GNUNET_free (path);
7061 } 7101 }
7062 7102 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
7103 "5 handle dv learn message from %s\n",
7104 GNUNET_i2s (&dvl->initiator));
7063 do_fwd = GNUNET_YES; 7105 do_fwd = GNUNET_YES;
7064 if (0 == GNUNET_memcmp (&GST_my_identity, &dvl->initiator)) 7106 if (0 == GNUNET_memcmp (&GST_my_identity, &dvl->initiator))
7065 { 7107 {
@@ -7104,6 +7146,9 @@ handle_dv_learn (void *cls, const struct TransportDVLearnMessage *dvl)
7104 do_fwd = GNUNET_NO; 7146 do_fwd = GNUNET_NO;
7105 return; 7147 return;
7106 } 7148 }
7149 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
7150 "6 handle dv learn message from %s\n",
7151 GNUNET_i2s (&dvl->initiator));
7107 if (bi_hop) 7152 if (bi_hop)
7108 { 7153 {
7109 /* last hop was bi-directional, we could learn something here! */ 7154 /* last hop was bi-directional, we could learn something here! */
@@ -7160,13 +7205,18 @@ handle_dv_learn (void *cls, const struct TransportDVLearnMessage *dvl)
7160 } 7205 }
7161 } 7206 }
7162 } 7207 }
7163 7208 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
7209 "7 handle dv learn message from %s\n",
7210 GNUNET_i2s (&dvl->initiator));
7164 if (MAX_DV_HOPS_ALLOWED == nhops) 7211 if (MAX_DV_HOPS_ALLOWED == nhops)
7165 { 7212 {
7166 /* At limit, we're out of here! */ 7213 /* At limit, we're out of here! */
7167 return; 7214 return;
7168 } 7215 }
7169 7216
7217 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
7218 "8 handle dv learn message from %s\n",
7219 GNUNET_i2s (&dvl->initiator));
7170 /* Forward to initiator, if path non-trivial and possible */ 7220 /* Forward to initiator, if path non-trivial and possible */
7171 bi_history = (bi_history << 1) | (bi_hop ? 1 : 0); 7221 bi_history = (bi_history << 1) | (bi_hop ? 1 : 0);
7172 did_initiator = GNUNET_NO; 7222 did_initiator = GNUNET_NO;
@@ -7220,6 +7270,9 @@ handle_dv_learn (void *cls, const struct TransportDVLearnMessage *dvl)
7220 &dv_neighbour_transmission, 7270 &dv_neighbour_transmission,
7221 &nsc); 7271 &nsc);
7222 } 7272 }
7273 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
7274 "9 handle dv learn message from %s\n",
7275 GNUNET_i2s (&dvl->initiator));
7223} 7276}
7224 7277
7225 7278