protover.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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. /** The protover version number that signifies HSv3 rendezvous point support */
  20. #define PROTOVER_HS_RENDEZVOUS_POINT_V3 2
  21. /** List of recognized subprotocols. */
  22. typedef enum protocol_type_t {
  23. PRT_LINK,
  24. PRT_LINKAUTH,
  25. PRT_RELAY,
  26. PRT_DIRCACHE,
  27. PRT_HSDIR,
  28. PRT_HSINTRO,
  29. PRT_HSREND,
  30. PRT_DESC,
  31. PRT_MICRODESC,
  32. PRT_CONS,
  33. } protocol_type_t;
  34. int protover_all_supported(const char *s, char **missing);
  35. int protover_is_supported_here(protocol_type_t pr, uint32_t ver);
  36. const char *protover_get_supported_protocols(void);
  37. char *protover_compute_vote(const smartlist_t *list_of_proto_strings,
  38. int threshold);
  39. const char *protover_compute_for_old_tor(const char *version);
  40. int protocol_list_supports_protocol(const char *list, protocol_type_t tp,
  41. uint32_t version);
  42. void protover_free_all(void);
  43. #ifdef PROTOVER_PRIVATE
  44. /** Represents a range of subprotocols of a given type. All subprotocols
  45. * between <b>low</b> and <b>high</b> inclusive are included. */
  46. typedef struct proto_range_t {
  47. uint32_t low;
  48. uint32_t high;
  49. } proto_range_t;
  50. /** Represents a set of ranges of subprotocols of a given type. */
  51. typedef struct proto_entry_t {
  52. /** The name of the protocol.
  53. *
  54. * (This needs to handle voting on protocols which
  55. * we don't recognize yet, so it's a char* rather than a protocol_type_t.)
  56. */
  57. char *name;
  58. /** Smartlist of proto_range_t */
  59. smartlist_t *ranges;
  60. } proto_entry_t;
  61. STATIC smartlist_t *parse_protocol_list(const char *s);
  62. STATIC void proto_entry_free(proto_entry_t *entry);
  63. STATIC char *encode_protocol_list(const smartlist_t *sl);
  64. STATIC const char *protocol_type_to_str(protocol_type_t pr);
  65. STATIC int str_to_protocol_type(const char *s, protocol_type_t *pr_out);
  66. #endif /* defined(PROTOVER_PRIVATE) */
  67. #endif /* !defined(TOR_PROTOVER_H) */