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