diff options
author | Christian Grothoff <christian@grothoff.org> | 2015-02-02 09:22:18 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2015-02-02 09:22:18 +0000 |
commit | 583fe23eac9e91896309c3d896af7541054d5e01 (patch) | |
tree | 07bdc466ac0b1d1669f0a6cceaf2369a9e8315a0 | |
parent | 0f550b188c85b709c37383dd75f0243b6222636f (diff) | |
download | gnunet-583fe23eac9e91896309c3d896af7541054d5e01.tar.gz gnunet-583fe23eac9e91896309c3d896af7541054d5e01.zip |
-doxyen, comments, indentation
-rw-r--r-- | src/transport/gnunet-service-transport_ats.c | 22 | ||||
-rw-r--r-- | src/transport/gnunet-service-transport_validation.c | 47 |
2 files changed, 57 insertions, 12 deletions
diff --git a/src/transport/gnunet-service-transport_ats.c b/src/transport/gnunet-service-transport_ats.c index 430c00ba6..bc20038f1 100644 --- a/src/transport/gnunet-service-transport_ats.c +++ b/src/transport/gnunet-service-transport_ats.c | |||
@@ -85,6 +85,21 @@ struct FindClosure | |||
85 | 85 | ||
86 | 86 | ||
87 | /** | 87 | /** |
88 | * Provide an update on the `p2a` map size to statistics. | ||
89 | * This function should be called whenever the `p2a` map | ||
90 | * is changed. | ||
91 | */ | ||
92 | static void | ||
93 | publish_p2a_stat_update () | ||
94 | { | ||
95 | GNUNET_STATISTICS_set (GST_stats, | ||
96 | gettext_noop ("# Addresses given to ATS"), | ||
97 | GNUNET_CONTAINER_multipeermap_size (p2a), | ||
98 | GNUNET_NO); | ||
99 | } | ||
100 | |||
101 | |||
102 | /** | ||
88 | * Find matching address info. | 103 | * Find matching address info. |
89 | * | 104 | * |
90 | * @param cls the `struct FindClosure` | 105 | * @param cls the `struct FindClosure` |
@@ -299,6 +314,7 @@ GST_ats_add_address (const struct GNUNET_HELLO_Address *address, | |||
299 | &ai->address->peer, | 314 | &ai->address->peer, |
300 | ai, | 315 | ai, |
301 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE); | 316 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE); |
317 | publish_p2a_stat_update (); | ||
302 | } | 318 | } |
303 | 319 | ||
304 | 320 | ||
@@ -480,6 +496,7 @@ GST_ats_expire_address (const struct GNUNET_HELLO_Address *address) | |||
480 | GNUNET_CONTAINER_multipeermap_remove (p2a, | 496 | GNUNET_CONTAINER_multipeermap_remove (p2a, |
481 | &address->peer, | 497 | &address->peer, |
482 | ai)); | 498 | ai)); |
499 | publish_p2a_stat_update (); | ||
483 | GNUNET_break (NULL == ai->session); | 500 | GNUNET_break (NULL == ai->session); |
484 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, | 501 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, |
485 | "transport-ats", | 502 | "transport-ats", |
@@ -518,6 +535,10 @@ destroy_ai (void *cls, | |||
518 | struct AddressInfo *ai = value; | 535 | struct AddressInfo *ai = value; |
519 | 536 | ||
520 | GNUNET_HELLO_address_free (ai->address); | 537 | GNUNET_HELLO_address_free (ai->address); |
538 | GNUNET_assert (GNUNET_YES == | ||
539 | GNUNET_CONTAINER_multipeermap_remove (p2a, | ||
540 | key, | ||
541 | ai)); | ||
521 | GNUNET_free (ai); | 542 | GNUNET_free (ai); |
522 | return GNUNET_OK; | 543 | return GNUNET_OK; |
523 | } | 544 | } |
@@ -532,6 +553,7 @@ GST_ats_done () | |||
532 | GNUNET_CONTAINER_multipeermap_iterate (p2a, | 553 | GNUNET_CONTAINER_multipeermap_iterate (p2a, |
533 | &destroy_ai, | 554 | &destroy_ai, |
534 | NULL); | 555 | NULL); |
556 | publish_p2a_stat_update (); | ||
535 | GNUNET_CONTAINER_multipeermap_destroy (p2a); | 557 | GNUNET_CONTAINER_multipeermap_destroy (p2a); |
536 | p2a = NULL; | 558 | p2a = NULL; |
537 | } | 559 | } |
diff --git a/src/transport/gnunet-service-transport_validation.c b/src/transport/gnunet-service-transport_validation.c index 7008d2df5..8dd8e1989 100644 --- a/src/transport/gnunet-service-transport_validation.c +++ b/src/transport/gnunet-service-transport_validation.c | |||
@@ -393,7 +393,8 @@ validation_entry_match (void *cls, | |||
393 | struct ValidationEntryMatchContext *vemc = cls; | 393 | struct ValidationEntryMatchContext *vemc = cls; |
394 | struct ValidationEntry *ve = value; | 394 | struct ValidationEntry *ve = value; |
395 | 395 | ||
396 | if (0 == GNUNET_HELLO_address_cmp (ve->address, vemc->address)) | 396 | if (0 == GNUNET_HELLO_address_cmp (ve->address, |
397 | vemc->address)) | ||
397 | { | 398 | { |
398 | vemc->ve = ve; | 399 | vemc->ve = ve; |
399 | return GNUNET_NO; | 400 | return GNUNET_NO; |
@@ -587,11 +588,15 @@ transmit_ping_if_allowed (void *cls, | |||
587 | /* build message with structure: | 588 | /* build message with structure: |
588 | * [HELLO][TransportPingMessage][Transport name][Address] */ | 589 | * [HELLO][TransportPingMessage][Transport name][Address] */ |
589 | memcpy (message_buf, hello, hsize); | 590 | memcpy (message_buf, hello, hsize); |
590 | memcpy (&message_buf[hsize], &ping, sizeof (struct TransportPingMessage)); | 591 | memcpy (&message_buf[hsize], |
592 | &ping, | ||
593 | sizeof (struct TransportPingMessage)); | ||
591 | memcpy (&message_buf[sizeof (struct TransportPingMessage) + hsize], | 594 | memcpy (&message_buf[sizeof (struct TransportPingMessage) + hsize], |
592 | ve->address->transport_name, slen); | 595 | ve->address->transport_name, |
596 | slen); | ||
593 | memcpy (&message_buf[sizeof (struct TransportPingMessage) + slen + hsize], | 597 | memcpy (&message_buf[sizeof (struct TransportPingMessage) + slen + hsize], |
594 | ve->address->address, ve->address->address_length); | 598 | ve->address->address, |
599 | ve->address->address_length); | ||
595 | papi = GST_plugins_find (ve->address->transport_name); | 600 | papi = GST_plugins_find (ve->address->transport_name); |
596 | if (NULL == papi) | 601 | if (NULL == papi) |
597 | { | 602 | { |
@@ -754,7 +759,8 @@ revalidate_address (void *cls, | |||
754 | GNUNET_STATISTICS_update (GST_stats, | 759 | GNUNET_STATISTICS_update (GST_stats, |
755 | gettext_noop ("# address revalidations started"), 1, | 760 | gettext_noop ("# address revalidations started"), 1, |
756 | GNUNET_NO); | 761 | GNUNET_NO); |
757 | bc = GST_blacklist_test_allowed (&ve->pid, ve->address->transport_name, | 762 | bc = GST_blacklist_test_allowed (&ve->pid, |
763 | ve->address->transport_name, | ||
758 | &transmit_ping_if_allowed, ve); | 764 | &transmit_ping_if_allowed, ve); |
759 | if (NULL != bc) | 765 | if (NULL != bc) |
760 | ve->bc = bc; /* only set 'bc' if 'transmit_ping_if_allowed' was not already | 766 | ve->bc = bc; /* only set 'bc' if 'transmit_ping_if_allowed' was not already |
@@ -1769,22 +1775,39 @@ struct ValidationIteratorContext | |||
1769 | }; | 1775 | }; |
1770 | 1776 | ||
1771 | 1777 | ||
1778 | /** | ||
1779 | * Function called on each entry in the validation map. | ||
1780 | * Passes the information from the validation entry to | ||
1781 | * the callback given in the closure. | ||
1782 | * | ||
1783 | * @param cls the `struct ValidationIteratorContext` | ||
1784 | * @param key peer this is about | ||
1785 | * @param value the `struct ValidationEntry` | ||
1786 | * @return #GNUNET_OK (continue to iterate) | ||
1787 | */ | ||
1772 | static int | 1788 | static int |
1773 | validation_entries_iterate (void *cls, | 1789 | validation_entries_iterate (void *cls, |
1774 | const struct GNUNET_PeerIdentity *key, | 1790 | const struct GNUNET_PeerIdentity *key, |
1775 | void *value) | 1791 | void *value) |
1776 | { | 1792 | { |
1777 | struct ValidationIteratorContext *ic = cls; | 1793 | struct ValidationIteratorContext *ic = cls; |
1778 | struct ValidationEntry *ve = value; | 1794 | struct ValidationEntry *ve = value; |
1779 | 1795 | ||
1780 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Notifying about validation entry for peer `%s' address `%s' \n", | 1796 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1781 | GNUNET_i2s (&ve->pid), GST_plugins_a2s (ve->address)); | 1797 | "Notifying about validation entry for peer `%s' address `%s' \n", |
1782 | ic->cb (ic->cb_cls, &ve->pid, ve->address, ve->send_time, | 1798 | GNUNET_i2s (&ve->pid), |
1783 | ve->valid_until, ve->next_validation, ve->state); | 1799 | GST_plugins_a2s (ve->address)); |
1784 | 1800 | ic->cb (ic->cb_cls, | |
1801 | &ve->pid, | ||
1802 | ve->address, | ||
1803 | ve->send_time, | ||
1804 | ve->valid_until, | ||
1805 | ve->next_validation, | ||
1806 | ve->state); | ||
1785 | return GNUNET_OK; | 1807 | return GNUNET_OK; |
1786 | } | 1808 | } |
1787 | 1809 | ||
1810 | |||
1788 | /** | 1811 | /** |
1789 | * Iterate over all iteration entries | 1812 | * Iterate over all iteration entries |
1790 | * | 1813 | * |