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.
|
2017-03-15 21:13:17 +01:00
|
|
|
* Copyright (c) 2007-2017, 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
|
|
|
**/
|
|
|
|
|
2012-10-12 18:13:10 +02:00
|
|
|
#ifndef TOR_ROUTER_H
|
|
|
|
#define TOR_ROUTER_H
|
2010-07-21 16:17:10 +02:00
|
|
|
|
2013-06-06 23:58:28 +02:00
|
|
|
#include "testsupport.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);
|
2015-09-07 19:22:33 +02:00
|
|
|
MOCK_DECL(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);
|
2017-03-10 13:00:20 +01:00
|
|
|
void expire_old_onion_keys(void);
|
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,
|
2014-12-11 06:30:14 +01:00
|
|
|
int severity, int log_greeting);
|
2010-07-21 16:17:10 +02:00
|
|
|
void v3_authority_check_key_expiry(void);
|
2017-03-10 12:18:52 +01:00
|
|
|
int get_onion_key_lifetime(void);
|
2017-03-10 12:56:36 +01:00
|
|
|
int get_onion_key_grace_period(void);
|
2010-07-21 16:17:10 +02:00
|
|
|
|
2012-12-04 21:58:18 +01:00
|
|
|
di_digest256_map_t *construct_ntor_key_map(void);
|
2017-11-21 15:37:47 +01:00
|
|
|
void ntor_key_map_free_(di_digest256_map_t *map);
|
2017-12-04 21:09:18 +01:00
|
|
|
#define ntor_key_map_free(map) \
|
2017-12-07 16:44:04 +01:00
|
|
|
FREE_AND_NULL(di_digest256_map_t, ntor_key_map_free_, (map))
|
2012-12-04 21:58:18 +01:00
|
|
|
|
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);
|
2015-08-11 16:35:10 +02:00
|
|
|
int init_keys_client(void);
|
2010-07-21 16:17:10 +02:00
|
|
|
|
2016-05-16 23:43:47 +02:00
|
|
|
int check_whether_orport_reachable(const or_options_t *options);
|
|
|
|
int check_whether_dirport_reachable(const or_options_t *options);
|
2014-10-28 23:01:06 +01:00
|
|
|
int dir_server_mode(const or_options_t *options);
|
2018-01-24 20:07:49 +01:00
|
|
|
void router_do_reachability_checks(int test_or, int test_dir);
|
2010-07-21 16:17:10 +02:00
|
|
|
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_v3(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
|
|
|
|
2013-03-11 22:20:43 +01:00
|
|
|
uint16_t router_get_active_listener_port_by_type_af(int listener_type,
|
|
|
|
sa_family_t family);
|
2011-06-14 19:01:38 +02:00
|
|
|
uint16_t router_get_advertised_or_port(const or_options_t *options);
|
2013-03-11 22:20:43 +01:00
|
|
|
uint16_t router_get_advertised_or_port_by_af(const or_options_t *options,
|
|
|
|
sa_family_t family);
|
2011-06-14 19:01:38 +02:00
|
|
|
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
|
|
|
|
2014-04-15 14:20:34 +02:00
|
|
|
MOCK_DECL(int, server_mode, (const or_options_t *options));
|
|
|
|
MOCK_DECL(int, public_server_mode, (const or_options_t *options));
|
2015-12-17 01:40:49 +01:00
|
|
|
MOCK_DECL(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);
|
2012-11-05 19:11:53 +01:00
|
|
|
int router_compare_to_my_exit_policy(const tor_addr_t *addr, uint16_t port);
|
2015-10-08 20:47:52 +02:00
|
|
|
MOCK_DECL(int, router_my_exit_policy_is_reject_star,(void));
|
2014-04-15 14:20:34 +02:00
|
|
|
MOCK_DECL(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);
|
2012-12-05 03:27:07 +01:00
|
|
|
const uint8_t *router_get_my_id_digest(void);
|
2010-07-21 16:17:10 +02:00
|
|
|
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);
|
2015-12-17 01:40:49 +01:00
|
|
|
MOCK_DECL(int,router_pick_published_address,(const or_options_t *options,
|
2016-11-16 22:13:03 +01:00
|
|
|
uint32_t *addr,
|
|
|
|
int cache_only));
|
2015-02-07 13:29:26 +01:00
|
|
|
int router_build_fresh_descriptor(routerinfo_t **r, extrainfo_t **e);
|
2010-07-21 16:17:10 +02:00
|
|
|
int router_rebuild_descriptor(int force);
|
2013-02-22 18:17:23 +01:00
|
|
|
char *router_dump_router_to_string(routerinfo_t *router,
|
2014-10-01 17:54:07 +02:00
|
|
|
const crypto_pk_t *ident_key,
|
|
|
|
const crypto_pk_t *tap_key,
|
|
|
|
const curve25519_keypair_t *ntor_keypair,
|
2014-10-01 05:36:47 +02:00
|
|
|
const ed25519_keypair_t *signing_keypair);
|
2013-08-23 20:06:42 +02:00
|
|
|
char *router_dump_exit_policy_to_string(const routerinfo_t *router,
|
|
|
|
int include_ipv4,
|
|
|
|
int include_ipv6);
|
2012-08-23 12:23:00 +02:00
|
|
|
void router_get_prim_orport(const routerinfo_t *router,
|
2012-08-01 11:38:43 +02:00
|
|
|
tor_addr_port_t *addr_port_out);
|
|
|
|
void router_get_pref_orport(const routerinfo_t *router,
|
|
|
|
tor_addr_port_t *addr_port_out);
|
|
|
|
void router_get_pref_ipv6_orport(const routerinfo_t *router,
|
|
|
|
tor_addr_port_t *addr_port_out);
|
|
|
|
int router_ipv6_preferred(const routerinfo_t *router);
|
2012-08-23 12:23:00 +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);
|
2012-08-01 11:38:43 +02:00
|
|
|
int extrainfo_dump_to_string(char **s, extrainfo_t *extrainfo,
|
2015-05-28 16:42:22 +02:00
|
|
|
crypto_pk_t *ident_key,
|
|
|
|
const ed25519_keypair_t *signing_keypair);
|
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
|
|
|
|
|
|
|
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 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);
|
|
|
|
|
2012-08-23 12:23:00 +02:00
|
|
|
smartlist_t *router_get_all_orports(const routerinfo_t *ri);
|
|
|
|
|
2010-07-21 16:17:10 +02:00
|
|
|
#ifdef ROUTER_PRIVATE
|
|
|
|
/* Used only by router.c and test.c */
|
2013-06-06 23:58:28 +02:00
|
|
|
STATIC void get_platform_str(char *platform, size_t len);
|
2014-02-26 19:42:21 +01:00
|
|
|
STATIC int router_write_fingerprint(int hashed);
|
2010-07-21 16:17:10 +02:00
|
|
|
#endif
|
|
|
|
|
2017-09-15 22:24:44 +02:00
|
|
|
#endif /* !defined(TOR_ROUTER_H) */
|
2010-07-21 16:17:10 +02:00
|
|
|
|