]> git.proxmox.com Git - mirror_frr.git/blame_incremental - ripngd/ripng_main.c
*: make all route_map_rule_cmd const
[mirror_frr.git] / ripngd / ripng_main.c
... / ...
CommitLineData
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 *
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
20 */
21
22#include <zebra.h>
23
24#include <lib/version.h>
25#include "getopt.h"
26#include "vector.h"
27#include "vty.h"
28#include "command.h"
29#include "memory.h"
30#include "memory_vty.h"
31#include "thread.h"
32#include "log.h"
33#include "prefix.h"
34#include "if.h"
35#include "privs.h"
36#include "sigevent.h"
37#include "vrf.h"
38#include "if_rmap.h"
39#include "libfrr.h"
40
41#include "ripngd/ripngd.h"
42#include "ripngd/ripng_nb.h"
43
44/* RIPngd options. */
45struct option longopts[] = {{0}};
46
47/* ripngd privileges */
48zebra_capabilities_t _caps_p[] = {ZCAP_NET_RAW, ZCAP_BIND, ZCAP_SYS_ADMIN};
49
50struct zebra_privs_t ripngd_privs = {
51#if defined(FRR_USER)
52 .user = FRR_USER,
53#endif
54#if defined FRR_GROUP
55 .group = FRR_GROUP,
56#endif
57#ifdef VTY_GROUP
58 .vty_group = VTY_GROUP,
59#endif
60 .caps_p = _caps_p,
61 .cap_num_p = array_size(_caps_p),
62 .cap_num_i = 0};
63
64
65/* Master of threads. */
66struct thread_master *master;
67
68static struct frr_daemon_info ripngd_di;
69
70/* SIGHUP handler. */
71static void sighup(void)
72{
73 zlog_info("SIGHUP received");
74
75 /* Reload config file. */
76 vty_read_config(NULL, ripngd_di.config_file, config_default);
77}
78
79/* SIGINT handler. */
80static void sigint(void)
81{
82 zlog_notice("Terminating on signal");
83
84 ripng_vrf_terminate();
85 if_rmap_terminate();
86 ripng_zebra_stop();
87 frr_fini();
88 exit(0);
89}
90
91/* SIGUSR1 handler. */
92static void sigusr1(void)
93{
94 zlog_rotate();
95}
96
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 },
114};
115
116static const struct frr_yang_module_info *ripngd_yang_modules[] = {
117 &frr_interface_info,
118 &frr_ripngd_info,
119};
120
121FRR_DAEMON_INFO(ripngd, RIPNG, .vty_port = RIPNG_VTY_PORT,
122
123 .proghelp = "Implementation of the RIPng routing protocol.",
124
125 .signals = ripng_signals,
126 .n_signals = array_size(ripng_signals),
127
128 .privs = &ripngd_privs,
129
130 .yang_modules = ripngd_yang_modules,
131 .n_yang_modules = array_size(ripngd_yang_modules), )
132
133#define DEPRECATED_OPTIONS ""
134
135/* RIPngd main routine. */
136int main(int argc, char **argv)
137{
138 frr_preinit(&ripngd_di, argc, argv);
139
140 frr_opt_add("" DEPRECATED_OPTIONS, longopts, "");
141
142 while (1) {
143 int opt;
144
145 opt = frr_getopt(argc, argv, NULL);
146
147 if (opt && opt < 128 && strchr(DEPRECATED_OPTIONS, opt)) {
148 fprintf(stderr,
149 "The -%c option no longer exists.\nPlease refer to the manual.\n",
150 opt);
151 continue;
152 }
153
154 if (opt == EOF)
155 break;
156
157 switch (opt) {
158 case 0:
159 break;
160 default:
161 frr_help_exit(1);
162 break;
163 }
164 }
165
166 master = frr_init();
167
168 /* Library inits. */
169 ripng_vrf_init();
170
171 /* RIPngd inits. */
172 ripng_init();
173 ripng_cli_init();
174 zebra_init(master);
175
176 frr_config_fork();
177 frr_run(master);
178
179 /* Not reached. */
180 return 0;
181}