microdesc_st.h 2.6 KB

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