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