1 /* NHRP daemon main functions
2 * Copyright (c) 2014-2015 Timo Teräs
4 * This file is free software: you may copy, redistribute and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 2 of the License, or
7 * (at your option) any later version.
24 #include "memory_vty.h"
30 #include "nhrp_errors.h"
32 DEFINE_MGROUP(NHRPD
, "NHRP")
34 unsigned int debug_flags
= 0;
36 struct thread_master
*master
;
37 struct timeval current_time
;
40 struct option longopts
[] = {{0}};
42 /* nhrpd privileges */
43 static zebra_capabilities_t _caps_p
[] = {
44 ZCAP_NET_RAW
, ZCAP_NET_ADMIN
,
45 ZCAP_DAC_OVERRIDE
, /* for now needed to write to
46 /proc/sys/net/ipv4/<if>/send_redirect */
49 struct zebra_privs_t nhrpd_privs
= {
50 #if defined(FRR_USER) && defined(FRR_GROUP)
55 .vty_group
= VTY_GROUP
,
58 .cap_num_p
= ZEBRA_NUM_OF(_caps_p
),
61 static void parse_arguments(int argc
, char **argv
)
66 opt
= frr_getopt(argc
, argv
, 0);
80 static void nhrp_sigusr1(void)
85 static void nhrp_request_stop(void)
87 debugf(NHRP_DEBUG_COMMON
, "Exiting...");
90 nhrp_shortcut_terminate();
92 nhrp_zebra_terminate();
98 debugf(NHRP_DEBUG_COMMON
, "Done.");
104 static struct quagga_signal_t sighandlers
[] = {
107 .handler
= &nhrp_sigusr1
,
111 .handler
= &nhrp_request_stop
,
115 .handler
= &nhrp_request_stop
,
119 static const struct frr_yang_module_info
*nhrpd_yang_modules
[] = {
123 FRR_DAEMON_INFO(nhrpd
, NHRP
, .vty_port
= NHRP_VTY_PORT
,
125 .proghelp
= "Implementation of the NHRP routing protocol.",
127 .signals
= sighandlers
, .n_signals
= array_size(sighandlers
),
129 .privs
= &nhrpd_privs
, .yang_modules
= nhrpd_yang_modules
,
130 .n_yang_modules
= array_size(nhrpd_yang_modules
), )
132 int main(int argc
, char **argv
)
134 frr_preinit(&nhrpd_di
, argc
, argv
);
135 frr_opt_add("", longopts
, "");
137 parse_arguments(argc
, argv
);
142 vrf_init(NULL
, NULL
, NULL
, NULL
, NULL
);
143 nhrp_interface_init();
146 /* Run with elevated capabilities, as for all netlink activity
147 * we need privileges anyway. */
148 nhrpd_privs
.change(ZPRIVS_RAISE
);
156 nhrp_shortcut_init();