Back to index

tor  0.2.3.18-rc
router.h
Go to the documentation of this file.
00001 /* Copyright (c) 2001 Matej Pfajfar.
00002  * Copyright (c) 2001-2004, Roger Dingledine.
00003  * Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
00004  * Copyright (c) 2007-2012, The Tor Project, Inc. */
00005 /* See LICENSE for licensing information */
00006 
00012 #ifndef _TOR_ROUTER_H
00013 #define _TOR_ROUTER_H
00014 
00015 crypto_pk_t *get_onion_key(void);
00016 time_t get_onion_key_set_at(void);
00017 void set_server_identity_key(crypto_pk_t *k);
00018 crypto_pk_t *get_server_identity_key(void);
00019 int server_identity_key_is_set(void);
00020 void set_client_identity_key(crypto_pk_t *k);
00021 crypto_pk_t *get_tlsclient_identity_key(void);
00022 int client_identity_key_is_set(void);
00023 authority_cert_t *get_my_v3_authority_cert(void);
00024 crypto_pk_t *get_my_v3_authority_signing_key(void);
00025 authority_cert_t *get_my_v3_legacy_cert(void);
00026 crypto_pk_t *get_my_v3_legacy_signing_key(void);
00027 void dup_onion_keys(crypto_pk_t **key, crypto_pk_t **last);
00028 void rotate_onion_key(void);
00029 crypto_pk_t *init_key_from_file(const char *fname, int generate,
00030                                     int severity);
00031 void v3_authority_check_key_expiry(void);
00032 
00033 int router_initialize_tls_context(void);
00034 int init_keys(void);
00035 
00036 int check_whether_orport_reachable(void);
00037 int check_whether_dirport_reachable(void);
00038 void consider_testing_reachability(int test_or, int test_dir);
00039 void router_orport_found_reachable(void);
00040 void router_dirport_found_reachable(void);
00041 void router_perform_bandwidth_test(int num_circs, time_t now);
00042 
00043 int net_is_disabled(void);
00044 
00045 int authdir_mode(const or_options_t *options);
00046 int authdir_mode_v1(const or_options_t *options);
00047 int authdir_mode_v2(const or_options_t *options);
00048 int authdir_mode_v3(const or_options_t *options);
00049 int authdir_mode_any_main(const or_options_t *options);
00050 int authdir_mode_any_nonhidserv(const or_options_t *options);
00051 int authdir_mode_handles_descs(const or_options_t *options, int purpose);
00052 int authdir_mode_publishes_statuses(const or_options_t *options);
00053 int authdir_mode_tests_reachability(const or_options_t *options);
00054 int authdir_mode_bridge(const or_options_t *options);
00055 
00056 uint16_t router_get_active_listener_port_by_type(int listener_type);
00057 uint16_t router_get_advertised_or_port(const or_options_t *options);
00058 uint16_t router_get_advertised_dir_port(const or_options_t *options,
00059                                         uint16_t dirport);
00060 
00061 int server_mode(const or_options_t *options);
00062 int public_server_mode(const or_options_t *options);
00063 int advertised_server_mode(void);
00064 int proxy_mode(const or_options_t *options);
00065 void consider_publishable_server(int force);
00066 int should_refuse_unknown_exits(const or_options_t *options);
00067 
00068 void router_upload_dir_desc_to_dirservers(int force);
00069 void mark_my_descriptor_dirty_if_too_old(time_t now);
00070 void mark_my_descriptor_dirty(const char *reason);
00071 void check_descriptor_bandwidth_changed(time_t now);
00072 void check_descriptor_ipaddress_changed(time_t now);
00073 void router_new_address_suggestion(const char *suggestion,
00074                                    const dir_connection_t *d_conn);
00075 int router_compare_to_my_exit_policy(edge_connection_t *conn);
00076 int router_my_exit_policy_is_reject_star(void);
00077 const routerinfo_t *router_get_my_routerinfo(void);
00078 extrainfo_t *router_get_my_extrainfo(void);
00079 const char *router_get_my_descriptor(void);
00080 const char *router_get_descriptor_gen_reason(void);
00081 int router_digest_is_me(const char *digest);
00082 int router_extrainfo_digest_is_me(const char *digest);
00083 int router_is_me(const routerinfo_t *router);
00084 int router_fingerprint_is_me(const char *fp);
00085 int router_pick_published_address(const or_options_t *options, uint32_t *addr);
00086 int router_rebuild_descriptor(int force);
00087 int router_dump_router_to_string(char *s, size_t maxlen, routerinfo_t *router,
00088                                  crypto_pk_t *ident_key);
00089 void router_get_prim_orport(const routerinfo_t *router,
00090                             tor_addr_port_t *addr_port_out);
00091 void router_get_pref_orport(const routerinfo_t *router,
00092                             tor_addr_port_t *addr_port_out);
00093 void router_get_pref_ipv6_orport(const routerinfo_t *router,
00094                                  tor_addr_port_t *addr_port_out);
00095 int router_ipv6_preferred(const routerinfo_t *router);
00096 int extrainfo_dump_to_string(char **s, extrainfo_t *extrainfo,
00097                              crypto_pk_t *ident_key);
00098 int is_legal_nickname(const char *s);
00099 int is_legal_nickname_or_hexdigest(const char *s);
00100 int is_legal_hexdigest(const char *s);
00101 
00109 #define NODE_DESC_BUF_LEN (MAX_VERBOSE_NICKNAME_LEN+4+TOR_ADDR_BUF_LEN)
00110 const char *format_node_description(char *buf,
00111                                     const char *id_digest,
00112                                     int is_named,
00113                                     const char *nickname,
00114                                     const tor_addr_t *addr,
00115                                     uint32_t addr32h);
00116 const char *router_get_description(char *buf, const routerinfo_t *ri);
00117 const char *node_get_description(char *buf, const node_t *node);
00118 const char *routerstatus_get_description(char *buf, const routerstatus_t *rs);
00119 const char *extend_info_get_description(char *buf, const extend_info_t *ei);
00120 const char *router_describe(const routerinfo_t *ri);
00121 const char *node_describe(const node_t *node);
00122 const char *routerstatus_describe(const routerstatus_t *ri);
00123 const char *extend_info_describe(const extend_info_t *ei);
00124 
00125 void router_get_verbose_nickname(char *buf, const routerinfo_t *router);
00126 void routerstatus_get_verbose_nickname(char *buf,
00127                                        const routerstatus_t *router);
00128 void router_reset_warnings(void);
00129 void router_reset_reachability(void);
00130 void router_free_all(void);
00131 
00132 const char *router_purpose_to_string(uint8_t p);
00133 uint8_t router_purpose_from_string(const char *s);
00134 
00135 #ifdef ROUTER_PRIVATE
00136 /* Used only by router.c and test.c */
00137 void get_platform_str(char *platform, size_t len);
00138 #endif
00139 
00140 #endif
00141