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