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