]>
Commit | Line | Data |
---|---|---|
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 | |
83190a40 | 18 | */ |
12e41d03 DL |
19 | |
20 | #ifndef PIM_IFACE_H | |
21 | #define PIM_IFACE_H | |
22 | ||
23 | #include <zebra.h> | |
24 | ||
25 | #include "if.h" | |
26 | #include "vty.h" | |
ba4eb1bc CS |
27 | #include "vrf.h" |
28 | #include "zclient.h" | |
37664928 | 29 | #include "ferr.h" |
12e41d03 DL |
30 | |
31 | #include "pim_igmp.h" | |
32 | #include "pim_upstream.h" | |
ba4eb1bc | 33 | #include "bfd.h" |
12e41d03 DL |
34 | |
35 | #define PIM_IF_MASK_PIM (1 << 0) | |
36 | #define PIM_IF_MASK_IGMP (1 << 1) | |
37 | #define PIM_IF_MASK_IGMP_LISTEN_ALLROUTERS (1 << 2) | |
38 | #define PIM_IF_MASK_PIM_CAN_DISABLE_JOIN_SUPRESSION (1 << 3) | |
39 | ||
40 | #define PIM_IF_IS_DELETED(ifp) ((ifp)->ifindex == IFINDEX_INTERNAL) | |
41 | ||
42 | #define PIM_IF_TEST_PIM(options) (PIM_IF_MASK_PIM & (options)) | |
43 | #define PIM_IF_TEST_IGMP(options) (PIM_IF_MASK_IGMP & (options)) | |
44 | #define PIM_IF_TEST_IGMP_LISTEN_ALLROUTERS(options) (PIM_IF_MASK_IGMP_LISTEN_ALLROUTERS & (options)) | |
45 | #define PIM_IF_TEST_PIM_CAN_DISABLE_JOIN_SUPRESSION(options) (PIM_IF_MASK_PIM_CAN_DISABLE_JOIN_SUPRESSION & (options)) | |
46 | ||
47 | #define PIM_IF_DO_PIM(options) ((options) |= PIM_IF_MASK_PIM) | |
48 | #define PIM_IF_DO_IGMP(options) ((options) |= PIM_IF_MASK_IGMP) | |
49 | #define PIM_IF_DO_IGMP_LISTEN_ALLROUTERS(options) ((options) |= PIM_IF_MASK_IGMP_LISTEN_ALLROUTERS) | |
50 | #define PIM_IF_DO_PIM_CAN_DISABLE_JOIN_SUPRESSION(options) ((options) |= PIM_IF_MASK_PIM_CAN_DISABLE_JOIN_SUPRESSION) | |
51 | ||
52 | #define PIM_IF_DONT_PIM(options) ((options) &= ~PIM_IF_MASK_PIM) | |
53 | #define PIM_IF_DONT_IGMP(options) ((options) &= ~PIM_IF_MASK_IGMP) | |
54 | #define PIM_IF_DONT_IGMP_LISTEN_ALLROUTERS(options) ((options) &= ~PIM_IF_MASK_IGMP_LISTEN_ALLROUTERS) | |
55 | #define PIM_IF_DONT_PIM_CAN_DISABLE_JOIN_SUPRESSION(options) ((options) &= ~PIM_IF_MASK_PIM_CAN_DISABLE_JOIN_SUPRESSION) | |
56 | ||
df696e3f | 57 | #define PIM_I_am_DR(pim_ifp) (pim_ifp)->pim_dr_addr.s_addr == (pim_ifp)->primary_address.s_addr |
22c35834 | 58 | #define PIM_I_am_DualActive(pim_ifp) (pim_ifp)->activeactive == true |
84366c7e | 59 | |
982bff89 | 60 | struct pim_iface_upstream_switch { |
d62a17ae | 61 | struct in_addr address; |
62 | struct list *us; | |
982bff89 DS |
63 | }; |
64 | ||
7176984f | 65 | enum pim_secondary_addr_flags { |
d62a17ae | 66 | PIM_SEC_ADDRF_NONE = 0, |
67 | PIM_SEC_ADDRF_STALE = (1 << 0) | |
7176984f | 68 | }; |
69 | ||
70 | struct pim_secondary_addr { | |
d62a17ae | 71 | struct prefix addr; |
72 | enum pim_secondary_addr_flags flags; | |
7176984f | 73 | }; |
74 | ||
12e41d03 | 75 | struct pim_interface { |
d62a17ae | 76 | uint32_t options; /* bit vector */ |
77 | ifindex_t mroute_vif_index; | |
c3bd5a10 DS |
78 | struct pim_instance *pim; |
79 | ||
d62a17ae | 80 | struct in_addr primary_address; /* remember addr to detect change */ |
81 | struct list *sec_addr_list; /* list of struct pim_secondary_addr */ | |
82 | struct in_addr update_source; /* user can statically set the primary | |
83 | * address of the interface */ | |
84 | ||
996c9314 LB |
85 | int igmp_version; /* IGMP version */ |
86 | int igmp_default_robustness_variable; /* IGMPv3 QRV */ | |
87 | int igmp_default_query_interval; /* IGMPv3 secs between general | |
d62a17ae | 88 | queries */ |
89 | int igmp_query_max_response_time_dsec; /* IGMPv3 Max Response Time in | |
90 | dsecs for general queries */ | |
91 | int igmp_specific_query_max_response_time_dsec; /* IGMPv3 Max Response | |
59115451 SP |
92 | Time in dsecs called |
93 | as last member query | |
94 | interval, defines the | |
95 | maximum response time | |
96 | advertised in IGMP | |
97 | group-specific | |
98 | queries */ | |
99 | int igmp_last_member_query_count; /* IGMP last member query count */ | |
d62a17ae | 100 | struct list *igmp_socket_list; /* list of struct igmp_sock */ |
101 | struct list *igmp_join_list; /* list of struct igmp_join */ | |
102 | ||
103 | int pim_sock_fd; /* PIM socket file descriptor */ | |
104 | struct thread *t_pim_sock_read; /* thread for reading PIM socket */ | |
105 | int64_t pim_sock_creation; /* timestamp of PIM socket creation */ | |
106 | ||
107 | struct thread *t_pim_hello_timer; | |
108 | int pim_hello_period; | |
109 | int pim_default_holdtime; | |
110 | int pim_triggered_hello_delay; | |
111 | uint32_t pim_generation_id; | |
112 | uint16_t pim_propagation_delay_msec; /* config */ | |
113 | uint16_t pim_override_interval_msec; /* config */ | |
114 | struct list *pim_neighbor_list; /* list of struct pim_neighbor */ | |
115 | struct list *upstream_switch_list; | |
ad7b74c4 | 116 | struct pim_ifchannel_rb ifchannel_rb; |
d62a17ae | 117 | |
118 | /* neighbors without lan_delay */ | |
119 | int pim_number_of_nonlandelay_neighbors; | |
120 | uint16_t pim_neighbors_highest_propagation_delay_msec; | |
121 | uint16_t pim_neighbors_highest_override_interval_msec; | |
122 | ||
123 | /* DR Election */ | |
124 | int64_t pim_dr_election_last; /* timestamp */ | |
125 | int pim_dr_election_count; | |
126 | int pim_dr_election_changes; | |
127 | struct in_addr pim_dr_addr; | |
128 | uint32_t pim_dr_priority; /* config */ | |
129 | int pim_dr_num_nondrpri_neighbors; /* neighbors without dr_pri */ | |
130 | ||
b0f525a8 QY |
131 | /* boundary prefix-list */ |
132 | char *boundary_oil_plist; | |
133 | ||
414d885a DS |
134 | /* Turn on Active-Active for this interface */ |
135 | bool activeactive; | |
136 | ||
d62a17ae | 137 | int64_t pim_ifstat_start; /* start timestamp for stats */ |
8a4dfb5d | 138 | uint64_t pim_ifstat_bsm_rx; |
139 | uint64_t pim_ifstat_bsm_tx; | |
d62a17ae | 140 | uint32_t pim_ifstat_hello_sent; |
141 | uint32_t pim_ifstat_hello_sendfail; | |
142 | uint32_t pim_ifstat_hello_recv; | |
143 | uint32_t pim_ifstat_hello_recvfail; | |
144 | uint32_t pim_ifstat_join_recv; | |
145 | uint32_t pim_ifstat_join_send; | |
146 | uint32_t pim_ifstat_prune_recv; | |
147 | uint32_t pim_ifstat_prune_send; | |
148 | uint32_t pim_ifstat_reg_recv; | |
149 | uint32_t pim_ifstat_reg_send; | |
150 | uint32_t pim_ifstat_reg_stop_recv; | |
151 | uint32_t pim_ifstat_reg_stop_send; | |
152 | uint32_t pim_ifstat_assert_recv; | |
153 | uint32_t pim_ifstat_assert_send; | |
8a4dfb5d | 154 | uint32_t pim_ifstat_bsm_cfg_miss; |
155 | uint32_t pim_ifstat_ucast_bsm_cfg_miss; | |
156 | uint32_t pim_ifstat_bsm_invalid_sz; | |
d62a17ae | 157 | struct bfd_info *bfd_info; |
8a4dfb5d | 158 | bool bsm_enable; /* bsm processing enable */ |
159 | bool ucast_bsm_accept; /* ucast bsm processing */ | |
12e41d03 DL |
160 | }; |
161 | ||
162 | /* | |
163 | if default_holdtime is set (>= 0), use it; | |
164 | otherwise default_holdtime is 3.5 * hello_period | |
165 | */ | |
d62a17ae | 166 | #define PIM_IF_DEFAULT_HOLDTIME(pim_ifp) \ |
167 | (((pim_ifp)->pim_default_holdtime < 0) \ | |
168 | ? ((pim_ifp)->pim_hello_period * 7 / 2) \ | |
169 | : ((pim_ifp)->pim_default_holdtime)) | |
12e41d03 | 170 | |
f88df3a6 DS |
171 | void pim_if_init(struct pim_instance *pim); |
172 | void pim_if_terminate(struct pim_instance *pim); | |
12e41d03 | 173 | |
85a13586 | 174 | struct pim_interface *pim_if_new(struct interface *ifp, bool igmp, bool pim, |
b1891fa0 | 175 | bool ispimreg, bool is_vxlan_term); |
d62a17ae | 176 | void pim_if_delete(struct interface *ifp); |
12e41d03 DL |
177 | void pim_if_addr_add(struct connected *ifc); |
178 | void pim_if_addr_del(struct connected *ifc, int force_prim_as_any); | |
179 | void pim_if_addr_add_all(struct interface *ifp); | |
180 | void pim_if_addr_del_all(struct interface *ifp); | |
181 | void pim_if_addr_del_all_igmp(struct interface *ifp); | |
182 | void pim_if_addr_del_all_pim(struct interface *ifp); | |
183 | ||
b1891fa0 | 184 | int pim_if_add_vif(struct interface *ifp, bool ispimreg, bool is_vxlan_term); |
12e41d03 | 185 | int pim_if_del_vif(struct interface *ifp); |
f88df3a6 DS |
186 | void pim_if_add_vif_all(struct pim_instance *pim); |
187 | void pim_if_del_vif_all(struct pim_instance *pim); | |
12e41d03 | 188 | |
7cfc7bcf DS |
189 | struct interface *pim_if_find_by_vif_index(struct pim_instance *pim, |
190 | ifindex_t vif_index); | |
191 | int pim_if_find_vifindex_by_ifindex(struct pim_instance *pim, | |
192 | ifindex_t ifindex); | |
12e41d03 DL |
193 | |
194 | int pim_if_lan_delay_enabled(struct interface *ifp); | |
195 | uint16_t pim_if_effective_propagation_delay_msec(struct interface *ifp); | |
196 | uint16_t pim_if_effective_override_interval_msec(struct interface *ifp); | |
197 | uint16_t pim_if_jp_override_interval_msec(struct interface *ifp); | |
198 | struct pim_neighbor *pim_if_find_neighbor(struct interface *ifp, | |
199 | struct in_addr addr); | |
200 | ||
201 | long pim_if_t_suppressed_msec(struct interface *ifp); | |
202 | int pim_if_t_override_msec(struct interface *ifp); | |
203 | ||
204 | struct in_addr pim_find_primary_addr(struct interface *ifp); | |
205 | ||
37664928 DS |
206 | ferr_r pim_if_igmp_join_add(struct interface *ifp, struct in_addr group_addr, |
207 | struct in_addr source_addr); | |
d62a17ae | 208 | int pim_if_igmp_join_del(struct interface *ifp, struct in_addr group_addr, |
12e41d03 DL |
209 | struct in_addr source_addr); |
210 | ||
211 | void pim_if_update_could_assert(struct interface *ifp); | |
212 | ||
213 | void pim_if_assert_on_neighbor_down(struct interface *ifp, | |
214 | struct in_addr neigh_addr); | |
215 | ||
216 | void pim_if_rpf_interface_changed(struct interface *old_rpf_ifp, | |
217 | struct pim_upstream *up); | |
218 | ||
219 | void pim_if_update_join_desired(struct pim_interface *pim_ifp); | |
220 | ||
221 | void pim_if_update_assert_tracking_desired(struct interface *ifp); | |
222 | ||
43e40fdf | 223 | void pim_if_create_pimreg(struct pim_instance *pim); |
3565202d | 224 | |
d62a17ae | 225 | int pim_if_connected_to_source(struct interface *ifp, struct in_addr src); |
4763cd0e | 226 | int pim_update_source_set(struct interface *ifp, struct in_addr source); |
3fdfd943 | 227 | |
e55a43d4 | 228 | bool pim_if_is_vrf_device(struct interface *ifp); |
ad7b74c4 DS |
229 | |
230 | int pim_if_ifchannel_count(struct pim_interface *pim_ifp); | |
138c5a74 DS |
231 | |
232 | extern int pim_ifp_create(struct interface *ifp); | |
233 | extern int pim_ifp_up(struct interface *ifp); | |
234 | extern int pim_ifp_down(struct interface *ifp); | |
235 | extern int pim_ifp_destroy(struct interface *ifp); | |
236 | ||
12e41d03 | 237 | #endif /* PIM_IFACE_H */ |