]> git.proxmox.com Git - mirror_frr.git/blame - vrrpd/vrrp_main.c
vrrpd: add .gitignore
[mirror_frr.git] / vrrpd / vrrp_main.c
CommitLineData
5435a2bf
QY
1/*
2 * VRRP
3 * Copyright (C) 2018 Cumulus Networks, Inc.
4 * Quentin Young
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#include <zebra.h>
21
22#include <lib/version.h>
23#include "getopt.h"
24#include "thread.h"
25#include "command.h"
26#include "log.h"
27#include "memory.h"
28#include "privs.h"
29#include "sigevent.h"
30#include "libfrr.h"
31#include "vrf.h"
32#include "nexthop.h"
33#include "filter.h"
34
35#include "vrrp.h"
36#include "vrrp_zebra.h"
37#include "vrrp_vty.h"
38
39char backup_config_file[256];
40
41zebra_capabilities_t _caps_p[] = {
42};
43
44struct zebra_privs_t vrrp_privs = {
45#if defined(FRR_USER) && defined(FRR_GROUP)
46 .user = FRR_USER,
47 .group = FRR_GROUP,
48#endif
49#if defined(VTY_GROUP)
50 .vty_group = VTY_GROUP,
51#endif
52 .caps_p = _caps_p,
53 .cap_num_p = array_size(_caps_p),
54 .cap_num_i = 0};
55
56struct option longopts[] = { { 0 } };
57
58/* Master of threads. */
59struct thread_master *master;
60
61/* SIGHUP handler. */
62static void sighup(void)
63{
64 zlog_info("SIGHUP received");
65}
66
67/* SIGINT / SIGTERM handler. */
68static void sigint(void)
69{
70 zlog_notice("Terminating on signal");
71
72 exit(0);
73}
74
75/* SIGUSR1 handler. */
76static void sigusr1(void)
77{
78 zlog_rotate();
79}
80
81struct quagga_signal_t vrrp_signals[] = {
82 {
83 .signal = SIGHUP,
84 .handler = &sighup,
85 },
86 {
87 .signal = SIGUSR1,
88 .handler = &sigusr1,
89 },
90 {
91 .signal = SIGINT,
92 .handler = &sigint,
93 },
94 {
95 .signal = SIGTERM,
96 .handler = &sigint,
97 },
98};
99
100static const struct frr_yang_module_info *vrrp_yang_modules[] = {
101};
102
103#define VRRP_VTY_PORT 2617
104
105FRR_DAEMON_INFO(vrrpd, VRRP, .vty_port = VRRP_VTY_PORT,
106 .proghelp = "Virtual Router Redundancy Protocol",
107 .signals = vrrp_signals,
108 .n_signals = array_size(vrrp_signals),
109 .privs = &vrrp_privs,
110 .yang_modules = vrrp_yang_modules,
111 .n_yang_modules = array_size(vrrp_yang_modules),
112)
113
114int main(int argc, char **argv, char **envp)
115{
116 frr_preinit(&vrrpd_di, argc, argv);
117 frr_opt_add("", longopts, "");
118
119 while (1) {
120 int opt;
121
122 opt = frr_getopt(argc, argv, NULL);
123
124 if (opt == EOF)
125 break;
126
127 switch (opt) {
128 case 0:
129 break;
130 default:
131 frr_help_exit(1);
132 break;
133 }
134 }
135
136 master = frr_init();
137
138 vrrp_zebra_init();
139 vrrp_vty_init();
140 vrrp_init();
141
142 snprintf(backup_config_file, sizeof(backup_config_file),
143 "%s/vrrpd.conf", frr_sysconfdir);
144 vrrpd_di.backup_config_file = backup_config_file;
145
146 frr_config_fork();
147 frr_run(master);
148
149 /* Not reached. */
150 return 0;
151}