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