]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
Use an enum for INTRO_POINT_FAILURE_*
authorDavid Goulet <dgoulet@ev0ke.net>
Thu, 25 Jun 2015 20:13:15 +0000 (16:13 -0400)
committerNick Mathewson <nickm@torproject.org>
Tue, 11 Aug 2015 13:34:41 +0000 (09:34 -0400)
Safer, wiser, stronger!

Signed-off-by: David Goulet <dgoulet@ev0ke.net>
src/or/rendcache.c
src/or/rendcache.h
src/or/rendclient.h
src/or/rendcommon.h

index acb9447de8acfc21d322e4b6025aa71ae8f964cb..8f3ddf5585ae32e850ea464bcdc6d2df4d3e5d3e 100644 (file)
@@ -125,7 +125,7 @@ rend_cache_failure_intro_entry_free(rend_cache_failure_intro_t *entry)
 /** Allocate a rend cache failure intro object and return it. <b>failure</b>
  * is set into the object. This function can not fail. */
 static rend_cache_failure_intro_t *
-rend_cache_failure_intro_entry_new(unsigned int failure)
+rend_cache_failure_intro_entry_new(rend_intro_point_failure_t failure)
 {
   rend_cache_failure_intro_t *entry = tor_malloc(sizeof(*entry));
   entry->failure_type = failure;
@@ -309,7 +309,7 @@ not_found:
  * <b>failure</b> in that object. */
 static void
 cache_failure_intro_add(const uint8_t *identity, const char *service_id,
-                        unsigned int failure)
+                        rend_intro_point_failure_t failure)
 {
   rend_cache_failure_t *fail_entry;
   rend_cache_failure_intro_t *entry;
@@ -376,7 +376,8 @@ validate_intro_point_failure(const rend_service_descriptor_t *desc,
  * <b>identity</b> and service ID <b>service_id</b>. If an entry already
  * exists in the cache, the failure type is changed with <b>failure</b>. */
 void
-rend_cache_intro_failure_note(unsigned int failure, const uint8_t *identity,
+rend_cache_intro_failure_note(rend_intro_point_failure_t failure,
+                              const uint8_t *identity,
                               const char *service_id)
 {
   int found;
index 9a18810821a21068b68dba18d554dc6c5e44b10b..b214a48ccc87f6e202a596857df08923b8d31ce5 100644 (file)
@@ -34,7 +34,7 @@ typedef struct rend_cache_entry_t {
 
 /* Introduction point failure type. */
 typedef struct rend_cache_failure_intro_t {
-  unsigned int failure_type;
+  rend_intro_point_failure_t failure_type;
 } rend_cache_failure_intro_t;
 
 /** Cache failure object indexed by service ID. */
@@ -65,7 +65,7 @@ rend_cache_store_status_t rend_cache_store_v2_desc_as_client(const char *desc,
                                                 rend_cache_entry_t **entry);
 size_t rend_cache_get_total_allocation(void);
 
-void rend_cache_intro_failure_note(unsigned int failure,
+void rend_cache_intro_failure_note(rend_intro_point_failure_t failure,
                                    const uint8_t *identity,
                                    const char *service_id);
 void rend_cache_failure_purge(void);
index 439f42875bf3452f793dd9566b46b6e312f4d21b..124433ef31a11623f0e90d3ddbbefab662574acf 100644 (file)
@@ -26,10 +26,6 @@ int rend_client_fetch_v2_desc(rend_data_t *query, smartlist_t *hsdirs);
 void rend_client_cancel_descriptor_fetches(void);
 void rend_client_purge_last_hid_serv_requests(void);
 
-#define INTRO_POINT_FAILURE_GENERIC 0
-#define INTRO_POINT_FAILURE_TIMEOUT 1
-#define INTRO_POINT_FAILURE_UNREACHABLE 2
-
 int rend_client_report_intro_point_failure(extend_info_t *failed_intro,
                                            rend_data_t *rend_query,
                                            unsigned int failure_type);
index ba5e0776422983cc222c96d034ad74c98d9c11cd..3b2f86d6147730f76856be065d07e82c4a104674 100644 (file)
 #ifndef TOR_RENDCOMMON_H
 #define TOR_RENDCOMMON_H
 
+typedef enum rend_intro_point_failure_t {
+  INTRO_POINT_FAILURE_GENERIC     = 0,
+  INTRO_POINT_FAILURE_TIMEOUT     = 1,
+  INTRO_POINT_FAILURE_UNREACHABLE = 2,
+} rend_intro_point_failure_t;
+
 /** Free all storage associated with <b>data</b> */
 static INLINE void
 rend_data_free(rend_data_t *data)