aboutsummaryrefslogtreecommitdiff
path: root/src/transport/test_transport_api.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2011-06-26 22:26:57 +0000
committerChristian Grothoff <christian@grothoff.org>2011-06-26 22:26:57 +0000
commit1791f39fa6dc0bc37d14af98a0684fe1a23fc697 (patch)
tree66b33b772226f77289f669e6d9e4afa03b42a22b /src/transport/test_transport_api.c
parent8a3016481ba6aeb36de3950a56e641dda53ca544 (diff)
downloadgnunet-1791f39fa6dc0bc37d14af98a0684fe1a23fc697.tar.gz
gnunet-1791f39fa6dc0bc37d14af98a0684fe1a23fc697.zip
partial fix of the NAT troubles
Diffstat (limited to 'src/transport/test_transport_api.c')
-rw-r--r--src/transport/test_transport_api.c102
1 files changed, 56 insertions, 46 deletions
diff --git a/src/transport/test_transport_api.c b/src/transport/test_transport_api.c
index ac818d557..ae56c939f 100644
--- a/src/transport/test_transport_api.c
+++ b/src/transport/test_transport_api.c
@@ -37,7 +37,7 @@
37#include "transport.h" 37#include "transport.h"
38#include "transport-testing.h" 38#include "transport-testing.h"
39 39
40#define VERBOSE GNUNET_YES 40#define VERBOSE GNUNET_NO
41 41
42#define VERBOSE_ARM GNUNET_NO 42#define VERBOSE_ARM GNUNET_NO
43 43
@@ -122,16 +122,57 @@ static void
122stop_arm (struct PeerContext *p) 122stop_arm (struct PeerContext *p)
123{ 123{
124#if START_ARM 124#if START_ARM
125 if (0 != GNUNET_OS_process_kill (p->arm_proc, SIGTERM)) 125 if (NULL != p->arm_proc)
126 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill"); 126 {
127 GNUNET_OS_process_wait (p->arm_proc); 127 if (0 != GNUNET_OS_process_kill (p->arm_proc, SIGTERM))
128 GNUNET_OS_process_close (p->arm_proc); 128 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill");
129 p->arm_proc = NULL; 129 GNUNET_OS_process_wait (p->arm_proc);
130 GNUNET_OS_process_close (p->arm_proc);
131 p->arm_proc = NULL;
132 }
130#endif 133#endif
131 GNUNET_CONFIGURATION_destroy (p->cfg); 134 GNUNET_CONFIGURATION_destroy (p->cfg);
132} 135}
133 136
134 137
138
139
140static void
141exchange_hello_last (void *cls,
142 const struct GNUNET_MessageHeader *message)
143{
144 struct PeerContext *me = cls;
145
146 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
147 "Exchanging HELLO of size %d with peer (%s)!\n",
148 (int) GNUNET_HELLO_size((const struct GNUNET_HELLO_Message *)message),
149 GNUNET_i2s (&me->id));
150 GNUNET_assert (message != NULL);
151 GNUNET_assert (GNUNET_OK ==
152 GNUNET_HELLO_get_id ((const struct GNUNET_HELLO_Message *)
153 message, &me->id));
154 GNUNET_TRANSPORT_offer_hello (p1.th, message, NULL, NULL);
155}
156
157
158static void
159exchange_hello (void *cls,
160 const struct GNUNET_MessageHeader *message)
161{
162 struct PeerContext *me = cls;
163
164 GNUNET_assert (message != NULL);
165 GNUNET_assert (GNUNET_OK ==
166 GNUNET_HELLO_get_id ((const struct GNUNET_HELLO_Message *)
167 message, &me->id));
168 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
169 "Exchanging HELLO of size %d from peer %s!\n",
170 (int) GNUNET_HELLO_size((const struct GNUNET_HELLO_Message *)message),
171 GNUNET_i2s (&me->id));
172 GNUNET_TRANSPORT_offer_hello (p2.th, message, NULL, NULL);
173}
174
175
135static void 176static void
136end_badly () 177end_badly ()
137{ 178{
@@ -139,8 +180,15 @@ end_badly ()
139 GNUNET_break (0); 180 GNUNET_break (0);
140 181
141 if (th != NULL) 182 if (th != NULL)
142 GNUNET_TRANSPORT_notify_transmit_ready_cancel(th); 183 {
143 th = NULL; 184 GNUNET_TRANSPORT_notify_transmit_ready_cancel(th);
185 th = NULL;
186 }
187 else
188 {
189 GNUNET_TRANSPORT_get_hello_cancel (p2.th, &exchange_hello_last, &p2);
190 GNUNET_TRANSPORT_get_hello_cancel (p1.th, &exchange_hello, &p1);
191 }
144 192
145 GNUNET_TRANSPORT_disconnect (p1.th); 193 GNUNET_TRANSPORT_disconnect (p1.th);
146 GNUNET_TRANSPORT_disconnect (p2.th); 194 GNUNET_TRANSPORT_disconnect (p2.th);
@@ -199,44 +247,6 @@ notify_ready (void *cls, size_t size, void *buf)
199 247
200 248
201static void 249static void
202exchange_hello_last (void *cls,
203 const struct GNUNET_MessageHeader *message)
204{
205 struct PeerContext *me = cls;
206
207 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
208 "Exchanging HELLO of size %d with peer (%s)!\n",
209 (int) GNUNET_HELLO_size((const struct GNUNET_HELLO_Message *)message),
210 GNUNET_i2s (&me->id));
211 GNUNET_assert (message != NULL);
212 GNUNET_assert (GNUNET_OK ==
213 GNUNET_HELLO_get_id ((const struct GNUNET_HELLO_Message *)
214 message, &me->id));
215 GNUNET_TRANSPORT_offer_hello (p1.th, message, NULL, NULL);
216}
217
218
219
220static void
221exchange_hello (void *cls,
222 const struct GNUNET_MessageHeader *message)
223{
224 struct PeerContext *me = cls;
225
226 GNUNET_assert (message != NULL);
227 GNUNET_assert (GNUNET_OK ==
228 GNUNET_HELLO_get_id ((const struct GNUNET_HELLO_Message *)
229 message, &me->id));
230 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
231 "Exchanging HELLO of size %d from peer %s!\n",
232 (int) GNUNET_HELLO_size((const struct GNUNET_HELLO_Message *)message),
233 GNUNET_i2s (&me->id));
234 GNUNET_TRANSPORT_offer_hello (p2.th, message, NULL, NULL);
235}
236
237
238
239static void
240notify_connect (void *cls, 250notify_connect (void *cls,
241 const struct GNUNET_PeerIdentity *peer, 251 const struct GNUNET_PeerIdentity *peer,
242 const struct GNUNET_TRANSPORT_ATS_Information *ats, 252 const struct GNUNET_TRANSPORT_ATS_Information *ats,