4 * Copyright (c) 2004, Andreas Tønnesen(andreto-at-olsr.org)
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 notice,
12 * this list of conditions and the following disclaimer.
13 * * Redistributions in binary form must reproduce the above copyright notice,
14 * this list of conditions and the following disclaimer in the documentation
15 * and/or other materials provided with the distribution.
16 * * Neither the name of the UniK olsr daemon nor the names of its contributors
17 * may be used to endorse or promote products derived from this software
18 * without specific prior written permission.
20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
21 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
22 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
23 * IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
24 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
25 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
27 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
28 * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
29 * OF THE POSSIBILITY OF SUCH DAMAGE.
34 * Dynamic linked library example for UniK OLSRd
37 #ifndef _OLSRD_PLUGIN_DEFS
38 #define _OLSRD_PLUGIN_DEFS
41 #include <sys/socket.h>
42 #include <netinet/in.h>
43 #include <arpa/inet.h>
48 #include "olsr_plugin_io.h"
51 /*****************************************************************************
53 * ALTER THIS TO YOUR OWN NEED *
54 *****************************************************************************/
56 #define PLUGIN_NAME "OLSRD dot draw plugin"
57 #define PLUGIN_VERSION "0.3"
58 #define PLUGIN_AUTHOR "Andreas Tønnesen"
59 #define MOD_DESC PLUGIN_NAME " " PLUGIN_VERSION " by " PLUGIN_AUTHOR
60 #define PLUGIN_INTERFACE_VERSION 2
62 struct in_addr ipc_accept_ip;
65 /****************************************************************************
66 * Various datastructures and definitions from olsrd *
67 ****************************************************************************/
82 #include <sys/types.h>
85 typedef u_int8_t olsr_u8_t;
86 typedef u_int16_t olsr_u16_t;
87 typedef u_int32_t olsr_u32_t;
88 typedef int8_t olsr_8_t;
89 typedef int16_t olsr_16_t;
90 typedef int32_t olsr_32_t;
92 typedef unsigned char olsr_u8_t;
93 typedef unsigned short olsr_u16_t;
94 typedef unsigned int olsr_u32_t;
95 typedef char olsr_8_t;
96 typedef short olsr_16_t;
97 typedef int olsr_32_t;
102 * VARIOUS DEFINITIONS
122 #define HASHMASK (HASHSIZE - 1)
124 #define MAXIFS 8 /* Maximum number of interfaces (from defs.h) in uOLSRd */
129 * Neighbor structures
132 /* One hop neighbor */
134 struct neighbor_2_list_entry
136 struct neighbor_2_entry *neighbor_2;
137 struct timeval neighbor_2_timer;
138 struct neighbor_2_list_entry *next;
139 struct neighbor_2_list_entry *prev;
142 struct neighbor_entry
144 union olsr_ip_addr neighbor_main_addr;
146 olsr_u8_t willingness;
148 olsr_bool was_mpr; /* Used to detect changes in MPR */
149 int neighbor_2_nocov;
151 struct neighbor_2_list_entry neighbor_2_list;
152 struct neighbor_entry *next;
153 struct neighbor_entry *prev;
157 /* Two hop neighbor */
161 struct neighbor_list_entry
163 struct neighbor_entry *neighbor;
164 struct neighbor_list_entry *next;
165 struct neighbor_list_entry *prev;
169 struct neighbor_2_entry
171 union olsr_ip_addr neighbor_2_addr;
172 olsr_u8_t mpr_covered_count; /*used in mpr calculation*/
173 olsr_u8_t processed; /*used in mpr calculation*/
174 olsr_16_t neighbor_2_pointer; /* Neighbor count */
175 struct neighbor_list_entry neighbor_2_nblist;
176 struct neighbor_2_entry *prev;
177 struct neighbor_2_entry *next;
184 union olsr_ip_addr T_dest_addr;
185 struct timeval T_time;
187 struct topo_dst *next;
188 struct topo_dst *prev;
189 #if defined USE_LINK_QUALITY
191 double inverse_link_quality;
192 double saved_link_quality;
193 double saved_inverse_link_quality;
200 union olsr_ip_addr T_last_addr;
201 struct topo_dst destinations;
202 struct tc_entry *next;
203 struct tc_entry *prev;
208 /* hna_netmask declared in packet.h */
212 union olsr_ip_addr A_network_addr;
213 union hna_netmask A_netmask;
214 struct timeval A_time;
215 struct hna_net *next;
216 struct hna_net *prev;
221 union olsr_ip_addr A_gateway_addr;
222 struct hna_net networks;
223 struct hna_entry *next;
224 struct hna_entry *prev;
229 struct neighbor_entry *neighbortable;
230 struct neighbor_2_entry *two_hop_neighbortable;
231 struct tc_entry *tc_table;
232 struct hna_entry *hna_set;
235 /* Buffer for olsr_ip_to_string */
237 char ipv6_buf[100]; /* buffer for IPv6 inet_htop */
240 /****************************************************************************
241 * Function pointers to functions in olsrd *
242 * These allow direct access to olsrd functions *
243 ****************************************************************************/
245 /* The multi-purpose funtion. All other functions are fetched trough this */
246 int (*olsr_plugin_io)(int, void *, size_t);
248 /* Register a "process changes" function */
249 int (*register_pcf)(int (*)(int, int, int));
251 /* Add a socket to the main olsrd select loop */
252 void (*add_olsr_socket)(int, void(*)(int));
254 /* Remove a socket from the main olsrd select loop */
255 int (*remove_olsr_socket)(int, void(*)(int));
257 /* get the link status to a neighbor */
258 int (*check_neighbor_link)(union olsr_ip_addr *);
260 /* olsrd printf wrapper */
261 int (*olsr_printf)(int, char *, ...);
263 /* olsrd malloc wrapper */
264 void *(*olsr_malloc)(size_t, const char *);
267 /****************************************************************************
269 * NOTE THAT POINTERS POINT TO THE DATA USED BY OLSRD! *
270 * NEVER ALTER DATA POINTED TO BY THESE POINTERS *
271 * UNLESS YOU KNOW WHAT YOU ARE DOING!!! *
272 ****************************************************************************/
274 /* These two are set automatically by olsrd at load time */
275 int ipversion; /* IPversion in use */
276 union olsr_ip_addr *main_addr; /* Main address */
279 size_t ipsize; /* Size of the ipadresses used */
281 /****************************************************************************
282 * Functions that the plugin MUST provide *
283 ****************************************************************************/
286 /* Initialization function */
290 /* IPC initialization function */
295 register_olsr_param(char *, char *);
297 /* Destructor function */
301 /* Mulitpurpose funtion */
303 plugin_io(int, void *, size_t);
306 get_plugin_interface_version();