summaryrefslogtreecommitdiff
path: root/src/transport/test_transport_api.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2011-06-05 00:11:22 +0000
committerChristian Grothoff <christian@grothoff.org>2011-06-05 00:11:22 +0000
commit91927291af2c925be9619aeef2d72a69bd84a1c2 (patch)
tree87b115987f3e8d228e567e076f1c251966bf446f /src/transport/test_transport_api.c
parent4ef653b9f65c03cc9e2506e2dbadd89deb724525 (diff)
downloadgnunet-91927291af2c925be9619aeef2d72a69bd84a1c2.tar.gz
gnunet-91927291af2c925be9619aeef2d72a69bd84a1c2.zip
moving some tests to new API
Diffstat (limited to 'src/transport/test_transport_api.c')
-rw-r--r--src/transport/test_transport_api.c360
1 files changed, 196 insertions, 164 deletions
diff --git a/src/transport/test_transport_api.c b/src/transport/test_transport_api.c
index d78e3264b..8b057d513 100644
--- a/src/transport/test_transport_api.c
+++ b/src/transport/test_transport_api.c
@@ -90,6 +90,8 @@ static int is_wlan;
90 90
91static GNUNET_SCHEDULER_TaskIdentifier die_task; 91static GNUNET_SCHEDULER_TaskIdentifier die_task;
92 92
93static GNUNET_SCHEDULER_TaskIdentifier tct;
94
93static char * key_file_p1; 95static char * key_file_p1;
94static char * cert_file_p1; 96static char * cert_file_p1;
95 97
@@ -106,15 +108,15 @@ static char * cert_file_p2;
106static void 108static void
107end () 109end ()
108{ 110{
109 /* do work here */
110 GNUNET_assert (ok == 6); 111 GNUNET_assert (ok == 6);
111 GNUNET_SCHEDULER_cancel (die_task); 112 GNUNET_SCHEDULER_cancel (die_task);
112 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Disconnecting from transports!\n"); 113 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
114 "Disconnecting from transports!\n");
113 GNUNET_TRANSPORT_disconnect (p1.th); 115 GNUNET_TRANSPORT_disconnect (p1.th);
114 GNUNET_TRANSPORT_disconnect (p2.th); 116 GNUNET_TRANSPORT_disconnect (p2.th);
115
116 die_task = GNUNET_SCHEDULER_NO_TASK; 117 die_task = GNUNET_SCHEDULER_NO_TASK;
117 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Transports disconnected, returning success!\n"); 118 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
119 "Transports disconnected, returning success!\n");
118 ok = 0; 120 ok = 0;
119} 121}
120 122
@@ -139,9 +141,15 @@ end_badly ()
139 GNUNET_break (0); 141 GNUNET_break (0);
140 GNUNET_TRANSPORT_disconnect (p1.th); 142 GNUNET_TRANSPORT_disconnect (p1.th);
141 GNUNET_TRANSPORT_disconnect (p2.th); 143 GNUNET_TRANSPORT_disconnect (p2.th);
144 if (GNUNET_SCHEDULER_NO_TASK != tct)
145 {
146 GNUNET_SCHEDULER_cancel (tct);
147 tct = GNUNET_SCHEDULER_NO_TASK;
148 }
142 ok = 1; 149 ok = 1;
143} 150}
144 151
152
145static void 153static void
146notify_receive (void *cls, 154notify_receive (void *cls,
147 const struct GNUNET_PeerIdentity *peer, 155 const struct GNUNET_PeerIdentity *peer,
@@ -149,20 +157,15 @@ notify_receive (void *cls,
149 const struct GNUNET_TRANSPORT_ATS_Information *ats, 157 const struct GNUNET_TRANSPORT_ATS_Information *ats,
150 uint32_t ats_count) 158 uint32_t ats_count)
151{ 159{
152 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "ok is (%d)!\n", 160 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
153 ok); 161 "Received message of type %d from peer %s!\n",
154 162 ntohs(message->type),
155 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received message of type %d from peer (%p)!\n", 163 GNUNET_i2s (peer));
156 ntohs(message->type), cls);
157
158 GNUNET_assert (ok == 5); 164 GNUNET_assert (ok == 5);
159 OKPP; 165 OKPP;
160
161 GNUNET_assert (MTYPE == ntohs (message->type)); 166 GNUNET_assert (MTYPE == ntohs (message->type));
162 GNUNET_assert (sizeof (struct GNUNET_MessageHeader) == 167 GNUNET_assert (sizeof (struct GNUNET_MessageHeader) ==
163 ntohs (message->size)); 168 ntohs (message->size));
164 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received message from peer (%p)!\n",
165 cls);
166 end (); 169 end ();
167} 170}
168 171
@@ -170,55 +173,97 @@ notify_receive (void *cls,
170static size_t 173static size_t
171notify_ready (void *cls, size_t size, void *buf) 174notify_ready (void *cls, size_t size, void *buf)
172{ 175{
176 struct PeerContext *p = cls;
173 struct GNUNET_MessageHeader *hdr; 177 struct GNUNET_MessageHeader *hdr;
174 178
175 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 179 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
176 "Transmitting message to peer (%p) - %u!\n", cls, sizeof (struct GNUNET_MessageHeader)); 180 "Transmitting message with %u bytes to peer %s\n",
181 sizeof (struct GNUNET_MessageHeader),
182 GNUNET_i2s (&p->id));
177 GNUNET_assert (size >= 256); 183 GNUNET_assert (size >= 256);
178 GNUNET_assert (ok == 4); 184 GNUNET_assert (ok == 4);
179 OKPP; 185 OKPP;
180
181 if (buf != NULL) 186 if (buf != NULL)
182 { 187 {
183 hdr = buf; 188 hdr = buf;
184 hdr->size = htons (sizeof (struct GNUNET_MessageHeader)); 189 hdr->size = htons (sizeof (struct GNUNET_MessageHeader));
185 hdr->type = htons (MTYPE); 190 hdr->type = htons (MTYPE);
186 } 191 }
187
188 return sizeof (struct GNUNET_MessageHeader); 192 return sizeof (struct GNUNET_MessageHeader);
189} 193}
190 194
191static size_t 195
192notify_ready_connect (void *cls, size_t size, void *buf) 196static void
197exchange_hello_last (void *cls,
198 const struct GNUNET_MessageHeader *message)
199{
200 struct PeerContext *me = cls;
201
202 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
203 "Exchanging HELLO of size %d with peer (%s)!\n",
204 (int) GNUNET_HELLO_size((const struct GNUNET_HELLO_Message *)message),
205 GNUNET_i2s (&me->id));
206 GNUNET_assert (message != NULL);
207 GNUNET_assert (GNUNET_OK ==
208 GNUNET_HELLO_get_id ((const struct GNUNET_HELLO_Message *)
209 message, &me->id));
210 GNUNET_TRANSPORT_offer_hello (p1.th, message, NULL, NULL);
211}
212
213
214
215static void
216exchange_hello (void *cls,
217 const struct GNUNET_MessageHeader *message)
193{ 218{
194 return 0; 219 struct PeerContext *me = cls;
220
221 GNUNET_assert (message != NULL);
222 GNUNET_assert (GNUNET_OK ==
223 GNUNET_HELLO_get_id ((const struct GNUNET_HELLO_Message *)
224 message, &me->id));
225 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
226 "Exchanging HELLO of size %d from peer %s!\n",
227 (int) GNUNET_HELLO_size((const struct GNUNET_HELLO_Message *)message),
228 GNUNET_i2s (&me->id));
229 GNUNET_TRANSPORT_offer_hello (p2.th, message, NULL, NULL);
195} 230}
196 231
197 232
233
198static void 234static void
199notify_connect (void *cls, 235notify_connect (void *cls,
200 const struct GNUNET_PeerIdentity *peer, 236 const struct GNUNET_PeerIdentity *peer,
201 const struct GNUNET_TRANSPORT_ATS_Information *ats, 237 const struct GNUNET_TRANSPORT_ATS_Information *ats,
202 uint32_t ats_count) 238 uint32_t ats_count)
203{ 239{
240 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
241 "Peer `%4s' connected to us (%p)!\n",
242 GNUNET_i2s (peer),
243 cls);
204 if (cls == &p1) 244 if (cls == &p1)
205 { 245 {
246 GNUNET_assert (ok >= 2);
247 OKPP;
248 OKPP;
206 GNUNET_SCHEDULER_cancel (die_task); 249 GNUNET_SCHEDULER_cancel (die_task);
250 GNUNET_SCHEDULER_cancel (tct);
251 tct = GNUNET_SCHEDULER_NO_TASK;
252 GNUNET_TRANSPORT_get_hello_cancel (p2.th, &exchange_hello_last, &p2);
253 GNUNET_TRANSPORT_get_hello_cancel (p1.th, &exchange_hello, &p1);
207 die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT_TRANSMIT, 254 die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT_TRANSMIT,
208 &end_badly, NULL); 255 &end_badly, NULL);
209
210 GNUNET_TRANSPORT_notify_transmit_ready (p1.th, 256 GNUNET_TRANSPORT_notify_transmit_ready (p1.th,
211 &p2.id, 257 &p2.id,
212 256, 0, TIMEOUT, &notify_ready, 258 256, 0, TIMEOUT, &notify_ready,
213 &p1); 259 &p1);
214 } 260 }
215 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
216 "Peer `%4s' connected to us (%p)!\n", GNUNET_i2s (peer), cls);
217} 261}
218 262
219 263
220static void 264static void
221notify_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer) 265notify_disconnect (void *cls,
266 const struct GNUNET_PeerIdentity *peer)
222{ 267{
223 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 268 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
224 "Peer `%4s' disconnected (%p)!\n", 269 "Peer `%4s' disconnected (%p)!\n",
@@ -227,7 +272,8 @@ notify_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer)
227 272
228 273
229static void 274static void
230setup_peer (struct PeerContext *p, const char *cfgname) 275setup_peer (struct PeerContext *p,
276 const char *cfgname)
231{ 277{
232 p->cfg = GNUNET_CONFIGURATION_create (); 278 p->cfg = GNUNET_CONFIGURATION_create ();
233#if START_ARM 279#if START_ARM
@@ -241,62 +287,74 @@ setup_peer (struct PeerContext *p, const char *cfgname)
241 GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname)); 287 GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname));
242 288
243 if (is_https) 289 if (is_https)
244 { 290 {
245 struct stat sbuf; 291 struct stat sbuf;
246 if (p==&p1) 292 if (p==&p1)
247 { 293 {
248 if (GNUNET_CONFIGURATION_have_value (p->cfg, 294 if (GNUNET_CONFIGURATION_have_value (p->cfg,
249 "transport-https", "KEY_FILE")) 295 "transport-https", "KEY_FILE"))
250 GNUNET_CONFIGURATION_get_value_string (p->cfg, "transport-https", "KEY_FILE", &key_file_p1); 296 GNUNET_CONFIGURATION_get_value_string (p->cfg, "transport-https", "KEY_FILE", &key_file_p1);
251 if (key_file_p1==NULL) 297 if (key_file_p1==NULL)
252 GNUNET_asprintf(&key_file_p1,"https.key"); 298 GNUNET_asprintf(&key_file_p1,"https.key");
253 if (0 == stat (key_file_p1, &sbuf )) 299 if (0 == stat (key_file_p1, &sbuf ))
254 { 300 {
255 if (0 == remove(key_file_p1)) 301 if (0 == remove(key_file_p1))
256 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Successfully removed existing private key file `%s'\n",key_file_p1); 302 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
257 else 303 "Successfully removed existing private key file `%s'\n",key_file_p1);
258 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to remove private key file `%s'\n",key_file_p1); 304 else
259 } 305 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
260 if (GNUNET_CONFIGURATION_have_value (p->cfg,"transport-https", "CERT_FILE")) 306 "Failed to remove private key file `%s'\n",key_file_p1);
261 GNUNET_CONFIGURATION_get_value_string (p->cfg, "transport-https", "CERT_FILE", &cert_file_p1); 307 }
262 if (cert_file_p1==NULL) 308 if (GNUNET_CONFIGURATION_have_value (p->cfg,"transport-https", "CERT_FILE"))
263 GNUNET_asprintf(&cert_file_p1,"https.cert"); 309 GNUNET_CONFIGURATION_get_value_string (p->cfg, "transport-https", "CERT_FILE", &cert_file_p1);
264 if (0 == stat (cert_file_p1, &sbuf )) 310 if (cert_file_p1==NULL)
265 { 311 GNUNET_asprintf(&cert_file_p1,"https.cert");
266 if (0 == remove(cert_file_p1)) 312 if (0 == stat (cert_file_p1, &sbuf ))
267 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Successfully removed existing certificate file `%s'\n",cert_file_p1); 313 {
268 else 314 if (0 == remove(cert_file_p1))
269 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to remove existing certificate file `%s'\n",cert_file_p1); 315 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
270 } 316 "Successfully removed existing certificate file `%s'\n",
271 } 317 cert_file_p1);
272 else if (p==&p2) 318 else
273 { 319 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
274 if (GNUNET_CONFIGURATION_have_value (p->cfg, 320 "Failed to remove existing certificate file `%s'\n",
275 "transport-https", "KEY_FILE")) 321 cert_file_p1);
276 GNUNET_CONFIGURATION_get_value_string (p->cfg, "transport-https", "KEY_FILE", &key_file_p2); 322 }
277 if (key_file_p2==NULL) 323 }
278 GNUNET_asprintf(&key_file_p2,"https.key"); 324 else if (p==&p2)
279 if (0 == stat (key_file_p2, &sbuf )) 325 {
280 { 326 if (GNUNET_CONFIGURATION_have_value (p->cfg,
281 if (0 == remove(key_file_p2)) 327 "transport-https", "KEY_FILE"))
282 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Successfully removed existing private key file `%s'\n",key_file_p2); 328 GNUNET_CONFIGURATION_get_value_string (p->cfg, "transport-https", "KEY_FILE", &key_file_p2);
283 else 329 if (key_file_p2==NULL)
284 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to remove private key file `%s'\n",key_file_p2); 330 GNUNET_asprintf(&key_file_p2,"https.key");
285 } 331 if (0 == stat (key_file_p2, &sbuf ))
286 if (GNUNET_CONFIGURATION_have_value (p->cfg,"transport-https", "CERT_FILE")) 332 {
287 GNUNET_CONFIGURATION_get_value_string (p->cfg, "transport-https", "CERT_FILE", &cert_file_p2); 333 if (0 == remove(key_file_p2))
288 if (cert_file_p2==NULL) 334 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
289 GNUNET_asprintf(&cert_file_p2,"https.cert"); 335 "Successfully removed existing private key file `%s'\n",
290 if (0 == stat (cert_file_p2, &sbuf )) 336 key_file_p2);
291 { 337 else
292 if (0 == remove(cert_file_p2)) 338 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
293 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Successfully removed existing certificate file `%s'\n",cert_file_p2); 339 "Failed to remove private key file `%s'\n",
294 else 340 key_file_p2);
295 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to remove existing certificate file `%s'\n",cert_file_p2); 341 }
296 } 342 if (GNUNET_CONFIGURATION_have_value (p->cfg,"transport-https", "CERT_FILE"))
297 } 343 GNUNET_CONFIGURATION_get_value_string (p->cfg, "transport-https", "CERT_FILE", &cert_file_p2);
298 } 344 if (cert_file_p2==NULL)
299 345 GNUNET_asprintf(&cert_file_p2,"https.cert");
346 if (0 == stat (cert_file_p2, &sbuf ))
347 {
348 if (0 == remove(cert_file_p2))
349 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
350 "Successfully removed existing certificate file `%s'\n",cert_file_p2);
351 else
352 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
353 "Failed to remove existing certificate file `%s'\n",cert_file_p2);
354 }
355 }
356 }
357
300 p->th = GNUNET_TRANSPORT_connect (p->cfg, 358 p->th = GNUNET_TRANSPORT_connect (p->cfg,
301 NULL, p, 359 NULL, p,
302 &notify_receive, 360 &notify_receive,
@@ -306,53 +364,18 @@ setup_peer (struct PeerContext *p, const char *cfgname)
306 364
307 365
308static void 366static void
309exchange_hello_last (void *cls, 367try_connect (void *cls,
310 const struct GNUNET_MessageHeader *message) 368 const struct GNUNET_SCHEDULER_TaskContext *tc)
311{
312 struct PeerContext *me = cls;
313
314 GNUNET_TRANSPORT_get_hello_cancel (p2.th, &exchange_hello_last, me);
315 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
316 "Exchanging HELLO with peer (%p)!\n", cls);
317 GNUNET_assert (ok >= 3);
318 OKPP;
319 GNUNET_assert (message != NULL);
320 GNUNET_assert (GNUNET_OK ==
321 GNUNET_HELLO_get_id ((const struct GNUNET_HELLO_Message *)
322 message, &me->id));
323
324 GNUNET_assert(NULL != GNUNET_TRANSPORT_notify_transmit_ready (p2.th,
325 &p1.id,
326 sizeof (struct GNUNET_MessageHeader), 0,
327 TIMEOUT,
328 &notify_ready_connect,
329 NULL));
330
331 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
332 "Finished exchanging HELLOs, now waiting for transmission!\n");
333}
334
335static void
336exchange_hello (void *cls,
337 const struct GNUNET_MessageHeader *message)
338{ 369{
339 struct PeerContext *me = cls;
340
341 GNUNET_TRANSPORT_get_hello_cancel (p1.th, &exchange_hello, me);
342 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
343 "Exchanging HELLO with peer (%p)!\n", cls);
344 GNUNET_assert (ok >= 2);
345 OKPP;
346 GNUNET_assert (message != NULL);
347 GNUNET_assert (GNUNET_OK ==
348 GNUNET_HELLO_get_id ((const struct GNUNET_HELLO_Message *)
349 message, &me->id));
350
351 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 370 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
352 "Received HELLO size %d\n", GNUNET_HELLO_size((const struct GNUNET_HELLO_Message *)message)); 371 "Asking peers to connect...\n");
353 372 GNUNET_TRANSPORT_try_connect (p2.th,
354 GNUNET_TRANSPORT_offer_hello (p2.th, message, NULL, NULL); 373 &p1.id);
355 GNUNET_TRANSPORT_get_hello (p2.th, &exchange_hello_last, &p2); 374 GNUNET_TRANSPORT_try_connect (p1.th,
375 &p2.id);
376 tct = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS,
377 &try_connect,
378 NULL);
356} 379}
357 380
358 381
@@ -373,7 +396,6 @@ run (void *cls,
373 } 396 }
374 if (is_unix) 397 if (is_unix)
375 { 398 {
376 GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Using unix domain socket transport\n");
377 setup_peer (&p1, "test_transport_api_unix_peer1.conf"); 399 setup_peer (&p1, "test_transport_api_unix_peer1.conf");
378 setup_peer (&p2, "test_transport_api_unix_peer2.conf"); 400 setup_peer (&p2, "test_transport_api_unix_peer2.conf");
379 } 401 }
@@ -416,6 +438,8 @@ run (void *cls,
416 GNUNET_assert(p2.th != NULL); 438 GNUNET_assert(p2.th != NULL);
417 439
418 GNUNET_TRANSPORT_get_hello (p1.th, &exchange_hello, &p1); 440 GNUNET_TRANSPORT_get_hello (p1.th, &exchange_hello, &p1);
441 GNUNET_TRANSPORT_get_hello (p2.th, &exchange_hello_last, &p2);
442 tct = GNUNET_SCHEDULER_add_now (&try_connect, NULL);
419} 443}
420 444
421static int 445static int
@@ -444,44 +468,52 @@ check ()
444 stop_arm (&p2); 468 stop_arm (&p2);
445 469
446 if (is_https) 470 if (is_https)
447 { 471 {
448 struct stat sbuf; 472 struct stat sbuf;
449 if (0 == stat (cert_file_p1, &sbuf )) 473 if (0 == stat (cert_file_p1, &sbuf ))
450 { 474 {
451 if (0 == remove(cert_file_p1)) 475 if (0 == remove(cert_file_p1))
452 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Successfully removed existing certificate file `%s'\n",cert_file_p1); 476 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
453 else 477 "Successfully removed existing certificate file `%s'\n",cert_file_p1);
454 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to remove certfile `%s'\n",cert_file_p1); 478 else
455 } 479 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
456 480 "Failed to remove certfile `%s'\n",cert_file_p1);
457 if (0 == stat (key_file_p1, &sbuf )) 481 }
458 { 482
459 if (0 == remove(key_file_p1)) 483 if (0 == stat (key_file_p1, &sbuf ))
460 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Successfully removed private key file `%s'\n",key_file_p1); 484 {
461 else 485 if (0 == remove(key_file_p1))
462 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to private key file `%s'\n",key_file_p1); 486 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
463 } 487 "Successfully removed private key file `%s'\n",key_file_p1);
464 488 else
465 if (0 == stat (cert_file_p2, &sbuf )) 489 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
466 { 490 "Failed to private key file `%s'\n",key_file_p1);
467 if (0 == remove(cert_file_p2)) 491 }
468 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Successfully removed existing certificate file `%s'\n",cert_file_p2); 492
469 else 493 if (0 == stat (cert_file_p2, &sbuf ))
470 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to remove certfile `%s'\n",cert_file_p2); 494 {
471 } 495 if (0 == remove(cert_file_p2))
472 496 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
473 if (0 == stat (key_file_p2, &sbuf )) 497 "Successfully removed existing certificate file `%s'\n",cert_file_p2);
474 { 498 else
475 if (0 == remove(key_file_p2)) 499 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
476 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Successfully removed private key file `%s'\n",key_file_p2); 500 "Failed to remove certfile `%s'\n",cert_file_p2);
477 else 501 }
478 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to private key file `%s'\n",key_file_p2); 502
479 } 503 if (0 == stat (key_file_p2, &sbuf ))
480 GNUNET_free(key_file_p1); 504 {
481 GNUNET_free(key_file_p2); 505 if (0 == remove(key_file_p2))
482 GNUNET_free(cert_file_p1); 506 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
483 GNUNET_free(cert_file_p2); 507 "Successfully removed private key file `%s'\n",key_file_p2);
484 } 508 else
509 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
510 "Failed to private key file `%s'\n",key_file_p2);
511 }
512 GNUNET_free(key_file_p1);
513 GNUNET_free(key_file_p2);
514 GNUNET_free(cert_file_p1);
515 GNUNET_free(cert_file_p2);
516 }
485 return ok; 517 return ok;
486} 518}
487 519