]> git.proxmox.com Git - mirror_frr.git/blob - eigrpd/eigrp_main.c
Merge pull request #12798 from donaldsharp/rib_match_multicast
[mirror_frr.git] / eigrpd / eigrp_main.c
1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /*
3 * EIGRP Main Routine.
4 * Copyright (C) 2013-2015
5 * Authors:
6 * Donnie Savage
7 * Jan Janovic
8 * Matej Perina
9 * Peter Orsag
10 * Peter Paluch
11 * Frantisek Gazo
12 * Tomas Hvorkovy
13 * Martin Kontsek
14 * Lukas Koribsky
15 */
16 #include <zebra.h>
17
18 #include <lib/version.h>
19 #include "getopt.h"
20 #include "thread.h"
21 #include "prefix.h"
22 #include "linklist.h"
23 #include "if.h"
24 #include "vector.h"
25 #include "vty.h"
26 #include "command.h"
27 #include "filter.h"
28 #include "plist.h"
29 #include "stream.h"
30 #include "log.h"
31 #include "memory.h"
32 #include "privs.h"
33 #include "sigevent.h"
34 #include "zclient.h"
35 #include "keychain.h"
36 #include "distribute.h"
37 #include "libfrr.h"
38 #include "routemap.h"
39 //#include "if_rmap.h"
40
41 #include "eigrpd/eigrp_structs.h"
42 #include "eigrpd/eigrpd.h"
43 #include "eigrpd/eigrp_dump.h"
44 #include "eigrpd/eigrp_interface.h"
45 #include "eigrpd/eigrp_neighbor.h"
46 #include "eigrpd/eigrp_packet.h"
47 #include "eigrpd/eigrp_vty.h"
48 #include "eigrpd/eigrp_zebra.h"
49 #include "eigrpd/eigrp_network.h"
50 #include "eigrpd/eigrp_snmp.h"
51 #include "eigrpd/eigrp_filter.h"
52 #include "eigrpd/eigrp_errors.h"
53 #include "eigrpd/eigrp_vrf.h"
54 #include "eigrpd/eigrp_cli.h"
55 #include "eigrpd/eigrp_yang.h"
56 //#include "eigrpd/eigrp_routemap.h"
57
58 /* eigprd privileges */
59 zebra_capabilities_t _caps_p[] = {
60 ZCAP_NET_RAW, ZCAP_BIND, ZCAP_NET_ADMIN,
61 };
62
63 struct zebra_privs_t eigrpd_privs = {
64 #if defined(FRR_USER) && defined(FRR_GROUP)
65 .user = FRR_USER,
66 .group = FRR_GROUP,
67 #endif
68 #if defined(VTY_GROUP)
69 .vty_group = VTY_GROUP,
70 #endif
71 .caps_p = _caps_p,
72 .cap_num_p = array_size(_caps_p),
73 .cap_num_i = 0};
74
75 /* EIGRPd options. */
76 struct option longopts[] = {{0}};
77
78 /* Master of threads. */
79 struct thread_master *master;
80
81 /* Forward declaration of daemon info structure. */
82 static struct frr_daemon_info eigrpd_di;
83
84 /* SIGHUP handler. */
85 static void sighup(void)
86 {
87 zlog_info("SIGHUP received");
88
89 /* Reload config file. */
90 vty_read_config(NULL, eigrpd_di.config_file, config_default);
91 }
92
93 /* SIGINT / SIGTERM handler. */
94 static void sigint(void)
95 {
96 zlog_notice("Terminating on signal");
97 eigrp_terminate();
98
99 exit(0);
100 }
101
102 /* SIGUSR1 handler. */
103 static void sigusr1(void)
104 {
105 zlog_rotate();
106 }
107
108 struct frr_signal_t eigrp_signals[] = {
109 {
110 .signal = SIGHUP,
111 .handler = &sighup,
112 },
113 {
114 .signal = SIGUSR1,
115 .handler = &sigusr1,
116 },
117 {
118 .signal = SIGINT,
119 .handler = &sigint,
120 },
121 {
122 .signal = SIGTERM,
123 .handler = &sigint,
124 },
125 };
126
127 static const struct frr_yang_module_info *const eigrpd_yang_modules[] = {
128 &frr_eigrpd_info,
129 &frr_filter_info,
130 &frr_interface_info,
131 &frr_route_map_info,
132 &frr_vrf_info,
133 };
134
135 FRR_DAEMON_INFO(eigrpd, EIGRP, .vty_port = EIGRP_VTY_PORT,
136
137 .proghelp = "Implementation of the EIGRP routing protocol.",
138
139 .signals = eigrp_signals,
140 .n_signals = array_size(eigrp_signals),
141
142 .privs = &eigrpd_privs, .yang_modules = eigrpd_yang_modules,
143 .n_yang_modules = array_size(eigrpd_yang_modules),
144 );
145
146 /* EIGRPd main routine. */
147 int main(int argc, char **argv, char **envp)
148 {
149 frr_preinit(&eigrpd_di, argc, argv);
150 frr_opt_add("", longopts, "");
151
152 while (1) {
153 int opt;
154
155 opt = frr_getopt(argc, argv, NULL);
156
157 if (opt == EOF)
158 break;
159
160 switch (opt) {
161 case 0:
162 break;
163 default:
164 frr_help_exit(1);
165 }
166 }
167
168 eigrp_sw_version_initialize();
169
170 /* EIGRP master init. */
171 eigrp_master_init();
172 eigrp_om->master = frr_init();
173 master = eigrp_om->master;
174
175 eigrp_error_init();
176 eigrp_vrf_init();
177 vrf_init(NULL, NULL, NULL, NULL);
178
179 /*EIGRPd init*/
180 eigrp_if_init();
181 eigrp_zebra_init();
182 eigrp_debug_init();
183
184 /* Get configuration file. */
185 /* EIGRP VTY inits */
186 eigrp_vty_init();
187 keychain_init();
188 eigrp_vty_show_init();
189 eigrp_cli_init();
190
191 #ifdef HAVE_SNMP
192 eigrp_snmp_init();
193 #endif /* HAVE_SNMP */
194
195 /* Access list install. */
196 access_list_init();
197 access_list_add_hook(eigrp_distribute_update_all_wrapper);
198 access_list_delete_hook(eigrp_distribute_update_all_wrapper);
199
200 /* Prefix list initialize.*/
201 prefix_list_init();
202 prefix_list_add_hook(eigrp_distribute_update_all);
203 prefix_list_delete_hook(eigrp_distribute_update_all);
204
205 /*
206 * XXX: This is just to get the CLI installed to suppress VTYSH errors.
207 * Routemaps in EIGRP are not yet functional.
208 */
209 route_map_init();
210 /*eigrp_route_map_init();
211 route_map_add_hook (eigrp_rmap_update);
212 route_map_delete_hook (eigrp_rmap_update);*/
213 /*if_rmap_init (EIGRP_NODE); */
214
215 frr_config_fork();
216 frr_run(master);
217
218 /* Not reached. */
219 return 0;
220 }