Line data Source code
1 : /*
2 : * PIM for Quagga
3 : * Copyright (C) 2008 Everton da Silva Marques
4 : *
5 : * This program is free software; you can redistribute it and/or modify
6 : * it under the terms of the GNU General Public License as published by
7 : * the Free Software Foundation; either version 2 of the License, or
8 : * (at your option) any later version.
9 : *
10 : * This program is distributed in the hope that it will be useful, but
11 : * WITHOUT ANY WARRANTY; without even the implied warranty of
12 : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 : * General Public License for more details.
14 : *
15 : * You should have received a copy of the GNU General Public License along
16 : * with this program; see the file COPYING; if not, write to the Free Software
17 : * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18 : */
19 :
20 : #include <zebra.h>
21 :
22 : #include "log.h"
23 : #include "privs.h"
24 : #include "lib/version.h"
25 : #include <getopt.h>
26 : #include "command.h"
27 : #include "thread.h"
28 : #include <signal.h>
29 :
30 : #include "memory.h"
31 : #include "vrf.h"
32 : #include "filter.h"
33 : #include "vty.h"
34 : #include "sigevent.h"
35 : #include "lib/version.h"
36 : #include "prefix.h"
37 : #include "plist.h"
38 : #include "vrf.h"
39 : #include "libfrr.h"
40 : #include "routemap.h"
41 : #include "routing_nb.h"
42 :
43 : #include "pimd.h"
44 : #include "pim_instance.h"
45 : #include "pim_signals.h"
46 : #include "pim_zebra.h"
47 : #include "pim_msdp.h"
48 : #include "pim_iface.h"
49 : #include "pim_bfd.h"
50 : #include "pim_mlag.h"
51 : #include "pim_errors.h"
52 : #include "pim_nb.h"
53 :
54 : extern struct host host;
55 :
56 : struct option longopts[] = {{0}};
57 :
58 : /* pimd privileges */
59 : zebra_capabilities_t _caps_p[] = {
60 : ZCAP_NET_ADMIN, ZCAP_SYS_ADMIN, ZCAP_NET_RAW, ZCAP_BIND,
61 : };
62 :
63 : /* pimd privileges to run with */
64 : struct zebra_privs_t pimd_privs = {
65 : #if defined(FRR_USER) && defined(FRR_GROUP)
66 : .user = FRR_USER,
67 : .group = FRR_GROUP,
68 : #endif
69 : #ifdef VTY_GROUP
70 : .vty_group = VTY_GROUP,
71 : #endif
72 : .caps_p = _caps_p,
73 : .cap_num_p = array_size(_caps_p),
74 : .cap_num_i = 0};
75 :
76 : static const struct frr_yang_module_info *const pimd_yang_modules[] = {
77 : &frr_filter_info,
78 : &frr_interface_info,
79 : &frr_route_map_info,
80 : &frr_vrf_info,
81 : &frr_routing_info,
82 : &frr_pim_info,
83 : &frr_pim_rp_info,
84 : &frr_gmp_info,
85 : };
86 :
87 3 : FRR_DAEMON_INFO(pimd, PIM, .vty_port = PIMD_VTY_PORT,
88 :
89 : .proghelp = "Implementation of the PIM routing protocol.",
90 :
91 : .signals = pimd_signals,
92 : .n_signals = 4 /* XXX array_size(pimd_signals) XXX*/,
93 :
94 : .privs = &pimd_privs, .yang_modules = pimd_yang_modules,
95 : .n_yang_modules = array_size(pimd_yang_modules),
96 : );
97 :
98 :
99 3 : int main(int argc, char **argv, char **envp)
100 : {
101 3 : frr_preinit(&pimd_di, argc, argv);
102 3 : frr_opt_add("", longopts, "");
103 :
104 : /* this while just reads the options */
105 3 : while (1) {
106 3 : int opt;
107 :
108 3 : opt = frr_getopt(argc, argv, NULL);
109 :
110 3 : if (opt == EOF)
111 : break;
112 :
113 0 : switch (opt) {
114 : case 0:
115 : break;
116 0 : default:
117 0 : frr_help_exit(1);
118 : }
119 : }
120 :
121 3 : pim_router_init();
122 :
123 : /*
124 : * Initializations
125 : */
126 3 : pim_error_init();
127 3 : pim_vrf_init();
128 3 : access_list_init();
129 3 : prefix_list_init();
130 3 : prefix_list_add_hook(pim_prefix_list_update);
131 3 : prefix_list_delete_hook(pim_prefix_list_update);
132 :
133 3 : pim_route_map_init();
134 3 : pim_init();
135 :
136 : /*
137 : * Initialize zclient "update" and "lookup" sockets
138 : */
139 3 : pim_iface_init();
140 3 : pim_zebra_init();
141 3 : pim_bfd_init();
142 3 : pim_mlag_init();
143 :
144 3 : hook_register(routing_conf_event,
145 : routing_control_plane_protocols_name_validate);
146 :
147 3 : routing_control_plane_protocols_register_vrf_dependency();
148 :
149 3 : frr_config_fork();
150 :
151 : #ifdef PIM_DEBUG_BYDEFAULT
152 : zlog_notice("PIM_DEBUG_BYDEFAULT: Enabling all debug commands");
153 : PIM_DO_DEBUG_PIM_EVENTS;
154 : PIM_DO_DEBUG_PIM_PACKETS;
155 : PIM_DO_DEBUG_PIM_TRACE;
156 : PIM_DO_DEBUG_GM_EVENTS;
157 : PIM_DO_DEBUG_GM_PACKETS;
158 : PIM_DO_DEBUG_GM_TRACE;
159 : PIM_DO_DEBUG_ZEBRA;
160 : #endif
161 :
162 : #ifdef PIM_CHECK_RECV_IFINDEX_SANITY
163 : zlog_notice(
164 : "PIM_CHECK_RECV_IFINDEX_SANITY: will match sock/recv ifindex");
165 : #ifdef PIM_REPORT_RECV_IFINDEX_MISMATCH
166 : zlog_notice(
167 : "PIM_REPORT_RECV_IFINDEX_MISMATCH: will report sock/recv ifindex mismatch");
168 : #endif
169 : #endif
170 :
171 : #ifdef PIM_UNEXPECTED_KERNEL_UPCALL
172 : zlog_notice(
173 : "PIM_UNEXPECTED_KERNEL_UPCALL: report unexpected kernel upcall");
174 : #endif
175 :
176 3 : frr_run(router->master);
177 :
178 : /* never reached */
179 0 : return 0;
180 : }
|