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