2 * Copyright (C) 1999 Yasuhiro Ohara
4 * This file is part of GNU Zebra.
6 * GNU Zebra is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation; either version 2, or (at your option) any
11 * GNU Zebra is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
16 * You should have received a copy of the GNU General Public License along
17 * with this program; see the file COPYING; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22 #include <lib/version.h>
43 #include "ospf6_top.h"
44 #include "ospf6_message.h"
45 #include "ospf6_network.h"
46 #include "ospf6_asbr.h"
47 #include "ospf6_lsa.h"
48 #include "ospf6_interface.h"
49 #include "ospf6_zebra.h"
50 #include "ospf6_routemap_nb.h"
52 /* Default configuration file name for ospf6d. */
53 #define OSPF6_DEFAULT_CONFIG "ospf6d.conf"
55 /* Default port values. */
56 #define OSPF6_VTY_PORT 2606
58 /* ospf6d privileges */
59 zebra_capabilities_t _caps_p
[] = {ZCAP_NET_RAW
, ZCAP_BIND
, ZCAP_SYS_ADMIN
};
61 struct zebra_privs_t ospf6d_privs
= {
69 .vty_group
= VTY_GROUP
,
72 .cap_num_p
= array_size(_caps_p
),
75 /* ospf6d options, we use GNU getopt library. */
76 struct option longopts
[] = {{0}};
78 /* Master of threads. */
79 struct thread_master
*master
;
81 static void __attribute__((noreturn
)) ospf6_exit(int status
)
84 struct interface
*ifp
;
86 struct listnode
*node
, *nnode
;
90 for (ALL_LIST_ELEMENTS(om6
->ospf6
, node
, nnode
, ospf6
)) {
91 vrf
= vrf_lookup_by_id(ospf6
->vrf_id
);
94 FOR_ALL_INTERFACES (vrf
, ifp
)
95 if (ifp
->info
!= NULL
)
96 ospf6_interface_delete(ifp
->info
);
102 ospf6_message_terminate();
103 ospf6_asbr_terminate();
104 ospf6_lsa_terminate();
106 /* reverse access_list_init */
109 /* reverse prefix_list_init */
110 prefix_list_add_hook(NULL
);
111 prefix_list_delete_hook(NULL
);
117 zclient_stop(zclient
);
118 zclient_free(zclient
);
125 /* SIGHUP handler. */
126 static void sighup(void)
128 zlog_info("SIGHUP received");
131 /* SIGINT handler. */
132 static void sigint(void)
134 zlog_notice("Terminating on signal SIGINT");
138 /* SIGTERM handler. */
139 static void sigterm(void)
141 zlog_notice("Terminating on signal SIGTERM");
145 /* SIGUSR1 handler. */
146 static void sigusr1(void)
148 zlog_info("SIGUSR1 received");
152 struct quagga_signal_t ospf6_signals
[] = {
171 static const struct frr_yang_module_info
*const ospf6d_yang_modules
[] = {
176 &frr_ospf_route_map_info
,
177 &frr_ospf6_route_map_info
,
180 FRR_DAEMON_INFO(ospf6d
, OSPF6
, .vty_port
= OSPF6_VTY_PORT
,
182 .proghelp
= "Implementation of the OSPFv3 routing protocol.",
184 .signals
= ospf6_signals
,
185 .n_signals
= array_size(ospf6_signals
),
187 .privs
= &ospf6d_privs
, .yang_modules
= ospf6d_yang_modules
,
188 .n_yang_modules
= array_size(ospf6d_yang_modules
),
191 /* Main routine of ospf6d. Treatment of argument and starting ospf finite
192 state machine is handled here. */
193 int main(int argc
, char *argv
[], char *envp
[])
197 frr_preinit(&ospf6d_di
, argc
, argv
);
198 frr_opt_add("", longopts
, "");
200 /* Command line argument treatment. */
202 opt
= frr_getopt(argc
, argv
, NULL
);
216 if (geteuid() != 0) {
218 perror(ospf6d_di
.progname
);
222 /* OSPF6 master init. */
223 ospf6_master_init(frr_init());
226 master
= om6
->master
;
228 vrf_init(NULL
, NULL
, NULL
, NULL
, NULL
);
232 /* initialize ospf6 */