]> git.proxmox.com Git - mirror_frr.git/blame - lib/libfrr.h
zebra, lib: fix the ZEBRA_INTERFACE_VRF_UPDATE zapi message
[mirror_frr.git] / lib / libfrr.h
CommitLineData
4f04a76b
DL
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 *
896014f4
DL
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
4f04a76b
DL
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"
30771d65 29#include "module.h"
a5b38c5b 30#include "hook.h"
1c2facd1 31#include "northbound.h"
4f04a76b 32
0a7c7856
DL
33/* The following options disable specific command line options that
34 * are not applicable for a particular daemon.
35 */
4f04a76b
DL
36#define FRR_NO_PRIVSEP (1 << 0)
37#define FRR_NO_TCPVTY (1 << 1)
857b5446 38#define FRR_LIMITED_CLI (1 << 2)
0a7c7856 39#define FRR_NO_CFG_PID_DRY (1 << 3)
eb05883f 40#define FRR_NO_ZCLIENT (1 << 4)
0a7c7856
DL
41/* If FRR_DETACH_LATER is used, the daemon will keep its parent running
42 * until frr_detach() is called. Normally "somedaemon -d" returns once the
43 * main event loop is reached in the daemon; use this for extra startup bits.
44 *
45 * Does nothing if -d isn't used.
46 */
47#define FRR_DETACH_LATER (1 << 5)
4f04a76b 48
1c2facd1
RW
49enum frr_cli_mode {
50 FRR_CLI_CLASSIC = 0,
51 FRR_CLI_TRANSACTIONAL,
52};
53
4f04a76b
DL
54struct frr_daemon_info {
55 unsigned flags;
56
57 const char *progname;
eb05883f 58 const char *name;
bf1013e6 59 const char *logname;
4f04a76b 60 unsigned short instance;
30771d65 61 struct frrmod_runtime *module;
4f04a76b
DL
62
63 char *vty_addr;
64 int vty_port;
65 char *vty_sock_path;
eb05883f
DL
66 bool dryrun;
67 bool daemon_mode;
cff2b211 68 bool terminal;
1c2facd1 69 enum frr_cli_mode cli_mode;
9e224e60
DS
70
71 struct thread *read_in;
eb05883f 72 const char *config_file;
573de11f 73 const char *backup_config_file;
eb05883f 74 const char *pid_file;
1c2facd1
RW
75#ifdef HAVE_SQLITE3
76 const char *db_file;
77#endif
eb05883f 78 const char *vty_path;
80b4df3b 79 const char *module_path;
d1b4fc1f 80 const char *pathspace;
f8507817 81 const char *early_logging;
e9b4e74a 82 const char *early_loglevel;
4f04a76b
DL
83
84 const char *proghelp;
85 void (*printhelp)(FILE *target);
86 const char *copyright;
16077f2f 87 char startinfo[128];
4f04a76b
DL
88
89 struct quagga_signal_t *signals;
90 size_t n_signals;
91
92 struct zebra_privs_t *privs;
1c2facd1
RW
93
94 const struct frr_yang_module_info **yang_modules;
95 size_t n_yang_modules;
4f04a76b
DL
96};
97
98/* execname is the daemon's executable (and pidfile and configfile) name,
99 * i.e. "zebra" or "bgpd"
100 * constname is the daemons source-level name, primarily for the logging ID,
101 * i.e. "ZEBRA" or "BGP"
102 *
103 * note that this macro is also a latch-on point for other changes (e.g.
30771d65 104 * upcoming module support) that need to place some per-daemon things. Each
4f04a76b
DL
105 * daemon should have one of these.
106 */
d62a17ae 107#define FRR_DAEMON_INFO(execname, constname, ...) \
108 static struct frr_daemon_info execname##_di = {.name = #execname, \
109 .logname = #constname, \
110 .module = THIS_MODULE, \
111 __VA_ARGS__}; \
112 FRR_COREMOD_SETUP(.name = #execname, \
113 .description = #execname " daemon", \
114 .version = FRR_VERSION, ) \
115/* end */
116
117extern void frr_preinit(struct frr_daemon_info *daemon, int argc, char **argv);
118extern void frr_opt_add(const char *optstr, const struct option *longopts,
119 const char *helpstr);
120extern int frr_getopt(int argc, char *const argv[], int *longindex);
4f04a76b
DL
121extern void frr_help_exit(int status);
122
123extern struct thread_master *frr_init(void);
1c2facd1
RW
124extern const char *frr_get_progname(void);
125extern enum frr_cli_mode frr_get_cli_mode(void);
4f04a76b 126
d62a17ae 127DECLARE_HOOK(frr_late_init, (struct thread_master * tm), (tm))
eb05883f
DL
128extern void frr_config_fork(void);
129
16077f2f 130extern void frr_run(struct thread_master *master);
0a7c7856 131extern void frr_detach(void);
16077f2f 132
689f5a8c
DL
133extern bool frr_zclient_addr(struct sockaddr_storage *sa, socklen_t *sa_len,
134 const char *path);
135
03951374
DL
136/* these two are before the protocol daemon does its own shutdown
137 * it's named this way being the counterpart to frr_late_init */
138DECLARE_KOOH(frr_early_fini, (), ())
139extern void frr_early_fini(void);
140/* and these two are after the daemon did its own cleanup */
141DECLARE_KOOH(frr_fini, (), ())
142extern void frr_fini(void);
143
ff44f570 144extern char config_default[512];
689f5a8c 145extern char frr_zclientpath[256];
eb05883f
DL
146extern const char frr_sysconfdir[];
147extern const char frr_vtydir[];
80b4df3b 148extern const char frr_moduledir[];
4f04a76b 149
b85120bc
DL
150extern char frr_protoname[];
151extern char frr_protonameinst[];
152
9eed278b
DL
153extern bool debug_memstats_at_exit;
154
4f04a76b 155#endif /* _ZEBRA_FRR_H */