- re-added testcase for crypto-paillier
[oweals/gnunet.git] / src / mesh / gnunet-mesh.c
1 /*
2      This file is part of GNUnet.
3      (C) 2012 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 /**
22  * @file mesh/gnunet-mesh.c
23  * @brief Print information about mesh tunnels and peers.
24  * @author Bartlomiej Polot
25  */
26 #include "platform.h"
27 #include "gnunet_util_lib.h"
28 #include "gnunet_mesh_service.h"
29
30
31 /**
32  * Option -m.
33  */
34 static int monitor_connections;
35
36 /**
37  * Option -P.
38  */
39 static int request_peers;
40
41 /**
42  * Option -T.
43  */
44 static int request_tunnels;
45
46 /**
47  * Option --tunnel
48  */
49 static char *tunnel_id;
50
51 /**
52  * Option --connection
53  */
54 static char *conn_id;
55
56 /**
57  * Option --channel
58  */
59 static char *channel_id;
60
61 /**
62  * Port to listen on (-p).
63  */
64 static uint32_t listen_port;
65
66 /**
67  * Request echo service
68  */
69 int echo;
70
71 /**
72  * Time of last echo request.
73  */
74 struct GNUNET_TIME_Absolute echo_time;
75
76 /**
77  * Task for next echo request.
78  */
79 GNUNET_SCHEDULER_TaskIdentifier echo_task;
80
81 /**
82  * Peer to connect to.
83  */
84 static char *target_id;
85
86 /**
87  * Port to connect to
88  */
89 static uint32_t target_port;
90
91 /**
92  * Data pending in netcat mode.
93  */
94 size_t data_size;
95
96
97 /**
98  * Mesh handle.
99  */
100 static struct GNUNET_MESH_Handle *mh;
101
102 /**
103  * Channel handle.
104  */
105 static struct GNUNET_MESH_Channel *ch;
106
107 /**
108  * Shutdown task handle.
109  */
110 GNUNET_SCHEDULER_TaskIdentifier sd;
111
112
113
114 static void
115 listen_stdio (void);
116
117
118
119 /**
120  * Task run in monitor mode when the user presses CTRL-C to abort.
121  * Stops monitoring activity.
122  *
123  * @param cls Closure (unused).
124  * @param tc scheduler context
125  */
126 static void
127 shutdown_task (void *cls,
128                const struct GNUNET_SCHEDULER_TaskContext *tc)
129 {
130   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Shutdown\n");
131   if (NULL != ch)
132   {
133     GNUNET_MESH_channel_destroy (ch);
134     ch = NULL;
135   }
136   if (NULL != mh)
137   {
138     GNUNET_MESH_disconnect (mh);
139         mh = NULL;
140   }
141 }
142
143
144 /**
145  * Function called to notify a client about the connection
146  * begin ready to queue more data.  "buf" will be
147  * NULL and "size" zero if the connection was closed for
148  * writing in the meantime.
149  *
150  * FIXME
151  *
152  * @param cls closure
153  * @param size number of bytes available in buf
154  * @param buf where the callee should write the message
155  * @return number of bytes written to buf
156  */
157 size_t
158 data_ready (void *cls, size_t size, void *buf)
159 {
160   struct GNUNET_MessageHeader *msg;
161   size_t total_size;
162
163   if (NULL == buf || 0 == size)
164   {
165     GNUNET_SCHEDULER_shutdown();
166     return 0;
167   }
168
169   total_size = data_size + sizeof (struct GNUNET_MessageHeader);
170   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "sending %u bytes\n", data_size);
171   GNUNET_assert (size >= total_size);
172
173   msg = buf;
174   msg->size = htons (total_size);
175   msg->type = htons (GNUNET_MESSAGE_TYPE_MESH_CLI);
176   memcpy (&msg[1], cls, data_size);
177   if (GNUNET_NO == echo)
178   {
179     listen_stdio ();
180   }
181   else
182   {
183     echo_time = GNUNET_TIME_absolute_get ();
184   }
185
186   return total_size;
187 }
188
189
190 /**
191  * Task run in monitor mode when the user presses CTRL-C to abort.
192  * Stops monitoring activity.
193  *
194  * @param cls Closure (unused).
195  * @param tc scheduler context
196  */
197 static void
198 read_stdio (void *cls,
199             const struct GNUNET_SCHEDULER_TaskContext *tc)
200 {
201   static char buf[60000];
202
203   if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN))
204   {
205     return;
206   }
207
208   data_size = read (0, buf, 60000);
209   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "stdio read %u bytes\n", data_size);
210   if (data_size < 1)
211   {
212     GNUNET_SCHEDULER_shutdown();
213     return;
214   }
215   GNUNET_MESH_notify_transmit_ready (ch, GNUNET_NO,
216                                      GNUNET_TIME_UNIT_FOREVER_REL,
217                                      data_size
218                                      + sizeof (struct GNUNET_MessageHeader),
219                                      &data_ready, buf);
220 }
221
222
223 /**
224  * Start listening to stdin
225  */
226 static void
227 listen_stdio (void)
228 {
229   struct GNUNET_NETWORK_FDSet *rs;
230
231   rs = GNUNET_NETWORK_fdset_create ();
232   GNUNET_NETWORK_fdset_set_native (rs, 0);
233   GNUNET_SCHEDULER_add_select (GNUNET_SCHEDULER_PRIORITY_DEFAULT,
234                                GNUNET_TIME_UNIT_FOREVER_REL,
235                                rs, NULL,
236                                &read_stdio, NULL);
237   GNUNET_NETWORK_fdset_destroy (rs);
238 }
239
240
241 /**
242  * Function called whenever a channel is destroyed.  Should clean up
243  * any associated state.
244  *
245  * It must NOT call #GNUNET_MESH_channel_destroy on the channel.
246  *
247  * @param cls closure (set from #GNUNET_MESH_connect)
248  * @param channel connection to the other end (henceforth invalid)
249  * @param channel_ctx place where local state associated
250  *                   with the channel is stored
251  */
252 static void
253 channel_ended (void *cls,
254                const struct GNUNET_MESH_Channel *channel,
255                void *channel_ctx)
256 {
257   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Channel ended!\n");
258   GNUNET_break (channel == ch);
259   ch = NULL;
260   GNUNET_SCHEDULER_shutdown ();
261 }
262
263
264 /**
265  * Method called whenever another peer has added us to a channel
266  * the other peer initiated.
267  * Only called (once) upon reception of data with a message type which was
268  * subscribed to in #GNUNET_MESH_connect.
269  *
270  * A call to #GNUNET_MESH_channel_destroy causes te channel to be ignored. In
271  * this case the handler MUST return NULL.
272  *
273  * @param cls closure
274  * @param channel new handle to the channel
275  * @param initiator peer that started the channel
276  * @param port Port this channel is for.
277  * @param options MeshOption flag field, with all active option bits set to 1.
278  *
279  * @return initial channel context for the channel
280  *         (can be NULL -- that's not an error)
281  */
282 static void *
283 channel_incoming (void *cls,
284                   struct GNUNET_MESH_Channel * channel,
285                   const struct GNUNET_PeerIdentity * initiator,
286                   uint32_t port, enum GNUNET_MESH_ChannelOption options)
287 {
288   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
289               "Incoming channel %p on port %u\n",
290               channel, port);
291   if (NULL != ch)
292   {
293     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "A channel already exists\n");
294     return NULL;
295   }
296   if (0 == listen_port)
297   {
298     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Not listening to channels\n");
299     return NULL;
300   }
301   ch = channel;
302   if (GNUNET_NO == echo)
303   {
304     listen_stdio ();
305     return NULL;
306   }
307   data_size = 0;
308   return NULL;
309 }
310
311 /**
312  * @brief Send an echo request to the remote peer.
313  *
314  * @param cls Closure (NULL).
315  * @param tc Task context.
316  */
317 static void
318 send_echo (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
319 {
320   GNUNET_MESH_notify_transmit_ready (ch, GNUNET_NO,
321                                      GNUNET_TIME_UNIT_FOREVER_REL,
322                                      sizeof (struct GNUNET_MessageHeader),
323                                      &data_ready, NULL);
324 }
325
326
327
328 /**
329  * Call MESH's monitor API, get info of one connection.
330  *
331  * @param cls Closure (unused).
332  * @param tc TaskContext
333  */
334 static void
335 create_channel (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
336 {
337   struct GNUNET_PeerIdentity pid;
338   enum GNUNET_MESH_ChannelOption opt;
339
340   GNUNET_assert (NULL == ch);
341
342   if (GNUNET_OK !=
343       GNUNET_CRYPTO_eddsa_public_key_from_string (target_id,
344                                                   strlen (target_id),
345                                                   &pid.public_key))
346   {
347     FPRINTF (stderr,
348              _("Invalid target `%s'\n"),
349              target_id);
350     GNUNET_SCHEDULER_shutdown ();
351     return;
352   }
353   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Connecting to `%s'\n", target_id);
354   opt = GNUNET_MESH_OPTION_DEFAULT | GNUNET_MESH_OPTION_RELIABLE;
355   ch = GNUNET_MESH_channel_create (mh, NULL, &pid, target_port, opt);
356   if (GNUNET_NO == echo)
357     listen_stdio ();
358   else
359     GNUNET_SCHEDULER_add_now (send_echo, NULL);
360 }
361
362
363 /**
364  * Function called whenever a message is received.
365  *
366  * Each time the function must call #GNUNET_MESH_receive_done on the channel
367  * in order to receive the next message. This doesn't need to be immediate:
368  * can be delayed if some processing is done on the message.
369  *
370  * @param cls Closure (set from #GNUNET_MESH_connect).
371  * @param channel Connection to the other end.
372  * @param channel_ctx Place to store local state associated with the channel.
373  * @param message The actual message.
374  * @return #GNUNET_OK to keep the channel open,
375  *         #GNUNET_SYSERR to close it (signal serious error).
376  */
377 static int
378 data_callback (void *cls,
379                struct GNUNET_MESH_Channel *channel,
380                void **channel_ctx,
381                const struct GNUNET_MessageHeader *message)
382 {
383   uint16_t len;
384   ssize_t done;
385   uint16_t off;
386   const char *buf;
387   GNUNET_break (ch == channel);
388
389   if (GNUNET_YES == echo)
390   {
391     if (0 != listen_port)
392     {
393       /* Just listening to echo incoming messages*/
394       GNUNET_MESH_notify_transmit_ready (channel, GNUNET_NO,
395                                         GNUNET_TIME_UNIT_FOREVER_REL,
396                                         sizeof (struct GNUNET_MessageHeader),
397                                         &data_ready, NULL);
398       return GNUNET_OK;
399     }
400     else
401     {
402       struct GNUNET_TIME_Relative latency;
403
404       latency = GNUNET_TIME_absolute_get_duration (echo_time);
405       echo_time = GNUNET_TIME_UNIT_FOREVER_ABS;
406       FPRINTF (stdout, "time: %s\n",
407                GNUNET_STRINGS_relative_time_to_string (latency, GNUNET_NO));
408       echo_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS,
409                                                 &send_echo, NULL);
410     }
411   }
412
413   len = ntohs (message->size) - sizeof (*message);
414   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Got %u bytes\n", len);
415   buf = (const char *) &message[1];
416   off = 0;
417   while (off < len)
418   {
419     done = write (1, &buf[off], len - off);
420     if (done <= 0)
421     {
422       if (-1 == done)
423         GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING,
424                              "write");
425       return GNUNET_SYSERR;
426     }
427     off += done;
428   }
429   return GNUNET_OK;
430 }
431
432
433 /**
434  * Method called to retrieve information about all peers in MESH, called
435  * once per peer.
436  *
437  * After last peer has been reported, an additional call with NULL is done.
438  *
439  * @param cls Closure.
440  * @param peer Peer, or NULL on "EOF".
441  * @param tunnel Do we have a tunnel towards this peer?
442  * @param best_path How long is the best path?
443  *                  (0 = unknown, 1 = ourselves, 2 = neighbor)
444  */
445 static void
446 peers_callback (void *cls, const struct GNUNET_PeerIdentity *peer,
447                 int tunnel, unsigned int best_path)
448 {
449   if (NULL == peer)
450   {
451     if (GNUNET_YES != monitor_connections)
452     {
453       GNUNET_SCHEDULER_shutdown();
454     }
455     return;
456   }
457   FPRINTF (stdout, "%s tunnel: %c, best path %u hops]\n",
458            GNUNET_i2s_full (peer), tunnel ? 'Y' : 'N', best_path);
459 }
460
461
462 /**
463  * Method called to retrieve information about all tunnels in MESH.
464  *
465  * @param cls Closure.
466  * @param peer Destination peer.
467  * @param channels Number of channels.
468  * @param connections Number of connections.
469  * @param estate Encryption state.
470  * @param cstate Connectivity state.
471  */
472 void
473 tunnels_callback (void *cls,
474                   const struct GNUNET_PeerIdentity *peer,
475                   unsigned int channels,
476                   unsigned int connections,
477                   uint16_t estate,
478                   uint16_t cstate)
479 {
480   if (NULL == peer)
481   {
482     if (GNUNET_YES != monitor_connections)
483     {
484       GNUNET_SCHEDULER_shutdown();
485     }
486     return;
487   }
488   FPRINTF (stdout, "%s [ENC: %u, CON: %u] CHs: %u, CONNs: %u\n",
489            GNUNET_i2s_full (peer), estate, cstate, channels, connections);
490 }
491
492
493 /**
494  * Method called to retrieve information about a specific tunnel the mesh peer
495  * has established, o`r is trying to establish.
496  *
497  * @param cls Closure.
498  * @param peer Peer towards whom the tunnel is directed.
499  * @param channels Number of channels.
500  * @param connections Number of connections.
501  * @param estate Encryption status.
502  * @param cstate Connectivity status.
503  */
504 void
505 tunnel_callback (void *cls,
506                  const struct GNUNET_PeerIdentity *peer,
507                  unsigned int channels,
508                  unsigned int connections,
509                  unsigned int estate,
510                  unsigned int cstate)
511 {
512   FPRINTF (stdout, "Tunnel %s\n", GNUNET_i2s_full (peer));
513   FPRINTF (stdout, "- %u channels\n", channels);
514   FPRINTF (stdout, "- %u connections\n", connections);
515   FPRINTF (stdout, "- enc state: %u\n", estate);
516   FPRINTF (stdout, "- con state: %u\n", cstate);
517 }
518
519
520 /**
521  * Call MESH's meta API, get all peers known to a peer.
522  *
523  * @param cls Closure (unused).
524  * @param tc TaskContext
525  */
526 static void
527 get_peers (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
528 {
529   if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN))
530   {
531     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Shutdown\n");
532     return;
533   }
534   GNUNET_MESH_get_peers (mh, &peers_callback, NULL);
535 }
536
537 /**
538  * Call MESH's meta API, get all tunnels known to a peer.
539  *
540  * @param cls Closure (unused).
541  * @param tc TaskContext
542  */
543 static void
544 get_tunnels (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
545 {
546   if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN))
547   {
548     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Shutdown\n");
549     return;
550   }
551   GNUNET_MESH_get_tunnels (mh, &tunnels_callback, NULL);
552 }
553
554
555 /**
556  * Call MESH's monitor API, get info of one tunnel.
557  *
558  * @param cls Closure (unused).
559  * @param tc TaskContext
560  */
561 static void
562 show_tunnel (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
563 {
564   struct GNUNET_PeerIdentity pid;
565
566   if (GNUNET_OK !=
567       GNUNET_CRYPTO_eddsa_public_key_from_string (tunnel_id,
568                                                   strlen (tunnel_id),
569                                                   &pid.public_key))
570   {
571     fprintf (stderr,
572              _("Invalid tunnel owner `%s'\n"),
573              tunnel_id);
574     GNUNET_SCHEDULER_shutdown();
575     return;
576   }
577   GNUNET_MESH_get_tunnel (mh, &pid, tunnel_callback, NULL);
578 }
579
580
581 /**
582  * Call MESH's monitor API, get info of one channel.
583  *
584  * @param cls Closure (unused).
585  * @param tc TaskContext
586  */
587 static void
588 show_channel (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
589 {
590
591 }
592
593
594 /**
595  * Call MESH's monitor API, get info of one connection.
596  *
597  * @param cls Closure (unused).
598  * @param tc TaskContext
599  */
600 static void
601 show_connection (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
602 {
603
604 }
605
606
607 /**
608  * Main function that will be run by the scheduler.
609  *
610  * @param cls closure
611  * @param args remaining command-line arguments
612  * @param cfgfile name of the configuration file used (for saving, can be NULL!)
613  * @param cfg configuration
614  */
615 static void
616 run (void *cls, char *const *args, const char *cfgfile,
617      const struct GNUNET_CONFIGURATION_Handle *cfg)
618 {
619   GNUNET_MESH_InboundChannelNotificationHandler *newch = NULL;
620   GNUNET_MESH_ChannelEndHandler *endch = NULL;
621   static const struct GNUNET_MESH_MessageHandler handlers[] = {
622     {&data_callback, GNUNET_MESSAGE_TYPE_MESH_CLI, 0},
623     {NULL, 0, 0} /* FIXME add option to monitor msg types */
624   };
625   static uint32_t *ports = NULL;
626   /* FIXME add option to monitor apps */
627
628   target_id = args[0];
629   target_port = args[0] && args[1] ? atoi(args[1]) : 0;
630   if ( (0 != (request_peers | request_tunnels)
631         || 0 != monitor_connections
632         || NULL != tunnel_id
633         || NULL != conn_id
634         || NULL != channel_id)
635        && target_id != NULL)
636   {
637     FPRINTF (stderr,
638              _("You must NOT give a TARGET"
639                "when using 'request all' options\n"));
640     return;
641   }
642
643   if (NULL != target_id)
644   {
645     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
646                 "Creating channel to %s\n",
647                 target_id);
648     GNUNET_SCHEDULER_add_now (&create_channel, NULL);
649     endch = &channel_ended;
650   }
651   else if (0 != listen_port)
652   {
653     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Listen\n");
654     newch = &channel_incoming;
655     endch = &channel_ended;
656     ports = GNUNET_malloc (sizeof (uint32_t) * 2);
657     ports[0] = listen_port;
658   }
659   else if (NULL != tunnel_id)
660   {
661     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Show tunnel\n");
662     GNUNET_SCHEDULER_add_now (&show_tunnel, NULL);
663   }
664   else if (NULL != channel_id)
665   {
666     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Show channel\n");
667     GNUNET_SCHEDULER_add_now (&show_channel, NULL);
668   }
669   else if (NULL != conn_id)
670   {
671     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Show connection\n");
672     GNUNET_SCHEDULER_add_now (&show_connection, NULL);
673   }
674   else if (GNUNET_YES == request_peers)
675   {
676     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Show all peers\n");
677     GNUNET_SCHEDULER_add_now (&get_peers, NULL);
678   }
679   else if (GNUNET_YES == request_tunnels)
680   {
681     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Show all tunnels\n");
682     GNUNET_SCHEDULER_add_now (&get_tunnels, NULL);
683   }
684   else
685   {
686     FPRINTF (stderr, "No action requested\n");
687     return;
688   }
689
690   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Connecting to mesh\n");
691   mh = GNUNET_MESH_connect (cfg,
692                             NULL, /* cls */
693                             newch, /* new channel */
694                             endch, /* cleaner */
695                             handlers,
696                             ports);
697   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Done\n");
698   if (NULL == mh)
699     GNUNET_SCHEDULER_add_now (shutdown_task, NULL);
700   else
701     sd = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL,
702                                        shutdown_task, NULL);
703
704 }
705
706
707 /**
708  * The main function to obtain peer information.
709  *
710  * @param argc number of arguments from the command line
711  * @param argv command line arguments
712  * @return 0 ok, 1 on error
713  */
714 int
715 main (int argc, char *const *argv)
716 {
717   int res;
718   const char helpstr[] = "Create channels and retreive info about meshs status.";
719   static const struct GNUNET_GETOPT_CommandLineOption options[] = {
720 //     {'a', "channel", "TUNNEL_ID:CHANNEL_ID",
721 //      gettext_noop ("provide information about a particular channel"),
722 //      GNUNET_YES, &GNUNET_GETOPT_set_string, &channel_id},
723 //     {'b', "connection", "TUNNEL_ID:CONNECTION_ID",
724 //      gettext_noop ("provide information about a particular connection"),
725 //      GNUNET_YES, &GNUNET_GETOPT_set_string, &conn_id},
726     {'e', "echo", NULL,
727      gettext_noop ("activate echo mode"),
728      GNUNET_NO, &GNUNET_GETOPT_set_one, &echo},
729 //     {'m', "monitor", NULL,
730 //      gettext_noop ("provide information about all tunnels (continuously) NOT IMPLEMENTED"), /* FIXME */
731 //      GNUNET_NO, &GNUNET_GETOPT_set_one, &monitor_connections},
732     {'p', "port", NULL,
733      gettext_noop ("port to listen to (default; 0)"),
734      GNUNET_YES, &GNUNET_GETOPT_set_uint, &listen_port},
735     {'P', "peers", NULL,
736     gettext_noop ("provide information about all peers"),
737     GNUNET_NO, &GNUNET_GETOPT_set_one, &request_peers},
738     {'t', "tunnel", "TUNNEL_ID",
739      gettext_noop ("provide information about a particular tunnel"),
740      GNUNET_YES, &GNUNET_GETOPT_set_string, &tunnel_id},
741     {'T', "tunnels", NULL,
742      gettext_noop ("provide information about all tunnels"),
743      GNUNET_NO, &GNUNET_GETOPT_set_one, &request_tunnels},
744
745     GNUNET_GETOPT_OPTION_END
746   };
747
748   monitor_connections = GNUNET_NO;
749
750   if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv))
751     return 2;
752
753   res = GNUNET_PROGRAM_run (argc, argv, "gnunet-mesh (OPTIONS | TARGET PORT)",
754                             gettext_noop (helpstr),
755                             options, &run, NULL);
756
757   GNUNET_free ((void *) argv);
758
759   if (GNUNET_OK == res)
760     return 0;
761   else
762     return 1;
763 }
764
765 /* end of gnunet-mesh.c */