nodefamily_st.h 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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 TOR_NODEFAMILY_ST_H
  7. #define TOR_NODEFAMILY_ST_H
  8. #include "orconfig.h"
  9. #include "ht.h"
  10. struct nodefamily_t {
  11. /** Entry for this nodefamily_t within the hashtable. */
  12. HT_ENTRY(nodefamily_t) ht_ent;
  13. /** Reference count. (The hashtable is not treated as a reference */
  14. uint32_t refcnt;
  15. /** Number of items encoded in <b>family_members</b>. */
  16. uint32_t n_members;
  17. /* A byte-array encoding the members of this family. We encode each member
  18. * as one byte to indicate whether it's a nickname or a fingerprint, plus
  19. * DIGEST_LEN bytes of data. The entries are lexically sorted.
  20. */
  21. uint8_t family_members[FLEXIBLE_ARRAY_MEMBER];
  22. };
  23. #define NODEFAMILY_MEMBER_LEN (1+DIGEST_LEN)
  24. /** Tag byte, indicates that the following bytes are a RSA1024 SHA1 ID.
  25. */
  26. #define NODEFAMILY_BY_RSA_ID 0
  27. /** Tag byte, indicates that the following bytes are a NUL-padded nickname.
  28. */
  29. #define NODEFAMILY_BY_NICKNAME 1
  30. /**
  31. * Number of bytes to allocate in the array for a nodefamily_t with N members.
  32. **/
  33. #define NODEFAMILY_ARRAY_SIZE(n) \
  34. ((n) * NODEFAMILY_MEMBER_LEN)
  35. /**
  36. * Pointer to the i'th member of <b>nf</b>, as encoded.
  37. */
  38. #define NODEFAMILY_MEMBER_PTR(nf, i) \
  39. (&((nf)->family_members[(i) * NODEFAMILY_MEMBER_LEN]))
  40. #endif /* !defined(TOR_NODEFAMILY_ST_H) */