[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r11159 - gnunet/src/dv
From: |
gnunet |
Subject: |
[GNUnet-SVN] r11159 - gnunet/src/dv |
Date: |
Mon, 3 May 2010 11:58:34 +0200 |
Author: nevans
Date: 2010-05-03 11:58:34 +0200 (Mon, 03 May 2010)
New Revision: 11159
Modified:
gnunet/src/dv/dv_api.c
gnunet/src/dv/plugin_transport_dv.c
Log:
address printing for dv plugin, doxygen comment
Modified: gnunet/src/dv/dv_api.c
===================================================================
--- gnunet/src/dv/dv_api.c 2010-05-03 09:57:08 UTC (rev 11158)
+++ gnunet/src/dv/dv_api.c 2010-05-03 09:58:34 UTC (rev 11159)
@@ -433,6 +433,8 @@
* @param timeout how long can this message be delayed (pass through to core)
* @param addr the address of this peer (internally known to DV)
* @param addrlen the length of the peer address
+ * @param cont continuation to call once the message has been sent (or failed)
+ * @param cont_cls closure for continuation
*
*/
int GNUNET_DV_send (struct GNUNET_DV_Handle *dv_handle,
Modified: gnunet/src/dv/plugin_transport_dv.c
===================================================================
--- gnunet/src/dv/plugin_transport_dv.c 2010-05-03 09:57:08 UTC (rev 11158)
+++ gnunet/src/dv/plugin_transport_dv.c 2010-05-03 09:58:34 UTC (rev 11159)
@@ -310,8 +310,48 @@
asc (asc_cls, NULL);
}
+/**
+ * Convert the DV address to a pretty string.
+ *
+ * @param cls closure
+ * @param addr the (hopefully) DV address
+ * @param addrlen the length of the address
+ *
+ * @return string representing the DV address
+ */
+static const char *address_to_string (void *cls,
+ const void *addr,
+ size_t addrlen)
+{
+ static char return_buffer[2 * 4 + 2]; // Two four character peer identity
prefixes a ':' and '\0'
+ struct GNUNET_CRYPTO_HashAsciiEncoded peer_hash;
+ struct GNUNET_CRYPTO_HashAsciiEncoded via_hash;
+ struct GNUNET_PeerIdentity *peer;
+ struct GNUNET_PeerIdentity *via;
+ char *addr_buf = (char *)addr;
+ if (addrlen == (2 * sizeof(struct GNUNET_PeerIdentity)))
+ {
+ peer = (struct GNUNET_PeerIdentity *)addr_buf;
+ via = (struct GNUNET_PeerIdentity *)&addr_buf[sizeof(struct
GNUNET_PeerIdentity)];
+
+ GNUNET_CRYPTO_hash_to_enc (&peer->hashPubKey, &peer_hash);
+ peer_hash.encoding[4] = '\0';
+ GNUNET_CRYPTO_hash_to_enc (&via->hashPubKey, &via_hash);
+ via_hash.encoding[4] = '\0';
+ GNUNET_snprintf (return_buffer,
+ sizeof (return_buffer),
+ "%s:%s",
+ &peer_hash,
+ &via_hash);
+ }
+ else
+ return NULL;
+
+ return return_buffer;
+}
+
/**
* Another peer has suggested an address for this
* peer and transport plugin. Check that this could be a valid
@@ -368,6 +408,7 @@
api->disconnect = &dv_plugin_disconnect;
api->address_pretty_printer = &dv_plugin_address_pretty_printer;
api->check_address = &dv_plugin_address_suggested;
+ api->address_to_string = &address_to_string;
return api;
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r11159 - gnunet/src/dv,
gnunet <=