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.
46 #include "olsrd_plugin.h"
47 #include "info/olsrd_info.h"
48 #include "olsrd_netjson.h"
50 #include "builddata.h"
52 #define PLUGIN_NAME "NETJSON"
53 #define PLUGIN_TITLE "OLSRD netjson plugin"
54 #define PLUGIN_INTERFACE_VERSION 5
56 info_plugin_functions_t functions;
57 info_plugin_config_t config;
60 static void my_init(void) __attribute__ ((constructor));
61 static void my_fini(void) __attribute__ ((destructor));
66 static void my_init(void) {
67 /* Print plugin info to stdout */
68 olsr_printf(0, "%s (%s)\n", PLUGIN_TITLE, git_descriptor);
70 info_plugin_config_init(&config, 2005);
76 static void my_fini(void) {
77 /* Calls the destruction function
79 * This function should be present in your
80 * sourcefile and all data destruction
81 * should happen there - NOT HERE!
87 *Do initialization here
89 *This function is called by the my_init
90 *function in uolsrd_plugin.c
92 int olsrd_plugin_init(void) {
93 memset(&functions, 0, sizeof(functions));
95 functions.supportsCompositeCommands = false;
96 functions.supported_commands_mask = get_supported_commands_mask;
97 functions.is_command = isCommand;
98 functions.cache_timeout = cache_timeout_generic;
99 functions.determine_mime_type = determine_mime_type;
100 functions.output_start = output_start;
101 functions.output_end = output_end;
102 functions.output_error = output_error;
104 functions.networkRoutes = ipc_print_network_routes;
105 functions.networkGraph = ipc_print_network_graph;
106 functions.networkCollection = ipc_print_network_collection;
108 return info_plugin_init(PLUGIN_NAME, &functions, &config);
112 * destructor - called at unload
114 void olsr_plugin_exit(void) {
118 int olsrd_plugin_interface_version(void) {
119 return PLUGIN_INTERFACE_VERSION;
122 static const struct olsrd_plugin_parameters plugin_parameters[] = { //
124 INFO_PLUGIN_CONFIG_PLUGIN_PARAMETERS(config), //
125 { .name = "pretty", .set_plugin_parameter = &set_plugin_boolean, .data = &pretty, .addon = { .pc = NULL } } //
128 void olsrd_get_plugin_parameters(const struct olsrd_plugin_parameters **params, int *size) {
129 *params = plugin_parameters;
130 *size = sizeof(plugin_parameters) / sizeof(*plugin_parameters);