aboutsummaryrefslogtreecommitdiff
path: root/src/feature/control/btrack.c
blob: 405630ecd46f598e23914c05560d9885f738b86b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
/* Copyright (c) 2007-2020, The Tor Project, Inc. */
/* See LICENSE for licensing information */

/**
 * \file btrack.c
 * \brief Bootstrap trackers
 *
 * Initializes and shuts down the specific bootstrap trackers.  These
 * trackers help the reporting of bootstrap progress by maintaining
 * state information about various subsystems within tor.  When the
 * correct state changes happen, these trackers emit controller
 * events.
 *
 * These trackers avoid referring directly to the internals of state
 * objects of other subsystems.
 *
 * btrack_circuit.c contains the tracker for origin circuits.
 *
 * btrack_orconn.c contains the tracker for OR connections.
 *
 * Eventually there will be a tracker for directory downloads as well.
 **/

#include "feature/control/btrack_circuit.h"
#include "feature/control/btrack_orconn.h"
#include "feature/control/btrack_sys.h"
#include "lib/pubsub/pubsub.h"
#include "lib/subsys/subsys.h"

static int
btrack_init(void)
{
  if (btrack_orconn_init())
    return -1;

  return 0;
}

static void
btrack_fini(void)
{
  btrack_orconn_fini();
  btrack_circ_fini();
}

static int
btrack_add_pubsub(pubsub_connector_t *connector)
{
  if (btrack_orconn_add_pubsub(connector))
    return -1;
  if (btrack_circ_add_pubsub(connector))
    return -1;

  return 0;
}

const subsys_fns_t sys_btrack = {
  .name = "btrack",
  SUBSYS_DECLARE_LOCATION(),
  .supported = true,
  .level = 55,
  .initialize = btrack_init,
  .shutdown = btrack_fini,
  .add_pubsub = btrack_add_pubsub,
};