summaryrefslogtreecommitdiff
path: root/src/or/or.h
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2008-12-17 21:50:01 +0000
committerNick Mathewson <nickm@torproject.org>2008-12-17 21:50:01 +0000
commit33e2053ebca5d3152c401f1394adeaab862b1988 (patch)
tree9f3e064f19cbea4ab8e80d2361f96d3035173fdd /src/or/or.h
parent43393b4b33b12e03e38da55da2ac4a38a13c4af8 (diff)
downloadtor-33e2053ebca5d3152c401f1394adeaab862b1988.tar.gz
tor-33e2053ebca5d3152c401f1394adeaab862b1988.zip
Make return code from router_add_to_routerlist a nice sensible enum. Based on patch from Sebastian.
svn:r17656
Diffstat (limited to 'src/or/or.h')
-rw-r--r--src/or/or.h43
1 files changed, 39 insertions, 4 deletions
diff --git a/src/or/or.h b/src/or/or.h
index cf782f8b1a..0e5ea4e0fd 100644
--- a/src/or/or.h
+++ b/src/or/or.h
@@ -3410,10 +3410,12 @@ int dirserv_add_own_fingerprint(const char *nickname, crypto_pk_env_t *pk);
int dirserv_load_fingerprint_file(void);
void dirserv_free_fingerprint_list(void);
const char *dirserv_get_nickname_by_digest(const char *digest);
-int dirserv_add_multiple_descriptors(const char *desc, uint8_t purpose,
+enum was_router_added_t dirserv_add_multiple_descriptors(
+ const char *desc, uint8_t purpose,
const char *source,
const char **msg);
-int dirserv_add_descriptor(routerinfo_t *ri, const char **msg);
+enum was_router_added_t dirserv_add_descriptor(routerinfo_t *ri,
+ const char **msg);
int getinfo_helper_dirserv_unregistered(control_connection_t *conn,
const char *question, char **answer);
void dirserv_free_descriptors(void);
@@ -4388,8 +4390,41 @@ void routerlist_remove(routerlist_t *rl, routerinfo_t *ri, int make_old);
void routerlist_free_all(void);
void routerlist_reset_warnings(void);
void router_set_status(const char *digest, int up);
-int router_add_to_routerlist(routerinfo_t *router, const char **msg,
- int from_cache, int from_fetch);
+
+/** Return value for router_add_to_routerlist() and dirserv_add_descriptor() */
+typedef enum was_router_added_t {
+ ROUTER_ADDED_SUCCESSFULLY = 0,
+ ROUTER_ADDED_NOTIFY_GENERATOR = 1,
+ ROUTER_WAS_NOT_NEW = -1,
+ ROUTER_NOT_IN_CONSENSUS = -2,
+ ROUTER_NOT_IN_CONSENSUS_OR_NETWORKSTATUS = -3,
+ ROUTER_AUTHDIR_REJECTS = -4,
+} was_router_added_t;
+
+static int WRA_WAS_ADDED(was_router_added_t s);
+static int WRA_WAS_OUTDATED(was_router_added_t s);
+static int WRA_WAS_REJECTED(was_router_added_t s);
+/**DOCDOC*/
+static INLINE int
+WRA_WAS_ADDED(was_router_added_t s) {
+ return s == ROUTER_ADDED_SUCCESSFULLY || s == ROUTER_ADDED_NOTIFY_GENERATOR;
+}
+/**DOCDOC*/
+static INLINE int WRA_WAS_OUTDATED(was_router_added_t s)
+{
+ return (s == ROUTER_WAS_NOT_NEW ||
+ s == ROUTER_NOT_IN_CONSENSUS ||
+ s == ROUTER_NOT_IN_CONSENSUS_OR_NETWORKSTATUS);
+}
+/**DOCDOC*/
+static INLINE int WRA_WAS_REJECTED(was_router_added_t s)
+{
+ return (s == ROUTER_AUTHDIR_REJECTS);
+}
+was_router_added_t router_add_to_routerlist(routerinfo_t *router,
+ const char **msg,
+ int from_cache,
+ int from_fetch);
int router_add_extrainfo_to_routerlist(extrainfo_t *ei, const char **msg,
int from_cache, int from_fetch);
void routerlist_remove_old_routers(void);