]> git.proxmox.com Git - mirror_frr.git/blob - isisd/isis_main.c
Merge pull request #3399 from opensourcerouting/ripngd-nb-retrofitting
[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/dict.h"
45 #include "isisd/isis_constants.h"
46 #include "isisd/isis_common.h"
47 #include "isisd/isis_flags.h"
48 #include "isisd/isis_circuit.h"
49 #include "isisd/isisd.h"
50 #include "isisd/isis_dynhn.h"
51 #include "isisd/isis_spf.h"
52 #include "isisd/isis_route.h"
53 #include "isisd/isis_routemap.h"
54 #include "isisd/isis_zebra.h"
55 #include "isisd/isis_te.h"
56 #include "isisd/isis_errors.h"
57 #include "isisd/isis_vty_common.h"
58 #include "isisd/isis_bfd.h"
59 #include "isisd/isis_lsp.h"
60 #include "isisd/isis_mt.h"
61 #include "isisd/fabricd.h"
62
63 /* Default configuration file name */
64 #define ISISD_DEFAULT_CONFIG "isisd.conf"
65 /* Default vty port */
66 #define ISISD_VTY_PORT 2608
67 #define FABRICD_VTY_PORT 2618
68
69 /* isisd privileges */
70 zebra_capabilities_t _caps_p[] = {ZCAP_NET_RAW, ZCAP_BIND};
71
72 struct zebra_privs_t isisd_privs = {
73 #if defined(FRR_USER)
74 .user = FRR_USER,
75 #endif
76 #if defined FRR_GROUP
77 .group = FRR_GROUP,
78 #endif
79 #ifdef VTY_GROUP
80 .vty_group = VTY_GROUP,
81 #endif
82 .caps_p = _caps_p,
83 .cap_num_p = sizeof(_caps_p) / sizeof(*_caps_p),
84 .cap_num_i = 0};
85
86 /* isisd options */
87 struct option longopts[] = {{0}};
88
89 /* Master of threads. */
90 struct thread_master *master;
91
92 /*
93 * Prototypes.
94 */
95 void sighup(void);
96 void sigint(void);
97 void sigterm(void);
98 void sigusr1(void);
99
100
101 static __attribute__((__noreturn__)) void terminate(int i)
102 {
103 isis_zebra_stop();
104 exit(i);
105 }
106
107 /*
108 * Signal handlers
109 */
110
111 void sighup(void)
112 {
113 zlog_notice("SIGHUP/reload is not implemented for isisd");
114 return;
115 }
116
117 __attribute__((__noreturn__)) void sigint(void)
118 {
119 zlog_notice("Terminating on signal SIGINT");
120 terminate(0);
121 }
122
123 __attribute__((__noreturn__)) void sigterm(void)
124 {
125 zlog_notice("Terminating on signal SIGTERM");
126 terminate(0);
127 }
128
129 void sigusr1(void)
130 {
131 zlog_debug("SIGUSR1 received");
132 zlog_rotate();
133 }
134
135 struct quagga_signal_t isisd_signals[] = {
136 {
137 .signal = SIGHUP,
138 .handler = &sighup,
139 },
140 {
141 .signal = SIGUSR1,
142 .handler = &sigusr1,
143 },
144 {
145 .signal = SIGINT,
146 .handler = &sigint,
147 },
148 {
149 .signal = SIGTERM,
150 .handler = &sigterm,
151 },
152 };
153
154 static const struct frr_yang_module_info *isisd_yang_modules[] = {
155 &frr_interface_info,
156 };
157
158 #ifdef FABRICD
159 FRR_DAEMON_INFO(fabricd, OPEN_FABRIC, .vty_port = FABRICD_VTY_PORT,
160
161 .proghelp = "Implementation of the OpenFabric routing protocol.",
162 #else
163 FRR_DAEMON_INFO(isisd, ISIS, .vty_port = ISISD_VTY_PORT,
164
165 .proghelp = "Implementation of the IS-IS routing protocol.",
166 #endif
167 .copyright =
168 "Copyright (c) 2001-2002 Sampo Saaristo,"
169 " Ofer Wald and Hannes Gredler",
170
171 .signals = isisd_signals,
172 .n_signals = array_size(isisd_signals),
173
174 .privs = &isisd_privs, .yang_modules = isisd_yang_modules,
175 .n_yang_modules = array_size(isisd_yang_modules), )
176
177 /*
178 * Main routine of isisd. Parse arguments and handle IS-IS state machine.
179 */
180 int main(int argc, char **argv, char **envp)
181 {
182 int opt;
183
184 #ifdef FABRICD
185 frr_preinit(&fabricd_di, argc, argv);
186 #else
187 frr_preinit(&isisd_di, argc, argv);
188 #endif
189 frr_opt_add("", longopts, "");
190
191 /* Command line argument treatment. */
192 while (1) {
193 opt = frr_getopt(argc, argv, NULL);
194
195 if (opt == EOF)
196 break;
197
198 switch (opt) {
199 case 0:
200 break;
201 default:
202 frr_help_exit(1);
203 break;
204 }
205 }
206
207 /* thread master */
208 master = frr_init();
209
210 /*
211 * initializations
212 */
213 isis_error_init();
214 access_list_init();
215 vrf_init(NULL, NULL, NULL, NULL, NULL);
216 prefix_list_init();
217 isis_init();
218 isis_circuit_init();
219 isis_vty_init();
220 isis_spf_cmds_init();
221 isis_redist_init();
222 isis_route_map_init();
223 isis_mpls_te_init();
224 lsp_init();
225 mt_init();
226
227 /* create the global 'isis' instance */
228 isis_new(1);
229
230 isis_zebra_init(master);
231 isis_bfd_init();
232 fabricd_init();
233
234 frr_config_fork();
235 frr_run(master);
236
237 /* Not reached. */
238 exit(0);
239 }