tor

The Tor anonymity network
git clone https://git.dasho.dev/tor.git
Log | Files | Refs | README | LICENSE

or_sys.c (1199B)


      1 /* Copyright (c) 2001 Matej Pfajfar.
      2 * Copyright (c) 2001-2004, Roger Dingledine.
      3 * Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
      4 * Copyright (c) 2007-2021, The Tor Project, Inc. */
      5 /* See LICENSE for licensing information */
      6 
      7 /**
      8 * @file or_sys.c
      9 * @brief Subsystem definitions for OR module.
     10 **/
     11 
     12 #include "orconfig.h"
     13 #include "core/or/or.h"
     14 #include "core/or/or_periodic.h"
     15 #include "core/or/or_sys.h"
     16 #include "core/or/policies.h"
     17 #include "core/or/protover.h"
     18 #include "core/or/versions.h"
     19 
     20 #include "lib/subsys/subsys.h"
     21 
     22 static int
     23 subsys_or_initialize(void)
     24 {
     25  or_register_periodic_events();
     26  return 0;
     27 }
     28 
     29 static void
     30 subsys_or_shutdown(void)
     31 {
     32  protover_free_all();
     33  protover_summary_cache_free_all();
     34  policies_free_all();
     35 }
     36 
     37 static int
     38 subsys_or_add_pubsub(struct pubsub_connector_t *connector)
     39 {
     40  int rv = 0;
     41  if (orconn_add_pubsub(connector) < 0)
     42    rv = -1;
     43  if (ocirc_add_pubsub(connector) < 0)
     44    rv = -1;
     45  return rv;
     46 }
     47 
     48 const struct subsys_fns_t sys_or = {
     49  .name = "or",
     50  SUBSYS_DECLARE_LOCATION(),
     51  .supported = true,
     52  .level = 20,
     53  .initialize = subsys_or_initialize,
     54  .shutdown = subsys_or_shutdown,
     55  .add_pubsub = subsys_or_add_pubsub,
     56 };