]> git.proxmox.com Git - mirror_frr.git/blob - staticd/static_main.c
zebra, lib: fix the ZEBRA_INTERFACE_VRF_UPDATE zapi message
[mirror_frr.git] / staticd / static_main.c
1 /*
2 * STATICd - main code
3 * Copyright (C) 2018 Cumulus Networks, Inc.
4 * Donald Sharp
5 *
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.
10 *
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.
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"
33 #include "filter.h"
34
35 #include "static_vrf.h"
36 #include "static_vty.h"
37 #include "static_routes.h"
38 #include "static_zebra.h"
39
40 char backup_config_file[256];
41
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 static const struct frr_yang_module_info *staticd_yang_modules[] = {
104 };
105
106 #define STATIC_VTY_PORT 2616
107
108 FRR_DAEMON_INFO(staticd, STATIC, .vty_port = STATIC_VTY_PORT,
109
110 .proghelp = "Implementation of STATIC.",
111
112 .signals = static_signals,
113 .n_signals = array_size(static_signals),
114
115 .privs = &static_privs, .yang_modules = staticd_yang_modules,
116 .n_yang_modules = array_size(staticd_yang_modules),
117 )
118
119 int main(int argc, char **argv, char **envp)
120 {
121 frr_preinit(&staticd_di, argc, argv);
122 frr_opt_add("", longopts, "");
123
124 while (1) {
125 int opt;
126
127 opt = frr_getopt(argc, argv, NULL);
128
129 if (opt == EOF)
130 break;
131
132 switch (opt) {
133 case 0:
134 break;
135 default:
136 frr_help_exit(1);
137 break;
138 }
139 }
140
141 master = frr_init();
142
143 access_list_init();
144 static_vrf_init();
145
146 static_zebra_init();
147 static_vty_init();
148
149 snprintf(backup_config_file, sizeof(backup_config_file),
150 "%s/zebra.conf", frr_sysconfdir);
151 staticd_di.backup_config_file = backup_config_file;
152
153 frr_config_fork();
154 frr_run(master);
155
156 /* Not reached. */
157 return 0;
158 }