1 /*
2 * The olsr.org Optimized Link-State Routing daemon (olsrd)
3 *
4 * (c) by the OLSR project
5 *
6 * See our Git repository to find out who worked on this file
7 * and thus is a copyright holder on it.
8 *
9 * All rights reserved.
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
14 *
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
20 * distribution.
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.
24 *
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.
37 *
38 * Visit http://www.olsr.org for more information.
39 *
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.
43 *
44 */
45
46 /* -------------------------------------------------------------------------
47 * File : olsrd_plugin.c
48 * Description : functions to setup plugin
49 * ------------------------------------------------------------------------- */
50
51 #include "olsrd_plugin.h"
52 #include "scheduler.h"
53 #include "defs.h"
54 #include "olsr.h"
55 #include "builddata.h"
56
57 #include "quagga.h"
58 #include "plugin.h"
59 #include "parse.h"
60
61 #define PLUGIN_NAME "OLSRD quagga plugin"
62 #define PLUGIN_INTERFACE_VERSION 5
63
64 static void __attribute__ ((constructor)) my_init(void);
65 static void __attribute__ ((destructor)) my_fini(void);
66
67 int
olsrd_plugin_interface_version(void)68 olsrd_plugin_interface_version(void)
69 {
70
71 return PLUGIN_INTERFACE_VERSION;
72 }
73
74 static const struct olsrd_plugin_parameters plugin_parameters[] = {
75 {.name = "Redistribute",.set_plugin_parameter = &zplugin_redistribute,},
76 {.name = "ExportRoutes",.set_plugin_parameter = &zplugin_exportroutes,},
77 {.name = "Distance",.set_plugin_parameter = &zplugin_distance,},
78 {.name = "LocalPref",.set_plugin_parameter = &zplugin_localpref,},
79 {.name = "SockPath",.set_plugin_parameter = &zplugin_sockpath,.addon = {PATH_MAX},},
80 {.name = "Port",.set_plugin_parameter = &zplugin_port,},
81 {.name = "Version",.set_plugin_parameter = &zplugin_version,},
82 };
83
84 void
olsrd_get_plugin_parameters(const struct olsrd_plugin_parameters ** params,int * size)85 olsrd_get_plugin_parameters(const struct olsrd_plugin_parameters **params, int *size)
86 {
87
88 *params = plugin_parameters;
89 *size = ARRAYSIZE(plugin_parameters);
90
91 }
92
93 int
olsrd_plugin_init(void)94 olsrd_plugin_init(void)
95 {
96
97 olsr_start_timer(1 * MSEC_PER_SEC, 0, OLSR_TIMER_PERIODIC, &zparse, NULL, 0);
98
99 return 0;
100 }
101
102 static void
my_init(void)103 my_init(void)
104 {
105 /* Print plugin info to stdout */
106 olsr_printf(0, "%s (%s)\n", PLUGIN_NAME, git_descriptor);
107
108 zebra_init();
109
110 }
111
112 static void
my_fini(void)113 my_fini(void)
114 {
115
116 zebra_fini();
117
118 }
119
120 /*
121 * Local Variables:
122 * c-basic-offset: 2
123 * indent-tabs-mode: nil
124 * End:
125 */
126