]>
Commit | Line | Data |
---|---|---|
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 "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 "version.h" | |
36 | #include "prefix.h" | |
37 | #include "plist.h" | |
38 | #include "vrf.h" | |
39 | #include "libfrr.h" | |
40 | ||
41 | #include "pimd.h" | |
42 | #include "pim_instance.h" | |
43 | #include "pim_version.h" | |
44 | #include "pim_signals.h" | |
45 | #include "pim_zebra.h" | |
46 | #include "pim_msdp.h" | |
47 | #include "pim_iface.h" | |
48 | #include "pim_bfd.h" | |
49 | #include "pim_mlag.h" | |
50 | #include "pim_errors.h" | |
51 | ||
52 | extern struct host host; | |
53 | ||
54 | struct option longopts[] = {{0}}; | |
55 | ||
56 | /* pimd privileges */ | |
57 | zebra_capabilities_t _caps_p[] = { | |
58 | ZCAP_NET_ADMIN, ZCAP_SYS_ADMIN, ZCAP_NET_RAW, ZCAP_BIND, | |
59 | }; | |
60 | ||
61 | /* pimd privileges to run with */ | |
62 | struct zebra_privs_t pimd_privs = { | |
63 | #if defined(FRR_USER) && defined(FRR_GROUP) | |
64 | .user = FRR_USER, | |
65 | .group = FRR_GROUP, | |
66 | #endif | |
67 | #ifdef VTY_GROUP | |
68 | .vty_group = VTY_GROUP, | |
69 | #endif | |
70 | .caps_p = _caps_p, | |
71 | .cap_num_p = array_size(_caps_p), | |
72 | .cap_num_i = 0}; | |
73 | ||
74 | static const struct frr_yang_module_info *const pimd_yang_modules[] = { | |
75 | &frr_interface_info, | |
76 | }; | |
77 | ||
78 | FRR_DAEMON_INFO(pimd, PIM, .vty_port = PIMD_VTY_PORT, | |
79 | ||
80 | .proghelp = "Implementation of the PIM routing protocol.", | |
81 | ||
82 | .signals = pimd_signals, | |
83 | .n_signals = 4 /* XXX array_size(pimd_signals) XXX*/, | |
84 | ||
85 | .privs = &pimd_privs, .yang_modules = pimd_yang_modules, | |
86 | .n_yang_modules = array_size(pimd_yang_modules), ) | |
87 | ||
88 | ||
89 | int main(int argc, char **argv, char **envp) | |
90 | { | |
91 | frr_preinit(&pimd_di, argc, argv); | |
92 | frr_opt_add("", longopts, ""); | |
93 | ||
94 | /* this while just reads the options */ | |
95 | while (1) { | |
96 | int opt; | |
97 | ||
98 | opt = frr_getopt(argc, argv, NULL); | |
99 | ||
100 | if (opt == EOF) | |
101 | break; | |
102 | ||
103 | switch (opt) { | |
104 | case 0: | |
105 | break; | |
106 | default: | |
107 | frr_help_exit(1); | |
108 | break; | |
109 | } | |
110 | } | |
111 | ||
112 | pim_router_init(); | |
113 | ||
114 | /* | |
115 | * Initializations | |
116 | */ | |
117 | pim_error_init(); | |
118 | pim_vrf_init(); | |
119 | access_list_init(); | |
120 | prefix_list_init(); | |
121 | prefix_list_add_hook(pim_prefix_list_update); | |
122 | prefix_list_delete_hook(pim_prefix_list_update); | |
123 | ||
124 | pim_route_map_init(); | |
125 | pim_init(); | |
126 | ||
127 | /* | |
128 | * Initialize zclient "update" and "lookup" sockets | |
129 | */ | |
130 | if_zapi_callbacks(pim_ifp_create, pim_ifp_up, | |
131 | pim_ifp_down, pim_ifp_destroy); | |
132 | pim_zebra_init(); | |
133 | pim_bfd_init(); | |
134 | pim_mlag_init(); | |
135 | ||
136 | frr_config_fork(); | |
137 | ||
138 | #ifdef PIM_DEBUG_BYDEFAULT | |
139 | zlog_notice("PIM_DEBUG_BYDEFAULT: Enabling all debug commands"); | |
140 | PIM_DO_DEBUG_PIM_EVENTS; | |
141 | PIM_DO_DEBUG_PIM_PACKETS; | |
142 | PIM_DO_DEBUG_PIM_TRACE; | |
143 | PIM_DO_DEBUG_IGMP_EVENTS; | |
144 | PIM_DO_DEBUG_IGMP_PACKETS; | |
145 | PIM_DO_DEBUG_IGMP_TRACE; | |
146 | PIM_DO_DEBUG_ZEBRA; | |
147 | #endif | |
148 | ||
149 | #ifdef PIM_CHECK_RECV_IFINDEX_SANITY | |
150 | zlog_notice( | |
151 | "PIM_CHECK_RECV_IFINDEX_SANITY: will match sock/recv ifindex"); | |
152 | #ifdef PIM_REPORT_RECV_IFINDEX_MISMATCH | |
153 | zlog_notice( | |
154 | "PIM_REPORT_RECV_IFINDEX_MISMATCH: will report sock/recv ifindex mismatch"); | |
155 | #endif | |
156 | #endif | |
157 | ||
158 | #ifdef PIM_UNEXPECTED_KERNEL_UPCALL | |
159 | zlog_notice( | |
160 | "PIM_UNEXPECTED_KERNEL_UPCALL: report unexpected kernel upcall"); | |
161 | #endif | |
162 | ||
163 | frr_run(router->master); | |
164 | ||
165 | /* never reached */ | |
166 | return 0; | |
167 | } |