]> git.proxmox.com Git - mirror_frr.git/blame - pimd/pim_ifchannel.h
Merge pull request #12798 from donaldsharp/rib_match_multicast
[mirror_frr.git] / pimd / pim_ifchannel.h
CommitLineData
acddc0ed 1// SPDX-License-Identifier: GPL-2.0-or-later
12e41d03 2/*
896014f4
DL
3 * PIM for Quagga
4 * Copyright (C) 2008 Everton da Silva Marques
896014f4 5 */
12e41d03
DL
6
7#ifndef PIM_IFCHANNEL_H
8#define PIM_IFCHANNEL_H
9
10#include <zebra.h>
11
12#include "if.h"
99064df9 13#include "prefix.h"
12e41d03 14
e34e07e6
DL
15#include "pim_assert.h"
16
9f44d042 17struct pim_ifchannel;
12e41d03
DL
18#include "pim_upstream.h"
19
d62a17ae 20enum pim_ifmembership { PIM_IFMEMBERSHIP_NOINFO, PIM_IFMEMBERSHIP_INCLUDE };
12e41d03
DL
21
22enum pim_ifjoin_state {
d62a17ae 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,
12e41d03
DL
29};
30
12e41d03
DL
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
637a61fa 46/*
9443810e 47 * Flag to tell us if the ifchannel is (S,G,rpt)
637a61fa
DS
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
9443810e
SP
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)
12e41d03
DL
71/*
72 Per-interface (S,G) state
73*/
74struct pim_ifchannel {
ad7b74c4
DS
75 RB_ENTRY(rb_ifchannel) pim_ifp_rb;
76
d62a17ae 77 struct pim_ifchannel *parent;
78 struct list *sources;
6fff2cc6 79 pim_sgaddr sg;
d62a17ae 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;
b85201d5 96 pim_addr ifassert_winner;
d62a17ae 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;
12e41d03
DL
103};
104
ad7b74c4 105RB_HEAD(pim_ifchannel_rb, pim_ifchannel);
996c9314
LB
106RB_PROTOTYPE(pim_ifchannel_rb, pim_ifchannel, pim_ifp_rb,
107 pim_ifchannel_compare);
ad7b74c4 108
12e41d03 109void pim_ifchannel_delete(struct pim_ifchannel *ch);
d62a17ae 110void pim_ifchannel_delete_all(struct interface *ifp);
12e41d03
DL
111void pim_ifchannel_membership_clear(struct interface *ifp);
112void pim_ifchannel_delete_on_noinfo(struct interface *ifp);
6fff2cc6
DL
113struct pim_ifchannel *pim_ifchannel_find(struct interface *ifp, pim_sgaddr *sg);
114struct pim_ifchannel *pim_ifchannel_add(struct interface *ifp, pim_sgaddr *sg,
115 uint8_t ch_flags, int up_flags);
2b844385
DL
116void pim_ifchannel_join_add(struct interface *ifp, pim_addr neigh_addr,
117 pim_addr upstream, pim_sgaddr *sg,
d62a17ae 118 uint8_t source_flags, uint16_t holdtime);
2b844385 119void pim_ifchannel_prune(struct interface *ifp, pim_addr upstream,
6fff2cc6 120 pim_sgaddr *sg, uint8_t source_flags,
12e41d03 121 uint16_t holdtime);
6fff2cc6
DL
122int pim_ifchannel_local_membership_add(struct interface *ifp, pim_sgaddr *sg,
123 bool is_vxlan);
124void pim_ifchannel_local_membership_del(struct interface *ifp, pim_sgaddr *sg);
12e41d03 125
d62a17ae 126void pim_ifchannel_ifjoin_switch(const char *caller, struct pim_ifchannel *ch,
12e41d03 127 enum pim_ifjoin_state new_state);
d62a17ae 128const char *pim_ifchannel_ifjoin_name(enum pim_ifjoin_state ifjoin_state,
129 int flags);
12e41d03
DL
130const char *pim_ifchannel_ifassert_name(enum pim_ifassert_state ifassert_state);
131
132int pim_ifchannel_isin_oiflist(struct pim_ifchannel *ch);
133
134void reset_ifassert_state(struct pim_ifchannel *ch);
135
136void pim_ifchannel_update_could_assert(struct pim_ifchannel *ch);
137void pim_ifchannel_update_my_assert_metric(struct pim_ifchannel *ch);
138void pim_ifchannel_update_assert_tracking_desired(struct pim_ifchannel *ch);
139
d62a17ae 140void pim_ifchannel_scan_forward_start(struct interface *new_ifp);
141void pim_ifchannel_set_star_g_join_state(struct pim_ifchannel *ch, int eom,
c206937b 142 uint8_t join);
3fdfd943 143
ad7b74c4
DS
144int pim_ifchannel_compare(const struct pim_ifchannel *ch1,
145 const struct pim_ifchannel *ch2);
a625e937 146
99f9518b 147void delete_on_noinfo(struct pim_ifchannel *ch);
12e41d03 148#endif /* PIM_IFCHANNEL_H */