fixing list-connections to show correct peer id
authorMatthias Wachs <wachs@net.in.tum.de>
Thu, 29 Sep 2011 14:44:24 +0000 (14:44 +0000)
committerMatthias Wachs <wachs@net.in.tum.de>
Thu, 29 Sep 2011 14:44:24 +0000 (14:44 +0000)
extending neighbour-iterate to return plugin, addr and addresslen

src/transport/gnunet-service-transport.c
src/transport/gnunet-service-transport_blacklist.c
src/transport/gnunet-service-transport_clients.c
src/transport/gnunet-service-transport_neighbours.c
src/transport/gnunet-service-transport_neighbours.h
src/transport/transport_api_address_iterate.c

index 92f78fec5bcbd94a528fe9f08af537c01b38aaca..3693bcf2e22da6c9a9f055f43c0c75985adb3cc1 100644 (file)
@@ -83,11 +83,17 @@ struct GNUNET_ATS_Handle *GST_ats;
  * @param target a connected neighbour
  * @param ats performance information (unused)
  * @param ats_count number of records in ats (unused)
+ * @param transport plugin
+ * @param addr address
+ * @param addrlen address length
  */
 static void
 transmit_our_hello (void *cls, const struct GNUNET_PeerIdentity *target,
                     const struct GNUNET_TRANSPORT_ATS_Information *ats,
-                    uint32_t ats_count)
+                    uint32_t ats_count,
+                    const char * transport,
+                    const void * addr,
+                    size_t addrlen)
 {
   const struct GNUNET_MessageHeader *hello = cls;
 
index a73aa17c1d43a53461078c6c800f62893335302b..cb79787ced992a89f5dfbfd3f352f209f847caa3 100644 (file)
@@ -550,11 +550,17 @@ struct TestConnectionContext
  * @param neighbour neighbour's identity
  * @param ats performance data
  * @param ats_count number of entries in ats (excluding 0-termination)
+ * @param transport plugin
+ * @param addr address
+ * @param addrlen address length
  */
 static void
 test_connection_ok (void *cls, const struct GNUNET_PeerIdentity *neighbour,
                     const struct GNUNET_TRANSPORT_ATS_Information *ats,
-                    uint32_t ats_count)
+                    uint32_t ats_count,
+                    const char * transport,
+                    const void * addr,
+                    size_t addrlen)
 {
   struct TestConnectionContext *tcc = cls;
   struct GST_BlacklistCheck *bc;
index 9936c1137542ed562adc825f2af56f2294a23f0c..650efc8dd52948946ea06ade8b6e336e8988ba42 100644 (file)
@@ -317,12 +317,18 @@ client_disconnect_notification (void *cls, struct GNUNET_SERVER_Client *client)
  * @param peer identity of the neighbour
  * @param ats performance data
  * @param ats_count number of entries in ats (excluding 0-termination)
+ * @param transport plugin
+ * @param addr address
+ * @param addrlen address length
  */
 static void
 notify_client_about_neighbour (void *cls,
                                const struct GNUNET_PeerIdentity *peer,
                                const struct GNUNET_TRANSPORT_ATS_Information
-                               *ats, uint32_t ats_count)
+                               *ats, uint32_t ats_count,
+                               const char * transport,
+                               const void * addr,
+                               size_t addrlen)
 {
   struct TransportClient *tc = cls;
   struct ConnectInfoMessage *cim;
@@ -803,24 +809,32 @@ clients_handle_peer_address_lookup (void *cls,
  * @param neighbour identity of the neighbour
  * @param ats performance data
  * @param ats_count number of entries in ats (excluding 0-termination)
+ * @param transport plugin
+ * @param addr address
+ * @param addrlen address length
  */
 static void
 output_addresses (void *cls, const struct GNUNET_PeerIdentity *peer,
                   const struct GNUNET_TRANSPORT_ATS_Information *ats,
-                  uint32_t ats_count)
+                  uint32_t ats_count,
+                  const char * transport,
+                  const void * addr,
+                  size_t addrlen)
 {
   struct GNUNET_SERVER_TransmitContext *tc = cls;
-  struct AddressIterateResponseMessage msg;
+  struct AddressIterateResponseMessage msg;
   size_t size;
 
   size =
-      sizeof (struct AddressIterateResponseMessage) -
-      sizeof (struct GNUNET_MessageHeader);
-  memcpy (&msg.peer, peer, sizeof (struct GNUNET_PeerIdentity));
-  msg.addrlen = ntohs (0);
-  msg.pluginlen = ntohs (0);
-
-  transmit_binary_to_client (tc, &msg, size);
+      (sizeof (struct AddressIterateResponseMessage) + strlen(transport) + 1);
+  msg = GNUNET_malloc (size);
+  memcpy (&msg->peer, peer, sizeof (struct GNUNET_PeerIdentity));
+  memcpy (&msg[0], transport, strlen(transport)+1);
+  msg->addrlen = ntohs (addrlen);
+  msg->pluginlen = ntohs (strlen(transport)+1);
+
+  transmit_binary_to_client (tc, msg, size);
+  GNUNET_free(msg);
 }
 
 
index 09e24565babb9c7bf7f36900353cc84980bed2c9..26bf3771c41ea33a93de993e2235535991582d3f 100644 (file)
@@ -1064,7 +1064,7 @@ neighbours_iterate (void *cls, const GNUNET_HashCode * key, void *value)
     return GNUNET_OK;
 
   GNUNET_assert (n->ats_count > 0);
-  ic->cb (ic->cb_cls, &n->id, n->ats, n->ats_count);
+  ic->cb (ic->cb_cls, &n->id, n->ats, n->ats_count, n->plugin_name, n->addr, n->addrlen);
   return GNUNET_OK;
 }
 
index 86939f91af7e6e8ee712aa236d2ddc09426a7d81..88e24b73abf3af586951d449e02e4f1d93c3d397 100644 (file)
@@ -152,13 +152,19 @@ GST_neighbours_force_disconnect (const struct GNUNET_PeerIdentity *target);
  * @param neighbour identity of the neighbour
  * @param ats performance data
  * @param ats_count number of entries in ats (including 0-termination)
+ * @param transport plugin
+ * @param addr address
+ * @param addrlen address length
  */
 typedef void (*GST_NeighbourIterator) (void *cls,
                                        const struct GNUNET_PeerIdentity *
                                        neighbour,
                                        const struct
                                        GNUNET_TRANSPORT_ATS_Information * ats,
-                                       uint32_t ats_count);
+                                       uint32_t ats_count,
+                                       const char * transport,
+                                       const void * addr,
+                                       size_t addrlen);
 
 
 /**
index da333798f55cd24b6d44528fa1cd9745f2e980f2..a5b4251c5c5bf71b56c8e712243ab8915439f131 100644 (file)
@@ -80,7 +80,10 @@ peer_address_response_processor (void *cls,
   struct AddressLookupCtx *alucb = cls;
   struct AddressIterateResponseMessage *address;
   uint16_t size;
-
+  char * transport;
+  size_t transport_len;
+  //void * addr;
+  size_t addrlen;
 
   if (msg == NULL)
   {
@@ -103,7 +106,7 @@ peer_address_response_processor (void *cls,
     GNUNET_free (alucb);
     return;
   }
-  if (size != sizeof (struct AddressIterateResponseMessage))
+  if (size < sizeof (struct AddressIterateResponseMessage))
   {
     /* invalid reply */
     GNUNET_break (0);
@@ -113,15 +116,16 @@ peer_address_response_processor (void *cls,
     return;
   }
 
-  address = (struct AddressIterateResponseMessage *) msg;
-  GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "PEER: %s\n",
-              GNUNET_i2s (&address->peer));
+  address = (struct AddressIterateResponseMessage *) &msg[1];
 
+  transport = (char *) &address[0];
+  transport_len = ntohs(address->pluginlen);
+  addrlen = ntohs(address->addrlen);
 
   /* expect more replies */
   GNUNET_CLIENT_receive (alucb->client, &peer_address_response_processor, alucb,
                          GNUNET_TIME_absolute_get_remaining (alucb->timeout));
-  alucb->cb (alucb->cb_cls, &address->peer, NULL, NULL, 0);
+  alucb->cb (alucb->cb_cls, &address->peer, transport, NULL, addrlen);
 }