]> git.proxmox.com Git - mirror_frr.git/blame - pimd/pim_upstream.h
pimd: Rework approach for needing nbrs
[mirror_frr.git] / pimd / pim_upstream.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
19
12e41d03
DL
20*/
21
22#ifndef PIM_UPSTREAM_H
23#define PIM_UPSTREAM_H
24
25#include <zebra.h>
05e451f8 26#include <prefix.h>
12e41d03 27
f9717886 28#include <pimd/pim_rpf.h>
bfea315d 29
12e41d03
DL
30#define PIM_UPSTREAM_FLAG_MASK_DR_JOIN_DESIRED (1 << 0)
31#define PIM_UPSTREAM_FLAG_MASK_DR_JOIN_DESIRED_UPDATED (2 << 0)
69ff3706 32#define PIM_UPSTREAM_FLAG_MASK_FHR (3 << 0)
1d3a62cd
DS
33#define PIM_UPSTREAM_FLAG_MASK_SRC_IGMP (4 << 0)
34#define PIM_UPSTREAM_FLAG_MASK_SRC_PIM (5 << 0)
35#define PIM_UPSTREAM_FLAG_MASK_SRC_STREAM (6 << 0)
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)
12e41d03
DL
43
44#define PIM_UPSTREAM_FLAG_SET_DR_JOIN_DESIRED(flags) ((flags) |= PIM_UPSTREAM_FLAG_MASK_DR_JOIN_DESIRED)
45#define PIM_UPSTREAM_FLAG_SET_DR_JOIN_DESIRED_UPDATED(flags) ((flags) |= PIM_UPSTREAM_FLAG_MASK_DR_JOIN_DESIRED_UPDATED)
69ff3706 46#define PIM_UPSTREAM_FLAG_SET_FHR(flags) ((flags) |= PIM_UPSTREAM_FLAG_MASK_FHR)
1d3a62cd
DS
47#define PIM_UPSTREAM_FLAG_SET_SRC_IGMP(flags) ((flags) |= PIM_UPSTREAM_FLAG_MASK_SRC_IGMP)
48#define PIM_UPSTREAM_FLAG_SET_SRC_PIM(flags) ((flags) |= PIM_UPSTREAM_FLAG_MASK_SRC_PIM)
49#define PIM_UPSTREAM_FLAG_SET_SRC_STREAM(flags) ((flags) |= PIM_UPSTREAM_FLAG_MASK_SRC_STREAM)
12e41d03
DL
50
51#define PIM_UPSTREAM_FLAG_UNSET_DR_JOIN_DESIRED(flags) ((flags) &= ~PIM_UPSTREAM_FLAG_MASK_DR_JOIN_DESIRED)
52#define PIM_UPSTREAM_FLAG_UNSET_DR_JOIN_DESIRED_UPDATED(flags) ((flags) &= ~PIM_UPSTREAM_FLAG_MASK_DR_JOIN_DESIRED_UPDATED)
69ff3706 53#define PIM_UPSTREAM_FLAG_UNSET_FHR(flags) ((flags) &= ~PIM_UPSTREAM_FLAG_MASK_FHR)
1d3a62cd
DS
54#define PIM_UPSTREAM_FLAG_UNSET_SRC_IGMP(flags) ((flags) &= ~PIM_UPSTREAM_FLAG_MASK_SRC_IGMP)
55#define PIM_UPSTREAM_FLAG_UNSET_SRC_PIM(flags) ((flags) &= ~PIM_UPSTREAM_FLAG_MASK_SRC_PIM)
56#define PIM_UPSTREAM_FLAG_UNSET_SRC_STREAM(flags) ((flags) &= ~PIM_UPSTREAM_FLAG_MASK_SRC_STREAM)
12e41d03 57
12e41d03
DL
58enum pim_upstream_state {
59 PIM_UPSTREAM_NOTJOINED,
d7259eac
DS
60 PIM_UPSTREAM_JOINED,
61 PIM_UPSTREAM_JOIN_PENDING,
62 PIM_UPSTREAM_PRUNE,
12e41d03
DL
63};
64
d99764f6
DS
65enum pim_upstream_sptbit {
66 PIM_UPSTREAM_SPTBIT_FALSE,
67 PIM_UPSTREAM_SPTBIT_TRUE
68};
69
12e41d03
DL
70/*
71 Upstream (S,G) channel in Joined state
72
73 (S,G) in the "Not Joined" state is not represented
74
75 See RFC 4601: 4.5.7. Sending (S,G) Join/Prune Message
76*/
77struct pim_upstream {
4d99418b 78 struct pim_upstream *parent;
8f5f5e91 79 struct in_addr upstream_addr;/* Who we are talking to */
8e38a2cf 80 struct in_addr upstream_register; /*Who we received a register from*/
4ed0af70 81 struct prefix_sg sg; /* (S,G) group key */
12e41d03
DL
82 uint32_t flags;
83 struct channel_oil *channel_oil;
84
85 enum pim_upstream_state join_state;
d99764f6
DS
86 enum pim_upstream_sptbit sptbit;
87
12e41d03
DL
88 int ref_count;
89
90 struct pim_rpf rpf;
91
92 struct thread *t_join_timer;
4a4c4a07 93
2ddab288
DS
94 /*
95 * RST(S,G)
96 */
97 struct thread *t_rs_timer;
98#define PIM_REGISTER_SUPPRESSION_PERIOD (60)
99#define PIM_REGISTER_PROBE_PERIOD (5)
100
4a4c4a07
DS
101 /*
102 * KAT(S,G)
103 */
104 struct thread *t_ka_timer;
105#define PIM_KEEPALIVE_PERIOD (210)
106#define PIM_RP_KEEPALIVE_PERIOD ( 3 * qpim_register_suppress_time + qpim_register_probe_time )
107
12e41d03
DL
108 int64_t state_transition; /* Record current state uptime */
109};
110
111void pim_upstream_free(struct pim_upstream *up);
112void pim_upstream_delete(struct pim_upstream *up);
4ed0af70
DS
113struct pim_upstream *pim_upstream_find (struct prefix_sg *sg);
114struct pim_upstream *pim_upstream_find_non_any (struct prefix_sg *sg);
115struct pim_upstream *pim_upstream_add (struct prefix_sg *sg,
651d0f71 116 struct interface *ifp);
12e41d03
DL
117void pim_upstream_del(struct pim_upstream *up);
118
119int pim_upstream_evaluate_join_desired(struct pim_upstream *up);
120void pim_upstream_update_join_desired(struct pim_upstream *up);
121
122void pim_upstream_join_suppress(struct pim_upstream *up,
123 struct in_addr rpf_addr,
124 int holdtime);
125void pim_upstream_join_timer_decrease_to_t_override(const char *debug_label,
126 struct pim_upstream *up,
127 struct in_addr rpf_addr);
128void pim_upstream_join_timer_restart(struct pim_upstream *up);
129void pim_upstream_rpf_genid_changed(struct in_addr neigh_addr);
130void pim_upstream_rpf_interface_changed(struct pim_upstream *up,
131 struct interface *old_rpf_ifp);
132
133void pim_upstream_update_could_assert(struct pim_upstream *up);
134void pim_upstream_update_my_assert_metric(struct pim_upstream *up);
135
f14248dd 136void pim_upstream_keep_alive_timer_start (struct pim_upstream *up, uint32_t time);
cb40b272 137
4ed0af70 138int pim_upstream_switch_to_spt_desired (struct prefix_sg *sg);
ad410c6c 139#define SwitchToSptDesired(sg) pim_upstream_switch_to_spt_desired (sg)
cb40b272 140
627ed2a3
DS
141void pim_upstream_start_register_stop_timer (struct pim_upstream *up, int null_register);
142
56638739
DS
143void pim_upstream_send_join (struct pim_upstream *up);
144
7fcdfb34
DS
145void pim_upstream_switch (struct pim_upstream *up, enum pim_upstream_state new_state);
146
c9802954 147const char *pim_upstream_state2str (enum pim_upstream_state join_state);
4fdc8f36
DS
148
149int pim_upstream_inherited_olist (struct pim_upstream *up);
d3dd1804
DS
150
151void pim_upstream_find_new_rpf (void);
152
12e41d03 153#endif /* PIM_UPSTREAM_H */