]> git.proxmox.com Git - mirror_frr.git/blob - pimd/pim_main.c
Merge branch 'frr/pull/569'
[mirror_frr.git] / pimd / pim_main.c
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 "memory_vty.h"
33 #include "filter.h"
34 #include "vty.h"
35 #include "sigevent.h"
36 #include "version.h"
37 #include "prefix.h"
38 #include "plist.h"
39 #include "vrf.h"
40 #include "libfrr.h"
41
42 #include "pimd.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
49 extern struct host host;
50
51 struct option longopts[] = {
52 { 0 }
53 };
54
55 /* pimd privileges */
56 zebra_capabilities_t _caps_p [] =
57 {
58 ZCAP_NET_ADMIN,
59 ZCAP_SYS_ADMIN,
60 ZCAP_NET_RAW,
61 ZCAP_BIND,
62 };
63
64 /* pimd privileges to run with */
65 struct zebra_privs_t pimd_privs =
66 {
67 #if defined(FRR_USER) && defined(FRR_GROUP)
68 .user = FRR_USER,
69 .group = FRR_GROUP,
70 #endif
71 #ifdef VTY_GROUP
72 .vty_group = VTY_GROUP,
73 #endif
74 .caps_p = _caps_p,
75 .cap_num_p = sizeof(_caps_p)/sizeof(_caps_p[0]),
76 .cap_num_i = 0
77 };
78
79 FRR_DAEMON_INFO(pimd, PIM,
80 .vty_port = PIMD_VTY_PORT,
81
82 .proghelp = "Implementation of the PIM routing protocol.",
83
84 .signals = pimd_signals,
85 .n_signals = 4 /* XXX array_size(pimd_signals) XXX*/,
86
87 .privs = &pimd_privs,
88 )
89
90
91 int main(int argc, char** argv, char** envp) {
92 frr_preinit(&pimd_di, argc, argv);
93 frr_opt_add("", longopts, "");
94
95 /* this while just reads the options */
96 while (1) {
97 int opt;
98
99 opt = frr_getopt(argc, argv, NULL);
100
101 if (opt == EOF)
102 break;
103
104 switch (opt) {
105 case 0:
106 break;
107 default:
108 frr_help_exit (1);
109 break;
110 }
111 }
112
113 master = frr_init();
114
115 /*
116 * Initializations
117 */
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 pim_msdp_init (master);
127
128 /*
129 * Initialize zclient "update" and "lookup" sockets
130 */
131 pim_zebra_init();
132
133 frr_config_fork();
134
135 #ifdef PIM_DEBUG_BYDEFAULT
136 zlog_notice("PIM_DEBUG_BYDEFAULT: Enabling all debug commands");
137 PIM_DO_DEBUG_PIM_EVENTS;
138 PIM_DO_DEBUG_PIM_PACKETS;
139 PIM_DO_DEBUG_PIM_TRACE;
140 PIM_DO_DEBUG_IGMP_EVENTS;
141 PIM_DO_DEBUG_IGMP_PACKETS;
142 PIM_DO_DEBUG_IGMP_TRACE;
143 PIM_DO_DEBUG_ZEBRA;
144 #endif
145
146 #ifdef PIM_CHECK_RECV_IFINDEX_SANITY
147 zlog_notice("PIM_CHECK_RECV_IFINDEX_SANITY: will match sock/recv ifindex");
148 #ifdef PIM_REPORT_RECV_IFINDEX_MISMATCH
149 zlog_notice("PIM_REPORT_RECV_IFINDEX_MISMATCH: will report sock/recv ifindex mismatch");
150 #endif
151 #endif
152
153 #ifdef PIM_UNEXPECTED_KERNEL_UPCALL
154 zlog_notice("PIM_UNEXPECTED_KERNEL_UPCALL: report unexpected kernel upcall");
155 #endif
156
157 frr_run(master);
158
159 /* never reached */
160 return 0;
161 }