guix-env: some update.
[oweals/gnunet.git] / src / cadet / gnunet-cadet.c
index d4286a1b00eb6dc4079e8e0deef66317d05b9261..675e7faf026b51164e94d10622081960f801cad6 100644 (file)
@@ -332,8 +332,8 @@ channel_incoming (void *cls,
                   struct GNUNET_CADET_Channel *channel,
                   const struct GNUNET_PeerIdentity *initiator)
 {
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-              "Incomming connection from %s\n",
+  GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE,
+              "Incoming connection from %s\n",
               GNUNET_i2s_full (initiator));
   GNUNET_assert (NULL == ch);
   GNUNET_assert (NULL != lp);
@@ -381,14 +381,10 @@ request_dump (void *cls)
 
 
 /**
- * Function called whenever a message is received.
- *
- * Each time the function must call #GNUNET_CADET_receive_done on the channel
- * in order to receive the next message. This doesn't need to be immediate:
- * can be delayed if some processing is done on the message.
+ * Check data message sanity. Does nothing so far (all messages are OK).
  *
- * @param cls should match #ch
- * @param message The actual message.
+ * @param cls Closure (unused).
+ * @param message The message to check.
  * @return #GNUNET_OK to keep the channel open,
  *         #GNUNET_SYSERR to close it (signal serious error).
  */
@@ -776,15 +772,15 @@ run (void *cls,
        && target_id != NULL)
   {
     FPRINTF (stderr,
-             _("You must NOT give a TARGET "
-               "when using 'request all' options\n"));
+             _("Extra arguments are not applicable "
+               "in combination with this option.\n"));
     return;
   }
 
   if (GNUNET_YES == dump)
   {
     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-                "requesting debug dump\n");
+                "Requesting debug dump\n");
     job = GNUNET_SCHEDULER_add_now (&request_dump,
                                     NULL);
   }
@@ -833,7 +829,7 @@ run (void *cls,
 
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
               "Connecting to CADET service\n");
-  mh = GNUNET_CADET_connecT (cfg);
+  mh = GNUNET_CADET_connect (cfg);
   GNUNET_SCHEDULER_add_shutdown (&shutdown_task,
                                  NULL);
   if (NULL == mh)
@@ -848,7 +844,7 @@ run (void *cls,
     GNUNET_CRYPTO_hash (listen_port,
                         strlen (listen_port),
                         &porthash);
-    lp = GNUNET_CADET_open_porT (mh,
+    lp = GNUNET_CADET_open_port (mh,
                                  &porthash,
                                  &channel_incoming,
                                  NULL,
@@ -880,7 +876,7 @@ run (void *cls,
     GNUNET_CRYPTO_hash (target_port,
                         strlen(target_port),
                         &porthash);
-    ch = GNUNET_CADET_channel_creatE (mh,
+    ch = GNUNET_CADET_channel_create (mh,
                                       NULL,
                                       &pid,
                                       &porthash,
@@ -923,32 +919,55 @@ main (int argc,
       char *const *argv)
 {
   int res;
-  const char helpstr[] = "Create channels and retreive info about cadets status.";
-  static const struct GNUNET_GETOPT_CommandLineOption options[] = {
-    {'C', "connection", "CONNECTION_ID",
-     gettext_noop ("provide information about a particular connection"),
-     GNUNET_YES, &GNUNET_GETOPT_set_string, &conn_id},
-    {'e', "echo", NULL,
-     gettext_noop ("activate echo mode"),
-     GNUNET_NO, &GNUNET_GETOPT_set_one, &echo},
-    {'d', "dump", NULL,
-     gettext_noop ("dump debug information to STDERR"),
-     GNUNET_NO, &GNUNET_GETOPT_set_one, &dump},
-    {'o', "open-port", "PORT",
-     gettext_noop ("port to listen to"),
-     GNUNET_YES, &GNUNET_GETOPT_set_string, &listen_port},
-    {'p', "peer", "PEER_ID",
-     gettext_noop ("provide information about a patricular peer"),
-     GNUNET_YES, &GNUNET_GETOPT_set_string, &peer_id},
-    {'P', "peers", NULL,
-      gettext_noop ("provide information about all peers"),
-      GNUNET_NO, &GNUNET_GETOPT_set_one, &request_peers},
-    {'t', "tunnel", "TUNNEL_ID",
-     gettext_noop ("provide information about a particular tunnel"),
-     GNUNET_YES, &GNUNET_GETOPT_set_string, &tunnel_id},
-    {'T', "tunnels", NULL,
-     gettext_noop ("provide information about all tunnels"),
-     GNUNET_NO, &GNUNET_GETOPT_set_one, &request_tunnels},
+  const char helpstr[] = "Create tunnels and retrieve info about CADET's status.";
+  struct GNUNET_GETOPT_CommandLineOption options[] = {
+    /* I would use the terminology 'circuit' here...  --lynX */
+    GNUNET_GETOPT_option_string ('C',
+                                 "connection",
+                                 "CONNECTION_ID",
+                                 gettext_noop ("Provide information about a particular connection"),
+                                 &conn_id),
+
+    GNUNET_GETOPT_option_flag ('e',
+                                  "echo",
+                                  gettext_noop ("Activate echo mode"),
+                                  &echo), 
+
+    GNUNET_GETOPT_option_flag ('d',
+                                  "dump",
+                                  gettext_noop ("Dump debug information to STDERR"),
+                                  &dump),
+
+    GNUNET_GETOPT_option_string ('o',
+                                 "open-port",
+                                 "SHARED_SECRET",
+                                 gettext_noop ("Listen for connections using a shared secret among sender and recipient"),
+                                 &listen_port),
+
+
+    GNUNET_GETOPT_option_string ('p',
+                                 "peer",
+                                 "PEER_ID",
+                                 gettext_noop ("Provide information about a patricular peer"),
+                                 &peer_id),
+
+
+    GNUNET_GETOPT_option_flag ('P',
+                                  "peers",
+                                  gettext_noop ("Provide information about all peers"),
+                                  &request_peers),
+
+    GNUNET_GETOPT_option_string ('t',
+                                 "tunnel",
+                                 "TUNNEL_ID",
+                                 gettext_noop ("Provide information about a particular tunnel"),
+                                 &tunnel_id),
+
+
+    GNUNET_GETOPT_option_flag ('T',
+                                  "tunnels",
+                                  gettext_noop ("Provide information about all tunnels"),
+                                  &request_tunnels),
 
     GNUNET_GETOPT_OPTION_END
   };
@@ -959,7 +978,7 @@ main (int argc,
     return 2;
 
   res = GNUNET_PROGRAM_run (argc, argv,
-                            "gnunet-cadet (OPTIONS | TARGET PORT)",
+                            "gnunet-cadet (OPTIONS | PEER_ID SHARED_SECRET)",
                             gettext_noop (helpstr),
                             options, &run, NULL);