protover.h 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. #ifndef TOR_PROTOVER_H
  2. #define TOR_PROTOVER_H
  3. #include "container.h"
  4. /** The first version of Tor that included "proto" entries in its
  5. * descriptors. Authorities should use this to decide whether to
  6. * guess proto lines. */
  7. /* This is a guess. */
  8. #define FIRST_TOR_VERSION_TO_ADVERTISE_PROTOCOLS "0.2.9.3-alpha"
  9. /** List of recognized subprotocols. */
  10. typedef enum protocol_type_t {
  11. PRT_LINK,
  12. PRT_LINKAUTH,
  13. PRT_RELAY,
  14. PRT_HSMID,
  15. PRT_DIRCACHE,
  16. PRT_HSDIR,
  17. PRT_DESC,
  18. PRT_MICRODESC,
  19. PRT_CONS,
  20. } protocol_type_t;
  21. int protover_all_supported(const char *s, char **missing);
  22. int protover_is_supported_here(protocol_type_t pr, uint32_t ver);
  23. const char *get_supported_protocols(void);
  24. char *compute_protover_vote(const smartlist_t *list_of_proto_strings,
  25. int threshold);
  26. const char *protover_compute_for_old_tor(const char *version);
  27. int protocol_list_supports_protocol(const char *list, protocol_type_t tp,
  28. uint32_t version);
  29. void protover_free_all(void);
  30. #ifdef PROTOVER_PRIVATE
  31. /** Represents a range of subprotocols of a given type. All subprotocols
  32. * between <b>low</b> and <b>high</b> inclusive are included. */
  33. typedef struct proto_range_t {
  34. uint32_t low;
  35. uint32_t high;
  36. } proto_range_t;
  37. /** Represents a set of ranges of subprotocols of a given type. */
  38. typedef struct proto_entry_t {
  39. /** The name of the protocol.
  40. *
  41. * (This needs to handle voting on protocols which
  42. * we don't recognize yet, so it's a char* rather than a protocol_type_t.)
  43. */
  44. char *name;
  45. /** Smartlist of proto_range_t */
  46. smartlist_t *ranges;
  47. } proto_entry_t;
  48. STATIC smartlist_t *parse_protocol_list(const char *s);
  49. STATIC void proto_entry_free(proto_entry_t *entry);
  50. STATIC char *encode_protocol_list(const smartlist_t *sl);
  51. STATIC const char *protocol_type_to_str(protocol_type_t pr);
  52. STATIC int str_to_protocol_type(const char *s, protocol_type_t *pr_out);
  53. #endif
  54. #endif