[tor-commits] [tor/master] Move summarize_protover_flags to versions.c

nickm at torproject.org nickm at torproject.org
Fri Oct 12 15:39:44 UTC 2018


commit 95e2eb9083d2cd9c79c3f4151850c86cbeaf4cc4
Author: Nick Mathewson <nickm at torproject.org>
Date:   Mon Oct 1 10:48:55 2018 -0500

    Move summarize_protover_flags to versions.c
---
 src/core/or/versions.c             | 45 ++++++++++++++++++++++++++++++++++++++
 src/core/or/versions.h             |  4 ++++
 src/feature/dirparse/routerparse.c | 44 -------------------------------------
 src/feature/dirparse/routerparse.h |  4 ----
 4 files changed, 49 insertions(+), 48 deletions(-)

diff --git a/src/core/or/versions.c b/src/core/or/versions.c
index 2d2486298..06274996a 100644
--- a/src/core/or/versions.c
+++ b/src/core/or/versions.c
@@ -10,6 +10,7 @@
  */
 #include "core/or/or.h"
 
+#include "core/or/protover.h"
 #include "core/or/versions.h"
 #include "lib/crypt_ops/crypto_util.h"
 
@@ -375,3 +376,47 @@ sort_version_list(smartlist_t *versions, int remove_duplicates)
   if (remove_duplicates)
     smartlist_uniq(versions, compare_tor_version_str_ptr_, tor_free_);
 }
+
+/** Summarize the protocols listed in <b>protocols</b> into <b>out</b>,
+ * falling back or correcting them based on <b>version</b> as appropriate.
+ */
+void
+summarize_protover_flags(protover_summary_flags_t *out,
+                         const char *protocols,
+                         const char *version)
+{
+  tor_assert(out);
+  memset(out, 0, sizeof(*out));
+  if (protocols) {
+    out->protocols_known = 1;
+    out->supports_extend2_cells =
+      protocol_list_supports_protocol(protocols, PRT_RELAY, 2);
+    out->supports_ed25519_link_handshake_compat =
+      protocol_list_supports_protocol(protocols, PRT_LINKAUTH, 3);
+    out->supports_ed25519_link_handshake_any =
+      protocol_list_supports_protocol_or_later(protocols, PRT_LINKAUTH, 3);
+    out->supports_ed25519_hs_intro =
+      protocol_list_supports_protocol(protocols, PRT_HSINTRO, 4);
+    out->supports_v3_hsdir =
+      protocol_list_supports_protocol(protocols, PRT_HSDIR,
+                                      PROTOVER_HSDIR_V3);
+    out->supports_v3_rendezvous_point =
+      protocol_list_supports_protocol(protocols, PRT_HSREND,
+                                      PROTOVER_HS_RENDEZVOUS_POINT_V3);
+  }
+  if (version && !strcmpstart(version, "Tor ")) {
+    if (!out->protocols_known) {
+      /* The version is a "Tor" version, and where there is no
+       * list of protocol versions that we should be looking at instead. */
+
+      out->supports_extend2_cells =
+        tor_version_as_new_as(version, "0.2.4.8-alpha");
+      out->protocols_known = 1;
+    } else {
+      /* Bug #22447 forces us to filter on this version. */
+      if (!tor_version_as_new_as(version, "0.3.0.8")) {
+        out->supports_v3_hsdir = 0;
+      }
+    }
+  }
+}
diff --git a/src/core/or/versions.h b/src/core/or/versions.h
index a2353bcae..0c773f3f4 100644
--- a/src/core/or/versions.h
+++ b/src/core/or/versions.h
@@ -37,4 +37,8 @@ int tor_version_compare(tor_version_t *a, tor_version_t *b);
 int tor_version_same_series(tor_version_t *a, tor_version_t *b);
 void sort_version_list(smartlist_t *lst, int remove_duplicates);
 
+void summarize_protover_flags(protover_summary_flags_t *out,
+                              const char *protocols,
+                              const char *version);
+
 #endif /* !defined(TOR_VERSIONS_H) */
diff --git a/src/feature/dirparse/routerparse.c b/src/feature/dirparse/routerparse.c
index 956e8f3ea..0e9773564 100644
--- a/src/feature/dirparse/routerparse.c
+++ b/src/feature/dirparse/routerparse.c
@@ -1201,50 +1201,6 @@ extrainfo_parse_entry_from_string(const char *s, const char *end,
   return extrainfo;
 }
 
-/** Summarize the protocols listed in <b>protocols</b> into <b>out</b>,
- * falling back or correcting them based on <b>version</b> as appropriate.
- */
-void
-summarize_protover_flags(protover_summary_flags_t *out,
-                         const char *protocols,
-                         const char *version)
-{
-  tor_assert(out);
-  memset(out, 0, sizeof(*out));
-  if (protocols) {
-    out->protocols_known = 1;
-    out->supports_extend2_cells =
-      protocol_list_supports_protocol(protocols, PRT_RELAY, 2);
-    out->supports_ed25519_link_handshake_compat =
-      protocol_list_supports_protocol(protocols, PRT_LINKAUTH, 3);
-    out->supports_ed25519_link_handshake_any =
-      protocol_list_supports_protocol_or_later(protocols, PRT_LINKAUTH, 3);
-    out->supports_ed25519_hs_intro =
-      protocol_list_supports_protocol(protocols, PRT_HSINTRO, 4);
-    out->supports_v3_hsdir =
-      protocol_list_supports_protocol(protocols, PRT_HSDIR,
-                                      PROTOVER_HSDIR_V3);
-    out->supports_v3_rendezvous_point =
-      protocol_list_supports_protocol(protocols, PRT_HSREND,
-                                      PROTOVER_HS_RENDEZVOUS_POINT_V3);
-  }
-  if (version && !strcmpstart(version, "Tor ")) {
-    if (!out->protocols_known) {
-      /* The version is a "Tor" version, and where there is no
-       * list of protocol versions that we should be looking at instead. */
-
-      out->supports_extend2_cells =
-        tor_version_as_new_as(version, "0.2.4.8-alpha");
-      out->protocols_known = 1;
-    } else {
-      /* Bug #22447 forces us to filter on this version. */
-      if (!tor_version_as_new_as(version, "0.3.0.8")) {
-        out->supports_v3_hsdir = 0;
-      }
-    }
-  }
-}
-
 /** Parse the addr policy in the string <b>s</b> and return it.  If
  * assume_action is nonnegative, then insert its action (ADDR_POLICY_ACCEPT or
  * ADDR_POLICY_REJECT) for items that specify no action.
diff --git a/src/feature/dirparse/routerparse.h b/src/feature/dirparse/routerparse.h
index 80c974e06..72f812ee4 100644
--- a/src/feature/dirparse/routerparse.h
+++ b/src/feature/dirparse/routerparse.h
@@ -44,10 +44,6 @@ int find_single_ipv6_orport(const smartlist_t *list,
 void routerparse_init(void);
 void routerparse_free_all(void);
 
-void summarize_protover_flags(protover_summary_flags_t *out,
-                                    const char *protocols,
-                                     const char *version);
-
 #define ED_DESC_SIGNATURE_PREFIX "Tor router descriptor signature v1"
 
 #endif /* !defined(TOR_ROUTERPARSE_H) */





More information about the tor-commits mailing list