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