diff options
author | Nathan S. Evans <evans@in.tum.de> | 2010-05-03 09:58:34 +0000 |
---|---|---|
committer | Nathan S. Evans <evans@in.tum.de> | 2010-05-03 09:58:34 +0000 |
commit | 94795b551faecef0a3d968a60e77188e5f691548 (patch) | |
tree | 53460479a766fd4519b71174a154a608316388f7 /src/dv/plugin_transport_dv.c | |
parent | 217db1cb60fd0838e865edca44b479123dd69eb6 (diff) | |
download | gnunet-94795b551faecef0a3d968a60e77188e5f691548.tar.gz gnunet-94795b551faecef0a3d968a60e77188e5f691548.zip |
address printing for dv plugin, doxygen comment
Diffstat (limited to 'src/dv/plugin_transport_dv.c')
-rw-r--r-- | src/dv/plugin_transport_dv.c | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/src/dv/plugin_transport_dv.c b/src/dv/plugin_transport_dv.c index 83a89abba..6932ce34b 100644 --- a/src/dv/plugin_transport_dv.c +++ b/src/dv/plugin_transport_dv.c | |||
@@ -310,7 +310,47 @@ dv_plugin_address_pretty_printer (void *cls, | |||
310 | asc (asc_cls, NULL); | 310 | asc (asc_cls, NULL); |
311 | } | 311 | } |
312 | 312 | ||
313 | /** | ||
314 | * Convert the DV address to a pretty string. | ||
315 | * | ||
316 | * @param cls closure | ||
317 | * @param addr the (hopefully) DV address | ||
318 | * @param addrlen the length of the address | ||
319 | * | ||
320 | * @return string representing the DV address | ||
321 | */ | ||
322 | static const char *address_to_string (void *cls, | ||
323 | const void *addr, | ||
324 | size_t addrlen) | ||
325 | { | ||
326 | static char return_buffer[2 * 4 + 2]; // Two four character peer identity prefixes a ':' and '\0' | ||
327 | |||
328 | struct GNUNET_CRYPTO_HashAsciiEncoded peer_hash; | ||
329 | struct GNUNET_CRYPTO_HashAsciiEncoded via_hash; | ||
330 | struct GNUNET_PeerIdentity *peer; | ||
331 | struct GNUNET_PeerIdentity *via; | ||
332 | char *addr_buf = (char *)addr; | ||
333 | |||
334 | if (addrlen == (2 * sizeof(struct GNUNET_PeerIdentity))) | ||
335 | { | ||
336 | peer = (struct GNUNET_PeerIdentity *)addr_buf; | ||
337 | via = (struct GNUNET_PeerIdentity *)&addr_buf[sizeof(struct GNUNET_PeerIdentity)]; | ||
338 | |||
339 | GNUNET_CRYPTO_hash_to_enc (&peer->hashPubKey, &peer_hash); | ||
340 | peer_hash.encoding[4] = '\0'; | ||
341 | GNUNET_CRYPTO_hash_to_enc (&via->hashPubKey, &via_hash); | ||
342 | via_hash.encoding[4] = '\0'; | ||
343 | GNUNET_snprintf (return_buffer, | ||
344 | sizeof (return_buffer), | ||
345 | "%s:%s", | ||
346 | &peer_hash, | ||
347 | &via_hash); | ||
348 | } | ||
349 | else | ||
350 | return NULL; | ||
313 | 351 | ||
352 | return return_buffer; | ||
353 | } | ||
314 | 354 | ||
315 | /** | 355 | /** |
316 | * Another peer has suggested an address for this | 356 | * Another peer has suggested an address for this |
@@ -368,6 +408,7 @@ libgnunet_plugin_transport_dv_init (void *cls) | |||
368 | api->disconnect = &dv_plugin_disconnect; | 408 | api->disconnect = &dv_plugin_disconnect; |
369 | api->address_pretty_printer = &dv_plugin_address_pretty_printer; | 409 | api->address_pretty_printer = &dv_plugin_address_pretty_printer; |
370 | api->check_address = &dv_plugin_address_suggested; | 410 | api->check_address = &dv_plugin_address_suggested; |
411 | api->address_to_string = &address_to_string; | ||
371 | return api; | 412 | return api; |
372 | } | 413 | } |
373 | 414 | ||