removing deprecated, dead test-connected API
[oweals/gnunet.git] / src / core / gnunet-service-core_neighbours.c
index 0e292fbd1456c0982e5b4477fa1a5ad2bb31cfd4..78213f9d9ddb428cc45a8ea21910f62e104ca83e 100644 (file)
@@ -129,6 +129,8 @@ static struct GNUNET_TRANSPORT_Handle *transport;
 static struct Neighbour *
 find_neighbour (const struct GNUNET_PeerIdentity *peer)
 {
+  if (NULL == neighbours)
+    return NULL;
   return GNUNET_CONTAINER_multihashmap_get (neighbours, &peer->hashPubKey);
 }
 
@@ -143,11 +145,9 @@ free_neighbour (struct Neighbour *n)
 {
   struct NeighbourMessageEntry *m;
 
-#if DEBUG_CORE
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
               "Destroying neighbour entry for peer `%4s'\n",
               GNUNET_i2s (&n->peer));
-#endif
   while (NULL != (m = n->message_head))
   {
     GNUNET_CONTAINER_DLL_remove (n->message_head, n->message_tail, m);
@@ -162,7 +162,6 @@ free_neighbour (struct Neighbour *n)
                             gettext_noop
                             ("# sessions terminated by transport disconnect"),
                             1, GNUNET_NO);
-  GSC_SESSIONS_end (&n->peer);
   if (NULL != n->kxinfo)
   {
     GSC_KX_stop (n->kxinfo);
@@ -222,29 +221,24 @@ transmit_ready (void *cls, size_t size, void *buf)
   GNUNET_CONTAINER_DLL_remove (n->message_head, n->message_tail, m);
   if (buf == NULL)
   {
-#if DEBUG_CORE
     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
                 "Transmission of message of type %u and size %u failed\n",
                 (unsigned int)
                 ntohs (((struct GNUNET_MessageHeader *) &m[1])->type),
                 (unsigned int) m->size);
-#endif
     GNUNET_free (m);
     process_queue (n);
     return 0;
   }
-  ret = 0;
   cbuf = buf;
   GNUNET_assert (size >= m->size);
   memcpy (cbuf, &m[1], m->size);
   ret = m->size;
-#if DEBUG_CORE
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
               "Copied message of type %u and size %u into transport buffer for `%4s'\n",
               (unsigned int)
               ntohs (((struct GNUNET_MessageHeader *) &m[1])->type),
               (unsigned int) ret, GNUNET_i2s (&n->peer));
-#endif
   GNUNET_free (m);
   process_queue (n);
   GNUNET_STATISTICS_update (GSC_stats,
@@ -276,13 +270,10 @@ process_queue (struct Neighbour *n)
     GSC_SESSIONS_solicit (&n->peer);
     return;
   }
-#if DEBUG_CORE > 1
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-              "Asking transport for transmission of %u bytes to `%4s' in next %llu ms\n",
+              "Asking transport for transmission of %u bytes to `%4s' in next %s\n",
               (unsigned int) m->size, GNUNET_i2s (&n->peer),
-              (unsigned long long)
-              GNUNET_TIME_absolute_get_remaining (m->deadline).rel_value);
-#endif
+              GNUNET_STRINGS_relative_time_to_string (GNUNET_TIME_absolute_get_remaining (m->deadline), GNUNET_NO));
   n->th =
       GNUNET_TRANSPORT_notify_transmit_ready (transport, &n->peer, m->size, 0,
                                               GNUNET_TIME_absolute_get_remaining
@@ -306,14 +297,10 @@ process_queue (struct Neighbour *n)
  *
  * @param cls closure
  * @param peer the peer that connected
- * @param atsi performance data
- * @param atsi_count number of entries in ats (excluding 0-termination)
  */
 static void
 handle_transport_notify_connect (void *cls,
-                                 const struct GNUNET_PeerIdentity *peer,
-                                 const struct GNUNET_ATS_Information *atsi,
-                                 uint32_t atsi_count)
+                                 const struct GNUNET_PeerIdentity *peer)
 {
   struct Neighbour *n;
 
@@ -329,10 +316,8 @@ handle_transport_notify_connect (void *cls,
     GNUNET_break (0);
     return;
   }
-#if DEBUG_CORE
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received connection from `%4s'.\n",
               GNUNET_i2s (peer));
-#endif
   n = GNUNET_malloc (sizeof (struct Neighbour));
   n->peer = *peer;
   GNUNET_assert (GNUNET_OK ==
@@ -360,11 +345,9 @@ handle_transport_notify_disconnect (void *cls,
 {
   struct Neighbour *n;
 
-#if DEBUG_CORE
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
               "Peer `%4s' disconnected from us; received notification from transport.\n",
               GNUNET_i2s (peer));
-#endif
   n = find_neighbour (peer);
   if (n == NULL)
   {
@@ -381,23 +364,17 @@ handle_transport_notify_disconnect (void *cls,
  * @param cls closure
  * @param peer (claimed) identity of the other peer
  * @param message the message
- * @param atsi performance data
- * @param atsi_count number of entries in ats (excluding 0-termination)
  */
 static void
 handle_transport_receive (void *cls, const struct GNUNET_PeerIdentity *peer,
-                          const struct GNUNET_MessageHeader *message,
-                          const struct GNUNET_ATS_Information *atsi,
-                          uint32_t atsi_count)
+                          const struct GNUNET_MessageHeader *message)
 {
   struct Neighbour *n;
   uint16_t type;
 
-#if DEBUG_CORE > 1
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
               "Received message of type %u from `%4s', demultiplexing.\n",
               (unsigned int) ntohs (message->type), GNUNET_i2s (peer));
-#endif
   if (0 == memcmp (peer, &GSC_my_identity, sizeof (struct GNUNET_PeerIdentity)))
   {
     GNUNET_break (0);
@@ -413,8 +390,8 @@ handle_transport_receive (void *cls, const struct GNUNET_PeerIdentity *peer,
   type = ntohs (message->type);
   switch (type)
   {
-  case GNUNET_MESSAGE_TYPE_CORE_SET_KEY:
-    GSC_KX_handle_set_key (n->kxinfo, message);
+  case GNUNET_MESSAGE_TYPE_CORE_EPHEMERAL_KEY:
+    GSC_KX_handle_ephemeral_key (n->kxinfo, message);
     break;
   case GNUNET_MESSAGE_TYPE_CORE_PING:
     GSC_KX_handle_ping (n->kxinfo, message);
@@ -423,14 +400,17 @@ handle_transport_receive (void *cls, const struct GNUNET_PeerIdentity *peer,
     GSC_KX_handle_pong (n->kxinfo, message);
     break;
   case GNUNET_MESSAGE_TYPE_CORE_ENCRYPTED_MESSAGE:
-    GSC_KX_handle_encrypted_message (n->kxinfo, message, atsi, atsi_count);
+    GSC_KX_handle_encrypted_message (n->kxinfo, message);
+    break;
+  case GNUNET_MESSAGE_TYPE_DUMMY:
+    /*  Dummy messages for testing / benchmarking, just discard */
     break;
   default:
     GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
-                _("Unsupported message of type %u (%u bytes) received from peer `%s'\n"),
-                (unsigned int) type,
-               (unsigned int) ntohs (message->size),
-               GNUNET_i2s (peer));
+                _
+                ("Unsupported message of type %u (%u bytes) received from peer `%s'\n"),
+                (unsigned int) type, (unsigned int) ntohs (message->size),
+                GNUNET_i2s (peer));
     return;
   }
 }
@@ -474,7 +454,7 @@ GSC_NEIGHBOURS_transmit (const struct GNUNET_PeerIdentity *target,
 int
 GSC_NEIGHBOURS_init ()
 {
-  neighbours = GNUNET_CONTAINER_multihashmap_create (128);
+  neighbours = GNUNET_CONTAINER_multihashmap_create (128, GNUNET_NO);
   transport =
       GNUNET_TRANSPORT_connect (GSC_cfg, &GSC_my_identity, NULL,
                                 &handle_transport_receive,
@@ -499,7 +479,7 @@ GSC_NEIGHBOURS_init ()
  * @return GNUNET_OK (continue to iterate)
  */
 static int
-free_neighbour_helper (void *cls, const GNUNET_HashCode * key, void *value)
+free_neighbour_helper (void *cls, const struct GNUNET_HashCode * key, void *value)
 {
   struct Neighbour *n = value;
 
@@ -516,14 +496,18 @@ free_neighbour_helper (void *cls, const GNUNET_HashCode * key, void *value)
 void
 GSC_NEIGHBOURS_done ()
 {
-  if (NULL == transport)
-    return;
-  GNUNET_TRANSPORT_disconnect (transport);
-  transport = NULL;
-  GNUNET_CONTAINER_multihashmap_iterate (neighbours, &free_neighbour_helper,
-                                         NULL);
-  GNUNET_CONTAINER_multihashmap_destroy (neighbours);
-  neighbours = NULL;
+  if (NULL != transport)
+  {
+    GNUNET_TRANSPORT_disconnect (transport);
+    transport = NULL;
+  }
+  if (NULL != neighbours)
+  {
+    GNUNET_CONTAINER_multihashmap_iterate (neighbours, &free_neighbour_helper,
+                                          NULL);
+    GNUNET_CONTAINER_multihashmap_destroy (neighbours);
+    neighbours = NULL;
+  }
 }
 
 /* end of gnunet-service-core_neighbours.c */