microdesc_st.h 2.8 KB

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