]> git.proxmox.com Git - mirror_frr.git/blob - isisd/isis_main.c
*: remove the configuration lock from all daemons
[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
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 = sizeof(_caps_p) / sizeof(*_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
110 void sighup(void)
111 {
112 zlog_notice("SIGHUP/reload is not implemented for isisd");
113 return;
114 }
115
116 __attribute__((__noreturn__)) void sigint(void)
117 {
118 zlog_notice("Terminating on signal SIGINT");
119 terminate(0);
120 }
121
122 __attribute__((__noreturn__)) void sigterm(void)
123 {
124 zlog_notice("Terminating on signal SIGTERM");
125 terminate(0);
126 }
127
128 void sigusr1(void)
129 {
130 zlog_debug("SIGUSR1 received");
131 zlog_rotate();
132 }
133
134 struct quagga_signal_t isisd_signals[] = {
135 {
136 .signal = SIGHUP,
137 .handler = &sighup,
138 },
139 {
140 .signal = SIGUSR1,
141 .handler = &sigusr1,
142 },
143 {
144 .signal = SIGINT,
145 .handler = &sigint,
146 },
147 {
148 .signal = SIGTERM,
149 .handler = &sigterm,
150 },
151 };
152
153 static const struct frr_yang_module_info *isisd_yang_modules[] = {
154 &frr_interface_info,
155 };
156
157 #ifdef FABRICD
158 FRR_DAEMON_INFO(fabricd, OPEN_FABRIC, .vty_port = FABRICD_VTY_PORT,
159
160 .proghelp = "Implementation of the OpenFabric routing protocol.",
161 #else
162 FRR_DAEMON_INFO(isisd, ISIS, .vty_port = ISISD_VTY_PORT,
163
164 .proghelp = "Implementation of the IS-IS routing protocol.",
165 #endif
166 .copyright =
167 "Copyright (c) 2001-2002 Sampo Saaristo,"
168 " Ofer Wald and Hannes Gredler",
169
170 .signals = isisd_signals,
171 .n_signals = array_size(isisd_signals),
172
173 .privs = &isisd_privs, .yang_modules = isisd_yang_modules,
174 .n_yang_modules = array_size(isisd_yang_modules), )
175
176 /*
177 * Main routine of isisd. Parse arguments and handle IS-IS state machine.
178 */
179 int main(int argc, char **argv, char **envp)
180 {
181 int opt;
182
183 #ifdef FABRICD
184 frr_preinit(&fabricd_di, argc, argv);
185 #else
186 frr_preinit(&isisd_di, argc, argv);
187 #endif
188 frr_opt_add("", longopts, "");
189
190 /* Command line argument treatment. */
191 while (1) {
192 opt = frr_getopt(argc, argv, NULL);
193
194 if (opt == EOF)
195 break;
196
197 switch (opt) {
198 case 0:
199 break;
200 default:
201 frr_help_exit(1);
202 break;
203 }
204 }
205
206 /* thread master */
207 master = frr_init();
208
209 /*
210 * initializations
211 */
212 isis_error_init();
213 access_list_init();
214 vrf_init(NULL, NULL, NULL, NULL, NULL);
215 prefix_list_init();
216 isis_init();
217 isis_circuit_init();
218 isis_vty_init();
219 isis_spf_cmds_init();
220 isis_redist_init();
221 isis_route_map_init();
222 isis_mpls_te_init();
223 lsp_init();
224 mt_init();
225
226 /* create the global 'isis' instance */
227 isis_new(1);
228
229 isis_zebra_init(master);
230 isis_bfd_init();
231
232 frr_config_fork();
233 frr_run(master);
234
235 /* Not reached. */
236 exit(0);
237 }