]> git.proxmox.com Git - mirror_frr.git/blob - isisd/isis_main.c
isisd: Add a hook when writing interface config
[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 #ifdef FABRICD
154 FRR_DAEMON_INFO(fabricd, OPEN_FABRIC, .vty_port = FABRICD_VTY_PORT,
155
156 .proghelp = "Implementation of the OpenFabric routing protocol.",
157 #else
158 FRR_DAEMON_INFO(isisd, ISIS, .vty_port = ISISD_VTY_PORT,
159
160 .proghelp = "Implementation of the IS-IS routing protocol.",
161 #endif
162 .copyright =
163 "Copyright (c) 2001-2002 Sampo Saaristo,"
164 " Ofer Wald and Hannes Gredler",
165
166 .signals = isisd_signals,
167 .n_signals = array_size(isisd_signals),
168
169 .privs = &isisd_privs, )
170
171 /*
172 * Main routine of isisd. Parse arguments and handle IS-IS state machine.
173 */
174 int main(int argc, char **argv, char **envp)
175 {
176 int opt;
177
178 #ifdef FABRICD
179 frr_preinit(&fabricd_di, argc, argv);
180 #else
181 frr_preinit(&isisd_di, argc, argv);
182 #endif
183 frr_opt_add("", longopts, "");
184
185 /* Command line argument treatment. */
186 while (1) {
187 opt = frr_getopt(argc, argv, NULL);
188
189 if (opt == EOF)
190 break;
191
192 switch (opt) {
193 case 0:
194 break;
195 default:
196 frr_help_exit(1);
197 break;
198 }
199 }
200
201 vty_config_lockless();
202 /* thread master */
203 master = frr_init();
204
205 /*
206 * initializations
207 */
208 isis_error_init();
209 access_list_init();
210 vrf_init(NULL, NULL, NULL, NULL, NULL);
211 prefix_list_init();
212 isis_init();
213 isis_circuit_init();
214 isis_vty_init();
215 isis_spf_cmds_init();
216 isis_redist_init();
217 isis_route_map_init();
218 isis_mpls_te_init();
219 lsp_init();
220 mt_init();
221
222 /* create the global 'isis' instance */
223 isis_new(1);
224
225 isis_zebra_init(master);
226 isis_bfd_init();
227
228 frr_config_fork();
229 frr_run(master);
230
231 /* Not reached. */
232 exit(0);
233 }