]>
Commit | Line | Data |
---|---|---|
718e3744 | 1 | /* |
2 | * RIPngd main routine. | |
3 | * Copyright (C) 1998, 1999 Kunihiro Ishiguro | |
4 | * | |
5 | * This file is part of GNU Zebra. | |
6 | * | |
7 | * GNU Zebra is free software; you can redistribute it and/or modify it | |
8 | * under the terms of the GNU General Public License as published by the | |
9 | * Free Software Foundation; either version 2, or (at your option) any | |
10 | * later version. | |
11 | * | |
12 | * GNU Zebra is distributed in the hope that it will be useful, but | |
13 | * WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
15 | * General Public License for more details. | |
16 | * | |
896014f4 DL |
17 | * You should have received a copy of the GNU General Public License along |
18 | * with this program; see the file COPYING; if not, write to the Free Software | |
19 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | |
718e3744 | 20 | */ |
21 | ||
22 | #include <zebra.h> | |
23 | ||
5e4fa164 | 24 | #include <lib/version.h> |
718e3744 | 25 | #include "getopt.h" |
26 | #include "vector.h" | |
27 | #include "vty.h" | |
28 | #include "command.h" | |
a94434b6 | 29 | #include "memory.h" |
fc7948fa | 30 | #include "memory_vty.h" |
718e3744 | 31 | #include "thread.h" |
32 | #include "log.h" | |
33 | #include "prefix.h" | |
34 | #include "if.h" | |
edd7c245 | 35 | #include "privs.h" |
2d75d052 | 36 | #include "sigevent.h" |
6a69b354 | 37 | #include "vrf.h" |
8f88441d | 38 | #include "if_rmap.h" |
4f04a76b | 39 | #include "libfrr.h" |
718e3744 | 40 | |
41 | #include "ripngd/ripngd.h" | |
42 | ||
718e3744 | 43 | /* RIPngd options. */ |
c8dde10f QY |
44 | #if CONFDATE > 20190521 |
45 | CPP_NOTICE("-r / --retain has reached deprecation EOL, remove") | |
46 | #endif | |
d62a17ae | 47 | struct option longopts[] = {{"retain", no_argument, NULL, 'r'}, {0}}; |
718e3744 | 48 | |
edd7c245 | 49 | /* ripngd privileges */ |
dde7b15b | 50 | zebra_capabilities_t _caps_p[] = {ZCAP_NET_RAW, ZCAP_BIND, ZCAP_SYS_ADMIN}; |
edd7c245 | 51 | |
d62a17ae | 52 | struct zebra_privs_t ripngd_privs = { |
b2f36157 | 53 | #if defined(FRR_USER) |
d62a17ae | 54 | .user = FRR_USER, |
edd7c245 | 55 | #endif |
b2f36157 | 56 | #if defined FRR_GROUP |
d62a17ae | 57 | .group = FRR_GROUP, |
d81fadfd | 58 | #endif |
59 | #ifdef VTY_GROUP | |
d62a17ae | 60 | .vty_group = VTY_GROUP, |
edd7c245 | 61 | #endif |
d62a17ae | 62 | .caps_p = _caps_p, |
dde7b15b | 63 | .cap_num_p = array_size(_caps_p), |
d62a17ae | 64 | .cap_num_i = 0}; |
edd7c245 | 65 | |
66 | ||
718e3744 | 67 | /* Master of threads. */ |
68 | struct thread_master *master; | |
69 | ||
eb05883f | 70 | static struct frr_daemon_info ripngd_di; |
718e3744 | 71 | |
718e3744 | 72 | /* SIGHUP handler. */ |
d62a17ae | 73 | static void sighup(void) |
718e3744 | 74 | { |
d62a17ae | 75 | zlog_info("SIGHUP received"); |
a94434b6 | 76 | |
d62a17ae | 77 | /* Reload config file. */ |
1c2facd1 | 78 | vty_read_config(NULL, ripngd_di.config_file, config_default); |
718e3744 | 79 | } |
80 | ||
81 | /* SIGINT handler. */ | |
d62a17ae | 82 | static void sigint(void) |
718e3744 | 83 | { |
d62a17ae | 84 | zlog_notice("Terminating on signal"); |
718e3744 | 85 | |
dde7b15b | 86 | ripng_vrf_terminate(); |
8f88441d | 87 | if_rmap_terminate(); |
d62a17ae | 88 | ripng_zebra_stop(); |
8879bd22 | 89 | frr_fini(); |
d62a17ae | 90 | exit(0); |
718e3744 | 91 | } |
92 | ||
93 | /* SIGUSR1 handler. */ | |
d62a17ae | 94 | static void sigusr1(void) |
718e3744 | 95 | { |
d62a17ae | 96 | zlog_rotate(); |
718e3744 | 97 | } |
98 | ||
d62a17ae | 99 | struct quagga_signal_t ripng_signals[] = { |
100 | { | |
101 | .signal = SIGHUP, | |
102 | .handler = &sighup, | |
103 | }, | |
104 | { | |
105 | .signal = SIGUSR1, | |
106 | .handler = &sigusr1, | |
107 | }, | |
108 | { | |
109 | .signal = SIGINT, | |
110 | .handler = &sigint, | |
111 | }, | |
112 | { | |
113 | .signal = SIGTERM, | |
114 | .handler = &sigint, | |
115 | }, | |
2d75d052 | 116 | }; |
6b0655a2 | 117 | |
8fcdd0d6 | 118 | static const struct frr_yang_module_info *ripngd_yang_modules[] = { |
a4bed468 | 119 | &frr_interface_info, |
e9ce224b | 120 | &frr_ripngd_info, |
8fcdd0d6 RW |
121 | }; |
122 | ||
d62a17ae | 123 | FRR_DAEMON_INFO(ripngd, RIPNG, .vty_port = RIPNG_VTY_PORT, |
4f04a76b | 124 | |
d62a17ae | 125 | .proghelp = "Implementation of the RIPng routing protocol.", |
4f04a76b | 126 | |
d62a17ae | 127 | .signals = ripng_signals, |
128 | .n_signals = array_size(ripng_signals), | |
4f04a76b | 129 | |
8fcdd0d6 RW |
130 | .privs = &ripngd_privs, |
131 | ||
132 | .yang_modules = ripngd_yang_modules, | |
133 | .n_yang_modules = array_size(ripngd_yang_modules), ) | |
4f04a76b | 134 | |
c8dde10f QY |
135 | #if CONFDATE > 20190521 |
136 | CPP_NOTICE("-r / --retain has reached deprecation EOL, remove") | |
137 | #endif | |
138 | #define DEPRECATED_OPTIONS "r" | |
139 | ||
718e3744 | 140 | /* RIPngd main routine. */ |
d62a17ae | 141 | int main(int argc, char **argv) |
718e3744 | 142 | { |
d62a17ae | 143 | frr_preinit(&ripngd_di, argc, argv); |
c8dde10f QY |
144 | |
145 | frr_opt_add("" DEPRECATED_OPTIONS, longopts, ""); | |
d62a17ae | 146 | |
147 | while (1) { | |
148 | int opt; | |
149 | ||
150 | opt = frr_getopt(argc, argv, NULL); | |
151 | ||
c8dde10f QY |
152 | if (opt && opt < 128 && strchr(DEPRECATED_OPTIONS, opt)) { |
153 | fprintf(stderr, | |
154 | "The -%c option no longer exists.\nPlease refer to the manual.\n", | |
155 | opt); | |
156 | continue; | |
157 | } | |
158 | ||
d62a17ae | 159 | if (opt == EOF) |
160 | break; | |
161 | ||
162 | switch (opt) { | |
163 | case 0: | |
164 | break; | |
d62a17ae | 165 | default: |
166 | frr_help_exit(1); | |
167 | break; | |
168 | } | |
718e3744 | 169 | } |
718e3744 | 170 | |
d62a17ae | 171 | master = frr_init(); |
718e3744 | 172 | |
d62a17ae | 173 | /* Library inits. */ |
dde7b15b | 174 | ripng_vrf_init(); |
718e3744 | 175 | |
d62a17ae | 176 | /* RIPngd inits. */ |
177 | ripng_init(); | |
e9ce224b | 178 | ripng_cli_init(); |
d62a17ae | 179 | zebra_init(master); |
a94434b6 | 180 | |
d62a17ae | 181 | frr_config_fork(); |
182 | frr_run(master); | |
718e3744 | 183 | |
d62a17ae | 184 | /* Not reached. */ |
185 | return 0; | |
718e3744 | 186 | } |