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"
26 #include "nhrp_errors.h"
28 DEFINE_MGROUP(NHRPD
, "NHRP")
30 unsigned int debug_flags
= 0;
32 struct thread_master
*master
;
33 struct timeval current_time
;
36 struct option longopts
[] = {{0}};
38 /* nhrpd privileges */
39 static zebra_capabilities_t _caps_p
[] = {
40 ZCAP_NET_RAW
, ZCAP_NET_ADMIN
,
41 ZCAP_DAC_OVERRIDE
, /* for now needed to write to
42 /proc/sys/net/ipv4/<if>/send_redirect */
45 struct zebra_privs_t nhrpd_privs
= {
46 #if defined(FRR_USER) && defined(FRR_GROUP)
51 .vty_group
= VTY_GROUP
,
54 .cap_num_p
= ZEBRA_NUM_OF(_caps_p
),
57 static void parse_arguments(int argc
, char **argv
)
62 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...");
86 nhrp_shortcut_terminate();
88 nhrp_zebra_terminate();
94 debugf(NHRP_DEBUG_COMMON
, "Done.");
100 static struct quagga_signal_t sighandlers
[] = {
103 .handler
= &nhrp_sigusr1
,
107 .handler
= &nhrp_request_stop
,
111 .handler
= &nhrp_request_stop
,
115 FRR_DAEMON_INFO(nhrpd
, NHRP
, .vty_port
= NHRP_VTY_PORT
,
117 .proghelp
= "Implementation of the NHRP routing protocol.",
119 .signals
= sighandlers
, .n_signals
= array_size(sighandlers
),
121 .privs
= &nhrpd_privs
, )
123 int main(int argc
, char **argv
)
125 frr_preinit(&nhrpd_di
, argc
, argv
);
126 frr_opt_add("", longopts
, "");
128 parse_arguments(argc
, argv
);
133 vrf_init(NULL
, NULL
, NULL
, NULL
);
134 nhrp_interface_init();
137 /* Run with elevated capabilities, as for all netlink activity
138 * we need privileges anyway. */
139 nhrpd_privs
.change(ZPRIVS_RAISE
);
147 nhrp_shortcut_init();