]> git.proxmox.com Git - mirror_frr.git/blob - ripngd/ripng_main.c
Merge pull request #2279 from donaldsharp/evpn_moo_moo
[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(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 FRR_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 #if CONFDATE > 20190521
131 CPP_NOTICE("-r / --retain has reached deprecation EOL, remove")
132 #endif
133 #define DEPRECATED_OPTIONS "r"
134
135 /* RIPngd main routine. */
136 int 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 vrf_init(NULL, NULL, NULL, NULL);
170
171 /* RIPngd inits. */
172 ripng_init();
173 zebra_init(master);
174 ripng_peer_init();
175
176 frr_config_fork();
177 frr_run(master);
178
179 /* Not reached. */
180 return 0;
181 }