]>
git.proxmox.com Git - mirror_frr.git/blob - lib/libfrr.h
2 * libfrr overall management functions
4 * Copyright (C) 2016 David Lamparter for NetDEF, Inc.
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the Free
8 * Software Foundation; either version 2 of the License, or (at your option)
11 * This program is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
16 * You should have received a copy of the GNU General Public License along
17 * with this program; see the file COPYING; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
31 #include "northbound.h"
37 /* The following options disable specific command line options that
38 * are not applicable for a particular daemon.
40 #define FRR_NO_PRIVSEP (1 << 0)
41 #define FRR_NO_TCPVTY (1 << 1)
42 #define FRR_LIMITED_CLI (1 << 2)
43 #define FRR_NO_SPLIT_CONFIG (1 << 3)
44 #define FRR_NO_PID (1 << 4)
45 #define FRR_NO_CFG_PID_DRY (FRR_NO_PID | FRR_NO_SPLIT_CONFIG)
46 #define FRR_NO_ZCLIENT (1 << 5)
47 /* If FRR_DETACH_LATER is used, the daemon will keep its parent running
48 * until frr_detach() is called. Normally "somedaemon -d" returns once the
49 * main event loop is reached in the daemon; use this for extra startup bits.
51 * Does nothing if -d isn't used.
53 #define FRR_DETACH_LATER (1 << 6)
57 FRR_CLI_TRANSACTIONAL
,
60 struct frr_daemon_info
{
66 unsigned short instance
;
67 struct frrmod_runtime
*module
;
75 enum frr_cli_mode cli_mode
;
77 struct thread
*read_in
;
78 const char *config_file
;
79 const char *backup_config_file
;
85 const char *module_path
;
86 const char *script_path
;
88 const char *pathspace
;
91 const char *early_logging
;
92 const char *early_loglevel
;
95 void (*printhelp
)(FILE *target
);
96 const char *copyright
;
99 struct frr_signal_t
*signals
;
102 struct zebra_privs_t
*privs
;
104 const struct frr_yang_module_info
*const *yang_modules
;
105 size_t n_yang_modules
;
109 /* Optional upper limit on the number of fds used in select/poll */
113 /* execname is the daemon's executable (and pidfile and configfile) name,
114 * i.e. "zebra" or "bgpd"
115 * constname is the daemons source-level name, primarily for the logging ID,
116 * i.e. "ZEBRA" or "BGP"
118 * note that this macro is also a latch-on point for other changes (e.g.
119 * upcoming module support) that need to place some per-daemon things. Each
120 * daemon should have one of these.
122 #define FRR_DAEMON_INFO(execname, constname, ...) \
123 static struct frr_daemon_info execname##_di = {.name = #execname, \
124 .logname = #constname, \
125 .module = THIS_MODULE, \
127 FRR_COREMOD_SETUP(.name = #execname, \
128 .description = #execname " daemon", \
129 .version = FRR_VERSION, ); \
130 MACRO_REQUIRE_SEMICOLON() /* end */
132 extern void frr_init_vtydir(void);
133 extern void frr_preinit(struct frr_daemon_info
*daemon
, int argc
, char **argv
);
134 extern void frr_opt_add(const char *optstr
, const struct option
*longopts
,
135 const char *helpstr
);
136 extern int frr_getopt(int argc
, char *const argv
[], int *longindex
);
138 extern __attribute__((__noreturn__
)) void frr_help_exit(int status
);
140 extern struct thread_master
*frr_init(void);
141 extern const char *frr_get_progname(void);
142 extern enum frr_cli_mode
frr_get_cli_mode(void);
143 extern uint32_t frr_get_fd_limit(void);
144 extern bool frr_is_startup_fd(int fd
);
146 /* call order of these hooks is as ordered here */
147 DECLARE_HOOK(frr_early_init
, (struct thread_master
* tm
), (tm
));
148 DECLARE_HOOK(frr_late_init
, (struct thread_master
* tm
), (tm
));
149 /* fork() happens between late_init and config_pre */
150 DECLARE_HOOK(frr_config_pre
, (struct thread_master
* tm
), (tm
));
151 DECLARE_HOOK(frr_config_post
, (struct thread_master
* tm
), (tm
));
153 extern void frr_config_fork(void);
155 extern void frr_run(struct thread_master
*master
);
156 extern void frr_detach(void);
158 extern bool frr_zclient_addr(struct sockaddr_storage
*sa
, socklen_t
*sa_len
,
161 /* these two are before the protocol daemon does its own shutdown
162 * it's named this way being the counterpart to frr_late_init */
163 DECLARE_KOOH(frr_early_fini
, (), ());
164 extern void frr_early_fini(void);
165 /* and these two are after the daemon did its own cleanup */
166 DECLARE_KOOH(frr_fini
, (), ());
167 extern void frr_fini(void);
169 extern char config_default
[512];
170 extern char frr_zclientpath
[256];
171 extern const char frr_sysconfdir
[];
172 extern char frr_vtydir
[256];
173 extern const char frr_moduledir
[];
174 extern const char frr_scriptdir
[];
176 extern char frr_protoname
[];
177 extern char frr_protonameinst
[];
178 /* always set in the spot where we *would* fork even if we don't do so */
179 extern bool frr_is_after_fork
;
181 extern bool debug_memstats_at_exit
;
187 #endif /* _ZEBRA_FRR_H */