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