]> git.proxmox.com Git - mirror_frr.git/blame - ripngd/ripng_main.c
Merge pull request #7540 from ton31337/fix/typo
[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"
718e3744 30#include "thread.h"
31#include "log.h"
32#include "prefix.h"
33#include "if.h"
edd7c245 34#include "privs.h"
2d75d052 35#include "sigevent.h"
6a69b354 36#include "vrf.h"
8f88441d 37#include "if_rmap.h"
4f04a76b 38#include "libfrr.h"
91835f1f 39#include "routemap.h"
718e3744 40
41#include "ripngd/ripngd.h"
ca473936 42#include "ripngd/ripng_nb.h"
718e3744 43
718e3744 44/* RIPngd options. */
f28963f7 45struct option longopts[] = {{0}};
718e3744 46
edd7c245 47/* ripngd privileges */
dde7b15b 48zebra_capabilities_t _caps_p[] = {ZCAP_NET_RAW, ZCAP_BIND, ZCAP_SYS_ADMIN};
edd7c245 49
d62a17ae 50struct zebra_privs_t ripngd_privs = {
b2f36157 51#if defined(FRR_USER)
d62a17ae 52 .user = FRR_USER,
edd7c245 53#endif
b2f36157 54#if defined FRR_GROUP
d62a17ae 55 .group = FRR_GROUP,
d81fadfd 56#endif
57#ifdef VTY_GROUP
d62a17ae 58 .vty_group = VTY_GROUP,
edd7c245 59#endif
d62a17ae 60 .caps_p = _caps_p,
dde7b15b 61 .cap_num_p = array_size(_caps_p),
d62a17ae 62 .cap_num_i = 0};
edd7c245 63
64
718e3744 65/* Master of threads. */
66struct thread_master *master;
67
eb05883f 68static struct frr_daemon_info ripngd_di;
718e3744 69
718e3744 70/* SIGHUP handler. */
d62a17ae 71static void sighup(void)
718e3744 72{
d62a17ae 73 zlog_info("SIGHUP received");
a94434b6 74
d62a17ae 75 /* Reload config file. */
1c2facd1 76 vty_read_config(NULL, ripngd_di.config_file, config_default);
718e3744 77}
78
79/* SIGINT handler. */
d62a17ae 80static void sigint(void)
718e3744 81{
d62a17ae 82 zlog_notice("Terminating on signal");
718e3744 83
dde7b15b 84 ripng_vrf_terminate();
8f88441d 85 if_rmap_terminate();
d62a17ae 86 ripng_zebra_stop();
8879bd22 87 frr_fini();
d62a17ae 88 exit(0);
718e3744 89}
90
91/* SIGUSR1 handler. */
d62a17ae 92static void sigusr1(void)
718e3744 93{
d62a17ae 94 zlog_rotate();
718e3744 95}
96
d62a17ae 97struct quagga_signal_t ripng_signals[] = {
98 {
99 .signal = SIGHUP,
100 .handler = &sighup,
101 },
102 {
103 .signal = SIGUSR1,
104 .handler = &sigusr1,
105 },
106 {
107 .signal = SIGINT,
108 .handler = &sigint,
109 },
110 {
111 .signal = SIGTERM,
112 .handler = &sigint,
113 },
2d75d052 114};
6b0655a2 115
0d8c7a26 116static const struct frr_yang_module_info *const ripngd_yang_modules[] = {
c2aab693 117 &frr_filter_info,
a4bed468 118 &frr_interface_info,
e9ce224b 119 &frr_ripngd_info,
91835f1f 120 &frr_route_map_info,
6fd8972a 121 &frr_vrf_info,
8fcdd0d6
RW
122};
123
d62a17ae 124FRR_DAEMON_INFO(ripngd, RIPNG, .vty_port = RIPNG_VTY_PORT,
4f04a76b 125
d62a17ae 126 .proghelp = "Implementation of the RIPng routing protocol.",
4f04a76b 127
d62a17ae 128 .signals = ripng_signals,
129 .n_signals = array_size(ripng_signals),
4f04a76b 130
8fcdd0d6
RW
131 .privs = &ripngd_privs,
132
133 .yang_modules = ripngd_yang_modules,
134 .n_yang_modules = array_size(ripngd_yang_modules), )
4f04a76b 135
f28963f7 136#define DEPRECATED_OPTIONS ""
c8dde10f 137
718e3744 138/* RIPngd main routine. */
d62a17ae 139int main(int argc, char **argv)
718e3744 140{
d62a17ae 141 frr_preinit(&ripngd_di, argc, argv);
c8dde10f
QY
142
143 frr_opt_add("" DEPRECATED_OPTIONS, longopts, "");
d62a17ae 144
145 while (1) {
146 int opt;
147
148 opt = frr_getopt(argc, argv, NULL);
149
c8dde10f
QY
150 if (opt && opt < 128 && strchr(DEPRECATED_OPTIONS, opt)) {
151 fprintf(stderr,
152 "The -%c option no longer exists.\nPlease refer to the manual.\n",
153 opt);
154 continue;
155 }
156
d62a17ae 157 if (opt == EOF)
158 break;
159
160 switch (opt) {
161 case 0:
162 break;
d62a17ae 163 default:
164 frr_help_exit(1);
165 break;
166 }
718e3744 167 }
718e3744 168
d62a17ae 169 master = frr_init();
718e3744 170
d62a17ae 171 /* Library inits. */
dde7b15b 172 ripng_vrf_init();
718e3744 173
d62a17ae 174 /* RIPngd inits. */
175 ripng_init();
e9ce224b 176 ripng_cli_init();
d62a17ae 177 zebra_init(master);
a94434b6 178
d62a17ae 179 frr_config_fork();
180 frr_run(master);
718e3744 181
d62a17ae 182 /* Not reached. */
183 return 0;
718e3744 184}