Ticket #13163: 04-dirinfo-type-expand-comments-explicit-constants.patch

File 04-dirinfo-type-expand-comments-explicit-constants.patch, 4.8 KB (added by teor, 6 years ago)

Expand various comments about NO_DIRINFO so that each function where it is used is clearly documented

  • src/or/config.c

    diff --git a/src/or/config.c b/src/or/config.c
    index 10af92a..42b9a2a 100644
    a b escaped_safe_str(const char *address) 
    845846}
    846847
    847848/** Add the default directory authorities directly into the trusted dir list,
    848  * but only add them insofar as they share bits with <b>type</b>. */
     849 * but only add them insofar as they share bits with <b>type</b>.
     850 * Each authority's bits are restricted to the bits shared with <b>type</b>.
     851 * If <b>type</b> is ALL_DIRINFO or NO_DIRINFO (zero), add all authorities. */
    849852static void
    850853add_default_trusted_dir_authorities(dirinfo_type_t type)
    851854{
    parse_server_transport_line(const or_options_t *options, 
    52015206/** Read the contents of a DirAuthority line from <b>line</b>. If
    52025207 * <b>validate_only</b> is 0, and the line is well-formed, and it
    52035208 * shares any bits with <b>required_type</b> or <b>required_type</b>
    5204  * is 0, then add the dirserver described in the line (minus whatever
    5205  * bits it's missing) as a valid authority. Return 0 on success,
     5209 * is NO_DIRINFO (zero), then add the dirserver described in the line (minus whatever
     5210 * bits it's missing) as a valid authority. Return 0 on success or filtering out by type,
    52065211 * or -1 if the line isn't well-formed or if we can't add it. */
    52075212static int
    52085213parse_dir_authority_line(const char *line, dirinfo_type_t required_type,
  • src/or/directory.c

    diff --git a/src/or/directory.c b/src/or/directory.c
    index 1aaa75c..032b971 100644
    a b directory_get_from_dirserver(uint8_t dir_purpose, uint8_t router_purpose, 
    523523      /* anybody with a non-zero dirport will do. Disregard firewalls. */
    524524      pds_flags |= PDS_IGNORE_FASCISTFIREWALL;
    525525      rs = router_pick_directory_server(type, pds_flags);
    526       /* If we have any hope of building an indirect conn, we know some router
    527        * descriptors.  If (rs==NULL), we can't build circuits anyway, so
    528        * there's no point in falling back to the authorities in this case. */
    529526    }
    530527  }
    531528
     529  /* If we have any hope of building an indirect conn, we know some router
     530   * descriptors.  If (rs==NULL), we can't build circuits anyway, so
     531   * there's no point in falling back to the authorities in this case. */
    532532  if (rs) {
    533533    const dir_indirection_t indirection =
    534534      get_via_tor ? DIRIND_ANONYMOUS : DIRIND_ONEHOP;
  • src/or/entrynodes.c

    diff --git a/src/or/entrynodes.c b/src/or/entrynodes.c
    index b95391e..8743cfd 100644
    a b node_understands_microdescriptors(const node_t *node) 
    10031003}
    10041004
    10051005/** Return true iff <b>node</b> is able to answer directory questions
    1006  * of type <b>dirinfo</b>. */
     1006 * of type <b>dirinfo</b>. Always returns true if <b>dirinfo</b> is
     1007 * NO_DIRINFO (zero). */
    10071008static int
    10081009node_can_handle_dirinfo(const node_t *node, dirinfo_type_t dirinfo)
    10091010{
    node_can_handle_dirinfo(const node_t *node, dirinfo_type_t dirinfo) 
    10251026 * <b>state</b> is non-NULL, this is for a specific circuit --
    10261027 * make sure not to pick this circuit's exit or any node in the
    10271028 * exit's family. If <b>state</b> is NULL, we're looking for a random
    1028  * guard (likely a bridge).  If <b>dirinfo</b> is not NO_DIRINFO, then
    1029  * only select from nodes that know how to answer directory questions
     1029 * guard (likely a bridge).  If <b>dirinfo</b> is not NO_DIRINFO (zero),
     1030 * then only select from nodes that know how to answer directory questions
    10301031 * of that type. */
    10311032const node_t *
    10321033choose_random_entry(cpath_build_state_t *state)
    10331034{
    1034   return choose_random_entry_impl(state, 0, 0, NULL);
     1035  return choose_random_entry_impl(state, 0, NO_DIRINFO, NULL);
    10351036}
    10361037
    10371038/** Pick a live (up and listed) directory guard from entry_guards for
    populate_live_entry_guards(smartlist_t *live_entry_guards, 
    11391140 * If <b>for_directory</b> is set, we are looking for a directory guard.
    11401141 *
    11411142 * <b>dirinfo_type</b> contains the kind of directory information we
    1142  * are looking for in our node.
     1143 * are looking for in our node, or NO_DIRINFO (zero) if we are not
     1144 * looking for any particular directory information (when set to
     1145 * NO_DIRINFO, the <b>dirinfo_type</b> filter is ignored).
    11431146 *
    11441147 * If <b>n_options_out</b> is set, we set it to the number of
    11451148 * candidate guard nodes we had before picking a specific guard node.
  • src/or/routerlist.c

    diff --git a/src/or/routerlist.c b/src/or/routerlist.c
    index 1faa05f..ed6b2c6 100644
    a b router_is_named(const routerinfo_t *router) 
    25322532
    25332533/** Return true iff <b>digest</b> is the digest of the identity key of a
    25342534 * trusted directory matching at least one bit of <b>type</b>.  If <b>type</b>
    2535  * is zero, any authority is okay. */
     2535 * is zero (NO_DIRINFO), or ALL_DIRINFO, any authority is okay. */
    25362536int
    25372537router_digest_is_trusted_dir_type(const char *digest, dirinfo_type_t type)
    25382538{