3 * Copyright (C) 1998, 99 Kunihiro Ishiguro, Toshiaki Takada
5 * This file is part of GNU Zebra.
7 * GNU Zebra is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the
9 * Free Software Foundation; either version 2, or (at your option) any
12 * GNU Zebra is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
17 * You should have received a copy of the GNU General Public License along
18 * with this program; see the file COPYING; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
24 #include <lib/version.h>
46 #include "ospfd/ospfd.h"
47 #include "ospfd/ospf_interface.h"
48 #include "ospfd/ospf_asbr.h"
49 #include "ospfd/ospf_lsa.h"
50 #include "ospfd/ospf_lsdb.h"
51 #include "ospfd/ospf_neighbor.h"
52 #include "ospfd/ospf_dump.h"
53 #include "ospfd/ospf_route.h"
54 #include "ospfd/ospf_zebra.h"
55 #include "ospfd/ospf_vty.h"
56 #include "ospfd/ospf_bfd.h"
57 #include "ospfd/ospf_gr.h"
58 #include "ospfd/ospf_errors.h"
59 #include "ospfd/ospf_ldp_sync.h"
60 #include "ospfd/ospf_routemap_nb.h"
62 /* ospfd privileges */
63 zebra_capabilities_t _caps_p
[] = {ZCAP_NET_RAW
, ZCAP_BIND
, ZCAP_NET_ADMIN
,
66 struct zebra_privs_t ospfd_privs
= {
67 #if defined(FRR_USER) && defined(FRR_GROUP)
71 #if defined(VTY_GROUP)
72 .vty_group
= VTY_GROUP
,
75 .cap_num_p
= array_size(_caps_p
),
79 const struct option longopts
[] = {
80 {"instance", required_argument
, NULL
, 'n'},
81 {"apiserver", no_argument
, NULL
, 'a'},
85 /* OSPFd program name */
87 /* Master of threads. */
88 struct thread_master
*master
;
90 #ifdef SUPPORT_OSPF_API
91 extern int ospf_apiserver_enable
;
92 #endif /* SUPPORT_OSPF_API */
95 static void sighup(void)
97 zlog_info("SIGHUP received");
100 /* SIGINT / SIGTERM handler. */
101 static void sigint(void)
103 zlog_notice("Terminating on signal");
104 bfd_protocol_integration_set_shutdown(true);
109 /* SIGUSR1 handler. */
110 static void sigusr1(void)
115 struct frr_signal_t ospf_signals
[] = {
134 static const struct frr_yang_module_info
*const ospfd_yang_modules
[] = {
139 &frr_ospf_route_map_info
,
142 FRR_DAEMON_INFO(ospfd
, OSPF
, .vty_port
= OSPF_VTY_PORT
,
144 .proghelp
= "Implementation of the OSPFv2 routing protocol.",
146 .signals
= ospf_signals
, .n_signals
= array_size(ospf_signals
),
148 .privs
= &ospfd_privs
, .yang_modules
= ospfd_yang_modules
,
149 .n_yang_modules
= array_size(ospfd_yang_modules
),
152 /* OSPFd main routine. */
153 int main(int argc
, char **argv
)
155 #ifdef SUPPORT_OSPF_API
156 /* OSPF apiserver is disabled by default. */
157 ospf_apiserver_enable
= 0;
158 #endif /* SUPPORT_OSPF_API */
160 frr_preinit(&ospfd_di
, argc
, argv
);
161 frr_opt_add("n:a", longopts
,
162 " -n, --instance Set the instance id\n"
163 " -a, --apiserver Enable OSPF apiserver\n");
168 opt
= frr_getopt(argc
, argv
, NULL
);
175 ospfd_di
.instance
= ospf_instance
= atoi(optarg
);
176 if (ospf_instance
< 1)
181 #ifdef SUPPORT_OSPF_API
183 ospf_apiserver_enable
= 1;
185 #endif /* SUPPORT_OSPF_API */
191 /* Invoked by a priviledged user? -- endo. */
192 if (geteuid() != 0) {
194 perror(ospfd_di
.progname
);
198 /* OSPF master init. */
199 ospf_master_init(frr_init());
201 /* Initializations. */
213 ospf_zebra_init(master
, ospf_instance
);
215 /* OSPF vty inits. */
217 ospf_vty_show_init();
218 ospf_vty_clear_init();
221 ospf_bfd_init(master
);
223 /* OSPF LDP IGP Sync init */
224 ospf_ldp_sync_init();
226 ospf_route_map_init();
229 ospf_gr_helper_init();
231 /* OSPF errors init */