Tor
0.4.7.0-alpha-dev
|
Code to manipulate, parse, and compare Tor versions. More...
#include "core/or/or.h"
#include "core/or/protover.h"
#include "core/or/versions.h"
#include "lib/crypt_ops/crypto_util.h"
#include "core/or/tor_version_st.h"
Go to the source code of this file.
Macros | |
#define | NUMBER(m) |
#define | DOT() |
#define | CMP(field) |
Functions | |
time_t | tor_get_approx_release_date (void) |
version_status_t | tor_version_is_obsolete (const char *myversion, const char *versionlist) |
int | tor_version_parse_platform (const char *platform, tor_version_t *router_version, int strict) |
int | tor_version_as_new_as (const char *platform, const char *cutoff) |
int | tor_version_parse (const char *s, tor_version_t *out) |
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) |
static int | compare_tor_version_str_ptr_ (const void **_a, const void **_b) |
void | sort_version_list (smartlist_t *versions, int remove_duplicates) |
static void | memoize_protover_summary (protover_summary_flags_t *out, const char *protocols) |
void | summarize_protover_flags (protover_summary_flags_t *out, const char *protocols, const char *version) |
void | protover_summary_cache_free_all (void) |
Variables | |
static const int | MAX_PROTOVER_SUMMARY_MAP_LEN = 1024 |
static strmap_t * | protover_summary_map = NULL |
Code to manipulate, parse, and compare Tor versions.
Definition in file versions.c.
#define CMP | ( | field | ) |
#define DOT | ( | ) |
#define NUMBER | ( | m | ) |
|
static |
Helper: Given pointers to two strings describing tor versions, return -1 if _a precedes _b, 1 if _b precedes _a, and 0 if they are equivalent. Used to sort a list of versions.
Definition at line 369 of file versions.c.
Referenced by sort_version_list().
|
static |
Helper. Given a non-NULL protover string protocols, set out to its summary, and memoize the result in protover_summary_map.
If the protover string does not contain any recognised protocols, sets protocols_known, but does not set any other flags. (Empty strings are also treated this way.)
Definition at line 417 of file versions.c.
Referenced by summarize_protover_flags().
void protover_summary_cache_free_all | ( | void | ) |
Free all space held in the protover_summary_map.
Definition at line 531 of file versions.c.
Referenced by memoize_protover_summary().
void sort_version_list | ( | smartlist_t * | versions, |
int | remove_duplicates | ||
) |
Sort a list of string-representations of versions in ascending order.
Definition at line 391 of file versions.c.
void summarize_protover_flags | ( | protover_summary_flags_t * | out, |
const char * | protocols, | ||
const char * | version | ||
) |
Summarize the protocols listed in protocols into out, falling back or correcting them based on version as appropriate.
If protocols and version are both NULL or "", returns a summary with no flags set.
If the protover string does not contain any recognised protocols, and the version is not recognised, sets protocols_known, but does not set any other flags. (Empty strings are also treated this way.)
Definition at line 501 of file versions.c.
time_t tor_get_approx_release_date | ( | void | ) |
Return the approximate date when this release came out, or was scheduled to come out, according to the APPROX_RELEASE_DATE set in configure.ac
Definition at line 25 of file versions.c.
Referenced by networkstatus_check_required_protocols().
int tor_version_as_new_as | ( | const char * | platform, |
const char * | cutoff | ||
) |
Parse the Tor version of the platform string platform, and compare it to the version in cutoff. Return 1 if the router is at least as new as the cutoff, else return 0.
Definition at line 171 of file versions.c.
Referenced by dirserv_rejects_tor_version(), protover_compute_for_old_tor(), and summarize_protover_flags().
int tor_version_compare | ( | tor_version_t * | a, |
tor_version_t * | b | ||
) |
Compare two tor versions; Return <0 if a < b; 0 if a ==b, >0 if a > b.
Definition at line 315 of file versions.c.
Referenced by compare_tor_version_str_ptr_().
version_status_t tor_version_is_obsolete | ( | const char * | myversion, |
const char * | versionlist | ||
) |
Return VS_RECOMMENDED if myversion is contained in versionlist. Else, return VS_EMPTY if versionlist has no entries. Else, return VS_OLD if every member of versionlist is newer than myversion. Else, return VS_NEW_IN_SERIES if there is at least one member of versionlist in the same series (major.minor.micro) as myversion, but no such member is newer than myversion.. Else, return VS_NEW if every member of versionlist is older than myversion. Else, return VS_UNRECOMMENDED.
(versionlist is a comma-separated list of version strings, optionally prefixed with "Tor". Versions that can't be parsed are ignored.)
Definition at line 53 of file versions.c.
int tor_version_parse | ( | const char * | s, |
tor_version_t * | out | ||
) |
Parse a tor version from s, and store the result in out. Return 0 on success, -1 on failure.
Definition at line 206 of file versions.c.
Referenced by compare_tor_version_str_ptr_(), and tor_version_as_new_as().
int tor_version_parse_platform | ( | const char * | platform, |
tor_version_t * | router_version, | ||
int | strict | ||
) |
Extract a Tor version from a platform line from a router descriptor, and place the result in router_version.
Return 1 on success, -1 on parsing failure, and 0 if the platform line does not indicate some version of Tor.
If strict is non-zero, finding any weird version components (like negative numbers) counts as a parsing failure.
Definition at line 127 of file versions.c.
int tor_version_same_series | ( | tor_version_t * | a, |
tor_version_t * | b | ||
) |
Return true iff versions a and b belong to the same series.
Definition at line 356 of file versions.c.
|
static |
If there are more than this many entries, we're probably under some kind of weird DoS.
Definition at line 401 of file versions.c.
Referenced by memoize_protover_summary().
|
static |
Map from protover string to protover_summary_flags_t.
Definition at line 406 of file versions.c.
Referenced by memoize_protover_summary().