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.
20 #include "memory_vty.h"
27 DEFINE_MGROUP(NHRPD
, "NHRP")
29 unsigned int debug_flags
= 0;
31 struct thread_master
*master
;
32 struct timeval current_time
;
35 struct option longopts
[] = {
39 /* nhrpd privileges */
40 static zebra_capabilities_t _caps_p
[] = {
43 ZCAP_DAC_OVERRIDE
, /* for now needed to write to /proc/sys/net/ipv4/<if>/send_redirect */
46 static struct zebra_privs_t nhrpd_privs
= {
47 #if defined(FRR_USER) && defined(FRR_GROUP)
52 .vty_group
= VTY_GROUP
,
55 .cap_num_p
= ZEBRA_NUM_OF(_caps_p
),
58 static void parse_arguments(int argc
, char **argv
)
63 opt
= frr_getopt(argc
, argv
, 0);
76 static void nhrp_sigusr1(void)
81 static void nhrp_request_stop(void)
83 debugf(NHRP_DEBUG_COMMON
, "Exiting...");
85 nhrp_shortcut_terminate();
87 nhrp_zebra_terminate();
92 /* memory_terminate(); */
93 /* vty_terminate(); */
95 /* signal_terminate(); */
96 zprivs_terminate(&nhrpd_privs
);
98 debugf(NHRP_DEBUG_COMMON
, "Done.");
105 static struct quagga_signal_t sighandlers
[] = {
106 { .signal
= SIGUSR1
, .handler
= &nhrp_sigusr1
, },
107 { .signal
= SIGINT
, .handler
= &nhrp_request_stop
, },
108 { .signal
= SIGTERM
, .handler
= &nhrp_request_stop
, },
111 FRR_DAEMON_INFO(nhrpd
, NHRP
,
112 .vty_port
= NHRP_VTY_PORT
,
114 .proghelp
= "Implementation of the NHRP routing protocol.",
116 .signals
= sighandlers
,
117 .n_signals
= array_size(sighandlers
),
119 .privs
= &nhrpd_privs
,
122 int main(int argc
, char **argv
)
124 frr_preinit(&nhrpd_di
, argc
, argv
);
125 frr_opt_add("", longopts
, "");
127 parse_arguments(argc
, argv
);
131 nhrp_interface_init();
132 vrf_init(NULL
, NULL
, NULL
, NULL
);
135 /* Run with elevated capabilities, as for all netlink activity
136 * we need privileges anyway. */
137 nhrpd_privs
.change(ZPRIVS_RAISE
);
145 nhrp_shortcut_init();