2 * The olsr.org Optimized Link-State Routing daemon(olsrd)
3 * Copyright (c) 2004-2009, the olsr.org team - see HISTORY file
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.
42 #include <assert.h> /* assert() */
43 #include <stddef.h> /* NULL */
46 #include "olsrd_plugin.h"
47 #include "plugin_util.h"
48 #include "defs.h" /* uint8_t, olsr_cnf */
49 #include "scheduler.h" /* olsr_start_timer() */
50 #include "olsr_cfg.h" /* olsr_cnf() */
51 #include "olsr_cookie.h" /* olsr_alloc_cookie() */
54 #include "p2pd.h" /* InitP2pd(), CloseP2pd() */
55 #include "NetworkInterfaces.h" /* AddNonOlsrIf */
57 static void __attribute__ ((constructor)) my_init(void);
58 static void __attribute__ ((destructor)) my_fini(void);
60 //static struct olsr_cookie_info *prune_packet_history_timer_cookie;
62 void olsr_plugin_exit(void);
64 /* -------------------------------------------------------------------------
65 * Function : olsrd_plugin_interface_version
66 * Description: Plugin interface version
69 * Return : P2PD plugin interface version number
71 * Notes : Called by main OLSRD (olsr_load_dl) to check plugin interface
73 * ------------------------------------------------------------------------- */
75 olsrd_plugin_interface_version(void)
77 return PLUGIN_INTERFACE_VERSION;
80 /* -------------------------------------------------------------------------
81 * Function : olsrd_plugin_init
82 * Description: Plugin initialisation
85 * Return : fail (0) or success (1)
86 * Data Used : olsr_cnf
87 * Notes : Called by main OLSRD (init_olsr_plugin) to initialize plugin
88 * ------------------------------------------------------------------------- */
90 olsrd_plugin_init(void)
92 return InitP2pd(NULL);
95 /* -------------------------------------------------------------------------
96 * Function : olsr_plugin_exit
97 * Description: Plugin cleanup
102 * Notes : Called by my_fini() at unload of shared object
103 * ------------------------------------------------------------------------- */
105 olsr_plugin_exit(void)
110 static const struct olsrd_plugin_parameters plugin_parameters[] = {
111 {.name = "NonOlsrIf",.set_plugin_parameter = &AddNonOlsrIf,.data = NULL},
112 {.name = "P2pdTtl", .set_plugin_parameter = &SetP2pdTtl, .data = NULL },
113 {.name = "UdpDestPort",.set_plugin_parameter = &AddUdpDestPort,.data = NULL},
114 {.name = "UseHashFilter",.set_plugin_parameter = &SetP2pdUseHashFilter,.data = NULL},
115 {.name = "UseTTLDecrement",.set_plugin_parameter = &SetP2pdUseTtlDecrement,.data = NULL},
118 /* -------------------------------------------------------------------------
119 * Function : olsrd_get_plugin_parameters
120 * Description: Return the parameter table and its size
122 * Output : params - the parameter table
123 * size - its size in no. of entries
125 * Data Used : plugin_parameters
126 * Notes : Called by main OLSR (init_olsr_plugin) for all plugins
127 * ------------------------------------------------------------------------- */
129 olsrd_get_plugin_parameters(const struct olsrd_plugin_parameters **params, int *size)
131 *params = plugin_parameters;
132 *size = ARRAYSIZE(plugin_parameters);
135 /* -------------------------------------------------------------------------
137 * Description: Plugin constructor
142 * Notes : Called at load of shared object
143 * ------------------------------------------------------------------------- */
147 /* Print plugin info to stdout */
148 printf("%s\n", MOD_DESC);
153 /* -------------------------------------------------------------------------
155 * Description: Plugin destructor
160 * Notes : Called at unload of shared object
161 * ------------------------------------------------------------------------- */
171 * indent-tabs-mode: nil