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