]> git.proxmox.com Git - mirror_frr.git/blame - pimd/pim_main.c
pimd: pim bfd support
[mirror_frr.git] / pimd / pim_main.c
CommitLineData
12e41d03 1/*
896014f4
DL
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 */
12e41d03
DL
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"
fc7948fa
DL
31#include "vrf.h"
32#include "memory_vty.h"
12e41d03
DL
33#include "filter.h"
34#include "vty.h"
35#include "sigevent.h"
36#include "version.h"
0e8ce7e6
DS
37#include "prefix.h"
38#include "plist.h"
48e8451b 39#include "vrf.h"
4f04a76b 40#include "libfrr.h"
12e41d03
DL
41
42#include "pimd.h"
43#include "pim_version.h"
44#include "pim_signals.h"
45#include "pim_zebra.h"
11128587 46#include "pim_msdp.h"
7176984f 47#include "pim_iface.h"
ba4eb1bc 48#include "pim_bfd.h"
12e41d03 49
12e41d03
DL
50extern struct host host;
51
12e41d03 52struct option longopts[] = {
12e41d03
DL
53 { 0 }
54};
55
56/* pimd privileges */
57zebra_capabilities_t _caps_p [] =
58{
59 ZCAP_NET_ADMIN,
60 ZCAP_SYS_ADMIN,
61 ZCAP_NET_RAW,
2a333e0f 62 ZCAP_BIND,
12e41d03
DL
63};
64
65/* pimd privileges to run with */
66struct zebra_privs_t pimd_privs =
67{
b2f36157
DL
68#if defined(FRR_USER) && defined(FRR_GROUP)
69 .user = FRR_USER,
70 .group = FRR_GROUP,
12e41d03
DL
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
4f04a76b
DL
80FRR_DAEMON_INFO(pimd, PIM,
81 .vty_port = PIMD_VTY_PORT,
12e41d03 82
4f04a76b 83 .proghelp = "Implementation of the PIM routing protocol.",
12e41d03 84
4f04a76b
DL
85 .signals = pimd_signals,
86 .n_signals = 4 /* XXX array_size(pimd_signals) XXX*/,
87
88 .privs = &pimd_privs,
89)
12e41d03 90
1bc98276 91
12e41d03 92int main(int argc, char** argv, char** envp) {
4f04a76b 93 frr_preinit(&pimd_di, argc, argv);
eb05883f 94 frr_opt_add("", longopts, "");
4f04a76b
DL
95
96 /* this while just reads the options */
12e41d03
DL
97 while (1) {
98 int opt;
4f04a76b
DL
99
100 opt = frr_getopt(argc, argv, NULL);
101
12e41d03
DL
102 if (opt == EOF)
103 break;
104
105 switch (opt) {
106 case 0:
107 break;
12e41d03 108 default:
4f04a76b 109 frr_help_exit (1);
12e41d03
DL
110 break;
111 }
112 }
113
4f04a76b 114 master = frr_init();
12e41d03 115
12e41d03
DL
116 /*
117 * Initializations
118 */
1bc98276 119 pim_vrf_init ();
12e41d03 120 access_list_init();
0e8ce7e6 121 prefix_list_init ();
15a5dafe 122 prefix_list_add_hook (pim_prefix_list_update);
123 prefix_list_delete_hook (pim_prefix_list_update);
dfe43e25 124
0e8ce7e6 125 pim_route_map_init ();
12e41d03 126 pim_init();
2a333e0f 127 pim_msdp_init (master);
12e41d03
DL
128
129 /*
18a23295 130 * Initialize zclient "update" and "lookup" sockets
12e41d03 131 */
eb05883f 132 pim_zebra_init();
ba4eb1bc 133 pim_bfd_init ();
12e41d03 134
eb05883f 135 frr_config_fork();
12e41d03 136
12e41d03
DL
137#ifdef PIM_DEBUG_BYDEFAULT
138 zlog_notice("PIM_DEBUG_BYDEFAULT: Enabling all debug commands");
139 PIM_DO_DEBUG_PIM_EVENTS;
140 PIM_DO_DEBUG_PIM_PACKETS;
141 PIM_DO_DEBUG_PIM_TRACE;
142 PIM_DO_DEBUG_IGMP_EVENTS;
143 PIM_DO_DEBUG_IGMP_PACKETS;
144 PIM_DO_DEBUG_IGMP_TRACE;
145 PIM_DO_DEBUG_ZEBRA;
146#endif
147
12e41d03
DL
148#ifdef PIM_CHECK_RECV_IFINDEX_SANITY
149 zlog_notice("PIM_CHECK_RECV_IFINDEX_SANITY: will match sock/recv ifindex");
150#ifdef PIM_REPORT_RECV_IFINDEX_MISMATCH
151 zlog_notice("PIM_REPORT_RECV_IFINDEX_MISMATCH: will report sock/recv ifindex mismatch");
152#endif
153#endif
154
155#ifdef PIM_UNEXPECTED_KERNEL_UPCALL
156 zlog_notice("PIM_UNEXPECTED_KERNEL_UPCALL: report unexpected kernel upcall");
157#endif
158
16077f2f 159 frr_run(master);
12e41d03
DL
160
161 /* never reached */
162 return 0;
163}