2010-07-21 16:17:10 +02:00
|
|
|
/* Copyright (c) 2001 Matej Pfajfar.
|
|
|
|
* Copyright (c) 2001-2004, Roger Dingledine.
|
|
|
|
* Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
|
2012-06-05 02:58:17 +02:00
|
|
|
* Copyright (c) 2007-2012, The Tor Project, Inc. */
|
2010-07-21 16:17:10 +02:00
|
|
|
/* See LICENSE for licensing information */
|
|
|
|
|
|
|
|
/**
|
|
|
|
* \file router.h
|
2010-07-28 17:42:33 +02:00
|
|
|
* \brief Header file for router.c.
|
2010-07-21 16:17:10 +02:00
|
|
|
**/
|
|
|
|
|
|
|
|
#ifndef _TOR_ROUTER_H
|
|
|
|
#define _TOR_ROUTER_H
|
|
|
|
|
2012-01-18 21:53:30 +01:00
|
|
|
crypto_pk_t *get_onion_key(void);
|
2010-07-21 16:17:10 +02:00
|
|
|
time_t get_onion_key_set_at(void);
|
2012-01-18 21:53:30 +01:00
|
|
|
void set_server_identity_key(crypto_pk_t *k);
|
|
|
|
crypto_pk_t *get_server_identity_key(void);
|
2010-10-04 07:38:53 +02:00
|
|
|
int server_identity_key_is_set(void);
|
2012-01-18 21:53:30 +01:00
|
|
|
void set_client_identity_key(crypto_pk_t *k);
|
|
|
|
crypto_pk_t *get_tlsclient_identity_key(void);
|
2010-10-04 07:38:53 +02:00
|
|
|
int client_identity_key_is_set(void);
|
2010-07-21 16:17:10 +02:00
|
|
|
authority_cert_t *get_my_v3_authority_cert(void);
|
2012-01-18 21:53:30 +01:00
|
|
|
crypto_pk_t *get_my_v3_authority_signing_key(void);
|
2010-07-21 16:17:10 +02:00
|
|
|
authority_cert_t *get_my_v3_legacy_cert(void);
|
2012-01-18 21:53:30 +01:00
|
|
|
crypto_pk_t *get_my_v3_legacy_signing_key(void);
|
|
|
|
void dup_onion_keys(crypto_pk_t **key, crypto_pk_t **last);
|
2010-07-21 16:17:10 +02:00
|
|
|
void rotate_onion_key(void);
|
2012-01-18 21:53:30 +01:00
|
|
|
crypto_pk_t *init_key_from_file(const char *fname, int generate,
|
2010-07-21 16:17:10 +02:00
|
|
|
int severity);
|
|
|
|
void v3_authority_check_key_expiry(void);
|
|
|
|
|
2011-11-24 06:40:02 +01:00
|
|
|
int router_initialize_tls_context(void);
|
2010-07-21 16:17:10 +02:00
|
|
|
int init_keys(void);
|
|
|
|
|
|
|
|
int check_whether_orport_reachable(void);
|
|
|
|
int check_whether_dirport_reachable(void);
|
|
|
|
void consider_testing_reachability(int test_or, int test_dir);
|
|
|
|
void router_orport_found_reachable(void);
|
|
|
|
void router_dirport_found_reachable(void);
|
|
|
|
void router_perform_bandwidth_test(int num_circs, time_t now);
|
|
|
|
|
2011-11-28 21:44:10 +01:00
|
|
|
int net_is_disabled(void);
|
|
|
|
|
2011-06-14 19:01:38 +02:00
|
|
|
int authdir_mode(const or_options_t *options);
|
|
|
|
int authdir_mode_v1(const or_options_t *options);
|
|
|
|
int authdir_mode_v2(const or_options_t *options);
|
|
|
|
int authdir_mode_v3(const or_options_t *options);
|
|
|
|
int authdir_mode_any_main(const or_options_t *options);
|
|
|
|
int authdir_mode_any_nonhidserv(const or_options_t *options);
|
|
|
|
int authdir_mode_handles_descs(const or_options_t *options, int purpose);
|
|
|
|
int authdir_mode_publishes_statuses(const or_options_t *options);
|
|
|
|
int authdir_mode_tests_reachability(const or_options_t *options);
|
|
|
|
int authdir_mode_bridge(const or_options_t *options);
|
2010-07-21 16:17:10 +02:00
|
|
|
|
2012-03-31 13:54:09 +02:00
|
|
|
uint16_t router_get_active_listener_port_by_type(int listener_type);
|
2011-06-14 19:01:38 +02:00
|
|
|
uint16_t router_get_advertised_or_port(const or_options_t *options);
|
|
|
|
uint16_t router_get_advertised_dir_port(const or_options_t *options,
|
2011-06-02 13:30:32 +02:00
|
|
|
uint16_t dirport);
|
2011-05-02 21:51:30 +02:00
|
|
|
|
2011-06-14 19:01:38 +02:00
|
|
|
int server_mode(const or_options_t *options);
|
|
|
|
int public_server_mode(const or_options_t *options);
|
2010-07-21 16:17:10 +02:00
|
|
|
int advertised_server_mode(void);
|
2011-06-14 19:01:38 +02:00
|
|
|
int proxy_mode(const or_options_t *options);
|
2010-07-21 16:17:10 +02:00
|
|
|
void consider_publishable_server(int force);
|
2011-06-14 19:01:38 +02:00
|
|
|
int should_refuse_unknown_exits(const or_options_t *options);
|
2010-07-21 16:17:10 +02:00
|
|
|
|
|
|
|
void router_upload_dir_desc_to_dirservers(int force);
|
2011-06-22 18:27:27 +02:00
|
|
|
void mark_my_descriptor_dirty_if_too_old(time_t now);
|
2011-05-20 05:36:20 +02:00
|
|
|
void mark_my_descriptor_dirty(const char *reason);
|
2010-07-21 16:17:10 +02:00
|
|
|
void check_descriptor_bandwidth_changed(time_t now);
|
|
|
|
void check_descriptor_ipaddress_changed(time_t now);
|
|
|
|
void router_new_address_suggestion(const char *suggestion,
|
|
|
|
const dir_connection_t *d_conn);
|
|
|
|
int router_compare_to_my_exit_policy(edge_connection_t *conn);
|
2010-09-21 07:03:29 +02:00
|
|
|
int router_my_exit_policy_is_reject_star(void);
|
2010-09-29 06:38:32 +02:00
|
|
|
const routerinfo_t *router_get_my_routerinfo(void);
|
2010-07-21 16:17:10 +02:00
|
|
|
extrainfo_t *router_get_my_extrainfo(void);
|
|
|
|
const char *router_get_my_descriptor(void);
|
2011-06-24 22:43:08 +02:00
|
|
|
const char *router_get_descriptor_gen_reason(void);
|
2010-07-21 16:17:10 +02:00
|
|
|
int router_digest_is_me(const char *digest);
|
|
|
|
int router_extrainfo_digest_is_me(const char *digest);
|
2010-09-29 06:38:32 +02:00
|
|
|
int router_is_me(const routerinfo_t *router);
|
2010-07-21 16:17:10 +02:00
|
|
|
int router_fingerprint_is_me(const char *fp);
|
2011-06-14 19:01:38 +02:00
|
|
|
int router_pick_published_address(const or_options_t *options, uint32_t *addr);
|
2010-07-21 16:17:10 +02:00
|
|
|
int router_rebuild_descriptor(int force);
|
|
|
|
int router_dump_router_to_string(char *s, size_t maxlen, routerinfo_t *router,
|
2012-01-18 21:53:30 +01:00
|
|
|
crypto_pk_t *ident_key);
|
2011-11-28 13:47:12 +01:00
|
|
|
void router_get_prim_orport(const routerinfo_t *router,
|
|
|
|
tor_addr_port_t *addr_port_out);
|
|
|
|
void router_get_pref_orport(const routerinfo_t *router,
|
|
|
|
tor_addr_port_t *addr_port_out);
|
2011-11-28 13:51:56 +01:00
|
|
|
void router_get_pref_ipv6_orport(const routerinfo_t *router,
|
|
|
|
tor_addr_port_t *addr_port_out);
|
2011-11-24 18:29:56 +01:00
|
|
|
int router_ipv6_preferred(const routerinfo_t *router);
|
2012-05-09 17:58:01 +02:00
|
|
|
int router_has_addr(const routerinfo_t *router, const tor_addr_t *addr);
|
|
|
|
int router_has_orport(const routerinfo_t *router, const tor_addr_port_t *orport);
|
2010-11-13 22:25:19 +01:00
|
|
|
int extrainfo_dump_to_string(char **s, extrainfo_t *extrainfo,
|
2012-01-18 21:53:30 +01:00
|
|
|
crypto_pk_t *ident_key);
|
2010-07-21 16:17:10 +02:00
|
|
|
int is_legal_nickname(const char *s);
|
|
|
|
int is_legal_nickname_or_hexdigest(const char *s);
|
|
|
|
int is_legal_hexdigest(const char *s);
|
2011-05-16 03:58:46 +02:00
|
|
|
|
2011-05-30 21:15:10 +02:00
|
|
|
/**
|
|
|
|
* Longest allowed output of format_node_description, plus 1 character for
|
|
|
|
* NUL. This allows space for:
|
|
|
|
* "$FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF~xxxxxxxxxxxxxxxxxxx at"
|
|
|
|
* " [ffff:ffff:ffff:ffff:ffff:ffff:255.255.255.255]"
|
|
|
|
* plus a terminating NUL.
|
|
|
|
*/
|
2011-05-16 03:58:46 +02:00
|
|
|
#define NODE_DESC_BUF_LEN (MAX_VERBOSE_NICKNAME_LEN+4+TOR_ADDR_BUF_LEN)
|
|
|
|
const char *format_node_description(char *buf,
|
|
|
|
const char *id_digest,
|
|
|
|
int is_named,
|
|
|
|
const char *nickname,
|
|
|
|
const tor_addr_t *addr,
|
|
|
|
uint32_t addr32h);
|
|
|
|
const char *router_get_description(char *buf, const routerinfo_t *ri);
|
2011-05-30 21:41:46 +02:00
|
|
|
const char *node_get_description(char *buf, const node_t *node);
|
2011-05-16 03:58:46 +02:00
|
|
|
const char *routerstatus_get_description(char *buf, const routerstatus_t *rs);
|
|
|
|
const char *extend_info_get_description(char *buf, const extend_info_t *ei);
|
|
|
|
const char *router_describe(const routerinfo_t *ri);
|
2011-05-30 21:41:46 +02:00
|
|
|
const char *node_describe(const node_t *node);
|
2011-05-16 03:58:46 +02:00
|
|
|
const char *routerstatus_describe(const routerstatus_t *ri);
|
|
|
|
const char *extend_info_describe(const extend_info_t *ei);
|
|
|
|
|
2010-07-21 16:17:10 +02:00
|
|
|
void router_get_verbose_nickname(char *buf, const routerinfo_t *router);
|
|
|
|
void routerstatus_get_verbose_nickname(char *buf,
|
|
|
|
const routerstatus_t *router);
|
|
|
|
void router_reset_warnings(void);
|
|
|
|
void router_reset_reachability(void);
|
|
|
|
void router_free_all(void);
|
|
|
|
|
|
|
|
const char *router_purpose_to_string(uint8_t p);
|
|
|
|
uint8_t router_purpose_from_string(const char *s);
|
|
|
|
|
|
|
|
#ifdef ROUTER_PRIVATE
|
|
|
|
/* Used only by router.c and test.c */
|
|
|
|
void get_platform_str(char *platform, size_t len);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|