]>
Commit | Line | Data |
---|---|---|
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 | |
12e41d03 DL |
19 | */ |
20 | ||
21 | #ifndef PIM_UPSTREAM_H | |
22 | #define PIM_UPSTREAM_H | |
23 | ||
24 | #include <zebra.h> | |
05e451f8 | 25 | #include <prefix.h> |
12e41d03 | 26 | |
f9717886 | 27 | #include <pimd/pim_rpf.h> |
bfea315d | 28 | |
12e41d03 | 29 | #define PIM_UPSTREAM_FLAG_MASK_DR_JOIN_DESIRED (1 << 0) |
ca973133 DS |
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) | |
1bf16443 | 35 | #define PIM_UPSTREAM_FLAG_MASK_SRC_MSDP (1 << 6) |
12e41d03 DL |
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) | |
69ff3706 | 39 | #define PIM_UPSTREAM_FLAG_TEST_FHR(flags) ((flags) & PIM_UPSTREAM_FLAG_MASK_FHR) |
1d3a62cd DS |
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) | |
7667c556 | 43 | #define PIM_UPSTREAM_FLAG_TEST_SRC_MSDP(flags) ((flags) & PIM_UPSTREAM_FLAG_MASK_SRC_MSDP) |
12e41d03 DL |
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) | |
69ff3706 | 47 | #define PIM_UPSTREAM_FLAG_SET_FHR(flags) ((flags) |= PIM_UPSTREAM_FLAG_MASK_FHR) |
1d3a62cd DS |
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) | |
7667c556 | 51 | #define PIM_UPSTREAM_FLAG_SET_SRC_MSDP(flags) ((flags) |= PIM_UPSTREAM_FLAG_MASK_SRC_MSDP) |
12e41d03 DL |
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) | |
69ff3706 | 55 | #define PIM_UPSTREAM_FLAG_UNSET_FHR(flags) ((flags) &= ~PIM_UPSTREAM_FLAG_MASK_FHR) |
1d3a62cd DS |
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) | |
7667c556 | 59 | #define PIM_UPSTREAM_FLAG_UNSET_SRC_MSDP(flags) ((flags) &= ~PIM_UPSTREAM_FLAG_MASK_SRC_MSDP) |
12e41d03 | 60 | |
12e41d03 DL |
61 | enum pim_upstream_state { |
62 | PIM_UPSTREAM_NOTJOINED, | |
d7259eac | 63 | PIM_UPSTREAM_JOINED, |
12e41d03 DL |
64 | }; |
65 | ||
0c2ebf00 | 66 | enum pim_reg_state { |
67 | PIM_REG_NOINFO, | |
68 | PIM_REG_JOIN, | |
69 | PIM_REG_JOIN_PENDING, | |
70 | PIM_REG_PRUNE, | |
71 | }; | |
72 | ||
d99764f6 DS |
73 | enum pim_upstream_sptbit { |
74 | PIM_UPSTREAM_SPTBIT_FALSE, | |
75 | PIM_UPSTREAM_SPTBIT_TRUE | |
76 | }; | |
77 | ||
12e41d03 DL |
78 | /* |
79 | Upstream (S,G) channel in Joined state | |
80 | ||
81 | (S,G) in the "Not Joined" state is not represented | |
82 | ||
83 | See RFC 4601: 4.5.7. Sending (S,G) Join/Prune Message | |
84 | */ | |
85 | struct pim_upstream { | |
4d99418b | 86 | struct pim_upstream *parent; |
8f5f5e91 | 87 | struct in_addr upstream_addr;/* Who we are talking to */ |
8e38a2cf | 88 | struct in_addr upstream_register; /*Who we received a register from*/ |
4ed0af70 | 89 | struct prefix_sg sg; /* (S,G) group key */ |
8bfb8b67 | 90 | char sg_str[PIM_SG_LEN]; |
12e41d03 DL |
91 | uint32_t flags; |
92 | struct channel_oil *channel_oil; | |
03417ccd | 93 | struct list *sources; |
12e41d03 DL |
94 | |
95 | enum pim_upstream_state join_state; | |
0c2ebf00 | 96 | enum pim_reg_state reg_state; |
d99764f6 DS |
97 | enum pim_upstream_sptbit sptbit; |
98 | ||
12e41d03 DL |
99 | int ref_count; |
100 | ||
101 | struct pim_rpf rpf; | |
102 | ||
103 | struct thread *t_join_timer; | |
4a4c4a07 | 104 | |
2ddab288 DS |
105 | /* |
106 | * RST(S,G) | |
107 | */ | |
108 | struct thread *t_rs_timer; | |
109 | #define PIM_REGISTER_SUPPRESSION_PERIOD (60) | |
70989c7c | 110 | #define PIM_REGISTER_PROBE_PERIOD (15) |
2ddab288 | 111 | |
4a4c4a07 DS |
112 | /* |
113 | * KAT(S,G) | |
114 | */ | |
115 | struct thread *t_ka_timer; | |
116 | #define PIM_KEEPALIVE_PERIOD (210) | |
117 | #define PIM_RP_KEEPALIVE_PERIOD ( 3 * qpim_register_suppress_time + qpim_register_probe_time ) | |
118 | ||
1bf16443 | 119 | /* on the RP we restart a timer to indicate if registers are being rxed for |
120 | * SG. This is needed by MSDP to determine its local SA cache */ | |
121 | struct thread *t_msdp_reg_timer; | |
122 | #define PIM_MSDP_REG_RXED_PERIOD (3 * (1.5 * qpim_register_suppress_time)) | |
123 | ||
12e41d03 DL |
124 | int64_t state_transition; /* Record current state uptime */ |
125 | }; | |
126 | ||
0f588989 DS |
127 | struct list *pim_upstream_list; |
128 | struct hash *pim_upstream_hash; | |
129 | ||
12e41d03 | 130 | void pim_upstream_free(struct pim_upstream *up); |
4ed0af70 | 131 | struct pim_upstream *pim_upstream_find (struct prefix_sg *sg); |
e711cd3c DS |
132 | struct pim_upstream *pim_upstream_find_or_add (struct prefix_sg *sg, |
133 | struct interface *ifp, int flags, | |
134 | const char *name); | |
4ed0af70 | 135 | struct pim_upstream *pim_upstream_add (struct prefix_sg *sg, |
e5905a3b DS |
136 | struct interface *ifp, int flags, |
137 | const char *name); | |
d0db90bf DS |
138 | void pim_upstream_ref (struct pim_upstream *up, int flags); |
139 | struct pim_upstream *pim_upstream_del(struct pim_upstream *up, const char *name); | |
12e41d03 DL |
140 | |
141 | int pim_upstream_evaluate_join_desired(struct pim_upstream *up); | |
9f44d042 DS |
142 | int pim_upstream_evaluate_join_desired_interface(struct pim_upstream *up, |
143 | struct pim_ifchannel *ch); | |
12e41d03 DL |
144 | void pim_upstream_update_join_desired(struct pim_upstream *up); |
145 | ||
146 | void pim_upstream_join_suppress(struct pim_upstream *up, | |
147 | struct in_addr rpf_addr, | |
148 | int holdtime); | |
c48a612c | 149 | |
12e41d03 | 150 | void pim_upstream_join_timer_decrease_to_t_override(const char *debug_label, |
c48a612c DS |
151 | struct pim_upstream *up); |
152 | ||
982bff89 | 153 | void pim_upstream_join_timer_restart(struct pim_upstream *up, struct pim_rpf *old); |
12e41d03 DL |
154 | void pim_upstream_rpf_genid_changed(struct in_addr neigh_addr); |
155 | void pim_upstream_rpf_interface_changed(struct pim_upstream *up, | |
156 | struct interface *old_rpf_ifp); | |
157 | ||
158 | void pim_upstream_update_could_assert(struct pim_upstream *up); | |
159 | void pim_upstream_update_my_assert_metric(struct pim_upstream *up); | |
160 | ||
f14248dd | 161 | void pim_upstream_keep_alive_timer_start (struct pim_upstream *up, uint32_t time); |
cb40b272 | 162 | |
4ed0af70 | 163 | int pim_upstream_switch_to_spt_desired (struct prefix_sg *sg); |
ad410c6c | 164 | #define SwitchToSptDesired(sg) pim_upstream_switch_to_spt_desired (sg) |
80d9c3a0 | 165 | int pim_upstream_is_sg_rpt (struct pim_upstream *up); |
cb40b272 | 166 | |
3a66b17b DS |
167 | void pim_upstream_set_sptbit (struct pim_upstream *up, struct interface *incoming); |
168 | ||
627ed2a3 DS |
169 | void pim_upstream_start_register_stop_timer (struct pim_upstream *up, int null_register); |
170 | ||
56638739 DS |
171 | void pim_upstream_send_join (struct pim_upstream *up); |
172 | ||
7fcdfb34 DS |
173 | void pim_upstream_switch (struct pim_upstream *up, enum pim_upstream_state new_state); |
174 | ||
c9802954 | 175 | const char *pim_upstream_state2str (enum pim_upstream_state join_state); |
e0e127b0 | 176 | #define PIM_REG_STATE_STR_LEN 12 |
0c2ebf00 | 177 | const char *pim_reg_state2str (enum pim_reg_state state, char *state_str); |
4fdc8f36 | 178 | |
b5183fd1 | 179 | int pim_upstream_inherited_olist_decide (struct pim_upstream *up); |
4fdc8f36 | 180 | int pim_upstream_inherited_olist (struct pim_upstream *up); |
80d9c3a0 | 181 | int pim_upstream_empty_inherited_olist (struct pim_upstream *up); |
d3dd1804 DS |
182 | |
183 | void pim_upstream_find_new_rpf (void); | |
1bf16443 | 184 | void pim_upstream_msdp_reg_timer_start(struct pim_upstream *up); |
d3dd1804 | 185 | |
0f588989 DS |
186 | void pim_upstream_init (void); |
187 | void pim_upstream_terminate (void); | |
982bff89 DS |
188 | |
189 | void join_timer_start (struct pim_upstream *up); | |
1bc98276 | 190 | int pim_upstream_compare (void *arg1, void *arg2); |
12e41d03 | 191 | #endif /* PIM_UPSTREAM_H */ |