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