]> git.proxmox.com Git - mirror_frr.git/blame - pimd/pim_upstream.h
pimd: Add the ability to test if the RPF' is the same
[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 30#define PIM_UPSTREAM_FLAG_MASK_DR_JOIN_DESIRED (1 << 0)
ca973133
DS
31#define PIM_UPSTREAM_FLAG_MASK_DR_JOIN_DESIRED_UPDATED (1 << 1)
32#define PIM_UPSTREAM_FLAG_MASK_FHR (1 << 2)
33#define PIM_UPSTREAM_FLAG_MASK_SRC_IGMP (1 << 3)
34#define PIM_UPSTREAM_FLAG_MASK_SRC_PIM (1 << 4)
35#define PIM_UPSTREAM_FLAG_MASK_SRC_STREAM (1 << 5)
5ce79466 36#define PIM_UPSTREAM_FLAG_MASK_CREATED_BY_UPSTREAM (1 << 6)
12e41d03
DL
37
38#define PIM_UPSTREAM_FLAG_TEST_DR_JOIN_DESIRED(flags) ((flags) & PIM_UPSTREAM_FLAG_MASK_DR_JOIN_DESIRED)
39#define PIM_UPSTREAM_FLAG_TEST_DR_JOIN_DESIRED_UPDATED(flags) ((flags) & PIM_UPSTREAM_FLAG_MASK_DR_JOIN_DESIRED_UPDATED)
69ff3706 40#define PIM_UPSTREAM_FLAG_TEST_FHR(flags) ((flags) & PIM_UPSTREAM_FLAG_MASK_FHR)
1d3a62cd
DS
41#define PIM_UPSTREAM_FLAG_TEST_SRC_IGMP(flags) ((flags) & PIM_UPSTREAM_FLAG_MASK_SRC_IGMP)
42#define PIM_UPSTREAM_FLAG_TEST_SRC_PIM(flags) ((flags) & PIM_UPSTREAM_FLAG_MASK_SRC_PIM)
43#define PIM_UPSTREAM_FLAG_TEST_SRC_STREAM(flags) ((flags) & PIM_UPSTREAM_FLAG_MASK_SRC_STREAM)
5ce79466 44#define PIM_UPSTREAM_FLAG_TEST_CREATED_BY_UPSTREAM(flags) ((flags) & PIM_UPSTREAM_FLAG_MASK_CREATED_BY_UPSTREAM)
12e41d03
DL
45
46#define PIM_UPSTREAM_FLAG_SET_DR_JOIN_DESIRED(flags) ((flags) |= PIM_UPSTREAM_FLAG_MASK_DR_JOIN_DESIRED)
47#define PIM_UPSTREAM_FLAG_SET_DR_JOIN_DESIRED_UPDATED(flags) ((flags) |= PIM_UPSTREAM_FLAG_MASK_DR_JOIN_DESIRED_UPDATED)
69ff3706 48#define PIM_UPSTREAM_FLAG_SET_FHR(flags) ((flags) |= PIM_UPSTREAM_FLAG_MASK_FHR)
1d3a62cd
DS
49#define PIM_UPSTREAM_FLAG_SET_SRC_IGMP(flags) ((flags) |= PIM_UPSTREAM_FLAG_MASK_SRC_IGMP)
50#define PIM_UPSTREAM_FLAG_SET_SRC_PIM(flags) ((flags) |= PIM_UPSTREAM_FLAG_MASK_SRC_PIM)
51#define PIM_UPSTREAM_FLAG_SET_SRC_STREAM(flags) ((flags) |= PIM_UPSTREAM_FLAG_MASK_SRC_STREAM)
5ce79466 52#define PIM_UPSTREAM_FLAG_SET_CREATED_BY_UPSTREAM(flags) ((flags) |= PIM_UPSTREAM_FLAG_MASK_CREATED_BY_UPSTREAM)
12e41d03
DL
53
54#define PIM_UPSTREAM_FLAG_UNSET_DR_JOIN_DESIRED(flags) ((flags) &= ~PIM_UPSTREAM_FLAG_MASK_DR_JOIN_DESIRED)
55#define PIM_UPSTREAM_FLAG_UNSET_DR_JOIN_DESIRED_UPDATED(flags) ((flags) &= ~PIM_UPSTREAM_FLAG_MASK_DR_JOIN_DESIRED_UPDATED)
69ff3706 56#define PIM_UPSTREAM_FLAG_UNSET_FHR(flags) ((flags) &= ~PIM_UPSTREAM_FLAG_MASK_FHR)
1d3a62cd
DS
57#define PIM_UPSTREAM_FLAG_UNSET_SRC_IGMP(flags) ((flags) &= ~PIM_UPSTREAM_FLAG_MASK_SRC_IGMP)
58#define PIM_UPSTREAM_FLAG_UNSET_SRC_PIM(flags) ((flags) &= ~PIM_UPSTREAM_FLAG_MASK_SRC_PIM)
59#define PIM_UPSTREAM_FLAG_UNSET_SRC_STREAM(flags) ((flags) &= ~PIM_UPSTREAM_FLAG_MASK_SRC_STREAM)
5ce79466 60#define PIM_UPSTREAM_FLAG_UNSET_CREATED_BY_UPSTREAM(flags) ((flags) &= ~PIM_UPSTREAM_FLAG_MASK_CREATED_BY_UPSTREAM)
12e41d03 61
12e41d03
DL
62enum pim_upstream_state {
63 PIM_UPSTREAM_NOTJOINED,
d7259eac
DS
64 PIM_UPSTREAM_JOINED,
65 PIM_UPSTREAM_JOIN_PENDING,
66 PIM_UPSTREAM_PRUNE,
12e41d03
DL
67};
68
d99764f6
DS
69enum pim_upstream_sptbit {
70 PIM_UPSTREAM_SPTBIT_FALSE,
71 PIM_UPSTREAM_SPTBIT_TRUE
72};
73
12e41d03
DL
74/*
75 Upstream (S,G) channel in Joined state
76
77 (S,G) in the "Not Joined" state is not represented
78
79 See RFC 4601: 4.5.7. Sending (S,G) Join/Prune Message
80*/
81struct pim_upstream {
4d99418b 82 struct pim_upstream *parent;
8f5f5e91 83 struct in_addr upstream_addr;/* Who we are talking to */
8e38a2cf 84 struct in_addr upstream_register; /*Who we received a register from*/
4ed0af70 85 struct prefix_sg sg; /* (S,G) group key */
12e41d03
DL
86 uint32_t flags;
87 struct channel_oil *channel_oil;
03417ccd 88 struct list *sources;
12e41d03
DL
89
90 enum pim_upstream_state join_state;
d99764f6
DS
91 enum pim_upstream_sptbit sptbit;
92
12e41d03
DL
93 int ref_count;
94
95 struct pim_rpf rpf;
96
97 struct thread *t_join_timer;
4a4c4a07 98
2ddab288
DS
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 (5)
105
4a4c4a07
DS
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
12e41d03
DL
113 int64_t state_transition; /* Record current state uptime */
114};
115
0f588989
DS
116struct list *pim_upstream_list;
117struct hash *pim_upstream_hash;
118
12e41d03 119void pim_upstream_free(struct pim_upstream *up);
4ed0af70 120struct pim_upstream *pim_upstream_find (struct prefix_sg *sg);
4ed0af70 121struct pim_upstream *pim_upstream_add (struct prefix_sg *sg,
e5905a3b
DS
122 struct interface *ifp, int flags,
123 const char *name);
124void pim_upstream_del(struct pim_upstream *up, const char *name);
12e41d03
DL
125
126int pim_upstream_evaluate_join_desired(struct pim_upstream *up);
127void pim_upstream_update_join_desired(struct pim_upstream *up);
128
129void pim_upstream_join_suppress(struct pim_upstream *up,
130 struct in_addr rpf_addr,
131 int holdtime);
132void pim_upstream_join_timer_decrease_to_t_override(const char *debug_label,
133 struct pim_upstream *up,
134 struct in_addr rpf_addr);
135void pim_upstream_join_timer_restart(struct pim_upstream *up);
136void pim_upstream_rpf_genid_changed(struct in_addr neigh_addr);
137void pim_upstream_rpf_interface_changed(struct pim_upstream *up,
138 struct interface *old_rpf_ifp);
139
140void pim_upstream_update_could_assert(struct pim_upstream *up);
141void pim_upstream_update_my_assert_metric(struct pim_upstream *up);
142
f14248dd 143void pim_upstream_keep_alive_timer_start (struct pim_upstream *up, uint32_t time);
cb40b272 144
4ed0af70 145int pim_upstream_switch_to_spt_desired (struct prefix_sg *sg);
ad410c6c 146#define SwitchToSptDesired(sg) pim_upstream_switch_to_spt_desired (sg)
cb40b272 147
627ed2a3
DS
148void pim_upstream_start_register_stop_timer (struct pim_upstream *up, int null_register);
149
56638739
DS
150void pim_upstream_send_join (struct pim_upstream *up);
151
7fcdfb34
DS
152void pim_upstream_switch (struct pim_upstream *up, enum pim_upstream_state new_state);
153
c9802954 154const char *pim_upstream_state2str (enum pim_upstream_state join_state);
4fdc8f36
DS
155
156int pim_upstream_inherited_olist (struct pim_upstream *up);
d3dd1804
DS
157
158void pim_upstream_find_new_rpf (void);
159
0f588989
DS
160void pim_upstream_init (void);
161void pim_upstream_terminate (void);
12e41d03 162#endif /* PIM_UPSTREAM_H */