]>
Commit | Line | Data |
---|---|---|
7e24fdf3 DS |
1 | /* |
2 | * STATICd - main code | |
3 | * Copyright (C) 2018 Cumulus Networks, Inc. | |
4 | * Donald Sharp | |
5 | * | |
8d5cbee9 DS |
6 | * This program 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 Free | |
8 | * Software Foundation; either version 2 of the License, or (at your option) | |
9 | * any later version. | |
7e24fdf3 | 10 | * |
8d5cbee9 DS |
11 | * This program is distributed in the hope that it will be useful, but WITHOUT |
12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | |
14 | * more details. | |
7e24fdf3 DS |
15 | * |
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 | |
19 | */ | |
20 | #include <zebra.h> | |
21 | ||
22 | #include <lib/version.h> | |
23 | #include "getopt.h" | |
24 | #include "thread.h" | |
25 | #include "command.h" | |
26 | #include "log.h" | |
27 | #include "memory.h" | |
28 | #include "privs.h" | |
29 | #include "sigevent.h" | |
30 | #include "libfrr.h" | |
31 | #include "vrf.h" | |
32 | #include "nexthop.h" | |
29348bd7 | 33 | #include "filter.h" |
7e24fdf3 DS |
34 | |
35 | #include "static_vrf.h" | |
36 | #include "static_vty.h" | |
37 | #include "static_routes.h" | |
38 | #include "static_zebra.h" | |
31ddf3b7 | 39 | #include "static_debug.h" |
7e24fdf3 | 40 | |
ad3489a0 DS |
41 | char backup_config_file[256]; |
42 | ||
7e24fdf3 DS |
43 | bool mpls_enabled; |
44 | ||
45 | zebra_capabilities_t _caps_p[] = { | |
46 | }; | |
47 | ||
48 | struct zebra_privs_t static_privs = { | |
49 | #if defined(FRR_USER) && defined(FRR_GROUP) | |
50 | .user = FRR_USER, | |
51 | .group = FRR_GROUP, | |
52 | #endif | |
53 | #if defined(VTY_GROUP) | |
54 | .vty_group = VTY_GROUP, | |
55 | #endif | |
56 | .caps_p = _caps_p, | |
57 | .cap_num_p = array_size(_caps_p), | |
58 | .cap_num_i = 0}; | |
59 | ||
60 | struct option longopts[] = { { 0 } }; | |
61 | ||
62 | /* Master of threads. */ | |
63 | struct thread_master *master; | |
64 | ||
65 | /* SIGHUP handler. */ | |
66 | static void sighup(void) | |
67 | { | |
68 | zlog_info("SIGHUP received"); | |
69 | } | |
70 | ||
71 | /* SIGINT / SIGTERM handler. */ | |
72 | static void sigint(void) | |
73 | { | |
74 | zlog_notice("Terminating on signal"); | |
75 | ||
76 | exit(0); | |
77 | } | |
78 | ||
79 | /* SIGUSR1 handler. */ | |
80 | static void sigusr1(void) | |
81 | { | |
82 | zlog_rotate(); | |
83 | } | |
84 | ||
85 | struct quagga_signal_t static_signals[] = { | |
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 | }; | |
103 | ||
0d8c7a26 | 104 | static const struct frr_yang_module_info *const staticd_yang_modules[] = { |
8fcdd0d6 RW |
105 | }; |
106 | ||
7e24fdf3 DS |
107 | #define STATIC_VTY_PORT 2616 |
108 | ||
109 | FRR_DAEMON_INFO(staticd, STATIC, .vty_port = STATIC_VTY_PORT, | |
110 | ||
111 | .proghelp = "Implementation of STATIC.", | |
112 | ||
113 | .signals = static_signals, | |
114 | .n_signals = array_size(static_signals), | |
115 | ||
8fcdd0d6 RW |
116 | .privs = &static_privs, .yang_modules = staticd_yang_modules, |
117 | .n_yang_modules = array_size(staticd_yang_modules), | |
ba86c88f | 118 | ) |
7e24fdf3 DS |
119 | |
120 | int main(int argc, char **argv, char **envp) | |
121 | { | |
122 | frr_preinit(&staticd_di, argc, argv); | |
123 | frr_opt_add("", longopts, ""); | |
124 | ||
125 | while (1) { | |
126 | int opt; | |
127 | ||
128 | opt = frr_getopt(argc, argv, NULL); | |
129 | ||
130 | if (opt == EOF) | |
131 | break; | |
132 | ||
133 | switch (opt) { | |
134 | case 0: | |
135 | break; | |
136 | default: | |
137 | frr_help_exit(1); | |
138 | break; | |
139 | } | |
140 | } | |
141 | ||
142 | master = frr_init(); | |
143 | ||
29348bd7 | 144 | access_list_init(); |
31ddf3b7 | 145 | static_debug_init(); |
7e24fdf3 DS |
146 | static_vrf_init(); |
147 | ||
148 | static_zebra_init(); | |
149 | static_vty_init(); | |
150 | ||
ad3489a0 DS |
151 | snprintf(backup_config_file, sizeof(backup_config_file), |
152 | "%s/zebra.conf", frr_sysconfdir); | |
153 | staticd_di.backup_config_file = backup_config_file; | |
154 | ||
7e24fdf3 DS |
155 | frr_config_fork(); |
156 | frr_run(master); | |
157 | ||
158 | /* Not reached. */ | |
159 | return 0; | |
160 | } |