]> git.proxmox.com Git - mirror_frr.git/blame - ripngd/ripng_main.c
ripd: add vrf input parameter to the "clear-rip-route" RPC
[mirror_frr.git] / ripngd / ripng_main.c
CommitLineData
718e3744 1/*
2 * RIPngd main routine.
3 * Copyright (C) 1998, 1999 Kunihiro Ishiguro
4 *
5 * This file is part of GNU Zebra.
6 *
7 * GNU Zebra is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the
9 * Free Software Foundation; either version 2, or (at your option) any
10 * later version.
11 *
12 * GNU Zebra is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
16 *
896014f4
DL
17 * You should have received a copy of the GNU General Public License along
18 * with this program; see the file COPYING; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
718e3744 20 */
21
22#include <zebra.h>
23
5e4fa164 24#include <lib/version.h>
718e3744 25#include "getopt.h"
26#include "vector.h"
27#include "vty.h"
28#include "command.h"
a94434b6 29#include "memory.h"
fc7948fa 30#include "memory_vty.h"
718e3744 31#include "thread.h"
32#include "log.h"
33#include "prefix.h"
34#include "if.h"
edd7c245 35#include "privs.h"
2d75d052 36#include "sigevent.h"
6a69b354 37#include "vrf.h"
4f04a76b 38#include "libfrr.h"
718e3744 39
40#include "ripngd/ripngd.h"
41
718e3744 42/* RIPngd options. */
c8dde10f
QY
43#if CONFDATE > 20190521
44 CPP_NOTICE("-r / --retain has reached deprecation EOL, remove")
45#endif
d62a17ae 46struct option longopts[] = {{"retain", no_argument, NULL, 'r'}, {0}};
718e3744 47
edd7c245 48/* ripngd privileges */
d62a17ae 49zebra_capabilities_t _caps_p[] = {ZCAP_NET_RAW, ZCAP_BIND};
edd7c245 50
d62a17ae 51struct zebra_privs_t ripngd_privs = {
b2f36157 52#if defined(FRR_USER)
d62a17ae 53 .user = FRR_USER,
edd7c245 54#endif
b2f36157 55#if defined FRR_GROUP
d62a17ae 56 .group = FRR_GROUP,
d81fadfd 57#endif
58#ifdef VTY_GROUP
d62a17ae 59 .vty_group = VTY_GROUP,
edd7c245 60#endif
d62a17ae 61 .caps_p = _caps_p,
62 .cap_num_p = 2,
63 .cap_num_i = 0};
edd7c245 64
65
718e3744 66/* Master of threads. */
67struct thread_master *master;
68
eb05883f 69static struct frr_daemon_info ripngd_di;
718e3744 70
718e3744 71/* SIGHUP handler. */
d62a17ae 72static void sighup(void)
718e3744 73{
d62a17ae 74 zlog_info("SIGHUP received");
a94434b6 75
d62a17ae 76 /* Reload config file. */
1c2facd1 77 vty_read_config(NULL, ripngd_di.config_file, config_default);
718e3744 78}
79
80/* SIGINT handler. */
d62a17ae 81static void sigint(void)
718e3744 82{
5c84b9a5
RW
83 struct vrf *vrf;
84
d62a17ae 85 zlog_notice("Terminating on signal");
718e3744 86
5c84b9a5
RW
87 RB_FOREACH (vrf, vrf_id_head, &vrfs_by_id) {
88 struct ripng *ripng;
89
90 ripng = vrf->info;
91 if (ripng)
92 ripng_clean(ripng);
93 }
718e3744 94
d62a17ae 95 ripng_zebra_stop();
8879bd22 96 frr_fini();
d62a17ae 97 exit(0);
718e3744 98}
99
100/* SIGUSR1 handler. */
d62a17ae 101static void sigusr1(void)
718e3744 102{
d62a17ae 103 zlog_rotate();
718e3744 104}
105
d62a17ae 106struct quagga_signal_t ripng_signals[] = {
107 {
108 .signal = SIGHUP,
109 .handler = &sighup,
110 },
111 {
112 .signal = SIGUSR1,
113 .handler = &sigusr1,
114 },
115 {
116 .signal = SIGINT,
117 .handler = &sigint,
118 },
119 {
120 .signal = SIGTERM,
121 .handler = &sigint,
122 },
2d75d052 123};
6b0655a2 124
8fcdd0d6 125static const struct frr_yang_module_info *ripngd_yang_modules[] = {
a4bed468 126 &frr_interface_info,
e9ce224b 127 &frr_ripngd_info,
8fcdd0d6
RW
128};
129
d62a17ae 130FRR_DAEMON_INFO(ripngd, RIPNG, .vty_port = RIPNG_VTY_PORT,
4f04a76b 131
d62a17ae 132 .proghelp = "Implementation of the RIPng routing protocol.",
4f04a76b 133
d62a17ae 134 .signals = ripng_signals,
135 .n_signals = array_size(ripng_signals),
4f04a76b 136
8fcdd0d6
RW
137 .privs = &ripngd_privs,
138
139 .yang_modules = ripngd_yang_modules,
140 .n_yang_modules = array_size(ripngd_yang_modules), )
4f04a76b 141
c8dde10f
QY
142#if CONFDATE > 20190521
143CPP_NOTICE("-r / --retain has reached deprecation EOL, remove")
144#endif
145#define DEPRECATED_OPTIONS "r"
146
718e3744 147/* RIPngd main routine. */
d62a17ae 148int main(int argc, char **argv)
718e3744 149{
d62a17ae 150 frr_preinit(&ripngd_di, argc, argv);
c8dde10f
QY
151
152 frr_opt_add("" DEPRECATED_OPTIONS, longopts, "");
d62a17ae 153
154 while (1) {
155 int opt;
156
157 opt = frr_getopt(argc, argv, NULL);
158
c8dde10f
QY
159 if (opt && opt < 128 && strchr(DEPRECATED_OPTIONS, opt)) {
160 fprintf(stderr,
161 "The -%c option no longer exists.\nPlease refer to the manual.\n",
162 opt);
163 continue;
164 }
165
d62a17ae 166 if (opt == EOF)
167 break;
168
169 switch (opt) {
170 case 0:
171 break;
d62a17ae 172 default:
173 frr_help_exit(1);
174 break;
175 }
718e3744 176 }
718e3744 177
d62a17ae 178 master = frr_init();
718e3744 179
d62a17ae 180 /* Library inits. */
ecbc5a37 181 vrf_init(NULL, NULL, NULL, NULL, NULL);
718e3744 182
d62a17ae 183 /* RIPngd inits. */
184 ripng_init();
e9ce224b 185 ripng_cli_init();
d62a17ae 186 zebra_init(master);
a94434b6 187
d62a17ae 188 frr_config_fork();
189 frr_run(master);
718e3744 190
d62a17ae 191 /* Not reached. */
192 return 0;
718e3744 193}