aboutsummaryrefslogtreecommitdiff
path: root/src/transport
diff options
context:
space:
mode:
Diffstat (limited to 'src/transport')
-rw-r--r--src/transport/Makefile.am1
-rw-r--r--src/transport/gnunet-communicator-tcp.c699
-rw-r--r--src/transport/gnunet-service-tng.c13
-rw-r--r--src/transport/test_communicator_basic.c16
-rw-r--r--src/transport/test_communicator_tcp_basic_peer1.conf5
-rw-r--r--src/transport/test_communicator_tcp_basic_peer2.conf5
-rw-r--r--src/transport/test_communicator_tcp_rekey_peer1.conf9
-rw-r--r--src/transport/test_communicator_tcp_rekey_peer2.conf9
-rw-r--r--src/transport/test_communicator_udp_backchannel_peer1.conf7
-rw-r--r--src/transport/test_communicator_udp_backchannel_peer2.conf7
-rw-r--r--src/transport/test_communicator_udp_basic_peer1.conf7
-rw-r--r--src/transport/test_communicator_udp_basic_peer2.conf8
-rw-r--r--src/transport/test_communicator_udp_rekey_peer1.conf7
-rw-r--r--src/transport/test_communicator_udp_rekey_peer2.conf7
-rw-r--r--src/transport/test_communicator_unix_basic_peer1.conf7
-rw-r--r--src/transport/test_communicator_unix_basic_peer2.conf7
-rw-r--r--src/transport/transport-testing2.c77
17 files changed, 788 insertions, 103 deletions
diff --git a/src/transport/Makefile.am b/src/transport/Makefile.am
index 354bb1cf4..e0369059d 100644
--- a/src/transport/Makefile.am
+++ b/src/transport/Makefile.am
@@ -278,6 +278,7 @@ gnunet_communicator_tcp_SOURCES = \
278 gnunet-communicator-tcp.c 278 gnunet-communicator-tcp.c
279gnunet_communicator_tcp_LDADD = \ 279gnunet_communicator_tcp_LDADD = \
280 libgnunettransportcommunicator.la \ 280 libgnunettransportcommunicator.la \
281 $(top_builddir)/src/peerstore/libgnunetpeerstore.la \
281 $(top_builddir)/src/nat/libgnunetnatnew.la \ 282 $(top_builddir)/src/nat/libgnunetnatnew.la \
282 $(top_builddir)/src/nt/libgnunetnt.la \ 283 $(top_builddir)/src/nt/libgnunetnt.la \
283 $(top_builddir)/src/statistics/libgnunetstatistics.la \ 284 $(top_builddir)/src/statistics/libgnunetstatistics.la \
diff --git a/src/transport/gnunet-communicator-tcp.c b/src/transport/gnunet-communicator-tcp.c
index 177b5c26c..880145424 100644
--- a/src/transport/gnunet-communicator-tcp.c
+++ b/src/transport/gnunet-communicator-tcp.c
@@ -24,26 +24,22 @@
24 * @author Christian Grothoff 24 * @author Christian Grothoff
25 * 25 *
26 * TODO: 26 * TODO:
27 * - support DNS names in BINDTO option (#5528)
28 * - support NAT connection reversal method (#5529) 27 * - support NAT connection reversal method (#5529)
29 * - support other TCP-specific NAT traversal methods (#5531) 28 * - support other TCP-specific NAT traversal methods (#5531)
30 * - add replay protection support to the protocol by
31 * adding a nonce in the KX and requiring (!) a
32 * nounce ACK to be send within the first X bytes of
33 * data (#5530)
34 */ 29 */
35#include "platform.h" 30#include "platform.h"
36#include "gnunet_util_lib.h" 31#include "gnunet_util_lib.h"
32#include "gnunet_core_service.h"
33#include "gnunet_peerstore_service.h"
37#include "gnunet_protocols.h" 34#include "gnunet_protocols.h"
38#include "gnunet_signatures.h" 35#include "gnunet_signatures.h"
39#include "gnunet_constants.h" 36#include "gnunet_constants.h"
40#include "gnunet_nt_lib.h" 37#include "gnunet_nt_lib.h"
41#include "gnunet_nat_service.h" 38#include "gnunet_nat_service.h"
42#include "gnunet_statistics_service.h" 39#include "gnunet_statistics_service.h"
43#include "gnunet_ats_transport_service.h"
44#include "transport.h"
45#include "gnunet_transport_communication_service.h" 40#include "gnunet_transport_communication_service.h"
46#include "gnunet_resolver_service.h" 41#include "gnunet_resolver_service.h"
42
47/** 43/**
48 * How long do we believe our addresses to remain up (before 44 * How long do we believe our addresses to remain up (before
49 * the other peer should revalidate). 45 * the other peer should revalidate).
@@ -91,6 +87,13 @@
91 (sizeof(struct GNUNET_CRYPTO_EcdhePublicKey) \ 87 (sizeof(struct GNUNET_CRYPTO_EcdhePublicKey) \
92 + sizeof(struct TCPConfirmation)) 88 + sizeof(struct TCPConfirmation))
93 89
90/**
91 * Size of the initial core key exchange messages.
92 */
93#define INITIAL_CORE_KX_SIZE \
94 (sizeof(struct EphemeralKeyMessage) \
95 + sizeof(struct PingMessage) \
96 + sizeof(struct PongMessage))
94 97
95/** 98/**
96 * Address prefix used by the communicator. 99 * Address prefix used by the communicator.
@@ -136,8 +139,45 @@ struct TcpHandshakeSignature
136 * (if receiver persists times by sender). 139 * (if receiver persists times by sender).
137 */ 140 */
138 struct GNUNET_TIME_AbsoluteNBO monotonic_time; 141 struct GNUNET_TIME_AbsoluteNBO monotonic_time;
142
143 /**
144 * Challenge value used to protect against replay attack, if there is no stored monotonic time value.
145 */
146 struct ChallengeNonceP challenge;
139}; 147};
140 148
149/**
150 * Signature we use to verify that the ack from the receiver of the ephemeral key was really send by
151 * the specified sender.
152 */
153struct TcpHandshakeAckSignature
154{
155 /**
156 * Purpose must be #GNUNET_SIGNATURE_COMMUNICATOR_TCP_HANDSHAKE_ACK
157 */
158 struct GNUNET_CRYPTO_EccSignaturePurpose purpose;
159
160 /**
161 * Identity of the inititor of the TCP connection (TCP client).
162 */
163 struct GNUNET_PeerIdentity sender;
164
165 /**
166 * Presumed identity of the target of the TCP connection (TCP server)
167 */
168 struct GNUNET_PeerIdentity receiver;
169
170 /**
171 * Monotonic time of @e sender, to possibly help detect replay attacks
172 * (if receiver persists times by sender).
173 */
174 struct GNUNET_TIME_AbsoluteNBO monotonic_time;
175
176 /**
177 * Challenge value used to protect against replay attack, if there is no stored monotonic time value.
178 */
179 struct ChallengeNonceP challenge;
180};
141 181
142/** 182/**
143 * Encrypted continuation of TCP initial handshake. 183 * Encrypted continuation of TCP initial handshake.
@@ -159,8 +199,48 @@ struct TCPConfirmation
159 * (if receiver persists times by sender). 199 * (if receiver persists times by sender).
160 */ 200 */
161 struct GNUNET_TIME_AbsoluteNBO monotonic_time; 201 struct GNUNET_TIME_AbsoluteNBO monotonic_time;
202
203 /**
204 * Challenge value used to protect against replay attack, if there is no stored monotonic time value.
205 */
206 struct ChallengeNonceP challenge;
207
162}; 208};
163 209
210/**
211 * Ack for the encrypted continuation of TCP initial handshake.
212 */
213struct TCPConfirmationAck
214{
215
216
217 /**
218 * Type is #GNUNET_MESSAGE_TYPE_COMMUNICATOR_TCP_CONFIRMATION_ACK.
219 */
220 struct GNUNET_MessageHeader header;
221
222 /**
223 * Sender's identity
224 */
225 struct GNUNET_PeerIdentity sender;
226
227 /**
228 * Sender's signature of type #GNUNET_SIGNATURE_COMMUNICATOR_TCP_HANDSHAKE_ACK
229 */
230 struct GNUNET_CRYPTO_EddsaSignature sender_sig;
231
232 /**
233 * Monotonic time of @e sender, to possibly help detect replay attacks
234 * (if receiver persists times by sender).
235 */
236 struct GNUNET_TIME_AbsoluteNBO monotonic_time;
237
238 /**
239 * Challenge value used to protect against replay attack, if there is no stored monotonic time value.
240 */
241 struct ChallengeNonceP challenge;
242
243};
164 244
165/** 245/**
166 * TCP message box. Always sent encrypted! 246 * TCP message box. Always sent encrypted!
@@ -456,6 +536,56 @@ struct Queue
456 * re-decrypt ciphertext. 536 * re-decrypt ciphertext.
457 */ 537 */
458 int rekeyed; 538 int rekeyed;
539
540 /**
541 * Monotonic time value for rekey message.
542 */
543 struct GNUNET_TIME_AbsoluteNBO rekey_monotonic_time;
544
545 /**
546 * Monotonic time value for handshake message.
547 */
548 struct GNUNET_TIME_AbsoluteNBO handshake_monotonic_time;
549
550 /**
551 * Monotonic time value for handshake ack message.
552 */
553 struct GNUNET_TIME_AbsoluteNBO handshake_ack_monotonic_time;
554
555 /**
556 * Challenge value used to protect against replay attack, if there is no stored monotonic time value.
557 */
558 struct ChallengeNonceP challenge;
559
560 /**
561 * Iteration Context for retrieving the monotonic time send with key for rekeying.
562 */
563 struct GNUNET_PEERSTORE_IterateContext *rekey_monotime_get;
564
565 /**
566 * Iteration Context for retrieving the monotonic time send with the handshake.
567 */
568 struct GNUNET_PEERSTORE_IterateContext *handshake_monotime_get;
569
570 /**
571 * Iteration Context for retrieving the monotonic time send with the handshake ack.
572 */
573 struct GNUNET_PEERSTORE_IterateContext *handshake_ack_monotime_get;
574
575 /**
576 * Store Context for retrieving the monotonic time send with key for rekeying.
577 */
578 struct GNUNET_PEERSTORE_StoreContext *rekey_monotime_sc;
579
580 /**
581 * Store Context for retrieving the monotonic time send with the handshake.
582 */
583 struct GNUNET_PEERSTORE_StoreContext *handshake_monotime_sc;
584
585 /**
586 * Store Context for retrieving the monotonic time send with the handshake ack.
587 */
588 struct GNUNET_PEERSTORE_StoreContext *handshake_ack_monotime_sc;
459}; 589};
460 590
461 591
@@ -535,7 +665,7 @@ struct PortOnlyIpv4Ipv6
535 /** 665 /**
536 * Length of ipv4 address. 666 * Length of ipv4 address.
537 */ 667 */
538 socklen_t *addr_len_ipv4; 668 socklen_t addr_len_ipv4;
539 669
540 /** 670 /**
541 * Ipv6 address we like to bind to. 671 * Ipv6 address we like to bind to.
@@ -545,7 +675,7 @@ struct PortOnlyIpv4Ipv6
545 /** 675 /**
546 * Length of ipv6 address. 676 * Length of ipv6 address.
547 */ 677 */
548 socklen_t *addr_len_ipv6; 678 socklen_t addr_len_ipv6;
549 679
550}; 680};
551 681
@@ -577,6 +707,7 @@ struct Addresses
577}; 707};
578 708
579 709
710
580/** 711/**
581 * Maximum queue length before we stop reading towards the transport service. 712 * Maximum queue length before we stop reading towards the transport service.
582 */ 713 */
@@ -658,6 +789,16 @@ struct Addresses *addrs_tail;
658int addrs_lens; 789int addrs_lens;
659 790
660/** 791/**
792 * Size of data received without KX challenge played back.
793 */
794size_t unverified_size;
795
796/**
797 * Database for peer's HELLOs.
798 */
799static struct GNUNET_PEERSTORE_Handle *peerstore;
800
801/**
661 * We have been notified that our listen socket has something to 802 * We have been notified that our listen socket has something to
662 * read. Do the read and reschedule this function to be called again 803 * read. Do the read and reschedule this function to be called again
663 * once more is available. 804 * once more is available.
@@ -687,6 +828,36 @@ queue_destroy (struct Queue *queue)
687 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 828 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
688 "Disconnecting queue for peer `%s'\n", 829 "Disconnecting queue for peer `%s'\n",
689 GNUNET_i2s (&queue->target)); 830 GNUNET_i2s (&queue->target));
831 if (NULL != queue->rekey_monotime_sc)
832 {
833 GNUNET_PEERSTORE_store_cancel (queue->rekey_monotime_sc);
834 queue->rekey_monotime_sc = NULL;
835 }
836 if (NULL != queue->handshake_monotime_sc)
837 {
838 GNUNET_PEERSTORE_store_cancel (queue->handshake_monotime_sc);
839 queue->handshake_monotime_sc = NULL;
840 }
841 if (NULL != queue->handshake_ack_monotime_sc)
842 {
843 GNUNET_PEERSTORE_store_cancel (queue->handshake_ack_monotime_sc);
844 queue->handshake_ack_monotime_sc = NULL;
845 }
846 if (NULL != queue->rekey_monotime_get)
847 {
848 GNUNET_PEERSTORE_iterate_cancel (queue->rekey_monotime_get);
849 queue->rekey_monotime_get = NULL;
850 }
851 if (NULL != queue->handshake_monotime_get)
852 {
853 GNUNET_PEERSTORE_iterate_cancel (queue->handshake_monotime_get);
854 queue->handshake_monotime_get = NULL;
855 }
856 if (NULL != queue->handshake_ack_monotime_get)
857 {
858 GNUNET_PEERSTORE_iterate_cancel (queue->handshake_ack_monotime_get);
859 queue->handshake_ack_monotime_get = NULL;
860 }
690 if (NULL != (mq = queue->mq)) 861 if (NULL != (mq = queue->mq))
691 { 862 {
692 queue->mq = NULL; 863 queue->mq = NULL;
@@ -964,6 +1135,78 @@ setup_in_cipher (const struct GNUNET_CRYPTO_EcdhePublicKey *ephemeral,
964 setup_cipher (&dh, &my_identity, &queue->in_cipher, &queue->in_hmac); 1135 setup_cipher (&dh, &my_identity, &queue->in_cipher, &queue->in_hmac);
965} 1136}
966 1137
1138/**
1139 * Callback called when peerstore store operation for rekey monotime value is finished.
1140 * @param cls Queue context the store operation was executed.
1141 * @param success Store operation was successful (GNUNET_OK) or not.
1142 */
1143static void
1144rekey_monotime_store_cb (void *cls, int success)
1145{
1146 struct Queue *queue = cls;
1147 if (GNUNET_OK != success)
1148 {
1149 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
1150 "Failed to store rekey monotonic time in PEERSTORE!\n");
1151 }
1152 queue->rekey_monotime_sc = NULL;
1153}
1154
1155/**
1156 * Callback called by peerstore when records for GNUNET_PEERSTORE_TRANSPORT_TCP_COMMUNICATOR_REKEY
1157 * where found.
1158 * @param cls Queue context the store operation was executed.
1159 * @param record The record found or NULL if there is no record left.
1160 * @param emsg Message from peerstore.
1161 */
1162static void
1163rekey_monotime_cb (void *cls,
1164 const struct GNUNET_PEERSTORE_Record *record,
1165 const char *emsg)
1166{
1167 struct Queue *queue = cls;
1168 struct GNUNET_TIME_AbsoluteNBO *mtbe;
1169 struct GNUNET_TIME_Absolute mt;
1170 const struct GNUNET_PeerIdentity *pid;
1171 struct GNUNET_TIME_AbsoluteNBO *rekey_monotonic_time;
1172
1173 (void) emsg;
1174
1175 rekey_monotonic_time = &queue->rekey_monotonic_time;
1176 pid = &queue->target;
1177 if (NULL == record)
1178 {
1179 queue->rekey_monotime_get = NULL;
1180 return;
1181 }
1182 if (sizeof(*mtbe) != record->value_size)
1183 {
1184 GNUNET_break (0);
1185 return;
1186 }
1187 mtbe = record->value;
1188 mt = GNUNET_TIME_absolute_ntoh (*mtbe);
1189 if (mt.abs_value_us > GNUNET_TIME_absolute_ntoh (
1190 queue->rekey_monotonic_time).abs_value_us)
1191 {
1192 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
1193 "Queue from %s dropped, rekey monotime in the past\n",
1194 GNUNET_i2s (&queue->target));
1195 GNUNET_break (0);
1196 queue_finish (queue);
1197 return;
1198 }
1199 queue->rekey_monotime_sc = GNUNET_PEERSTORE_store (peerstore,
1200 "transport_tcp_communicator",
1201 pid,
1202 GNUNET_PEERSTORE_TRANSPORT_TCP_COMMUNICATOR_REKEY,
1203 rekey_monotonic_time,
1204 sizeof(rekey_monotonic_time),
1205 GNUNET_TIME_UNIT_FOREVER_ABS,
1206 GNUNET_PEERSTORE_STOREOPTION_REPLACE,
1207 &rekey_monotime_store_cb,
1208 queue);
1209}
967 1210
968/** 1211/**
969 * Handle @a rekey message on @a queue. The message was already 1212 * Handle @a rekey message on @a queue. The message was already
@@ -983,7 +1226,6 @@ do_rekey (struct Queue *queue, const struct TCPRekey *rekey)
983 thp.receiver = my_identity; 1226 thp.receiver = my_identity;
984 thp.ephemeral = rekey->ephemeral; 1227 thp.ephemeral = rekey->ephemeral;
985 thp.monotonic_time = rekey->monotonic_time; 1228 thp.monotonic_time = rekey->monotonic_time;
986 /* FIXME: check monotonic time is monotonic... */
987 if (GNUNET_OK != 1229 if (GNUNET_OK !=
988 GNUNET_CRYPTO_eddsa_verify (GNUNET_SIGNATURE_COMMUNICATOR_TCP_REKEY, 1230 GNUNET_CRYPTO_eddsa_verify (GNUNET_SIGNATURE_COMMUNICATOR_TCP_REKEY,
989 &thp, 1231 &thp,
@@ -994,11 +1236,93 @@ do_rekey (struct Queue *queue, const struct TCPRekey *rekey)
994 queue_finish (queue); 1236 queue_finish (queue);
995 return; 1237 return;
996 } 1238 }
1239 queue->rekey_monotonic_time = rekey->monotonic_time;
1240 queue->rekey_monotime_get = GNUNET_PEERSTORE_iterate (peerstore,
1241 "transport_tcp_communicator",
1242 &queue->target,
1243 GNUNET_PEERSTORE_TRANSPORT_TCP_COMMUNICATOR_REKEY,
1244 &rekey_monotime_cb,
1245 queue);
997 gcry_cipher_close (queue->in_cipher); 1246 gcry_cipher_close (queue->in_cipher);
998 queue->rekeyed = GNUNET_YES; 1247 queue->rekeyed = GNUNET_YES;
999 setup_in_cipher (&rekey->ephemeral, queue); 1248 setup_in_cipher (&rekey->ephemeral, queue);
1000} 1249}
1001 1250
1251/**
1252 * Callback called when peerstore store operation for handshake ack monotime value is finished.
1253 * @param cls Queue context the store operation was executed.
1254 * @param success Store operation was successful (GNUNET_OK) or not.
1255 */
1256static void
1257handshake_ack_monotime_store_cb (void *cls, int success)
1258{
1259 struct Queue *queue = cls;
1260
1261 if (GNUNET_OK != success)
1262 {
1263 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
1264 "Failed to store handshake ack monotonic time in PEERSTORE!\n");
1265 }
1266 queue->handshake_ack_monotime_sc = NULL;
1267}
1268
1269/**
1270 * Callback called by peerstore when records for GNUNET_PEERSTORE_TRANSPORT_TCP_COMMUNICATOR_HANDSHAKE_ACK
1271 * where found.
1272 * @param cls Queue context the store operation was executed.
1273 * @param record The record found or NULL if there is no record left.
1274 * @param emsg Message from peerstore.
1275 */
1276static void
1277handshake_ack_monotime_cb (void *cls,
1278 const struct GNUNET_PEERSTORE_Record *record,
1279 const char *emsg)
1280{
1281 struct Queue *queue = cls;
1282 struct GNUNET_TIME_AbsoluteNBO *mtbe;
1283 struct GNUNET_TIME_Absolute mt;
1284 const struct GNUNET_PeerIdentity *pid;
1285 struct GNUNET_TIME_AbsoluteNBO *handshake_ack_monotonic_time;
1286
1287 (void) emsg;
1288
1289 handshake_ack_monotonic_time = &queue->handshake_ack_monotonic_time;
1290 pid = &queue->target;
1291 if (NULL == record)
1292 {
1293 queue->handshake_ack_monotime_get = NULL;
1294 return;
1295 }
1296 if (sizeof(*mtbe) != record->value_size)
1297 {
1298 GNUNET_break (0);
1299 return;
1300 }
1301 mtbe = record->value;
1302 mt = GNUNET_TIME_absolute_ntoh (*mtbe);
1303 if (mt.abs_value_us > GNUNET_TIME_absolute_ntoh (
1304 queue->handshake_ack_monotonic_time).abs_value_us)
1305 {
1306 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
1307 "Queue from %s dropped, handshake ack monotime in the past\n",
1308 GNUNET_i2s (&queue->target));
1309 GNUNET_break (0);
1310 queue_finish (queue);
1311 return;
1312 }
1313 queue->handshake_ack_monotime_sc = GNUNET_PEERSTORE_store (peerstore,
1314 "transport_tcp_communicator",
1315 pid,
1316 GNUNET_PEERSTORE_TRANSPORT_TCP_COMMUNICATOR_HANDSHAKE_ACK,
1317 handshake_ack_monotonic_time,
1318 sizeof(
1319 handshake_ack_monotonic_time),
1320 GNUNET_TIME_UNIT_FOREVER_ABS,
1321 GNUNET_PEERSTORE_STOREOPTION_REPLACE,
1322 &
1323 handshake_ack_monotime_store_cb,
1324 queue);
1325}
1002 1326
1003/** 1327/**
1004 * Test if we have received a full message in plaintext. 1328 * Test if we have received a full message in plaintext.
@@ -1012,6 +1336,8 @@ try_handle_plaintext (struct Queue *queue)
1012{ 1336{
1013 const struct GNUNET_MessageHeader *hdr = 1337 const struct GNUNET_MessageHeader *hdr =
1014 (const struct GNUNET_MessageHeader *) queue->pread_buf; 1338 (const struct GNUNET_MessageHeader *) queue->pread_buf;
1339 const struct TCPConfirmationAck *tca = (const struct
1340 TCPConfirmationAck *) queue->pread_buf;
1015 const struct TCPBox *box = (const struct TCPBox *) queue->pread_buf; 1341 const struct TCPBox *box = (const struct TCPBox *) queue->pread_buf;
1016 const struct TCPRekey *rekey = (const struct TCPRekey *) queue->pread_buf; 1342 const struct TCPRekey *rekey = (const struct TCPRekey *) queue->pread_buf;
1017 const struct TCPFinish *fin = (const struct TCPFinish *) queue->pread_buf; 1343 const struct TCPFinish *fin = (const struct TCPFinish *) queue->pread_buf;
@@ -1020,12 +1346,92 @@ try_handle_plaintext (struct Queue *queue)
1020 struct GNUNET_ShortHashCode tmac; 1346 struct GNUNET_ShortHashCode tmac;
1021 uint16_t type; 1347 uint16_t type;
1022 size_t size = 0; /* make compiler happy */ 1348 size_t size = 0; /* make compiler happy */
1349 struct TcpHandshakeAckSignature thas;
1350 const struct ChallengeNonceP challenge = queue->challenge;
1023 1351
1024 if (sizeof(*hdr) > queue->pread_off) 1352 if ((sizeof(*hdr) > queue->pread_off))
1353 {
1354 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1355 "Handling plaintext, not even a header!\n");
1025 return 0; /* not even a header */ 1356 return 0; /* not even a header */
1357 }
1358
1359 if ((-1 != unverified_size) && (unverified_size > INITIAL_CORE_KX_SIZE))
1360 {
1361 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
1362 "Already received data of size %u bigger than KX size %u!\n",
1363 unverified_size,
1364 INITIAL_CORE_KX_SIZE);
1365 GNUNET_break_op (0);
1366 queue_finish (queue);
1367 return 0;
1368 }
1369
1026 type = ntohs (hdr->type); 1370 type = ntohs (hdr->type);
1027 switch (type) 1371 switch (type)
1028 { 1372 {
1373 case GNUNET_MESSAGE_TYPE_COMMUNICATOR_TCP_CONFIRMATION_ACK:
1374 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1375 "start processing ack\n");
1376 if (sizeof(*tca) > queue->pread_off)
1377 {
1378 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1379 "Handling plaintext size of tca greater than pread offset.\n");
1380 return 0;
1381 }
1382 if (ntohs (hdr->size) != sizeof(*tca))
1383 {
1384 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1385 "Handling plaintext size does not match message type.\n");
1386 GNUNET_break_op (0);
1387 queue_finish (queue);
1388 return 0;
1389 }
1390
1391 thas.purpose.purpose = htonl (
1392 GNUNET_SIGNATURE_COMMUNICATOR_TCP_HANDSHAKE_ACK);
1393 thas.purpose.size = htonl (sizeof(thas));
1394 thas.sender = tca->sender;
1395 thas.receiver = my_identity;
1396 thas.monotonic_time = tca->monotonic_time;
1397 thas.challenge = tca->challenge;
1398
1399 if (GNUNET_SYSERR == GNUNET_CRYPTO_eddsa_verify (
1400 GNUNET_SIGNATURE_COMMUNICATOR_TCP_HANDSHAKE_ACK,
1401 &thas,
1402 &tca->sender_sig,
1403 &tca->sender.public_key))
1404 {
1405 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
1406 "Verification of signature failed!\n");
1407 GNUNET_break (0);
1408 queue_finish (queue);
1409 return 0;
1410 }
1411 if (0 != GNUNET_memcmp (&tca->challenge, &challenge))
1412 {
1413 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
1414 "Challenge in TCPConfirmationAck not correct!\n");
1415 GNUNET_break (0);
1416 queue_finish (queue);
1417 return 0;
1418 }
1419
1420 queue->handshake_ack_monotime_get = GNUNET_PEERSTORE_iterate (peerstore,
1421 "transport_tcp_communicator",
1422 &queue->target,
1423 GNUNET_PEERSTORE_TRANSPORT_TCP_COMMUNICATOR_HANDSHAKE_ACK,
1424 &
1425 handshake_ack_monotime_cb,
1426 queue);
1427
1428 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1429 "Handling plaintext, ack processed!");
1430
1431 unverified_size = -1;
1432
1433 size = ntohs (hdr->size);
1434 break;
1029 case GNUNET_MESSAGE_TYPE_COMMUNICATOR_TCP_BOX: 1435 case GNUNET_MESSAGE_TYPE_COMMUNICATOR_TCP_BOX:
1030 /* Special case: header size excludes box itself! */ 1436 /* Special case: header size excludes box itself! */
1031 if (ntohs (hdr->size) + sizeof(struct TCPBox) > queue->pread_off) 1437 if (ntohs (hdr->size) + sizeof(struct TCPBox) > queue->pread_off)
@@ -1039,6 +1445,8 @@ try_handle_plaintext (struct Queue *queue)
1039 } 1445 }
1040 pass_plaintext_to_core (queue, (const void *) &box[1], ntohs (hdr->size)); 1446 pass_plaintext_to_core (queue, (const void *) &box[1], ntohs (hdr->size));
1041 size = ntohs (hdr->size) + sizeof(*box); 1447 size = ntohs (hdr->size) + sizeof(*box);
1448 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1449 "Handling plaintext, box processed!\n");
1042 break; 1450 break;
1043 1451
1044 case GNUNET_MESSAGE_TYPE_COMMUNICATOR_TCP_REKEY: 1452 case GNUNET_MESSAGE_TYPE_COMMUNICATOR_TCP_REKEY:
@@ -1061,6 +1469,8 @@ try_handle_plaintext (struct Queue *queue)
1061 } 1469 }
1062 do_rekey (queue, rekey); 1470 do_rekey (queue, rekey);
1063 size = ntohs (hdr->size); 1471 size = ntohs (hdr->size);
1472 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1473 "Handling plaintext, rekey processed!\n");
1064 break; 1474 break;
1065 1475
1066 case GNUNET_MESSAGE_TYPE_COMMUNICATOR_TCP_FINISH: 1476 case GNUNET_MESSAGE_TYPE_COMMUNICATOR_TCP_FINISH:
@@ -1083,14 +1493,20 @@ try_handle_plaintext (struct Queue *queue)
1083 } 1493 }
1084 /* handle FINISH by destroying queue */ 1494 /* handle FINISH by destroying queue */
1085 queue_destroy (queue); 1495 queue_destroy (queue);
1496 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1497 "Handling plaintext, finish processed!\n");
1086 break; 1498 break;
1087 1499
1088 default: 1500 default:
1501 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1502 "Handling plaintext, nothing processed!\n");
1089 GNUNET_break_op (0); 1503 GNUNET_break_op (0);
1090 queue_finish (queue); 1504 queue_finish (queue);
1091 return 0; 1505 return 0;
1092 } 1506 }
1093 GNUNET_assert (0 != size); 1507 GNUNET_assert (0 != size);
1508 if (-1 != unverified_size)
1509 unverified_size += size;
1094 return size; 1510 return size;
1095} 1511}
1096 1512
@@ -1202,7 +1618,6 @@ queue_read (void *cls)
1202 queue_finish (queue); 1618 queue_finish (queue);
1203} 1619}
1204 1620
1205
1206/** 1621/**
1207 * Convert a `struct sockaddr_in6 to a `struct sockaddr *` 1622 * Convert a `struct sockaddr_in6 to a `struct sockaddr *`
1208 * 1623 *
@@ -1216,10 +1631,6 @@ tcp_address_to_sockaddr_numeric_v6 (socklen_t *sock_len, struct sockaddr_in6 v6,
1216{ 1631{
1217 struct sockaddr *in; 1632 struct sockaddr *in;
1218 1633
1219 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
1220 "1 address %s\n",
1221 GNUNET_a2s (in, *sock_len));
1222
1223 v6.sin6_family = AF_INET6; 1634 v6.sin6_family = AF_INET6;
1224 v6.sin6_port = htons ((uint16_t) port); 1635 v6.sin6_port = htons ((uint16_t) port);
1225#if HAVE_SOCKADDR_IN_SIN_LEN 1636#if HAVE_SOCKADDR_IN_SIN_LEN
@@ -1227,14 +1638,10 @@ tcp_address_to_sockaddr_numeric_v6 (socklen_t *sock_len, struct sockaddr_in6 v6,
1227#endif 1638#endif
1228 in = GNUNET_memdup (&v6, sizeof(v6)); 1639 in = GNUNET_memdup (&v6, sizeof(v6));
1229 *sock_len = sizeof(struct sockaddr_in6); 1640 *sock_len = sizeof(struct sockaddr_in6);
1230 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
1231 "address %s\n",
1232 GNUNET_a2s (in, *sock_len));
1233 1641
1234 return in; 1642 return in;
1235} 1643}
1236 1644
1237
1238/** 1645/**
1239 * Convert a `struct sockaddr_in4 to a `struct sockaddr *` 1646 * Convert a `struct sockaddr_in4 to a `struct sockaddr *`
1240 * 1647 *
@@ -1258,7 +1665,6 @@ tcp_address_to_sockaddr_numeric_v4 (socklen_t *sock_len, struct sockaddr_in v4,
1258 return in; 1665 return in;
1259} 1666}
1260 1667
1261
1262/** 1668/**
1263 * Convert TCP bind specification to a `struct PortOnlyIpv4Ipv6 *` 1669 * Convert TCP bind specification to a `struct PortOnlyIpv4Ipv6 *`
1264 * 1670 *
@@ -1294,7 +1700,7 @@ tcp_address_to_sockaddr_port_only (const char *bindto, unsigned int *port)
1294 i4 = GNUNET_malloc (sizeof(struct sockaddr_in)); 1700 i4 = GNUNET_malloc (sizeof(struct sockaddr_in));
1295 po->addr_ipv4 = tcp_address_to_sockaddr_numeric_v4 (&sock_len_ipv4, *i4, 1701 po->addr_ipv4 = tcp_address_to_sockaddr_numeric_v4 (&sock_len_ipv4, *i4,
1296 *port); 1702 *port);
1297 po->addr_len_ipv4 = &sock_len_ipv4; 1703 po->addr_len_ipv4 = sock_len_ipv4;
1298 } 1704 }
1299 else 1705 else
1300 { 1706 {
@@ -1302,25 +1708,22 @@ tcp_address_to_sockaddr_port_only (const char *bindto, unsigned int *port)
1302 i4 = GNUNET_malloc (sizeof(struct sockaddr_in)); 1708 i4 = GNUNET_malloc (sizeof(struct sockaddr_in));
1303 po->addr_ipv4 = tcp_address_to_sockaddr_numeric_v4 (&sock_len_ipv4, *i4, 1709 po->addr_ipv4 = tcp_address_to_sockaddr_numeric_v4 (&sock_len_ipv4, *i4,
1304 *port); 1710 *port);
1305 po->addr_len_ipv4 = &sock_len_ipv4; 1711 po->addr_len_ipv4 = sock_len_ipv4;
1306
1307 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
1308 "3.5 address %s\n",
1309 GNUNET_a2s (po->addr_ipv4, sock_len_ipv4));
1310 1712
1311 i6 = GNUNET_malloc (sizeof(struct sockaddr_in6)); 1713 i6 = GNUNET_malloc (sizeof(struct sockaddr_in6));
1312 po->addr_ipv6 = tcp_address_to_sockaddr_numeric_v6 (&sock_len_ipv6, *i6, 1714 po->addr_ipv6 = tcp_address_to_sockaddr_numeric_v6 (&sock_len_ipv6, *i6,
1313 *port); 1715 *port);
1314 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
1315 "3 address %s\n",
1316 GNUNET_a2s (po->addr_ipv6, sock_len_ipv6));
1317 1716
1318 po->addr_len_ipv6 = &sock_len_ipv6; 1717 po->addr_len_ipv6 = sock_len_ipv6;
1718
1719 GNUNET_free (i6);
1319 } 1720 }
1721
1722 GNUNET_free (i4);
1723
1320 return po; 1724 return po;
1321} 1725}
1322 1726
1323
1324/** 1727/**
1325 * This Method extracts the address part of the BINDTO string. 1728 * This Method extracts the address part of the BINDTO string.
1326 * 1729 *
@@ -1347,8 +1750,7 @@ extract_address (const char *bindto)
1347 start++; /* skip over '['*/ 1750 start++; /* skip over '['*/
1348 cp[strlen (cp) - 1] = '\0'; /* eat ']'*/ 1751 cp[strlen (cp) - 1] = '\0'; /* eat ']'*/
1349 } 1752 }
1350 else 1753 else {
1351 {
1352 token = strtok_r (cp, "]", &rest); 1754 token = strtok_r (cp, "]", &rest);
1353 if (strlen (bindto) == strlen (token)) 1755 if (strlen (bindto) == strlen (token))
1354 { 1756 {
@@ -1361,12 +1763,11 @@ extract_address (const char *bindto)
1361 } 1763 }
1362 } 1764 }
1363 1765
1364 // GNUNET_free(cp); 1766 GNUNET_free (cp);
1365 1767
1366 return start; 1768 return start;
1367} 1769}
1368 1770
1369
1370/** 1771/**
1371 * This Method extracts the port part of the BINDTO string. 1772 * This Method extracts the port part of the BINDTO string.
1372 * 1773 *
@@ -1445,7 +1846,6 @@ extract_port (const char *addr_and_port)
1445 return port; 1846 return port;
1446} 1847}
1447 1848
1448
1449/** 1849/**
1450 * Convert TCP bind specification to a `struct sockaddr *` 1850 * Convert TCP bind specification to a `struct sockaddr *`
1451 * 1851 *
@@ -1827,12 +2227,16 @@ transmit_kx (struct Queue *queue,
1827 tc.sender = my_identity; 2227 tc.sender = my_identity;
1828 tc.monotonic_time = 2228 tc.monotonic_time =
1829 GNUNET_TIME_absolute_hton (GNUNET_TIME_absolute_get_monotonic (cfg)); 2229 GNUNET_TIME_absolute_hton (GNUNET_TIME_absolute_get_monotonic (cfg));
2230 GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_NONCE,
2231 &tc.challenge,
2232 sizeof(tc.challenge));
1830 ths.purpose.purpose = htonl (GNUNET_SIGNATURE_COMMUNICATOR_TCP_HANDSHAKE); 2233 ths.purpose.purpose = htonl (GNUNET_SIGNATURE_COMMUNICATOR_TCP_HANDSHAKE);
1831 ths.purpose.size = htonl (sizeof(ths)); 2234 ths.purpose.size = htonl (sizeof(ths));
1832 ths.sender = my_identity; 2235 ths.sender = my_identity;
1833 ths.receiver = queue->target; 2236 ths.receiver = queue->target;
1834 ths.ephemeral = *epub; 2237 ths.ephemeral = *epub;
1835 ths.monotonic_time = tc.monotonic_time; 2238 ths.monotonic_time = tc.monotonic_time;
2239 ths.challenge = tc.challenge;
1836 GNUNET_CRYPTO_eddsa_sign (my_private_key, 2240 GNUNET_CRYPTO_eddsa_sign (my_private_key,
1837 &ths, 2241 &ths,
1838 &tc.sender_sig); 2242 &tc.sender_sig);
@@ -1842,7 +2246,12 @@ transmit_kx (struct Queue *queue,
1842 sizeof(tc), 2246 sizeof(tc),
1843 &tc, 2247 &tc,
1844 sizeof(tc))); 2248 sizeof(tc)));
2249 queue->challenge = tc.challenge;
1845 queue->cwrite_off += sizeof(tc); 2250 queue->cwrite_off += sizeof(tc);
2251
2252 GNUNET_log_from_nocheck (GNUNET_ERROR_TYPE_DEBUG,
2253 "transport",
2254 "handshake written\n");
1846} 2255}
1847 2256
1848 2257
@@ -1864,6 +2273,80 @@ start_initial_kx_out (struct Queue *queue)
1864 transmit_kx (queue, &epub); 2273 transmit_kx (queue, &epub);
1865} 2274}
1866 2275
2276/**
2277 * Callback called when peerstore store operation for handshake monotime is finished.
2278 * @param cls Queue context the store operation was executed.
2279 * @param success Store operation was successful (GNUNET_OK) or not.
2280 */
2281static void
2282handshake_monotime_store_cb (void *cls, int success)
2283{
2284 struct Queue *queue = cls;
2285 if (GNUNET_OK != success)
2286 {
2287 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
2288 "Failed to store handshake monotonic time in PEERSTORE!\n");
2289 }
2290 queue->handshake_monotime_sc = NULL;
2291}
2292
2293/**
2294 * Callback called by peerstore when records for GNUNET_PEERSTORE_TRANSPORT_TCP_COMMUNICATOR_HANDSHAKE
2295 * where found.
2296 * @param cls Queue context the store operation was executed.
2297 * @param record The record found or NULL if there is no record left.
2298 * @param emsg Message from peerstore.
2299 */
2300static void
2301handshake_monotime_cb (void *cls,
2302 const struct GNUNET_PEERSTORE_Record *record,
2303 const char *emsg)
2304{
2305 struct Queue *queue = cls;
2306 struct GNUNET_TIME_AbsoluteNBO *mtbe;
2307 struct GNUNET_TIME_Absolute mt;
2308 const struct GNUNET_PeerIdentity *pid;
2309 struct GNUNET_TIME_AbsoluteNBO *handshake_monotonic_time;
2310
2311 (void) emsg;
2312
2313 handshake_monotonic_time = &queue->handshake_monotonic_time;
2314 pid = &queue->target;
2315 if (NULL == record)
2316 {
2317 queue->handshake_monotime_get = NULL;
2318 return;
2319 }
2320 if (sizeof(*mtbe) != record->value_size)
2321 {
2322 GNUNET_break (0);
2323 return;
2324 }
2325 mtbe = record->value;
2326 mt = GNUNET_TIME_absolute_ntoh (*mtbe);
2327 if (mt.abs_value_us > GNUNET_TIME_absolute_ntoh (
2328 queue->handshake_monotonic_time).abs_value_us)
2329 {
2330 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
2331 "Queue from %s dropped, handshake monotime in the past\n",
2332 GNUNET_i2s (&queue->target));
2333 GNUNET_break (0);
2334 queue_finish (queue);
2335 return;
2336 }
2337 queue->handshake_monotime_sc = GNUNET_PEERSTORE_store (peerstore,
2338 "transport_tcp_communicator",
2339 pid,
2340 GNUNET_PEERSTORE_TRANSPORT_TCP_COMMUNICATOR_HANDSHAKE,
2341 handshake_monotonic_time,
2342 sizeof(
2343 handshake_monotonic_time),
2344 GNUNET_TIME_UNIT_FOREVER_ABS,
2345 GNUNET_PEERSTORE_STOREOPTION_REPLACE,
2346 &
2347 handshake_monotime_store_cb,
2348 queue);
2349}
1867 2350
1868/** 2351/**
1869 * We have received the first bytes from the other side on a @a queue. 2352 * We have received the first bytes from the other side on a @a queue.
@@ -1896,13 +2379,19 @@ decrypt_and_check_tc (struct Queue *queue,
1896 ths.receiver = my_identity; 2379 ths.receiver = my_identity;
1897 memcpy (&ths.ephemeral, ibuf, sizeof(struct GNUNET_CRYPTO_EcdhePublicKey)); 2380 memcpy (&ths.ephemeral, ibuf, sizeof(struct GNUNET_CRYPTO_EcdhePublicKey));
1898 ths.monotonic_time = tc->monotonic_time; 2381 ths.monotonic_time = tc->monotonic_time;
1899 /* FIXME: check monotonic time against previous mono times 2382 ths.challenge = tc->challenge;
1900 from this sender! */
1901 return GNUNET_CRYPTO_eddsa_verify ( 2383 return GNUNET_CRYPTO_eddsa_verify (
1902 GNUNET_SIGNATURE_COMMUNICATOR_TCP_HANDSHAKE, 2384 GNUNET_SIGNATURE_COMMUNICATOR_TCP_HANDSHAKE,
1903 &ths, 2385 &ths,
1904 &tc->sender_sig, 2386 &tc->sender_sig,
1905 &tc->sender.public_key); 2387 &tc->sender.public_key);
2388 queue->handshake_monotime_get = GNUNET_PEERSTORE_iterate (peerstore,
2389 "transport_tcp_communicator",
2390 &queue->target,
2391 GNUNET_PEERSTORE_TRANSPORT_TCP_COMMUNICATOR_HANDSHAKE,
2392 &
2393 handshake_monotime_cb,
2394 queue);
1906} 2395}
1907 2396
1908 2397
@@ -1930,6 +2419,47 @@ free_proto_queue (struct ProtoQueue *pq)
1930 GNUNET_free (pq); 2419 GNUNET_free (pq);
1931} 2420}
1932 2421
2422/**
2423 * Sending challenge with TcpConfirmationAck back to sender of ephemeral key.
2424 *
2425 * @param tc The TCPConfirmation originally send.
2426 * @param queue The queue context.
2427 */
2428static void
2429send_challenge (struct TCPConfirmation tc, struct Queue *queue)
2430{
2431 struct TCPConfirmationAck tca;
2432 struct TcpHandshakeAckSignature thas;
2433
2434 GNUNET_log_from_nocheck (GNUNET_ERROR_TYPE_DEBUG,
2435 "transport",
2436 "sending challenge\n");
2437
2438 tca.header.type = ntohs (
2439 GNUNET_MESSAGE_TYPE_COMMUNICATOR_TCP_CONFIRMATION_ACK);
2440 tca.header.size = ntohs (sizeof(tca));
2441 tca.challenge = tc.challenge;
2442 tca.sender = my_identity;
2443 tca.monotonic_time =
2444 GNUNET_TIME_absolute_hton (GNUNET_TIME_absolute_get_monotonic (cfg));
2445 thas.purpose.purpose = htonl (
2446 GNUNET_SIGNATURE_COMMUNICATOR_TCP_HANDSHAKE_ACK);
2447 thas.purpose.size = htonl (sizeof(thas));
2448 thas.sender = my_identity;
2449 thas.receiver = queue->target;
2450 thas.monotonic_time = tca.monotonic_time;
2451 thas.challenge = tca.challenge;
2452 GNUNET_CRYPTO_eddsa_sign (my_private_key,
2453 &thas,
2454 &tca.sender_sig);
2455 GNUNET_assert (0 ==
2456 gcry_cipher_encrypt (queue->out_cipher,
2457 &queue->cwrite_buf[queue->cwrite_off],
2458 sizeof(tca),
2459 &tca,
2460 sizeof(tca)));
2461 queue->cwrite_off += sizeof(tca);
2462}
1933 2463
1934/** 2464/**
1935 * Read from the socket of the proto queue until we have enough data 2465 * Read from the socket of the proto queue until we have enough data
@@ -1999,6 +2529,11 @@ proto_read_kx (void *cls)
1999 queue->listen_task = pq->listen_task; 2529 queue->listen_task = pq->listen_task;
2000 queue->listen_sock = pq->listen_sock; 2530 queue->listen_sock = pq->listen_sock;
2001 queue->sock = pq->sock; 2531 queue->sock = pq->sock;
2532
2533
2534 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
2535 "start kx proto\n");
2536
2002 start_initial_kx_out (queue); 2537 start_initial_kx_out (queue);
2003 boot_queue (queue, GNUNET_TRANSPORT_CS_INBOUND); 2538 boot_queue (queue, GNUNET_TRANSPORT_CS_INBOUND);
2004 queue->read_task = 2539 queue->read_task =
@@ -2011,6 +2546,8 @@ proto_read_kx (void *cls)
2011 queue->sock, 2546 queue->sock,
2012 &queue_write, 2547 &queue_write,
2013 queue); 2548 queue);
2549 send_challenge (tc, queue);
2550
2014 GNUNET_CONTAINER_DLL_remove (proto_head, proto_tail, pq); 2551 GNUNET_CONTAINER_DLL_remove (proto_head, proto_tail, pq);
2015 GNUNET_free (pq); 2552 GNUNET_free (pq);
2016} 2553}
@@ -2134,7 +2671,7 @@ queue_read_kx (void *cls)
2134 queue_destroy (queue); 2671 queue_destroy (queue);
2135 return; 2672 return;
2136 } 2673 }
2137 2674 send_challenge (tc, queue);
2138 /* update queue timeout */ 2675 /* update queue timeout */
2139 reschedule_queue_timeout (queue); 2676 reschedule_queue_timeout (queue);
2140 /* prepare to continue with regular read task immediately */ 2677 /* prepare to continue with regular read task immediately */
@@ -2146,7 +2683,6 @@ queue_read_kx (void *cls)
2146 queue->read_task = GNUNET_SCHEDULER_add_now (&queue_read, queue); 2683 queue->read_task = GNUNET_SCHEDULER_add_now (&queue_read, queue);
2147} 2684}
2148 2685
2149
2150/** 2686/**
2151 * Function called by the transport service to initialize a 2687 * Function called by the transport service to initialize a
2152 * message queue given address information about another peer. 2688 * message queue given address information about another peer.
@@ -2227,6 +2763,11 @@ mq_init (void *cls, const struct GNUNET_PeerIdentity *peer, const char *address)
2227 queue->sock, 2763 queue->sock,
2228 &queue_read_kx, 2764 &queue_read_kx,
2229 queue); 2765 queue);
2766
2767
2768 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
2769 "start kx mq_init\n");
2770
2230 start_initial_kx_out (queue); 2771 start_initial_kx_out (queue);
2231 queue->write_task = 2772 queue->write_task =
2232 GNUNET_SCHEDULER_add_write_net (GNUNET_TIME_UNIT_FOREVER_REL, 2773 GNUNET_SCHEDULER_add_write_net (GNUNET_TIME_UNIT_FOREVER_REL,
@@ -2236,7 +2777,6 @@ mq_init (void *cls, const struct GNUNET_PeerIdentity *peer, const char *address)
2236 return GNUNET_OK; 2777 return GNUNET_OK;
2237} 2778}
2238 2779
2239
2240/** 2780/**
2241 * Iterator over all message queues to clean up. 2781 * Iterator over all message queues to clean up.
2242 * 2782 *
@@ -2346,10 +2886,6 @@ nat_address_cb (void *cls,
2346 char *my_addr; 2886 char *my_addr;
2347 struct GNUNET_TRANSPORT_AddressIdentifier *ai; 2887 struct GNUNET_TRANSPORT_AddressIdentifier *ai;
2348 2888
2349 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
2350 "1 nat_address %s\n",
2351 GNUNET_a2s (addr, addrlen));
2352
2353 if (GNUNET_YES == add_remove) 2889 if (GNUNET_YES == add_remove)
2354 { 2890 {
2355 enum GNUNET_NetworkType nt; 2891 enum GNUNET_NetworkType nt;
@@ -2375,7 +2911,6 @@ nat_address_cb (void *cls,
2375 } 2911 }
2376} 2912}
2377 2913
2378
2379/** 2914/**
2380 * This method launch network interactions for each address we like to bind to. 2915 * This method launch network interactions for each address we like to bind to.
2381 * 2916 *
@@ -2399,10 +2934,6 @@ init_socket (const struct sockaddr *addr,
2399 return GNUNET_SYSERR; 2934 return GNUNET_SYSERR;
2400 } 2935 }
2401 2936
2402 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
2403 "4 address %s\n",
2404 GNUNET_a2s (addr, in_len));
2405
2406 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 2937 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
2407 "address %s\n", 2938 "address %s\n",
2408 GNUNET_a2s (addr, in_len)); 2939 GNUNET_a2s (addr, in_len));
@@ -2465,7 +2996,8 @@ init_socket (const struct sockaddr *addr,
2465 GNUNET_ERROR_TYPE_ERROR, 2996 GNUNET_ERROR_TYPE_ERROR,
2466 _ ( 2997 _ (
2467 "Transport service is lacking key configuration settings. Exiting.\n")); 2998 "Transport service is lacking key configuration settings. Exiting.\n"));
2468 GNUNET_RESOLVER_request_cancel (resolve_request_handle); 2999 if (NULL != resolve_request_handle)
3000 GNUNET_RESOLVER_request_cancel (resolve_request_handle);
2469 GNUNET_SCHEDULER_shutdown (); 3001 GNUNET_SCHEDULER_shutdown ();
2470 return GNUNET_SYSERR; 3002 return GNUNET_SYSERR;
2471 } 3003 }
@@ -2483,7 +3015,7 @@ init_socket (const struct sockaddr *addr,
2483 if (NULL == queue_map) 3015 if (NULL == queue_map)
2484 queue_map = GNUNET_CONTAINER_multipeermap_create (10, GNUNET_NO); 3016 queue_map = GNUNET_CONTAINER_multipeermap_create (10, GNUNET_NO);
2485 3017
2486 if (NULL == ch) 3018 if (NULL == ch )
2487 ch = GNUNET_TRANSPORT_communicator_connect (cfg, 3019 ch = GNUNET_TRANSPORT_communicator_connect (cfg,
2488 COMMUNICATOR_CONFIG_SECTION, 3020 COMMUNICATOR_CONFIG_SECTION,
2489 COMMUNICATOR_ADDRESS_PREFIX, 3021 COMMUNICATOR_ADDRESS_PREFIX,
@@ -2496,7 +3028,8 @@ init_socket (const struct sockaddr *addr,
2496 if (NULL == ch) 3028 if (NULL == ch)
2497 { 3029 {
2498 GNUNET_break (0); 3030 GNUNET_break (0);
2499 GNUNET_RESOLVER_request_cancel (resolve_request_handle); 3031 if (NULL != resolve_request_handle)
3032 GNUNET_RESOLVER_request_cancel (resolve_request_handle);
2500 GNUNET_SCHEDULER_shutdown (); 3033 GNUNET_SCHEDULER_shutdown ();
2501 return GNUNET_SYSERR; 3034 return GNUNET_SYSERR;
2502 } 3035 }
@@ -2505,7 +3038,6 @@ init_socket (const struct sockaddr *addr,
2505 3038
2506} 3039}
2507 3040
2508
2509/** 3041/**
2510 * This method reads from the DLL addrs_head to register them at the NAT service. 3042 * This method reads from the DLL addrs_head to register them at the NAT service.
2511 */ 3043 */
@@ -2518,35 +3050,20 @@ nat_register ()
2518 int i; 3050 int i;
2519 struct Addresses *pos; 3051 struct Addresses *pos;
2520 3052
2521 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
2522 "nat here\n");
2523
2524 i = 0; 3053 i = 0;
2525 saddrs = GNUNET_malloc ((addrs_lens + 1) * sizeof(struct sockaddr *)); 3054 saddrs = GNUNET_malloc ((addrs_lens + 1) * sizeof(struct sockaddr *));
2526 3055
2527 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
2528 "2 nat here\n");
2529
2530 saddr_lens = GNUNET_malloc ((addrs_lens + 1) * sizeof(socklen_t)); 3056 saddr_lens = GNUNET_malloc ((addrs_lens + 1) * sizeof(socklen_t));
2531 3057
2532 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
2533 "3 nat here\n");
2534
2535 for (pos = addrs_head; NULL != pos; pos = pos->next) 3058 for (pos = addrs_head; NULL != pos; pos = pos->next)
2536 { 3059 {
2537 3060
2538 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
2539 "5 nat here\n");
2540
2541 saddr_lens[i] = addrs_head->addr_len; 3061 saddr_lens[i] = addrs_head->addr_len;
2542 saddrs[i] = GNUNET_malloc (saddr_lens[i]); 3062 saddrs[i] = GNUNET_malloc (saddr_lens[i]);
2543 saddrs[i] = addrs_head->addr; 3063 saddrs[i] = addrs_head->addr;
2544 3064
2545 i++; 3065 i++;
2546 3066
2547 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
2548 "6 nat here\n");
2549
2550 } 3067 }
2551 3068
2552 nat = GNUNET_NAT_register (cfg, 3069 nat = GNUNET_NAT_register (cfg,
@@ -2559,15 +3076,22 @@ nat_register ()
2559 NULL /* FIXME: support reversal: #5529 */, 3076 NULL /* FIXME: support reversal: #5529 */,
2560 NULL /* closure */); 3077 NULL /* closure */);
2561 3078
3079 i = 0;
3080
3081 /*for (i = addrs_lens - 1; i >= 0; i--)
3082 GNUNET_free (saddrs[i]);*/
3083 GNUNET_free (saddrs);
3084 GNUNET_free (saddr_lens);
3085
2562 if (NULL == nat) 3086 if (NULL == nat)
2563 { 3087 {
2564 GNUNET_break (0); 3088 GNUNET_break (0);
2565 GNUNET_RESOLVER_request_cancel (resolve_request_handle); 3089 if (NULL != resolve_request_handle)
3090 GNUNET_RESOLVER_request_cancel (resolve_request_handle);
2566 GNUNET_SCHEDULER_shutdown (); 3091 GNUNET_SCHEDULER_shutdown ();
2567 } 3092 }
2568} 3093}
2569 3094
2570
2571/** 3095/**
2572 * This method adds addresses to the DLL, that are later register at the NAT service. 3096 * This method adds addresses to the DLL, that are later register at the NAT service.
2573 */ 3097 */
@@ -2584,7 +3108,6 @@ add_addr (struct sockaddr *in, socklen_t in_len)
2584 addrs_lens++; 3108 addrs_lens++;
2585} 3109}
2586 3110
2587
2588/** 3111/**
2589 * This method is the callback called by the resolver API, and wraps method init_socket. 3112 * This method is the callback called by the resolver API, and wraps method init_socket.
2590 * 3113 *
@@ -2637,7 +3160,6 @@ init_socket_resolv (void *cls,
2637 } 3160 }
2638} 3161}
2639 3162
2640
2641/** 3163/**
2642 * Setup communicator and launch network interactions. 3164 * Setup communicator and launch network interactions.
2643 * 3165 *
@@ -2662,6 +3184,8 @@ run (void *cls,
2662 char dummy[2]; 3184 char dummy[2];
2663 char *rest = NULL; 3185 char *rest = NULL;
2664 struct PortOnlyIpv4Ipv6 *po; 3186 struct PortOnlyIpv4Ipv6 *po;
3187 socklen_t addr_len_ipv4;
3188 socklen_t addr_len_ipv6;
2665 3189
2666 (void) cls; 3190 (void) cls;
2667 cfg = c; 3191 cfg = c;
@@ -2689,6 +3213,13 @@ run (void *cls,
2689 &rekey_interval)) 3213 &rekey_interval))
2690 rekey_interval = DEFAULT_REKEY_INTERVAL; 3214 rekey_interval = DEFAULT_REKEY_INTERVAL;
2691 3215
3216 peerstore = GNUNET_PEERSTORE_connect (cfg);
3217 if (NULL == peerstore)
3218 {
3219 GNUNET_break (0);
3220 GNUNET_SCHEDULER_shutdown ();
3221 return;
3222 }
2692 3223
2693 // cp = GNUNET_strdup (bindto); 3224 // cp = GNUNET_strdup (bindto);
2694 start = extract_address (bindto); 3225 start = extract_address (bindto);
@@ -2697,16 +3228,24 @@ run (void *cls,
2697 { 3228 {
2698 po = tcp_address_to_sockaddr_port_only (bindto, &port); 3229 po = tcp_address_to_sockaddr_port_only (bindto, &port);
2699 3230
2700 if (NULL != &po->addr_ipv4) 3231 addr_len_ipv4 = po->addr_len_ipv4;
3232
3233
3234 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
3235 "address po %s\n",
3236 GNUNET_a2s (po->addr_ipv4, addr_len_ipv4));
3237
3238 if (NULL != po->addr_ipv4)
2701 { 3239 {
2702 init_socket (po->addr_ipv4, *po->addr_len_ipv4); 3240 init_socket (po->addr_ipv4, addr_len_ipv4);
2703 add_addr (po->addr_ipv4, *po->addr_len_ipv4); 3241 add_addr (po->addr_ipv4, addr_len_ipv4);
2704 } 3242 }
2705 3243
2706 if (NULL != &po->addr_ipv6) 3244 if (NULL != po->addr_ipv6)
2707 { 3245 {
2708 init_socket (po->addr_ipv6, *po->addr_len_ipv6); 3246 addr_len_ipv6 = po->addr_len_ipv6;
2709 add_addr (po->addr_ipv6, *po->addr_len_ipv6); 3247 init_socket (po->addr_ipv6, addr_len_ipv6);
3248 add_addr (po->addr_ipv6, addr_len_ipv6);
2710 } 3249 }
2711 3250
2712 nat_register (); 3251 nat_register ();
diff --git a/src/transport/gnunet-service-tng.c b/src/transport/gnunet-service-tng.c
index 5f3178939..baefdfa88 100644
--- a/src/transport/gnunet-service-tng.c
+++ b/src/transport/gnunet-service-tng.c
@@ -329,19 +329,6 @@ struct AcknowledgementUUIDP
329 struct GNUNET_Uuid value; 329 struct GNUNET_Uuid value;
330}; 330};
331 331
332
333/**
334 * Type of a nonce used for challenges.
335 */
336struct ChallengeNonceP
337{
338 /**
339 * The value of the nonce. Note that this is NOT a hash.
340 */
341 struct GNUNET_ShortHashCode value;
342};
343
344
345/** 332/**
346 * Outer layer of an encapsulated backchannel message. 333 * Outer layer of an encapsulated backchannel message.
347 */ 334 */
diff --git a/src/transport/test_communicator_basic.c b/src/transport/test_communicator_basic.c
index 45c268684..e2d2eb73c 100644
--- a/src/transport/test_communicator_basic.c
+++ b/src/transport/test_communicator_basic.c
@@ -587,6 +587,7 @@ main (int argc,
587 GNUNET_asprintf (&communicator_binary, 587 GNUNET_asprintf (&communicator_binary,
588 "gnunet-communicator-%s", 588 "gnunet-communicator-%s",
589 communicator_name); 589 communicator_name);
590
590 if (GNUNET_OK != 591 if (GNUNET_OK !=
591 GNUNET_log_setup ("test_communicator_basic", 592 GNUNET_log_setup ("test_communicator_basic",
592 "DEBUG", 593 "DEBUG",
@@ -645,6 +646,21 @@ main (int argc,
645 GNUNET_i2s_full (&peer_id[i])); 646 GNUNET_i2s_full (&peer_id[i]));
646 } 647 }
647 LOG (GNUNET_ERROR_TYPE_MESSAGE, "Starting test...\n"); 648 LOG (GNUNET_ERROR_TYPE_MESSAGE, "Starting test...\n");
649 LOG (GNUNET_ERROR_TYPE_DEBUG,
650 "argv[0]: %s\n",
651 argv[0]);
652 LOG (GNUNET_ERROR_TYPE_DEBUG,
653 "test_name: %s\n",
654 test_name);
655
656 LOG (GNUNET_ERROR_TYPE_DEBUG,
657 "communicator_name: %s\n",
658 communicator_name);
659
660 LOG (GNUNET_ERROR_TYPE_DEBUG,
661 "communicator_binary: %s\n",
662 communicator_binary);
663
648 GNUNET_SCHEDULER_run (&run, 664 GNUNET_SCHEDULER_run (&run,
649 NULL); 665 NULL);
650 return ret; 666 return ret;
diff --git a/src/transport/test_communicator_tcp_basic_peer1.conf b/src/transport/test_communicator_tcp_basic_peer1.conf
index d0293ff51..c08737b7b 100644
--- a/src/transport/test_communicator_tcp_basic_peer1.conf
+++ b/src/transport/test_communicator_tcp_basic_peer1.conf
@@ -19,10 +19,15 @@ UNIXPATH = $GNUNET_RUNTIME_DIR/gnunet-service-transport_test_1.sock
19[nat] 19[nat]
20UNIXPATH = $GNUNET_TMP/test-communicator-unix-1/nat.sock 20UNIXPATH = $GNUNET_TMP/test-communicator-unix-1/nat.sock
21 21
22[peerstore]
23UNIXPATH = $GNUNET_TMP/test-communicator-unix-1/peerstore.sock
24
22[communicator-unix] 25[communicator-unix]
23UNIXPATH = $GNUNET_RUNTIME_DIR/test_gnunet-communicator-unix_1.sock 26UNIXPATH = $GNUNET_RUNTIME_DIR/test_gnunet-communicator-unix_1.sock
24 27
25[communicator-tcp] 28[communicator-tcp]
29#PREFIX = xterm -geometry 100x85 -T peer1 -e gdb --args
30#PREFIX = valgrind --leak-check=full --track-origins=yes
26BINDTO = 60002 31BINDTO = 60002
27DISABLE_V6 = NO 32DISABLE_V6 = NO
28 33
diff --git a/src/transport/test_communicator_tcp_basic_peer2.conf b/src/transport/test_communicator_tcp_basic_peer2.conf
index 5b9050547..45b7e7844 100644
--- a/src/transport/test_communicator_tcp_basic_peer2.conf
+++ b/src/transport/test_communicator_tcp_basic_peer2.conf
@@ -20,10 +20,15 @@ UNIXPATH = $GNUNET_RUNTIME_DIR/gnunet-service-transport_test_2.sock
20[nat] 20[nat]
21UNIXPATH = $GNUNET_TMP/test-communicator-unix-2/nat.sock 21UNIXPATH = $GNUNET_TMP/test-communicator-unix-2/nat.sock
22 22
23[peerstore]
24UNIXPATH = $GNUNET_TMP/test-communicator-unix-2/peerstore.sock
25
23[communicator-unix] 26[communicator-unix]
24UNIXPATH = $GNUNET_RUNTIME_DIR/test_gnunet-communicator-unix_2.sock 27UNIXPATH = $GNUNET_RUNTIME_DIR/test_gnunet-communicator-unix_2.sock
25 28
26[communicator-tcp] 29[communicator-tcp]
30#PREFIX = xterm -geometry 100x85 -T peer2 -e gdb --args
31#PREFIX = valgrind --leak-check=full --track-origins=yes
27BINDTO = 60003 32BINDTO = 60003
28DISABLE_V6 = NO 33DISABLE_V6 = NO
29 34
diff --git a/src/transport/test_communicator_tcp_rekey_peer1.conf b/src/transport/test_communicator_tcp_rekey_peer1.conf
index 18028cd48..901f415ef 100644
--- a/src/transport/test_communicator_tcp_rekey_peer1.conf
+++ b/src/transport/test_communicator_tcp_rekey_peer1.conf
@@ -20,10 +20,19 @@ UNIXPATH = $GNUNET_RUNTIME_DIR/gnunet-service-transport_test_1.sock
20UNIXPATH = $GNUNET_TMP/test-communicator-unix-1/nat.sock 20UNIXPATH = $GNUNET_TMP/test-communicator-unix-1/nat.sock
21ENABLE_IPSCAN = YES 21ENABLE_IPSCAN = YES
22 22
23[peerstore]
24UNIXPATH = $GNUNET_TMP/test-communicator-unix-1/peerstore.sock
25
26[resolver]
27PORT = 62089
28UNIXPATH = $GNUNET_RUNTIME_DIR/gnunet-service-resolver_test_1.sock
29
23[communicator-unix] 30[communicator-unix]
24UNIXPATH = $GNUNET_RUNTIME_DIR/test_gnunet-communicator-unix_1.sock 31UNIXPATH = $GNUNET_RUNTIME_DIR/test_gnunet-communicator-unix_1.sock
25 32
26[communicator-tcp] 33[communicator-tcp]
34#PREFIX = xterm -geometry 100x85 -T peer1 -e gdb --args
35#PREFIX = valgrind --leak-check=full --track-origins=yes
27BINDTO = 60002 36BINDTO = 60002
28DISABLE_V6 = YES 37DISABLE_V6 = YES
29REKEY_INTERVAL = 100ms 38REKEY_INTERVAL = 100ms
diff --git a/src/transport/test_communicator_tcp_rekey_peer2.conf b/src/transport/test_communicator_tcp_rekey_peer2.conf
index 7d7179578..138650a3b 100644
--- a/src/transport/test_communicator_tcp_rekey_peer2.conf
+++ b/src/transport/test_communicator_tcp_rekey_peer2.conf
@@ -20,10 +20,19 @@ UNIXPATH = $GNUNET_RUNTIME_DIR/gnunet-service-transport_test_2.sock
20[nat] 20[nat]
21UNIXPATH = $GNUNET_TMP/test-communicator-unix-2/nat.sock 21UNIXPATH = $GNUNET_TMP/test-communicator-unix-2/nat.sock
22 22
23[peerstore]
24UNIXPATH = $GNUNET_TMP/test-communicator-unix-2/peerstore.sock
25
26[resolver]
27PORT = 62090
28UNIXPATH = $GNUNET_RUNTIME_DIR/gnunet-service-resolver_test_2.sock
29
23[communicator-unix] 30[communicator-unix]
24UNIXPATH = $GNUNET_RUNTIME_DIR/test_gnunet-communicator-unix_2.sock 31UNIXPATH = $GNUNET_RUNTIME_DIR/test_gnunet-communicator-unix_2.sock
25 32
26[communicator-tcp] 33[communicator-tcp]
34#PREFIX = xterm -geometry 100x85 -T peer1 -e gdb --args
35#PREFIX = valgrind --leak-check=full --track-origins=yes
27BINDTO = 60003 36BINDTO = 60003
28DISABLE_V6 = YES 37DISABLE_V6 = YES
29REKEY_INTERVAL = 100ms 38REKEY_INTERVAL = 100ms
diff --git a/src/transport/test_communicator_udp_backchannel_peer1.conf b/src/transport/test_communicator_udp_backchannel_peer1.conf
index 0c595b77b..b99a76d6c 100644
--- a/src/transport/test_communicator_udp_backchannel_peer1.conf
+++ b/src/transport/test_communicator_udp_backchannel_peer1.conf
@@ -20,6 +20,13 @@ UNIXPATH = $GNUNET_RUNTIME_DIR/gnunet-service-transport_test_1.sock
20UNIXPATH = $GNUNET_TMP/test-communicator-unix-1/nat.sock 20UNIXPATH = $GNUNET_TMP/test-communicator-unix-1/nat.sock
21ENABLE_IPSCAN = YES 21ENABLE_IPSCAN = YES
22 22
23[peerstore]
24UNIXPATH = $GNUNET_TMP/test-communicator-unix-1/peerstore.sock
25
26[resolver]
27PORT = 62089
28UNIXPATH = $GNUNET_RUNTIME_DIR/gnunet-service-resolver_test_1.sock
29
23[communicator-unix] 30[communicator-unix]
24UNIXPATH = $GNUNET_RUNTIME_DIR/test_gnunet-communicator-unix_1.sock 31UNIXPATH = $GNUNET_RUNTIME_DIR/test_gnunet-communicator-unix_1.sock
25 32
diff --git a/src/transport/test_communicator_udp_backchannel_peer2.conf b/src/transport/test_communicator_udp_backchannel_peer2.conf
index d29f37ec9..48bd54c8b 100644
--- a/src/transport/test_communicator_udp_backchannel_peer2.conf
+++ b/src/transport/test_communicator_udp_backchannel_peer2.conf
@@ -20,6 +20,13 @@ UNIXPATH = $GNUNET_RUNTIME_DIR/gnunet-service-transport_test_2.sock
20[nat] 20[nat]
21UNIXPATH = $GNUNET_TMP/test-communicator-unix-2/nat.sock 21UNIXPATH = $GNUNET_TMP/test-communicator-unix-2/nat.sock
22 22
23[peerstore]
24UNIXPATH = $GNUNET_TMP/test-communicator-unix-2/peerstore.sock
25
26[resolver]
27PORT = 62090
28UNIXPATH = $GNUNET_RUNTIME_DIR/gnunet-service-resolver_test_2.sock
29
23[communicator-unix] 30[communicator-unix]
24UNIXPATH = $GNUNET_RUNTIME_DIR/test_gnunet-communicator-unix_2.sock 31UNIXPATH = $GNUNET_RUNTIME_DIR/test_gnunet-communicator-unix_2.sock
25 32
diff --git a/src/transport/test_communicator_udp_basic_peer1.conf b/src/transport/test_communicator_udp_basic_peer1.conf
index 4cfb6f72f..d53a55210 100644
--- a/src/transport/test_communicator_udp_basic_peer1.conf
+++ b/src/transport/test_communicator_udp_basic_peer1.conf
@@ -20,6 +20,13 @@ UNIXPATH = $GNUNET_RUNTIME_DIR/gnunet-service-transport_test_1.sock
20UNIXPATH = $GNUNET_TMP/test-communicator-unix-1/nat.sock 20UNIXPATH = $GNUNET_TMP/test-communicator-unix-1/nat.sock
21ENABLE_IPSCAN = YES 21ENABLE_IPSCAN = YES
22 22
23[peerstore]
24UNIXPATH = $GNUNET_TMP/test-communicator-unix-1/peerstore.sock
25
26[resolver]
27PORT = 62089
28UNIXPATH = $GNUNET_RUNTIME_DIR/gnunet-service-resolver_test_1.sock
29
23[communicator-udp] 30[communicator-udp]
24BINDTO = 60002 31BINDTO = 60002
25DISABLE_V6 = YES 32DISABLE_V6 = YES
diff --git a/src/transport/test_communicator_udp_basic_peer2.conf b/src/transport/test_communicator_udp_basic_peer2.conf
index b9bed2756..f05ebc5cb 100644
--- a/src/transport/test_communicator_udp_basic_peer2.conf
+++ b/src/transport/test_communicator_udp_basic_peer2.conf
@@ -20,6 +20,14 @@ UNIXPATH = $GNUNET_RUNTIME_DIR/gnunet-service-transport_test_2.sock
20[nat] 20[nat]
21UNIXPATH = $GNUNET_TMP/test-communicator-unix-2/nat.sock 21UNIXPATH = $GNUNET_TMP/test-communicator-unix-2/nat.sock
22 22
23
24[peerstore]
25UNIXPATH = $GNUNET_TMP/test-communicator-unix-2/peerstore.sock
26
27[resolver]
28PORT = 62090
29UNIXPATH = $GNUNET_RUNTIME_DIR/gnunet-service-resolver_test_2.sock
30
23[communicator-udp] 31[communicator-udp]
24BINDTO = 60003 32BINDTO = 60003
25DISABLE_V6 = YES 33DISABLE_V6 = YES
diff --git a/src/transport/test_communicator_udp_rekey_peer1.conf b/src/transport/test_communicator_udp_rekey_peer1.conf
index 18028cd48..e7161e488 100644
--- a/src/transport/test_communicator_udp_rekey_peer1.conf
+++ b/src/transport/test_communicator_udp_rekey_peer1.conf
@@ -20,6 +20,13 @@ UNIXPATH = $GNUNET_RUNTIME_DIR/gnunet-service-transport_test_1.sock
20UNIXPATH = $GNUNET_TMP/test-communicator-unix-1/nat.sock 20UNIXPATH = $GNUNET_TMP/test-communicator-unix-1/nat.sock
21ENABLE_IPSCAN = YES 21ENABLE_IPSCAN = YES
22 22
23[peerstore]
24UNIXPATH = $GNUNET_TMP/test-communicator-unix-1/peerstore.sock
25
26[resolver]
27PORT = 62089
28UNIXPATH = $GNUNET_RUNTIME_DIR/gnunet-service-resolver_test_1.sock
29
23[communicator-unix] 30[communicator-unix]
24UNIXPATH = $GNUNET_RUNTIME_DIR/test_gnunet-communicator-unix_1.sock 31UNIXPATH = $GNUNET_RUNTIME_DIR/test_gnunet-communicator-unix_1.sock
25 32
diff --git a/src/transport/test_communicator_udp_rekey_peer2.conf b/src/transport/test_communicator_udp_rekey_peer2.conf
index 7d7179578..8f175a405 100644
--- a/src/transport/test_communicator_udp_rekey_peer2.conf
+++ b/src/transport/test_communicator_udp_rekey_peer2.conf
@@ -20,6 +20,13 @@ UNIXPATH = $GNUNET_RUNTIME_DIR/gnunet-service-transport_test_2.sock
20[nat] 20[nat]
21UNIXPATH = $GNUNET_TMP/test-communicator-unix-2/nat.sock 21UNIXPATH = $GNUNET_TMP/test-communicator-unix-2/nat.sock
22 22
23[peerstore]
24UNIXPATH = $GNUNET_TMP/test-communicator-unix-2/peerstore.sock
25
26[resolver]
27PORT = 62090
28UNIXPATH = $GNUNET_RUNTIME_DIR/gnunet-service-resolver_test_2.sock
29
23[communicator-unix] 30[communicator-unix]
24UNIXPATH = $GNUNET_RUNTIME_DIR/test_gnunet-communicator-unix_2.sock 31UNIXPATH = $GNUNET_RUNTIME_DIR/test_gnunet-communicator-unix_2.sock
25 32
diff --git a/src/transport/test_communicator_unix_basic_peer1.conf b/src/transport/test_communicator_unix_basic_peer1.conf
index d50588007..71283e381 100644
--- a/src/transport/test_communicator_unix_basic_peer1.conf
+++ b/src/transport/test_communicator_unix_basic_peer1.conf
@@ -20,6 +20,13 @@ UNIXPATH = $GNUNET_RUNTIME_DIR/gnunet-service-transport_test_1.sock
20UNIXPATH = $GNUNET_TMP/communicator-unix-1/nat.sock 20UNIXPATH = $GNUNET_TMP/communicator-unix-1/nat.sock
21ENABLE_IPSCAN = YES 21ENABLE_IPSCAN = YES
22 22
23[peerstore]
24UNIXPATH = $GNUNET_TMP/test-communicator-unix-1/peerstore.sock
25
26[resolver]
27PORT = 62089
28UNIXPATH = $GNUNET_RUNTIME_DIR/gnunet-service-resolver_test_1.sock
29
23[communicator-unix] 30[communicator-unix]
24UNIXPATH = $GNUNET_RUNTIME_DIR/communicator-unix-1.sock 31UNIXPATH = $GNUNET_RUNTIME_DIR/communicator-unix-1.sock
25 32
diff --git a/src/transport/test_communicator_unix_basic_peer2.conf b/src/transport/test_communicator_unix_basic_peer2.conf
index fe27ef1a6..ac95845b2 100644
--- a/src/transport/test_communicator_unix_basic_peer2.conf
+++ b/src/transport/test_communicator_unix_basic_peer2.conf
@@ -20,6 +20,13 @@ UNIXPATH = $GNUNET_RUNTIME_DIR/gnunet-service-transport_test_2.sock
20[nat] 20[nat]
21UNIXPATH = $GNUNET_TMP/communicator-unix-2/nat.sock 21UNIXPATH = $GNUNET_TMP/communicator-unix-2/nat.sock
22 22
23[peerstore]
24UNIXPATH = $GNUNET_TMP/test-communicator-unix-2/peerstore.sock
25
26[resolver]
27PORT = 62090
28UNIXPATH = $GNUNET_RUNTIME_DIR/gnunet-service-resolver_test_2.sock
29
23[communicator-unix] 30[communicator-unix]
24UNIXPATH = $GNUNET_RUNTIME_DIR/communicator-unix-2.sock 31UNIXPATH = $GNUNET_RUNTIME_DIR/communicator-unix-2.sock
25 32
diff --git a/src/transport/transport-testing2.c b/src/transport/transport-testing2.c
index 772ad9f2d..10b064241 100644
--- a/src/transport/transport-testing2.c
+++ b/src/transport/transport-testing2.c
@@ -114,6 +114,11 @@ struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle
114 struct GNUNET_OS_Process *resolver_proc; 114 struct GNUNET_OS_Process *resolver_proc;
115 115
116 /** 116 /**
117 * peerstore service process
118 */
119 struct GNUNET_OS_Process *ps_proc;
120
121 /**
117 * @brief Task that will be run on shutdown to stop and clean communicator 122 * @brief Task that will be run on shutdown to stop and clean communicator
118 */ 123 */
119 struct GNUNET_SCHEDULER_Task *c_shutdown_task; 124 struct GNUNET_SCHEDULER_Task *c_shutdown_task;
@@ -892,6 +897,12 @@ shutdown_process (struct GNUNET_OS_Process *proc)
892 GNUNET_OS_process_destroy (proc); 897 GNUNET_OS_process_destroy (proc);
893} 898}
894 899
900static void
901shutdown_peerstore (void *cls)
902{
903 struct GNUNET_OS_Process *proc = cls;
904 shutdown_process (proc);
905}
895 906
896static void 907static void
897shutdown_communicator (void *cls) 908shutdown_communicator (void *cls)
@@ -912,19 +923,31 @@ communicator_start (
912 const char *binary_name) 923 const char *binary_name)
913{ 924{
914 char *binary; 925 char *binary;
926 char *loprefix;
927 char *section_name;
915 928
916 LOG (GNUNET_ERROR_TYPE_DEBUG, "communicator_start\n"); 929 LOG (GNUNET_ERROR_TYPE_DEBUG, "communicator_start\n");
930
931 section_name = strchr (binary_name, '-');
932 section_name++;
933
934 if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_string (tc_h->cfg,
935 section_name,
936 "PREFIX",
937 &loprefix))
938 loprefix = GNUNET_strdup ("");
939
940
917 binary = GNUNET_OS_get_libexec_binary_path (binary_name); 941 binary = GNUNET_OS_get_libexec_binary_path (binary_name);
918 tc_h->c_proc = GNUNET_OS_start_process (GNUNET_OS_INHERIT_STD_OUT_AND_ERR 942 tc_h->c_proc = GNUNET_OS_start_process_s (GNUNET_YES,
919 | GNUNET_OS_USE_PIPE_CONTROL, 943 GNUNET_OS_INHERIT_STD_OUT_AND_ERR,
920 NULL, 944 NULL,
921 NULL, 945 loprefix,
922 NULL, 946 binary,
923 binary, 947 binary_name,
924 binary_name, 948 "-c",
925 "-c", 949 tc_h->cfg_filename,
926 tc_h->cfg_filename, 950 NULL);
927 NULL);
928 if (NULL == tc_h->c_proc) 951 if (NULL == tc_h->c_proc)
929 { 952 {
930 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to start communicator!"); 953 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to start communicator!");
@@ -992,6 +1015,37 @@ resolver_start (struct
992 1015
993 1016
994/** 1017/**
1018 * @brief Start Peerstore
1019 *
1020 */
1021static void
1022peerstore_start (
1023 struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *tc_h)
1024{
1025 char *binary;
1026
1027 LOG (GNUNET_ERROR_TYPE_DEBUG, "peerstore_start\n");
1028 binary = GNUNET_OS_get_libexec_binary_path ("gnunet-service-peerstore");
1029 tc_h->ps_proc = GNUNET_OS_start_process (GNUNET_YES,
1030 GNUNET_OS_INHERIT_STD_OUT_AND_ERR,
1031 NULL,
1032 NULL,
1033 NULL,
1034 binary,
1035 "gnunet-service-peerstore",
1036 "-c",
1037 tc_h->cfg_filename,
1038 NULL);
1039 if (NULL == tc_h->ps_proc)
1040 {
1041 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to start Peerstore!");
1042 return;
1043 }
1044 LOG (GNUNET_ERROR_TYPE_INFO, "started Peerstore\n");
1045 GNUNET_free (binary);
1046}
1047
1048/**
995 * @brief Start NAT 1049 * @brief Start NAT
996 * 1050 *
997 */ 1051 */
@@ -1087,6 +1141,8 @@ GNUNET_TRANSPORT_TESTING_transport_communicator_service_start (
1087 nat_start (tc_h); 1141 nat_start (tc_h);
1088 /* Start resolver service */ 1142 /* Start resolver service */
1089 resolver_start (tc_h); 1143 resolver_start (tc_h);
1144 /* Start peerstore service */
1145 peerstore_start (tc_h);
1090 /* Schedule start communicator */ 1146 /* Schedule start communicator */
1091 communicator_start (tc_h, 1147 communicator_start (tc_h,
1092 binary_name); 1148 binary_name);
@@ -1102,6 +1158,7 @@ GNUNET_TRANSPORT_TESTING_transport_communicator_service_stop (
1102 shutdown_service (tc_h->sh); 1158 shutdown_service (tc_h->sh);
1103 shutdown_nat (tc_h->nat_proc); 1159 shutdown_nat (tc_h->nat_proc);
1104 shutdown_resolver (tc_h->resolver_proc); 1160 shutdown_resolver (tc_h->resolver_proc);
1161 shutdown_peerstore (tc_h->ps_proc);
1105 GNUNET_CONFIGURATION_destroy (tc_h->cfg); 1162 GNUNET_CONFIGURATION_destroy (tc_h->cfg);
1106 GNUNET_free (tc_h); 1163 GNUNET_free (tc_h);
1107} 1164}