|
17 | 17 | * under the License.
|
18 | 18 | */
|
19 | 19 |
|
| 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 | + |
20 | 36 | #include <qpid/dispatch/ctools.h>
|
21 | 37 | #include <qpid/dispatch/enum.h>
|
22 | 38 | #include <qpid/dispatch/alloc_pool.h>
|
23 | 39 | #include <qpid/dispatch/io_module.h>
|
24 | 40 | #include <qpid/dispatch/protocol_adaptor.h>
|
25 | 41 | #include <qpid/dispatch/log.h>
|
26 | 42 | #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; |
27 | 99 |
|
28 | 100 | //===========================================================================================
|
29 | 101 | // Transport API Handlers
|
@@ -80,26 +152,33 @@ static qd_error_t refresh_tcp_connector(qd_entity_t* entity, void *impl)
|
80 | 152 | //
|
81 | 153 | static void TRANSPORT_init(qdr_core_t *core, void **adaptor_context)
|
82 | 154 | {
|
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; |
92 | 170 | }
|
93 | 171 |
|
94 | 172 | //
|
95 | 173 | // This finalization function is invoked once at router shut-down only if it was earlier initialized.
|
96 | 174 | //
|
97 | 175 | static void TRANSPORT_final(void *module_context)
|
98 | 176 | {
|
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); |
100 | 179 | }
|
101 | 180 |
|
102 | 181 | /**
|
103 | 182 | * Declare the module so that it will self-register on process startup.
|
104 | 183 | */
|
105 |
| -QDR_TRANSPORT_MODULE_DECLARE("reference", TRANSPORT_init, TRANSPORT_final) |
| 184 | +QDR_TRANSPORT_MODULE_DECLARE(module_name, TRANSPORT_init, TRANSPORT_final) |
0 commit comments