2 * The olsr.org Optimized Link-State Routing daemon (olsrd)
4 * (c) by the OLSR project
6 * See our Git repository to find out who worked on this file
7 * and thus is a copyright holder on it.
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
15 * * Redistributions of source code must retain the above copyright
16 * notice, this list of conditions and the following disclaimer.
17 * * Redistributions in binary form must reproduce the above copyright
18 * notice, this list of conditions and the following disclaimer in
19 * the documentation and/or other materials provided with the
21 * * Neither the name of olsr.org, olsrd nor the names of its
22 * contributors may be used to endorse or promote products derived
23 * from this software without specific prior written permission.
25 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
26 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
27 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
28 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
29 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
30 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
31 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
32 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
33 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
34 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
35 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36 * POSSIBILITY OF SUCH DAMAGE.
38 * Visit http://www.olsr.org for more information.
40 * If you find this software useful feel free to make a donation
41 * to the project. For more information see the website or contact
42 * the copyright holders.
47 * Dynamic linked library for the olsr.org olsr daemon
50 #include "olsrd_plugin.h"
51 #include "info/olsrd_info.h"
52 #include "olsrd_jsoninfo.h"
54 #include "builddata.h"
56 #define PLUGIN_NAME "JSONINFO"
57 #define PLUGIN_TITLE "OLSRD jsoninfo plugin"
58 #define PLUGIN_INTERFACE_VERSION 5
60 info_plugin_functions_t functions;
61 info_plugin_config_t config;
62 char uuidfile[FILENAME_MAX];
65 static void my_init(void) __attribute__ ((constructor));
66 static void my_fini(void) __attribute__ ((destructor));
71 static void my_init(void) {
72 /* Print plugin info to stdout */
73 olsr_printf(0, "%s (%s)\n", PLUGIN_TITLE, git_descriptor);
75 info_plugin_config_init(&config, 9090);
76 memset(uuidfile, 0, sizeof(uuidfile));
82 static void my_fini(void) {
83 /* Calls the destruction function
85 * This function should be present in your
86 * sourcefile and all data destruction
87 * should happen there - NOT HERE!
93 *Do initialization here
95 *This function is called by the my_init
96 *function in uolsrd_plugin.c
98 int olsrd_plugin_init(void) {
99 memset(&functions, 0, sizeof(functions));
101 functions.supportsCompositeCommands = true;
102 functions.init = plugin_init;
103 functions.supported_commands_mask = get_supported_commands_mask;
104 functions.is_command = isCommand;
105 functions.cache_timeout = cache_timeout_generic;
106 functions.determine_mime_type = determine_mime_type;
107 functions.output_start = output_start;
108 functions.output_end = output_end;
109 functions.output_error = output_error;
111 functions.neighbors = ipc_print_neighbors;
112 functions.links = ipc_print_links;
113 functions.routes = ipc_print_routes;
114 functions.topology = ipc_print_topology;
115 functions.hna = ipc_print_hna;
116 functions.mid = ipc_print_mid;
117 functions.gateways = ipc_print_gateways;
118 functions.sgw = ipc_print_sgw;
119 functions.version = ipc_print_version;
120 functions.olsrd_conf = ipc_print_olsrd_conf;
121 functions.interfaces = ipc_print_interfaces;
122 functions.twohop = ipc_print_twohop;
123 functions.config = ipc_print_config;
124 functions.plugins = ipc_print_plugins;
126 return info_plugin_init(PLUGIN_NAME, &functions, &config);
130 * destructor - called at unload
132 void olsr_plugin_exit(void) {
136 int olsrd_plugin_interface_version(void) {
137 return PLUGIN_INTERFACE_VERSION;
140 static const struct olsrd_plugin_parameters plugin_parameters[] = { //
142 INFO_PLUGIN_CONFIG_PLUGIN_PARAMETERS(config), //
143 { .name = "uuidfile", .set_plugin_parameter = &set_plugin_string, .data = uuidfile, .addon = { .ui = FILENAME_MAX - 1 } }, //
144 { .name = "pretty", .set_plugin_parameter = set_plugin_boolean, .data = &pretty, .addon = { .pc = NULL } } //
147 void olsrd_get_plugin_parameters(const struct olsrd_plugin_parameters **params, int *size) {
148 *params = plugin_parameters;
149 *size = sizeof(plugin_parameters) / sizeof(*plugin_parameters);
157 * indent-tabs-mode: nil