extract networkstatus parsing to its own file.

This commit is contained in:
Nick Mathewson 2018-10-01 10:44:59 -05:00
parent cd23903427
commit 4201203845
18 changed files with 1771 additions and 1707 deletions

View File

@ -75,6 +75,7 @@ LIBTOR_APP_A_SOURCES = \
src/feature/dircommon/voting_schedule.c \
src/feature/dirparse/authcert_parse.c \
src/feature/dirparse/microdesc_parse.c \
src/feature/dirparse/ns_parse.c \
src/feature/dirparse/parsecommon.c \
src/feature/dirparse/routerparse.c \
src/feature/dirparse/sigcommon.c \
@ -298,6 +299,7 @@ noinst_HEADERS += \
src/feature/dirparse/authcert_members.i \
src/feature/dirparse/authcert_parse.h \
src/feature/dirparse/microdesc_parse.h \
src/feature/dirparse/ns_parse.h \
src/feature/dirparse/parsecommon.h \
src/feature/dirparse/routerparse.h \
src/feature/dirparse/sigcommon.h \

View File

@ -15,7 +15,7 @@
#include "app/config/config.h"
#include "feature/nodelist/networkstatus.h"
#include "feature/nodelist/routerlist.h"
#include "feature/dirparse/routerparse.h"
#include "feature/dirparse/ns_parse.h"
#include "feature/nodelist/routerinfo_st.h"
#include "feature/nodelist/vote_routerstatus_st.h"

View File

@ -6,32 +6,33 @@
#define DIRVOTE_PRIVATE
#include "core/or/or.h"
#include "app/config/config.h"
#include "feature/dirauth/dircollate.h"
#include "feature/dirauth/dsigs_parse.h"
#include "feature/dirauth/recommend_pkg.h"
#include "feature/dirauth/voteflags.h"
#include "feature/dircommon/directory.h"
#include "feature/dirclient/dirclient.h"
#include "feature/dirauth/bwauth.h"
#include "feature/dircache/dirserv.h"
#include "feature/dirauth/guardfraction.h"
#include "feature/nodelist/microdesc.h"
#include "feature/nodelist/networkstatus.h"
#include "feature/nodelist/nodelist.h"
#include "feature/dirparse/parsecommon.h"
#include "core/or/policies.h"
#include "core/or/protover.h"
#include "core/or/tor_version_st.h"
#include "feature/stats/rephist.h"
#include "feature/relay/router.h"
#include "feature/relay/routerkeys.h"
#include "core/or/versions.h"
#include "feature/dirauth/bwauth.h"
#include "feature/dirauth/dircollate.h"
#include "feature/dirauth/dsigs_parse.h"
#include "feature/dirauth/guardfraction.h"
#include "feature/dirauth/recommend_pkg.h"
#include "feature/dirauth/voteflags.h"
#include "feature/dircache/dirserv.h"
#include "feature/dirclient/dirclient.h"
#include "feature/dircommon/directory.h"
#include "feature/dirparse/microdesc_parse.h"
#include "feature/dirparse/ns_parse.h"
#include "feature/dirparse/parsecommon.h"
#include "feature/dirparse/signing.h"
#include "feature/nodelist/authcert.h"
#include "feature/nodelist/dirlist.h"
#include "feature/nodelist/routerlist.h"
#include "feature/dirparse/routerparse.h"
#include "feature/dirparse/microdesc_parse.h"
#include "feature/dirparse/signing.h"
#include "feature/nodelist/fmt_routerstatus.h"
#include "feature/nodelist/microdesc.h"
#include "feature/nodelist/networkstatus.h"
#include "feature/nodelist/nodelist.h"
#include "feature/nodelist/routerlist.h"
#include "feature/relay/router.h"
#include "feature/relay/routerkeys.h"
#include "feature/stats/rephist.h"
#include "feature/client/entrynodes.h" /* needed for guardfraction methods */
#include "feature/nodelist/torcert.h"
#include "feature/dircommon/voting_schedule.h"

View File

@ -12,7 +12,7 @@
#include "core/or/or.h"
#include "feature/dirauth/guardfraction.h"
#include "feature/nodelist/networkstatus.h"
#include "feature/dirparse/routerparse.h"
#include "feature/dirparse/ns_parse.h"
#include "feature/nodelist/vote_routerstatus_st.h"

View File

@ -20,7 +20,7 @@
#include "feature/dircache/consdiffmgr.h"
#include "core/mainloop/cpuworker.h"
#include "feature/nodelist/networkstatus.h"
#include "feature/dirparse/routerparse.h"
#include "feature/dirparse/ns_parse.h"
#include "lib/evloop/compat_libevent.h"
#include "lib/evloop/workqueue.h"
#include "lib/compress/compress.h"

View File

@ -41,7 +41,7 @@
#include "core/or/or.h"
#include "feature/dircommon/consdiff.h"
#include "lib/memarea/memarea.h"
#include "feature/dirparse/routerparse.h"
#include "feature/dirparse/ns_parse.h"
static const char* ns_diff_version = "network-status-diff-version 1";
static const char* hash_token = "hash";

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,45 @@
/* Copyright (c) 2001 Matej Pfajfar.
* Copyright (c) 2001-2004, Roger Dingledine.
* Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
* Copyright (c) 2007-2018, The Tor Project, Inc. */
/* See LICENSE for licensing information */
/**
* \file ns_parse.h
* \brief Header file for ns_parse.c.
**/
#ifndef TOR_NS_PARSE_H
#define TOR_NS_PARSE_H
int router_get_networkstatus_v3_hashes(const char *s,
common_digests_t *digests);
int router_get_networkstatus_v3_signed_boundaries(const char *s,
const char **start_out,
const char **end_out);
int router_get_networkstatus_v3_sha3_as_signed(uint8_t *digest_out,
const char *s);
int compare_vote_routerstatus_entries(const void **_a, const void **_b);
int networkstatus_verify_bw_weights(networkstatus_t *ns, int);
enum networkstatus_type_t;
networkstatus_t *networkstatus_parse_vote_from_string(const char *s,
const char **eos_out,
enum networkstatus_type_t ns_type);
#ifdef NS_PARSE_PRIVATE
STATIC int routerstatus_parse_guardfraction(const char *guardfraction_str,
networkstatus_t *vote,
vote_routerstatus_t *vote_rs,
routerstatus_t *rs);
struct memarea_t;
STATIC routerstatus_t *routerstatus_parse_entry_from_string(
struct memarea_t *area,
const char **s, smartlist_t *tokens,
networkstatus_t *vote,
vote_routerstatus_t *vote_rs,
int consensus_method,
consensus_flavor_t flav);
#endif
#endif

File diff suppressed because it is too large Load Diff

View File

@ -14,16 +14,7 @@
#include "core/or/versions.h"
enum networkstatus_type_t;
int router_get_router_hash(const char *s, size_t s_len, char *digest);
int router_get_networkstatus_v3_hashes(const char *s,
common_digests_t *digests);
int router_get_networkstatus_v3_signed_boundaries(const char *s,
const char **start_out,
const char **end_out);
int router_get_networkstatus_v3_sha3_as_signed(uint8_t *digest_out,
const char *s);
int router_get_extrainfo_hash(const char *s, size_t s_len, char *digest);
int router_parse_list_from_string(const char **s, const char *eos,
@ -46,12 +37,6 @@ extrainfo_t *extrainfo_parse_entry_from_string(const char *s, const char *end,
MOCK_DECL(addr_policy_t *, router_parse_addr_policy_item_from_string,
(const char *s, int assume_action, int *malformed_list));
int compare_vote_routerstatus_entries(const void **_a, const void **_b);
int networkstatus_verify_bw_weights(networkstatus_t *ns, int);
networkstatus_t *networkstatus_parse_vote_from_string(const char *s,
const char **eos_out,
enum networkstatus_type_t ns_type);
int find_single_ipv6_orport(const smartlist_t *list,
tor_addr_t *addr_out,
uint16_t *port_out);
@ -59,23 +44,9 @@ int find_single_ipv6_orport(const smartlist_t *list,
void routerparse_init(void);
void routerparse_free_all(void);
#ifdef ROUTERPARSE_PRIVATE
STATIC int routerstatus_parse_guardfraction(const char *guardfraction_str,
networkstatus_t *vote,
vote_routerstatus_t *vote_rs,
routerstatus_t *rs);
struct memarea_t;
STATIC routerstatus_t *routerstatus_parse_entry_from_string(
struct memarea_t *area,
const char **s, smartlist_t *tokens,
networkstatus_t *vote,
vote_routerstatus_t *vote_rs,
int consensus_method,
consensus_flavor_t flav);
STATIC void summarize_protover_flags(protover_summary_flags_t *out,
const char *protocols,
void summarize_protover_flags(protover_summary_flags_t *out,
const char *protocols,
const char *version);
#endif /* defined(ROUTERPARSE_PRIVATE) */
#define ED_DESC_SIGNATURE_PREFIX "Tor router descriptor signature v1"

View File

@ -53,6 +53,7 @@
#include "core/or/protover.h"
#include "core/or/relay.h"
#include "core/or/scheduler.h"
#include "core/or/versions.h"
#include "feature/client/bridges.h"
#include "feature/client/entrynodes.h"
#include "feature/client/transports.h"
@ -64,7 +65,7 @@
#include "feature/dirclient/dlstatus.h"
#include "feature/dircommon/directory.h"
#include "feature/dircommon/voting_schedule.h"
#include "feature/dirparse/routerparse.h"
#include "feature/dirparse/ns_parse.h"
#include "feature/hibernate/hibernate.h"
#include "feature/nodelist/authcert.h"
#include "feature/nodelist/dirlist.h"

View File

@ -2,7 +2,7 @@
/* See LICENSE for licensing information */
#define SIGCOMMON_PRIVATE
#include "core/or/or.h"
#include "feature/dirparse/routerparse.h"
#include "feature/dirparse/ns_parse.h"
#include "feature/dirparse/sigcommon.h"
#include "feature/dirparse/unparseable.h"
#include "feature/nodelist/networkstatus.h"

View File

@ -1,9 +1,9 @@
/* Copyright (c) 2016-2018, The Tor Project, Inc. */
/* See LICENSE for licensing information */
#define ROUTERPARSE_PRIVATE
#define NS_PARSE_PRIVATE
#define NETWORKSTATUS_PRIVATE
#include "core/or/or.h"
#include "feature/dirparse/routerparse.h"
#include "feature/dirparse/ns_parse.h"
#include "feature/dirparse/unparseable.h"
#include "lib/memarea/memarea.h"
#include "feature/nodelist/microdesc.h"

View File

@ -11,7 +11,7 @@
#include "core/mainloop/cpuworker.h"
#include "lib/crypt_ops/crypto_rand.h"
#include "feature/nodelist/networkstatus.h"
#include "feature/dirparse/routerparse.h"
#include "feature/dirparse/ns_parse.h"
#include "lib/evloop/workqueue.h"
#include "lib/compress/compress.h"
#include "lib/encoding/confline.h"

View File

@ -16,6 +16,7 @@
#define DLSTATUS_PRIVATE
#define HIBERNATE_PRIVATE
#define NETWORKSTATUS_PRIVATE
#define NS_PARSE_PRIVATE
#define NODE_SELECT_PRIVATE
#define RELAY_PRIVATE
#define ROUTERLIST_PRIVATE
@ -54,6 +55,7 @@
#include "feature/nodelist/node_select.h"
#include "feature/nodelist/routerlist.h"
#include "feature/dirparse/authcert_parse.h"
#include "feature/dirparse/ns_parse.h"
#include "feature/dirparse/routerparse.h"
#include "feature/dirparse/unparseable.h"
#include "feature/nodelist/routerset.h"

View File

@ -11,6 +11,7 @@
#include "feature/nodelist/nodelist.h"
#include "feature/nodelist/routerlist.h"
#include "feature/dirparse/authcert_parse.h"
#include "feature/dirparse/ns_parse.h"
#include "test/test_dir_common.h"
#include "feature/dircommon/voting_schedule.h"

View File

@ -2,15 +2,15 @@
/* See LICENSE for licensing information */
#define GUARDFRACTION_PRIVATE
#define ROUTERPARSE_PRIVATE
#define NETWORKSTATUS_PRIVATE
#define NS_PARSE_PRIVATE
#include "orconfig.h"
#include "core/or/or.h"
#include "app/config/config.h"
#include "feature/dirauth/guardfraction.h"
#include "feature/client/entrynodes.h"
#include "feature/dirparse/routerparse.h"
#include "feature/dirparse/ns_parse.h"
#include "feature/nodelist/networkstatus.h"
#include "feature/nodelist/networkstatus_st.h"

View File

@ -35,6 +35,7 @@
#include "feature/nodelist/routerset.h"
#include "feature/dirparse/authcert_parse.h"
#include "feature/dirparse/routerparse.h"
#include "feature/dirparse/ns_parse.h"
#include "feature/dirauth/shared_random.h"
#include "app/config/statefile.h"