Tor  0.4.3.0-alpha-dev
dispatch_cfg.h
Go to the documentation of this file.
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-2020, The Tor Project, Inc. */
5 /* See LICENSE for licensing information */
6 
7 #ifndef TOR_DISPATCH_CFG_H
8 #define TOR_DISPATCH_CFG_H
9 
10 /**
11  * @file dispatch_cfg.h
12  * @brief Header for distpach_cfg.c
13  **/
14 
15 #include "lib/dispatch/msgtypes.h"
17 
18 /**
19  * A "dispatch_cfg" is the configuration used to set up a dispatcher.
20  * It is created and accessed with a set of dcfg_* functions, and then
21  * used with dispatcher_new() to make the dispatcher.
22  */
23 typedef struct dispatch_cfg_t dispatch_cfg_t;
24 
26 
27 int dcfg_msg_set_type(dispatch_cfg_t *cfg, message_id_t msg,
28  msg_type_id_t type);
29 
30 int dcfg_msg_set_chan(dispatch_cfg_t *cfg, message_id_t msg,
31  channel_id_t chan);
32 
34  const dispatch_typefns_t *fns);
35 
36 int dcfg_add_recv(dispatch_cfg_t *cfg, message_id_t msg,
37  subsys_id_t sys, recv_fn_t fn);
38 
39 /** Free a dispatch_cfg_t. */
40 #define dcfg_free(cfg) \
41  FREE_AND_NULL(dispatch_cfg_t, dcfg_free_, (cfg))
42 
43 void dcfg_free_(dispatch_cfg_t *cfg);
44 
45 #ifdef DISPATCH_NEW_PRIVATE
46 struct smartlist_t;
47 STATIC int max_in_u16_sl(const struct smartlist_t *sl, int dflt);
48 #endif
49 
50 #endif /* !defined(TOR_DISPATCH_CFG_H) */
#define STATIC
Definition: testsupport.h:32
dispatch_cfg_t * dcfg_new(void)
Definition: dispatch_cfg.c:30
Types used for messages in the dispatcher code.
int dcfg_type_set_fns(dispatch_cfg_t *cfg, msg_type_id_t type, const dispatch_typefns_t *fns)
Definition: dispatch_cfg.c:81
int dcfg_msg_set_type(dispatch_cfg_t *cfg, message_id_t msg, msg_type_id_t type)
Definition: dispatch_cfg.c:45
STATIC int max_in_u16_sl(const smartlist_t *sl, int dflt)
Definition: dispatch_new.c:31
uint16_t msg_type_id_t
Definition: msgtypes.h:29
void dcfg_free_(dispatch_cfg_t *cfg)
Definition: dispatch_cfg.c:121
uint16_t subsys_id_t
Definition: msgtypes.h:22
void(* recv_fn_t)(const msg_t *m)
Definition: msgtypes.h:66
int dcfg_msg_set_chan(dispatch_cfg_t *cfg, message_id_t msg, channel_id_t chan)
Definition: dispatch_cfg.c:63
Macros to implement mocking and selective exposure for the test code.
int dcfg_add_recv(dispatch_cfg_t *cfg, message_id_t msg, subsys_id_t sys, recv_fn_t fn)
Definition: dispatch_cfg.c:101