]> git.proxmox.com Git - mirror_frr.git/blob - pimd/pim_main.c
d814af6b2c1ba9b2750f5488f800a8790ad8b750
[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
16 along with this program; see the file COPYING; if not, write to the
17 Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
18 MA 02110-1301 USA
19 */
20
21 #include <zebra.h>
22
23 #include "log.h"
24 #include "privs.h"
25 #include "version.h"
26 #include <getopt.h>
27 #include "command.h"
28 #include "thread.h"
29 #include <signal.h>
30
31 #include "memory.h"
32 #include "vrf.h"
33 #include "memory_vty.h"
34 #include "filter.h"
35 #include "vty.h"
36 #include "sigevent.h"
37 #include "version.h"
38 #include "prefix.h"
39 #include "plist.h"
40 #include "vrf.h"
41 #include "libfrr.h"
42
43 #include "pimd.h"
44 #include "pim_version.h"
45 #include "pim_signals.h"
46 #include "pim_zebra.h"
47 #include "pim_msdp.h"
48 #include "pim_iface.h"
49
50 extern struct host host;
51
52 struct option longopts[] = {
53 { 0 }
54 };
55
56 /* pimd privileges */
57 zebra_capabilities_t _caps_p [] =
58 {
59 ZCAP_NET_ADMIN,
60 ZCAP_SYS_ADMIN,
61 ZCAP_NET_RAW,
62 ZCAP_BIND,
63 };
64
65 /* pimd privileges to run with */
66 struct zebra_privs_t pimd_privs =
67 {
68 #if defined(FRR_USER) && defined(FRR_GROUP)
69 .user = FRR_USER,
70 .group = FRR_GROUP,
71 #endif
72 #ifdef VTY_GROUP
73 .vty_group = VTY_GROUP,
74 #endif
75 .caps_p = _caps_p,
76 .cap_num_p = sizeof(_caps_p)/sizeof(_caps_p[0]),
77 .cap_num_i = 0
78 };
79
80 FRR_DAEMON_INFO(pimd, PIM,
81 .vty_port = PIMD_VTY_PORT,
82
83 .proghelp = "Implementation of the PIM routing protocol.",
84
85 .signals = pimd_signals,
86 .n_signals = 4 /* XXX array_size(pimd_signals) XXX*/,
87
88 .privs = &pimd_privs,
89 )
90
91
92 int main(int argc, char** argv, char** envp) {
93 frr_preinit(&pimd_di, argc, argv);
94 frr_opt_add("", longopts, "");
95
96 /* this while just reads the options */
97 while (1) {
98 int opt;
99
100 opt = frr_getopt(argc, argv, NULL);
101
102 if (opt == EOF)
103 break;
104
105 switch (opt) {
106 case 0:
107 break;
108 default:
109 frr_help_exit (1);
110 break;
111 }
112 }
113
114 master = frr_init();
115
116 /*
117 * Initializations
118 */
119 pim_vrf_init ();
120 access_list_init();
121 prefix_list_init ();
122 prefix_list_add_hook (pim_prefix_list_update);
123 prefix_list_delete_hook (pim_prefix_list_update);
124
125 pim_route_map_init ();
126 pim_init();
127 pim_msdp_init (master);
128
129 /*
130 * Initialize zclient "update" and "lookup" sockets
131 */
132 pim_zebra_init();
133
134 frr_config_fork();
135
136 #ifdef PIM_DEBUG_BYDEFAULT
137 zlog_notice("PIM_DEBUG_BYDEFAULT: Enabling all debug commands");
138 PIM_DO_DEBUG_PIM_EVENTS;
139 PIM_DO_DEBUG_PIM_PACKETS;
140 PIM_DO_DEBUG_PIM_TRACE;
141 PIM_DO_DEBUG_IGMP_EVENTS;
142 PIM_DO_DEBUG_IGMP_PACKETS;
143 PIM_DO_DEBUG_IGMP_TRACE;
144 PIM_DO_DEBUG_ZEBRA;
145 #endif
146
147 #ifdef PIM_CHECK_RECV_IFINDEX_SANITY
148 zlog_notice("PIM_CHECK_RECV_IFINDEX_SANITY: will match sock/recv ifindex");
149 #ifdef PIM_REPORT_RECV_IFINDEX_MISMATCH
150 zlog_notice("PIM_REPORT_RECV_IFINDEX_MISMATCH: will report sock/recv ifindex mismatch");
151 #endif
152 #endif
153
154 #ifdef PIM_UNEXPECTED_KERNEL_UPCALL
155 zlog_notice("PIM_UNEXPECTED_KERNEL_UPCALL: report unexpected kernel upcall");
156 #endif
157
158 frr_run(master);
159
160 /* never reached */
161 return 0;
162 }