aboutsummaryrefslogtreecommitdiff
path: root/src/or/hs_descriptor.c
diff options
context:
space:
mode:
authorDavid Goulet <dgoulet@ev0ke.net>2016-03-29 15:08:04 -0400
committerDavid Goulet <dgoulet@torproject.org>2016-11-04 10:31:35 -0400
commit025610612d78fe0a0ec95dd88c3d44e4bf643603 (patch)
tree165a149fe0534bb58711aa61c4b2c622e7c87b25 /src/or/hs_descriptor.c
parent473f99bf7bdb7d23b914cd1b590451333baaf7fe (diff)
downloadtor-025610612d78fe0a0ec95dd88c3d44e4bf643603.tar.gz
tor-025610612d78fe0a0ec95dd88c3d44e4bf643603.zip
prop224: Directory cache support
This implements the proposal 224 directory descriptor cache store and lookup functionalities. Furthermore, it merges the OOM call for the HSDir cache with current protocol v2 and the new upcoming v3. Add hs_cache.{c|h} with store/lookup API. Closes #18572 Signed-off-by: David Goulet <dgoulet@torproject.org> Signed-off-by: George Kadianakis <desnacked@riseup.net>
Diffstat (limited to 'src/or/hs_descriptor.c')
-rw-r--r--src/or/hs_descriptor.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/or/hs_descriptor.c b/src/or/hs_descriptor.c
index cdbea76605..9714d52f8c 100644
--- a/src/or/hs_descriptor.c
+++ b/src/or/hs_descriptor.c
@@ -1918,3 +1918,15 @@ hs_descriptor_free(hs_descriptor_t *desc)
desc_encrypted_data_free_contents(&desc->encrypted_data);
tor_free(desc);
}
+
+/* Return the size in bytes of the given plaintext data object. A sizeof() is
+ * not enough because the object contains pointers and the encrypted blob.
+ * This is particularly useful for our OOM subsystem that tracks the HSDir
+ * cache size for instance. */
+size_t
+hs_desc_plaintext_obj_size(const hs_desc_plaintext_data_t *data)
+{
+ tor_assert(data);
+ return (sizeof(*data) + sizeof(*data->signing_key_cert) +
+ data->encrypted_blob_size);
+}