2 * The olsr.org Optimized Link-State Routing daemon(olsrd)
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
11 * * Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * * Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in
15 * the documentation and/or other materials provided with the
17 * * Neither the name of olsr.org, olsrd nor the names of its
18 * contributors may be used to endorse or promote products derived
19 * from this software without specific prior written permission.
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
27 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
31 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32 * POSSIBILITY OF SUCH DAMAGE.
34 * Visit http://www.olsr.org for more information.
36 * If you find this software useful feel free to make a donation
37 * to the project. For more information see the website or contact
38 * the copyright holders.
42 #ifndef _OLSRD_LIB_INFO_INFO_TYPES_H_
43 #define _OLSRD_LIB_INFO_INFO_TYPES_H_
47 #include <netinet/in.h>
49 #include "common/autobuf.h"
52 union olsr_ip_addr accept_ip;
53 union olsr_ip_addr listen_ip;
58 } info_plugin_config_t;
60 #define INFO_PLUGIN_CONFIG_PLUGIN_PARAMETERS(config) \
61 { .name = "port", .set_plugin_parameter = &set_plugin_port, .data = &config.ipc_port }, \
62 { .name = "accept", .set_plugin_parameter = &set_plugin_ipaddress, .data = &config.accept_ip }, \
63 { .name = "listen", .set_plugin_parameter = &set_plugin_ipaddress, .data = &config.listen_ip }, \
64 { .name = "httpheaders", .set_plugin_parameter = &set_plugin_boolean, .data = &config.http_headers }, \
65 { .name = "allowlocalhost", .set_plugin_parameter = &set_plugin_boolean, .data = &config.allow_localhost }, \
66 { .name = "ipv6only", .set_plugin_parameter = &set_plugin_boolean, .data = &config.ipv6_only }
68 /* these provide all of the runtime status info */
69 #define SIW_NEIGHBORS 0x00000001ULL
70 #define SIW_LINKS 0x00000002ULL
71 #define SIW_ROUTES 0x00000004ULL
72 #define SIW_HNA 0x00000008ULL
73 #define SIW_MID 0x00000010ULL
74 #define SIW_TOPOLOGY 0x00000020ULL
75 #define SIW_GATEWAYS 0x00000040ULL
76 #define SIW_INTERFACES 0x00000080ULL
77 #define SIW_2HOP 0x00000100ULL
78 #define SIW_SGW 0x00000200ULL
79 #define SIW_RUNTIME_ALL (SIW_NEIGHBORS | SIW_LINKS | SIW_ROUTES | SIW_HNA | SIW_MID | SIW_TOPOLOGY | SIW_GATEWAYS | SIW_INTERFACES | SIW_2HOP | SIW_SGW)
80 #define SIW_NEIGHBORS_FREIFUNK (SIW_NEIGHBORS | SIW_LINKS) /* special */
82 /* these only change at olsrd startup */
83 #define SIW_VERSION 0x00000400ULL
84 #define SIW_CONFIG 0x00000800ULL
85 #define SIW_PLUGINS 0x00001000ULL
86 #define SIW_STARTUP_ALL (SIW_VERSION | SIW_CONFIG | SIW_PLUGINS)
88 /* this is everything in normal format */
89 #define SIW_ALL (SIW_RUNTIME_ALL | SIW_STARTUP_ALL)
91 /* this data is not normal format but olsrd.conf format */
92 #define SIW_OLSRD_CONF 0x00002000ULL
94 typedef void (*init_plugin)(const char *plugin_name);
95 typedef bool (*command_matcher)(const char *str, unsigned long long siw);
96 typedef const char * (*mime_type)(unsigned int send_what);
97 typedef void (*output_start_end)(struct autobuf *abuf);
98 typedef void (*printer_error)(struct autobuf *abuf, unsigned int status, const char * req, bool http_headers);
99 typedef void (*printer_generic)(struct autobuf *abuf);
102 bool supportsCompositeCommands;
104 command_matcher is_command;
105 mime_type determine_mime_type;
106 output_start_end output_start;
107 output_start_end output_end;
108 printer_error output_error;
109 printer_generic neighbors;
110 printer_generic links;
111 printer_generic routes;
112 printer_generic topology;
115 printer_generic gateways;
117 printer_generic version;
118 printer_generic olsrd_conf;
119 printer_generic interfaces;
120 printer_generic twohop;
121 printer_generic config;
122 printer_generic plugins;
123 } info_plugin_functions_t;
125 static INLINE void info_plugin_config_init(info_plugin_config_t *config, unsigned short port) {
128 if (olsr_cnf->ip_version == AF_INET) {
129 config->accept_ip.v4.s_addr = htonl(INADDR_LOOPBACK);
130 config->listen_ip.v4.s_addr = htonl(INADDR_ANY);
132 config->accept_ip.v6 = in6addr_loopback;
133 config->listen_ip.v6 = in6addr_any;
136 config->ipc_port = port;
137 config->http_headers = true;
138 config->allow_localhost = false;
139 config->ipv6_only = false;
142 #endif /* _OLSRD_LIB_INFO_INFO_TYPES_H_ */