2 * The olsr.org Optimized Link-State Routing daemon(olsrd)
3 * Copyright (c) 2004, Andreas Tønnesen(andreto@olsr.org)
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
10 * * Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * * Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in
14 * the documentation and/or other materials provided with the
16 * * Neither the name of olsr.org, olsrd nor the names of its
17 * contributors may be used to endorse or promote products derived
18 * from this software without specific prior written permission.
20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
23 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
24 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
25 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
26 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
27 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
28 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
30 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31 * POSSIBILITY OF SUCH DAMAGE.
33 * Visit http://www.olsr.org for more information.
35 * If you find this software useful feel free to make a donation
36 * to the project. For more information see the website or contact
37 * the copyright holders.
39 * $Id: olsrd_plugin.h,v 1.13 2005/02/17 21:31:52 kattemat Exp $
43 * Dynamic linked library for the olsr.org olsr daemon
46 #ifndef _OLSRD_PLUGIN_DEFS
47 #define _OLSRD_PLUGIN_DEFS
50 #include <netinet/in.h>
51 #include <sys/socket.h>
52 #include <sys/times.h>
53 #include <arpa/inet.h>
58 #include "olsr_plugin_io.h"
61 /*****************************************************************************
63 * ALTER THIS TO YOUR OWN NEED *
64 *****************************************************************************/
66 #define PLUGIN_NAME "Httpinfo olsrd plugin"
67 #define PLUGIN_VERSION "0.1"
68 #define PLUGIN_AUTHOR "Andreas Tønnesen"
69 #define MOD_DESC PLUGIN_NAME " " PLUGIN_VERSION " by " PLUGIN_AUTHOR
70 #define PLUGIN_INTERFACE_VERSION 2
74 /****************************************************************************
75 * Various datastructures and definitions from olsrd *
76 ****************************************************************************/
99 #include <sys/types.h>
102 typedef u_int8_t olsr_u8_t;
103 typedef u_int16_t olsr_u16_t;
104 typedef u_int32_t olsr_u32_t;
105 typedef int8_t olsr_8_t;
106 typedef int16_t olsr_16_t;
107 typedef int32_t olsr_32_t;
109 typedef unsigned char olsr_u8_t;
110 typedef unsigned short olsr_u16_t;
111 typedef unsigned int olsr_u32_t;
112 typedef char olsr_8_t;
113 typedef short olsr_16_t;
114 typedef int olsr_32_t;
119 * VARIOUS DEFINITIONS
139 #define HASHMASK (HASHSIZE - 1)
141 #define MAXIFS 8 /* Maximum number of interfaces (from defs.h) in uOLSRd */
146 union olsr_ip_addr host;
147 struct allowed_host *next;
152 union olsr_ip_addr net;
153 union olsr_ip_addr mask;
154 struct allowed_net *next;
157 struct allowed_host *allowed_hosts;
158 struct allowed_net *allowed_nets;
162 * Neighbor structures
165 /* One hop neighbor */
167 struct neighbor_2_list_entry
169 struct neighbor_2_entry *neighbor_2;
170 clock_t neighbor_2_timer;
171 struct neighbor_2_list_entry *next;
172 struct neighbor_2_list_entry *prev;
175 struct neighbor_entry
177 union olsr_ip_addr neighbor_main_addr;
179 olsr_u8_t willingness;
181 olsr_bool was_mpr; /* Used to detect changes in MPR */
183 int neighbor_2_nocov;
185 struct neighbor_2_list_entry neighbor_2_list;
186 struct neighbor_entry *next;
187 struct neighbor_entry *prev;
191 /* Two hop neighbor */
194 struct neighbor_list_entry
196 struct neighbor_entry *neighbor;
197 double path_link_quality;
198 double saved_path_link_quality;
199 struct neighbor_list_entry *next;
200 struct neighbor_list_entry *prev;
203 struct neighbor_2_entry
205 union olsr_ip_addr neighbor_2_addr;
206 olsr_u8_t mpr_covered_count; /*used in mpr calculation*/
207 olsr_u8_t processed; /*used in mpr calculation*/
208 olsr_16_t neighbor_2_pointer; /* Neighbor count */
209 struct neighbor_list_entry neighbor_2_nblist;
210 struct neighbor_2_entry *prev;
211 struct neighbor_2_entry *next;
219 union olsr_ip_addr T_dest_addr;
222 struct topo_dst *next;
223 struct topo_dst *prev;
225 double inverse_link_quality;
226 double saved_link_quality;
227 double saved_inverse_link_quality;
232 union olsr_ip_addr T_last_addr;
233 struct topo_dst destinations;
234 struct tc_entry *next;
235 struct tc_entry *prev;
240 /* hna_netmask declared in packet.h */
244 union olsr_ip_addr A_network_addr;
245 union hna_netmask A_netmask;
247 struct hna_net *next;
248 struct hna_net *prev;
253 union olsr_ip_addr A_gateway_addr;
254 struct hna_net networks;
255 struct hna_entry *next;
256 struct hna_entry *prev;
261 union olsr_ip_addr alias;
262 struct mid_entry *main_entry;
264 struct mid_address *next_alias;
266 /* These are for the reverse list */
267 struct mid_address *prev;
268 struct mid_address *next;
272 *Contains the main addr of a node and a list of aliases
276 union olsr_ip_addr main_addr;
277 struct mid_address *aliases;
278 struct mid_entry *prev;
279 struct mid_entry *next;
287 union olsr_ip_addr rt_dst;
288 union olsr_ip_addr rt_router;
289 union hna_netmask rt_mask;
291 olsr_u16_t rt_metric;
292 struct interface *rt_if;
293 struct rt_entry *prev;
294 struct rt_entry *next;
300 struct neighbor_entry *neighbortable;
301 struct neighbor_2_entry *two_hop_neighbortable;
302 struct link_entry *link_set;
303 struct tc_entry *tc_table;
304 struct hna_entry *hna_set;
305 struct mid_entry *mid_set;
306 struct rt_entry *host_routes;
307 struct rt_entry *hna_routes;
310 /* Buffer for olsr_ip_to_string */
312 char ipv6_buf[100]; /* buffer for IPv6 inet_htop */
318 union olsr_ip_addr MS_main_addr;
320 struct mpr_selector *next;
321 struct mpr_selector *prev;
324 /* Global config pointer */
325 struct olsrd_config *cfg;
327 /****************************************************************************
328 * Function pointers to functions in olsrd *
329 * These allow direct access to olsrd functions *
330 ****************************************************************************/
332 /* The multi-purpose funtion. All other functions are fetched trough this */
333 int (*olsr_plugin_io)(int, void *, size_t);
335 /* Add a socket to the main olsrd select loop */
336 void (*add_olsr_socket)(int, void(*)(int));
338 /* Lookup MPR entry */
339 struct mpr_selector *(*olsr_lookup_mprs_set)(union olsr_ip_addr *);
342 /* olsrd printf wrapper */
343 int (*olsr_printf)(int, char *, ...);
345 /* olsrd malloc wrapper */
346 void *(*olsr_malloc)(size_t, const char *);
349 /****************************************************************************
351 * NOTE THAT POINTERS POINT TO THE DATA USED BY OLSRD! *
352 * NEVER ALTER DATA POINTED TO BY THESE POINTERS *
353 * UNLESS YOU KNOW WHAT YOU ARE DOING!!! *
354 ****************************************************************************/
356 /* These two are set automatically by olsrd at load time */
357 int ipversion; /* IPversion in use */
358 union olsr_ip_addr *main_addr; /* Main address */
361 size_t ipsize; /* Size of the ipadresses used */
363 /****************************************************************************
364 * Functions that the plugin MUST provide *
365 ****************************************************************************/
368 /* Initialization function */
370 olsr_plugin_init(void);
372 /* IPC initialization function */
374 plugin_ipc_init(void);
377 register_olsr_param(char *, char *);
379 /* Destructor function */
381 olsr_plugin_exit(void);
383 /* Mulitpurpose funtion */
385 plugin_io(int, void *, size_t);
388 get_plugin_interface_version(void);