doxygen and other cleanups

svn:r13440
This commit is contained in:
Roger Dingledine 2008-02-09 03:11:10 +00:00
parent be1e577d5e
commit 509d2912dc
12 changed files with 51 additions and 40 deletions

View file

@ -286,7 +286,7 @@ aes_crypt(aes_cnt_cipher_t *cipher, const char *input, size_t len,
/* XXXX This function is up to 5% of our runtime in some profiles; /* XXXX This function is up to 5% of our runtime in some profiles;
* we should look into unrolling some of the loops; taking advantage * we should look into unrolling some of the loops; taking advantage
* of alignmement, using a bigger buffer, and so on. Not till after 0.1.2.x, * of alignment, using a bigger buffer, and so on. Not till after 0.1.2.x,
* though. */ * though. */
int c = cipher->pos; int c = cipher->pos;
if (PREDICT_UNLIKELY(!len)) return; if (PREDICT_UNLIKELY(!len)) return;
@ -322,7 +322,7 @@ aes_crypt_inplace(aes_cnt_cipher_t *cipher, char *data, size_t len)
/* XXXX This function is up to 5% of our runtime in some profiles; /* XXXX This function is up to 5% of our runtime in some profiles;
* we should look into unrolling some of the loops; taking advantage * we should look into unrolling some of the loops; taking advantage
* of alignmement, using a bigger buffer, and so on. Not till after 0.1.2.x, * of alignment, using a bigger buffer, and so on. Not till after 0.1.2.x,
* though. */ * though. */
int c = cipher->pos; int c = cipher->pos;
if (PREDICT_UNLIKELY(!len)) return; if (PREDICT_UNLIKELY(!len)) return;

View file

@ -1550,12 +1550,12 @@ crypto_dh_compute_secret(crypto_dh_env_t *dh,
goto error; goto error;
} }
secret_len = result; secret_len = result;
/* sometimes secret_len might be less than 128, e.g., 127. that's ok. */ /* sometimes secret_len might be less than 128, e.g., 127. that's ok. -RD */
/* Actually, http://www.faqs.org/rfcs/rfc2631.html says: /* Actually, http://www.faqs.org/rfcs/rfc2631.html says:
* Leading zeros MUST be preserved, so that ZZ occupies as many * Leading zeros MUST be preserved, so that ZZ occupies as many
* octets as p. For instance, if p is 1024 bits, ZZ should be 128 * octets as p. For instance, if p is 1024 bits, ZZ should be 128
* bytes long. * bytes long.
* What are the security implications here? * XXX021 What are the security implications here? -NM
*/ */
if (crypto_expand_key_material(secret_tmp, secret_len, if (crypto_expand_key_material(secret_tmp, secret_len,
secret_out, secret_bytes_out)<0) secret_out, secret_bytes_out)<0)
@ -1578,7 +1578,7 @@ crypto_dh_compute_secret(crypto_dh_env_t *dh,
/** Given <b>key_in_len</b> bytes of negotiated randomness in <b>key_in</b> /** Given <b>key_in_len</b> bytes of negotiated randomness in <b>key_in</b>
* ("K"), expand it into <b>key_out_len</b> bytes of negotiated key material in * ("K"), expand it into <b>key_out_len</b> bytes of negotiated key material in
* <b>key_out</b> by taking the first key_out_len bytes of * <b>key_out</b> by taking the first <b>key_out_len</b> bytes of
* H(K | [00]) | H(K | [01]) | .... * H(K | [00]) | H(K | [01]) | ....
* *
* Return 0 on success, -1 on failure. * Return 0 on success, -1 on failure.
@ -1710,7 +1710,7 @@ crypto_seed_rng(void)
#endif #endif
} }
/** Write n bytes of strong random data to <b>to</b>. Return 0 on /** Write <b>n</b> bytes of strong random data to <b>to</b>. Return 0 on
* success, -1 on failure. * success, -1 on failure.
*/ */
int int
@ -1725,7 +1725,7 @@ crypto_rand(char *to, size_t n)
} }
/** Return a pseudorandom integer, chosen uniformly from the values /** Return a pseudorandom integer, chosen uniformly from the values
* between 0 and max-1. */ * between 0 and <b>max</b>-1. */
int int
crypto_rand_int(unsigned int max) crypto_rand_int(unsigned int max)
{ {
@ -1746,8 +1746,8 @@ crypto_rand_int(unsigned int max)
} }
} }
/** Return a pseudorandom integer, chosen uniformly from the values /** Return a pseudorandom 64-bit integer, chosen uniformly from the values
* between 0 and max-1. */ * between 0 and <b>max</b>-1. */
uint64_t uint64_t
crypto_rand_uint64(uint64_t max) crypto_rand_uint64(uint64_t max)
{ {
@ -1768,9 +1768,10 @@ crypto_rand_uint64(uint64_t max)
} }
} }
/** Generate and return a new random hostname starting with prefix, ending /** Generate and return a new random hostname starting with <b>prefix</b>,
* with suffix, and containing between min_rand_len and max_rand_len random * ending with <b>suffix</b>, and containing no less than
* base32 characters between. */ * <b>min_rand_len</b> and no more than <b>max_rand_len</b> random base32
* characters between. */
char * char *
crypto_random_hostname(int min_rand_len, int max_rand_len, const char *prefix, crypto_random_hostname(int min_rand_len, int max_rand_len, const char *prefix,
const char *suffix) const char *suffix)
@ -1799,8 +1800,8 @@ crypto_random_hostname(int min_rand_len, int max_rand_len, const char *prefix,
return result; return result;
} }
/** Return a randomly chosen element of sl; or NULL if sl is empty. /** Return a randomly chosen element of <b>sl</b>; or NULL if <b>sl</b>
*/ * is empty. */
void * void *
smartlist_choose(const smartlist_t *sl) smartlist_choose(const smartlist_t *sl)
{ {
@ -1811,7 +1812,7 @@ smartlist_choose(const smartlist_t *sl)
return NULL; /* no elements to choose from */ return NULL; /* no elements to choose from */
} }
/** Scramble the elements of sl into a random order. */ /** Scramble the elements of <b>sl</b> into a random order. */
void void
smartlist_shuffle(smartlist_t *sl) smartlist_shuffle(smartlist_t *sl)
{ {
@ -1834,7 +1835,7 @@ smartlist_shuffle(smartlist_t *sl)
int int
base64_encode(char *dest, size_t destlen, const char *src, size_t srclen) base64_encode(char *dest, size_t destlen, const char *src, size_t srclen)
{ {
/* XXXX we might want to rewrite this along the lines of base64_decode, if /* FFFF we might want to rewrite this along the lines of base64_decode, if
* it ever shows up in the profile. */ * it ever shows up in the profile. */
EVP_ENCODE_CTX ctx; EVP_ENCODE_CTX ctx;
int len, ret; int len, ret;

View file

@ -204,7 +204,7 @@ add_newly_used_chunk_to_used_list(mp_pool_t *pool, mp_chunk_t *chunk)
ASSERT(!chunk->prev); ASSERT(!chunk->prev);
} }
/** Return an newly allocated item from <b>pool</b>. */ /** Return a newly allocated item from <b>pool</b>. */
void * void *
mp_pool_get(mp_pool_t *pool) mp_pool_get(mp_pool_t *pool)
{ {

View file

@ -50,11 +50,11 @@ struct mp_pool_t {
* padding. */ * padding. */
size_t item_alloc_size; size_t item_alloc_size;
#ifdef MEMPOOL_STATS #ifdef MEMPOOL_STATS
/** Total number of items allocated ever */ /** Total number of items allocated ever. */
uint64_t total_items_allocated; uint64_t total_items_allocated;
/** Total number of chunks allocated ever */ /** Total number of chunks allocated ever. */
uint64_t total_chunks_allocated; uint64_t total_chunks_allocated;
/** Total number of chunks freed ever */ /** Total number of chunks freed ever. */
uint64_t total_chunks_freed; uint64_t total_chunks_freed;
#endif #endif
}; };

View file

@ -322,7 +322,7 @@ always_accept_verify_cb(int preverify_ok,
return 1; return 1;
} }
/** Return a newly allocated X509 name with commonName <b>cname</b> */ /** Return a newly allocated X509 name with commonName <b>cname</b>. */
static X509_NAME * static X509_NAME *
tor_x509_name_new(const char *cname) tor_x509_name_new(const char *cname)
{ {

View file

@ -707,7 +707,7 @@ tor_parse_long(const char *s, int base, long min, long max,
CHECK_STRTOX_RESULT(); CHECK_STRTOX_RESULT();
} }
/** As tor_parse_long, but return an unsigned long. */ /** As tor_parse_long(), but return an unsigned long. */
unsigned long unsigned long
tor_parse_ulong(const char *s, int base, unsigned long min, tor_parse_ulong(const char *s, int base, unsigned long min,
unsigned long max, int *ok, char **next) unsigned long max, int *ok, char **next)

View file

@ -2822,15 +2822,23 @@ getinfo_helper_entry_guards(control_connection_t *conn,
return 0; return 0;
} }
/** DOCDOC arma */ /** Information about a configured bridge. Currently this just matches the
* ones in the torrc file, but one day we may be able to learn about new
* bridges on our own, and remember them in the state file. */
typedef struct { typedef struct {
/** IPv4 address of the bridge. */
uint32_t addr; uint32_t addr;
/** TLS port for the bridge. */
uint16_t port; uint16_t port;
/** Expected identity digest, or all \0's if we don't know what the
* digest should be. */
char identity[DIGEST_LEN]; char identity[DIGEST_LEN];
/** When should we next try to fetch a descriptor for this bridge? */
download_status_t fetch_status; download_status_t fetch_status;
} bridge_info_t; } bridge_info_t;
/** A list of known bridges. */ /** A list of configured bridges. Whenever we actually get a descriptor
* for one, we add it as an entry guard. */
static smartlist_t *bridge_list = NULL; static smartlist_t *bridge_list = NULL;
/** Initialize the bridge list to empty, creating it if needed. */ /** Initialize the bridge list to empty, creating it if needed. */

View file

@ -174,13 +174,14 @@ var_cell_new(uint16_t payload_len)
return cell; return cell;
} }
/** Release all space held by <b>cell</b> */ /** Release all space held by <b>cell</b>. */
void void
var_cell_free(var_cell_t *cell) var_cell_free(var_cell_t *cell)
{ {
tor_free(cell); tor_free(cell);
} }
/** We've received an EOF from <b>conn</b>. Mark it for close and return. */
int int
connection_or_reached_eof(or_connection_t *conn) connection_or_reached_eof(or_connection_t *conn)
{ {

View file

@ -1876,7 +1876,7 @@ connection_dir_client_reached_eof(dir_connection_t *conn)
return 0; return 0;
} }
/** Called when a directory connection reaches EOF */ /** Called when a directory connection reaches EOF. */
int int
connection_dir_reached_eof(dir_connection_t *conn) connection_dir_reached_eof(dir_connection_t *conn)
{ {

View file

@ -786,7 +786,7 @@ networkstatus_vote_find_entry(networkstatus_t *ns, const char *digest)
/*XXXX make this static once functions are moved into this file. */ /*XXXX make this static once functions are moved into this file. */
/** Search the routerstatuses in <b>ns</b> for one whose identity digest is /** Search the routerstatuses in <b>ns</b> for one whose identity digest is
* <b>digest</b>. Return value and set *<b>found_out</b> as for * <b>digest</b>. Return value and set *<b>found_out</b> as for
* smartlist_besearch_idx(). */ * smartlist_bsearch_idx(). */
int int
networkstatus_vote_find_entry_idx(networkstatus_t *ns, networkstatus_vote_find_entry_idx(networkstatus_t *ns,
const char *digest, int *found_out) const char *digest, int *found_out)

View file

@ -19,9 +19,9 @@ static void bw_arrays_init(void);
static void predicted_ports_init(void); static void predicted_ports_init(void);
static void hs_usage_init(void); static void hs_usage_init(void);
/** Total number of bytes currently allocated in fields used by rephist.c */ /** Total number of bytes currently allocated in fields used by rephist.c. */
uint64_t rephist_total_alloc=0; uint64_t rephist_total_alloc=0;
/** Number of or_history_t obects currently allocated */ /** Number of or_history_t objects currently allocated. */
uint32_t rephist_total_num=0; uint32_t rephist_total_num=0;
/** If the total weighted run count of all runs for a router ever falls /** If the total weighted run count of all runs for a router ever falls

View file

@ -1081,20 +1081,20 @@ _test_eq_ip6(struct in6_addr *a, struct in6_addr *b, const char *e1,
#define test_eq_ip6(a,b) _test_eq_ip6((a),(b),#a,#b,__LINE__) #define test_eq_ip6(a,b) _test_eq_ip6((a),(b),#a,#b,__LINE__)
/** Helper: Assert that two strings both decode as IPv6 addresses with /** Helper: Assert that two strings both decode as IPv6 addresses with
* tor_inet_pton, and both decode to the same address. */ * tor_inet_pton(), and both decode to the same address. */
#define test_pton6_same(a,b) STMT_BEGIN \ #define test_pton6_same(a,b) STMT_BEGIN \
test_eq(tor_inet_pton(AF_INET6, a, &a1), 1); \ test_eq(tor_inet_pton(AF_INET6, a, &a1), 1); \
test_eq(tor_inet_pton(AF_INET6, b, &a2), 1); \ test_eq(tor_inet_pton(AF_INET6, b, &a2), 1); \
_test_eq_ip6(&a1,&a2,#a,#b,__LINE__); \ _test_eq_ip6(&a1,&a2,#a,#b,__LINE__); \
STMT_END STMT_END
/** Helper: Assert that <b>a</b> is recognized as a bed IPv6 address by /** Helper: Assert that <b>a</b> is recognized as a bad IPv6 address by
* tor_inet_pton. */ * tor_inet_pton(). */
#define test_pton6_bad(a) \ #define test_pton6_bad(a) \
test_eq(0, tor_inet_pton(AF_INET6, a, &a1)) test_eq(0, tor_inet_pton(AF_INET6, a, &a1))
/** Helper: assert that <b>a</b> when parsed by tor_inet_pton and displayed /** Helper: assert that <b>a</b>, when parsed by tor_inet_pton() and displayed
* with tor_inet_ntop, yields <b>b</b>. Also assert that <b>b</b> parses to * with tor_inet_ntop(), yields <b>b</b>. Also assert that <b>b</b> parses to
* the same value as <b>a</b>. */ * the same value as <b>a</b>. */
#define test_ntop6_reduces(a,b) STMT_BEGIN \ #define test_ntop6_reduces(a,b) STMT_BEGIN \
test_eq(tor_inet_pton(AF_INET6, a, &a1), 1); \ test_eq(tor_inet_pton(AF_INET6, a, &a1), 1); \
@ -1103,8 +1103,8 @@ _test_eq_ip6(struct in6_addr *a, struct in6_addr *b, const char *e1,
_test_eq_ip6(&a1, &a2, a, b, __LINE__); \ _test_eq_ip6(&a1, &a2, a, b, __LINE__); \
STMT_END STMT_END
/** Helper: assert that <b>a</a> parses by tor_inet_pton into a address that /** Helper: assert that <b>a</a> parses by tor_inet_pton() into a address that
* passes tor_addr_is_internal with for_listening */ * passes tor_addr_is_internal() with <b>for_listening</b> */
#define test_internal_ip(a,for_listening) STMT_BEGIN \ #define test_internal_ip(a,for_listening) STMT_BEGIN \
test_eq(tor_inet_pton(AF_INET6, a, &t1.addr.in6_addr), 1); \ test_eq(tor_inet_pton(AF_INET6, a, &t1.addr.in6_addr), 1); \
t1.family = AF_INET6; \ t1.family = AF_INET6; \
@ -1112,8 +1112,8 @@ _test_eq_ip6(struct in6_addr *a, struct in6_addr *b, const char *e1,
test_fail_msg( a "was not internal."); \ test_fail_msg( a "was not internal."); \
STMT_END STMT_END
/** Helper: assert that <b>a</a> parses by tor_inet_pton into a address that /** Helper: assert that <b>a</a> parses by tor_inet_pton() into a address that
* does not pass tor_addr_is_internal with for_listening. */ * does not pass tor_addr_is_internal() with <b>for_listening</b>. */
#define test_external_ip(a,for_listening) STMT_BEGIN \ #define test_external_ip(a,for_listening) STMT_BEGIN \
test_eq(tor_inet_pton(AF_INET6, a, &t1.addr.in6_addr), 1); \ test_eq(tor_inet_pton(AF_INET6, a, &t1.addr.in6_addr), 1); \
t1.family = AF_INET6; \ t1.family = AF_INET6; \
@ -1121,8 +1121,9 @@ _test_eq_ip6(struct in6_addr *a, struct in6_addr *b, const char *e1,
test_fail_msg(a "was not external."); \ test_fail_msg(a "was not external."); \
STMT_END STMT_END
/** Helper: Assert that a and b, when parsed by tor_inet_pton, give addresses /** Helper: Assert that <b>a</b> and <b>b</b>, when parsed by
* that compare in the order defined by op with tor_addr_compare(). */ * tor_inet_pton(), give addresses that compare in the order defined by
* <b>op</b> with tor_addr_compare(). */
#define test_addr_compare(a, op, b) STMT_BEGIN \ #define test_addr_compare(a, op, b) STMT_BEGIN \
test_eq(tor_inet_pton(AF_INET6, a, &t1.addr.in6_addr), 1); \ test_eq(tor_inet_pton(AF_INET6, a, &t1.addr.in6_addr), 1); \
test_eq(tor_inet_pton(AF_INET6, b, &t2.addr.in6_addr), 1); \ test_eq(tor_inet_pton(AF_INET6, b, &t2.addr.in6_addr), 1); \