Merge branch 'maint-0.2.5' into maint-0.2.6
[tor.git] / src / or / rendcommon.h
blob8396cc3551486585679babd4e43fb95595fc441a
1 /* Copyright (c) 2001 Matej Pfajfar.
2 * Copyright (c) 2001-2004, Roger Dingledine.
3 * Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
4 * Copyright (c) 2007-2015, The Tor Project, Inc. */
5 /* See LICENSE for licensing information */
7 /**
8 * \file rendcommon.h
9 * \brief Header file for rendcommon.c.
10 **/
12 #ifndef TOR_RENDCOMMON_H
13 #define TOR_RENDCOMMON_H
15 /** Free all storage associated with <b>data</b> */
16 static INLINE void
17 rend_data_free(rend_data_t *data)
19 tor_free(data);
22 int rend_cmp_service_ids(const char *one, const char *two);
24 void rend_process_relay_cell(circuit_t *circ, const crypt_path_t *layer_hint,
25 int command, size_t length,
26 const uint8_t *payload);
28 void rend_service_descriptor_free(rend_service_descriptor_t *desc);
29 int rend_get_service_id(crypto_pk_t *pk, char *out);
30 void rend_encoded_v2_service_descriptor_free(
31 rend_encoded_v2_service_descriptor_t *desc);
32 void rend_intro_point_free(rend_intro_point_t *intro);
34 void rend_cache_init(void);
35 void rend_cache_clean(time_t now);
36 void rend_cache_clean_v2_descs_as_dir(time_t now, size_t min_to_remove);
37 void rend_cache_purge(void);
38 void rend_cache_free_all(void);
39 int rend_valid_service_id(const char *query);
40 int rend_cache_lookup_entry(const char *query, int version,
41 rend_cache_entry_t **entry_out);
42 int rend_cache_lookup_v2_desc_as_dir(const char *query, const char **desc);
43 /** Return value from rend_cache_store_v2_desc_as_{dir,client}. */
44 typedef enum {
45 RCS_NOTDIR = -2, /**< We're not a directory */
46 RCS_BADDESC = -1, /**< This descriptor is no good. */
47 RCS_OKAY = 0 /**< All worked as expected */
48 } rend_cache_store_status_t;
50 rend_cache_store_status_t rend_cache_store_v2_desc_as_dir(const char *desc);
51 rend_cache_store_status_t rend_cache_store_v2_desc_as_client(const char *desc,
52 const char *desc_id_base32,
53 const rend_data_t *rend_query);
54 int rend_encode_v2_descriptors(smartlist_t *descs_out,
55 rend_service_descriptor_t *desc, time_t now,
56 uint8_t period, rend_auth_type_t auth_type,
57 crypto_pk_t *client_key,
58 smartlist_t *client_cookies);
59 int rend_compute_v2_desc_id(char *desc_id_out, const char *service_id,
60 const char *descriptor_cookie,
61 time_t now, uint8_t replica);
62 int rend_id_is_in_interval(const char *a, const char *b, const char *c);
63 void rend_get_descriptor_id_bytes(char *descriptor_id_out,
64 const char *service_id,
65 const char *secret_id_part);
66 size_t rend_cache_get_total_allocation(void);
68 #endif