gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r31140 - gnunet/src/mesh


From: gnunet
Subject: [GNUnet-SVN] r31140 - gnunet/src/mesh
Date: Fri, 6 Dec 2013 13:58:00 +0100

Author: bartpolot
Date: 2013-12-06 13:58:00 +0100 (Fri, 06 Dec 2013)
New Revision: 31140

Modified:
   gnunet/src/mesh/gnunet-mesh.c
Log:
- wip


Modified: gnunet/src/mesh/gnunet-mesh.c
===================================================================
--- gnunet/src/mesh/gnunet-mesh.c       2013-12-06 12:27:35 UTC (rev 31139)
+++ gnunet/src/mesh/gnunet-mesh.c       2013-12-06 12:58:00 UTC (rev 31140)
@@ -98,6 +98,19 @@
 
 
 /**
+ * Call MESH's monitor API, get info of one connection.
+ *
+ * @param cls Closure (unused).
+ * @param tc TaskContext
+ */
+static void
+create_channel (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
+{
+
+}
+
+
+/**
  * Method called to retrieve information about each tunnel the mesh peer
  * is aware of.
  *
@@ -169,12 +182,12 @@
 
   if (GNUNET_OK !=
       GNUNET_CRYPTO_eddsa_public_key_from_string (tunnel_id,
-                                                    strlen (tunnel_id),
-                                                    &pid.public_key))
+                                                  strlen (tunnel_id),
+                                                  &pid.public_key))
   {
     fprintf (stderr,
-            _("Invalid tunnel owner `%s'\n"),
-            tunnel_id);
+             _("Invalid tunnel owner `%s'\n"),
+             tunnel_id);
     GNUNET_SCHEDULER_shutdown();
     return;
   }
@@ -183,6 +196,63 @@
 
 
 /**
+ * Call MESH's monitor API, get info of one channel.
+ *
+ * @param cls Closure (unused).
+ * @param tc TaskContext
+ */
+static void
+show_channel (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
+{
+
+}
+
+
+/**
+ * Call MESH's monitor API, get info of one connection.
+ *
+ * @param cls Closure (unused).
+ * @param tc TaskContext
+ */
+static void
+show_connection (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
+{
+
+}
+
+
+
+/**
+ * Method called whenever another peer has added us to a channel
+ * the other peer initiated.
+ * Only called (once) upon reception of data with a message type which was
+ * subscribed to in #GNUNET_MESH_connect.
+ *
+ * A call to #GNUNET_MESH_channel_destroy causes te channel to be ignored. In
+ * this case the handler MUST return NULL.
+ *
+ * @param cls closure
+ * @param channel new handle to the channel
+ * @param initiator peer that started the channel
+ * @param port Port this channel is for.
+ * @param options MeshOption flag field, with all active option bits set to 1.
+ *
+ * @return initial channel context for the channel
+ *         (can be NULL -- that's not an error)
+ */
+void *
+incoming_channel (void *cls,
+                  struct GNUNET_MESH_Channel * channel,
+                  const struct GNUNET_PeerIdentity * initiator,
+                  uint32_t port, enum MeshOption options)
+{
+  FPRINTF (stdout, "Incoming channel!\n");
+  return NULL;
+}
+
+
+
+/**
  * Main function that will be run by the scheduler.
  *
  * @param cls closure
@@ -198,11 +268,6 @@
     {NULL, 0, 0} /* FIXME add option to monitor msg types */
   };
   /* FIXME add option to monitor apps */
-  int i;
-  for (i = 0; args[i]; i++)
-  {
-    FPRINTF (stderr, "Parameter %u `%s'\n", i, args[i]);
-  }
 
   target_id = args[0];
   target_port = args[0] && args[1] ? atoi(args[1]) : 0;
@@ -216,22 +281,54 @@
     FPRINTF (stderr, _("You must NOT give a TARGET when using options\n"));
     return;
   }
+
+  if (NULL != target_id)
+  {
+    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                "Creating channel to %s\n",
+                target_id);
+    GNUNET_SCHEDULER_add_now (&create_channel, NULL);
+  }
+  else if (NULL != tunnel_id)
+  {
+    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Show tunnel\n");
+    GNUNET_SCHEDULER_add_now (&show_tunnel, NULL);
+  }
+  else if (NULL != channel_id)
+  {
+    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Show channel\n");
+    GNUNET_SCHEDULER_add_now (&show_channel, NULL);
+  }
+  else if (NULL != conn_id)
+  {
+    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Show connection\n");
+    GNUNET_SCHEDULER_add_now (&show_connection, NULL);
+  }
+  else if (GNUNET_YES == get_info)
+  {
+    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Show all tunnels\n");
+    GNUNET_SCHEDULER_add_now (&get_tunnels, NULL);
+  }
+  else
+  {
+    FPRINTF (stderr, "No action requested\n");
+    return;
+  }
+
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Connecting to mesh\n");
   mh = GNUNET_MESH_connect (cfg,
                             NULL, /* cls */
                             NULL, /* new tunnel */
                             NULL, /* cleaner */
                             handlers,
                             NULL);
+  FPRINTF (stdout, "Done\n");
   if (NULL == mh)
     GNUNET_SCHEDULER_add_now (shutdown_task, NULL);
   else
     sd = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL,
                                        shutdown_task, NULL);
 
-  if (NULL != tunnel_id)
-    GNUNET_SCHEDULER_add_now (&show_tunnel, NULL);
-  else
-    GNUNET_SCHEDULER_add_now (&get_tunnels, NULL);
 }
 
 
@@ -247,24 +344,24 @@
 {
   int res;
   static const struct GNUNET_GETOPT_CommandLineOption options[] = {
+    {'a', "channel", "TUNNEL_ID:CHANNEL_ID",
+     gettext_noop ("provide information about a particular channel"),
+     GNUNET_YES, &GNUNET_GETOPT_set_string, &channel_id},
+    {'b', "connection", "TUNNEL_ID:CONNECTION_ID",
+     gettext_noop ("provide information about a particular connection"),
+     GNUNET_YES, &GNUNET_GETOPT_set_string, &conn_id},
+    {'i', "info", NULL,
+     gettext_noop ("provide information about all tunnels"),
+     GNUNET_NO, &GNUNET_GETOPT_set_one, &get_info},
     {'m', "monitor", NULL,
      gettext_noop ("provide information about all tunnels (continuously) NOT 
IMPLEMENTED"), /* FIXME */
      GNUNET_NO, &GNUNET_GETOPT_set_one, &monitor_connections},
-    {'i', "info", NULL,
-     gettext_noop ("provide information about all tunnels"),
-     GNUNET_NO, &GNUNET_GETOPT_set_one, &get_info},
     {'p', "port", NULL,
-     gettext_noop ("listen on this port"),
-     GNUNET_NO, &GNUNET_GETOPT_set_uint, &listen_port},
+     gettext_noop ("port to listen to (default; 0)"),
+     GNUNET_YES, &GNUNET_GETOPT_set_uint, &listen_port},
     {'t', "tunnel", "TUNNEL_ID",
      gettext_noop ("provide information about a particular tunnel"),
      GNUNET_YES, &GNUNET_GETOPT_set_string, &tunnel_id},
-    {'n', "connection", "TUNNEL_ID:CONNECTION_ID",
-     gettext_noop ("provide information about a particular connection"),
-     GNUNET_YES, &GNUNET_GETOPT_set_string, &conn_id},
-    {'a', "channel", "TUNNEL_ID:CHANNEL_ID",
-     gettext_noop ("provide information about a particular channel"),
-     GNUNET_YES, &GNUNET_GETOPT_set_string, &channel_id},
     GNUNET_GETOPT_OPTION_END
   };
 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]