]>
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 | * | |
27 | * You should have received a copy of the GNU General Public License | |
28 | * along with GNU Zebra; see the file COPYING. If not, write to the Free | |
29 | * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA | |
30 | * 02111-1307, USA. | |
31 | */ | |
32 | #include <zebra.h> | |
33 | ||
34 | #include <lib/version.h> | |
35 | #include "getopt.h" | |
36 | #include "thread.h" | |
37 | #include "prefix.h" | |
38 | #include "linklist.h" | |
39 | #include "if.h" | |
40 | #include "vector.h" | |
41 | #include "vty.h" | |
42 | #include "command.h" | |
43 | #include "filter.h" | |
44 | #include "plist.h" | |
45 | #include "stream.h" | |
46 | #include "log.h" | |
47 | #include "memory.h" | |
48 | #include "privs.h" | |
49 | #include "sigevent.h" | |
50 | #include "zclient.h" | |
51 | #include "keychain.h" | |
52 | #include "distribute.h" | |
53 | #include "libfrr.h" | |
54 | //#include "routemap.h" | |
55 | //#include "if_rmap.h" | |
56 | ||
57 | #include "eigrpd/eigrp_structs.h" | |
58 | #include "eigrpd/eigrpd.h" | |
59 | #include "eigrpd/eigrp_dump.h" | |
60 | #include "eigrpd/eigrp_interface.h" | |
61 | #include "eigrpd/eigrp_neighbor.h" | |
62 | #include "eigrpd/eigrp_packet.h" | |
63 | #include "eigrpd/eigrp_vty.h" | |
64 | #include "eigrpd/eigrp_zebra.h" | |
65 | #include "eigrpd/eigrp_network.h" | |
66 | #include "eigrpd/eigrp_snmp.h" | |
67 | #include "eigrpd/eigrp_filter.h" | |
68 | //#include "eigrpd/eigrp_routemap.h" | |
69 | ||
70 | /* eigprd privileges */ | |
71 | zebra_capabilities_t _caps_p [] = | |
72 | { | |
73 | ZCAP_NET_RAW, | |
74 | ZCAP_BIND, | |
75 | ZCAP_NET_ADMIN, | |
76 | }; | |
77 | ||
78 | struct zebra_privs_t eigrpd_privs = | |
79 | { | |
80 | #if defined (FRR_USER) && defined (FRR_GROUP) | |
81 | .user = FRR_USER, | |
82 | .group = FRR_GROUP, | |
83 | #endif | |
84 | #if defined (VTY_GROUP) | |
85 | .vty_group = VTY_GROUP, | |
86 | #endif | |
87 | .caps_p = _caps_p, | |
88 | .cap_num_p = array_size (_caps_p), | |
89 | .cap_num_i = 0 | |
90 | }; | |
91 | ||
92 | /* EIGRPd options. */ | |
93 | struct option longopts[] = | |
f9e5c9ca DS |
94 | { |
95 | { 0 } | |
96 | }; | |
7f57883e DS |
97 | |
98 | /* Master of threads. */ | |
99 | struct thread_master *master; | |
100 | ||
101 | /* SIGHUP handler. */ | |
102 | static void | |
103 | sighup (void) | |
104 | { | |
105 | zlog_info ("SIGHUP received"); | |
106 | } | |
107 | ||
108 | /* SIGINT / SIGTERM handler. */ | |
109 | static void | |
110 | sigint (void) | |
111 | { | |
112 | zlog_notice ("Terminating on signal"); | |
113 | eigrp_terminate (); | |
114 | } | |
115 | ||
116 | /* SIGUSR1 handler. */ | |
117 | static void | |
118 | sigusr1 (void) | |
119 | { | |
120 | zlog_rotate (); | |
121 | } | |
122 | ||
123 | struct quagga_signal_t eigrp_signals[] = | |
124 | { | |
125 | { | |
126 | .signal = SIGHUP, | |
127 | .handler = &sighup, | |
128 | }, | |
129 | { | |
130 | .signal = SIGUSR1, | |
131 | .handler = &sigusr1, | |
132 | }, | |
133 | { | |
134 | .signal = SIGINT, | |
135 | .handler = &sigint, | |
136 | }, | |
137 | { | |
138 | .signal = SIGTERM, | |
139 | .handler = &sigint, | |
140 | }, | |
141 | }; | |
142 | ||
143 | FRR_DAEMON_INFO(eigrpd, EIGRP, | |
144 | .vty_port = EIGRP_VTY_PORT, | |
145 | ||
146 | .proghelp = "Implementation of the EIGRP routing protocol.", | |
147 | ||
148 | .signals = eigrp_signals, | |
149 | .n_signals = array_size(eigrp_signals), | |
150 | ||
151 | .privs = &eigrpd_privs, | |
152 | ) | |
153 | ||
154 | /* EIGRPd main routine. */ | |
155 | int | |
156 | main (int argc, char **argv, char **envp) | |
157 | { | |
158 | frr_preinit (&eigrpd_di, argc, argv); | |
159 | frr_opt_add ("", longopts, ""); | |
160 | ||
161 | while (1) | |
162 | { | |
163 | int opt; | |
164 | ||
165 | opt = frr_getopt (argc, argv, NULL); | |
166 | ||
167 | if (opt == EOF) | |
168 | break; | |
169 | ||
170 | switch (opt) | |
171 | { | |
172 | case 0: | |
173 | break; | |
174 | default: | |
175 | frr_help_exit (1); | |
176 | break; | |
177 | } | |
178 | } | |
179 | ||
180 | /* EIGRP master init. */ | |
181 | eigrp_master_init (); | |
182 | eigrp_om->master = frr_init(); | |
183 | master = eigrp_om->master; | |
184 | ||
185 | vrf_init (); | |
186 | ||
187 | /*EIGRPd init*/ | |
188 | eigrp_if_init (); | |
189 | eigrp_zebra_init (); | |
190 | eigrp_debug_init (); | |
191 | ||
192 | /* Get configuration file. */ | |
193 | /* EIGRP VTY inits */ | |
194 | eigrp_vty_init (); | |
195 | keychain_init(); | |
196 | eigrp_vty_show_init (); | |
197 | eigrp_vty_if_init (); | |
198 | ||
199 | #ifdef HAVE_SNMP | |
200 | eigrp_snmp_init (); | |
201 | #endif /* HAVE_SNMP */ | |
202 | ||
203 | /* Access list install. */ | |
204 | access_list_init (); | |
205 | access_list_add_hook (eigrp_distribute_update_all_wrapper); | |
206 | access_list_delete_hook (eigrp_distribute_update_all_wrapper); | |
207 | ||
208 | /* Prefix list initialize.*/ | |
209 | prefix_list_init (); | |
210 | prefix_list_add_hook (eigrp_distribute_update_all); | |
211 | prefix_list_delete_hook (eigrp_distribute_update_all); | |
212 | ||
213 | /*eigrp_route_map_init(); | |
f9e5c9ca DS |
214 | route_map_add_hook (eigrp_rmap_update); |
215 | route_map_delete_hook (eigrp_rmap_update);*/ | |
7f57883e | 216 | /*if_rmap_init (EIGRP_NODE); |
f9e5c9ca DS |
217 | if_rmap_hook_add (eigrp_if_rmap_update); |
218 | if_rmap_hook_delete (eigrp_if_rmap_update);*/ | |
7f57883e DS |
219 | |
220 | /* Distribute list install. */ | |
221 | distribute_list_init (EIGRP_NODE); | |
222 | distribute_list_add_hook (eigrp_distribute_update); | |
223 | distribute_list_delete_hook (eigrp_distribute_update); | |
224 | ||
225 | frr_config_fork (); | |
226 | frr_run(master); | |
227 | ||
228 | /* Not reached. */ | |
229 | return (0); | |
230 | ||
231 | } |