]> git.proxmox.com Git - mirror_frr.git/blob - ripngd/ripng_main.c
Merge pull request #12863 from sri-mohan1/sri-mohan-ldp
[mirror_frr.git] / ripngd / ripng_main.c
1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /*
3 * RIPngd main routine.
4 * Copyright (C) 1998, 1999 Kunihiro Ishiguro
5 */
6
7 #include <zebra.h>
8
9 #include <lib/version.h>
10 #include "getopt.h"
11 #include "vector.h"
12 #include "vty.h"
13 #include "command.h"
14 #include "memory.h"
15 #include "thread.h"
16 #include "log.h"
17 #include "prefix.h"
18 #include "if.h"
19 #include "privs.h"
20 #include "sigevent.h"
21 #include "vrf.h"
22 #include "if_rmap.h"
23 #include "libfrr.h"
24 #include "routemap.h"
25
26 #include "ripngd/ripngd.h"
27 #include "ripngd/ripng_nb.h"
28
29 /* RIPngd options. */
30 struct option longopts[] = {{0}};
31
32 /* ripngd privileges */
33 zebra_capabilities_t _caps_p[] = {ZCAP_NET_RAW, ZCAP_BIND, ZCAP_SYS_ADMIN};
34
35 struct zebra_privs_t ripngd_privs = {
36 #if defined(FRR_USER)
37 .user = FRR_USER,
38 #endif
39 #if defined FRR_GROUP
40 .group = FRR_GROUP,
41 #endif
42 #ifdef VTY_GROUP
43 .vty_group = VTY_GROUP,
44 #endif
45 .caps_p = _caps_p,
46 .cap_num_p = array_size(_caps_p),
47 .cap_num_i = 0};
48
49
50 /* Master of threads. */
51 struct thread_master *master;
52
53 static struct frr_daemon_info ripngd_di;
54
55 /* SIGHUP handler. */
56 static void sighup(void)
57 {
58 zlog_info("SIGHUP received");
59
60 /* Reload config file. */
61 vty_read_config(NULL, ripngd_di.config_file, config_default);
62 }
63
64 /* SIGINT handler. */
65 static void sigint(void)
66 {
67 zlog_notice("Terminating on signal");
68
69 ripng_vrf_terminate();
70 if_rmap_terminate();
71 ripng_zebra_stop();
72 frr_fini();
73 exit(0);
74 }
75
76 /* SIGUSR1 handler. */
77 static void sigusr1(void)
78 {
79 zlog_rotate();
80 }
81
82 struct frr_signal_t ripng_signals[] = {
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 };
100
101 static const struct frr_yang_module_info *const ripngd_yang_modules[] = {
102 &frr_filter_info,
103 &frr_interface_info,
104 &frr_ripngd_info,
105 &frr_route_map_info,
106 &frr_vrf_info,
107 };
108
109 FRR_DAEMON_INFO(ripngd, RIPNG, .vty_port = RIPNG_VTY_PORT,
110
111 .proghelp = "Implementation of the RIPng routing protocol.",
112
113 .signals = ripng_signals,
114 .n_signals = array_size(ripng_signals),
115
116 .privs = &ripngd_privs,
117
118 .yang_modules = ripngd_yang_modules,
119 .n_yang_modules = array_size(ripngd_yang_modules),
120 );
121
122 #define DEPRECATED_OPTIONS ""
123
124 /* RIPngd main routine. */
125 int main(int argc, char **argv)
126 {
127 frr_preinit(&ripngd_di, argc, argv);
128
129 frr_opt_add("" DEPRECATED_OPTIONS, longopts, "");
130
131 while (1) {
132 int opt;
133
134 opt = frr_getopt(argc, argv, NULL);
135
136 if (opt && opt < 128 && strchr(DEPRECATED_OPTIONS, opt)) {
137 fprintf(stderr,
138 "The -%c option no longer exists.\nPlease refer to the manual.\n",
139 opt);
140 continue;
141 }
142
143 if (opt == EOF)
144 break;
145
146 switch (opt) {
147 case 0:
148 break;
149 default:
150 frr_help_exit(1);
151 }
152 }
153
154 master = frr_init();
155
156 /* Library inits. */
157 ripng_vrf_init();
158
159 /* RIPngd inits. */
160 ripng_init();
161 ripng_cli_init();
162 zebra_init(master);
163
164 frr_config_fork();
165 frr_run(master);
166
167 /* Not reached. */
168 return 0;
169 }