]>
Commit | Line | Data |
---|---|---|
7f57883e DS |
1 | /* |
2 | * EIGRP Main Routine. | |
3 | * Copyright (C) 2013-2015 | |
4 | * Authors: | |
5 | * Donnie Savage | |
6 | * Jan Janovic | |
7 | * Matej Perina | |
8 | * Peter Orsag | |
9 | * Peter Paluch | |
10 | * Frantisek Gazo | |
11 | * Tomas Hvorkovy | |
12 | * Martin Kontsek | |
13 | * Lukas Koribsky | |
14 | * | |
15 | * This file is part of GNU Zebra. | |
16 | * | |
17 | * GNU Zebra is free software; you can redistribute it and/or modify it | |
18 | * under the terms of the GNU General Public License as published by the | |
19 | * Free Software Foundation; either version 2, or (at your option) any | |
20 | * later version. | |
21 | * | |
22 | * GNU Zebra is distributed in the hope that it will be useful, but | |
23 | * WITHOUT ANY WARRANTY; without even the implied warranty of | |
24 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
25 | * General Public License for more details. | |
26 | * | |
896014f4 DL |
27 | * You should have received a copy of the GNU General Public License along |
28 | * with this program; see the file COPYING; if not, write to the Free Software | |
29 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | |
7f57883e DS |
30 | */ |
31 | #include <zebra.h> | |
32 | ||
33 | #include <lib/version.h> | |
34 | #include "getopt.h" | |
35 | #include "thread.h" | |
36 | #include "prefix.h" | |
37 | #include "linklist.h" | |
38 | #include "if.h" | |
39 | #include "vector.h" | |
40 | #include "vty.h" | |
41 | #include "command.h" | |
42 | #include "filter.h" | |
43 | #include "plist.h" | |
44 | #include "stream.h" | |
45 | #include "log.h" | |
46 | #include "memory.h" | |
47 | #include "privs.h" | |
48 | #include "sigevent.h" | |
49 | #include "zclient.h" | |
50 | #include "keychain.h" | |
51 | #include "distribute.h" | |
52 | #include "libfrr.h" | |
a72730d3 | 53 | #include "routemap.h" |
7f57883e DS |
54 | //#include "if_rmap.h" |
55 | ||
56 | #include "eigrpd/eigrp_structs.h" | |
57 | #include "eigrpd/eigrpd.h" | |
58 | #include "eigrpd/eigrp_dump.h" | |
59 | #include "eigrpd/eigrp_interface.h" | |
60 | #include "eigrpd/eigrp_neighbor.h" | |
61 | #include "eigrpd/eigrp_packet.h" | |
62 | #include "eigrpd/eigrp_vty.h" | |
63 | #include "eigrpd/eigrp_zebra.h" | |
64 | #include "eigrpd/eigrp_network.h" | |
65 | #include "eigrpd/eigrp_snmp.h" | |
66 | #include "eigrpd/eigrp_filter.h" | |
8b0a80f1 | 67 | #include "eigrpd/eigrp_errors.h" |
c20fa244 | 68 | #include "eigrpd/eigrp_vrf.h" |
b66c8fbb | 69 | #include "eigrpd/eigrp_cli.h" |
fb532db3 | 70 | #include "eigrpd/eigrp_yang.h" |
7f57883e DS |
71 | //#include "eigrpd/eigrp_routemap.h" |
72 | ||
73 | /* eigprd privileges */ | |
d62a17ae | 74 | zebra_capabilities_t _caps_p[] = { |
9d303b37 | 75 | ZCAP_NET_RAW, ZCAP_BIND, ZCAP_NET_ADMIN, |
7f57883e DS |
76 | }; |
77 | ||
d62a17ae | 78 | struct zebra_privs_t eigrpd_privs = { |
79 | #if defined(FRR_USER) && defined(FRR_GROUP) | |
80 | .user = FRR_USER, | |
81 | .group = FRR_GROUP, | |
7f57883e | 82 | #endif |
d62a17ae | 83 | #if defined(VTY_GROUP) |
84 | .vty_group = VTY_GROUP, | |
7f57883e | 85 | #endif |
d62a17ae | 86 | .caps_p = _caps_p, |
87 | .cap_num_p = array_size(_caps_p), | |
88 | .cap_num_i = 0}; | |
7f57883e DS |
89 | |
90 | /* EIGRPd options. */ | |
d62a17ae | 91 | struct option longopts[] = {{0}}; |
7f57883e DS |
92 | |
93 | /* Master of threads. */ | |
94 | struct thread_master *master; | |
95 | ||
3e975968 RZ |
96 | /* Forward declaration of daemon info structure. */ |
97 | static struct frr_daemon_info eigrpd_di; | |
98 | ||
7f57883e | 99 | /* SIGHUP handler. */ |
d62a17ae | 100 | static void sighup(void) |
7f57883e | 101 | { |
d62a17ae | 102 | zlog_info("SIGHUP received"); |
3e975968 RZ |
103 | |
104 | /* Reload config file. */ | |
105 | vty_read_config(NULL, eigrpd_di.config_file, config_default); | |
7f57883e DS |
106 | } |
107 | ||
108 | /* SIGINT / SIGTERM handler. */ | |
d62a17ae | 109 | static void sigint(void) |
7f57883e | 110 | { |
d62a17ae | 111 | zlog_notice("Terminating on signal"); |
112 | eigrp_terminate(); | |
77382984 DS |
113 | |
114 | exit(0); | |
7f57883e DS |
115 | } |
116 | ||
117 | /* SIGUSR1 handler. */ | |
d62a17ae | 118 | static void sigusr1(void) |
7f57883e | 119 | { |
d62a17ae | 120 | zlog_rotate(); |
7f57883e DS |
121 | } |
122 | ||
7cc91e67 | 123 | struct frr_signal_t eigrp_signals[] = { |
d62a17ae | 124 | { |
125 | .signal = SIGHUP, | |
126 | .handler = &sighup, | |
127 | }, | |
128 | { | |
129 | .signal = SIGUSR1, | |
130 | .handler = &sigusr1, | |
131 | }, | |
132 | { | |
133 | .signal = SIGINT, | |
134 | .handler = &sigint, | |
135 | }, | |
136 | { | |
137 | .signal = SIGTERM, | |
138 | .handler = &sigint, | |
139 | }, | |
7f57883e DS |
140 | }; |
141 | ||
0d8c7a26 | 142 | static const struct frr_yang_module_info *const eigrpd_yang_modules[] = { |
f25c244b | 143 | &frr_eigrpd_info, |
c2aab693 | 144 | &frr_filter_info, |
a4bed468 | 145 | &frr_interface_info, |
91835f1f | 146 | &frr_route_map_info, |
6fd8972a | 147 | &frr_vrf_info, |
8fcdd0d6 RW |
148 | }; |
149 | ||
d62a17ae | 150 | FRR_DAEMON_INFO(eigrpd, EIGRP, .vty_port = EIGRP_VTY_PORT, |
7f57883e | 151 | |
d62a17ae | 152 | .proghelp = "Implementation of the EIGRP routing protocol.", |
7f57883e | 153 | |
d62a17ae | 154 | .signals = eigrp_signals, |
155 | .n_signals = array_size(eigrp_signals), | |
7f57883e | 156 | |
8fcdd0d6 | 157 | .privs = &eigrpd_privs, .yang_modules = eigrpd_yang_modules, |
80413c20 DL |
158 | .n_yang_modules = array_size(eigrpd_yang_modules), |
159 | ); | |
7f57883e DS |
160 | |
161 | /* EIGRPd main routine. */ | |
d62a17ae | 162 | int main(int argc, char **argv, char **envp) |
7f57883e | 163 | { |
d62a17ae | 164 | frr_preinit(&eigrpd_di, argc, argv); |
165 | frr_opt_add("", longopts, ""); | |
166 | ||
167 | while (1) { | |
168 | int opt; | |
169 | ||
170 | opt = frr_getopt(argc, argv, NULL); | |
171 | ||
172 | if (opt == EOF) | |
173 | break; | |
174 | ||
175 | switch (opt) { | |
176 | case 0: | |
177 | break; | |
178 | default: | |
179 | frr_help_exit(1); | |
d62a17ae | 180 | } |
181 | } | |
182 | ||
01cbe587 DS |
183 | eigrp_sw_version_initialize(); |
184 | ||
d62a17ae | 185 | /* EIGRP master init. */ |
186 | eigrp_master_init(); | |
187 | eigrp_om->master = frr_init(); | |
188 | master = eigrp_om->master; | |
189 | ||
8b0a80f1 | 190 | eigrp_error_init(); |
c20fa244 | 191 | eigrp_vrf_init(); |
ecbc5a37 | 192 | vrf_init(NULL, NULL, NULL, NULL, NULL); |
d62a17ae | 193 | |
194 | /*EIGRPd init*/ | |
195 | eigrp_if_init(); | |
196 | eigrp_zebra_init(); | |
197 | eigrp_debug_init(); | |
198 | ||
199 | /* Get configuration file. */ | |
200 | /* EIGRP VTY inits */ | |
201 | eigrp_vty_init(); | |
202 | keychain_init(); | |
203 | eigrp_vty_show_init(); | |
f25c244b | 204 | eigrp_cli_init(); |
7f57883e DS |
205 | |
206 | #ifdef HAVE_SNMP | |
d62a17ae | 207 | eigrp_snmp_init(); |
7f57883e DS |
208 | #endif /* HAVE_SNMP */ |
209 | ||
d62a17ae | 210 | /* Access list install. */ |
211 | access_list_init(); | |
212 | access_list_add_hook(eigrp_distribute_update_all_wrapper); | |
213 | access_list_delete_hook(eigrp_distribute_update_all_wrapper); | |
214 | ||
215 | /* Prefix list initialize.*/ | |
216 | prefix_list_init(); | |
217 | prefix_list_add_hook(eigrp_distribute_update_all); | |
218 | prefix_list_delete_hook(eigrp_distribute_update_all); | |
219 | ||
a72730d3 QY |
220 | /* |
221 | * XXX: This is just to get the CLI installed to suppress VTYSH errors. | |
222 | * Routemaps in EIGRP are not yet functional. | |
223 | */ | |
224 | route_map_init(); | |
d62a17ae | 225 | /*eigrp_route_map_init(); |
226 | route_map_add_hook (eigrp_rmap_update); | |
227 | route_map_delete_hook (eigrp_rmap_update);*/ | |
4b23867c | 228 | /*if_rmap_init (EIGRP_NODE); */ |
d62a17ae | 229 | |
230 | frr_config_fork(); | |
231 | frr_run(master); | |
232 | ||
233 | /* Not reached. */ | |
95f7965d | 234 | return 0; |
7f57883e | 235 | } |