]>
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" | |
39 | ||
ad3489a0 DS |
40 | char backup_config_file[256]; |
41 | ||
7e24fdf3 DS |
42 | bool mpls_enabled; |
43 | ||
44 | zebra_capabilities_t _caps_p[] = { | |
45 | }; | |
46 | ||
47 | struct zebra_privs_t static_privs = { | |
48 | #if defined(FRR_USER) && defined(FRR_GROUP) | |
49 | .user = FRR_USER, | |
50 | .group = FRR_GROUP, | |
51 | #endif | |
52 | #if defined(VTY_GROUP) | |
53 | .vty_group = VTY_GROUP, | |
54 | #endif | |
55 | .caps_p = _caps_p, | |
56 | .cap_num_p = array_size(_caps_p), | |
57 | .cap_num_i = 0}; | |
58 | ||
59 | struct option longopts[] = { { 0 } }; | |
60 | ||
61 | /* Master of threads. */ | |
62 | struct thread_master *master; | |
63 | ||
64 | /* SIGHUP handler. */ | |
65 | static void sighup(void) | |
66 | { | |
67 | zlog_info("SIGHUP received"); | |
68 | } | |
69 | ||
70 | /* SIGINT / SIGTERM handler. */ | |
71 | static void sigint(void) | |
72 | { | |
73 | zlog_notice("Terminating on signal"); | |
74 | ||
75 | exit(0); | |
76 | } | |
77 | ||
78 | /* SIGUSR1 handler. */ | |
79 | static void sigusr1(void) | |
80 | { | |
81 | zlog_rotate(); | |
82 | } | |
83 | ||
84 | struct quagga_signal_t static_signals[] = { | |
85 | { | |
86 | .signal = SIGHUP, | |
87 | .handler = &sighup, | |
88 | }, | |
89 | { | |
90 | .signal = SIGUSR1, | |
91 | .handler = &sigusr1, | |
92 | }, | |
93 | { | |
94 | .signal = SIGINT, | |
95 | .handler = &sigint, | |
96 | }, | |
97 | { | |
98 | .signal = SIGTERM, | |
99 | .handler = &sigint, | |
100 | }, | |
101 | }; | |
102 | ||
103 | #define STATIC_VTY_PORT 2616 | |
104 | ||
105 | FRR_DAEMON_INFO(staticd, STATIC, .vty_port = STATIC_VTY_PORT, | |
106 | ||
107 | .proghelp = "Implementation of STATIC.", | |
108 | ||
109 | .signals = static_signals, | |
110 | .n_signals = array_size(static_signals), | |
111 | ||
ba86c88f DL |
112 | .privs = &static_privs, |
113 | ) | |
7e24fdf3 DS |
114 | |
115 | int main(int argc, char **argv, char **envp) | |
116 | { | |
117 | frr_preinit(&staticd_di, argc, argv); | |
118 | frr_opt_add("", longopts, ""); | |
119 | ||
120 | while (1) { | |
121 | int opt; | |
122 | ||
123 | opt = frr_getopt(argc, argv, NULL); | |
124 | ||
125 | if (opt == EOF) | |
126 | break; | |
127 | ||
128 | switch (opt) { | |
129 | case 0: | |
130 | break; | |
131 | default: | |
132 | frr_help_exit(1); | |
133 | break; | |
134 | } | |
135 | } | |
136 | ||
137 | master = frr_init(); | |
138 | ||
29348bd7 | 139 | access_list_init(); |
7e24fdf3 DS |
140 | static_vrf_init(); |
141 | ||
142 | static_zebra_init(); | |
143 | static_vty_init(); | |
144 | ||
ad3489a0 DS |
145 | snprintf(backup_config_file, sizeof(backup_config_file), |
146 | "%s/zebra.conf", frr_sysconfdir); | |
147 | staticd_di.backup_config_file = backup_config_file; | |
148 | ||
7e24fdf3 DS |
149 | frr_config_fork(); |
150 | frr_run(master); | |
151 | ||
152 | /* Not reached. */ | |
153 | return 0; | |
154 | } |