]> git.proxmox.com Git - mirror_frr.git/blame - sharpd/sharp_main.c
sharpd: Add 'sharp data route" dump command
[mirror_frr.git] / sharpd / sharp_main.c
CommitLineData
8a71d93d
DS
1/*
2 * SHARP - main code
3 * Copyright (C) Cumulus Networks, Inc.
4 * Donald Sharp
5 *
6 * This file is part of FRR.
7 *
8 * FRR is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License as published by the
10 * Free Software Foundation; either version 2, or (at your option) any
11 * later version.
12 *
13 * FRR is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License along
19 * with this program; see the file COPYING; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21 */
22#include <zebra.h>
23
24#include <lib/version.h>
25#include "getopt.h"
26#include "thread.h"
27#include "prefix.h"
28#include "linklist.h"
29#include "if.h"
30#include "vector.h"
31#include "vty.h"
32#include "command.h"
33#include "filter.h"
34#include "plist.h"
35#include "stream.h"
36#include "log.h"
37#include "memory.h"
38#include "privs.h"
39#include "sigevent.h"
40#include "zclient.h"
41#include "keychain.h"
42#include "distribute.h"
43#include "libfrr.h"
44#include "routemap.h"
694b242f 45#include "nexthop_group.h"
8a71d93d
DS
46
47#include "sharp_zebra.h"
48#include "sharp_vty.h"
d21f1a93 49#include "sharp_globals.h"
8a71d93d 50
8a71d93d 51zebra_capabilities_t _caps_p[] = {
8a71d93d
DS
52};
53
54struct zebra_privs_t sharp_privs = {
55#if defined(FRR_USER) && defined(FRR_GROUP)
56 .user = FRR_USER,
57 .group = FRR_GROUP,
58#endif
59#if defined(VTY_GROUP)
60 .vty_group = VTY_GROUP,
61#endif
62 .caps_p = _caps_p,
63 .cap_num_p = array_size(_caps_p),
64 .cap_num_i = 0};
65
66struct option longopts[] = {{0}};
67
68/* Master of threads. */
69struct thread_master *master;
70
71/* SIGHUP handler. */
72static void sighup(void)
73{
74 zlog_info("SIGHUP received");
75}
76
77/* SIGINT / SIGTERM handler. */
78static void sigint(void)
79{
80 zlog_notice("Terminating on signal");
81
82 exit(0);
83}
84
85/* SIGUSR1 handler. */
86static void sigusr1(void)
87{
88 zlog_rotate();
89}
90
91struct quagga_signal_t sharp_signals[] = {
92 {
93 .signal = SIGHUP,
94 .handler = &sighup,
95 },
96 {
97 .signal = SIGUSR1,
98 .handler = &sigusr1,
99 },
100 {
101 .signal = SIGINT,
102 .handler = &sigint,
103 },
104 {
105 .signal = SIGTERM,
106 .handler = &sigint,
107 },
108};
109
110#define SHARP_VTY_PORT 2614
111
8fcdd0d6
RW
112static const struct frr_yang_module_info *sharpd_yang_modules[] = {
113};
114
8a71d93d
DS
115FRR_DAEMON_INFO(sharpd, SHARP, .vty_port = SHARP_VTY_PORT,
116
117 .proghelp = "Implementation of a Sharp of routes daemon.",
118
119 .signals = sharp_signals,
120 .n_signals = array_size(sharp_signals),
121
8fcdd0d6
RW
122 .privs = &sharp_privs, .yang_modules = sharpd_yang_modules,
123 .n_yang_modules = array_size(sharpd_yang_modules), )
8a71d93d 124
d21f1a93
DS
125struct sharp_global sg;
126
127static void sharp_global_init(void)
128{
129 memset(&sg, 0, sizeof(sg));
130}
8a71d93d
DS
131
132int main(int argc, char **argv, char **envp)
133{
134 frr_preinit(&sharpd_di, argc, argv);
135 frr_opt_add("", longopts, "");
136
137 while (1) {
138 int opt;
139
140 opt = frr_getopt(argc, argv, NULL);
141
142 if (opt == EOF)
143 break;
144
145 switch (opt) {
146 case 0:
147 break;
148 default:
149 frr_help_exit(1);
150 break;
151 }
152 }
153
154 master = frr_init();
155
d21f1a93
DS
156 sharp_global_init();
157
81dd71eb 158 nexthop_group_init(NULL, NULL, NULL, NULL);
ecbc5a37 159 vrf_init(NULL, NULL, NULL, NULL, NULL);
8a71d93d 160
29348bd7 161 access_list_init();
808afce9
DS
162 route_map_init();
163
8a71d93d
DS
164 sharp_zebra_init();
165
166 /* Get configuration file. */
167 sharp_vty_init();
168
169 frr_config_fork();
170 frr_run(master);
171
172 /* Not reached. */
173 return 0;
174}