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