]> git.proxmox.com Git - mirror_frr.git/blob - ripngd/ripng_main.c
bfdd: Modify bfdd to quietly accept access-lists
[mirror_frr.git] / ripngd / ripng_main.c
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
43 /* RIPngd options. */
44 #if CONFDATE > 20190521
45 CPP_NOTICE("-r / --retain has reached deprecation EOL, remove")
46 #endif
47 struct option longopts[] = {{"retain", no_argument, NULL, 'r'}, {0}};
48
49 /* ripngd privileges */
50 zebra_capabilities_t _caps_p[] = {ZCAP_NET_RAW, ZCAP_BIND, ZCAP_SYS_ADMIN};
51
52 struct zebra_privs_t ripngd_privs = {
53 #if defined(FRR_USER)
54 .user = FRR_USER,
55 #endif
56 #if defined FRR_GROUP
57 .group = FRR_GROUP,
58 #endif
59 #ifdef VTY_GROUP
60 .vty_group = VTY_GROUP,
61 #endif
62 .caps_p = _caps_p,
63 .cap_num_p = array_size(_caps_p),
64 .cap_num_i = 0};
65
66
67 /* Master of threads. */
68 struct thread_master *master;
69
70 static struct frr_daemon_info ripngd_di;
71
72 /* SIGHUP handler. */
73 static void sighup(void)
74 {
75 zlog_info("SIGHUP received");
76
77 /* Reload config file. */
78 vty_read_config(NULL, ripngd_di.config_file, config_default);
79 }
80
81 /* SIGINT handler. */
82 static void sigint(void)
83 {
84 zlog_notice("Terminating on signal");
85
86 ripng_vrf_terminate();
87 if_rmap_terminate();
88 ripng_zebra_stop();
89 frr_fini();
90 exit(0);
91 }
92
93 /* SIGUSR1 handler. */
94 static void sigusr1(void)
95 {
96 zlog_rotate();
97 }
98
99 struct quagga_signal_t ripng_signals[] = {
100 {
101 .signal = SIGHUP,
102 .handler = &sighup,
103 },
104 {
105 .signal = SIGUSR1,
106 .handler = &sigusr1,
107 },
108 {
109 .signal = SIGINT,
110 .handler = &sigint,
111 },
112 {
113 .signal = SIGTERM,
114 .handler = &sigint,
115 },
116 };
117
118 static const struct frr_yang_module_info *ripngd_yang_modules[] = {
119 &frr_interface_info,
120 &frr_ripngd_info,
121 };
122
123 FRR_DAEMON_INFO(ripngd, RIPNG, .vty_port = RIPNG_VTY_PORT,
124
125 .proghelp = "Implementation of the RIPng routing protocol.",
126
127 .signals = ripng_signals,
128 .n_signals = array_size(ripng_signals),
129
130 .privs = &ripngd_privs,
131
132 .yang_modules = ripngd_yang_modules,
133 .n_yang_modules = array_size(ripngd_yang_modules), )
134
135 #if CONFDATE > 20190521
136 CPP_NOTICE("-r / --retain has reached deprecation EOL, remove")
137 #endif
138 #define DEPRECATED_OPTIONS "r"
139
140 /* RIPngd main routine. */
141 int main(int argc, char **argv)
142 {
143 frr_preinit(&ripngd_di, argc, argv);
144
145 frr_opt_add("" DEPRECATED_OPTIONS, longopts, "");
146
147 while (1) {
148 int opt;
149
150 opt = frr_getopt(argc, argv, NULL);
151
152 if (opt && opt < 128 && strchr(DEPRECATED_OPTIONS, opt)) {
153 fprintf(stderr,
154 "The -%c option no longer exists.\nPlease refer to the manual.\n",
155 opt);
156 continue;
157 }
158
159 if (opt == EOF)
160 break;
161
162 switch (opt) {
163 case 0:
164 break;
165 default:
166 frr_help_exit(1);
167 break;
168 }
169 }
170
171 master = frr_init();
172
173 /* Library inits. */
174 ripng_vrf_init();
175
176 /* RIPngd inits. */
177 ripng_init();
178 ripng_cli_init();
179 zebra_init(master);
180
181 frr_config_fork();
182 frr_run(master);
183
184 /* Not reached. */
185 return 0;
186 }