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
18 * along with GNU Zebra; see the file COPYING. If not, write to the Free
19 * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
25 #include <lib/version.h>
39 #include "memory_vty.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_zebra.h"
54 #include "ospfd/ospf_vty.h"
55 #include "ospfd/ospf_bfd.h"
57 /* ospfd privileges */
58 zebra_capabilities_t _caps_p
[] =
65 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
),
80 struct option longopts
[] =
82 { "instance", required_argument
, NULL
, 'n'},
83 { "apiserver", no_argument
, NULL
, 'a'},
87 /* OSPFd program name */
89 /* Master of threads. */
90 struct thread_master
*master
;
92 #ifdef SUPPORT_OSPF_API
93 extern int ospf_apiserver_enable
;
94 #endif /* SUPPORT_OSPF_API */
100 zlog_info("SIGHUP received");
103 /* SIGINT / SIGTERM handler. */
107 zlog_notice ("Terminating on signal");
111 /* SIGUSR1 handler. */
118 struct quagga_signal_t ospf_signals
[] =
138 FRR_DAEMON_INFO(ospfd
, OSPF
,
139 .vty_port
= OSPF_VTY_PORT
,
141 .proghelp
= "Implementation of the OSPFv2 routing protocol.",
143 .signals
= ospf_signals
,
144 .n_signals
= array_size(ospf_signals
),
146 .privs
= &ospfd_privs
,
149 /* OSPFd main routine. */
151 main (int argc
, char **argv
)
153 u_short instance
= 0;
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");
169 opt
= frr_getopt (argc
, argv
, NULL
);
177 ospfd_di
.instance
= instance
= atoi(optarg
);
183 #ifdef SUPPORT_OSPF_API
185 ospf_apiserver_enable
= 1;
187 #endif /* SUPPORT_OSPF_API */
194 /* Invoked by a priviledged user? -- endo. */
198 perror (ospfd_di
.progname
);
202 /* OSPF master init. */
203 ospf_master_init (frr_init ());
205 /* Initializations. */
217 ospf_zebra_init(master
, instance
);
219 /* OSPF vty inits. */
221 ospf_vty_show_init ();
222 ospf_vty_clear_init ();
227 ospf_route_map_init ();
230 /* Need to initialize the default ospf structure, so the interface mode
231 commands can be duly processed if they are received before 'router ospf',
232 when quagga(ospfd) is restarted */
233 if (!ospf_get_instance(instance
))
235 zlog_err("OSPF instance init failed: %s", strerror(errno
));