]> git.proxmox.com Git - mirror_frr.git/blob - isisd/isis_main.c
Merge pull request #5005 from Frankkkkk/dockerfile
[mirror_frr.git] / isisd / isis_main.c
1 /*
2 * IS-IS Rout(e)ing protocol - isis_main.c
3 *
4 * Copyright (C) 2001,2002 Sampo Saaristo
5 * Tampere University of Technology
6 * Institute of Communications Engineering
7 *
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public Licenseas published by the Free
10 * Software Foundation; either version 2 of the License, or (at your option)
11 * any later version.
12 *
13 * This program is distributed in the hope that it will be useful,but WITHOUT
14 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
16 * more details.
17 *
18 * You should have received a copy of the GNU General Public License along
19 * with this program; see the file COPYING; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21 */
22
23 #include <zebra.h>
24
25 #include "getopt.h"
26 #include "thread.h"
27 #include "log.h"
28 #include <lib/version.h>
29 #include "command.h"
30 #include "vty.h"
31 #include "memory.h"
32 #include "memory_vty.h"
33 #include "stream.h"
34 #include "if.h"
35 #include "privs.h"
36 #include "sigevent.h"
37 #include "filter.h"
38 #include "plist.h"
39 #include "zclient.h"
40 #include "vrf.h"
41 #include "qobj.h"
42 #include "libfrr.h"
43
44 #include "isisd/isis_constants.h"
45 #include "isisd/isis_common.h"
46 #include "isisd/isis_flags.h"
47 #include "isisd/isis_circuit.h"
48 #include "isisd/isisd.h"
49 #include "isisd/isis_dynhn.h"
50 #include "isisd/isis_spf.h"
51 #include "isisd/isis_route.h"
52 #include "isisd/isis_routemap.h"
53 #include "isisd/isis_zebra.h"
54 #include "isisd/isis_te.h"
55 #include "isisd/isis_errors.h"
56 #include "isisd/isis_bfd.h"
57 #include "isisd/isis_lsp.h"
58 #include "isisd/isis_mt.h"
59 #include "isisd/fabricd.h"
60
61 /* Default configuration file name */
62 #define ISISD_DEFAULT_CONFIG "isisd.conf"
63 /* Default vty port */
64 #define ISISD_VTY_PORT 2608
65 #define FABRICD_VTY_PORT 2618
66
67 /* isisd privileges */
68 zebra_capabilities_t _caps_p[] = {ZCAP_NET_RAW, ZCAP_BIND};
69
70 struct zebra_privs_t isisd_privs = {
71 #if defined(FRR_USER)
72 .user = FRR_USER,
73 #endif
74 #if defined FRR_GROUP
75 .group = FRR_GROUP,
76 #endif
77 #ifdef VTY_GROUP
78 .vty_group = VTY_GROUP,
79 #endif
80 .caps_p = _caps_p,
81 .cap_num_p = array_size(_caps_p),
82 .cap_num_i = 0};
83
84 /* isisd options */
85 struct option longopts[] = {{0}};
86
87 /* Master of threads. */
88 struct thread_master *master;
89
90 /*
91 * Prototypes.
92 */
93 void sighup(void);
94 void sigint(void);
95 void sigterm(void);
96 void sigusr1(void);
97
98
99 static __attribute__((__noreturn__)) void terminate(int i)
100 {
101 isis_zebra_stop();
102 exit(i);
103 }
104
105 /*
106 * Signal handlers
107 */
108 #ifdef FABRICD
109 void sighup(void)
110 {
111 zlog_notice("SIGHUP/reload is not implemented for fabricd");
112 return;
113 }
114 #else
115 static struct frr_daemon_info isisd_di;
116 void sighup(void)
117 {
118 zlog_info("SIGHUP received");
119
120 /* Reload config file. */
121 vty_read_config(NULL, isisd_di.config_file, config_default);
122 }
123
124 #endif
125
126 __attribute__((__noreturn__)) void sigint(void)
127 {
128 zlog_notice("Terminating on signal SIGINT");
129 terminate(0);
130 }
131
132 __attribute__((__noreturn__)) void sigterm(void)
133 {
134 zlog_notice("Terminating on signal SIGTERM");
135 terminate(0);
136 }
137
138 void sigusr1(void)
139 {
140 zlog_debug("SIGUSR1 received");
141 zlog_rotate();
142 }
143
144 struct quagga_signal_t isisd_signals[] = {
145 {
146 .signal = SIGHUP,
147 .handler = &sighup,
148 },
149 {
150 .signal = SIGUSR1,
151 .handler = &sigusr1,
152 },
153 {
154 .signal = SIGINT,
155 .handler = &sigint,
156 },
157 {
158 .signal = SIGTERM,
159 .handler = &sigterm,
160 },
161 };
162
163
164 static const struct frr_yang_module_info *isisd_yang_modules[] = {
165 &frr_interface_info,
166 #ifndef FABRICD
167 &frr_isisd_info,
168 #endif /* ifndef FABRICD */
169 };
170
171 #ifdef FABRICD
172 FRR_DAEMON_INFO(fabricd, OPEN_FABRIC, .vty_port = FABRICD_VTY_PORT,
173
174 .proghelp = "Implementation of the OpenFabric routing protocol.",
175 #else
176 FRR_DAEMON_INFO(isisd, ISIS, .vty_port = ISISD_VTY_PORT,
177
178 .proghelp = "Implementation of the IS-IS routing protocol.",
179 #endif
180 .copyright =
181 "Copyright (c) 2001-2002 Sampo Saaristo,"
182 " Ofer Wald and Hannes Gredler",
183
184 .signals = isisd_signals,
185 .n_signals = array_size(isisd_signals),
186
187 .privs = &isisd_privs, .yang_modules = isisd_yang_modules,
188 .n_yang_modules = array_size(isisd_yang_modules), )
189
190 /*
191 * Main routine of isisd. Parse arguments and handle IS-IS state machine.
192 */
193 int main(int argc, char **argv, char **envp)
194 {
195 int opt;
196
197 #ifdef FABRICD
198 frr_preinit(&fabricd_di, argc, argv);
199 #else
200 frr_preinit(&isisd_di, argc, argv);
201 #endif
202 frr_opt_add("", longopts, "");
203
204 /* Command line argument treatment. */
205 while (1) {
206 opt = frr_getopt(argc, argv, NULL);
207
208 if (opt == EOF)
209 break;
210
211 switch (opt) {
212 case 0:
213 break;
214 default:
215 frr_help_exit(1);
216 break;
217 }
218 }
219
220 /* thread master */
221 master = frr_init();
222
223 /*
224 * initializations
225 */
226 isis_error_init();
227 access_list_init();
228 vrf_init(NULL, NULL, NULL, NULL, NULL);
229 prefix_list_init();
230 isis_init();
231 isis_circuit_init();
232 #ifdef FABRICD
233 isis_vty_daemon_init();
234 #endif /* FABRICD */
235 #ifndef FABRICD
236 isis_cli_init();
237 #endif /* ifdef FABRICD */
238 isis_spf_cmds_init();
239 isis_redist_init();
240 isis_route_map_init();
241 isis_mpls_te_init();
242 lsp_init();
243 mt_init();
244
245 /* create the global 'isis' instance */
246 isis_new(1, VRF_DEFAULT);
247
248 isis_zebra_init(master);
249 isis_bfd_init();
250 fabricd_init();
251
252 frr_config_fork();
253 frr_run(master);
254
255 /* Not reached. */
256 exit(0);
257 }