gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r17107 - gnunet/src/transport


From: gnunet
Subject: [GNUnet-SVN] r17107 - gnunet/src/transport
Date: Thu, 29 Sep 2011 16:44:24 +0200

Author: wachs
Date: 2011-09-29 16:44:24 +0200 (Thu, 29 Sep 2011)
New Revision: 17107

Modified:
   gnunet/src/transport/gnunet-service-transport.c
   gnunet/src/transport/gnunet-service-transport_blacklist.c
   gnunet/src/transport/gnunet-service-transport_clients.c
   gnunet/src/transport/gnunet-service-transport_neighbours.c
   gnunet/src/transport/gnunet-service-transport_neighbours.h
   gnunet/src/transport/transport_api_address_iterate.c
Log:
fixing list-connections to show correct peer id
extending neighbour-iterate to return plugin, addr and addresslen


Modified: gnunet/src/transport/gnunet-service-transport.c
===================================================================
--- gnunet/src/transport/gnunet-service-transport.c     2011-09-29 14:21:05 UTC 
(rev 17106)
+++ gnunet/src/transport/gnunet-service-transport.c     2011-09-29 14:44:24 UTC 
(rev 17107)
@@ -83,11 +83,17 @@
  * @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;
 

Modified: gnunet/src/transport/gnunet-service-transport_blacklist.c
===================================================================
--- gnunet/src/transport/gnunet-service-transport_blacklist.c   2011-09-29 
14:21:05 UTC (rev 17106)
+++ gnunet/src/transport/gnunet-service-transport_blacklist.c   2011-09-29 
14:44:24 UTC (rev 17107)
@@ -550,11 +550,17 @@
  * @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;

Modified: gnunet/src/transport/gnunet-service-transport_clients.c
===================================================================
--- gnunet/src/transport/gnunet-service-transport_clients.c     2011-09-29 
14:21:05 UTC (rev 17106)
+++ gnunet/src/transport/gnunet-service-transport_clients.c     2011-09-29 
14:44:24 UTC (rev 17107)
@@ -317,12 +317,18 @@
  * @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 @@
  * @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);
+      (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);
+  transmit_binary_to_client (tc, msg, size);
+  GNUNET_free(msg);
 }
 
 

Modified: gnunet/src/transport/gnunet-service-transport_neighbours.c
===================================================================
--- gnunet/src/transport/gnunet-service-transport_neighbours.c  2011-09-29 
14:21:05 UTC (rev 17106)
+++ gnunet/src/transport/gnunet-service-transport_neighbours.c  2011-09-29 
14:44:24 UTC (rev 17107)
@@ -1064,7 +1064,7 @@
     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;
 }
 

Modified: gnunet/src/transport/gnunet-service-transport_neighbours.h
===================================================================
--- gnunet/src/transport/gnunet-service-transport_neighbours.h  2011-09-29 
14:21:05 UTC (rev 17106)
+++ gnunet/src/transport/gnunet-service-transport_neighbours.h  2011-09-29 
14:44:24 UTC (rev 17107)
@@ -152,13 +152,19 @@
  * @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);
 
 
 /**

Modified: gnunet/src/transport/transport_api_address_iterate.c
===================================================================
--- gnunet/src/transport/transport_api_address_iterate.c        2011-09-29 
14:21:05 UTC (rev 17106)
+++ gnunet/src/transport/transport_api_address_iterate.c        2011-09-29 
14:44:24 UTC (rev 17107)
@@ -80,8 +80,11 @@
   struct AddressLookupCtx *alucb = cls;
   struct AddressIterateResponseMessage *address;
   uint16_t size;
+  char * transport;
+  size_t transport_len;
+  //void * addr;
+  size_t addrlen;
 
-
   if (msg == NULL)
   {
     alucb->cb (alucb->cb_cls, NULL, NULL, NULL, 0);
@@ -103,7 +106,7 @@
     GNUNET_free (alucb);
     return;
   }
-  if (size != sizeof (struct AddressIterateResponseMessage))
+  if (size < sizeof (struct AddressIterateResponseMessage))
   {
     /* invalid reply */
     GNUNET_break (0);
@@ -113,15 +116,16 @@
     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);
 }
 
 




reply via email to

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