1 // SPDX-License-Identifier: ISC
3 * Copyright (c) 2015-16 David Lamparter, for NetDEF, Inc.
19 struct frrmod_runtime
;
22 /* single-line few-word title */
24 /* human-readable version number, should not contain spaces */
26 /* one-paragraph description */
27 const char *description
;
32 /* primary entry point structure to be present in loadable module under
33 * "_frrmod_this_module" dlsym() name
35 * note space for future extensions is reserved below, so other modules
36 * (e.g. memory management, hooks) can add fields
38 * const members/info are in frrmod_info.
40 struct frrmod_runtime
{
41 struct frrmod_runtime
*next
;
43 const struct frrmod_info
*info
;
45 bool finished_loading
;
51 /* space-reserving foo */
52 struct _frrmod_runtime_size
{
53 struct frrmod_runtime r
;
54 /* this will barf if frrmod_runtime exceeds 1024 bytes ... */
55 uint8_t space
[1024 - sizeof(struct frrmod_runtime
)];
57 union _frrmod_runtime_u
{
58 struct frrmod_runtime r
;
59 struct _frrmod_runtime_size s
;
62 extern union _frrmod_runtime_u _frrmod_this_module
;
63 #define THIS_MODULE (&_frrmod_this_module.r)
65 #define FRR_COREMOD_SETUP(...) \
66 static const struct frrmod_info _frrmod_info = {__VA_ARGS__}; \
67 DSO_LOCAL union _frrmod_runtime_u _frrmod_this_module = {{ \
72 MACRO_REQUIRE_SEMICOLON() /* end */
74 #define FRR_MODULE_SETUP(...) \
75 FRR_COREMOD_SETUP(__VA_ARGS__); \
76 DSO_SELF struct frrmod_runtime *frr_module = &_frrmod_this_module.r; \
77 MACRO_REQUIRE_SEMICOLON() /* end */
79 extern struct frrmod_runtime
*frrmod_list
;
81 extern void frrmod_init(struct frrmod_runtime
*modinfo
);
82 extern struct frrmod_runtime
*frrmod_load(const char *spec
, const char *dir
,
83 void (*pFerrlog
)(const void *,
85 const void *pErrlogCookie
);
87 /* not implemented yet */
88 extern void frrmod_unload(struct frrmod_runtime
*module
);
95 #endif /* _FRR_MODULE_H */