]> git.proxmox.com Git - mirror_frr.git/blob - pimd/pim_upstream.h
f36b6fba8b0c0e8abd37183271997ea3e5ea4a02
[mirror_frr.git] / pimd / pim_upstream.h
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
21 #ifndef PIM_UPSTREAM_H
22 #define PIM_UPSTREAM_H
23
24 #include <zebra.h>
25 #include <prefix.h>
26
27 #include <pimd/pim_rpf.h>
28
29 #define PIM_UPSTREAM_FLAG_MASK_DR_JOIN_DESIRED (1 << 0)
30 #define PIM_UPSTREAM_FLAG_MASK_DR_JOIN_DESIRED_UPDATED (1 << 1)
31 #define PIM_UPSTREAM_FLAG_MASK_FHR (1 << 2)
32 #define PIM_UPSTREAM_FLAG_MASK_SRC_IGMP (1 << 3)
33 #define PIM_UPSTREAM_FLAG_MASK_SRC_PIM (1 << 4)
34 #define PIM_UPSTREAM_FLAG_MASK_SRC_STREAM (1 << 5)
35 #define PIM_UPSTREAM_FLAG_MASK_SRC_MSDP (1 << 6)
36
37 #define PIM_UPSTREAM_FLAG_TEST_DR_JOIN_DESIRED(flags) ((flags) & PIM_UPSTREAM_FLAG_MASK_DR_JOIN_DESIRED)
38 #define PIM_UPSTREAM_FLAG_TEST_DR_JOIN_DESIRED_UPDATED(flags) ((flags) & PIM_UPSTREAM_FLAG_MASK_DR_JOIN_DESIRED_UPDATED)
39 #define PIM_UPSTREAM_FLAG_TEST_FHR(flags) ((flags) & PIM_UPSTREAM_FLAG_MASK_FHR)
40 #define PIM_UPSTREAM_FLAG_TEST_SRC_IGMP(flags) ((flags) & PIM_UPSTREAM_FLAG_MASK_SRC_IGMP)
41 #define PIM_UPSTREAM_FLAG_TEST_SRC_PIM(flags) ((flags) & PIM_UPSTREAM_FLAG_MASK_SRC_PIM)
42 #define PIM_UPSTREAM_FLAG_TEST_SRC_STREAM(flags) ((flags) & PIM_UPSTREAM_FLAG_MASK_SRC_STREAM)
43 #define PIM_UPSTREAM_FLAG_TEST_SRC_MSDP(flags) ((flags) & PIM_UPSTREAM_FLAG_MASK_SRC_MSDP)
44
45 #define PIM_UPSTREAM_FLAG_SET_DR_JOIN_DESIRED(flags) ((flags) |= PIM_UPSTREAM_FLAG_MASK_DR_JOIN_DESIRED)
46 #define PIM_UPSTREAM_FLAG_SET_DR_JOIN_DESIRED_UPDATED(flags) ((flags) |= PIM_UPSTREAM_FLAG_MASK_DR_JOIN_DESIRED_UPDATED)
47 #define PIM_UPSTREAM_FLAG_SET_FHR(flags) ((flags) |= PIM_UPSTREAM_FLAG_MASK_FHR)
48 #define PIM_UPSTREAM_FLAG_SET_SRC_IGMP(flags) ((flags) |= PIM_UPSTREAM_FLAG_MASK_SRC_IGMP)
49 #define PIM_UPSTREAM_FLAG_SET_SRC_PIM(flags) ((flags) |= PIM_UPSTREAM_FLAG_MASK_SRC_PIM)
50 #define PIM_UPSTREAM_FLAG_SET_SRC_STREAM(flags) ((flags) |= PIM_UPSTREAM_FLAG_MASK_SRC_STREAM)
51 #define PIM_UPSTREAM_FLAG_SET_SRC_MSDP(flags) ((flags) |= PIM_UPSTREAM_FLAG_MASK_SRC_MSDP)
52
53 #define PIM_UPSTREAM_FLAG_UNSET_DR_JOIN_DESIRED(flags) ((flags) &= ~PIM_UPSTREAM_FLAG_MASK_DR_JOIN_DESIRED)
54 #define PIM_UPSTREAM_FLAG_UNSET_DR_JOIN_DESIRED_UPDATED(flags) ((flags) &= ~PIM_UPSTREAM_FLAG_MASK_DR_JOIN_DESIRED_UPDATED)
55 #define PIM_UPSTREAM_FLAG_UNSET_FHR(flags) ((flags) &= ~PIM_UPSTREAM_FLAG_MASK_FHR)
56 #define PIM_UPSTREAM_FLAG_UNSET_SRC_IGMP(flags) ((flags) &= ~PIM_UPSTREAM_FLAG_MASK_SRC_IGMP)
57 #define PIM_UPSTREAM_FLAG_UNSET_SRC_PIM(flags) ((flags) &= ~PIM_UPSTREAM_FLAG_MASK_SRC_PIM)
58 #define PIM_UPSTREAM_FLAG_UNSET_SRC_STREAM(flags) ((flags) &= ~PIM_UPSTREAM_FLAG_MASK_SRC_STREAM)
59 #define PIM_UPSTREAM_FLAG_UNSET_SRC_MSDP(flags) ((flags) &= ~PIM_UPSTREAM_FLAG_MASK_SRC_MSDP)
60
61 enum pim_upstream_state {
62 PIM_UPSTREAM_NOTJOINED,
63 PIM_UPSTREAM_JOINED,
64 PIM_UPSTREAM_JOIN_PENDING,
65 PIM_UPSTREAM_PRUNE,
66 };
67
68 enum pim_upstream_sptbit {
69 PIM_UPSTREAM_SPTBIT_FALSE,
70 PIM_UPSTREAM_SPTBIT_TRUE
71 };
72
73 /*
74 Upstream (S,G) channel in Joined state
75
76 (S,G) in the "Not Joined" state is not represented
77
78 See RFC 4601: 4.5.7. Sending (S,G) Join/Prune Message
79 */
80 struct pim_upstream {
81 struct pim_upstream *parent;
82 struct in_addr upstream_addr;/* Who we are talking to */
83 struct in_addr upstream_register; /*Who we received a register from*/
84 struct prefix_sg sg; /* (S,G) group key */
85 char sg_str[PIM_SG_LEN];
86 uint32_t flags;
87 struct channel_oil *channel_oil;
88 struct list *sources;
89
90 enum pim_upstream_state join_state;
91 enum pim_upstream_sptbit sptbit;
92
93 int ref_count;
94
95 struct pim_rpf rpf;
96
97 struct thread *t_join_timer;
98
99 /*
100 * RST(S,G)
101 */
102 struct thread *t_rs_timer;
103 #define PIM_REGISTER_SUPPRESSION_PERIOD (60)
104 #define PIM_REGISTER_PROBE_PERIOD (15)
105
106 /*
107 * KAT(S,G)
108 */
109 struct thread *t_ka_timer;
110 #define PIM_KEEPALIVE_PERIOD (210)
111 #define PIM_RP_KEEPALIVE_PERIOD ( 3 * qpim_register_suppress_time + qpim_register_probe_time )
112
113 /* on the RP we restart a timer to indicate if registers are being rxed for
114 * SG. This is needed by MSDP to determine its local SA cache */
115 struct thread *t_msdp_reg_timer;
116 #define PIM_MSDP_REG_RXED_PERIOD (3 * (1.5 * qpim_register_suppress_time))
117
118 int64_t state_transition; /* Record current state uptime */
119 };
120
121 struct list *pim_upstream_list;
122 struct hash *pim_upstream_hash;
123
124 void pim_upstream_free(struct pim_upstream *up);
125 struct pim_upstream *pim_upstream_find (struct prefix_sg *sg);
126 struct pim_upstream *pim_upstream_add (struct prefix_sg *sg,
127 struct interface *ifp, int flags,
128 const char *name);
129 void pim_upstream_del(struct pim_upstream *up, const char *name);
130
131 int pim_upstream_evaluate_join_desired(struct pim_upstream *up);
132 int pim_upstream_evaluate_join_desired_interface(struct pim_upstream *up,
133 struct pim_ifchannel *ch);
134 void pim_upstream_update_join_desired(struct pim_upstream *up);
135
136 void pim_upstream_join_suppress(struct pim_upstream *up,
137 struct in_addr rpf_addr,
138 int holdtime);
139
140 void pim_upstream_join_timer_decrease_to_t_override(const char *debug_label,
141 struct pim_upstream *up);
142
143 void pim_upstream_join_timer_restart(struct pim_upstream *up);
144 void pim_upstream_rpf_genid_changed(struct in_addr neigh_addr);
145 void pim_upstream_rpf_interface_changed(struct pim_upstream *up,
146 struct interface *old_rpf_ifp);
147
148 void pim_upstream_update_could_assert(struct pim_upstream *up);
149 void pim_upstream_update_my_assert_metric(struct pim_upstream *up);
150
151 void pim_upstream_keep_alive_timer_start (struct pim_upstream *up, uint32_t time);
152
153 int pim_upstream_switch_to_spt_desired (struct prefix_sg *sg);
154 #define SwitchToSptDesired(sg) pim_upstream_switch_to_spt_desired (sg)
155 int pim_upstream_is_sg_rpt (struct pim_upstream *up);
156
157 void pim_upstream_set_sptbit (struct pim_upstream *up, struct interface *incoming);
158
159 void pim_upstream_start_register_stop_timer (struct pim_upstream *up, int null_register);
160
161 void pim_upstream_send_join (struct pim_upstream *up);
162
163 void pim_upstream_switch (struct pim_upstream *up, enum pim_upstream_state new_state);
164
165 const char *pim_upstream_state2str (enum pim_upstream_state join_state);
166
167 int pim_upstream_inherited_olist_decide (struct pim_upstream *up);
168 int pim_upstream_inherited_olist (struct pim_upstream *up);
169 int pim_upstream_empty_inherited_olist (struct pim_upstream *up);
170
171 void pim_upstream_find_new_rpf (void);
172 void pim_upstream_msdp_reg_timer_start(struct pim_upstream *up);
173
174 void pim_upstream_init (void);
175 void pim_upstream_terminate (void);
176 #endif /* PIM_UPSTREAM_H */