]>
Commit | Line | Data |
---|---|---|
4d7b695d SM |
1 | /* |
2 | * Copyright (C) 2020 NetDEF, Inc. | |
3 | * | |
4 | * This program is free software; you can redistribute it and/or modify it | |
5 | * under the terms of the GNU General Public License as published by the Free | |
6 | * Software Foundation; either version 2 of the License, or (at your option) | |
7 | * any later version. | |
8 | * | |
9 | * This program is distributed in the hope that it will be useful, but WITHOUT | |
10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | |
12 | * more details. | |
13 | * | |
14 | * You should have received a copy of the GNU General Public License along | |
15 | * with this program; see the file COPYING; if not, write to the Free Software | |
16 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | |
17 | */ | |
18 | #include <zebra.h> | |
19 | ||
20 | #include <lib/version.h> | |
21 | #include "getopt.h" | |
22 | #include "thread.h" | |
23 | #include "command.h" | |
24 | #include "log.h" | |
25 | #include "memory.h" | |
26 | #include "privs.h" | |
27 | #include "sigevent.h" | |
28 | #include "libfrr.h" | |
29 | #include "vrf.h" | |
30 | #include "filter.h" | |
31 | ||
32 | #include "pathd.h" | |
33 | #include "path_nb.h" | |
34 | #include "path_zebra.h" | |
35 | #include "path_errors.h" | |
75c69d15 | 36 | #include "path_ted.h" |
4d7b695d SM |
37 | |
38 | char backup_config_file[256]; | |
39 | ||
40 | zebra_capabilities_t _caps_p[] = {}; | |
41 | ||
42 | struct zebra_privs_t pathd_privs = { | |
43 | #if defined(FRR_USER) && defined(FRR_GROUP) | |
44 | .user = FRR_USER, | |
45 | .group = FRR_GROUP, | |
46 | #endif | |
47 | #if defined(VTY_GROUP) | |
48 | .vty_group = VTY_GROUP, | |
49 | #endif | |
50 | .caps_p = _caps_p, | |
51 | .cap_num_p = array_size(_caps_p), | |
52 | .cap_num_i = 0}; | |
53 | ||
54 | struct option longopts[] = {{0}}; | |
55 | ||
56 | /* Master of threads. */ | |
57 | struct thread_master *master; | |
58 | ||
59 | static struct frr_daemon_info pathd_di; | |
60 | ||
61 | /* SIGHUP handler. */ | |
62 | static void sighup(void) | |
63 | { | |
64 | zlog_info("SIGHUP received"); | |
65 | ||
66 | /* Reload config file. */ | |
67 | vty_read_config(NULL, pathd_di.config_file, config_default); | |
68 | } | |
69 | ||
70 | /* SIGINT / SIGTERM handler. */ | |
71 | static void sigint(void) | |
72 | { | |
73 | zlog_notice("Terminating on signal"); | |
75c69d15 JG |
74 | zlog_notice("Unregisterfrom opaque,etc "); |
75 | pathd_shutdown(); | |
4d7b695d SM |
76 | |
77 | exit(0); | |
78 | } | |
79 | ||
80 | /* SIGUSR1 handler. */ | |
81 | static void sigusr1(void) | |
82 | { | |
83 | zlog_rotate(); | |
84 | } | |
85 | ||
7cc91e67 | 86 | struct frr_signal_t path_signals[] = { |
4d7b695d SM |
87 | { |
88 | .signal = SIGHUP, | |
89 | .handler = &sighup, | |
90 | }, | |
91 | { | |
92 | .signal = SIGUSR1, | |
93 | .handler = &sigusr1, | |
94 | }, | |
95 | { | |
96 | .signal = SIGINT, | |
97 | .handler = &sigint, | |
98 | }, | |
99 | { | |
100 | .signal = SIGTERM, | |
101 | .handler = &sigint, | |
102 | }, | |
103 | }; | |
104 | ||
105 | static const struct frr_yang_module_info *pathd_yang_modules[] = { | |
106 | &frr_filter_info, | |
107 | &frr_interface_info, | |
108 | &frr_pathd_info, | |
109 | }; | |
110 | ||
111 | #define PATH_VTY_PORT 2621 | |
112 | ||
113 | FRR_DAEMON_INFO(pathd, PATH, .vty_port = PATH_VTY_PORT, | |
114 | ||
115 | .proghelp = "Implementation of PATH.", | |
116 | ||
117 | .signals = path_signals, .n_signals = array_size(path_signals), | |
118 | ||
119 | .privs = &pathd_privs, .yang_modules = pathd_yang_modules, | |
80413c20 DL |
120 | .n_yang_modules = array_size(pathd_yang_modules), |
121 | ); | |
4d7b695d SM |
122 | |
123 | int main(int argc, char **argv, char **envp) | |
124 | { | |
125 | frr_preinit(&pathd_di, argc, argv); | |
126 | frr_opt_add("", longopts, ""); | |
127 | ||
128 | while (1) { | |
129 | int opt; | |
130 | ||
131 | opt = frr_getopt(argc, argv, NULL); | |
132 | ||
133 | if (opt == EOF) | |
134 | break; | |
135 | ||
136 | switch (opt) { | |
137 | case 0: | |
138 | break; | |
139 | default: | |
140 | frr_help_exit(1); | |
4d7b695d SM |
141 | } |
142 | } | |
143 | ||
144 | master = frr_init(); | |
145 | ||
146 | access_list_init(); | |
147 | ||
148 | path_error_init(); | |
149 | path_zebra_init(master); | |
150 | path_cli_init(); | |
75c69d15 | 151 | path_ted_init(master); |
4d7b695d SM |
152 | |
153 | frr_config_fork(); | |
154 | frr_run(master); | |
155 | ||
156 | /* Not reached. */ | |
157 | return 0; | |
158 | } |