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