changes for wlan
[oweals/gnunet.git] / src / transport / test_transport_api.c
1 /*
2      This file is part of GNUnet.
3      (C) 2009, 2010 Christian Grothoff (and other contributing authors)
4
5      GNUnet is free software; you can redistribute it and/or modify
6      it under the terms of the GNU General Public License as published
7      by the Free Software Foundation; either version 3, or (at your
8      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      General Public License for more details.
14
15      You should have received a copy of the GNU General Public License
16      along with GNUnet; see the file COPYING.  If not, write to the
17      Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18      Boston, MA 02111-1307, USA.
19 */
20 /**
21  * @file transport/test_transport_api.c
22  * @brief base test case for transport implementations
23  *
24  * This test case serves as a base for tcp, udp, and udp-nat
25  * transport test cases.  Based on the executable being run
26  * the correct test case will be performed.  Conservation of
27  * C code apparently.
28  */
29 #include "platform.h"
30 #include "gnunet_common.h"
31 #include "gnunet_hello_lib.h"
32 #include "gnunet_getopt_lib.h"
33 #include "gnunet_os_lib.h"
34 #include "gnunet_program_lib.h"
35 #include "gnunet_scheduler_lib.h"
36 #include "gnunet_transport_service.h"
37 #include "transport.h"
38 #include "transport-testing.h"
39
40 #define VERBOSE GNUNET_YES
41
42 #define VERBOSE_ARM GNUNET_NO
43
44 #define START_ARM GNUNET_YES
45
46 /**
47  * How long until we give up on transmitting the message?
48  */
49 #define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 300)
50
51 /**
52  * How long until we give up on transmitting the message?
53  */
54 #define TIMEOUT_TRANSMIT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 60)
55
56 #define MTYPE 12345
57
58 static struct PeerContext p1;
59
60 static struct PeerContext p2;
61
62 static int ok;
63
64 static int is_tcp;
65
66 static int is_tcp_nat;
67
68 static int is_udp;
69
70 static int is_unix;
71
72 static int is_udp_nat;
73
74 static int is_http;
75
76 static int is_https;
77
78 static int is_multi_protocol;
79
80 static int is_wlan;
81
82 static  GNUNET_SCHEDULER_TaskIdentifier die_task;
83
84 static  GNUNET_SCHEDULER_TaskIdentifier tct;
85
86 static char * key_file_p1;
87 static char * cert_file_p1;
88
89 static char * key_file_p2;
90 static char * cert_file_p2;
91
92 #if VERBOSE
93 #define OKPP do { ok++; fprintf (stderr, "Now at stage %u at %s:%u\n", ok, __FILE__, __LINE__); } while (0)
94 #else
95 #define OKPP do { ok++; } while (0)
96 #endif
97
98
99 static void
100 end ()
101 {
102   GNUNET_assert (ok == 6);
103   GNUNET_SCHEDULER_cancel (die_task);
104   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
105               "Disconnecting from transports!\n");
106   GNUNET_TRANSPORT_disconnect (p1.th);
107   GNUNET_TRANSPORT_disconnect (p2.th);
108   die_task = GNUNET_SCHEDULER_NO_TASK;
109   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 
110               "Transports disconnected, returning success!\n");
111   ok = 0;
112 }
113
114 static void
115 stop_arm (struct PeerContext *p)
116 {
117 #if START_ARM
118   if (0 != GNUNET_OS_process_kill (p->arm_proc, SIGTERM))
119     GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill");
120   GNUNET_OS_process_wait (p->arm_proc);
121   GNUNET_OS_process_close (p->arm_proc);
122   p->arm_proc = NULL;
123 #endif
124   GNUNET_CONFIGURATION_destroy (p->cfg);
125 }
126
127
128 static void
129 end_badly ()
130 {
131   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Disconnecting from transports!\n");
132   GNUNET_break (0);
133   GNUNET_TRANSPORT_disconnect (p1.th);
134   GNUNET_TRANSPORT_disconnect (p2.th);
135   if (GNUNET_SCHEDULER_NO_TASK != tct)
136     {
137       GNUNET_SCHEDULER_cancel (tct);
138       tct = GNUNET_SCHEDULER_NO_TASK;
139     }
140   ok = 1;
141 }
142
143
144 static void
145 notify_receive (void *cls,
146                 const struct GNUNET_PeerIdentity *peer,
147                 const struct GNUNET_MessageHeader *message,
148                 const struct GNUNET_TRANSPORT_ATS_Information *ats,
149                 uint32_t ats_count)
150 {
151   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 
152               "Received message of type %d from peer %s!\n",
153               ntohs(message->type), 
154               GNUNET_i2s (peer));
155   GNUNET_assert (ok == 5);
156   OKPP;
157   GNUNET_assert (MTYPE == ntohs (message->type));
158   GNUNET_assert (sizeof (struct GNUNET_MessageHeader) ==
159                  ntohs (message->size));
160   end ();
161 }
162
163
164 static size_t
165 notify_ready (void *cls, size_t size, void *buf)
166 {
167   struct PeerContext *p = cls;
168   struct GNUNET_MessageHeader *hdr;
169
170   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
171               "Transmitting message with %u bytes to peer %s\n", 
172               sizeof (struct GNUNET_MessageHeader),
173               GNUNET_i2s (&p->id));
174   GNUNET_assert (size >= 256);
175   GNUNET_assert (ok == 4);
176   OKPP;
177   if (buf != NULL)
178   {
179     hdr = buf;
180     hdr->size = htons (sizeof (struct GNUNET_MessageHeader));
181     hdr->type = htons (MTYPE);
182   }
183   return sizeof (struct GNUNET_MessageHeader);
184 }
185
186
187 static void
188 exchange_hello_last (void *cls,
189                      const struct GNUNET_MessageHeader *message)
190 {
191   struct PeerContext *me = cls;
192
193   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
194               "Exchanging HELLO of size %d with peer (%s)!\n", 
195               (int) GNUNET_HELLO_size((const struct GNUNET_HELLO_Message *)message),
196               GNUNET_i2s (&me->id));
197   GNUNET_assert (message != NULL);
198   GNUNET_assert (GNUNET_OK ==
199                  GNUNET_HELLO_get_id ((const struct GNUNET_HELLO_Message *)
200                                       message, &me->id));
201   GNUNET_TRANSPORT_offer_hello (p1.th, message, NULL, NULL);
202 }
203
204
205
206 static void
207 exchange_hello (void *cls,
208                 const struct GNUNET_MessageHeader *message)
209 {
210   struct PeerContext *me = cls;
211
212   GNUNET_assert (message != NULL);
213   GNUNET_assert (GNUNET_OK ==
214                  GNUNET_HELLO_get_id ((const struct GNUNET_HELLO_Message *)
215                                       message, &me->id));
216   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
217               "Exchanging HELLO of size %d from peer %s!\n", 
218               (int) GNUNET_HELLO_size((const struct GNUNET_HELLO_Message *)message),
219               GNUNET_i2s (&me->id));
220   GNUNET_TRANSPORT_offer_hello (p2.th, message, NULL, NULL);
221 }
222
223
224
225 static void
226 notify_connect (void *cls,
227                 const struct GNUNET_PeerIdentity *peer,
228                 const struct GNUNET_TRANSPORT_ATS_Information *ats,
229                 uint32_t ats_count)
230 {
231   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
232               "Peer `%4s' connected to us (%p)!\n", 
233               GNUNET_i2s (peer), 
234               cls);
235   if (cls == &p1)
236     {
237       GNUNET_assert (ok >= 2);
238       OKPP;
239       OKPP;
240       GNUNET_SCHEDULER_cancel (die_task);
241       GNUNET_SCHEDULER_cancel (tct);
242       tct = GNUNET_SCHEDULER_NO_TASK;
243       GNUNET_TRANSPORT_get_hello_cancel (p2.th, &exchange_hello_last, &p2);
244       GNUNET_TRANSPORT_get_hello_cancel (p1.th, &exchange_hello, &p1);
245       die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT_TRANSMIT,
246                                                &end_badly, NULL);
247       GNUNET_TRANSPORT_notify_transmit_ready (p1.th,
248                                               &p2.id,
249                                               256, 0, TIMEOUT, &notify_ready,
250                                               &p1);
251     }
252 }
253
254
255 static void
256 notify_disconnect (void *cls,
257                    const struct GNUNET_PeerIdentity *peer)
258 {
259   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
260               "Peer `%4s' disconnected (%p)!\n",
261               GNUNET_i2s (peer), cls);
262 }
263
264
265 static void
266 setup_peer (struct PeerContext *p, 
267             const char *cfgname)
268 {
269   p->cfg = GNUNET_CONFIGURATION_create ();
270
271   GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname));
272   if (GNUNET_CONFIGURATION_have_value (p->cfg,"PATHS", "SERVICEHOME"))
273       GNUNET_CONFIGURATION_get_value_string (p->cfg, "PATHS", "SERVICEHOME", &p->servicehome);
274   GNUNET_DISK_directory_remove (p->servicehome);
275
276 #if START_ARM
277   p->arm_proc = GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm",
278                                         "gnunet-service-arm",
279 #if VERBOSE_ARM
280                                         "-L", "DEBUG",
281 #endif
282                                         "-c", cfgname, NULL);
283 #endif
284
285
286   if (GNUNET_CONFIGURATION_have_value (p->cfg,"PATHS", "SERVICEHOME"))
287       GNUNET_CONFIGURATION_get_value_string (p->cfg, "PATHS", "SERVICEHOME", &p->servicehome);
288
289   if (is_https)
290     {
291       struct stat sbuf;
292       if (p==&p1)
293         {
294           if (GNUNET_CONFIGURATION_have_value (p->cfg,
295                                                "transport-https", "KEY_FILE"))
296             GNUNET_CONFIGURATION_get_value_string (p->cfg, "transport-https", "KEY_FILE", &key_file_p1);
297           if (key_file_p1==NULL)
298             GNUNET_asprintf(&key_file_p1,"https.key");
299           if (0 == stat (key_file_p1, &sbuf ))
300             {
301               if (0 == remove(key_file_p1))
302                 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 
303                             "Successfully removed existing private key file `%s'\n",key_file_p1);
304               else
305                 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 
306                             "Failed to remove private key file `%s'\n",key_file_p1);
307             }
308           if (GNUNET_CONFIGURATION_have_value (p->cfg,"transport-https", "CERT_FILE"))
309             GNUNET_CONFIGURATION_get_value_string (p->cfg, "transport-https", "CERT_FILE", &cert_file_p1);
310           if (cert_file_p1==NULL)
311             GNUNET_asprintf(&cert_file_p1,"https.cert");
312           if (0 == stat (cert_file_p1, &sbuf ))
313             {
314               if (0 == remove(cert_file_p1))
315                 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
316                             "Successfully removed existing certificate file `%s'\n",
317                             cert_file_p1);
318               else
319                 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
320                             "Failed to remove existing certificate file `%s'\n",
321                             cert_file_p1);
322             }
323         }
324       else if (p==&p2)
325         {
326           if (GNUNET_CONFIGURATION_have_value (p->cfg,
327                                                "transport-https", "KEY_FILE"))
328             GNUNET_CONFIGURATION_get_value_string (p->cfg, "transport-https", "KEY_FILE", &key_file_p2);
329           if (key_file_p2==NULL)
330             GNUNET_asprintf(&key_file_p2,"https.key");
331           if (0 == stat (key_file_p2, &sbuf ))
332             {
333               if (0 == remove(key_file_p2))
334                 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 
335                             "Successfully removed existing private key file `%s'\n",
336                             key_file_p2);
337               else
338                 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 
339                             "Failed to remove private key file `%s'\n",
340                             key_file_p2);
341             }
342           if (GNUNET_CONFIGURATION_have_value (p->cfg,"transport-https", "CERT_FILE"))
343             GNUNET_CONFIGURATION_get_value_string (p->cfg, "transport-https", "CERT_FILE", &cert_file_p2);
344           if (cert_file_p2==NULL)
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   
358   p->th = GNUNET_TRANSPORT_connect (p->cfg,
359                                     NULL, p,
360                                     &notify_receive,
361                                     &notify_connect, &notify_disconnect);
362   GNUNET_assert (p->th != NULL);
363 }
364
365
366 static void
367 try_connect (void *cls,
368              const struct GNUNET_SCHEDULER_TaskContext *tc)
369 {
370   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
371               "Asking peers to connect...\n");
372   GNUNET_TRANSPORT_try_connect (p2.th,
373                                 &p1.id);
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);
379 }
380
381
382 static void
383 run (void *cls,
384      char *const *args,
385      const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg)
386 {
387   GNUNET_assert (ok == 1);
388   OKPP;
389   die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT,
390                                            &end_badly, NULL);
391
392   if (is_udp)
393     {
394       setup_peer (&p1, "test_transport_api_udp_peer1.conf");
395       setup_peer (&p2, "test_transport_api_udp_peer2.conf");
396     }
397   if (is_unix)
398     {
399       setup_peer (&p1, "test_transport_api_unix_peer1.conf");
400       setup_peer (&p2, "test_transport_api_unix_peer2.conf");
401     }
402   if (is_multi_protocol)
403     {
404       setup_peer (&p1, "test_transport_api_multi_peer1.conf");
405       setup_peer (&p2, "test_transport_api_multi_peer2.conf");
406     }
407   else if (is_tcp)
408     {
409       setup_peer (&p1, "test_transport_api_tcp_peer1.conf");
410       setup_peer (&p2, "test_transport_api_tcp_peer2.conf");
411     }
412   else if (is_tcp_nat)
413     {
414       setup_peer (&p1, "test_transport_api_tcp_nat_peer1.conf");
415       setup_peer (&p2, "test_transport_api_tcp_nat_peer2.conf");
416     }
417   else if (is_udp_nat)
418     {
419       setup_peer (&p1, "test_transport_api_udp_nat_peer1.conf");
420       setup_peer (&p2, "test_transport_api_udp_nat_peer2.conf");
421     }
422   else if (is_http)
423     {
424       setup_peer (&p1, "test_transport_api_http_peer1.conf");
425       setup_peer (&p2, "test_transport_api_http_peer2.conf");
426     }
427   else if (is_https)
428     {
429       setup_peer (&p1, "test_transport_api_https_peer1.conf");
430       setup_peer (&p2, "test_transport_api_https_peer2.conf");
431     }
432   else if (is_wlan)
433     {
434       setup_peer (&p1, "test_transport_api_wlan_peer1.conf");
435       setup_peer (&p2, "test_transport_api_wlan_peer2.conf");
436     }
437   GNUNET_assert(p1.th != NULL);
438   GNUNET_assert(p2.th != NULL);
439
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);
443 }
444
445 static int
446 check ()
447 {
448   static char *const argv[] = { "test-transport-api",
449     "-c",
450     "test_transport_api_data.conf",
451 #if VERBOSE
452     "-L", "DEBUG",
453 #endif
454     NULL
455   };
456   static struct GNUNET_GETOPT_CommandLineOption options[] = {
457     GNUNET_GETOPT_OPTION_END
458   };
459
460 #if WRITECONFIG
461   setTransportOptions("test_transport_api_data.conf");
462 #endif
463   ok = 1;
464   GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1,
465                       argv, "test-transport-api", "nohelp",
466                       options, &run, &ok);
467   stop_arm (&p1);
468   stop_arm (&p2);
469
470   if (is_https)
471     {
472       struct stat sbuf;
473       if (0 == stat (cert_file_p1, &sbuf ))
474         {
475           if (0 == remove(cert_file_p1))
476             GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 
477                         "Successfully removed existing certificate file `%s'\n",cert_file_p1);
478           else
479             GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 
480                         "Failed to remove certfile `%s'\n",cert_file_p1);
481         }
482       
483       if (0 == stat (key_file_p1, &sbuf ))
484         {
485           if (0 == remove(key_file_p1))
486             GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 
487                         "Successfully removed private key file `%s'\n",key_file_p1);
488           else
489             GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 
490                         "Failed to private key file `%s'\n",key_file_p1);
491         }
492       
493       if (0 == stat (cert_file_p2, &sbuf ))
494         {
495           if (0 == remove(cert_file_p2))
496             GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
497                         "Successfully removed existing certificate file `%s'\n",cert_file_p2);
498           else
499             GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
500                         "Failed to remove certfile `%s'\n",cert_file_p2);
501         }
502       
503       if (0 == stat (key_file_p2, &sbuf ))
504         {
505           if (0 == remove(key_file_p2))
506             GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
507                         "Successfully removed private key file `%s'\n",key_file_p2);
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     }
517
518   if ((p1.servicehome != NULL) && (p2.servicehome != NULL))
519   {
520     GNUNET_DISK_directory_remove (p1.servicehome);
521     GNUNET_DISK_directory_remove (p2.servicehome);
522     GNUNET_free(p1.servicehome);
523     GNUNET_free(p2.servicehome);
524   }
525   return ok;
526 }
527
528 /**
529  * Return the actual path to a file found in the current
530  * PATH environment variable.
531  *
532  * @param binary the name of the file to find
533  */
534 static char *
535 get_path_from_PATH (char *binary)
536 {
537   char *path;
538   char *pos;
539   char *end;
540   char *buf;
541   const char *p;
542
543   p = getenv ("PATH");
544   if (p == NULL)
545     {
546       GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
547                   _("PATH environment variable is unset.\n"));
548       return NULL;
549     }
550   path = GNUNET_strdup (p);     /* because we write on it */
551   buf = GNUNET_malloc (strlen (path) + 20);
552   pos = path;
553
554   while (NULL != (end = strchr (pos, PATH_SEPARATOR)))
555     {
556       *end = '\0';
557       sprintf (buf, "%s/%s", pos, binary);
558       if (GNUNET_DISK_file_test (buf) == GNUNET_YES)
559         {
560           GNUNET_free (path);
561           return buf;
562         }
563       pos = end + 1;
564     }
565   sprintf (buf, "%s/%s", pos, binary);
566   if (GNUNET_DISK_file_test (buf) == GNUNET_YES)
567     {
568       GNUNET_free (path);
569       return buf;
570     }
571   GNUNET_free (buf);
572   GNUNET_free (path);
573   return NULL;
574 }
575
576 /**
577  * Check whether the suid bit is set on a file.
578  * Attempts to find the file using the current
579  * PATH environment variable as a search path.
580  *
581  * @param binary the name of the file to check
582  *
583  * @return GNUNET_YES if the binary is found and
584  *         can be run properly, GNUNET_NO otherwise
585  */
586 static int
587 check_gnunet_nat_binary(char *binary)
588 {
589   struct stat statbuf;
590   char *p;
591 #ifdef MINGW
592   SOCKET rawsock;
593 #endif
594
595 #ifdef MINGW
596   char *binaryexe;
597   GNUNET_asprintf (&binaryexe, "%s.exe", binary);
598   p = get_path_from_PATH (binaryexe);
599   free (binaryexe);
600 #else
601   p = get_path_from_PATH (binary);
602 #endif
603   if (p == NULL)
604     {
605       GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
606                   _("Could not find binary `%s' in PATH!\n"),
607                   binary);
608       return GNUNET_NO;
609     }
610   if (0 != STAT (p, &statbuf))
611     {
612       GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
613                   _("stat (%s) failed: %s\n"),
614                   p,
615                   STRERROR (errno));
616       GNUNET_free (p);
617       return GNUNET_SYSERR;
618     }
619   GNUNET_free (p);
620 #ifndef MINGW
621   if ( (0 != (statbuf.st_mode & S_ISUID)) &&
622        (statbuf.st_uid == 0) )
623     return GNUNET_YES;
624   return GNUNET_NO;
625 #else
626   rawsock = socket (AF_INET, SOCK_RAW, IPPROTO_ICMP);
627   if (INVALID_SOCKET == rawsock)
628     {
629       DWORD err = GetLastError ();
630       GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
631                   "socket (AF_INET, SOCK_RAW, IPPROTO_ICMP) have failed! GLE = %d\n", err);
632       return GNUNET_NO; /* not running as administrator */
633     }
634   closesocket (rawsock);
635   return GNUNET_YES;
636 #endif
637 }
638
639 int
640 main (int argc, char *argv[])
641 {
642   int ret;
643 #ifdef MINGW
644   return GNUNET_SYSERR;
645 #endif
646
647   GNUNET_log_setup ("test-transport-api",
648 #if VERBOSE
649                     "DEBUG",
650 #else
651                     "WARNING",
652 #endif
653                     NULL);
654
655   if (strstr(argv[0], "tcp_nat") != NULL)
656     {
657       is_tcp_nat = GNUNET_YES;
658       if (GNUNET_YES != check_gnunet_nat_binary("gnunet-nat-server"))
659         {
660           GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
661                       "`%s' not properly installed, cannot run NAT test!\n",
662                       "gnunet-nat-server");
663           return 0;
664         }
665     }
666   else if (strstr(argv[0], "tcp") != NULL)
667     {
668       is_tcp = GNUNET_YES;
669     }
670   else if (strstr(argv[0], "udp_nat") != NULL)
671     {
672       is_udp_nat = GNUNET_YES;
673       if (GNUNET_YES != check_gnunet_nat_binary("gnunet-nat-server"))
674         {
675           GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
676                       "`%s' not properly installed, cannot run NAT test!\n",
677                       "gnunet-nat-server");
678           return 0;
679         }      GNUNET_free(p1.servicehome);
680         GNUNET_free(p2.servicehome);
681     }
682   else if (strstr(argv[0], "udp") != NULL)
683     {
684       is_udp = GNUNET_YES;
685     }
686   else if (strstr(argv[0], "unix") != NULL)
687     {
688       is_unix = GNUNET_YES;
689     }
690   else if (strstr(argv[0], "https") != NULL)
691     {
692       is_https = GNUNET_YES;
693     }
694   else if (strstr(argv[0], "http") != NULL)
695     {
696       is_http = GNUNET_YES;
697     }
698   else if (strstr(argv[0], "wlan") != NULL)
699     {
700        is_wlan = GNUNET_YES;
701     }
702   else if (strstr(argv[0], "multi") != NULL)
703     {
704        is_multi_protocol = GNUNET_YES;
705     }
706
707   ret = check ();
708
709   return ret;
710 }
711
712 /* end of test_transport_api.c */