]> git.proxmox.com Git - mirror_frr.git/blame - pimd/pim_iface.h
Merge pull request #435 from chiragshah6/pim_dev
[mirror_frr.git] / pimd / pim_iface.h
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
83190a40 19 */
12e41d03
DL
20
21#ifndef PIM_IFACE_H
22#define PIM_IFACE_H
23
24#include <zebra.h>
25
26#include "if.h"
27#include "vty.h"
28
29#include "pim_igmp.h"
30#include "pim_upstream.h"
31
32#define PIM_IF_MASK_PIM (1 << 0)
33#define PIM_IF_MASK_IGMP (1 << 1)
34#define PIM_IF_MASK_IGMP_LISTEN_ALLROUTERS (1 << 2)
35#define PIM_IF_MASK_PIM_CAN_DISABLE_JOIN_SUPRESSION (1 << 3)
36
37#define PIM_IF_IS_DELETED(ifp) ((ifp)->ifindex == IFINDEX_INTERNAL)
38
39#define PIM_IF_TEST_PIM(options) (PIM_IF_MASK_PIM & (options))
40#define PIM_IF_TEST_IGMP(options) (PIM_IF_MASK_IGMP & (options))
41#define PIM_IF_TEST_IGMP_LISTEN_ALLROUTERS(options) (PIM_IF_MASK_IGMP_LISTEN_ALLROUTERS & (options))
42#define PIM_IF_TEST_PIM_CAN_DISABLE_JOIN_SUPRESSION(options) (PIM_IF_MASK_PIM_CAN_DISABLE_JOIN_SUPRESSION & (options))
43
44#define PIM_IF_DO_PIM(options) ((options) |= PIM_IF_MASK_PIM)
45#define PIM_IF_DO_IGMP(options) ((options) |= PIM_IF_MASK_IGMP)
46#define PIM_IF_DO_IGMP_LISTEN_ALLROUTERS(options) ((options) |= PIM_IF_MASK_IGMP_LISTEN_ALLROUTERS)
47#define PIM_IF_DO_PIM_CAN_DISABLE_JOIN_SUPRESSION(options) ((options) |= PIM_IF_MASK_PIM_CAN_DISABLE_JOIN_SUPRESSION)
48
49#define PIM_IF_DONT_PIM(options) ((options) &= ~PIM_IF_MASK_PIM)
50#define PIM_IF_DONT_IGMP(options) ((options) &= ~PIM_IF_MASK_IGMP)
51#define PIM_IF_DONT_IGMP_LISTEN_ALLROUTERS(options) ((options) &= ~PIM_IF_MASK_IGMP_LISTEN_ALLROUTERS)
52#define PIM_IF_DONT_PIM_CAN_DISABLE_JOIN_SUPRESSION(options) ((options) &= ~PIM_IF_MASK_PIM_CAN_DISABLE_JOIN_SUPRESSION)
53
df696e3f 54#define PIM_I_am_DR(pim_ifp) (pim_ifp)->pim_dr_addr.s_addr == (pim_ifp)->primary_address.s_addr
84366c7e 55
982bff89
DS
56struct pim_iface_upstream_switch {
57 struct in_addr address;
58 struct list *us;
59};
60
7176984f 61enum pim_secondary_addr_flags {
62 PIM_SEC_ADDRF_NONE = 0,
63 PIM_SEC_ADDRF_STALE = (1 << 0)
64};
65
66struct pim_secondary_addr {
294b6d72 67 struct prefix addr;
7176984f 68 enum pim_secondary_addr_flags flags;
69};
70
12e41d03
DL
71struct pim_interface {
72 uint32_t options; /* bit vector */
b892f1dd 73 ifindex_t mroute_vif_index;
12e41d03 74 struct in_addr primary_address; /* remember addr to detect change */
7176984f 75 struct list *sec_addr_list; /* list of struct pim_secondary_addr */
4763cd0e 76 struct in_addr update_source; /* user can statically set the primary
77 * address of the interface */
12e41d03 78
b05b72e8 79 int igmp_version; /* IGMP version */
12e41d03
DL
80 int igmp_default_robustness_variable; /* IGMPv3 QRV */
81 int igmp_default_query_interval; /* IGMPv3 secs between general queries */
82 int igmp_query_max_response_time_dsec; /* IGMPv3 Max Response Time in dsecs for general queries */
83 int igmp_specific_query_max_response_time_dsec; /* IGMPv3 Max Response Time in dsecs for specific queries */
84 struct list *igmp_socket_list; /* list of struct igmp_sock */
85 struct list *igmp_join_list; /* list of struct igmp_join */
86
87 int pim_sock_fd; /* PIM socket file descriptor */
88 struct thread *t_pim_sock_read; /* thread for reading PIM socket */
89 int64_t pim_sock_creation; /* timestamp of PIM socket creation */
90
91 struct thread *t_pim_hello_timer;
92 int pim_hello_period;
93 int pim_default_holdtime;
94 int pim_triggered_hello_delay;
95 uint32_t pim_generation_id;
96 uint16_t pim_propagation_delay_msec; /* config */
97 uint16_t pim_override_interval_msec; /* config */
98 struct list *pim_neighbor_list; /* list of struct pim_neighbor */
982bff89 99 struct list *upstream_switch_list;
12e41d03 100 struct list *pim_ifchannel_list; /* list of struct pim_ifchannel */
a625e937 101 struct hash *pim_ifchannel_hash;
12e41d03
DL
102
103 /* neighbors without lan_delay */
104 int pim_number_of_nonlandelay_neighbors;
105 uint16_t pim_neighbors_highest_propagation_delay_msec;
106 uint16_t pim_neighbors_highest_override_interval_msec;
107
108 /* DR Election */
109 int64_t pim_dr_election_last; /* timestamp */
110 int pim_dr_election_count;
111 int pim_dr_election_changes;
112 struct in_addr pim_dr_addr;
113 uint32_t pim_dr_priority; /* config */
114 int pim_dr_num_nondrpri_neighbors; /* neighbors without dr_pri */
115
116 int64_t pim_ifstat_start; /* start timestamp for stats */
117 uint32_t pim_ifstat_hello_sent;
118 uint32_t pim_ifstat_hello_sendfail;
119 uint32_t pim_ifstat_hello_recv;
120 uint32_t pim_ifstat_hello_recvfail;
39438188
CS
121 uint32_t pim_ifstat_join_recv;
122 uint32_t pim_ifstat_join_send;
123 uint32_t pim_ifstat_prune_recv;
124 uint32_t pim_ifstat_prune_send;
125 uint32_t pim_ifstat_reg_recv;
126 uint32_t pim_ifstat_reg_send;
127 uint32_t pim_ifstat_reg_stop_recv;
128 uint32_t pim_ifstat_reg_stop_send;
129 uint32_t pim_ifstat_assert_recv;
130 uint32_t pim_ifstat_assert_send;
12e41d03
DL
131};
132
c992c9a0 133extern struct interface *pim_regiface;
ea4a71fc 134extern struct list *pim_ifchannel_list;
12e41d03
DL
135/*
136 if default_holdtime is set (>= 0), use it;
137 otherwise default_holdtime is 3.5 * hello_period
138 */
139#define PIM_IF_DEFAULT_HOLDTIME(pim_ifp) \
140 (((pim_ifp)->pim_default_holdtime < 0) ? \
141 ((pim_ifp)->pim_hello_period * 7 / 2) : \
142 ((pim_ifp)->pim_default_holdtime))
143
144void pim_if_init(void);
ea4a71fc 145void pim_if_terminate (void);
12e41d03
DL
146
147struct pim_interface *pim_if_new(struct interface *ifp, int igmp, int pim);
148void pim_if_delete(struct interface *ifp);
149void pim_if_addr_add(struct connected *ifc);
150void pim_if_addr_del(struct connected *ifc, int force_prim_as_any);
151void pim_if_addr_add_all(struct interface *ifp);
152void pim_if_addr_del_all(struct interface *ifp);
153void pim_if_addr_del_all_igmp(struct interface *ifp);
154void pim_if_addr_del_all_pim(struct interface *ifp);
155
9f0edbc9
DS
156struct interface *pim_if_lookup_address_vrf (struct in_addr src, vrf_id_t vrf_id);
157
12e41d03
DL
158int pim_if_add_vif(struct interface *ifp);
159int pim_if_del_vif(struct interface *ifp);
160void pim_if_add_vif_all(void);
161void pim_if_del_vif_all(void);
162
b892f1dd
PJ
163struct interface *pim_if_find_by_vif_index(ifindex_t vif_index);
164int pim_if_find_vifindex_by_ifindex(ifindex_t ifindex);
12e41d03
DL
165
166int pim_if_lan_delay_enabled(struct interface *ifp);
167uint16_t pim_if_effective_propagation_delay_msec(struct interface *ifp);
168uint16_t pim_if_effective_override_interval_msec(struct interface *ifp);
169uint16_t pim_if_jp_override_interval_msec(struct interface *ifp);
170struct pim_neighbor *pim_if_find_neighbor(struct interface *ifp,
171 struct in_addr addr);
172
173long pim_if_t_suppressed_msec(struct interface *ifp);
174int pim_if_t_override_msec(struct interface *ifp);
175
176struct in_addr pim_find_primary_addr(struct interface *ifp);
177
178int pim_if_igmp_join_add(struct interface *ifp,
179 struct in_addr group_addr,
180 struct in_addr source_addr);
181int pim_if_igmp_join_del(struct interface *ifp,
182 struct in_addr group_addr,
183 struct in_addr source_addr);
184
185void pim_if_update_could_assert(struct interface *ifp);
186
187void pim_if_assert_on_neighbor_down(struct interface *ifp,
188 struct in_addr neigh_addr);
189
190void pim_if_rpf_interface_changed(struct interface *old_rpf_ifp,
191 struct pim_upstream *up);
192
193void pim_if_update_join_desired(struct pim_interface *pim_ifp);
194
195void pim_if_update_assert_tracking_desired(struct interface *ifp);
196
c992c9a0 197void pim_if_create_pimreg(void);
3565202d
DS
198
199int pim_if_connected_to_source (struct interface *ifp, struct in_addr src);
4763cd0e 200int pim_update_source_set(struct interface *ifp, struct in_addr source);
3fdfd943 201
12e41d03 202#endif /* PIM_IFACE_H */