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