protover.h 2.1 KB

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