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