]> git.proxmox.com Git - mirror_frr.git/blame - pimd/pimd.c
pimd: Modify the RP data structure.
[mirror_frr.git] / pimd / pimd.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
19
20 $QuaggaId: $Format:%an, %ai, %h$ $
21*/
22
23#include <zebra.h>
24
25#include "log.h"
26#include "memory.h"
27
28#include "pimd.h"
29#include "pim_cmd.h"
30#include "pim_iface.h"
31#include "pim_zebra.h"
32#include "pim_str.h"
33#include "pim_oil.h"
34#include "pim_pim.h"
35#include "pim_upstream.h"
12e41d03
DL
36#include "pim_rpf.h"
37#include "pim_ssmpingd.h"
6250610a 38#include "pim_static.h"
12e41d03
DL
39
40const char *const PIM_ALL_SYSTEMS = MCAST_ALL_SYSTEMS;
41const char *const PIM_ALL_ROUTERS = MCAST_ALL_ROUTERS;
42const char *const PIM_ALL_PIM_ROUTERS = MCAST_ALL_PIM_ROUTERS;
43const char *const PIM_ALL_IGMP_ROUTERS = MCAST_ALL_IGMP_ROUTERS;
44
469351b3 45struct thread_master *master = NULL;
12e41d03
DL
46uint32_t qpim_debugs = 0;
47int qpim_mroute_socket_fd = -1;
48int64_t qpim_mroute_socket_creation = 0; /* timestamp of creation */
49struct thread *qpim_mroute_socket_reader = 0;
50int qpim_mroute_oif_highest_vif_index = -1;
51struct list *qpim_channel_oil_list = 0;
52int qpim_t_periodic = PIM_DEFAULT_T_PERIODIC; /* Period between Join/Prune Messages */
53struct list *qpim_upstream_list = 0;
54struct zclient *qpim_zclient_update = 0;
55struct zclient *qpim_zclient_lookup = 0;
56struct pim_assert_metric qpim_infinite_assert_metric;
57long qpim_rpf_cache_refresh_delay_msec = 10000;
58struct thread *qpim_rpf_cache_refresher = 0;
59int64_t qpim_rpf_cache_refresh_requests = 0;
60int64_t qpim_rpf_cache_refresh_events = 0;
61int64_t qpim_rpf_cache_refresh_last = 0;
62struct in_addr qpim_inaddr_any;
63struct list *qpim_ssmpingd_list = 0;
64struct in_addr qpim_ssmpingd_group_addr;
65int64_t qpim_scan_oil_events = 0;
66int64_t qpim_scan_oil_last = 0;
67int64_t qpim_mroute_add_events = 0;
68int64_t qpim_mroute_add_last = 0;
69int64_t qpim_mroute_del_events = 0;
70int64_t qpim_mroute_del_last = 0;
6250610a 71struct list *qpim_static_route_list = 0;
c8ae3ce8 72struct pim_rpf qpim_rp = { .rpf_addr.s_addr = INADDR_NONE };
12e41d03 73
4a4c4a07
DS
74int32_t qpim_register_suppress_time = PIM_REGISTER_SUPPRESSION_TIME_DEFAULT;
75int32_t qpim_register_probe_time = PIM_REGISTER_PROBE_TIME_DEFAULT;
76
12e41d03
DL
77static void pim_free()
78{
79 pim_ssmpingd_destroy();
80
81 if (qpim_channel_oil_list)
82 list_free(qpim_channel_oil_list);
83
84 if (qpim_upstream_list)
85 list_free(qpim_upstream_list);
6250610a
JAG
86
87 if (qpim_static_route_list)
88 list_free(qpim_static_route_list);
12e41d03
DL
89}
90
91void pim_init()
92{
60b40924 93 srandom(time(NULL));
12e41d03
DL
94
95 if (!inet_aton(PIM_ALL_PIM_ROUTERS, &qpim_all_pim_routers_addr)) {
96 zlog_err("%s %s: could not solve %s to group address: errno=%d: %s",
97 __FILE__, __PRETTY_FUNCTION__,
98 PIM_ALL_PIM_ROUTERS, errno, safe_strerror(errno));
99 zassert(0);
100 return;
101 }
102
103 qpim_channel_oil_list = list_new();
104 if (!qpim_channel_oil_list) {
105 zlog_err("%s %s: failure: channel_oil_list=list_new()",
106 __FILE__, __PRETTY_FUNCTION__);
107 return;
108 }
109 qpim_channel_oil_list->del = (void (*)(void *)) pim_channel_oil_free;
110
111 qpim_upstream_list = list_new();
112 if (!qpim_upstream_list) {
113 zlog_err("%s %s: failure: upstream_list=list_new()",
114 __FILE__, __PRETTY_FUNCTION__);
115 pim_free();
116 return;
117 }
118 qpim_upstream_list->del = (void (*)(void *)) pim_upstream_free;
119
6250610a
JAG
120 qpim_static_route_list = list_new();
121 if (!qpim_static_route_list) {
122 zlog_err("%s %s: failure: static_route_list=list_new()",
123 __FILE__, __PRETTY_FUNCTION__);
124 return;
125 }
126 qpim_static_route_list->del = (void (*)(void *)) pim_static_route_free;
127
12e41d03
DL
128 qpim_mroute_socket_fd = -1; /* mark mroute as disabled */
129 qpim_mroute_oif_highest_vif_index = -1;
130
131 zassert(!qpim_debugs);
132 zassert(!PIM_MROUTE_IS_ENABLED);
133
134 qpim_inaddr_any.s_addr = PIM_NET_INADDR_ANY;
135
136 /*
137 RFC 4601: 4.6.3. Assert Metrics
138
139 assert_metric
140 infinite_assert_metric() {
141 return {1,infinity,infinity,0}
142 }
143 */
144 qpim_infinite_assert_metric.rpt_bit_flag = 1;
145 qpim_infinite_assert_metric.metric_preference = PIM_ASSERT_METRIC_PREFERENCE_MAX;
146 qpim_infinite_assert_metric.route_metric = PIM_ASSERT_ROUTE_METRIC_MAX;
147 qpim_infinite_assert_metric.ip_address = qpim_inaddr_any;
148
149 pim_if_init();
150 pim_cmd_init();
151 pim_ssmpingd_init();
152}
153
154void pim_terminate()
155{
156 pim_free();
157}