#include "torint.h"
#include "compat.h"
+/* DOCDOC maskbits_t */
typedef uint8_t maskbits_t;
struct in_addr;
/** Holds an IPv4 or IPv6 address. (Uses less memory than struct
/* DOCDOC*/
static INLINE uint32_t tor_addr_to_ipv4n(const tor_addr_t *a);
+/* DOCDOC tor_addr_to_ipv4h */
static INLINE uint32_t tor_addr_to_ipv4h(const tor_addr_t *a);
+/* DOCDOC tor_addr_to_mapped_ipv4h */
static INLINE uint32_t tor_addr_to_mapped_ipv4h(const tor_addr_t *a);
+/* DOCDOC tor_addr_family */
static INLINE sa_family_t tor_addr_family(const tor_addr_t *a);
+/* DOCDOC tor_addr_to_in */
static INLINE const struct in_addr *tor_addr_to_in(const tor_addr_t *a);
+/* DOCDOC tor_addr_to_in6 */
static INLINE const struct in6_addr *tor_addr_to_in6(const tor_addr_t *a);
+/* DOCDOC tor_addr_eq_ipv4h */
static INLINE int tor_addr_eq_ipv4h(const tor_addr_t *a, uint32_t u);
socklen_t tor_addr_to_sockaddr(const tor_addr_t *a, uint16_t port,
struct sockaddr *sa_out, socklen_t len);
uint16_t *port_max_out);
int addr_mask_get_bits(uint32_t mask);
int addr_mask_cmp_bits(uint32_t a1, uint32_t a2, maskbits_t bits);
-#define INET_NTOA_BUF_LEN 16 /* 255.255.255.255 */
+/** Length of a buffer to allocate to hold the results of tor_inet_ntoa.*/
+#define INET_NTOA_BUF_LEN 16
int tor_inet_ntoa(const struct in_addr *in, char *buf, size_t buf_len);
char *tor_dup_ip(uint32_t addr) ATTR_MALLOC;
int get_interface_address(int severity, uint32_t *addr);
#elif defined(USE_PTHREADS)
static pthread_mutexattr_t attr_reentrant;
static int threads_initialized = 0;
+/* DOCDOC tor_mutex_init */
void
tor_mutex_init(tor_mutex_t *mutex)
{
tor_fragile_assert();
}
}
+/* DOCDOC tor_mutex_uninit */
void
tor_mutex_uninit(tor_mutex_t *m)
{
#endif
#ifdef TOR_IS_MULTITHREADED
+/* DOCDOC tor_mutex_new */
tor_mutex_t *
tor_mutex_new(void)
{
tor_mutex_init(m);
return m;
}
+/* DOCDOC tor_mutex_free */
void
tor_mutex_free(tor_mutex_t *m)
{
smartlist_uniq(sl, _compare_digests, _tor_free);
}
+/* DOCDOC DEFINE_MAP_STRUCTS */
#define DEFINE_MAP_STRUCTS(maptype, keydecl, prefix) \
typedef struct prefix ## entry_t { \
HT_ENTRY(prefix ## entry_t) node; \
HT_HEAD(prefix ## impl, prefix ## entry_t) head; \
}
+/* DOCDOC DEFINE_MAP_STRUCTS */
DEFINE_MAP_STRUCTS(strmap_t, char *key, strmap_);
+/* DOCDOC DEFINE_MAP_STRUCTS */
DEFINE_MAP_STRUCTS(digestmap_t, char key[DIGEST_LEN], digestmap_);
/** Helper: compare strmap_entry_t objects by key value. */
return HT_START(strmap_impl, &map->head);
}
+/* DOCDOC digestmap_iter_init */
digestmap_iter_t *
digestmap_iter_init(digestmap_t *map)
{
return HT_NEXT(strmap_impl, &map->head, iter);
}
+/* DOCDOC digestmap_iter_next */
digestmap_iter_t *
digestmap_iter_next(digestmap_t *map, digestmap_iter_t *iter)
{
return iter;
}
+/* DOCDOC digestmap_iter_next_rmv */
digestmap_iter_t *
digestmap_iter_next_rmv(digestmap_t *map, digestmap_iter_t *iter)
{
*valp = (*iter)->val;
}
+/* DOCDOC digestmap_iter_get */
void
digestmap_iter_get(digestmap_iter_t *iter, const char **keyp, void **valp)
{
{
return iter == NULL;
}
+/* DOCDOC digestmap_iter_done */
int
digestmap_iter_done(digestmap_iter_t *iter)
{
HT_CLEAR(strmap_impl, &map->head);
tor_free(map);
}
+/* DOCDOC digestmap_free */
void
digestmap_free(digestmap_t *map, void (*free_val)(void*))
{
tor_free(map);
}
+/* DOCDOC strmap_assert_ok */
void
strmap_assert_ok(const strmap_t *map)
{
tor_assert(!_strmap_impl_HT_REP_IS_BAD(&map->head));
}
+/* DOCDOC digestmap_assert_ok */
void
digestmap_assert_ok(const digestmap_t *map)
{
return HT_EMPTY(&map->head);
}
+/* DOCDOC digestmap_isempty */
int
digestmap_isempty(const digestmap_t *map)
{
return HT_SIZE(&map->head);
}
+/* DOCDOC digestmap_size */
int
digestmap_size(const digestmap_t *map)
{
return _crypto_new_pk_env_rsa(rsa);
}
+/* DOCDOC _crypto_pk_env_get_rsa */
RSA *
_crypto_pk_env_get_rsa(crypto_pk_env_t *env)
{
tor_mutex_release(_openssl_mutexes[n]);
}
+/* DOCDOC CRYPTO_dynlock_value */
struct CRYPTO_dynlock_value {
tor_mutex_t *lock;
};
+/* DOCDOC _openssl_dynlock_create_cb */
static struct CRYPTO_dynlock_value *
_openssl_dynlock_create_cb(const char *file, int line)
{
return v;
}
+/* DOCDOC _openssl_dynlock_lock_cb */
static void
_openssl_dynlock_lock_cb(int mode, struct CRYPTO_dynlock_value *v,
const char *file, int line)
tor_mutex_release(v->lock);
}
+/* DOCDOC _openssl_dynlock_destroy_cb */
static void
_openssl_dynlock_destroy_cb(struct CRYPTO_dynlock_value *v,
const char *file, int line)
/** Length of hex encoding of SHA1 digest, not including final NUL. */
#define HEX_DIGEST_LEN 40
+/* DOCDOC crypto_pk_env_t */
typedef struct crypto_pk_env_t crypto_pk_env_t;
+/* DOCDOC crypto_cipher_env_t */
typedef struct crypto_cipher_env_t crypto_cipher_env_t;
+/* DOCDOC crypto_digest_env_t */
typedef struct crypto_digest_env_t crypto_digest_env_t;
+/* DOCDOC crypto_dh_env_t */
typedef struct crypto_dh_env_t crypto_dh_env_t;
/* global state */
#error "void* is neither 4 nor 8 bytes long. I don't know how to align stuff."
#endif
-/* Increment <b>ptr</b> until it is aligned to MEMAREA_ALIGN. */
+/** Increment <b>ptr</b> until it is aligned to MEMAREA_ALIGN. */
static INLINE void *
realign_pointer(void *ptr)
{
}
}
+/* DOCDOC chunk_free */
static void
chunk_free(memarea_chunk_t *chunk)
{
typedef enum {
TOR_ZLIB_OK, TOR_ZLIB_DONE, TOR_ZLIB_BUF_FULL, TOR_ZLIB_ERR
} tor_zlib_output_t;
+/** Internal state for an incremental zlib compression/decompression. */
typedef struct tor_zlib_state_t tor_zlib_state_t;
tor_zlib_state_t *tor_zlib_new(int compress, compress_method_t method);
*/
static int ftime_skew = 0;
static int ftime_slop = 60;
+/* DOCDOC ftime_set_maximum_sloppiness */
void
ftime_set_maximum_sloppiness(int seconds)
{
tor_assert(seconds >= 0);
ftime_slop = seconds;
}
+/* DOCDOC ftime_set_estimated_skew */
void
ftime_set_estimated_skew(int seconds)
{
ft_out->latest = now + ftime_skew + ftime_slop;
}
#endif
+/* DOCDOC ftime_maybe_after */
int
ftime_maybe_after(time_t now, time_t when)
{
/* It may be after when iff the latest possible current time is after when */
return (now + ftime_skew + ftime_slop) >= when;
}
+/* DOCDOC ftime_maybe_before */
int
ftime_maybe_before(time_t now, time_t when)
{
/* It may be before when iff the earliest possible current time is before */
return (now + ftime_skew - ftime_slop) < when;
}
+/* DOCDOC ftime_definitely_after */
int
ftime_definitely_after(time_t now, time_t when)
{
* after when. */
return (now + ftime_skew - ftime_slop) >= when;
}
+/* DOCDOC ftime_definitely_before */
int
ftime_definitely_before(time_t now, time_t when)
{
#define TOR_ISODIGIT(c) ('0' <= (c) && (c) <= '7')
-/* Given a c-style double-quoted escaped string in <b>s</b>, extract and
+/** Given a c-style double-quoted escaped string in <b>s</b>, extract and
* decode its contents into a newly allocated string. On success, assign this
* string to *<b>result</b>, assign its length to <b>size_out</b> (if
* provided), and return a pointer to the position in <b>s</b> immediately
return buf;
}
+/* DOCDOC dir_connection_new */
dir_connection_t *
dir_connection_new(int socket_family)
{
connection_init(time(NULL), TO_CONN(dir_conn), CONN_TYPE_DIR, socket_family);
return dir_conn;
}
+/* DOCDOC or_connection_new */
or_connection_t *
or_connection_new(int socket_family)
{
return or_conn;
}
+/* DOCDOC edge_connection_new */
edge_connection_t *
edge_connection_new(int type, int socket_family)
{
edge_conn->socks_request = tor_malloc_zero(sizeof(socks_request_t));
return edge_conn;
}
+/* DOCDOC control_connection_new */
control_connection_t *
control_connection_new(int socket_family)
{
return control_conn;
}
+/* DOCDOC connection_new */
connection_t *
connection_new(int type, int socket_family)
{
};
#endif /* HAVE_SYS_UN_H */
+/* DOCDOC warn_too_many_conns */
static void
warn_too_many_conns(void)
{
#define EXTENDED_FORMAT 4
#define NONEXTENDED_FORMAT 8
#define ALL_FORMATS (EXTENDED_FORMAT|NONEXTENDED_FORMAT)
+/* DOCDOC event_format_t */
typedef int event_format_t;
static void connection_printf_to_buf(control_connection_t *conn,
connection_write_str_to_buf("250 OK\r\n", conn);
}
-/* Send an event to all v1 controllers that are listening for code
+/** Send an event to all v1 controllers that are listening for code
* <b>event</b>. The event's body is given by <b>msg</b>.
*
* If <b>which</b> & SHORT_NAMES, the event contains short-format names: send
}
}
-/* Send an event to all v1 controllers that are listening for code
+/** Send an event to all v1 controllers that are listening for code
* <b>event</b>. The event's body is created by the printf-style format in
* <b>format</b>, and other arguments as provided.
*
va_end(ap);
}
-/* Send an event to all v1 controllers that are listening for code
+/** Send an event to all v1 controllers that are listening for code
* <b>event</b>. The event's body is created by the printf-style format in
* <b>format</b>, and other arguments as provided.
*
}
}
-/* Called when Tor has failed to make bootstrapping progress in a way
+/** Called when Tor has failed to make bootstrapping progress in a way
* that indicates a problem. <b>warn</b> gives a hint as to why, and
* <b>reason</b> provides an "or_conn_end_reason" tag.
*/
#if (CONDITIONAL_CONSENSUS_FPR_LEN > DIGEST_LEN)
#error "conditional consensus fingerprint length is larger than digest length"
#endif
+
+/* DOCDOC directory_get_consensus_url */
static char *
directory_get_consensus_url(int supports_conditional_consensus)
{
* of request. Maps from request type to pointer to request_t. */
static strmap_t *request_map = NULL;
+/* DOCDOC note_client_request */
static void
note_client_request(int purpose, int compressed, size_t bytes)
{
return 1;
}
-/* Return 1 if we should fetch new networkstatuses, descriptors, etc
+/** Return 1 if we should fetch new networkstatuses, descriptors, etc
* on the "mirror" schedule rather than the "client" schedule.
*/
int
return directory_fetches_from_authorities(options);
}
-/* Return 1 if we should fetch new networkstatuses, descriptors, etc
+/** Return 1 if we should fetch new networkstatuses, descriptors, etc
* on a very passive schedule -- waiting long enough for ordinary clients
* to probably have the info we want. These would include bridge users,
* and maybe others in the future e.g. if a Tor client uses another Tor
"v1 network status list", V1_AUTHORITY);
}
+/* DOCDOC */
cached_dir_t *
dirserv_get_consensus(void)
{
return smartlist_get(vote->voters, 0);
}
-typedef struct {
+/* DOCDOC dir_src_ent_t */
+typedef struct dir_src_ent_t {
networkstatus_t *v;
const char *digest;
int is_legacy;
get_voter(b)->identity_digest, DIGEST_LEN);
}
+/* DOCDOC _compare_dir_src_ents_by_authority_id */
static int
_compare_dir_src_ents_by_authority_id(const void **_a, const void **_b)
{
log(severity, LD_EXIT, "eventdns: %s", msg);
}
+/* DOCDOC randfn */
static void
randfn(char *b, size_t n)
{
#include "or.h"
#include "eventdns.h"
-/* Helper function: called by evdns whenever the client sends a request to our
+/** Helper function: called by evdns whenever the client sends a request to our
* DNSPort. We need to eventually answer the request <b>req</b>.
*/
static void
tor_free(q_name);
}
-/* Helper function: called whenever the client sends a resolve request to our
+/** Helper function: called whenever the client sends a resolve request to our
* controller. We need to eventually answer the request <b>req</b>.
* Returns 0 if the controller will be getting (or has gotten) an event in
* response; -1 if we couldn't launch the request.
conn->dns_server_request = NULL;
}
-/* Set up the evdns server port for the UDP socket on <b>conn</b>, which
+/** Set up the evdns server port for the UDP socket on <b>conn</b>, which
* must be an AP_DNS_LISTENER */
void
dnsserv_configure_listener(connection_t *conn)
* are willing to talk about it? */
#define GEOIP_MIN_OBSERVATION_TIME (12*60*60)
+/* DOCDOC round_to_next_multiple_of */
static INLINE unsigned
round_to_next_multiple_of(unsigned number, unsigned divisor)
{
return result;
}
+/* DOCDOC dump_geoip_stats */
void
dump_geoip_stats(void)
{
}
}
+/* DOCDOC have_lockfile */
int
have_lockfile(void)
{
return lockfile != NULL;
}
+/* DOCDOC release_lockfile */
void
release_lockfile(void)
{
return 0;
}
+/** Free all storage held by the vote_routerstatus object <b>rs</b>. */
static void
vote_routerstatus_free(vote_routerstatus_t *rs)
{
#define AT(x) ((policy_summary_item_t*)smartlist_get(summary, x))
#define REJECT_CUTOFF_COUNT (1<<25)
-/* Split an exit policy summary so that prt_min and prt_max
+/** Split an exit policy summary so that prt_min and prt_max
* fall at exactly the start and end of an item respectively.
*/
static int
++total_cells_allocated;
return mp_pool_get(cell_pool);
}
+/* DOCDOC dump_cell_pool_usage */
void
dump_cell_pool_usage(int severity)
{
return authority_signing_key;
}
+/* DOCDOC get_my_v3_legacy_cert */
authority_cert_t *
get_my_v3_legacy_cert(void)
{
return legacy_key_certificate;
}
+/* DOCDOC get_my_v3_legacy_signing_key */
crypto_pk_env_t *
get_my_v3_legacy_signing_key(void)
{
return NULL;
}
+/* DOCDOC load_authority_keyset */
static int
load_authority_keyset(int legacy, crypto_pk_env_t **key_out,
authority_cert_t **cert_out)
return body;
}
-/* Return the extrainfo document for this OR, or NULL if we have none.
+/** Return the extrainfo document for this OR, or NULL if we have none.
* Rebuilt it (and the server descriptor) if necessary. */
extrainfo_t *
router_get_my_extrainfo(void)
return store->journal_len > (1<<15);
}
+/* DOCDOC desc_get_store */
static INLINE desc_store_t *
desc_get_store(routerlist_t *rl, signed_descriptor_t *sd)
{
#endif
}
+/* DOCDOC _routerlist_find_elt */
static INLINE int
_routerlist_find_elt(smartlist_t *sl, void *ri, int idx)
{
return dir_info_status;
}
+/* DOCDOC count_usable_descriptors */
static void
count_usable_descriptors(int *num_present, int *num_usable,
const networkstatus_t *consensus,
goto done_tokenizing; \
STMT_END
+/* DOCDOC token_check_object */
static INLINE directory_token_t *
token_check_object(memarea_t *area, const char *kwd,
directory_token_t *tok, obj_syntax o_syn)
static char temp_dir[256];
+/* DOCDOC setup_directory */
static void
setup_directory(void)
{
is_setup = 1;
}
+/* DOCDOC get_fname */
static const char *
get_fname(const char *name)
{
return buf;
}
+/* DOCDOC remove_directory */
static void
remove_directory(void)
{
#undef CACHE_GENERATED_KEYS
static crypto_pk_env_t *pregen_keys[5] = {NULL, NULL, NULL, NULL, NULL};
+/* DOCDOC pk_generate */
static crypto_pk_env_t *
pk_generate(int idx)
{
#endif
}
+/* DOCDOC free_pregenerated_keys */
static void
free_pregenerated_keys(void)
{
}
}
+/* DOCDOC test_buffers */
static void
test_buffers(void)
{
buf_free(buf2);
}
+/* DOCDOC test_crypto_dh */
static void
test_crypto_dh(void)
{
crypto_dh_free(dh2);
}
+/* DOCDOC test_crypto_rng */
static void
test_crypto_rng(void)
{
;
}
+/* DOCDOC test_crypto_aes */
static void
test_crypto_aes(void)
{
tor_free(data3);
}
+/* DOCDOC test_crypto_sha */
static void
test_crypto_sha(void)
{
crypto_free_digest_env(d2);
}
+/* DOCDOC test_crypto_pk */
static void
test_crypto_pk(void)
{
tor_free(encoded);
}
+/* DOCDOC test_crypto */
static void
test_crypto(void)
{
tor_free(data3);
}
+/* DOCDOC test_crypto_s2k */
static void
test_crypto_s2k(void)
{
tor_free(buf3);
}
+/* DOCDOC _compare_strs */
static int
_compare_strs(const void **a, const void **b)
{
return strcmp(s1, s2);
}
+/* DOCDOC _compare_without_first_ch */
static int
_compare_without_first_ch(const void *a, const void **b)
{
return strcasecmp(s1+1, s2);
}
+/* DOCDOC test_util */
static void
test_util(void)
{
test_eq(port2, pt2); \
STMT_END
+/* DOCDOC test_util_ip6_helpers */
static void
test_util_ip6_helpers(void)
{
;
}
+/* DOCDOC test_util_smartlist_basic */
static void
test_util_smartlist_basic(void)
{
smartlist_free(sl);
}
+/* DOCDOC test_util_smartlist_strings */
static void
test_util_smartlist_strings(void)
{
tor_free(cp_alloc);
}
+/* DOCDOC test_util_smartlist_overlap */
static void
test_util_smartlist_overlap(void)
{
smartlist_free(sl);
}
+/* DOCDOC test_util_smartlist_digests */
static void
test_util_smartlist_digests(void)
{
smartlist_free(sl);
}
+/* DOCDOC test_util_smartlist_join */
static void
test_util_smartlist_join(void)
{
tor_free(joined);
}
+/* DOCDOC test_util_bitarray */
static void
test_util_bitarray(void)
{
bitarray_free(ba);
}
+/* DOCDOC test_util_digestset */
static void
test_util_digestset(void)
{
static char *_thread1_name = NULL;
static char *_thread2_name = NULL;
+/* DOCDOC _thread_test_func */
static void _thread_test_func(void* _s) ATTR_NORETURN;
static int t1_count = 0;
spawn_exit();
}
+/* DOCDOC test_util_threads */
static void
test_util_threads(void)
{
tor_mutex_free(_thread_test_start2);
}
+/* DOCDOC _compare_strings_for_pqueue */
static int
_compare_strings_for_pqueue(const void *s1, const void *s2)
{
return strcmp((const char*)s1, (const char*)s2);
}
+/* DOCDOC test_util_pqueue */
static void
test_util_pqueue(void)
{
smartlist_free(sl);
}
+/* DOCDOC test_util_gzip */
static void
test_util_gzip(void)
{
tor_free(buf1);
}
+/* DOCDOC test_util_strmap */
static void
test_util_strmap(void)
{
tor_free(visited);
}
+/* DOCDOC test_util_mmap */
static void
test_util_mmap(void)
{
tor_munmap_file(mapping);
}
+/* DOCDOC test_util_control_formats */
static void
test_util_control_formats(void)
{
tor_free(out);
}
+/* DOCDOC test_onion_handshake */
static void
test_onion_handshake(void)
{
extern smartlist_t *fingerprint_list;
+/* DOCDOC test_dir_format */
static void
test_dir_format(void)
{
tor_free(dir2); /* And more !*/
}
+/* DOCDOC test_dirutil */
static void
test_dirutil(void)
{
extern const char AUTHORITY_CERT_3[];
extern const char AUTHORITY_SIGNKEY_3[];
+/* DOCDOC test_same_voter */
static void
test_same_voter(networkstatus_voter_info_t *v1,
networkstatus_voter_info_t *v2)
;
}
+/* DOCDOC test_util_order_functions */
static void
test_util_order_functions(void)
{
;
}
+/* DOCDOC generate_ri_from_rs */
static routerinfo_t *
generate_ri_from_rs(const vote_routerstatus_t *vrs)
{
return r;
}
+/* DOCDOC test_v3_networkstatus */
static void
test_v3_networkstatus(void)
{
ns_detached_signatures_free(dsig2);
}
+/* DOCDOC test_policy_summary_helper */
static void
test_policy_summary_helper(const char *policy_str,
const char *expected_summary)
addr_policy_list_free(policy);
}
+/* DOCDOC test_policies */
static void
test_policies(void)
{
}
}
+/* DOCDOC test_rend_fns */
static void
test_rend_fns(void)
{
tor_free(encoded);
}
+/* DOCDOC bench_aes */
static void
bench_aes(void)
{
crypto_free_cipher_env(c);
}
+/* DOCDOC bench_dmap */
static void
bench_dmap(void)
{
smartlist_free(sl2);
}
+/* DOCDOC test_util_mempool */
static void
test_util_mempool(void)
{
mp_pool_destroy(pool);
}
+/* DOCDOC test_util_memarea */
static void
test_util_memarea(void)
{
tor_free(malloced_ptr);
}
+/* DOCDOC test_util_datadir */
static void
test_util_datadir(void)
{
}
/* Test AES-CTR encryption and decryption with IV. */
+/* DOCDOC test_crypto_aes_iv */
static void
test_crypto_aes_iv(void)
{
}
/* Test base32 decoding. */
+/* DOCDOC test_crypto_base32_decode */
static void
test_crypto_base32_decode(void)
{
}
/* Test encoding and parsing of v2 rendezvous service descriptors. */
+/* DOCDOC test_rend_fns_v2 */
static void
test_rend_fns_v2(void)
{
tor_free(intro_points_encrypted);
}
+/* DOCDOC test_geoip */
static void
test_geoip(void)
{
};
static void syntax(void) ATTR_NORETURN;
+/* DOCDOC syntax */
static void
syntax(void)
{
exit(0);
}
+/* DOCDOC main */
int
main(int c, char**v)
{