]> git.proxmox.com Git - mirror_frr.git/blame - pathd/path_main.c
Merge pull request #12798 from donaldsharp/rib_match_multicast
[mirror_frr.git] / pathd / path_main.c
CommitLineData
acddc0ed 1// SPDX-License-Identifier: GPL-2.0-or-later
4d7b695d
SM
2/*
3 * Copyright (C) 2020 NetDEF, Inc.
4d7b695d
SM
4 */
5#include <zebra.h>
6
7#include <lib/version.h>
8#include "getopt.h"
9#include "thread.h"
10#include "command.h"
11#include "log.h"
12#include "memory.h"
13#include "privs.h"
14#include "sigevent.h"
15#include "libfrr.h"
16#include "vrf.h"
17#include "filter.h"
18
19#include "pathd.h"
20#include "path_nb.h"
21#include "path_zebra.h"
22#include "path_errors.h"
75c69d15 23#include "path_ted.h"
4d7b695d
SM
24
25char backup_config_file[256];
26
27zebra_capabilities_t _caps_p[] = {};
28
29struct zebra_privs_t pathd_privs = {
30#if defined(FRR_USER) && defined(FRR_GROUP)
31 .user = FRR_USER,
32 .group = FRR_GROUP,
33#endif
34#if defined(VTY_GROUP)
35 .vty_group = VTY_GROUP,
36#endif
37 .caps_p = _caps_p,
38 .cap_num_p = array_size(_caps_p),
39 .cap_num_i = 0};
40
41struct option longopts[] = {{0}};
42
43/* Master of threads. */
44struct thread_master *master;
45
46static struct frr_daemon_info pathd_di;
47
48/* SIGHUP handler. */
49static void sighup(void)
50{
51 zlog_info("SIGHUP received");
52
53 /* Reload config file. */
54 vty_read_config(NULL, pathd_di.config_file, config_default);
55}
56
57/* SIGINT / SIGTERM handler. */
58static void sigint(void)
59{
60 zlog_notice("Terminating on signal");
75c69d15
JG
61 zlog_notice("Unregisterfrom opaque,etc ");
62 pathd_shutdown();
4d7b695d
SM
63
64 exit(0);
65}
66
67/* SIGUSR1 handler. */
68static void sigusr1(void)
69{
70 zlog_rotate();
71}
72
7cc91e67 73struct frr_signal_t path_signals[] = {
4d7b695d
SM
74 {
75 .signal = SIGHUP,
76 .handler = &sighup,
77 },
78 {
79 .signal = SIGUSR1,
80 .handler = &sigusr1,
81 },
82 {
83 .signal = SIGINT,
84 .handler = &sigint,
85 },
86 {
87 .signal = SIGTERM,
88 .handler = &sigint,
89 },
90};
91
92static const struct frr_yang_module_info *pathd_yang_modules[] = {
93 &frr_filter_info,
94 &frr_interface_info,
95 &frr_pathd_info,
96};
97
98#define PATH_VTY_PORT 2621
99
100FRR_DAEMON_INFO(pathd, PATH, .vty_port = PATH_VTY_PORT,
101
102 .proghelp = "Implementation of PATH.",
103
104 .signals = path_signals, .n_signals = array_size(path_signals),
105
106 .privs = &pathd_privs, .yang_modules = pathd_yang_modules,
80413c20
DL
107 .n_yang_modules = array_size(pathd_yang_modules),
108);
4d7b695d
SM
109
110int main(int argc, char **argv, char **envp)
111{
112 frr_preinit(&pathd_di, argc, argv);
113 frr_opt_add("", longopts, "");
114
115 while (1) {
116 int opt;
117
118 opt = frr_getopt(argc, argv, NULL);
119
120 if (opt == EOF)
121 break;
122
123 switch (opt) {
124 case 0:
125 break;
126 default:
127 frr_help_exit(1);
4d7b695d
SM
128 }
129 }
130
131 master = frr_init();
132
133 access_list_init();
134
135 path_error_init();
136 path_zebra_init(master);
137 path_cli_init();
75c69d15 138 path_ted_init(master);
4d7b695d
SM
139
140 frr_config_fork();
141 frr_run(master);
142
143 /* Not reached. */
144 return 0;
145}