btrack.c 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. /* Copyright (c) 2007-2019, The Tor Project, Inc. */
  2. /* See LICENSE for licensing information */
  3. /**
  4. * \file btrack.c
  5. * \brief Bootstrap trackers
  6. *
  7. * Initializes and shuts down the specific bootstrap trackers. These
  8. * trackers help the reporting of bootstrap progress by maintaining
  9. * state information about various subsystems within tor. When the
  10. * correct state changes happen, these trackers emit controller
  11. * events.
  12. *
  13. * These trackers avoid referring directly to the internals of state
  14. * objects of other subsystems.
  15. *
  16. * btrack_circuit.c contains the tracker for origin circuits.
  17. *
  18. * btrack_orconn.c contains the tracker for OR connections.
  19. *
  20. * Eventually there will be a tracker for directory downloads as well.
  21. **/
  22. #include "feature/control/btrack_circuit.h"
  23. #include "feature/control/btrack_orconn.h"
  24. #include "feature/control/btrack_sys.h"
  25. #include "lib/pubsub/pubsub.h"
  26. #include "lib/subsys/subsys.h"
  27. static int
  28. btrack_init(void)
  29. {
  30. if (btrack_orconn_init())
  31. return -1;
  32. return 0;
  33. }
  34. static void
  35. btrack_fini(void)
  36. {
  37. btrack_orconn_fini();
  38. btrack_circ_fini();
  39. }
  40. static int
  41. btrack_add_pubsub(pubsub_connector_t *connector)
  42. {
  43. if (btrack_orconn_add_pubsub(connector))
  44. return -1;
  45. if (btrack_circ_add_pubsub(connector))
  46. return -1;
  47. return 0;
  48. }
  49. const subsys_fns_t sys_btrack = {
  50. .name = "btrack",
  51. .supported = true,
  52. .level = -30,
  53. .initialize = btrack_init,
  54. .shutdown = btrack_fini,
  55. .add_pubsub = btrack_add_pubsub,
  56. };