diff options
author | Nick Mathewson <nickm@torproject.org> | 2016-11-14 11:41:37 -0500 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2016-11-30 14:42:52 -0500 |
commit | 22f2f13f81407cffd46d5b17eca4bcead347fe58 (patch) | |
tree | 75f66d34b6951af5e1e6f0cf89a51475ef649cd2 /src/or/entrynodes.h | |
parent | 4614f8e6816d559f8fbe9ae0f42d751d3fb95c77 (diff) | |
download | tor-22f2f13f81407cffd46d5b17eca4bcead347fe58.tar.gz tor-22f2f13f81407cffd46d5b17eca4bcead347fe58.zip |
prop271: make entry_guard_t mostly-private
The entry_guard_t structure should really be opaque, so that we
can change its contents and have the rest of Tor not care.
This commit makes it "mostly opaque" -- circpathbias.c can still see
inside it. (I'm making circpathbias.c exempt since it's the only
part of Tor outside of entrynodes.c that made serious use of
entry_guard_t internals.)
Diffstat (limited to 'src/or/entrynodes.h')
-rw-r--r-- | src/or/entrynodes.h | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/src/or/entrynodes.h b/src/or/entrynodes.h index 00f96916b6..7f5a9110c9 100644 --- a/src/or/entrynodes.h +++ b/src/or/entrynodes.h @@ -12,18 +12,18 @@ #ifndef TOR_ENTRYNODES_H #define TOR_ENTRYNODES_H -#if 1 -/* XXXX NM I would prefer that all of this stuff be private to - * entrynodes.c. */ - /* Forward declare for guard_selection_t; entrynodes.c has the real struct */ typedef struct guard_selection_s guard_selection_t; +/* Forward declare for entry_guard_t; the real declaration is private. */ +typedef struct entry_guard_t entry_guard_t; + +#if defined(ENTRYNODES_PRIVATE) || defined(ENTRYNODES_EXPOSE_STRUCT) /** An entry_guard_t represents our information about a chosen long-term * first hop, known as a "helper" node in the literature. We can't just * use a node_t, since we want to remember these even when we * don't have any directory info. */ -typedef struct entry_guard_t { +struct entry_guard_t { char nickname[MAX_NICKNAME_LEN+1]; char identity[DIGEST_LEN]; time_t chosen_on_date; /**< Approximately when was this guard added? @@ -80,8 +80,12 @@ typedef struct entry_guard_t { double use_successes; /**< Number of successfully used circuits using * this guard as first hop. */ /**@}*/ -} entry_guard_t; +}; +#endif +#if 1 +/* XXXX NM I would prefer that all of this stuff be private to + * entrynodes.c. */ entry_guard_t *entry_guard_get_by_id_digest_for_guard_selection( guard_selection_t *gs, const char *digest); entry_guard_t *entry_guard_get_by_id_digest(const char *digest); @@ -98,6 +102,8 @@ int num_live_entry_guards(int for_directory); #endif +const node_t *entry_guard_find_node(const entry_guard_t *guard); + #ifdef ENTRYNODES_PRIVATE STATIC const node_t *add_an_entry_guard(guard_selection_t *gs, const node_t *chosen, |