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