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