aboutsummaryrefslogtreecommitdiff
path: root/src/or/routerparse.c
diff options
context:
space:
mode:
authorRoger Dingledine <arma@torproject.org>2006-02-13 10:33:00 +0000
committerRoger Dingledine <arma@torproject.org>2006-02-13 10:33:00 +0000
commit259c65ab08a4a88e310097cd5df155d62ea22447 (patch)
treedf8c85eeb34952fc4590d37770d15b69d58aaaf9 /src/or/routerparse.c
parentaa63a84fe10a32c33dac183517e8c41b7494a128 (diff)
downloadtor-259c65ab08a4a88e310097cd5df155d62ea22447.tar
tor-259c65ab08a4a88e310097cd5df155d62ea22447.tar.gz
the last of the log convention conversion. finally.
svn:r6005
Diffstat (limited to 'src/or/routerparse.c')
-rw-r--r--src/or/routerparse.c244
1 files changed, 126 insertions, 118 deletions
diff --git a/src/or/routerparse.c b/src/or/routerparse.c
index a5abae3fd..4bdd1ce06 100644
--- a/src/or/routerparse.c
+++ b/src/or/routerparse.c
@@ -223,7 +223,7 @@ router_append_dirobj_signature(char *buf, size_t buf_len, const char *digest,
if (crypto_pk_private_sign(private_key, signature, digest, DIGEST_LEN) < 0) {
- warn(LD_BUG,"Couldn't sign digest.");
+ log_warn(LD_BUG,"Couldn't sign digest.");
return -1;
}
if (strlcat(buf, "-----BEGIN SIGNATURE-----\n", buf_len) >= buf_len)
@@ -231,7 +231,7 @@ router_append_dirobj_signature(char *buf, size_t buf_len, const char *digest,
i = strlen(buf);
if (base64_encode(buf+i, buf_len-i, signature, 128) < 0) {
- warn(LD_BUG,"couldn't base64-encode signature");
+ log_warn(LD_BUG,"couldn't base64-encode signature");
tor_free(buf);
return -1;
}
@@ -241,7 +241,7 @@ router_append_dirobj_signature(char *buf, size_t buf_len, const char *digest,
return 0;
truncated:
- warn(LD_BUG,"tried to exceed string length.");
+ log_warn(LD_BUG,"tried to exceed string length.");
return -1;
}
@@ -270,11 +270,11 @@ tor_version_is_obsolete(const char *myversion, const char *versionlist)
vl = versionlist;
- debug(LD_CONFIG,"Checking whether version '%s' is in '%s'",
- myversion, versionlist);
+ log_debug(LD_CONFIG,"Checking whether version '%s' is in '%s'",
+ myversion, versionlist);
if (tor_version_parse(myversion, &mine)) {
- err(LD_BUG,"I couldn't parse my own version (%s)", myversion);
+ log_err(LD_BUG,"I couldn't parse my own version (%s)", myversion);
tor_assert(0);
}
version_sl = smartlist_create();
@@ -370,29 +370,29 @@ router_parse_directory(const char *str)
* touch it. */
if (router_get_dir_hash(str, digest)) {
- warn(LD_DIR, "Unable to compute digest of directory");
+ log_warn(LD_DIR, "Unable to compute digest of directory");
goto err;
}
- debug(LD_DIR,"Received directory hashes to %s",hex_str(digest,4));
+ log_debug(LD_DIR,"Received directory hashes to %s",hex_str(digest,4));
/* Check signature first, before we try to tokenize. */
cp = str;
while (cp && (end = strstr(cp+1, "\ndirectory-signature")))
cp = end;
if (cp == str || !cp) {
- warn(LD_DIR, "No signature found on directory."); goto err;
+ log_warn(LD_DIR, "No signature found on directory."); goto err;
}
++cp;
tokens = smartlist_create();
if (tokenize_string(cp,strchr(cp,'\0'),tokens,DIR)) {
- warn(LD_DIR, "Error tokenizing directory signature"); goto err;
+ log_warn(LD_DIR, "Error tokenizing directory signature"); goto err;
}
if (smartlist_len(tokens) != 1) {
- warn(LD_DIR, "Unexpected number of tokens in signature"); goto err;
+ log_warn(LD_DIR, "Unexpected number of tokens in signature"); goto err;
}
tok=smartlist_get(tokens,0);
if (tok->tp != K_DIRECTORY_SIGNATURE) {
- warn(LD_DIR,"Expected a single directory signature"); goto err;
+ log_warn(LD_DIR,"Expected a single directory signature"); goto err;
}
declared_key = find_dir_signing_key(str);
if (check_directory_signature(digest, tok, NULL, declared_key, 1)<0)
@@ -413,11 +413,11 @@ router_parse_directory(const char *str)
tokens = smartlist_create();
if (tokenize_string(str,end,tokens,DIR)) {
- warn(LD_DIR, "Error tokenizing directory"); goto err;
+ log_warn(LD_DIR, "Error tokenizing directory"); goto err;
}
if (!(tok = find_first_by_keyword(tokens, K_PUBLISHED))) {
- warn(LD_DIR, "Missing published time on directory.");
+ log_warn(LD_DIR, "Missing published time on directory.");
goto err;
}
tor_assert(tok->n_args == 1);
@@ -458,26 +458,26 @@ router_parse_runningrouters(const char *str)
smartlist_t *tokens = NULL;
if (router_get_runningrouters_hash(str, digest)) {
- warn(LD_DIR, "Unable to compute digest of directory");
+ log_warn(LD_DIR, "Unable to compute digest of directory");
goto err;
}
tokens = smartlist_create();
if (tokenize_string(str,str+strlen(str),tokens,DIR)) {
- warn(LD_DIR, "Error tokenizing directory"); goto err;
+ log_warn(LD_DIR, "Error tokenizing directory"); goto err;
}
if ((tok = find_first_by_keyword(tokens, _UNRECOGNIZED))) {
- warn(LD_DIR, "Unrecognized keyword '%s'; can't parse running-routers",
- tok->args[0]);
+ log_warn(LD_DIR, "Unrecognized keyword '%s'; can't parse running-routers",
+ tok->args[0]);
goto err;
}
tok = smartlist_get(tokens,0);
if (tok->tp != K_NETWORK_STATUS) {
- warn(LD_DIR, "Network-status starts with wrong token");
+ log_warn(LD_DIR, "Network-status starts with wrong token");
goto err;
}
if (!(tok = find_first_by_keyword(tokens, K_PUBLISHED))) {
- warn(LD_DIR, "Missing published time on directory.");
+ log_warn(LD_DIR, "Missing published time on directory.");
goto err;
}
tor_assert(tok->n_args == 1);
@@ -485,7 +485,7 @@ router_parse_runningrouters(const char *str)
goto err;
}
if (!(tok = find_first_by_keyword(tokens, K_DIRECTORY_SIGNATURE))) {
- warn(LD_DIR, "Missing signature on running-routers");
+ log_warn(LD_DIR, "Missing signature on running-routers");
goto err;
}
declared_key = find_dir_signing_key(str);
@@ -527,11 +527,11 @@ find_dir_signing_key(const char *str)
tok = get_next_token(&cp, DIR);
if (!tok) {
- warn(LD_DIR, "Unparseable dir-signing-key token");
+ log_warn(LD_DIR, "Unparseable dir-signing-key token");
return NULL;
}
if (tok->tp != K_DIR_SIGNING_KEY) {
- warn(LD_DIR, "Dir-signing-key token did not parse as expected");
+ log_warn(LD_DIR, "Dir-signing-key token did not parse as expected");
return NULL;
}
@@ -543,11 +543,11 @@ find_dir_signing_key(const char *str)
* can remove this logic. */
key = crypto_pk_DER64_decode_public_key(tok->args[0]);
if (!key) {
- warn(LD_DIR, "Unparseable dir-signing-key argument");
+ log_warn(LD_DIR, "Unparseable dir-signing-key argument");
return NULL;
}
} else {
- warn(LD_DIR, "Dir-signing-key token contained no key");
+ log_warn(LD_DIR, "Dir-signing-key token contained no key");
return NULL;
}
@@ -563,11 +563,11 @@ dir_signing_key_is_trusted(crypto_pk_env_t *key)
char digest[DIGEST_LEN];
if (!key) return 0;
if (crypto_pk_get_digest(key, digest) < 0) {
- warn(LD_DIR, "Error computing dir-signing-key digest");
+ log_warn(LD_DIR, "Error computing dir-signing-key digest");
return 0;
}
if (!router_digest_is_trusted_dir(digest)) {
- warn(LD_DIR, "Listed dir-signing-key is not trusted");
+ log_warn(LD_DIR, "Listed dir-signing-key is not trusted");
return 0;
}
return 1;
@@ -596,7 +596,7 @@ check_directory_signature(const char *digest,
crypto_pk_env_t *_pkey = NULL;
if (tok->n_args != 1) {
- warn(LD_DIR, "Too many or too few arguments to directory-signature");
+ log_warn(LD_DIR, "Too many or too few arguments to directory-signature");
return -1;
}
@@ -609,13 +609,14 @@ check_directory_signature(const char *digest,
_pkey = pkey;
}
if (!_pkey) {
- warn(LD_DIR, "Obsolete directory format (dir signing key not present) or "
- "signing key not trusted--rejecting.");
+ log_warn(LD_DIR,
+ "Obsolete directory format (dir signing key not present) or "
+ "signing key not trusted--rejecting.");
return -1;
}
if (strcmp(tok->object_type, "SIGNATURE") || tok->object_size != 128) {
- warn(LD_DIR, "Bad object type or length on directory signature");
+ log_warn(LD_DIR, "Bad object type or length on directory signature");
return -1;
}
@@ -623,12 +624,13 @@ check_directory_signature(const char *digest,
if (crypto_pk_public_checksig(_pkey, signed_digest, tok->object_body, 128)
!= 20) {
- warn(LD_DIR, "Error reading directory: invalid signature.");
+ log_warn(LD_DIR, "Error reading directory: invalid signature.");
return -1;
}
- debug(LD_DIR,"Signed directory hash starts %s", hex_str(signed_digest,4));
+ log_debug(LD_DIR,"Signed directory hash starts %s",
+ hex_str(signed_digest,4));
if (memcmp(digest, signed_digest, DIGEST_LEN)) {
- warn(LD_DIR, "Error reading directory: signature does not match.");
+ log_warn(LD_DIR, "Error reading directory: signature does not match.");
return -1;
}
return 0;
@@ -675,7 +677,7 @@ router_parse_list_from_string(const char **s, smartlist_t *dest)
* descriptor */
if (strcmpstart(cp, "\n-----END SIGNATURE-----\n")) {
- info(LD_DIR, "Ignoring truncated router descriptor.");
+ log_info(LD_DIR, "Ignoring truncated router descriptor.");
*s = end;
continue;
}
@@ -684,7 +686,7 @@ router_parse_list_from_string(const char **s, smartlist_t *dest)
*s = end;
if (!router) {
- warn(LD_DIR, "Error reading router; skipping");
+ log_warn(LD_DIR, "Error reading router; skipping");
continue;
}
smartlist_add(dest, router);
@@ -717,30 +719,30 @@ router_parse_entry_from_string(const char *s, const char *end)
--end;
if (router_get_router_hash(s, digest) < 0) {
- warn(LD_DIR, "Couldn't compute router hash.");
+ log_warn(LD_DIR, "Couldn't compute router hash.");
return NULL;
}
tokens = smartlist_create();
if (tokenize_string(s,end,tokens,RTR)) {
- warn(LD_DIR, "Error tokeninzing router descriptor.");
+ log_warn(LD_DIR, "Error tokeninzing router descriptor.");
goto err;
}
if (smartlist_len(tokens) < 2) {
- warn(LD_DIR, "Impossibly short router descriptor.");
+ log_warn(LD_DIR, "Impossibly short router descriptor.");
goto err;
}
if ((tok = find_first_by_keyword(tokens, _UNRECOGNIZED))) {
- warn(LD_DIR,
- "Unrecognized critical keyword '%s'; skipping descriptor. "
- "(It may be from another version of Tor.)",
- tok->args[0]);
+ log_warn(LD_DIR,
+ "Unrecognized critical keyword '%s'; skipping descriptor. "
+ "(It may be from another version of Tor.)",
+ tok->args[0]);
goto err;
}
tok = smartlist_get(tokens,0);
if (tok->tp != K_ROUTER) {
- warn(LD_DIR,"Entry does not start with \"router\"");
+ log_warn(LD_DIR,"Entry does not start with \"router\"");
goto err;
}
@@ -752,12 +754,12 @@ router_parse_entry_from_string(const char *s, const char *end)
if (tok->n_args >= 5) {
router->nickname = tor_strdup(tok->args[0]);
if (!is_legal_nickname(router->nickname)) {
- warn(LD_DIR,"Router nickname is invalid");
+ log_warn(LD_DIR,"Router nickname is invalid");
goto err;
}
router->address = tor_strdup(tok->args[1]);
if (!tor_inet_aton(router->address, &in)) {
- warn(LD_DIR,"Router address is not an IP.");
+ log_warn(LD_DIR,"Router address is not an IP.");
goto err;
}
router->addr = ntohl(in.s_addr);
@@ -767,18 +769,18 @@ router_parse_entry_from_string(const char *s, const char *end)
router->dir_port =
(uint16_t) tor_parse_long(tok->args[4],10,0,65535,NULL,NULL);
} else {
- warn(LD_DIR,"Wrong # of arguments to \"router\" (%d)",tok->n_args);
+ log_warn(LD_DIR,"Wrong # of arguments to \"router\" (%d)",tok->n_args);
goto err;
}
tok = find_first_by_keyword(tokens, K_BANDWIDTH);
if (!tok) {
- warn(LD_DIR,"No bandwidth declared; failing.");
+ log_warn(LD_DIR,"No bandwidth declared; failing.");
goto err;
} else {
if (tok->n_args < 3) {
- warn(LD_DIR,
- "Not enough arguments to \"bandwidth\" in server descriptor.");
+ log_warn(LD_DIR,
+ "Not enough arguments to \"bandwidth\" in server descriptor.");
goto err;
}
router->bandwidthrate =
@@ -791,7 +793,7 @@ router_parse_entry_from_string(const char *s, const char *end)
if ((tok = find_first_by_keyword(tokens, K_UPTIME))) {
if (tok->n_args != 1) {
- warn(LD_DIR, "Unrecognized number of args on K_UPTIME; skipping.");
+ log_warn(LD_DIR, "Unrecognized number of args on K_UPTIME; skipping.");
} else {
router->uptime = tor_parse_long(tok->args[0],10,0,LONG_MAX,NULL,NULL);
}
@@ -799,7 +801,7 @@ router_parse_entry_from_string(const char *s, const char *end)
if ((tok = find_first_by_keyword(tokens, K_HIBERNATING))) {
if (tok->n_args < 1) {
- warn(LD_DIR, "Too few args on 'hibernating' keyword. Skipping.");
+ log_warn(LD_DIR, "Too few args on 'hibernating' keyword. Skipping.");
} else {
router->is_hibernating
= (tor_parse_long(tok->args[0],10,0,LONG_MAX,NULL,NULL) != 0);
@@ -807,28 +809,28 @@ router_parse_entry_from_string(const char *s, const char *end)
}
if (!(tok = find_first_by_keyword(tokens, K_PUBLISHED))) {
- warn(LD_DIR, "Missing published time"); goto err;
+ log_warn(LD_DIR, "Missing published time"); goto err;
}
tor_assert(tok->n_args == 1);
if (parse_iso_time(tok->args[0], &router->cache_info.published_on) < 0)
goto err;
if (!(tok = find_first_by_keyword(tokens, K_ONION_KEY))) {
- warn(LD_DIR, "Missing onion key"); goto err;
+ log_warn(LD_DIR, "Missing onion key"); goto err;
}
if (crypto_pk_keysize(tok->key) != PK_BYTES) {
- warn(LD_DIR, "Wrong size on onion key: %d bits!",
- (int)crypto_pk_keysize(tok->key)*8);
+ log_warn(LD_DIR, "Wrong size on onion key: %d bits!",
+ (int)crypto_pk_keysize(tok->key)*8);
goto err;
}
router->onion_pkey = tok->key;
tok->key = NULL; /* Prevent free */
if (!(tok = find_first_by_keyword(tokens, K_SIGNING_KEY))) {
- warn(LD_DIR, "Missing identity key"); goto err;
+ log_warn(LD_DIR, "Missing identity key"); goto err;
}
if (crypto_pk_keysize(tok->key) != PK_BYTES) {
- warn(LD_DIR, "Wrong size on identity key: %d bits!",
+ log_warn(LD_DIR, "Wrong size on identity key: %d bits!",
(int)crypto_pk_keysize(tok->key)*8);
goto err;
}
@@ -836,24 +838,24 @@ router_parse_entry_from_string(const char *s, const char *end)
tok->key = NULL; /* Prevent free */
if (crypto_pk_get_digest(router->identity_pkey,
router->cache_info.identity_digest)) {
- warn(LD_DIR, "Couldn't calculate key digest"); goto err;
+ log_warn(LD_DIR, "Couldn't calculate key digest"); goto err;
}
if ((tok = find_first_by_keyword(tokens, K_FINGERPRINT))) {
/* If there's a fingerprint line, it must match the identity digest. */
char d[DIGEST_LEN];
if (tok->n_args < 1) {
- warn(LD_DIR, "Too few arguments to fingerprint");
+ log_warn(LD_DIR, "Too few arguments to fingerprint");
goto err;
}
tor_strstrip(tok->args[0], " ");
if (base16_decode(d, DIGEST_LEN, tok->args[0], strlen(tok->args[0]))) {
- warn(LD_DIR, "Couldn't decode fingerprint '%s'", tok->args[0]);
+ log_warn(LD_DIR, "Couldn't decode fingerprint '%s'", tok->args[0]);
goto err;
}
if (memcmp(d,router->cache_info.identity_digest, DIGEST_LEN)!=0) {
- warn(LD_DIR, "Fingerprint '%s' does not match identity digest.",
- tok->args[0]);
+ log_warn(LD_DIR, "Fingerprint '%s' does not match identity digest.",
+ tok->args[0]);
goto err;
}
}
@@ -869,7 +871,7 @@ router_parse_entry_from_string(const char *s, const char *end)
exit_policy_tokens = find_all_exitpolicy(tokens);
SMARTLIST_FOREACH(exit_policy_tokens, directory_token_t *, t,
if (router_add_exit_policy(router,t)<0) {
- warn(LD_DIR,"Error in exit policy");
+ log_warn(LD_DIR,"Error in exit policy");
goto err;
});
@@ -878,7 +880,7 @@ router_parse_entry_from_string(const char *s, const char *end)
router->declared_family = smartlist_create();
for (i=0;i<tok->n_args;++i) {
if (!is_legal_nickname_or_hexdigest(tok->args[i])) {
- warn(LD_DIR, "Illegal nickname '%s' in family line", tok->args[i]);
+ log_warn(LD_DIR, "Illegal nickname '%s' in family line", tok->args[i]);
goto err;
}
smartlist_add(router->declared_family, tor_strdup(tok->args[i]));
@@ -886,29 +888,29 @@ router_parse_entry_from_string(const char *s, const char *end)
}
if (!(tok = find_first_by_keyword(tokens, K_ROUTER_SIGNATURE))) {
- warn(LD_DIR, "Missing router signature");
+ log_warn(LD_DIR, "Missing router signature");
goto err;
}
if (strcmp(tok->object_type, "SIGNATURE") || tok->object_size != 128) {
- warn(LD_DIR, "Bad object type or length on router signature");
+ log_warn(LD_DIR, "Bad object type or length on router signature");
goto err;
}
if ((t=crypto_pk_public_checksig(router->identity_pkey, signed_digest,
tok->object_body, 128)) != 20) {
- warn(LD_DIR, "Invalid signature %d",t);
+ log_warn(LD_DIR, "Invalid signature %d",t);
goto err;
}
if (memcmp(digest, signed_digest, DIGEST_LEN)) {
- warn(LD_DIR, "Mismatched signature");
+ log_warn(LD_DIR, "Mismatched signature");
goto err;
}
if (!router->or_port) {
- warn(LD_DIR,"or_port unreadable or 0. Failing.");
+ log_warn(LD_DIR,"or_port unreadable or 0. Failing.");
goto err;
}
if (!router->bandwidthrate) {
- warn(LD_DIR,"bandwidthrate unreadable or 0. Failing.");
+ log_warn(LD_DIR,"bandwidthrate unreadable or 0. Failing.");
goto err;
}
if (!router->platform) {
@@ -965,54 +967,56 @@ routerstatus_parse_entry_from_string(const char **s, smartlist_t *tokens)
eos = find_start_of_next_routerstatus(*s);
if (tokenize_string(*s, eos, tokens, RTRSTATUS)) {
- warn(LD_DIR, "Error tokenizing router status");
+ log_warn(LD_DIR, "Error tokenizing router status");
goto err;
}
if (smartlist_len(tokens) < 1) {
- warn(LD_DIR, "Impossibly short router status");
+ log_warn(LD_DIR, "Impossibly short router status");
goto err;
}
if ((tok = find_first_by_keyword(tokens, _UNRECOGNIZED))) {
- warn(LD_DIR, "Unrecognized keyword \"%s\" in router status; skipping.",
- tok->args[0]);
+ log_warn(LD_DIR, "Unrecognized keyword \"%s\" in router status; skipping.",
+ tok->args[0]);
goto err;
}
if (!(tok = find_first_by_keyword(tokens, K_R))) {
- warn(LD_DIR, "Missing 'r' keywork in router status; skipping.");
+ log_warn(LD_DIR, "Missing 'r' keywork in router status; skipping.");
goto err;
}
if (tok->n_args < 8) {
- warn(LD_DIR,
+ log_warn(LD_DIR,
"Too few arguments to 'r' keywork in router status; skipping.");
}
rs = tor_malloc_zero(sizeof(routerstatus_t));
if (!is_legal_nickname(tok->args[0])) {
- warn(LD_DIR,
- "Invalid nickname '%s' in router status; skipping.", tok->args[0]);
+ log_warn(LD_DIR,
+ "Invalid nickname '%s' in router status; skipping.",
+ tok->args[0]);
goto err;
}
strlcpy(rs->nickname, tok->args[0], sizeof(rs->nickname));
if (digest_from_base64(rs->identity_digest, tok->args[1])) {
- warn(LD_DIR, "Error decoding digest '%s'", tok->args[1]);
+ log_warn(LD_DIR, "Error decoding digest '%s'", tok->args[1]);
goto err;
}
if (digest_from_base64(rs->descriptor_digest, tok->args[2])) {
- warn(LD_DIR, "Error decoding digest '%s'", tok->args[2]);
+ log_warn(LD_DIR, "Error decoding digest '%s'", tok->args[2]);
goto err;
}
if (tor_snprintf(timebuf, sizeof(timebuf), "%s %s",
tok->args[3], tok->args[4]) < 0 ||
parse_iso_time(timebuf, &rs->published_on)<0) {
- warn(LD_DIR, "Error parsing time '%s %s'", tok->args[3], tok->args[4]);
+ log_warn(LD_DIR, "Error parsing time '%s %s'",
+ tok->args[3], tok->args[4]);
goto err;
}
if (tor_inet_aton(tok->args[5], &in) == 0) {
- warn(LD_DIR, "Error parsing address '%s'", tok->args[5]);
+ log_warn(LD_DIR, "Error parsing address '%s'", tok->args[5]);
goto err;
}
rs->addr = ntohl(in.s_addr);
@@ -1081,60 +1085,60 @@ networkstatus_parse_from_string(const char *s)
int i;
if (router_get_networkstatus_v2_hash(s, ns_digest)) {
- warn(LD_DIR, "Unable to compute digest of network-status");
+ log_warn(LD_DIR, "Unable to compute digest of network-status");
goto err;
}
eos = find_start_of_next_routerstatus(s);
if (tokenize_string(s, eos, tokens, NETSTATUS)) {
- warn(LD_DIR, "Error tokenizing network-status header.");
+ log_warn(LD_DIR, "Error tokenizing network-status header.");
goto err;
}
if ((tok = find_first_by_keyword(tokens, _UNRECOGNIZED))) {
- warn(LD_DIR, "Unrecognized keyword '%s'; can't parse network-status",
- tok->args[0]);
+ log_warn(LD_DIR, "Unrecognized keyword '%s'; can't parse network-status",
+ tok->args[0]);
goto err;
}
ns = tor_malloc_zero(sizeof(networkstatus_t));
memcpy(ns->networkstatus_digest, ns_digest, DIGEST_LEN);
if (!(tok = find_first_by_keyword(tokens, K_NETWORK_STATUS_VERSION))) {
- warn(LD_DIR, "Couldn't find network-status-version keyword");
+ log_warn(LD_DIR, "Couldn't find network-status-version keyword");
goto err;
}
if (!(tok = find_first_by_keyword(tokens, K_DIR_SOURCE))) {
- warn(LD_DIR, "Couldn't find dir-source keyword");
+ log_warn(LD_DIR, "Couldn't find dir-source keyword");
goto err;
}
if (tok->n_args < 3) {
- warn(LD_DIR, "Too few arguments to dir-source keyword");
+ log_warn(LD_DIR, "Too few arguments to dir-source keyword");
goto err;
}
ns->source_address = tok->args[0]; tok->args[0] = NULL;
if (tor_inet_aton(tok->args[1], &in) == 0) {
- warn(LD_DIR, "Error parsing address '%s'", tok->args[1]);
+ log_warn(LD_DIR, "Error parsing address '%s'", tok->args[1]);
goto err;
}
ns->source_addr = ntohl(in.s_addr);
ns->source_dirport =
(uint16_t) tor_parse_long(tok->args[2],10,0,65535,NULL,NULL);
if (ns->source_dirport == 0) {
- warn(LD_DIR, "Directory source without dirport; skipping.");
+ log_warn(LD_DIR, "Directory source without dirport; skipping.");
goto err;
}
if (!(tok = find_first_by_keyword(tokens, K_FINGERPRINT))) {
- warn(LD_DIR, "Couldn't find fingerprint keyword");
+ log_warn(LD_DIR, "Couldn't find fingerprint keyword");
goto err;
}
if (tok->n_args < 1) {
- warn(LD_DIR, "Too few arguments to fingerprint");
+ log_warn(LD_DIR, "Too few arguments to fingerprint");
goto err;
}
if (base16_decode(ns->identity_digest, DIGEST_LEN, tok->args[0],
strlen(tok->args[0]))) {
- warn(LD_DIR, "Couldn't decode fingerprint '%s'", tok->args[0]);
+ log_warn(LD_DIR, "Couldn't decode fingerprint '%s'", tok->args[0]);
goto err;
}
@@ -1144,18 +1148,19 @@ networkstatus_parse_from_string(const char *s)
}
if (!(tok = find_first_by_keyword(tokens, K_DIR_SIGNING_KEY)) || !tok->key) {
- warn(LD_DIR, "Missing dir-signing-key");
+ log_warn(LD_DIR, "Missing dir-signing-key");
goto err;
}
ns->signing_key = tok->key;
tok->key = NULL;
if (crypto_pk_get_digest(ns->signing_key, tmp_digest)<0) {
- warn(LD_DIR, "Couldn't compute signing key digest");
+ log_warn(LD_DIR, "Couldn't compute signing key digest");
goto err;
}
if (memcmp(tmp_digest, ns->identity_digest, DIGEST_LEN)) {
- warn(LD_DIR, "network-status fingerprint did not match dir-signing-key");
+ log_warn(LD_DIR,
+ "network-status fingerprint did not match dir-signing-key");
goto err;
}
@@ -1171,14 +1176,14 @@ networkstatus_parse_from_string(const char *s)
if (ns->recommends_versions) {
if (!(tok = find_first_by_keyword(tokens, K_CLIENT_VERSIONS)) ||
tok->n_args<1) {
- warn(LD_DIR, "Missing client-versions");
+ log_warn(LD_DIR, "Missing client-versions");
}
ns->client_versions = tok->args[0];
tok->args[0] = NULL;
if (!(tok = find_first_by_keyword(tokens, K_SERVER_VERSIONS)) ||
tok->n_args<1) {
- warn(LD_DIR, "Missing server-versions on versioning directory");
+ log_warn(LD_DIR, "Missing server-versions on versioning directory");
goto err;
}
ns->server_versions = tok->args[0];
@@ -1186,7 +1191,7 @@ networkstatus_parse_from_string(const char *s)
}
if (!(tok = find_first_by_keyword(tokens, K_PUBLISHED))) {
- warn(LD_DIR, "Missing published time on directory.");
+ log_warn(LD_DIR, "Missing published time on directory.");
goto err;
}
tor_assert(tok->n_args == 1);
@@ -1211,24 +1216,26 @@ networkstatus_parse_from_string(const char *s)
routerstatus_t *rs2 = smartlist_get(ns->entries, i+1);
if (!memcmp(rs1->identity_digest,
rs2->identity_digest, DIGEST_LEN)) {
- warn(LD_DIR,
- "Network-status has two entries for the same router. Dropping one.");
+ log_warn(LD_DIR,
+ "Network-status has two entries for the same router. "
+ "Dropping one.");
smartlist_del_keeporder(ns->entries, i--);
routerstatus_free(rs1);
}
}
if (tokenize_string(s, NULL, tokens, NETSTATUS)) {
- warn(LD_DIR, "Error tokenizing network-status footer.");
+ log_warn(LD_DIR, "Error tokenizing network-status footer.");
goto err;
}
if (smartlist_len(tokens) < 1) {
- warn(LD_DIR, "Too few items in network-status footer.");
+ log_warn(LD_DIR, "Too few items in network-status footer.");
goto err;
}
tok = smartlist_get(tokens, smartlist_len(tokens)-1);
if (tok->tp != K_DIRECTORY_SIGNATURE) {
- warn(LD_DIR, "Expected network-status footer to end with a signature.");
+ log_warn(LD_DIR,
+ "Expected network-status footer to end with a signature.");
goto err;
}
@@ -1279,11 +1286,11 @@ router_parse_addr_policy_from_string(const char *s, int assume_action)
}
tok = get_next_token(&cp, RTR);
if (tok->tp == _ERR) {
- warn(LD_DIR, "Error reading exit policy: %s", tok->error);
+ log_warn(LD_DIR, "Error reading exit policy: %s", tok->error);
goto err;
}
if (tok->tp != K_ACCEPT && tok->tp != K_REJECT) {
- warn(LD_DIR, "Expected 'accept' or 'reject'.");
+ log_warn(LD_DIR, "Expected 'accept' or 'reject'.");
goto err;
}
@@ -1357,7 +1364,7 @@ router_parse_addr_policy(directory_token_t *tok)
policy_read_failed:
tor_assert(newe->string);
- warn(LD_DIR,"Couldn't parse line '%s'. Dropping", newe->string);
+ log_warn(LD_DIR,"Couldn't parse line '%s'. Dropping", newe->string);
tor_free(newe->string);
tor_free(newe);
return NULL;
@@ -1618,7 +1625,7 @@ tokenize_string(const char *start, const char *end, smartlist_t *out,
while (*s < end && (!tok || tok->tp != _EOF)) {
tok = get_next_token(s, where);
if (tok->tp == _ERR) {
- warn(LD_DIR, "parse error: %s", tok->error);
+ log_warn(LD_DIR, "parse error: %s", tok->error);
return -1;
}
smartlist_add(out, tok);
@@ -1666,28 +1673,29 @@ router_get_hash_impl(const char *s, char *digest,
char *start, *end;
start = strstr(s, start_str);
if (!start) {
- warn(LD_DIR,"couldn't find \"%s\"",start_str);
+ log_warn(LD_DIR,"couldn't find \"%s\"",start_str);
return -1;
}
if (start != s && *(start-1) != '\n') {
- warn(LD_DIR, "first occurrence of \"%s\" is not at the start of a line",
- start_str);
+ log_warn(LD_DIR,
+ "first occurrence of \"%s\" is not at the start of a line",
+ start_str);
return -1;
}
end = strstr(start+strlen(start_str), end_str);
if (!end) {
- warn(LD_DIR,"couldn't find \"%s\"",end_str);
+ log_warn(LD_DIR,"couldn't find \"%s\"",end_str);
return -1;
}
end = strchr(end+strlen(end_str), '\n');
if (!end) {
- warn(LD_DIR,"couldn't find EOL");
+ log_warn(LD_DIR,"couldn't find EOL");
return -1;
}
++end;
if (crypto_digest(digest, start, end-start)) {
- warn(LD_DIR,"couldn't compute digest");
+ log_warn(LD_DIR,"couldn't compute digest");
return -1;
}
@@ -1706,7 +1714,7 @@ tor_version_as_new_as(const char *platform, const char *cutoff)
char tmp[128];
if (tor_version_parse(cutoff, &cutoff_version)<0) {
- warn(LD_DIR,"Bug: cutoff version '%s' unparseable.",cutoff);
+ log_warn(LD_DIR,"Bug: cutoff version '%s' unparseable.",cutoff);
return 0;
}
if (strcmpstart(platform,"Tor ")) /* nonstandard Tor; be safe and say yes */
@@ -1720,7 +1728,7 @@ tor_version_as_new_as(const char *platform, const char *cutoff)
strlcpy(tmp, start, s-start+1);
if (tor_version_parse(tmp, &router_version)<0) {
- info(LD_DIR,"Router version '%s' unparseable.",tmp);
+ log_info(LD_DIR,"Router version '%s' unparseable.",tmp);
return 1; /* be safe and say yes */
}