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