refactor DHT for new service API
[oweals/gnunet.git] / src / core / core_api.c
index acdac5fa455a33786f0a06a2f57bed614e7b395a..67f17352ddfd9170f8117b04332fabd6b0d4c28a 100644 (file)
@@ -541,11 +541,12 @@ handle_notify_inbound (void *cls,
   uint16_t et;
 
   GNUNET_break (GNUNET_NO == h->currently_down);
-  LOG (GNUNET_ERROR_TYPE_DEBUG,
-       "Received inbound message from `%s'.\n",
-       GNUNET_i2s (&ntm->peer));
   em = (const struct GNUNET_MessageHeader *) &ntm[1];
   et = ntohs (em->type);
+  LOG (GNUNET_ERROR_TYPE_DEBUG,
+       "Received inbound message of type %d from `%s'.\n",
+       (int) et,
+       GNUNET_i2s (&ntm->peer));
   for (unsigned int hpos = 0; NULL != h->handlers[hpos].callback; hpos++)
   {
     const struct GNUNET_CORE_MessageHandler *mh;
@@ -767,31 +768,31 @@ handle_send_ready (void *cls,
 static void
 reconnect (struct GNUNET_CORE_Handle *h)
 {
-  GNUNET_MQ_hd_fixed_size (init_reply,
-                           GNUNET_MESSAGE_TYPE_CORE_INIT_REPLY,
-                           struct InitReplyMessage);
-  GNUNET_MQ_hd_fixed_size (connect_notify,
-                           GNUNET_MESSAGE_TYPE_CORE_NOTIFY_CONNECT,
-                           struct ConnectNotifyMessage);
-  GNUNET_MQ_hd_fixed_size (disconnect_notify,
-                           GNUNET_MESSAGE_TYPE_CORE_NOTIFY_DISCONNECT,
-                           struct DisconnectNotifyMessage);
-  GNUNET_MQ_hd_var_size (notify_inbound,
-                         GNUNET_MESSAGE_TYPE_CORE_NOTIFY_INBOUND,
-                         struct NotifyTrafficMessage);
-  GNUNET_MQ_hd_var_size (notify_outbound,
-                         GNUNET_MESSAGE_TYPE_CORE_NOTIFY_OUTBOUND,
-                         struct NotifyTrafficMessage);
-  GNUNET_MQ_hd_fixed_size (send_ready,
-                           GNUNET_MESSAGE_TYPE_CORE_SEND_READY,
-                           struct SendMessageReady);
- struct GNUNET_MQ_MessageHandler handlers[] = {
-    make_init_reply_handler (h),
-    make_connect_notify_handler (h),
-    make_disconnect_notify_handler (h),
-    make_notify_inbound_handler (h),
-    make_notify_outbound_handler (h),
-    make_send_ready_handler (h),
+  struct GNUNET_MQ_MessageHandler handlers[] = {
+    GNUNET_MQ_hd_fixed_size (init_reply,
+                             GNUNET_MESSAGE_TYPE_CORE_INIT_REPLY,
+                             struct InitReplyMessage,
+                             h),
+    GNUNET_MQ_hd_fixed_size (connect_notify,
+                             GNUNET_MESSAGE_TYPE_CORE_NOTIFY_CONNECT,
+                             struct ConnectNotifyMessage,
+                             h),
+    GNUNET_MQ_hd_fixed_size (disconnect_notify,
+                             GNUNET_MESSAGE_TYPE_CORE_NOTIFY_DISCONNECT,
+                             struct DisconnectNotifyMessage,
+                             h),
+    GNUNET_MQ_hd_var_size (notify_inbound,
+                           GNUNET_MESSAGE_TYPE_CORE_NOTIFY_INBOUND,
+                           struct NotifyTrafficMessage,
+                           h),
+    GNUNET_MQ_hd_var_size (notify_outbound,
+                           GNUNET_MESSAGE_TYPE_CORE_NOTIFY_OUTBOUND,
+                           struct NotifyTrafficMessage,
+                           h),
+    GNUNET_MQ_hd_fixed_size (send_ready,
+                             GNUNET_MESSAGE_TYPE_CORE_SEND_READY,
+                             struct SendMessageReady,
+                             h),
     GNUNET_MQ_handler_end ()
   };
   struct InitMessage *init;
@@ -916,44 +917,6 @@ GNUNET_CORE_connect (const struct GNUNET_CONFIGURATION_Handle *cfg,
 }
 
 
-/**
- * Connect to the core service.  Note that the connection may complete
- * (or fail) asynchronously.  This function primarily causes the given
- * callback notification functions to be invoked whenever the
- * specified event happens.  The maximum number of queued
- * notifications (queue length) is per client; the queue is shared
- * across all types of notifications.  So a slow client that registers
- * for @a outbound_notify also risks missing @a inbound_notify messages.
- * Certain events (such as connect/disconnect notifications) are not
- * subject to queue size limitations.
- *
- * @param cfg configuration to use
- * @param cls closure for the various callbacks that follow (including handlers in the handlers array)
- * @param init callback to call once we have successfully
- *        connected to the core service
- * @param connects function to call on peer connect, can be NULL
- * @param disconnects function to call on peer disconnect / timeout, can be NULL
- * @param handlers callbacks for messages we care about, NULL-terminated
- *                note that the core is allowed to drop notifications about inbound
- *                messages if the client does not process them fast enough (for this
- *                notification type, a bounded queue is used)
- * @return handle to the core service (only useful for disconnect until @a init is called),
- *           NULL on error (in this case, init is never called)
- */
-struct GNUNET_CORE_Handle *
-GNUNET_CORE_connecT (const struct GNUNET_CONFIGURATION_Handle *cfg,
-                     void *cls,
-                     GNUNET_CORE_StartupCallback init,
-                     GNUNET_CORE_ConnecTEventHandler connects,
-                     GNUNET_CORE_DisconnecTEventHandler disconnects,
-                     const struct GNUNET_MQ_MessageHandler *handlers)
-{
-  GNUNET_break (0); // not implemented
-  // NOTE: re-enable core-related tests in ats-tests/ once implemented!
-  return NULL;
-}
-
-
 /**
  * Disconnect from the core service.  This function can only
  * be called *after* all pending #GNUNET_CORE_notify_transmit_ready()