dispatch_cfg.h 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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-2018, The Tor Project, Inc. */
  5. /* See LICENSE for licensing information */
  6. #ifndef TOR_DISPATCH_CFG_H
  7. #define TOR_DISPATCH_CFG_H
  8. #include "lib/dispatch/msgtypes.h"
  9. #include "lib/testsupport/testsupport.h"
  10. /**
  11. * A "dispatch_cfg" is the configuration used to set up a dispatcher.
  12. * It is created and accessed with a set of dcfg_* functions, and then
  13. * used with dispatcher_new() to make the dispatcher.
  14. */
  15. typedef struct dispatch_cfg_t dispatch_cfg_t;
  16. dispatch_cfg_t *dcfg_new(void);
  17. int dcfg_msg_set_type(dispatch_cfg_t *cfg, message_id_t msg,
  18. msg_type_id_t type);
  19. int dcfg_msg_set_chan(dispatch_cfg_t *cfg, message_id_t msg,
  20. channel_id_t chan);
  21. int dcfg_type_set_fns(dispatch_cfg_t *cfg, msg_type_id_t type,
  22. const dispatch_typefns_t *fns);
  23. int dcfg_add_recv(dispatch_cfg_t *cfg, message_id_t msg,
  24. subsys_id_t sys, recv_fn_t fn);
  25. /** Free a dispatch_cfg_t. */
  26. #define dcfg_free(cfg) \
  27. FREE_AND_NULL(dispatch_cfg_t, dcfg_free_, (cfg))
  28. void dcfg_free_(dispatch_cfg_t *cfg);
  29. #ifdef DISPATCH_NEW_PRIVATE
  30. struct smartlist_t;
  31. STATIC int max_in_u16_sl(const struct smartlist_t *sl, int dflt);
  32. #endif
  33. #endif /* !defined(TOR_DISPATCH_CFG_H) */