]> git.proxmox.com Git - mirror_frr.git/blob - staticd/static_main.c
staticd: Start the addition of a staticd
[mirror_frr.git] / staticd / static_main.c
1 /*
2 * STATICd - main code
3 * Copyright (C) 2018 Cumulus Networks, Inc.
4 * Donald Sharp
5 *
6 * FRR 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 * FRR 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 *
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
34 #include "static_vrf.h"
35 #include "static_vty.h"
36 #include "static_routes.h"
37 #include "static_zebra.h"
38
39 bool mpls_enabled;
40
41 zebra_capabilities_t _caps_p[] = {
42 };
43
44 struct zebra_privs_t static_privs = {
45 #if defined(FRR_USER) && defined(FRR_GROUP)
46 .user = FRR_USER,
47 .group = FRR_GROUP,
48 #endif
49 #if defined(VTY_GROUP)
50 .vty_group = VTY_GROUP,
51 #endif
52 .caps_p = _caps_p,
53 .cap_num_p = array_size(_caps_p),
54 .cap_num_i = 0};
55
56 struct option longopts[] = { { 0 } };
57
58 /* Master of threads. */
59 struct thread_master *master;
60
61 /* SIGHUP handler. */
62 static void sighup(void)
63 {
64 zlog_info("SIGHUP received");
65 }
66
67 /* SIGINT / SIGTERM handler. */
68 static void sigint(void)
69 {
70 zlog_notice("Terminating on signal");
71
72 exit(0);
73 }
74
75 /* SIGUSR1 handler. */
76 static void sigusr1(void)
77 {
78 zlog_rotate();
79 }
80
81 struct quagga_signal_t static_signals[] = {
82 {
83 .signal = SIGHUP,
84 .handler = &sighup,
85 },
86 {
87 .signal = SIGUSR1,
88 .handler = &sigusr1,
89 },
90 {
91 .signal = SIGINT,
92 .handler = &sigint,
93 },
94 {
95 .signal = SIGTERM,
96 .handler = &sigint,
97 },
98 };
99
100 #define STATIC_VTY_PORT 2616
101
102 FRR_DAEMON_INFO(staticd, STATIC, .vty_port = STATIC_VTY_PORT,
103
104 .proghelp = "Implementation of STATIC.",
105
106 .signals = static_signals,
107 .n_signals = array_size(static_signals),
108
109 .privs = &static_privs, )
110
111 int main(int argc, char **argv, char **envp)
112 {
113 frr_preinit(&staticd_di, argc, argv);
114 frr_opt_add("", longopts, "");
115
116 while (1) {
117 int opt;
118
119 opt = frr_getopt(argc, argv, NULL);
120
121 if (opt == EOF)
122 break;
123
124 switch (opt) {
125 case 0:
126 break;
127 default:
128 frr_help_exit(1);
129 break;
130 }
131 }
132
133 master = frr_init();
134
135 static_vrf_init();
136
137 static_zebra_init();
138 static_vty_init();
139
140 frr_config_fork();
141 frr_run(master);
142
143 /* Not reached. */
144 return 0;
145 }