]> git.proxmox.com Git - mirror_frr.git/blob - lib/libfrr.h
Merge pull request #3119 from pacovn/Coverity_1465497_dead_code
[mirror_frr.git] / lib / libfrr.h
1 /*
2 * libfrr overall management functions
3 *
4 * Copyright (C) 2016 David Lamparter for NetDEF, Inc.
5 *
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)
9 * any later version.
10 *
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
14 * more details.
15 *
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
19 */
20
21 #ifndef _ZEBRA_FRR_H
22 #define _ZEBRA_FRR_H
23
24 #include "sigevent.h"
25 #include "privs.h"
26 #include "thread.h"
27 #include "log.h"
28 #include "getopt.h"
29 #include "module.h"
30 #include "hook.h"
31
32 /* The following options disable specific command line options that
33 * are not applicable for a particular daemon.
34 */
35 #define FRR_NO_PRIVSEP (1 << 0)
36 #define FRR_NO_TCPVTY (1 << 1)
37 #define FRR_LIMITED_CLI (1 << 2)
38 #define FRR_NO_CFG_PID_DRY (1 << 3)
39 #define FRR_NO_ZCLIENT (1 << 4)
40 /* If FRR_DETACH_LATER is used, the daemon will keep its parent running
41 * until frr_detach() is called. Normally "somedaemon -d" returns once the
42 * main event loop is reached in the daemon; use this for extra startup bits.
43 *
44 * Does nothing if -d isn't used.
45 */
46 #define FRR_DETACH_LATER (1 << 5)
47
48 struct frr_daemon_info {
49 unsigned flags;
50
51 const char *progname;
52 const char *name;
53 const char *logname;
54 unsigned short instance;
55 struct frrmod_runtime *module;
56
57 char *vty_addr;
58 int vty_port;
59 char *vty_sock_path;
60 bool dryrun;
61 bool daemon_mode;
62 bool terminal;
63
64 struct thread *read_in;
65 const char *config_file;
66 const char *backup_config_file;
67 const char *pid_file;
68 const char *vty_path;
69 const char *module_path;
70 const char *pathspace;
71 const char *early_logging;
72 const char *early_loglevel;
73
74 const char *proghelp;
75 void (*printhelp)(FILE *target);
76 const char *copyright;
77 char startinfo[128];
78
79 struct quagga_signal_t *signals;
80 size_t n_signals;
81
82 struct zebra_privs_t *privs;
83 };
84
85 /* execname is the daemon's executable (and pidfile and configfile) name,
86 * i.e. "zebra" or "bgpd"
87 * constname is the daemons source-level name, primarily for the logging ID,
88 * i.e. "ZEBRA" or "BGP"
89 *
90 * note that this macro is also a latch-on point for other changes (e.g.
91 * upcoming module support) that need to place some per-daemon things. Each
92 * daemon should have one of these.
93 */
94 #define FRR_DAEMON_INFO(execname, constname, ...) \
95 static struct frr_daemon_info execname##_di = {.name = #execname, \
96 .logname = #constname, \
97 .module = THIS_MODULE, \
98 __VA_ARGS__}; \
99 FRR_COREMOD_SETUP(.name = #execname, \
100 .description = #execname " daemon", \
101 .version = FRR_VERSION, ) \
102 /* end */
103
104 extern void frr_preinit(struct frr_daemon_info *daemon, int argc, char **argv);
105 extern void frr_opt_add(const char *optstr, const struct option *longopts,
106 const char *helpstr);
107 extern int frr_getopt(int argc, char *const argv[], int *longindex);
108 extern void frr_help_exit(int status);
109
110 extern struct thread_master *frr_init(void);
111
112 DECLARE_HOOK(frr_late_init, (struct thread_master * tm), (tm))
113 extern void frr_config_fork(void);
114
115 extern void frr_run(struct thread_master *master);
116 extern void frr_detach(void);
117
118 extern bool frr_zclient_addr(struct sockaddr_storage *sa, socklen_t *sa_len,
119 const char *path);
120
121 /* these two are before the protocol daemon does its own shutdown
122 * it's named this way being the counterpart to frr_late_init */
123 DECLARE_KOOH(frr_early_fini, (), ())
124 extern void frr_early_fini(void);
125 /* and these two are after the daemon did its own cleanup */
126 DECLARE_KOOH(frr_fini, (), ())
127 extern void frr_fini(void);
128
129 extern char config_default[512];
130 extern char frr_zclientpath[256];
131 extern const char frr_sysconfdir[];
132 extern const char frr_vtydir[];
133 extern const char frr_moduledir[];
134
135 extern char frr_protoname[];
136 extern char frr_protonameinst[];
137
138 extern bool debug_memstats_at_exit;
139
140 #endif /* _ZEBRA_FRR_H */