1 /* Copyright © 2012 Brandon L Black <blblack@gmail.com>
2 *
3 * This file is part of gdnsd.
4 *
5 * gdnsd is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * gdnsd is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with gdnsd. If not, see <http://www.gnu.org/licenses/>.
17 *
18 */
19
20 #ifdef GDNSD_PLUGIN_H
21 #error gdnsd/plugin.h must be included *exactly once* from *exactly one* source file per plugin
22 #endif
23
24 #define GDNSD_PLUGIN_H
25
26 // Include all of the libgdnsd stuff for convenience
27 #include <gdnsd/compiler.h>
28 #include <gdnsd/alloc.h>
29 #include <gdnsd/dmn.h>
30 #include <gdnsd/vscf.h>
31 #include <gdnsd/dname.h>
32 #include <gdnsd/net.h>
33 #include <gdnsd/log.h>
34 #include <gdnsd/mon.h>
35 #include <gdnsd/plugapi.h>
36 #include <gdnsd/misc.h>
37 #include <gdnsd/paths.h>
38 #include <gdnsd/prcu.h>
39 #include <gdnsd/stats.h>
40
41 #ifndef GDNSD_PLUGIN_NAME
42 #error You must define GDNSD_PLUGIN_NAME before including <gdnsd/plugin.h>
43 #endif
44
45 /* All of the below is just to declare the API functions the plugin
46 * should be implementing, so that the compiler can complain if the
47 * prototypes don't match your code. Also, the get_api_version call
48 * is implemented in the header file directly.
49 */
50
51 #define __PASTE3(a,b,c) a##b##c
52
53 #define SYM_GET_APIV(x) __PASTE3(plugin_, x, _get_api_version)
54 #define SYM_LOAD_CONFIG(x) __PASTE3(plugin_, x, _load_config)
55 #define SYM_MAP_RES(x) __PASTE3(plugin_, x, _map_res)
56 #define SYM_PRE_RUN(x) __PASTE3(plugin_, x, _pre_run)
57 #define SYM_IOTH_INIT(x) __PASTE3(plugin_, x, _iothread_init)
58 #define SYM_RESOLVE(x) __PASTE3(plugin_, x, _resolve)
59 #define SYM_EXIT(x) __PASTE3(plugin_, x, _exit)
60 #define SYM_ADD_SVC(x) __PASTE3(plugin_, x, _add_svctype)
61 #define SYM_ADD_MON_ADDR(x) __PASTE3(plugin_, x, _add_mon_addr)
62 #define SYM_ADD_MON_CNAME(x) __PASTE3(plugin_, x, _add_mon_cname)
63 #define SYM_INIT_MONS(x) __PASTE3(plugin_, x, _init_monitors)
64 #define SYM_START_MONS(x) __PASTE3(plugin_, x, _start_monitors)
65
66 #pragma GCC visibility push(default)
67
68 F_CONST
69 uint32_t SYM_GET_APIV(GDNSD_PLUGIN_NAME)(void);
SYM_GET_APIV(GDNSD_PLUGIN_NAME)70 uint32_t SYM_GET_APIV(GDNSD_PLUGIN_NAME)(void) { return GDNSD_PLUGIN_API_VERSION; }
71
72 void SYM_LOAD_CONFIG(GDNSD_PLUGIN_NAME)(vscf_data_t* config, const unsigned num_threads);
73 int SYM_MAP_RES(GDNSD_PLUGIN_NAME)(const char* resname, const uint8_t* origin);
74 F_NONNULL
75 void SYM_PRE_RUN(GDNSD_PLUGIN_NAME)(void);
76 void SYM_IOTH_INIT(GDNSD_PLUGIN_NAME)(unsigned threadnum);
77 F_NONNULLX(3,4)
78 gdnsd_sttl_t SYM_RESOLVE(GDNSD_PLUGIN_NAME)(unsigned resnum, const uint8_t* origin, const client_info_t* cinfo, dyn_result_t* result);
79 void SYM_EXIT(GDNSD_PLUGIN_NAME)(void);
80 F_NONNULL
81 void SYM_ADD_SVC(GDNSD_PLUGIN_NAME)(const char* name, vscf_data_t* svc_cfg, const unsigned interval, const unsigned timeout);
82 F_NONNULL
83 void SYM_ADD_MON_ADDR(GDNSD_PLUGIN_NAME)(const char* desc, const char* svc_name, const char* cname, const dmn_anysin_t* addr, const unsigned idx);
84 F_NONNULL
85 void SYM_ADD_MON_CNAME(GDNSD_PLUGIN_NAME)(const char* desc, const char* svc_name, const char* cname, const unsigned idx);
86 F_NONNULL
87 void SYM_INIT_MONS(GDNSD_PLUGIN_NAME)(struct ev_loop* mon_loop);
88 F_NONNULL
89 void SYM_START_MONS(GDNSD_PLUGIN_NAME)(struct ev_loop* mon_loop);
90
91 #pragma GCC visibility pop
92
93 #undef SYM_APIV
94 #undef SYM_LOAD_CONFIG
95 #undef SYM_MAP_RES
96 #undef SYM_PRE_RUN
97 #undef SYM_IOTH_INIT
98 #undef SYM_RESOLVE
99 #undef SYM_EXIT
100 #undef SYM_ADD_SVC
101 #undef SYM_ADD_MON_ADDR
102 #undef SYM_ADD_MON_CNAME
103 #undef SYM_INIT_MONS
104 #undef SYM_START_MONS
105