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