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