]> git.proxmox.com Git - mirror_frr.git/blob - isisd/isis_main.c
*: fix route map integration
[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 "stream.h"
33 #include "if.h"
34 #include "privs.h"
35 #include "sigevent.h"
36 #include "filter.h"
37 #include "plist.h"
38 #include "zclient.h"
39 #include "vrf.h"
40 #include "qobj.h"
41 #include "libfrr.h"
42 #include "routemap.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 #include "isisd/isis_nb.h"
61
62 /* Default configuration file name */
63 #define ISISD_DEFAULT_CONFIG "isisd.conf"
64 /* Default vty port */
65 #define ISISD_VTY_PORT 2608
66 #define FABRICD_VTY_PORT 2618
67
68 /* isisd privileges */
69 zebra_capabilities_t _caps_p[] = {ZCAP_NET_RAW, ZCAP_BIND};
70
71 struct zebra_privs_t isisd_privs = {
72 #if defined(FRR_USER)
73 .user = FRR_USER,
74 #endif
75 #if defined FRR_GROUP
76 .group = FRR_GROUP,
77 #endif
78 #ifdef VTY_GROUP
79 .vty_group = VTY_GROUP,
80 #endif
81 .caps_p = _caps_p,
82 .cap_num_p = array_size(_caps_p),
83 .cap_num_i = 0};
84
85 /* isisd options */
86 struct option longopts[] = {{0}};
87
88 /* Master of threads. */
89 struct thread_master *master;
90
91 /*
92 * Prototypes.
93 */
94 void sighup(void);
95 void sigint(void);
96 void sigterm(void);
97 void sigusr1(void);
98
99
100 static __attribute__((__noreturn__)) void terminate(int i)
101 {
102 isis_zebra_stop();
103 exit(i);
104 }
105
106 /*
107 * Signal handlers
108 */
109 #ifdef FABRICD
110 void sighup(void)
111 {
112 zlog_notice("SIGHUP/reload is not implemented for fabricd");
113 return;
114 }
115 #else
116 static struct frr_daemon_info isisd_di;
117 void sighup(void)
118 {
119 zlog_info("SIGHUP received");
120
121 /* Reload config file. */
122 vty_read_config(NULL, isisd_di.config_file, config_default);
123 }
124
125 #endif
126
127 __attribute__((__noreturn__)) void sigint(void)
128 {
129 zlog_notice("Terminating on signal SIGINT");
130 terminate(0);
131 }
132
133 __attribute__((__noreturn__)) void sigterm(void)
134 {
135 zlog_notice("Terminating on signal SIGTERM");
136 terminate(0);
137 }
138
139 void sigusr1(void)
140 {
141 zlog_debug("SIGUSR1 received");
142 zlog_rotate();
143 }
144
145 struct quagga_signal_t isisd_signals[] = {
146 {
147 .signal = SIGHUP,
148 .handler = &sighup,
149 },
150 {
151 .signal = SIGUSR1,
152 .handler = &sigusr1,
153 },
154 {
155 .signal = SIGINT,
156 .handler = &sigint,
157 },
158 {
159 .signal = SIGTERM,
160 .handler = &sigterm,
161 },
162 };
163
164
165 static const struct frr_yang_module_info *const isisd_yang_modules[] = {
166 &frr_interface_info,
167 #ifndef FABRICD
168 &frr_isisd_info,
169 #endif /* ifndef FABRICD */
170 &frr_route_map_info,
171 };
172
173 #ifdef FABRICD
174 FRR_DAEMON_INFO(fabricd, OPEN_FABRIC, .vty_port = FABRICD_VTY_PORT,
175
176 .proghelp = "Implementation of the OpenFabric routing protocol.",
177 #else
178 FRR_DAEMON_INFO(isisd, ISIS, .vty_port = ISISD_VTY_PORT,
179
180 .proghelp = "Implementation of the IS-IS routing protocol.",
181 #endif
182 .copyright =
183 "Copyright (c) 2001-2002 Sampo Saaristo,"
184 " Ofer Wald and Hannes Gredler",
185
186 .signals = isisd_signals,
187 .n_signals = array_size(isisd_signals),
188
189 .privs = &isisd_privs, .yang_modules = isisd_yang_modules,
190 .n_yang_modules = array_size(isisd_yang_modules), )
191
192 /*
193 * Main routine of isisd. Parse arguments and handle IS-IS state machine.
194 */
195 int main(int argc, char **argv, char **envp)
196 {
197 int opt;
198
199 #ifdef FABRICD
200 frr_preinit(&fabricd_di, argc, argv);
201 #else
202 frr_preinit(&isisd_di, argc, argv);
203 #endif
204 frr_opt_add("", longopts, "");
205
206 /* Command line argument treatment. */
207 while (1) {
208 opt = frr_getopt(argc, argv, NULL);
209
210 if (opt == EOF)
211 break;
212
213 switch (opt) {
214 case 0:
215 break;
216 default:
217 frr_help_exit(1);
218 break;
219 }
220 }
221
222 /* thread master */
223 master = frr_init();
224
225 /*
226 * initializations
227 */
228 isis_error_init();
229 access_list_init();
230 vrf_init(NULL, NULL, NULL, NULL, NULL);
231 prefix_list_init();
232 isis_init();
233 isis_circuit_init();
234 #ifdef FABRICD
235 isis_vty_daemon_init();
236 #endif /* FABRICD */
237 #ifndef FABRICD
238 isis_cli_init();
239 #endif /* ifdef FABRICD */
240 isis_spf_cmds_init();
241 isis_redist_init();
242 isis_route_map_init();
243 isis_mpls_te_init();
244 lsp_init();
245 mt_init();
246
247 /* create the global 'isis' instance */
248 isis_new(1, VRF_DEFAULT);
249
250 isis_zebra_init(master);
251 isis_bfd_init();
252 fabricd_init();
253
254 frr_config_fork();
255 frr_run(master);
256
257 /* Not reached. */
258 exit(0);
259 }