microdesc_st.h 2.5 KB

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