protover.h 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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_DIRCACHE,
  15. PRT_HSDIR,
  16. PRT_HSINTRO,
  17. PRT_HSREND,
  18. PRT_DESC,
  19. PRT_MICRODESC,
  20. PRT_CONS,
  21. } protocol_type_t;
  22. int protover_all_supported(const char *s, char **missing);
  23. int protover_is_supported_here(protocol_type_t pr, uint32_t ver);
  24. const char *protover_get_supported_protocols(void);
  25. char *protover_compute_vote(const smartlist_t *list_of_proto_strings,
  26. int threshold);
  27. const char *protover_compute_for_old_tor(const char *version);
  28. int protocol_list_supports_protocol(const char *list, protocol_type_t tp,
  29. uint32_t version);
  30. void protover_free_all(void);
  31. #ifdef PROTOVER_PRIVATE
  32. /** Represents a range of subprotocols of a given type. All subprotocols
  33. * between <b>low</b> and <b>high</b> inclusive are included. */
  34. typedef struct proto_range_t {
  35. uint32_t low;
  36. uint32_t high;
  37. } proto_range_t;
  38. /** Represents a set of ranges of subprotocols of a given type. */
  39. typedef struct proto_entry_t {
  40. /** The name of the protocol.
  41. *
  42. * (This needs to handle voting on protocols which
  43. * we don't recognize yet, so it's a char* rather than a protocol_type_t.)
  44. */
  45. char *name;
  46. /** Smartlist of proto_range_t */
  47. smartlist_t *ranges;
  48. } proto_entry_t;
  49. STATIC smartlist_t *parse_protocol_list(const char *s);
  50. STATIC void proto_entry_free(proto_entry_t *entry);
  51. STATIC char *encode_protocol_list(const smartlist_t *sl);
  52. STATIC const char *protocol_type_to_str(protocol_type_t pr);
  53. STATIC int str_to_protocol_type(const char *s, protocol_type_t *pr_out);
  54. #endif
  55. #endif