]> git.proxmox.com Git - mirror_frr.git/blob - eigrpd/eigrp_main.c
Merge pull request #5722 from donaldsharp/kernel_routes
[mirror_frr.git] / eigrpd / eigrp_main.c
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 *
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
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"
53 #include "routemap.h"
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"
67 #include "eigrpd/eigrp_errors.h"
68 #include "eigrpd/eigrp_vrf.h"
69 //#include "eigrpd/eigrp_routemap.h"
70
71 /* eigprd privileges */
72 zebra_capabilities_t _caps_p[] = {
73 ZCAP_NET_RAW, ZCAP_BIND, ZCAP_NET_ADMIN,
74 };
75
76 struct zebra_privs_t eigrpd_privs = {
77 #if defined(FRR_USER) && defined(FRR_GROUP)
78 .user = FRR_USER,
79 .group = FRR_GROUP,
80 #endif
81 #if defined(VTY_GROUP)
82 .vty_group = VTY_GROUP,
83 #endif
84 .caps_p = _caps_p,
85 .cap_num_p = array_size(_caps_p),
86 .cap_num_i = 0};
87
88 /* EIGRPd options. */
89 struct option longopts[] = {{0}};
90
91 /* Master of threads. */
92 struct thread_master *master;
93
94 /* Forward declaration of daemon info structure. */
95 static struct frr_daemon_info eigrpd_di;
96
97 /* SIGHUP handler. */
98 static void sighup(void)
99 {
100 zlog_info("SIGHUP received");
101
102 /* Reload config file. */
103 vty_read_config(NULL, eigrpd_di.config_file, config_default);
104 }
105
106 /* SIGINT / SIGTERM handler. */
107 static void sigint(void)
108 {
109 zlog_notice("Terminating on signal");
110 eigrp_terminate();
111
112 exit(0);
113 }
114
115 /* SIGUSR1 handler. */
116 static void sigusr1(void)
117 {
118 zlog_rotate();
119 }
120
121 struct quagga_signal_t eigrp_signals[] = {
122 {
123 .signal = SIGHUP,
124 .handler = &sighup,
125 },
126 {
127 .signal = SIGUSR1,
128 .handler = &sigusr1,
129 },
130 {
131 .signal = SIGINT,
132 .handler = &sigint,
133 },
134 {
135 .signal = SIGTERM,
136 .handler = &sigint,
137 },
138 };
139
140 static const struct frr_yang_module_info *const eigrpd_yang_modules[] = {
141 &frr_eigrpd_info,
142 &frr_interface_info,
143 &frr_route_map_info,
144 };
145
146 FRR_DAEMON_INFO(eigrpd, EIGRP, .vty_port = EIGRP_VTY_PORT,
147
148 .proghelp = "Implementation of the EIGRP routing protocol.",
149
150 .signals = eigrp_signals,
151 .n_signals = array_size(eigrp_signals),
152
153 .privs = &eigrpd_privs, .yang_modules = eigrpd_yang_modules,
154 .n_yang_modules = array_size(eigrpd_yang_modules), )
155
156 /* EIGRPd main routine. */
157 int main(int argc, char **argv, char **envp)
158 {
159 frr_preinit(&eigrpd_di, argc, argv);
160 frr_opt_add("", longopts, "");
161
162 while (1) {
163 int opt;
164
165 opt = frr_getopt(argc, argv, NULL);
166
167 if (opt == EOF)
168 break;
169
170 switch (opt) {
171 case 0:
172 break;
173 default:
174 frr_help_exit(1);
175 break;
176 }
177 }
178
179 eigrp_sw_version_initialize();
180
181 /* EIGRP master init. */
182 eigrp_master_init();
183 eigrp_om->master = frr_init();
184 master = eigrp_om->master;
185
186 eigrp_error_init();
187 eigrp_vrf_init();
188 vrf_init(NULL, NULL, NULL, NULL, NULL);
189
190 /*EIGRPd init*/
191 eigrp_if_init();
192 eigrp_zebra_init();
193 eigrp_debug_init();
194
195 /* Get configuration file. */
196 /* EIGRP VTY inits */
197 eigrp_vty_init();
198 keychain_init();
199 eigrp_vty_show_init();
200 eigrp_cli_init();
201
202 #ifdef HAVE_SNMP
203 eigrp_snmp_init();
204 #endif /* HAVE_SNMP */
205
206 /* Access list install. */
207 access_list_init();
208 access_list_add_hook(eigrp_distribute_update_all_wrapper);
209 access_list_delete_hook(eigrp_distribute_update_all_wrapper);
210
211 /* Prefix list initialize.*/
212 prefix_list_init();
213 prefix_list_add_hook(eigrp_distribute_update_all);
214 prefix_list_delete_hook(eigrp_distribute_update_all);
215
216 /*
217 * XXX: This is just to get the CLI installed to suppress VTYSH errors.
218 * Routemaps in EIGRP are not yet functional.
219 */
220 route_map_init();
221 /*eigrp_route_map_init();
222 route_map_add_hook (eigrp_rmap_update);
223 route_map_delete_hook (eigrp_rmap_update);*/
224 /*if_rmap_init (EIGRP_NODE); */
225 /* Distribute list install. */
226 distribute_list_init(EIGRP_NODE);
227
228 frr_config_fork();
229 frr_run(master);
230
231 /* Not reached. */
232 return (0);
233 }