]> git.proxmox.com Git - mirror_frr.git/blame - isisd/isis_main.c
isisd: implemented the 'sequence-number-skipped' notification
[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"
52df8228 58#include "isisd/isis_bfd.h"
a5b5e946 59#include "isisd/isis_lsp.h"
d56afe53 60#include "isisd/isis_mt.h"
2cd971af 61#include "isisd/fabricd.h"
eb5d44eb 62
63/* Default configuration file name */
64#define ISISD_DEFAULT_CONFIG "isisd.conf"
65/* Default vty port */
fc58e874 66#define ISISD_VTY_PORT 2608
7c0cbd0e 67#define FABRICD_VTY_PORT 2618
eb5d44eb 68
9e867fe6 69/* isisd privileges */
d62a17ae 70zebra_capabilities_t _caps_p[] = {ZCAP_NET_RAW, ZCAP_BIND};
9e867fe6 71
f390d2c7 72struct zebra_privs_t isisd_privs = {
b2f36157 73#if defined(FRR_USER)
d62a17ae 74 .user = FRR_USER,
9e867fe6 75#endif
b2f36157 76#if defined FRR_GROUP
d62a17ae 77 .group = FRR_GROUP,
9e867fe6 78#endif
79#ifdef VTY_GROUP
d62a17ae 80 .vty_group = VTY_GROUP,
9e867fe6 81#endif
d62a17ae 82 .caps_p = _caps_p,
83 .cap_num_p = sizeof(_caps_p) / sizeof(*_caps_p),
84 .cap_num_i = 0};
9e867fe6 85
eb5d44eb 86/* isisd options */
d62a17ae 87struct option longopts[] = {{0}};
eb5d44eb 88
eb5d44eb 89/* Master of threads. */
90struct thread_master *master;
91
41b36e90
PJ
92/*
93 * Prototypes.
94 */
41b36e90
PJ
95void sighup(void);
96void sigint(void);
97void sigterm(void);
98void sigusr1(void);
99
100
d62a17ae 101static __attribute__((__noreturn__)) void terminate(int i)
eb5d44eb 102{
d62a17ae 103 isis_zebra_stop();
104 exit(i);
eb5d44eb 105}
106
107/*
108 * Signal handlers
109 */
2d75d052 110
d62a17ae 111void sighup(void)
eb5d44eb 112{
38937bd5 113 zlog_notice("SIGHUP/reload is not implemented for isisd");
d62a17ae 114 return;
eb5d44eb 115}
116
d62a17ae 117__attribute__((__noreturn__)) void sigint(void)
eb5d44eb 118{
d62a17ae 119 zlog_notice("Terminating on signal SIGINT");
120 terminate(0);
eb5d44eb 121}
122
d62a17ae 123__attribute__((__noreturn__)) void sigterm(void)
eb5d44eb 124{
d62a17ae 125 zlog_notice("Terminating on signal SIGTERM");
126 terminate(0);
eb5d44eb 127}
128
d62a17ae 129void sigusr1(void)
eb5d44eb 130{
d62a17ae 131 zlog_debug("SIGUSR1 received");
132 zlog_rotate();
eb5d44eb 133}
134
d62a17ae 135struct quagga_signal_t isisd_signals[] = {
136 {
137 .signal = SIGHUP,
138 .handler = &sighup,
139 },
140 {
141 .signal = SIGUSR1,
142 .handler = &sigusr1,
143 },
144 {
145 .signal = SIGINT,
146 .handler = &sigint,
147 },
148 {
149 .signal = SIGTERM,
150 .handler = &sigterm,
151 },
2d75d052 152};
eb5d44eb 153
20bd27e2 154
8fcdd0d6 155static const struct frr_yang_module_info *isisd_yang_modules[] = {
a4bed468 156 &frr_interface_info,
20bd27e2
EDP
157#ifndef FABRICD
158 &frr_isisd_info,
159#endif /* ifndef FABRICD */
8fcdd0d6
RW
160};
161
7c0cbd0e
CF
162#ifdef FABRICD
163FRR_DAEMON_INFO(fabricd, OPEN_FABRIC, .vty_port = FABRICD_VTY_PORT,
164
165 .proghelp = "Implementation of the OpenFabric routing protocol.",
166#else
d62a17ae 167FRR_DAEMON_INFO(isisd, ISIS, .vty_port = ISISD_VTY_PORT,
4f04a76b 168
d62a17ae 169 .proghelp = "Implementation of the IS-IS routing protocol.",
7c0cbd0e 170#endif
d62a17ae 171 .copyright =
172 "Copyright (c) 2001-2002 Sampo Saaristo,"
173 " Ofer Wald and Hannes Gredler",
4f04a76b 174
d62a17ae 175 .signals = isisd_signals,
176 .n_signals = array_size(isisd_signals),
4f04a76b 177
8fcdd0d6
RW
178 .privs = &isisd_privs, .yang_modules = isisd_yang_modules,
179 .n_yang_modules = array_size(isisd_yang_modules), )
4f04a76b 180
eb5d44eb 181/*
182 * Main routine of isisd. Parse arguments and handle IS-IS state machine.
183 */
d62a17ae 184int main(int argc, char **argv, char **envp)
eb5d44eb 185{
d62a17ae 186 int opt;
eb5d44eb 187
7c0cbd0e
CF
188#ifdef FABRICD
189 frr_preinit(&fabricd_di, argc, argv);
190#else
d62a17ae 191 frr_preinit(&isisd_di, argc, argv);
7c0cbd0e 192#endif
d62a17ae 193 frr_opt_add("", longopts, "");
4f04a76b 194
d62a17ae 195 /* Command line argument treatment. */
196 while (1) {
197 opt = frr_getopt(argc, argv, NULL);
f390d2c7 198
d62a17ae 199 if (opt == EOF)
200 break;
f390d2c7 201
d62a17ae 202 switch (opt) {
203 case 0:
204 break;
205 default:
206 frr_help_exit(1);
207 break;
208 }
f390d2c7 209 }
d62a17ae 210
d62a17ae 211 /* thread master */
212 master = frr_init();
213
214 /*
215 * initializations
216 */
54ece698 217 isis_error_init();
d62a17ae 218 access_list_init();
ecbc5a37 219 vrf_init(NULL, NULL, NULL, NULL, NULL);
d62a17ae 220 prefix_list_init();
221 isis_init();
222 isis_circuit_init();
ef020087 223 isis_vty_init();
20bd27e2
EDP
224#ifndef FABRICD
225 isis_cli_init();
226#endif /* ifdef FABRICD */
d62a17ae 227 isis_spf_cmds_init();
228 isis_redist_init();
229 isis_route_map_init();
230 isis_mpls_te_init();
a5b5e946 231 lsp_init();
d56afe53 232 mt_init();
d62a17ae 233
234 /* create the global 'isis' instance */
235 isis_new(1);
236
237 isis_zebra_init(master);
52df8228 238 isis_bfd_init();
2cd971af 239 fabricd_init();
d62a17ae 240
241 frr_config_fork();
242 frr_run(master);
243
244 /* Not reached. */
245 exit(0);
eb5d44eb 246}