add logic to handle monitor start to gnunet-service-tng.c
authorChristian Grothoff <christian@grothoff.org>
Wed, 14 Nov 2018 13:42:12 +0000 (14:42 +0100)
committerChristian Grothoff <christian@grothoff.org>
Wed, 14 Nov 2018 13:42:12 +0000 (14:42 +0100)
src/transport/gnunet-service-tng.c

index 447e9fa5d48047d7a979649d2681ee885ea31ea8..d92964654ae3105667c7898f394e81f01b472dc0 100644 (file)
@@ -145,7 +145,7 @@ struct GNUNET_STATISTICS_Handle *GST_stats;
 const struct GNUNET_CONFIGURATION_Handle *GST_cfg;
 
 /**
- * Configuration handle.
+ * Our public key.
  */
 struct GNUNET_PeerIdentity GST_my_identity;
 
@@ -587,6 +587,31 @@ handle_send_message_ack (void *cls,
 }
 
 
+/**
+ * Initialize a monitor client.
+ *
+ * @param cls the client
+ * @param start the start message that was sent
+ */
+static void
+handle_monitor_start (void *cls,
+                    const struct GNUNET_TRANSPORT_MonitorStart *start)
+{
+  struct TransportClient *tc = cls;
+
+  if (CT_NONE != tc->type)
+  {
+    GNUNET_break (0);
+    GNUNET_SERVICE_client_drop (tc->client);
+    return;
+  }
+  tc->type = CT_MONITOR;
+  tc->details.monitor_peer = start->peer;
+  // FIXME: remember also the one_shot flag!
+  GNUNET_SERVICE_client_continue (tc->client);
+}
+
+
 /**
  * Function called when the service shuts down.  Unloads our plugins
  * and cancels pending validations.
@@ -708,6 +733,11 @@ GNUNET_SERVICE_MAIN
                           GNUNET_MESSAGE_TYPE_TRANSPORT_SEND_MSG_ACK,
                           struct GNUNET_TRANSPORT_SendMessageToAck,
                           NULL),
+ /* communication with monitors */
+ GNUNET_MQ_hd_fixed_size (monitor_start,
+                          GNUNET_MESSAGE_TYPE_TRANSPORT_MONITOR_START,
+                          struct GNUNET_TRANSPORT_MonitorStart,
+                          NULL),
  GNUNET_MQ_handler_end ());