microdesc_st.h 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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-2019, The Tor Project, Inc. */
  5. /* See LICENSE for licensing information */
  6. #ifndef MICRODESC_ST_H
  7. #define MICRODESC_ST_H
  8. struct curve25519_public_key_t;
  9. struct ed25519_public_key_t;
  10. struct nodefamily_t;
  11. struct short_policy_t;
  12. /** A microdescriptor is the smallest amount of information needed to build a
  13. * circuit through a router. They are generated by the directory authorities,
  14. * using information from the uploaded routerinfo documents. They are not
  15. * self-signed, but are rather authenticated by having their hash in a signed
  16. * networkstatus document. */
  17. struct microdesc_t {
  18. /** Hashtable node, used to look up the microdesc by its digest. */
  19. HT_ENTRY(microdesc_t) node;
  20. /* Cache information */
  21. /** When was this microdescriptor last listed in a consensus document?
  22. * Once a microdesc has been unlisted long enough, we can drop it.
  23. */
  24. time_t last_listed;
  25. /** Where is this microdescriptor currently stored? */
  26. saved_location_bitfield_t saved_location : 3;
  27. /** If true, do not attempt to cache this microdescriptor on disk. */
  28. unsigned int no_save : 1;
  29. /** If true, this microdesc has an entry in the microdesc_map */
  30. unsigned int held_in_map : 1;
  31. /** True iff the exit policy for this router rejects everything. */
  32. unsigned int policy_is_reject_star : 1;
  33. /** Reference count: how many node_ts have a reference to this microdesc? */
  34. unsigned int held_by_nodes;
  35. /** If saved_location == SAVED_IN_CACHE, this field holds the offset of the
  36. * microdescriptor in the cache. */
  37. off_t off;
  38. /* The string containing the microdesc. */
  39. /** A pointer to the encoded body of the microdescriptor. If the
  40. * saved_location is SAVED_IN_CACHE, then the body is a pointer into an
  41. * mmap'd region. Otherwise, it is a malloc'd string. The string might not
  42. * be NUL-terminated; take the length from <b>bodylen</b>. */
  43. char *body;
  44. /** The length of the microdescriptor in <b>body</b>. */
  45. size_t bodylen;
  46. /** A SHA256-digest of the microdescriptor. */
  47. char digest[DIGEST256_LEN];
  48. /* Fields in the microdescriptor. */
  49. /**
  50. * Public RSA TAP key for onions, ASN.1 encoded. We store this
  51. * in its encoded format since storing it as a crypto_pk_t uses
  52. * significantly more memory. */
  53. char *onion_pkey;
  54. /** Length of onion_pkey, in bytes. */
  55. size_t onion_pkey_len;
  56. /** As routerinfo_t.onion_curve25519_pkey */
  57. struct curve25519_public_key_t *onion_curve25519_pkey;
  58. /** Ed25519 identity key, if included. */
  59. struct ed25519_public_key_t *ed25519_identity_pkey;
  60. /** As routerinfo_t.ipv6_addr */
  61. tor_addr_t ipv6_addr;
  62. /** As routerinfo_t.ipv6_orport */
  63. uint16_t ipv6_orport;
  64. /** As routerinfo_t.family, with readable members parsed. */
  65. struct nodefamily_t *family;
  66. /** IPv4 exit policy summary */
  67. struct short_policy_t *exit_policy;
  68. /** IPv6 exit policy summary */
  69. struct short_policy_t *ipv6_exit_policy;
  70. };
  71. #endif /* !defined(MICRODESC_ST_H) */