]> git.proxmox.com Git - mirror_frr.git/blame - isisd/isis_main.c
isisd: Add forward declaration of struct isis_route_info
[mirror_frr.git] / isisd / isis_main.c
CommitLineData
eb5d44eb 1/*
2 * IS-IS Rout(e)ing protocol - isis_main.c
3 *
4 * Copyright (C) 2001,2002 Sampo Saaristo
d62a17ae 5 * Tampere University of Technology
eb5d44eb 6 * Institute of Communications Engineering
7 *
d62a17ae 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)
eb5d44eb 11 * any later version.
12 *
d62a17ae 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
eb5d44eb 16 * more details.
896014f4
DL
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
eb5d44eb 21 */
22
eb5d44eb 23#include <zebra.h>
eb5d44eb 24
25#include "getopt.h"
26#include "thread.h"
27#include "log.h"
5e4fa164 28#include <lib/version.h>
eb5d44eb 29#include "command.h"
30#include "vty.h"
31#include "memory.h"
fc7948fa 32#include "memory_vty.h"
eb5d44eb 33#include "stream.h"
34#include "if.h"
9e867fe6 35#include "privs.h"
2d75d052 36#include "sigevent.h"
c729c650 37#include "filter.h"
f3ccedaa 38#include "plist.h"
48d8bea8 39#include "zclient.h"
6a69b354 40#include "vrf.h"
676a4ea3 41#include "qobj.h"
4f04a76b 42#include "libfrr.h"
eb5d44eb 43
44#include "isisd/dict.h"
eb5d44eb 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"
3f045a08
JB
51#include "isisd/isis_spf.h"
52#include "isisd/isis_route.h"
f3ccedaa 53#include "isisd/isis_routemap.h"
3f045a08 54#include "isisd/isis_zebra.h"
f8c06e2c 55#include "isisd/isis_te.h"
54ece698 56#include "isisd/isis_errors.h"
ef020087 57#include "isisd/isis_vty_common.h"
eb5d44eb 58
59/* Default configuration file name */
60#define ISISD_DEFAULT_CONFIG "isisd.conf"
61/* Default vty port */
fc58e874 62#define ISISD_VTY_PORT 2608
7c0cbd0e 63#define FABRICD_VTY_PORT 2618
eb5d44eb 64
9e867fe6 65/* isisd privileges */
d62a17ae 66zebra_capabilities_t _caps_p[] = {ZCAP_NET_RAW, ZCAP_BIND};
9e867fe6 67
f390d2c7 68struct zebra_privs_t isisd_privs = {
b2f36157 69#if defined(FRR_USER)
d62a17ae 70 .user = FRR_USER,
9e867fe6 71#endif
b2f36157 72#if defined FRR_GROUP
d62a17ae 73 .group = FRR_GROUP,
9e867fe6 74#endif
75#ifdef VTY_GROUP
d62a17ae 76 .vty_group = VTY_GROUP,
9e867fe6 77#endif
d62a17ae 78 .caps_p = _caps_p,
79 .cap_num_p = sizeof(_caps_p) / sizeof(*_caps_p),
80 .cap_num_i = 0};
9e867fe6 81
eb5d44eb 82/* isisd options */
d62a17ae 83struct option longopts[] = {{0}};
eb5d44eb 84
eb5d44eb 85/* Master of threads. */
86struct thread_master *master;
87
41b36e90
PJ
88/*
89 * Prototypes.
90 */
41b36e90
PJ
91void sighup(void);
92void sigint(void);
93void sigterm(void);
94void sigusr1(void);
95
96
d62a17ae 97static __attribute__((__noreturn__)) void terminate(int i)
eb5d44eb 98{
d62a17ae 99 isis_zebra_stop();
100 exit(i);
eb5d44eb 101}
102
103/*
104 * Signal handlers
105 */
2d75d052 106
d62a17ae 107void sighup(void)
eb5d44eb 108{
38937bd5 109 zlog_notice("SIGHUP/reload is not implemented for isisd");
d62a17ae 110 return;
eb5d44eb 111}
112
d62a17ae 113__attribute__((__noreturn__)) void sigint(void)
eb5d44eb 114{
d62a17ae 115 zlog_notice("Terminating on signal SIGINT");
116 terminate(0);
eb5d44eb 117}
118
d62a17ae 119__attribute__((__noreturn__)) void sigterm(void)
eb5d44eb 120{
d62a17ae 121 zlog_notice("Terminating on signal SIGTERM");
122 terminate(0);
eb5d44eb 123}
124
d62a17ae 125void sigusr1(void)
eb5d44eb 126{
d62a17ae 127 zlog_debug("SIGUSR1 received");
128 zlog_rotate();
eb5d44eb 129}
130
d62a17ae 131struct quagga_signal_t isisd_signals[] = {
132 {
133 .signal = SIGHUP,
134 .handler = &sighup,
135 },
136 {
137 .signal = SIGUSR1,
138 .handler = &sigusr1,
139 },
140 {
141 .signal = SIGINT,
142 .handler = &sigint,
143 },
144 {
145 .signal = SIGTERM,
146 .handler = &sigterm,
147 },
2d75d052 148};
eb5d44eb 149
7c0cbd0e
CF
150#ifdef FABRICD
151FRR_DAEMON_INFO(fabricd, OPEN_FABRIC, .vty_port = FABRICD_VTY_PORT,
152
153 .proghelp = "Implementation of the OpenFabric routing protocol.",
154#else
d62a17ae 155FRR_DAEMON_INFO(isisd, ISIS, .vty_port = ISISD_VTY_PORT,
4f04a76b 156
d62a17ae 157 .proghelp = "Implementation of the IS-IS routing protocol.",
7c0cbd0e 158#endif
d62a17ae 159 .copyright =
160 "Copyright (c) 2001-2002 Sampo Saaristo,"
161 " Ofer Wald and Hannes Gredler",
4f04a76b 162
d62a17ae 163 .signals = isisd_signals,
164 .n_signals = array_size(isisd_signals),
4f04a76b 165
d62a17ae 166 .privs = &isisd_privs, )
4f04a76b 167
eb5d44eb 168/*
169 * Main routine of isisd. Parse arguments and handle IS-IS state machine.
170 */
d62a17ae 171int main(int argc, char **argv, char **envp)
eb5d44eb 172{
d62a17ae 173 int opt;
eb5d44eb 174
7c0cbd0e
CF
175#ifdef FABRICD
176 frr_preinit(&fabricd_di, argc, argv);
177#else
d62a17ae 178 frr_preinit(&isisd_di, argc, argv);
7c0cbd0e 179#endif
d62a17ae 180 frr_opt_add("", longopts, "");
4f04a76b 181
d62a17ae 182 /* Command line argument treatment. */
183 while (1) {
184 opt = frr_getopt(argc, argv, NULL);
f390d2c7 185
d62a17ae 186 if (opt == EOF)
187 break;
f390d2c7 188
d62a17ae 189 switch (opt) {
190 case 0:
191 break;
192 default:
193 frr_help_exit(1);
194 break;
195 }
f390d2c7 196 }
d62a17ae 197
198 vty_config_lockless();
199 /* thread master */
200 master = frr_init();
201
202 /*
203 * initializations
204 */
54ece698 205 isis_error_init();
d62a17ae 206 access_list_init();
ecbc5a37 207 vrf_init(NULL, NULL, NULL, NULL, NULL);
d62a17ae 208 prefix_list_init();
209 isis_init();
210 isis_circuit_init();
ef020087 211 isis_vty_init();
d62a17ae 212 isis_spf_cmds_init();
213 isis_redist_init();
214 isis_route_map_init();
215 isis_mpls_te_init();
216
217 /* create the global 'isis' instance */
218 isis_new(1);
219
220 isis_zebra_init(master);
221
222 frr_config_fork();
223 frr_run(master);
224
225 /* Not reached. */
226 exit(0);
eb5d44eb 227}