diff options
author | Mike Perry <mikeperry-git@fscked.org> | 2010-01-29 15:40:40 -0800 |
---|---|---|
committer | Mike Perry <mikeperry-git@fscked.org> | 2010-02-22 16:52:11 -0800 |
commit | df1ef2f0f0856af71d92d333bcf2c788c2938703 (patch) | |
tree | deceeb832a6138d652e9e6ef07f4e01a7675466b /src/or/networkstatus.c | |
parent | f9d40649fe24590463f6e607c6b4e3c757f3b05f (diff) | |
download | tor-df1ef2f0f0856af71d92d333bcf2c788c2938703.tar.gz tor-df1ef2f0f0856af71d92d333bcf2c788c2938703.zip |
Add parsing+verification for bw weight values.
Diffstat (limited to 'src/or/networkstatus.c')
-rw-r--r-- | src/or/networkstatus.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/or/networkstatus.c b/src/or/networkstatus.c index b5c84d0e61..d673ef6f7d 100644 --- a/src/or/networkstatus.c +++ b/src/or/networkstatus.c @@ -2074,6 +2074,23 @@ networkstatus_get_param(networkstatus_t *ns, const char *param_name, return get_net_param_from_list(ns->net_params, param_name, default_val); } +/** Return the value of a integer bw weight parameter from the networkstatus + * <b>ns</b> whose name is <b>weight_name</b>. If <b>ns</b> is NULL, try + * loading the latest consensus ourselves. Return <b>default_val</b> if no + * latest consensus, or if it has no parameter called <b>param_name</b>. */ +int32_t +networkstatus_get_bw_weight(networkstatus_t *ns, const char *weight_name, + int32_t default_val) +{ + if (!ns) /* if they pass in null, go find it ourselves */ + ns = networkstatus_get_latest_consensus(); + + if (!ns || !ns->weight_params) + return default_val; + + return get_net_param_from_list(ns->weight_params, weight_name, default_val); +} + /** Return the name of the consensus flavor <b>flav</b> as used to identify * the flavor in directory documents. */ const char * |