summaryrefslogtreecommitdiff
path: root/src/lib/dispatch/dispatch_cfg.h
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2019-01-11 20:17:04 -0500
committerNick Mathewson <nickm@torproject.org>2019-03-25 16:35:33 -0400
commite4d3098d4d23686320013b80b6305fbd52863f76 (patch)
tree96c23b73d84025ec42e676b4087c6b7aaa5dd63e /src/lib/dispatch/dispatch_cfg.h
parenta62ac1719887f0756ceb516ce3b12cd2aee18191 (diff)
downloadtor-e4d3098d4d23686320013b80b6305fbd52863f76.tar.gz
tor-e4d3098d4d23686320013b80b6305fbd52863f76.zip
Low-level dispatch module for publish-subscribe mechanism
This module implements a way to send messages from one module to another, with associated data types. It does not yet do anything to ensure that messages are correct, that types match, or that other forms of consistency are preserved.
Diffstat (limited to 'src/lib/dispatch/dispatch_cfg.h')
-rw-r--r--src/lib/dispatch/dispatch_cfg.h39
1 files changed, 39 insertions, 0 deletions
diff --git a/src/lib/dispatch/dispatch_cfg.h b/src/lib/dispatch/dispatch_cfg.h
new file mode 100644
index 0000000000..2c755e39bc
--- /dev/null
+++ b/src/lib/dispatch/dispatch_cfg.h
@@ -0,0 +1,39 @@
+/* Copyright (c) 2001, Matej Pfajfar.
+ * Copyright (c) 2001-2004, Roger Dingledine.
+ * Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
+ * Copyright (c) 2007-2018, The Tor Project, Inc. */
+/* See LICENSE for licensing information */
+
+#ifndef TOR_DISPATCH_CFG_H
+#define TOR_DISPATCH_CFG_H
+
+#include "lib/dispatch/msgtypes.h"
+
+/**
+ * A "dispatch_cfg" is the configuration used to set up a dispatcher.
+ * It is created and accessed with a set of dcfg_* functions, and then
+ * used with dispatcher_new() to make the dispatcher.
+ */
+typedef struct dispatch_cfg_t dispatch_cfg_t;
+
+dispatch_cfg_t *dcfg_new(void);
+
+int dcfg_msg_set_type(dispatch_cfg_t *cfg, message_id_t msg,
+ msg_type_id_t type);
+
+int dcfg_msg_set_chan(dispatch_cfg_t *cfg, message_id_t msg,
+ channel_id_t chan);
+
+int dcfg_type_set_fns(dispatch_cfg_t *cfg, msg_type_id_t type,
+ const dispatch_typefns_t *fns);
+
+int dcfg_add_recv(dispatch_cfg_t *cfg, message_id_t msg,
+ subsys_id_t sys, recv_fn_t fn);
+
+/** Free a dispatch_cfg_t. */
+#define dcfg_free(cfg) \
+ FREE_AND_NULL(dispatch_cfg_t, dcfg_free_, (cfg))
+
+void dcfg_free_(dispatch_cfg_t *cfg);
+
+#endif