]> git.proxmox.com Git - mirror_frr.git/blob - lib/libfrr.h
Merge pull request #2534 from pacovn/Coverity_1470113_Untrusted_array_index_write
[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 #define FRR_NO_PRIVSEP (1 << 0)
33 #define FRR_NO_TCPVTY (1 << 1)
34 #define FRR_LIMITED_CLI (1 << 2)
35 #define FRR_NO_CFG_PID_DRY (1 << 3)
36 #define FRR_NO_ZCLIENT (1 << 4)
37
38 struct frr_daemon_info {
39 unsigned flags;
40
41 const char *progname;
42 const char *name;
43 const char *logname;
44 unsigned short instance;
45 struct frrmod_runtime *module;
46
47 char *vty_addr;
48 int vty_port;
49 char *vty_sock_path;
50 bool dryrun;
51 bool daemon_mode;
52 bool terminal;
53
54 struct thread *read_in;
55 const char *config_file;
56 const char *backup_config_file;
57 const char *pid_file;
58 const char *vty_path;
59 const char *module_path;
60 const char *pathspace;
61 const char *early_logging;
62 const char *early_loglevel;
63
64 const char *proghelp;
65 void (*printhelp)(FILE *target);
66 const char *copyright;
67 char startinfo[128];
68
69 struct quagga_signal_t *signals;
70 size_t n_signals;
71
72 struct zebra_privs_t *privs;
73 };
74
75 /* execname is the daemon's executable (and pidfile and configfile) name,
76 * i.e. "zebra" or "bgpd"
77 * constname is the daemons source-level name, primarily for the logging ID,
78 * i.e. "ZEBRA" or "BGP"
79 *
80 * note that this macro is also a latch-on point for other changes (e.g.
81 * upcoming module support) that need to place some per-daemon things. Each
82 * daemon should have one of these.
83 */
84 #define FRR_DAEMON_INFO(execname, constname, ...) \
85 static struct frr_daemon_info execname##_di = {.name = #execname, \
86 .logname = #constname, \
87 .module = THIS_MODULE, \
88 __VA_ARGS__}; \
89 FRR_COREMOD_SETUP(.name = #execname, \
90 .description = #execname " daemon", \
91 .version = FRR_VERSION, ) \
92 /* end */
93
94 extern void frr_preinit(struct frr_daemon_info *daemon, int argc, char **argv);
95 extern void frr_opt_add(const char *optstr, const struct option *longopts,
96 const char *helpstr);
97 extern int frr_getopt(int argc, char *const argv[], int *longindex);
98 extern void frr_help_exit(int status);
99
100 extern struct thread_master *frr_init(void);
101
102 DECLARE_HOOK(frr_late_init, (struct thread_master * tm), (tm))
103 extern void frr_config_fork(void);
104
105 extern void frr_vty_serv(void);
106
107 /* note: contains call to frr_vty_serv() */
108 extern void frr_run(struct thread_master *master);
109
110 extern bool frr_zclient_addr(struct sockaddr_storage *sa, socklen_t *sa_len,
111 const char *path);
112
113 /* these two are before the protocol daemon does its own shutdown
114 * it's named this way being the counterpart to frr_late_init */
115 DECLARE_KOOH(frr_early_fini, (), ())
116 extern void frr_early_fini(void);
117 /* and these two are after the daemon did its own cleanup */
118 DECLARE_KOOH(frr_fini, (), ())
119 extern void frr_fini(void);
120
121 extern char config_default[512];
122 extern char frr_zclientpath[256];
123 extern const char frr_sysconfdir[];
124 extern const char frr_vtydir[];
125 extern const char frr_moduledir[];
126
127 extern char frr_protoname[];
128 extern char frr_protonameinst[];
129
130 extern bool debug_memstats_at_exit;
131
132 #endif /* _ZEBRA_FRR_H */