routerparse.h 4.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. /* Copyright (c) 2001 Matej Pfajfar.
  2. * Copyright (c) 2001-2004, Roger Dingledine.
  3. * Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
  4. * Copyright (c) 2007-2018, The Tor Project, Inc. */
  5. /* See LICENSE for licensing information */
  6. /**
  7. * \file routerparse.h
  8. * \brief Header file for routerparse.c.
  9. **/
  10. #ifndef TOR_ROUTERPARSE_H
  11. #define TOR_ROUTERPARSE_H
  12. #include "core/or/versions.h"
  13. enum networkstatus_type_t;
  14. int router_get_router_hash(const char *s, size_t s_len, char *digest);
  15. int router_get_dir_hash(const char *s, char *digest);
  16. int router_get_networkstatus_v3_hashes(const char *s,
  17. common_digests_t *digests);
  18. int router_get_networkstatus_v3_signed_boundaries(const char *s,
  19. const char **start_out,
  20. const char **end_out);
  21. int router_get_networkstatus_v3_sha3_as_signed(uint8_t *digest_out,
  22. const char *s);
  23. int router_get_extrainfo_hash(const char *s, size_t s_len, char *digest);
  24. int router_parse_list_from_string(const char **s, const char *eos,
  25. smartlist_t *dest,
  26. saved_location_t saved_location,
  27. int is_extrainfo,
  28. int allow_annotations,
  29. const char *prepend_annotations,
  30. smartlist_t *invalid_digests_out);
  31. routerinfo_t *router_parse_entry_from_string(const char *s, const char *end,
  32. int cache_copy,
  33. int allow_annotations,
  34. const char *prepend_annotations,
  35. int *can_dl_again_out);
  36. struct digest_ri_map_t;
  37. extrainfo_t *extrainfo_parse_entry_from_string(const char *s, const char *end,
  38. int cache_copy, struct digest_ri_map_t *routermap,
  39. int *can_dl_again_out);
  40. MOCK_DECL(addr_policy_t *, router_parse_addr_policy_item_from_string,
  41. (const char *s, int assume_action, int *malformed_list));
  42. void assert_addr_policy_ok(smartlist_t *t);
  43. void dump_distinct_digest_count(int severity);
  44. int compare_vote_routerstatus_entries(const void **_a, const void **_b);
  45. int networkstatus_verify_bw_weights(networkstatus_t *ns, int);
  46. networkstatus_t *networkstatus_parse_vote_from_string(const char *s,
  47. const char **eos_out,
  48. enum networkstatus_type_t ns_type);
  49. ns_detached_signatures_t *networkstatus_parse_detached_signatures(
  50. const char *s, const char *eos);
  51. smartlist_t *microdescs_parse_from_string(const char *s, const char *eos,
  52. int allow_annotations,
  53. saved_location_t where,
  54. smartlist_t *invalid_digests_out);
  55. void routerparse_init(void);
  56. void routerparse_free_all(void);
  57. #ifdef ROUTERPARSE_PRIVATE
  58. STATIC int routerstatus_parse_guardfraction(const char *guardfraction_str,
  59. networkstatus_t *vote,
  60. vote_routerstatus_t *vote_rs,
  61. routerstatus_t *rs);
  62. struct memarea_t;
  63. STATIC routerstatus_t *routerstatus_parse_entry_from_string(
  64. struct memarea_t *area,
  65. const char **s, smartlist_t *tokens,
  66. networkstatus_t *vote,
  67. vote_routerstatus_t *vote_rs,
  68. int consensus_method,
  69. consensus_flavor_t flav);
  70. STATIC void summarize_protover_flags(protover_summary_flags_t *out,
  71. const char *protocols,
  72. const char *version);
  73. #endif /* defined(ROUTERPARSE_PRIVATE) */
  74. #define ED_DESC_SIGNATURE_PREFIX "Tor router descriptor signature v1"
  75. #endif /* !defined(TOR_ROUTERPARSE_H) */