aboutsummaryrefslogtreecommitdiff
path: root/src/transport
diff options
context:
space:
mode:
authorMartin Schanzenbach <mschanzenbach@posteo.de>2021-02-21 21:02:57 +0100
committerMartin Schanzenbach <mschanzenbach@posteo.de>2021-02-21 21:02:57 +0100
commit03b5746e4ba53a1538eb3367b01560f9d70e45b8 (patch)
treefab1cbaa711d44e43b0e3b56fd3de306ff14c07c /src/transport
parent05040a491361a25bfed43a0b978b092da008129f (diff)
downloadgnunet-03b5746e4ba53a1538eb3367b01560f9d70e45b8.tar.gz
gnunet-03b5746e4ba53a1538eb3367b01560f9d70e45b8.zip
TNG: Add a the api test; WIP
Diffstat (limited to 'src/transport')
-rw-r--r--src/transport/Makefile.am18
-rw-r--r--src/transport/gnunet-service-tng.c3
-rw-r--r--src/transport/test_transport_api2.c126
-rw-r--r--src/transport/transport-testing-filenames2.c202
-rw-r--r--src/transport/transport-testing-loggers2.c80
-rw-r--r--src/transport/transport-testing-main2.c613
-rw-r--r--src/transport/transport-testing-send2.c240
-rw-r--r--src/transport/transport-testing2.c6
8 files changed, 1283 insertions, 5 deletions
diff --git a/src/transport/Makefile.am b/src/transport/Makefile.am
index 0251b001e..67b35365d 100644
--- a/src/transport/Makefile.am
+++ b/src/transport/Makefile.am
@@ -124,9 +124,7 @@ endif
124 124
125noinst_PROGRAMS = \ 125noinst_PROGRAMS = \
126 gnunet-transport-profiler \ 126 gnunet-transport-profiler \
127 gnunet-communicator-tcp \
128 gnunet-communicator-udp \ 127 gnunet-communicator-udp \
129 gnunet-service-tng \
130 $(WLAN_BIN_SENDER) \ 128 $(WLAN_BIN_SENDER) \
131 $(WLAN_BIN_RECEIVER) 129 $(WLAN_BIN_RECEIVER)
132 130
@@ -170,6 +168,10 @@ libgnunettransporttesting_la_LDFLAGS = \
170 168
171libgnunettransporttesting2_la_SOURCES = \ 169libgnunettransporttesting2_la_SOURCES = \
172 transport-testing2.c transport-testing2.h \ 170 transport-testing2.c transport-testing2.h \
171 transport-testing-filenames2.c \
172 transport-testing-loggers2.c \
173 transport-testing-main2.c \
174 transport-testing-send2.c \
173 transport-testing-communicator.c transport-testing-communicator.h 175 transport-testing-communicator.c transport-testing-communicator.h
174libgnunettransporttesting2_la_LIBADD = \ 176libgnunettransporttesting2_la_LIBADD = \
175 libgnunettransport.la \ 177 libgnunettransport.la \
@@ -253,6 +255,7 @@ libexec_PROGRAMS = \
253 $(WLAN_BIN_DUMMY) \ 255 $(WLAN_BIN_DUMMY) \
254 $(BT_BIN) \ 256 $(BT_BIN) \
255 gnunet-service-transport \ 257 gnunet-service-transport \
258 gnunet-service-tng \
256 gnunet-communicator-unix \ 259 gnunet-communicator-unix \
257 gnunet-communicator-udp \ 260 gnunet-communicator-udp \
258 gnunet-communicator-tcp 261 gnunet-communicator-tcp
@@ -554,6 +557,7 @@ check_PROGRAMS = \
554 test_transport_api_blacklisting_tcp \ 557 test_transport_api_blacklisting_tcp \
555 test_transport_api_disconnect_tcp \ 558 test_transport_api_disconnect_tcp \
556 test_transport_api_tcp \ 559 test_transport_api_tcp \
560 test_transport_api2_tcp \
557 test_transport_api_restart_1peer \ 561 test_transport_api_restart_1peer \
558 test_transport_api_restart_2peers \ 562 test_transport_api_restart_2peers \
559 test_transport_api_timeout_tcp \ 563 test_transport_api_timeout_tcp \
@@ -949,6 +953,14 @@ test_transport_api_tcp_LDADD = \
949 $(top_builddir)/src/util/libgnunetutil.la \ 953 $(top_builddir)/src/util/libgnunetutil.la \
950 libgnunettransporttesting.la 954 libgnunettransporttesting.la
951 955
956test_transport_api2_tcp_SOURCES = \
957 test_transport_api.c
958test_transport_api2_tcp_LDADD = \
959 libgnunettransport.la \
960 $(top_builddir)/src/hello/libgnunethello.la \
961 $(top_builddir)/src/util/libgnunetutil.la \
962 libgnunettransporttesting2.la
963
952test_transport_api_restart_1peer_SOURCES = \ 964test_transport_api_restart_1peer_SOURCES = \
953 test_transport_api_restart_reconnect.c 965 test_transport_api_restart_reconnect.c
954test_transport_api_restart_1peer_LDADD = \ 966test_transport_api_restart_1peer_LDADD = \
@@ -1503,6 +1515,8 @@ test_transport_api_tcp_nat_peer1.conf\
1503test_transport_api_tcp_nat_peer2.conf\ 1515test_transport_api_tcp_nat_peer2.conf\
1504test_transport_api_tcp_peer1.conf\ 1516test_transport_api_tcp_peer1.conf\
1505test_transport_api_tcp_peer2.conf\ 1517test_transport_api_tcp_peer2.conf\
1518test_transport_api2_tcp_peer1.conf\
1519test_transport_api2_tcp_peer2.conf\
1506test_transport_api_udp_nat_peer1.conf\ 1520test_transport_api_udp_nat_peer1.conf\
1507test_transport_api_udp_nat_peer2.conf\ 1521test_transport_api_udp_nat_peer2.conf\
1508test_transport_api_udp_peer1.conf\ 1522test_transport_api_udp_peer1.conf\
diff --git a/src/transport/gnunet-service-tng.c b/src/transport/gnunet-service-tng.c
index bd9acd0cf..9c37f15e2 100644
--- a/src/transport/gnunet-service-tng.c
+++ b/src/transport/gnunet-service-tng.c
@@ -9505,7 +9505,8 @@ handle_add_queue_message (void *cls,
9505 const char *addr; 9505 const char *addr;
9506 uint16_t addr_len; 9506 uint16_t addr_len;
9507 9507
9508 if (ntohl (aqm->mtu) <= sizeof(struct TransportFragmentBoxMessage)) 9508 if ((0 != ntohl (aqm->mtu)) &&
9509 (ntohl (aqm->mtu) <= sizeof(struct TransportFragmentBoxMessage)))
9509 { 9510 {
9510 /* MTU so small as to be useless for transmissions, 9511 /* MTU so small as to be useless for transmissions,
9511 required for #fragment_message()! */ 9512 required for #fragment_message()! */
diff --git a/src/transport/test_transport_api2.c b/src/transport/test_transport_api2.c
new file mode 100644
index 000000000..e1606e0be
--- /dev/null
+++ b/src/transport/test_transport_api2.c
@@ -0,0 +1,126 @@
1/*
2 This file is part of GNUnet.
3 Copyright (C) 2009, 2010, 2016 GNUnet e.V.
4
5 GNUnet is free software: you can redistribute it and/or modify it
6 under the terms of the GNU Affero General Public License as published
7 by the Free Software Foundation, either version 3 of the License,
8 or (at your option) any later version.
9
10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Affero General Public License for more details.
14
15 You should have received a copy of the GNU Affero General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17
18 SPDX-License-Identifier: AGPL3.0-or-later
19 */
20/**
21 * @file transport/test_transport_api.c
22 * @brief base test case for transport implementations
23 * @author Christian Grothoff
24 *
25 * This test case serves as a base for tcp, udp, and udp-nat
26 * transport test cases. Based on the executable being run
27 * the correct test case will be performed. Conservation of
28 * C code apparently.
29 */
30#include "platform.h"
31//#include "gnunet_transport_service.h"
32#include "transport-testing2.h"
33
34/**
35 * How long until we give up on transmitting the message?
36 */
37#define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 30)
38
39static struct GNUNET_TRANSPORT_TESTING_ConnectCheckContext *ccc;
40
41
42static void
43notify_receive (void *cls,
44 struct GNUNET_TRANSPORT_TESTING_PeerContext *receiver,
45 const struct GNUNET_PeerIdentity *sender,
46 const struct GNUNET_TRANSPORT_TESTING_TestMessage *message)
47{
48 {
49 char *ps = GNUNET_strdup (GNUNET_i2s (&receiver->id));
50
51 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
52 "Peer %u (`%s') received message of type %d and size %u size from peer %s!\n",
53 receiver->no,
54 ps,
55 ntohs (message->header.type),
56 ntohs (message->header.size),
57 GNUNET_i2s (sender));
58 GNUNET_free (ps);
59 }
60
61 if ((GNUNET_TRANSPORT_TESTING_SIMPLE_MTYPE == ntohs (message->header.type)) &&
62 (GNUNET_TRANSPORT_TESTING_LARGE_MESSAGE_SIZE == ntohs (
63 message->header.size)))
64 {
65 ccc->global_ret = GNUNET_OK;
66 GNUNET_SCHEDULER_shutdown ();
67 }
68 else
69 {
70 GNUNET_break (0);
71 ccc->global_ret = GNUNET_SYSERR;
72 GNUNET_SCHEDULER_shutdown ();
73 }
74}
75
76
77/**
78 * Runs the test.
79 *
80 * @param argv the argv argument from main()
81 * @param bi_directional should we try to establish connections
82 * in both directions simultaneously?
83 */
84static int
85test (char *argv[],
86 int bi_directional)
87{
88 struct GNUNET_TRANSPORT_TESTING_SendClosure sc = {
89 .num_messages = 1
90 };
91 struct GNUNET_TRANSPORT_TESTING_ConnectCheckContext my_ccc = {
92 .connect_continuation = &GNUNET_TRANSPORT_TESTING_large_send,
93 .connect_continuation_cls = &sc,
94 .config_file = "test_transport_api_data.conf",
95 .rec = &notify_receive,
96 .nc = &GNUNET_TRANSPORT_TESTING_log_connect,
97 .nd = &GNUNET_TRANSPORT_TESTING_log_disconnect,
98 .timeout = TIMEOUT,
99 .bi_directional = bi_directional
100 };
101
102 ccc = &my_ccc;
103 sc.ccc = ccc;
104 if (GNUNET_OK !=
105 GNUNET_TRANSPORT_TESTING_main (2,
106 &GNUNET_TRANSPORT_TESTING_connect_check,
107 ccc))
108 return 1;
109 return 0;
110}
111
112
113int
114main (int argc,
115 char *argv[])
116{
117 if ((0 != test (argv,
118 GNUNET_NO)) ||
119 (0 != test (argv,
120 GNUNET_YES)))
121 return 1;
122 return 0;
123}
124
125
126/* end of test_transport_api.c */
diff --git a/src/transport/transport-testing-filenames2.c b/src/transport/transport-testing-filenames2.c
new file mode 100644
index 000000000..7d6fd529d
--- /dev/null
+++ b/src/transport/transport-testing-filenames2.c
@@ -0,0 +1,202 @@
1/*
2 This file is part of GNUnet.
3 Copyright (C) 2006, 2009, 2015, 2016 GNUnet e.V.
4
5 GNUnet is free software: you can redistribute it and/or modify it
6 under the terms of the GNU Affero General Public License as published
7 by the Free Software Foundation, either version 3 of the License,
8 or (at your option) any later version.
9
10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Affero General Public License for more details.
14
15 You should have received a copy of the GNU Affero General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17
18 SPDX-License-Identifier: AGPL3.0-or-later
19 */
20/**
21 * @file transport-testing-filenames.c
22 * @brief convenience string manipulation functions for tests
23 * @author Matthias Wachs
24 * @author Christian Grothoff
25 */
26#include "transport-testing2.h"
27
28
29/**
30 * Removes all directory separators from absolute filename
31 *
32 * @param file the absolute file name, e.g. as found in argv[0]
33 * @return extracted file name, has to be freed by caller
34 */
35static char *
36extract_filename (const char *file)
37{
38 char *pch = GNUNET_strdup (file);
39 char *backup = pch;
40 char *filename = NULL;
41 char *res;
42
43 if (NULL != strstr (pch, "/"))
44 {
45 pch = strtok (pch, "/");
46 while (pch != NULL)
47 {
48 pch = strtok (NULL, "/");
49 if (pch != NULL)
50 {
51 filename = pch;
52 }
53 }
54 }
55 else
56 filename = pch;
57
58 res = GNUNET_strdup (filename);
59 GNUNET_free (backup);
60 return res;
61}
62
63
64/**
65 * Extracts the test filename from an absolute file name and removes
66 * the extension
67 *
68 * @param file absolute file name
69 * @return the result
70 */
71char *
72GNUNET_TRANSPORT_TESTING_get_test_name (const char *file)
73{
74 char *backup = extract_filename (file);
75 char *filename = backup;
76 char *dotexe;
77 char *ret;
78
79 if (NULL == filename)
80 return NULL;
81
82 /* remove "lt-" */
83 filename = strstr (filename, "test");
84 if (NULL == filename)
85 {
86 GNUNET_free (backup);
87 return NULL;
88 }
89
90 /* remove ".exe" */
91 if (NULL != (dotexe = strstr (filename, ".exe")))
92 dotexe[0] = '\0';
93 ret = GNUNET_strdup (filename);
94 GNUNET_free (backup);
95 return ret;
96}
97
98
99/**
100 * Extracts the filename from an absolute file name and removes the extension
101 *
102 * @param file absolute file name
103 * @return the result
104 */
105char *
106GNUNET_TRANSPORT_TESTING_get_test_source_name (const char *file)
107{
108 char *src = extract_filename (file);
109 char *split;
110
111 split = strstr (src, ".");
112 if (NULL != split)
113 split[0] = '\0';
114 return src;
115}
116
117
118/**
119 * Extracts the plugin name from an absolute file name and the test name
120 *
121 * @param file absolute file name
122 * @param test test name
123 * @return the result
124 */
125char *
126GNUNET_TRANSPORT_TESTING_get_test_plugin_name (const char *file,
127 const char *test)
128{
129 char *filename;
130 char *dotexe;
131 char *e = extract_filename (file);
132 char *t = extract_filename (test);
133 char *ret;
134
135 if (NULL == e)
136 goto fail;
137 /* remove "lt-" */
138 filename = strstr (e, "tes");
139 if (NULL == filename)
140 goto fail;
141 /* remove ".exe" */
142 if (NULL != (dotexe = strstr (filename, ".exe")))
143 dotexe[0] = '\0';
144
145 /* find last _ */
146 filename = strstr (filename, t);
147 if (NULL == filename)
148 goto fail;
149 /* copy plugin */
150 filename += strlen (t);
151 if ('\0' != *filename)
152 filename++;
153 ret = GNUNET_strdup (filename);
154 goto suc;
155fail:
156 ret = NULL;
157suc:
158 GNUNET_free (t);
159 GNUNET_free (e);
160 return ret;
161}
162
163
164/**
165 * This function takes the filename (e.g. argv[0), removes a "lt-"-prefix and
166 * if existing ".exe"-prefix and adds the peer-number
167 *
168 * @param file filename of the test, e.g. argv[0]
169 * @param count peer number
170 * @return the result
171 */
172char *
173GNUNET_TRANSPORT_TESTING_get_config_name (const char *file,
174 int count)
175{
176 char *filename = extract_filename (file);
177 char *backup = filename;
178 char *dotexe;
179 char *ret;
180
181 if (NULL == filename)
182 return NULL;
183 /* remove "lt-" */
184 filename = strstr (filename, "test");
185 if (NULL == filename)
186 goto fail;
187 /* remove ".exe" */
188 if (NULL != (dotexe = strstr (filename, ".exe")))
189 dotexe[0] = '\0';
190 GNUNET_asprintf (&ret,
191 "%s_peer%u.conf",
192 filename,
193 count);
194 GNUNET_free (backup);
195 return ret;
196fail:
197 GNUNET_free (backup);
198 return NULL;
199}
200
201
202/* end of transport-testing-filenames.c */
diff --git a/src/transport/transport-testing-loggers2.c b/src/transport/transport-testing-loggers2.c
new file mode 100644
index 000000000..ead4fa365
--- /dev/null
+++ b/src/transport/transport-testing-loggers2.c
@@ -0,0 +1,80 @@
1/*
2 This file is part of GNUnet.
3 Copyright (C) 2016 GNUnet e.V.
4
5 GNUnet is free software: you can redistribute it and/or modify it
6 under the terms of the GNU Affero General Public License as published
7 by the Free Software Foundation, either version 3 of the License,
8 or (at your option) any later version.
9
10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Affero General Public License for more details.
14
15 You should have received a copy of the GNU Affero General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17
18 SPDX-License-Identifier: AGPL3.0-or-later
19 */
20/**
21 * @file transport-testing-loggers.c
22 * @brief convenience functions for logging common events in tests
23 * @author Christian Grothoff
24 */
25#include "transport-testing2.h"
26
27
28/**
29 * Log a connect event.
30 *
31 * @param cls NULL
32 * @param me peer that had the event
33 * @param other peer that connected.
34 */
35void
36GNUNET_TRANSPORT_TESTING_log_connect (void *cls,
37 struct
38 GNUNET_TRANSPORT_TESTING_PeerContext *me,
39 const struct GNUNET_PeerIdentity *other)
40{
41 char *ps;
42
43 ps = GNUNET_strdup (GNUNET_i2s (&me->id));
44 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
45 "Peer %s connected to %u (%s)!\n",
46 GNUNET_i2s (other),
47 me->no,
48 ps);
49 GNUNET_free (ps);
50}
51
52
53/**
54 * Log a disconnect event.
55 *
56 * @param cls NULL
57 * @param me peer that had the event
58 * @param other peer that disconnected.
59 */
60void
61GNUNET_TRANSPORT_TESTING_log_disconnect (void *cls,
62 struct
63 GNUNET_TRANSPORT_TESTING_PeerContext *
64 me,
65 const struct
66 GNUNET_PeerIdentity *other)
67{
68 char *ps;
69
70 ps = GNUNET_strdup (GNUNET_i2s (&me->id));
71 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
72 "Peer `%s' disconnected from %u (%s)!\n",
73 GNUNET_i2s (other),
74 me->no,
75 ps);
76 GNUNET_free (ps);
77}
78
79
80/* end of transport-testing-loggers.c */
diff --git a/src/transport/transport-testing-main2.c b/src/transport/transport-testing-main2.c
new file mode 100644
index 000000000..62aa3ceb7
--- /dev/null
+++ b/src/transport/transport-testing-main2.c
@@ -0,0 +1,613 @@
1/*
2 This file is part of GNUnet.
3 Copyright (C) 2016 GNUnet e.V.
4
5 GNUnet is free software: you can redistribute it and/or modify it
6 under the terms of the GNU Affero General Public License as published
7 by the Free Software Foundation, either version 3 of the License,
8 or (at your option) any later version.
9
10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Affero General Public License for more details.
14
15 You should have received a copy of the GNU Affero General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17
18 SPDX-License-Identifier: AGPL3.0-or-later
19 */
20/**
21 * @file transport-testing-main.c
22 * @brief convenience main function for tests
23 * @author Christian Grothoff
24 */
25#include "transport-testing2.h"
26
27
28/**
29 * Closure for #connect_cb.
30 */
31struct GNUNET_TRANSPORT_TESTING_ConnectRequestList
32{
33 /**
34 * Stored in a DLL.
35 */
36 struct GNUNET_TRANSPORT_TESTING_ConnectRequestList *next;
37
38 /**
39 * Stored in a DLL.
40 */
41 struct GNUNET_TRANSPORT_TESTING_ConnectRequestList *prev;
42
43 /**
44 * Overall context we are in.
45 */
46 struct GNUNET_TRANSPORT_TESTING_ConnectCheckContext *ccc;
47
48 /**
49 * Connect request this is about.
50 */
51 struct GNUNET_TRANSPORT_TESTING_ConnectRequest *cr;
52
53 /**
54 * Peer being connected.
55 */
56 struct GNUNET_TRANSPORT_TESTING_PeerContext *p1;
57
58 /**
59 * Peer being connected.
60 */
61 struct GNUNET_TRANSPORT_TESTING_PeerContext *p2;
62};
63
64
65/**
66 * Shutdown function for the test. Stops all peers.
67 *
68 * @param cls our `struct GNUNET_TRANSPORT_TESTING_ConnectCheckContext *`
69 */
70static void
71do_shutdown (void *cls)
72{
73 struct GNUNET_TRANSPORT_TESTING_ConnectCheckContext *ccc = cls;
74 struct GNUNET_TRANSPORT_TESTING_ConnectRequestList *crl;
75
76 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
77 "Testcase shutting down\n");
78 if (NULL != ccc->shutdown_task)
79 ccc->shutdown_task (ccc->shutdown_task_cls);
80 if (NULL != ccc->timeout_task)
81 {
82 GNUNET_SCHEDULER_cancel (ccc->timeout_task);
83 ccc->timeout_task = NULL;
84 }
85 if (NULL != ccc->connect_task)
86 {
87 GNUNET_SCHEDULER_cancel (ccc->connect_task);
88 ccc->connect_task = NULL;
89 }
90 while (NULL != (crl = ccc->crl_head))
91 {
92 GNUNET_CONTAINER_DLL_remove (ccc->crl_head,
93 ccc->crl_tail,
94 crl);
95 GNUNET_TRANSPORT_TESTING_connect_peers_cancel (crl->cr);
96 GNUNET_free (crl);
97 }
98 for (unsigned int i = 0; i < ccc->num_peers; i++)
99 {
100 if (NULL != ccc->p[i])
101 {
102 GNUNET_TRANSPORT_TESTING_stop_peer (ccc->p[i]);
103 ccc->p[i] = NULL;
104 }
105 }
106}
107
108
109/**
110 * Testcase hit timeout, shut it down with error.
111 *
112 * @param cls our `struct GNUNET_TRANSPORT_TESTING_ConnectCheckContext *`
113 */
114static void
115do_timeout (void *cls)
116{
117 struct GNUNET_TRANSPORT_TESTING_ConnectCheckContext *ccc = cls;
118
119 ccc->timeout_task = NULL;
120 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
121 "Testcase timed out\n");
122 ccc->global_ret = GNUNET_SYSERR;
123 GNUNET_SCHEDULER_shutdown ();
124}
125
126
127/**
128 * Internal data structure. Closure for
129 * #connect_cb, #disconnect_cb, #my_nc and #start_cb.
130 * Allows us to identify which peer this is about.
131 */
132struct GNUNET_TRANSPORT_TESTING_InternalPeerContext
133{
134 /**
135 * Overall context of the callback.
136 */
137 struct GNUNET_TRANSPORT_TESTING_ConnectCheckContext *ccc;
138
139 /**
140 * Offset of the peer this is about.
141 */
142 unsigned int off;
143};
144
145
146/**
147 * Information tracked per connected peer.
148 */
149struct ConnectPairInfo
150{
151 /**
152 * Peer this is about.
153 */
154 const struct GNUNET_PeerIdentity *sender;
155
156 /**
157 * Information about the receiving peer.
158 */
159 struct GNUNET_TRANSPORT_TESTING_InternalPeerContext *ipi;
160};
161
162
163/**
164 * Function called when we connected two peers. Once we have gotten
165 * to the clique, launch test-specific logic.
166 *
167 * @param cls our `struct GNUNET_TRANSPORT_TESTING_ConnectRequestList *`
168 */
169static void
170connect_cb (void *cls)
171{
172 struct GNUNET_TRANSPORT_TESTING_ConnectRequestList *crl = cls;
173 struct GNUNET_TRANSPORT_TESTING_ConnectCheckContext *ccc = crl->ccc;
174
175 GNUNET_CONTAINER_DLL_remove (ccc->crl_head,
176 ccc->crl_tail,
177 crl);
178 {
179 char *p1_c = GNUNET_strdup (GNUNET_i2s (&crl->p1->id));
180
181 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
182 "Peers connected: %u (%s) <-> %u (%s)\n",
183 crl->p1->no,
184 p1_c,
185 crl->p2->no,
186 GNUNET_i2s (&crl->p2->id));
187 GNUNET_free (p1_c);
188 GNUNET_free (crl);
189 }
190 if (NULL == ccc->crl_head)
191 {
192 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
193 "All connections UP, launching custom test logic.\n");
194 GNUNET_SCHEDULER_add_now (ccc->connect_continuation,
195 ccc->connect_continuation_cls);
196 }
197}
198
199
200/**
201 * Find peer by peer ID.
202 *
203 * @param ccc context to search
204 * @param peer peer to look for
205 * @return NULL if @a peer was not found
206 */
207struct GNUNET_TRANSPORT_TESTING_PeerContext *
208GNUNET_TRANSPORT_TESTING_find_peer (struct
209 GNUNET_TRANSPORT_TESTING_ConnectCheckContext
210 *ccc,
211 const struct GNUNET_PeerIdentity *peer)
212{
213 for (unsigned int i = 0; i < ccc->num_peers; i++)
214 if ((NULL != ccc->p[i]) &&
215 (0 == memcmp (peer,
216 &ccc->p[i]->id,
217 sizeof(*peer))))
218 return ccc->p[i];
219 return NULL;
220}
221
222
223/**
224 * Wrapper around peers connecting. Calls client's nc function.
225 *
226 * @param cls our `struct GNUNET_TRANSPORT_TESTING_InternalPeerContext *`
227 * @param peer peer we got connected to
228 * @param mq message queue for transmissions to @a peer
229 * @return closure for message handlers
230 */
231static void *
232my_nc (void *cls,
233 const struct GNUNET_PeerIdentity *peer,
234 struct GNUNET_MQ_Handle *mq)
235{
236 struct GNUNET_TRANSPORT_TESTING_InternalPeerContext *ipi = cls;
237 struct GNUNET_TRANSPORT_TESTING_ConnectCheckContext *ccc = ipi->ccc;
238 struct ConnectPairInfo *cpi;
239
240 if (NULL != ccc->nc)
241 ccc->nc (ccc->cls,
242 ccc->p[ipi->off],
243 peer);
244 cpi = GNUNET_new (struct ConnectPairInfo);
245 cpi->ipi = ipi;
246 cpi->sender = peer; /* valid until disconnect */
247 return cpi;
248}
249
250
251/**
252 * Wrapper around peers disconnecting. Calls client's nd function.
253 *
254 * @param cls our `struct GNUNET_TRANSPORT_TESTING_InternalPeerContext *`
255 * @param peer peer we got disconnected from
256 * @param custom_cls return value from @my_nc
257 */
258static void
259my_nd (void *cls,
260 const struct GNUNET_PeerIdentity *peer,
261 void *custom_cls)
262{
263 struct GNUNET_TRANSPORT_TESTING_InternalPeerContext *ipi = cls;
264 struct GNUNET_TRANSPORT_TESTING_ConnectCheckContext *ccc = ipi->ccc;
265 struct ConnectPairInfo *cpi = custom_cls;
266
267 if (NULL != ccc->nd)
268 ccc->nd (ccc->cls,
269 ccc->p[ipi->off],
270 peer);
271 GNUNET_free (cpi);
272}
273
274
275/**
276 * Wrapper around receiving data. Calls client's rec function.
277 *
278 * @param cls our `struct ConnectPairInfo *`
279 * @param message message we received
280 * @return #GNUNET_OK (all messages are fine)
281 */
282static int
283check_test (void *cls,
284 const struct GNUNET_TRANSPORT_TESTING_TestMessage *message)
285{
286 return GNUNET_OK;
287}
288
289
290/**
291 * Wrapper around receiving data. Calls client's rec function.
292 *
293 * @param cls our `struct ConnectPairInfo *`
294 * @param message message we received
295 */
296static void
297handle_test (void *cls,
298 const struct GNUNET_TRANSPORT_TESTING_TestMessage *message)
299{
300 struct ConnectPairInfo *cpi = cls;
301 struct GNUNET_TRANSPORT_TESTING_InternalPeerContext *ipi = cpi->ipi;
302 struct GNUNET_TRANSPORT_TESTING_ConnectCheckContext *ccc = ipi->ccc;
303
304 if (NULL != ccc->rec)
305 ccc->rec (ccc->cls,
306 ccc->p[ipi->off],
307 cpi->sender,
308 message);
309}
310
311
312/**
313 * Wrapper around receiving data. Calls client's rec function.
314 *
315 * @param cls our `struct ConnectPairInfo *`
316 * @param message message we received
317 * @return #GNUNET_OK (all messages are fine)
318 */
319static int
320check_test2 (void *cls,
321 const struct GNUNET_TRANSPORT_TESTING_TestMessage *message)
322{
323 return GNUNET_OK;
324}
325
326
327/**
328 * Wrapper around receiving data. Calls client's rec function.
329 *
330 * @param cls our `struct ConnectPairInfo *`
331 * @param message message we received
332 */
333static void
334handle_test2 (void *cls,
335 const struct GNUNET_TRANSPORT_TESTING_TestMessage *message)
336{
337 struct ConnectPairInfo *cpi = cls;
338 struct GNUNET_TRANSPORT_TESTING_InternalPeerContext *ipi = cpi->ipi;
339 struct GNUNET_TRANSPORT_TESTING_ConnectCheckContext *ccc = ipi->ccc;
340
341 if (NULL != ccc->rec)
342 ccc->rec (ccc->cls,
343 ccc->p[ipi->off],
344 cpi->sender,
345 message);
346}
347
348
349/**
350 * Connect the peers as a clique.
351 *
352 * @param cls our `struct GNUNET_TRANSPORT_TESTING_ConnectCheckContext`
353 */
354static void
355do_connect (void *cls)
356{
357 struct GNUNET_TRANSPORT_TESTING_ConnectCheckContext *ccc = cls;
358
359 ccc->connect_task = NULL;
360 for (unsigned int i = 0; i < ccc->num_peers; i++)
361 for (unsigned int j = (ccc->bi_directional ? 0 : i + 1); j < ccc->num_peers;
362 j++)
363 {
364 struct GNUNET_TRANSPORT_TESTING_ConnectRequestList *crl;
365
366 if (i == j)
367 continue;
368 crl = GNUNET_new (struct GNUNET_TRANSPORT_TESTING_ConnectRequestList);
369 GNUNET_CONTAINER_DLL_insert (ccc->crl_head,
370 ccc->crl_tail,
371 crl);
372 crl->ccc = ccc;
373 crl->p1 = ccc->p[i];
374 crl->p2 = ccc->p[j];
375 {
376 char *sender_c = GNUNET_strdup (GNUNET_i2s (&ccc->p[0]->id));
377
378 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
379 "Test tries to connect peer %u (`%s') -> peer %u (`%s')\n",
380 ccc->p[0]->no,
381 sender_c,
382 ccc->p[1]->no,
383 GNUNET_i2s (&ccc->p[1]->id));
384 GNUNET_free (sender_c);
385 }
386 crl->cr = GNUNET_TRANSPORT_TESTING_connect_peers (ccc->p[i],
387 ccc->p[j],
388 &connect_cb,
389 crl);
390 }
391}
392
393
394/**
395 * Function called once we have successfully launched a peer.
396 * Once all peers have been launched, we connect all of them
397 * in a clique.
398 *
399 * @param cls our `struct GNUNET_TRANSPORT_TESTING_InternalPeerContext *`
400 */
401static void
402start_cb (void *cls)
403{
404 struct GNUNET_TRANSPORT_TESTING_InternalPeerContext *ipi = cls;
405 struct GNUNET_TRANSPORT_TESTING_ConnectCheckContext *ccc = ipi->ccc;
406 struct GNUNET_TRANSPORT_TESTING_PeerContext *p = ccc->p[ipi->off];
407
408 ccc->started++;
409 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
410 "Peer %u (`%s') started\n",
411 p->no,
412 GNUNET_i2s (&p->id));
413 if (ccc->started != ccc->num_peers)
414 return;
415 if (NULL != ccc->pre_connect_task)
416 {
417 /* Run the custom per-connect job, then give it a second to
418 go into effect before we continue connecting peers. */
419 ccc->pre_connect_task (ccc->pre_connect_task_cls);
420 ccc->connect_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS,
421 &do_connect,
422 ccc);
423 }
424 else
425 {
426 do_connect (ccc);
427 }
428}
429
430
431/**
432 * Function run from #GNUNET_TRANSPORT_TESTING_connect_check
433 * once the scheduler is up. Should launch the peers and
434 * then in the continuations try to connect them.
435 *
436 * @param cls our `struct GNUNET_TRANSPORT_TESTING_ConnectCheckContext *`
437 * @param args ignored
438 * @param cfgfile ignored
439 * @param cfg configuration
440 */
441static void
442connect_check_run (void *cls,
443 char *const *args,
444 const char *cfgfile,
445 const struct GNUNET_CONFIGURATION_Handle *cfg)
446{
447 struct GNUNET_TRANSPORT_TESTING_ConnectCheckContext *ccc = cls;
448 int ok;
449
450 ccc->cfg = cfg;
451 ccc->timeout_task = GNUNET_SCHEDULER_add_delayed (ccc->timeout,
452 &do_timeout,
453 ccc);
454 GNUNET_SCHEDULER_add_shutdown (&do_shutdown,
455 ccc);
456 ok = GNUNET_OK;
457 for (unsigned int i = 0; i < ccc->num_peers; i++)
458 {
459 struct GNUNET_MQ_MessageHandler handlers[] = {
460 GNUNET_MQ_hd_var_size (test,
461 GNUNET_TRANSPORT_TESTING_SIMPLE_MTYPE,
462 struct GNUNET_TRANSPORT_TESTING_TestMessage,
463 NULL),
464 GNUNET_MQ_hd_var_size (test2,
465 GNUNET_TRANSPORT_TESTING_SIMPLE_MTYPE2,
466 struct GNUNET_TRANSPORT_TESTING_TestMessage,
467 NULL),
468 GNUNET_MQ_handler_end ()
469 };
470 ccc->p[i] = GNUNET_TRANSPORT_TESTING_start_peer (ccc->tth,
471 ccc->cfg_files[i],
472 i + 1,
473 handlers,
474 &my_nc,
475 &my_nd,
476 &ccc->ip[i],
477 &start_cb,
478 &ccc->ip[i]);
479 if (NULL == ccc->p[i])
480 ok = GNUNET_SYSERR;
481 }
482 if (GNUNET_OK != ok)
483 {
484 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
485 "Fail! Could not start peers!\n");
486 GNUNET_SCHEDULER_shutdown ();
487 }
488}
489
490
491/**
492 * Common implementation of the #GNUNET_TRANSPORT_TESTING_CheckCallback.
493 * Starts and connects the two peers, then invokes the
494 * `connect_continuation` from @a cls. Sets up a timeout to
495 * abort the test, and a shutdown handler to clean up properly
496 * on exit.
497 *
498 * @param cls closure of type `struct GNUNET_TRANSPORT_TESTING_ConnectCheckContext`
499 * @param tth_ initialized testing handle
500 * @param test_plugin_ name of the plugin
501 * @param test_name_ name of the test
502 * @param num_peers number of entries in the @a cfg_file array
503 * @param cfg_files array of names of configuration files for the peers
504 * @return #GNUNET_SYSERR on error
505 */
506int
507GNUNET_TRANSPORT_TESTING_connect_check (void *cls,
508 struct GNUNET_TRANSPORT_TESTING_Handle *
509 tth_,
510 const char *test_plugin_,
511 const char *test_name_,
512 unsigned int num_peers,
513 char *cfg_files[])
514{
515 static struct GNUNET_GETOPT_CommandLineOption options[] = {
516 GNUNET_GETOPT_OPTION_END
517 };
518 struct GNUNET_TRANSPORT_TESTING_ConnectCheckContext *ccc = cls;
519 struct GNUNET_TRANSPORT_TESTING_PeerContext *p[num_peers];
520 struct GNUNET_TRANSPORT_TESTING_InternalPeerContext ip[num_peers];
521 char *argv[] = {
522 (char *) test_name_,
523 "-c",
524 (char *) ccc->config_file,
525 NULL
526 };
527
528 ccc->num_peers = num_peers;
529 ccc->cfg_files = cfg_files;
530 ccc->test_plugin = test_plugin_;
531 ccc->test_name = test_name_;
532 ccc->tth = tth_;
533 ccc->global_ret = GNUNET_OK;
534 ccc->p = p;
535 ccc->ip = ip;
536 for (unsigned int i = 0; i < num_peers; i++)
537 {
538 ip[i].off = i;
539 ip[i].ccc = ccc;
540 }
541 if (GNUNET_OK !=
542 GNUNET_PROGRAM_run ((sizeof(argv) / sizeof(char *)) - 1,
543 argv,
544 test_name_,
545 "nohelp",
546 options,
547 &connect_check_run,
548 ccc))
549 return GNUNET_SYSERR;
550 return ccc->global_ret;
551}
552
553
554/**
555 * Setup testcase. Calls @a check with the data the test needs.
556 *
557 * @param argv0 binary name (argv[0])
558 * @param filename source file name (__FILE__)
559 * @param num_peers number of peers to start
560 * @param check main function to run
561 * @param check_cls closure for @a check
562 * @return #GNUNET_OK on success
563 */
564int
565GNUNET_TRANSPORT_TESTING_main_ (const char *argv0,
566 const char *filename,
567 unsigned int num_peers,
568 GNUNET_TRANSPORT_TESTING_CheckCallback check,
569 void *check_cls)
570{
571 struct GNUNET_TRANSPORT_TESTING_Handle *tth;
572 char *test_name;
573 char *test_source;
574 char *test_plugin;
575 char *cfg_names[num_peers];
576 int ret;
577
578 ret = GNUNET_OK;
579 test_name = GNUNET_TRANSPORT_TESTING_get_test_name (argv0);
580 GNUNET_log_setup (test_name,
581 "WARNING",
582 NULL);
583 test_source = GNUNET_TRANSPORT_TESTING_get_test_source_name (filename);
584 test_plugin = GNUNET_TRANSPORT_TESTING_get_test_plugin_name (argv0,
585 test_source);
586 for (unsigned int i = 0; i < num_peers; i++)
587 cfg_names[i] = GNUNET_TRANSPORT_TESTING_get_config_name (argv0,
588 i + 1);
589 tth = GNUNET_TRANSPORT_TESTING_init ();
590 if (NULL == tth)
591 {
592 ret = GNUNET_SYSERR;
593 }
594 else
595 {
596 ret = check (check_cls,
597 tth,
598 test_plugin,
599 test_name,
600 num_peers,
601 cfg_names);
602 GNUNET_TRANSPORT_TESTING_done (tth);
603 }
604 for (unsigned int i = 0; i < num_peers; i++)
605 GNUNET_free (cfg_names[i]);
606 GNUNET_free (test_source);
607 GNUNET_free (test_plugin);
608 GNUNET_free (test_name);
609 return ret;
610}
611
612
613/* end of transport-testing-main.c */
diff --git a/src/transport/transport-testing-send2.c b/src/transport/transport-testing-send2.c
new file mode 100644
index 000000000..bd2afb9b0
--- /dev/null
+++ b/src/transport/transport-testing-send2.c
@@ -0,0 +1,240 @@
1/*
2 This file is part of GNUnet.
3 Copyright (C) 2016 GNUnet e.V.
4
5 GNUnet is free software: you can redistribute it and/or modify it
6 under the terms of the GNU Affero General Public License as published
7 by the Free Software Foundation, either version 3 of the License,
8 or (at your option) any later version.
9
10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Affero General Public License for more details.
14
15 You should have received a copy of the GNU Affero General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17
18 SPDX-License-Identifier: AGPL3.0-or-later
19 */
20/**
21 * @file transport-testing-send.c
22 * @brief convenience transmission function for tests
23 * @author Christian Grothoff
24 */
25#include "transport-testing2.h"
26
27/**
28 * Acceptable transmission delay.
29 */
30#define TIMEOUT_TRANSMIT GNUNET_TIME_relative_multiply ( \
31 GNUNET_TIME_UNIT_SECONDS, 30)
32
33
34/**
35 * Return @a cx in @a cls.
36 */
37static void
38find_cr (void *cls,
39 struct GNUNET_TRANSPORT_TESTING_ConnectRequest *cx)
40{
41 struct GNUNET_TRANSPORT_TESTING_ConnectRequest **cr = cls;
42
43 if (GNUNET_NO == cx->connected)
44 return;
45 *cr = cx;
46}
47
48
49/**
50 * Send a test message of type @a mtype and size @a msize from
51 * peer @a sender to peer @a receiver. The peers should be
52 * connected when this function is called.
53 *
54 * @param sender the sending peer
55 * @param receiver the receiving peer
56 * @param mtype message type to use
57 * @param msize size of the message, at least `sizeof (struct GNUNET_TRANSPORT_TESTING_TestMessage)`
58 * @param num unique message number
59 * @param cont continuation to call after transmission
60 * @param cont_cls closure for @a cont
61 * @return #GNUNET_OK if message was queued,
62 * #GNUNET_NO if peers are not connected
63 * #GNUNET_SYSERR if @a msize is illegal
64 */
65int
66GNUNET_TRANSPORT_TESTING_send (struct
67 GNUNET_TRANSPORT_TESTING_PeerContext *sender,
68 struct GNUNET_TRANSPORT_TESTING_PeerContext *
69 receiver,
70 uint16_t mtype,
71 uint16_t msize,
72 uint32_t num,
73 GNUNET_SCHEDULER_TaskCallback cont,
74 void *cont_cls)
75{
76 struct GNUNET_TRANSPORT_TESTING_ConnectRequest *cr;
77 struct GNUNET_MQ_Envelope *env;
78 struct GNUNET_TRANSPORT_TESTING_TestMessage *test;
79
80 if (msize < sizeof(struct GNUNET_TRANSPORT_TESTING_TestMessage))
81 {
82 GNUNET_break (0);
83 return GNUNET_SYSERR;
84 }
85 cr = NULL;
86 GNUNET_TRANSPORT_TESTING_find_connecting_context (sender,
87 receiver,
88 &find_cr,
89 &cr);
90 if (NULL == cr)
91 GNUNET_TRANSPORT_TESTING_find_connecting_context (receiver,
92 sender,
93 &find_cr,
94 &cr);
95 if (NULL == cr)
96 {
97 GNUNET_break (0);
98 return GNUNET_NO;
99 }
100 if (NULL == cr->mq)
101 {
102 GNUNET_break (0);
103 return GNUNET_NO;
104 }
105 {
106 char *receiver_s = GNUNET_strdup (GNUNET_i2s (&receiver->id));
107
108 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
109 "Sending message from peer %u (`%s') -> peer %u (`%s') !\n",
110 sender->no,
111 GNUNET_i2s (&sender->id),
112 receiver->no,
113 receiver_s);
114 GNUNET_free (receiver_s);
115 }
116 env = GNUNET_MQ_msg_extra (test,
117 msize - sizeof(*test),
118 mtype);
119 test->num = htonl (num);
120 memset (&test[1],
121 num,
122 msize - sizeof(*test));
123 GNUNET_MQ_notify_sent (env,
124 cont,
125 cont_cls);
126 GNUNET_MQ_send (cr->mq,
127 env);
128 return GNUNET_OK;
129}
130
131
132/**
133 * Task that sends a test message from the
134 * first peer to the second peer.
135 *
136 * @param ccc context which should contain at least two peers, the
137 * first two of which should be currently connected
138 * @param size desired message size
139 * @param cont continuation to call after transmission
140 * @param cont_cls closure for @a cont
141 */
142static void
143do_send (struct GNUNET_TRANSPORT_TESTING_ConnectCheckContext *ccc,
144 uint16_t size,
145 GNUNET_SCHEDULER_TaskCallback cont,
146 void *cont_cls)
147{
148 int ret;
149
150 ccc->global_ret = GNUNET_SYSERR;
151 ret = GNUNET_TRANSPORT_TESTING_send (ccc->p[0],
152 ccc->p[1],
153 GNUNET_TRANSPORT_TESTING_SIMPLE_MTYPE,
154 size,
155 ccc->send_num_gen++,
156 cont,
157 cont_cls);
158 GNUNET_assert (GNUNET_SYSERR != ret);
159 if (GNUNET_NO == ret)
160 {
161 GNUNET_break (0);
162 ccc->global_ret = GNUNET_SYSERR;
163 GNUNET_SCHEDULER_shutdown ();
164 }
165}
166
167
168/**
169 * Task that sends a minimalistic test message from the
170 * first peer to the second peer.
171 *
172 * @param cls the `struct GNUNET_TRANSPORT_TESTING_ConnectCheckContext`
173 * which should contain at least two peers, the first two
174 * of which should be currently connected
175 */
176void
177GNUNET_TRANSPORT_TESTING_simple_send (void *cls)
178{
179 struct GNUNET_TRANSPORT_TESTING_SendClosure *sc = cls;
180 int done;
181 size_t msize;
182
183 if (0 < sc->num_messages)
184 {
185 sc->num_messages--;
186 done = (0 == sc->num_messages);
187 }
188 else
189 {
190 done = 0; /* infinite loop */
191 }
192 msize = sizeof(struct GNUNET_TRANSPORT_TESTING_TestMessage);
193 if (NULL != sc->get_size_cb)
194 msize = sc->get_size_cb (sc->num_messages);
195 /* if this was the last message, call the continuation,
196 otherwise call this function again */
197 do_send (sc->ccc,
198 msize,
199 done ? sc->cont : &GNUNET_TRANSPORT_TESTING_simple_send,
200 done ? sc->cont_cls : sc);
201}
202
203
204/**
205 * Task that sends a large test message from the
206 * first peer to the second peer.
207 *
208 * @param cls the `struct GNUNET_TRANSPORT_TESTING_ConnectCheckContext`
209 * which should contain at least two peers, the first two
210 * of which should be currently connected
211 */
212void
213GNUNET_TRANSPORT_TESTING_large_send (void *cls)
214{
215 struct GNUNET_TRANSPORT_TESTING_SendClosure *sc = cls;
216 int done;
217 size_t msize;
218
219 if (0 < sc->num_messages)
220 {
221 sc->num_messages--;
222 done = (0 == sc->num_messages);
223 }
224 else
225 {
226 done = 0; /* infinite loop */
227 }
228 msize = 2600;
229 if (NULL != sc->get_size_cb)
230 msize = sc->get_size_cb (sc->num_messages);
231 /* if this was the last message, call the continuation,
232 otherwise call this function again */
233 do_send (sc->ccc,
234 msize,
235 done ? sc->cont : &GNUNET_TRANSPORT_TESTING_large_send,
236 done ? sc->cont_cls : sc);
237}
238
239
240/* end of transport-testing-send.c */
diff --git a/src/transport/transport-testing2.c b/src/transport/transport-testing2.c
index 374d78f67..d9f1d5e56 100644
--- a/src/transport/transport-testing2.c
+++ b/src/transport/transport-testing2.c
@@ -344,6 +344,7 @@ hello_iter_cb (void *cb_cls,
344 p->hello_size = record->value_size; 344 p->hello_size = record->value_size;
345 p->hello = GNUNET_malloc (p->hello_size); 345 p->hello = GNUNET_malloc (p->hello_size);
346 memcpy (p->hello, record->value, p->hello_size); 346 memcpy (p->hello, record->value, p->hello_size);
347 p->hello[p->hello_size-1] = '\0';
347 348
348 GNUNET_PEERSTORE_iterate_cancel (p->pic); 349 GNUNET_PEERSTORE_iterate_cancel (p->pic);
349 if (NULL != p->start_cb) 350 if (NULL != p->start_cb)
@@ -751,7 +752,7 @@ offer_hello (void *cls)
751 struct GNUNET_TRANSPORT_TESTING_PeerContext *p1 = cc->p1; 752 struct GNUNET_TRANSPORT_TESTING_PeerContext *p1 = cc->p1;
752 struct GNUNET_TRANSPORT_TESTING_PeerContext *p2 = cc->p2; 753 struct GNUNET_TRANSPORT_TESTING_PeerContext *p2 = cc->p2;
753 struct GNUNET_TIME_Absolute t; 754 struct GNUNET_TIME_Absolute t;
754 enum GNUNET_NetworkType nt; 755 enum GNUNET_NetworkType nt = 0;
755 char *addr; 756 char *addr;
756 757
757 cc->tct = NULL; 758 cc->tct = NULL;
@@ -769,11 +770,12 @@ offer_hello (void *cls)
769 } 770 }
770 771
771 addr = GNUNET_HELLO_extract_address (p2->hello, 772 addr = GNUNET_HELLO_extract_address (p2->hello,
772 strlen (p2->hello), 773 p2->hello_size,
773 &p2->id, 774 &p2->id,
774 &nt, 775 &nt,
775 &t); 776 &t);
776 GNUNET_assert (NULL != addr); 777 GNUNET_assert (NULL != addr);
778 GNUNET_assert (NULL != p1->hello);
777 GNUNET_TRANSPORT_application_validate (p1->ah, 779 GNUNET_TRANSPORT_application_validate (p1->ah,
778 &p2->id, 780 &p2->id,
779 nt, 781 nt,