protover.h 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. /* Copyright (c) 2016-2017, The Tor Project, Inc. */
  2. /* See LICENSE for licensing information */
  3. /**
  4. * \file protover.h
  5. * \brief Headers and type declarations for protover.c
  6. **/
  7. #ifndef TOR_PROTOVER_H
  8. #define TOR_PROTOVER_H
  9. #include "container.h"
  10. /** The first version of Tor that included "proto" entries in its
  11. * descriptors. Authorities should use this to decide whether to
  12. * guess proto lines. */
  13. /* This is a guess. */
  14. #define FIRST_TOR_VERSION_TO_ADVERTISE_PROTOCOLS "0.2.9.3-alpha"
  15. /** The protover version number that signifies HSDir support for HSv3 */
  16. #define PROTOVER_HSDIR_V3 2
  17. /** The protover version number that signifies HSv3 intro point support */
  18. #define PROTOVER_HS_INTRO_V3 4
  19. /** List of recognized subprotocols. */
  20. typedef enum protocol_type_t {
  21. PRT_LINK,
  22. PRT_LINKAUTH,
  23. PRT_RELAY,
  24. PRT_DIRCACHE,
  25. PRT_HSDIR,
  26. PRT_HSINTRO,
  27. PRT_HSREND,
  28. PRT_DESC,
  29. PRT_MICRODESC,
  30. PRT_CONS,
  31. } protocol_type_t;
  32. int protover_all_supported(const char *s, char **missing);
  33. int protover_is_supported_here(protocol_type_t pr, uint32_t ver);
  34. const char *protover_get_supported_protocols(void);
  35. char *protover_compute_vote(const smartlist_t *list_of_proto_strings,
  36. int threshold);
  37. const char *protover_compute_for_old_tor(const char *version);
  38. int protocol_list_supports_protocol(const char *list, protocol_type_t tp,
  39. uint32_t version);
  40. void protover_free_all(void);
  41. #ifdef PROTOVER_PRIVATE
  42. /** Represents a range of subprotocols of a given type. All subprotocols
  43. * between <b>low</b> and <b>high</b> inclusive are included. */
  44. typedef struct proto_range_t {
  45. uint32_t low;
  46. uint32_t high;
  47. } proto_range_t;
  48. /** Represents a set of ranges of subprotocols of a given type. */
  49. typedef struct proto_entry_t {
  50. /** The name of the protocol.
  51. *
  52. * (This needs to handle voting on protocols which
  53. * we don't recognize yet, so it's a char* rather than a protocol_type_t.)
  54. */
  55. char *name;
  56. /** Smartlist of proto_range_t */
  57. smartlist_t *ranges;
  58. } proto_entry_t;
  59. STATIC smartlist_t *parse_protocol_list(const char *s);
  60. STATIC void proto_entry_free(proto_entry_t *entry);
  61. STATIC char *encode_protocol_list(const smartlist_t *sl);
  62. STATIC const char *protocol_type_to_str(protocol_type_t pr);
  63. STATIC int str_to_protocol_type(const char *s, protocol_type_t *pr_out);
  64. #endif
  65. #endif