summaryrefslogtreecommitdiff
path: root/src/or/protover.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2016-08-26 12:49:00 -0400
committerNick Mathewson <nickm@torproject.org>2016-09-26 10:56:51 -0700
commite525f5697f9a0682b2cc24fa9779ebe9f0f3c233 (patch)
tree82d48a2023146861c13c04260faba130f2e7f996 /src/or/protover.c
parent90a6fe318cfae4d64fff034574153b8c96895a6c (diff)
downloadtor-e525f5697f9a0682b2cc24fa9779ebe9f0f3c233.tar.gz
tor-e525f5697f9a0682b2cc24fa9779ebe9f0f3c233.zip
Use protocols to see when EXTEND2 support exists.
(Technically, we could just remove extend2 cell checking entirely, since all Tor versions on our network are required to have it, but let's keep this around as an example of How To Do It.)
Diffstat (limited to 'src/or/protover.c')
-rw-r--r--src/or/protover.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/or/protover.c b/src/or/protover.c
index 7feec0c5c7..ca03a71acd 100644
--- a/src/or/protover.c
+++ b/src/or/protover.c
@@ -235,6 +235,28 @@ protover_is_supported_here(protocol_type_t pr, uint32_t ver)
return protocol_list_contains(ours, pr, ver);
}
+/**
+ * Return true iff "list" encodes a protocol list that includes support for
+ * the indicated protocol and version.
+ */
+int
+protocol_list_supports_protocol(const char *list, protocol_type_t tp,
+ uint32_t version)
+{
+ /* NOTE: This is a pretty inefficient implementation. If it ever shows
+ * up in profiles, we should memoize it.
+ */
+ smartlist_t *protocols = parse_protocol_list(list);
+ if (!protocols) {
+ return 0;
+ }
+ int contains = protocol_list_contains(protocols, tp, version);
+
+ SMARTLIST_FOREACH(protocols, proto_entry_t *, ent, proto_entry_free(ent));
+ smartlist_free(protocols);
+ return contains;
+}
+
/** Return the canonical string containing the list of protocols
* that we support. */
const char *