Skip to content

Commit 7e932b5

Browse files
committed
Began annotating the reference file with development instructions.
1 parent 297264f commit 7e932b5

File tree

1 file changed

+90
-11
lines changed

1 file changed

+90
-11
lines changed

src/transport_modules/reference.c

Lines changed: 90 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,85 @@
1717
* under the License.
1818
*/
1919

20+
//
21+
// HOW TO USE THIS FILE:
22+
//
23+
// - Make a copy of this source file in the same directory but under a different name.
24+
// - Add the new file to src/CMakeLists.txt so it will be built.
25+
//
26+
// In your copy:
27+
// - Change the name of the module in the module_name constant.
28+
// - Fill in all of the TODO sections with your specific implementation.
29+
//
30+
// To select your plugin as the active transport:
31+
// Add the following line to the "router" section in etc/skrouterd.conf:
32+
//
33+
// transportPlugin: <the name of your module>
34+
//
35+
2036
#include <qpid/dispatch/ctools.h>
2137
#include <qpid/dispatch/enum.h>
2238
#include <qpid/dispatch/alloc_pool.h>
2339
#include <qpid/dispatch/io_module.h>
2440
#include <qpid/dispatch/protocol_adaptor.h>
2541
#include <qpid/dispatch/log.h>
2642
#include <qpid/dispatch/adaptor_common.h>
43+
#include <qpid/dispatch/service_transport.h>
44+
45+
//===========================================================================================
46+
// Settings and Definitions
47+
//===========================================================================================
48+
49+
//
50+
// TODO: Change the name
51+
//
52+
static const char *module_name = "reference";
53+
54+
//===========================================================================================
55+
// State Definitions
56+
//===========================================================================================
57+
58+
//
59+
// Service Listener
60+
//
61+
typedef struct tmod_tcp_listener_t {
62+
DEQ_LINKS(struct tmod_tcp_listener_t);
63+
} tmod_tcp_listener_t;
64+
65+
ALLOC_DECLARE(tmod_tcp_listener_t);
66+
ALLOC_DEFINE(tmod_tcp_listener_t);
67+
DEQ_DECLARE(tmod_tcp_listener_t, tmod_tcp_listener_list_t);
68+
69+
//
70+
// Service Connector
71+
//
72+
typedef struct tmod_tcp_connector_t {
73+
DEQ_LINKS(struct tmod_tcp_connector_t);
74+
} tmod_tcp_connector_t;
75+
76+
ALLOC_DECLARE(tmod_tcp_connector_t);
77+
ALLOC_DEFINE(tmod_tcp_connector_t);
78+
DEQ_DECLARE(tmod_tcp_connector_t, tmod_tcp_connector_list_t);
79+
80+
//
81+
// Inter-Router Listener
82+
//
83+
84+
//
85+
// Inter-Router Connector
86+
//
87+
88+
//
89+
// Inter-Router Link
90+
//
91+
92+
//
93+
// Module State
94+
//
95+
typedef struct {
96+
tmod_tcp_listener_list_t tcpListeners;
97+
tmod_tcp_connector_list_t tcpConnectors;
98+
} tmod_module_t;
2799

28100
//===========================================================================================
29101
// Transport API Handlers
@@ -80,26 +152,33 @@ static qd_error_t refresh_tcp_connector(qd_entity_t* entity, void *impl)
80152
//
81153
static void TRANSPORT_init(qdr_core_t *core, void **adaptor_context)
82154
{
83-
qd_log(LOG_ROUTER, QD_LOG_INFO, "Reference Transport Module Initialized");
84-
85-
qd_register_tcp_management_handlers(configure_tcp_listener,
86-
configure_tcp_connector,
87-
update_tcp_listener,
88-
delete_tcp_listener,
89-
delete_tcp_connector,
90-
refresh_tcp_listener,
91-
refresh_tcp_connector);
155+
qd_log(LOG_ROUTER, QD_LOG_INFO, "Transport Module Initialized: %s", module_name);
156+
157+
qd_register_tcp_management_handlers(
158+
configure_tcp_listener,
159+
configure_tcp_connector,
160+
update_tcp_listener,
161+
delete_tcp_listener,
162+
delete_tcp_connector,
163+
refresh_tcp_listener,
164+
refresh_tcp_connector
165+
);
166+
167+
tmod_module_t *module = NEW(tmod_module_t);
168+
ZERO(module);
169+
*adaptor_context = module;
92170
}
93171

94172
//
95173
// This finalization function is invoked once at router shut-down only if it was earlier initialized.
96174
//
97175
static void TRANSPORT_final(void *module_context)
98176
{
99-
qd_log(LOG_ROUTER, QD_LOG_INFO, "Reference Transport Module Finalized");
177+
qd_log(LOG_ROUTER, QD_LOG_INFO, "Transport Module Finalized: %s", module_name);
178+
free(module_context);
100179
}
101180

102181
/**
103182
* Declare the module so that it will self-register on process startup.
104183
*/
105-
QDR_TRANSPORT_MODULE_DECLARE("reference", TRANSPORT_init, TRANSPORT_final)
184+
QDR_TRANSPORT_MODULE_DECLARE(module_name, TRANSPORT_init, TRANSPORT_final)

0 commit comments

Comments
 (0)