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