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