]> git.proxmox.com Git - mirror_frr.git/blame - ripd/rip_main.c
Merge pull request #13374 from opensourcerouting/build-fix-rmap-yang
[mirror_frr.git] / ripd / rip_main.c
CommitLineData
acddc0ed 1// SPDX-License-Identifier: GPL-2.0-or-later
718e3744 2/* RIPd main routine.
3 * Copyright (C) 1997, 98 Kunihiro Ishiguro <kunihiro@zebra.org>
718e3744 4 */
5
6#include <zebra.h>
7
5e4fa164 8#include <lib/version.h>
718e3744 9#include "getopt.h"
24a58196 10#include "frrevent.h"
718e3744 11#include "command.h"
12#include "memory.h"
13#include "prefix.h"
14#include "filter.h"
15#include "keychain.h"
16#include "log.h"
edd7c245 17#include "privs.h"
2d75d052 18#include "sigevent.h"
b5114685 19#include "zclient.h"
6a69b354 20#include "vrf.h"
8f88441d 21#include "if_rmap.h"
4f04a76b 22#include "libfrr.h"
91835f1f 23#include "routemap.h"
c262df82 24#include "bfd.h"
718e3744 25
26#include "ripd/ripd.h"
c262df82 27#include "ripd/rip_bfd.h"
f80ec39e 28#include "ripd/rip_nb.h"
518e377f 29#include "ripd/rip_errors.h"
718e3744 30
31/* ripd options. */
f28963f7 32static struct option longopts[] = {{0}};
718e3744 33
edd7c245 34/* ripd privileges */
ae7b826a 35zebra_capabilities_t _caps_p[] = {ZCAP_NET_RAW, ZCAP_BIND, ZCAP_SYS_ADMIN};
edd7c245 36
d62a17ae 37struct zebra_privs_t ripd_privs = {
b2f36157 38#if defined(FRR_USER)
d62a17ae 39 .user = FRR_USER,
edd7c245 40#endif
b2f36157 41#if defined FRR_GROUP
d62a17ae 42 .group = FRR_GROUP,
d81fadfd 43#endif
44#ifdef VTY_GROUP
d62a17ae 45 .vty_group = VTY_GROUP,
edd7c245 46#endif
d62a17ae 47 .caps_p = _caps_p,
ae7b826a 48 .cap_num_p = array_size(_caps_p),
d62a17ae 49 .cap_num_i = 0};
edd7c245 50
718e3744 51/* Master of threads. */
cd9d0537 52struct event_loop *master;
718e3744 53
eb05883f 54static struct frr_daemon_info ripd_di;
718e3744 55
718e3744 56/* SIGHUP handler. */
d62a17ae 57static void sighup(void)
718e3744 58{
d62a17ae 59 zlog_info("SIGHUP received");
718e3744 60
d62a17ae 61 /* Reload config file. */
1c2facd1 62 vty_read_config(NULL, ripd_di.config_file, config_default);
718e3744 63}
64
65/* SIGINT handler. */
d62a17ae 66static void sigint(void)
718e3744 67{
d62a17ae 68 zlog_notice("Terminating on signal");
718e3744 69
c262df82 70 bfd_protocol_integration_set_shutdown(true);
ae7b826a 71 rip_vrf_terminate();
8f88441d 72 if_rmap_terminate();
d62a17ae 73 rip_zclient_stop();
8879bd22 74 frr_fini();
a2f9eb82 75
d62a17ae 76 exit(0);
718e3744 77}
78
79/* SIGUSR1 handler. */
d62a17ae 80static void sigusr1(void)
718e3744 81{
d62a17ae 82 zlog_rotate();
718e3744 83}
84
7cc91e67 85static struct frr_signal_t ripd_signals[] = {
d62a17ae 86 {
87 .signal = SIGHUP,
88 .handler = &sighup,
89 },
90 {
91 .signal = SIGUSR1,
92 .handler = &sigusr1,
93 },
94 {
95 .signal = SIGINT,
96 .handler = &sigint,
97 },
98 {
99 .signal = SIGTERM,
100 .handler = &sigint,
101 },
102};
4f04a76b 103
0d8c7a26 104static const struct frr_yang_module_info *const ripd_yang_modules[] = {
c2aab693 105 &frr_filter_info,
a4bed468 106 &frr_interface_info,
707656ec 107 &frr_ripd_info,
91835f1f 108 &frr_route_map_info,
6fd8972a 109 &frr_vrf_info,
8fcdd0d6
RW
110};
111
d62a17ae 112FRR_DAEMON_INFO(ripd, RIP, .vty_port = RIP_VTY_PORT,
718e3744 113
d62a17ae 114 .proghelp = "Implementation of the RIP routing protocol.",
718e3744 115
d62a17ae 116 .signals = ripd_signals, .n_signals = array_size(ripd_signals),
718e3744 117
8fcdd0d6 118 .privs = &ripd_privs, .yang_modules = ripd_yang_modules,
80413c20
DL
119 .n_yang_modules = array_size(ripd_yang_modules),
120);
d62a17ae 121
f28963f7 122#define DEPRECATED_OPTIONS ""
c8dde10f 123
d62a17ae 124/* Main routine of ripd. */
125int main(int argc, char **argv)
126{
127 frr_preinit(&ripd_di, argc, argv);
c8dde10f
QY
128
129 frr_opt_add("" DEPRECATED_OPTIONS, longopts, "");
d62a17ae 130
131 /* Command line option parse. */
132 while (1) {
133 int opt;
134
135 opt = frr_getopt(argc, argv, NULL);
136
c8dde10f
QY
137 if (opt && opt < 128 && strchr(DEPRECATED_OPTIONS, opt)) {
138 fprintf(stderr,
139 "The -%c option no longer exists.\nPlease refer to the manual.\n",
140 opt);
141 continue;
142 }
143
d62a17ae 144 if (opt == EOF)
145 break;
146
147 switch (opt) {
148 case 0:
149 break;
d62a17ae 150 default:
151 frr_help_exit(1);
d62a17ae 152 }
718e3744 153 }
718e3744 154
d62a17ae 155 /* Prepare master thread. */
156 master = frr_init();
718e3744 157
d62a17ae 158 /* Library initialization. */
518e377f 159 rip_error_init();
d62a17ae 160 keychain_init();
ae7b826a 161 rip_vrf_init();
718e3744 162
d62a17ae 163 /* RIP related initialization. */
164 rip_init();
165 rip_if_init();
707656ec 166 rip_cli_init();
d62a17ae 167 rip_zclient_init(master);
c262df82 168 rip_bfd_init(master);
718e3744 169
d62a17ae 170 frr_config_fork();
171 frr_run(master);
718e3744 172
d62a17ae 173 /* Not reached. */
95f7965d 174 return 0;
718e3744 175}