]> git.proxmox.com Git - mirror_frr.git/blob - isisd/isis_main.c
*: make consistent & update GPLv2 file headers
[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_tlv.h"
56 #include "isisd/isis_te.h"
57
58 /* Default configuration file name */
59 #define ISISD_DEFAULT_CONFIG "isisd.conf"
60 /* Default vty port */
61 #define ISISD_VTY_PORT 2608
62
63 /* isisd privileges */
64 zebra_capabilities_t _caps_p[] = {
65 ZCAP_NET_RAW,
66 ZCAP_BIND
67 };
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
84 /* isisd options */
85 struct option longopts[] = {
86 {0}
87 };
88
89 /* Master of threads. */
90 struct thread_master *master;
91
92 /*
93 * Prototypes.
94 */
95 void sighup(void);
96 void sigint(void);
97 void sigterm(void);
98 void sigusr1(void);
99
100
101 static __attribute__((__noreturn__)) void
102 terminate (int i)
103 {
104 exit (i);
105 }
106
107 /*
108 * Signal handlers
109 */
110
111 void
112 sighup (void)
113 {
114 zlog_err ("SIGHUP/reload is not implemented for isisd");
115 return;
116 }
117
118 __attribute__((__noreturn__)) void
119 sigint (void)
120 {
121 zlog_notice ("Terminating on signal SIGINT");
122 terminate (0);
123 }
124
125 __attribute__((__noreturn__)) void
126 sigterm (void)
127 {
128 zlog_notice ("Terminating on signal SIGTERM");
129 terminate (0);
130 }
131
132 void
133 sigusr1 (void)
134 {
135 zlog_debug ("SIGUSR1 received");
136 zlog_rotate();
137 }
138
139 struct quagga_signal_t isisd_signals[] =
140 {
141 {
142 .signal = SIGHUP,
143 .handler = &sighup,
144 },
145 {
146 .signal = SIGUSR1,
147 .handler = &sigusr1,
148 },
149 {
150 .signal = SIGINT,
151 .handler = &sigint,
152 },
153 {
154 .signal = SIGTERM,
155 .handler = &sigterm,
156 },
157 };
158
159 FRR_DAEMON_INFO(isisd, ISIS,
160 .vty_port = ISISD_VTY_PORT,
161
162 .proghelp = "Implementation of the IS-IS routing protocol.",
163 .copyright = "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 /*
173 * Main routine of isisd. Parse arguments and handle IS-IS state machine.
174 */
175 int
176 main (int argc, char **argv, char **envp)
177 {
178 int opt;
179
180 frr_preinit (&isisd_di, argc, argv);
181 frr_opt_add ("", longopts, "");
182
183 /* Command line argument treatment. */
184 while (1)
185 {
186 opt = frr_getopt (argc, argv, NULL);
187
188 if (opt == EOF)
189 break;
190
191 switch (opt)
192 {
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 access_list_init();
209 vrf_init ();
210 prefix_list_init();
211 isis_init ();
212 isis_circuit_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
223 frr_config_fork ();
224 frr_run (master);
225
226 /* Not reached. */
227 exit (0);
228 }