]> git.proxmox.com Git - mirror_frr.git/blob - pimd/pim_ifchannel.h
Merge pull request #12845 from sri-mohan1/sri-mohan-ldp
[mirror_frr.git] / pimd / pim_ifchannel.h
1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /*
3 * PIM for Quagga
4 * Copyright (C) 2008 Everton da Silva Marques
5 */
6
7 #ifndef PIM_IFCHANNEL_H
8 #define PIM_IFCHANNEL_H
9
10 #include <zebra.h>
11
12 #include "if.h"
13 #include "prefix.h"
14
15 #include "pim_assert.h"
16
17 struct pim_ifchannel;
18 #include "pim_upstream.h"
19
20 enum pim_ifmembership { PIM_IFMEMBERSHIP_NOINFO, PIM_IFMEMBERSHIP_INCLUDE };
21
22 enum pim_ifjoin_state {
23 PIM_IFJOIN_NOINFO,
24 PIM_IFJOIN_JOIN,
25 PIM_IFJOIN_PRUNE,
26 PIM_IFJOIN_PRUNE_PENDING,
27 PIM_IFJOIN_PRUNE_TMP,
28 PIM_IFJOIN_PRUNE_PENDING_TMP,
29 };
30
31 /*
32 Flag to detect change in CouldAssert(S,G,I)
33 */
34 #define PIM_IF_FLAG_MASK_COULD_ASSERT (1 << 0)
35 #define PIM_IF_FLAG_TEST_COULD_ASSERT(flags) ((flags) & PIM_IF_FLAG_MASK_COULD_ASSERT)
36 #define PIM_IF_FLAG_SET_COULD_ASSERT(flags) ((flags) |= PIM_IF_FLAG_MASK_COULD_ASSERT)
37 #define PIM_IF_FLAG_UNSET_COULD_ASSERT(flags) ((flags) &= ~PIM_IF_FLAG_MASK_COULD_ASSERT)
38 /*
39 Flag to detect change in AssertTrackingDesired(S,G,I)
40 */
41 #define PIM_IF_FLAG_MASK_ASSERT_TRACKING_DESIRED (1 << 1)
42 #define PIM_IF_FLAG_TEST_ASSERT_TRACKING_DESIRED(flags) ((flags) & PIM_IF_FLAG_MASK_ASSERT_TRACKING_DESIRED)
43 #define PIM_IF_FLAG_SET_ASSERT_TRACKING_DESIRED(flags) ((flags) |= PIM_IF_FLAG_MASK_ASSERT_TRACKING_DESIRED)
44 #define PIM_IF_FLAG_UNSET_ASSERT_TRACKING_DESIRED(flags) ((flags) &= ~PIM_IF_FLAG_MASK_ASSERT_TRACKING_DESIRED)
45
46 /*
47 * Flag to tell us if the ifchannel is (S,G,rpt)
48 */
49 #define PIM_IF_FLAG_MASK_S_G_RPT (1 << 2)
50 #define PIM_IF_FLAG_TEST_S_G_RPT(flags) ((flags) & PIM_IF_FLAG_MASK_S_G_RPT)
51 #define PIM_IF_FLAG_SET_S_G_RPT(flags) ((flags) |= PIM_IF_FLAG_MASK_S_G_RPT)
52 #define PIM_IF_FLAG_UNSET_S_G_RPT(flags) ((flags) &= ~PIM_IF_FLAG_MASK_S_G_RPT)
53
54 /*
55 * Flag to tell us if the ifchannel is proto PIM
56 */
57 #define PIM_IF_FLAG_MASK_PROTO_PIM (1 << 3)
58 #define PIM_IF_FLAG_TEST_PROTO_PIM(flags) ((flags)&PIM_IF_FLAG_MASK_PROTO_PIM)
59 #define PIM_IF_FLAG_SET_PROTO_PIM(flags) ((flags) |= PIM_IF_FLAG_MASK_PROTO_PIM)
60 #define PIM_IF_FLAG_UNSET_PROTO_PIM(flags) \
61 ((flags) &= ~PIM_IF_FLAG_MASK_PROTO_PIM)
62 /*
63 * Flag to tell us if the ifchannel is proto IGMP
64 */
65 #define PIM_IF_FLAG_MASK_PROTO_IGMP (1 << 4)
66 #define PIM_IF_FLAG_TEST_PROTO_IGMP(flags) ((flags)&PIM_IF_FLAG_MASK_PROTO_IGMP)
67 #define PIM_IF_FLAG_SET_PROTO_IGMP(flags) \
68 ((flags) |= PIM_IF_FLAG_MASK_PROTO_IGMP)
69 #define PIM_IF_FLAG_UNSET_PROTO_IGMP(flags) \
70 ((flags) &= ~PIM_IF_FLAG_MASK_PROTO_IGMP)
71 /*
72 Per-interface (S,G) state
73 */
74 struct pim_ifchannel {
75 RB_ENTRY(rb_ifchannel) pim_ifp_rb;
76
77 struct pim_ifchannel *parent;
78 struct list *sources;
79 pim_sgaddr sg;
80 char sg_str[PIM_SG_LEN];
81 struct interface *interface; /* backpointer to interface */
82 uint32_t flags;
83
84 /* IGMPv3 determined interface has local members for (S,G) ? */
85 enum pim_ifmembership local_ifmembership;
86
87 /* Per-interface (S,G) Join/Prune State (Section 4.1.4 of RFC4601) */
88 enum pim_ifjoin_state ifjoin_state;
89 struct thread *t_ifjoin_expiry_timer;
90 struct thread *t_ifjoin_prune_pending_timer;
91 int64_t ifjoin_creation; /* Record uptime of ifjoin state */
92
93 /* Per-interface (S,G) Assert State (Section 4.6.1 of RFC4601) */
94 enum pim_ifassert_state ifassert_state;
95 struct thread *t_ifassert_timer;
96 pim_addr ifassert_winner;
97 struct pim_assert_metric ifassert_winner_metric;
98 int64_t ifassert_creation; /* Record uptime of ifassert state */
99 struct pim_assert_metric ifassert_my_metric;
100
101 /* Upstream (S,G) state */
102 struct pim_upstream *upstream;
103 };
104
105 RB_HEAD(pim_ifchannel_rb, pim_ifchannel);
106 RB_PROTOTYPE(pim_ifchannel_rb, pim_ifchannel, pim_ifp_rb,
107 pim_ifchannel_compare);
108
109 void pim_ifchannel_delete(struct pim_ifchannel *ch);
110 void pim_ifchannel_delete_all(struct interface *ifp);
111 void pim_ifchannel_membership_clear(struct interface *ifp);
112 void pim_ifchannel_delete_on_noinfo(struct interface *ifp);
113 struct pim_ifchannel *pim_ifchannel_find(struct interface *ifp, pim_sgaddr *sg);
114 struct pim_ifchannel *pim_ifchannel_add(struct interface *ifp, pim_sgaddr *sg,
115 uint8_t ch_flags, int up_flags);
116 void pim_ifchannel_join_add(struct interface *ifp, pim_addr neigh_addr,
117 pim_addr upstream, pim_sgaddr *sg,
118 uint8_t source_flags, uint16_t holdtime);
119 void pim_ifchannel_prune(struct interface *ifp, pim_addr upstream,
120 pim_sgaddr *sg, uint8_t source_flags,
121 uint16_t holdtime);
122 int pim_ifchannel_local_membership_add(struct interface *ifp, pim_sgaddr *sg,
123 bool is_vxlan);
124 void pim_ifchannel_local_membership_del(struct interface *ifp, pim_sgaddr *sg);
125
126 void pim_ifchannel_ifjoin_switch(const char *caller, struct pim_ifchannel *ch,
127 enum pim_ifjoin_state new_state);
128 const char *pim_ifchannel_ifjoin_name(enum pim_ifjoin_state ifjoin_state,
129 int flags);
130 const char *pim_ifchannel_ifassert_name(enum pim_ifassert_state ifassert_state);
131
132 int pim_ifchannel_isin_oiflist(struct pim_ifchannel *ch);
133
134 void reset_ifassert_state(struct pim_ifchannel *ch);
135
136 void pim_ifchannel_update_could_assert(struct pim_ifchannel *ch);
137 void pim_ifchannel_update_my_assert_metric(struct pim_ifchannel *ch);
138 void pim_ifchannel_update_assert_tracking_desired(struct pim_ifchannel *ch);
139
140 void pim_ifchannel_scan_forward_start(struct interface *new_ifp);
141 void pim_ifchannel_set_star_g_join_state(struct pim_ifchannel *ch, int eom,
142 uint8_t join);
143
144 int pim_ifchannel_compare(const struct pim_ifchannel *ch1,
145 const struct pim_ifchannel *ch2);
146
147 void delete_on_noinfo(struct pim_ifchannel *ch);
148 #endif /* PIM_IFCHANNEL_H */