]>
Commit | Line | Data |
---|---|---|
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" | |
49 | ||
50 | uint32_t total_routes = 0; | |
51 | uint32_t installed_routes = 0; | |
52 | uint32_t removed_routes = 0; | |
53 | ||
54 | zebra_capabilities_t _caps_p[] = { | |
8a71d93d DS |
55 | }; |
56 | ||
57 | struct zebra_privs_t sharp_privs = { | |
58 | #if defined(FRR_USER) && defined(FRR_GROUP) | |
59 | .user = FRR_USER, | |
60 | .group = FRR_GROUP, | |
61 | #endif | |
62 | #if defined(VTY_GROUP) | |
63 | .vty_group = VTY_GROUP, | |
64 | #endif | |
65 | .caps_p = _caps_p, | |
66 | .cap_num_p = array_size(_caps_p), | |
67 | .cap_num_i = 0}; | |
68 | ||
69 | struct option longopts[] = {{0}}; | |
70 | ||
71 | /* Master of threads. */ | |
72 | struct thread_master *master; | |
73 | ||
74 | /* SIGHUP handler. */ | |
75 | static void sighup(void) | |
76 | { | |
77 | zlog_info("SIGHUP received"); | |
78 | } | |
79 | ||
80 | /* SIGINT / SIGTERM handler. */ | |
81 | static void sigint(void) | |
82 | { | |
83 | zlog_notice("Terminating on signal"); | |
84 | ||
85 | exit(0); | |
86 | } | |
87 | ||
88 | /* SIGUSR1 handler. */ | |
89 | static void sigusr1(void) | |
90 | { | |
91 | zlog_rotate(); | |
92 | } | |
93 | ||
94 | struct quagga_signal_t sharp_signals[] = { | |
95 | { | |
96 | .signal = SIGHUP, | |
97 | .handler = &sighup, | |
98 | }, | |
99 | { | |
100 | .signal = SIGUSR1, | |
101 | .handler = &sigusr1, | |
102 | }, | |
103 | { | |
104 | .signal = SIGINT, | |
105 | .handler = &sigint, | |
106 | }, | |
107 | { | |
108 | .signal = SIGTERM, | |
109 | .handler = &sigint, | |
110 | }, | |
111 | }; | |
112 | ||
113 | #define SHARP_VTY_PORT 2614 | |
114 | ||
8fcdd0d6 RW |
115 | static const struct frr_yang_module_info *sharpd_yang_modules[] = { |
116 | }; | |
117 | ||
8a71d93d DS |
118 | FRR_DAEMON_INFO(sharpd, SHARP, .vty_port = SHARP_VTY_PORT, |
119 | ||
120 | .proghelp = "Implementation of a Sharp of routes daemon.", | |
121 | ||
122 | .signals = sharp_signals, | |
123 | .n_signals = array_size(sharp_signals), | |
124 | ||
8fcdd0d6 RW |
125 | .privs = &sharp_privs, .yang_modules = sharpd_yang_modules, |
126 | .n_yang_modules = array_size(sharpd_yang_modules), ) | |
8a71d93d DS |
127 | |
128 | extern void sharp_vty_init(void); | |
129 | ||
130 | int main(int argc, char **argv, char **envp) | |
131 | { | |
132 | frr_preinit(&sharpd_di, argc, argv); | |
133 | frr_opt_add("", longopts, ""); | |
134 | ||
135 | while (1) { | |
136 | int opt; | |
137 | ||
138 | opt = frr_getopt(argc, argv, NULL); | |
139 | ||
140 | if (opt == EOF) | |
141 | break; | |
142 | ||
143 | switch (opt) { | |
144 | case 0: | |
145 | break; | |
146 | default: | |
147 | frr_help_exit(1); | |
148 | break; | |
149 | } | |
150 | } | |
151 | ||
152 | master = frr_init(); | |
153 | ||
81dd71eb | 154 | nexthop_group_init(NULL, NULL, NULL, NULL); |
ecbc5a37 | 155 | vrf_init(NULL, NULL, NULL, NULL, NULL); |
8a71d93d | 156 | |
29348bd7 | 157 | access_list_init(); |
808afce9 DS |
158 | route_map_init(); |
159 | ||
8a71d93d DS |
160 | sharp_zebra_init(); |
161 | ||
162 | /* Get configuration file. */ | |
163 | sharp_vty_init(); | |
164 | ||
165 | frr_config_fork(); | |
166 | frr_run(master); | |
167 | ||
168 | /* Not reached. */ | |
169 | return 0; | |
170 | } |