]> git.proxmox.com Git - mirror_frr.git/blob - ripngd/ripng_main.c
Merge pull request #3239 from pguibert6WIND/ospf_virtual_link_config
[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 ripng_clean();
76 ripng_reset();
77
78 /* Reload config file. */
79 vty_read_config(NULL, ripngd_di.config_file, config_default);
80
81 /* Try to return to normal operation. */
82 }
83
84 /* SIGINT handler. */
85 static void sigint(void)
86 {
87 zlog_notice("Terminating on signal");
88
89 ripng_clean();
90
91 ripng_zebra_stop();
92 frr_fini();
93 exit(0);
94 }
95
96 /* SIGUSR1 handler. */
97 static void sigusr1(void)
98 {
99 zlog_rotate();
100 }
101
102 struct quagga_signal_t ripng_signals[] = {
103 {
104 .signal = SIGHUP,
105 .handler = &sighup,
106 },
107 {
108 .signal = SIGUSR1,
109 .handler = &sigusr1,
110 },
111 {
112 .signal = SIGINT,
113 .handler = &sigint,
114 },
115 {
116 .signal = SIGTERM,
117 .handler = &sigint,
118 },
119 };
120
121 static const struct frr_yang_module_info *ripngd_yang_modules[] = {
122 &frr_interface_info,
123 };
124
125 FRR_DAEMON_INFO(ripngd, RIPNG, .vty_port = RIPNG_VTY_PORT,
126
127 .proghelp = "Implementation of the RIPng routing protocol.",
128
129 .signals = ripng_signals,
130 .n_signals = array_size(ripng_signals),
131
132 .privs = &ripngd_privs,
133
134 .yang_modules = ripngd_yang_modules,
135 .n_yang_modules = array_size(ripngd_yang_modules), )
136
137 #if CONFDATE > 20190521
138 CPP_NOTICE("-r / --retain has reached deprecation EOL, remove")
139 #endif
140 #define DEPRECATED_OPTIONS "r"
141
142 /* RIPngd main routine. */
143 int main(int argc, char **argv)
144 {
145 frr_preinit(&ripngd_di, argc, argv);
146
147 frr_opt_add("" DEPRECATED_OPTIONS, longopts, "");
148
149 while (1) {
150 int opt;
151
152 opt = frr_getopt(argc, argv, NULL);
153
154 if (opt && opt < 128 && strchr(DEPRECATED_OPTIONS, opt)) {
155 fprintf(stderr,
156 "The -%c option no longer exists.\nPlease refer to the manual.\n",
157 opt);
158 continue;
159 }
160
161 if (opt == EOF)
162 break;
163
164 switch (opt) {
165 case 0:
166 break;
167 default:
168 frr_help_exit(1);
169 break;
170 }
171 }
172
173 master = frr_init();
174
175 /* Library inits. */
176 vrf_init(NULL, NULL, NULL, NULL, NULL);
177
178 /* RIPngd inits. */
179 ripng_init();
180 zebra_init(master);
181 ripng_peer_init();
182
183 frr_config_fork();
184 frr_run(master);
185
186 /* Not reached. */
187 return 0;
188 }