]> git.proxmox.com Git - mirror_frr.git/blame - pimd/pim_ifchannel.h
Merge pull request #1685 from LabNConsulting/working/vpn-doc
[mirror_frr.git] / pimd / pim_ifchannel.h
CommitLineData
12e41d03 1/*
896014f4
DL
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 along
16 * with this program; see the file COPYING; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18 */
12e41d03
DL
19
20#ifndef PIM_IFCHANNEL_H
21#define PIM_IFCHANNEL_H
22
23#include <zebra.h>
24
25#include "if.h"
99064df9 26#include "prefix.h"
12e41d03 27
9f44d042 28struct pim_ifchannel;
12e41d03
DL
29#include "pim_upstream.h"
30
d62a17ae 31enum pim_ifmembership { PIM_IFMEMBERSHIP_NOINFO, PIM_IFMEMBERSHIP_INCLUDE };
12e41d03
DL
32
33enum pim_ifjoin_state {
d62a17ae 34 PIM_IFJOIN_NOINFO,
35 PIM_IFJOIN_JOIN,
36 PIM_IFJOIN_PRUNE,
37 PIM_IFJOIN_PRUNE_PENDING,
38 PIM_IFJOIN_PRUNE_TMP,
39 PIM_IFJOIN_PRUNE_PENDING_TMP,
12e41d03
DL
40};
41
42enum pim_ifassert_state {
d62a17ae 43 PIM_IFASSERT_NOINFO,
44 PIM_IFASSERT_I_AM_WINNER,
45 PIM_IFASSERT_I_AM_LOSER
12e41d03
DL
46};
47
48struct pim_assert_metric {
d62a17ae 49 uint32_t rpt_bit_flag;
50 uint32_t metric_preference;
51 uint32_t route_metric;
52 struct in_addr ip_address; /* neighbor router that sourced the Assert
53 message */
12e41d03
DL
54};
55
56/*
57 Flag to detect change in CouldAssert(S,G,I)
58*/
59#define PIM_IF_FLAG_MASK_COULD_ASSERT (1 << 0)
60#define PIM_IF_FLAG_TEST_COULD_ASSERT(flags) ((flags) & PIM_IF_FLAG_MASK_COULD_ASSERT)
61#define PIM_IF_FLAG_SET_COULD_ASSERT(flags) ((flags) |= PIM_IF_FLAG_MASK_COULD_ASSERT)
62#define PIM_IF_FLAG_UNSET_COULD_ASSERT(flags) ((flags) &= ~PIM_IF_FLAG_MASK_COULD_ASSERT)
63/*
64 Flag to detect change in AssertTrackingDesired(S,G,I)
65*/
66#define PIM_IF_FLAG_MASK_ASSERT_TRACKING_DESIRED (1 << 1)
67#define PIM_IF_FLAG_TEST_ASSERT_TRACKING_DESIRED(flags) ((flags) & PIM_IF_FLAG_MASK_ASSERT_TRACKING_DESIRED)
68#define PIM_IF_FLAG_SET_ASSERT_TRACKING_DESIRED(flags) ((flags) |= PIM_IF_FLAG_MASK_ASSERT_TRACKING_DESIRED)
69#define PIM_IF_FLAG_UNSET_ASSERT_TRACKING_DESIRED(flags) ((flags) &= ~PIM_IF_FLAG_MASK_ASSERT_TRACKING_DESIRED)
70
637a61fa
DS
71/*
72 * Flat to tell us if the ifchannel is (S,G,rpt)
73 */
74#define PIM_IF_FLAG_MASK_S_G_RPT (1 << 2)
75#define PIM_IF_FLAG_TEST_S_G_RPT(flags) ((flags) & PIM_IF_FLAG_MASK_S_G_RPT)
76#define PIM_IF_FLAG_SET_S_G_RPT(flags) ((flags) |= PIM_IF_FLAG_MASK_S_G_RPT)
77#define PIM_IF_FLAG_UNSET_S_G_RPT(flags) ((flags) &= ~PIM_IF_FLAG_MASK_S_G_RPT)
78
12e41d03
DL
79/*
80 Per-interface (S,G) state
81*/
82struct pim_ifchannel {
ad7b74c4
DS
83 RB_ENTRY(rb_ifchannel) pim_ifp_rb;
84
d62a17ae 85 struct pim_ifchannel *parent;
86 struct list *sources;
87 struct prefix_sg sg;
88 char sg_str[PIM_SG_LEN];
89 struct interface *interface; /* backpointer to interface */
90 uint32_t flags;
91
92 /* IGMPv3 determined interface has local members for (S,G) ? */
93 enum pim_ifmembership local_ifmembership;
94
95 /* Per-interface (S,G) Join/Prune State (Section 4.1.4 of RFC4601) */
96 enum pim_ifjoin_state ifjoin_state;
97 struct thread *t_ifjoin_expiry_timer;
98 struct thread *t_ifjoin_prune_pending_timer;
99 int64_t ifjoin_creation; /* Record uptime of ifjoin state */
100
101 /* Per-interface (S,G) Assert State (Section 4.6.1 of RFC4601) */
102 enum pim_ifassert_state ifassert_state;
103 struct thread *t_ifassert_timer;
104 struct in_addr ifassert_winner;
105 struct pim_assert_metric ifassert_winner_metric;
106 int64_t ifassert_creation; /* Record uptime of ifassert state */
107 struct pim_assert_metric ifassert_my_metric;
108
109 /* Upstream (S,G) state */
110 struct pim_upstream *upstream;
12e41d03
DL
111};
112
ad7b74c4
DS
113RB_HEAD(pim_ifchannel_rb, pim_ifchannel);
114RB_PROTOTYPE(pim_ifchannel_rb, pim_ifchannel,
115 pim_ifp_rb, pim_ifchannel_compare);
116
12e41d03
DL
117void pim_ifchannel_free(struct pim_ifchannel *ch);
118void pim_ifchannel_delete(struct pim_ifchannel *ch);
d62a17ae 119void pim_ifchannel_delete_all(struct interface *ifp);
12e41d03
DL
120void pim_ifchannel_membership_clear(struct interface *ifp);
121void pim_ifchannel_delete_on_noinfo(struct interface *ifp);
122struct pim_ifchannel *pim_ifchannel_find(struct interface *ifp,
4ed0af70 123 struct prefix_sg *sg);
12e41d03 124struct pim_ifchannel *pim_ifchannel_add(struct interface *ifp,
0885a9f1
DS
125 struct prefix_sg *sg, uint8_t ch_flags,
126 int up_flags);
d62a17ae 127void pim_ifchannel_join_add(struct interface *ifp, struct in_addr neigh_addr,
128 struct in_addr upstream, struct prefix_sg *sg,
129 uint8_t source_flags, uint16_t holdtime);
130void pim_ifchannel_prune(struct interface *ifp, struct in_addr upstream,
131 struct prefix_sg *sg, uint8_t source_flags,
12e41d03 132 uint16_t holdtime);
f663aa7a
DS
133int pim_ifchannel_local_membership_add(struct interface *ifp,
134 struct prefix_sg *sg);
12e41d03 135void pim_ifchannel_local_membership_del(struct interface *ifp,
4ed0af70 136 struct prefix_sg *sg);
12e41d03 137
d62a17ae 138void pim_ifchannel_ifjoin_switch(const char *caller, struct pim_ifchannel *ch,
12e41d03 139 enum pim_ifjoin_state new_state);
d62a17ae 140const char *pim_ifchannel_ifjoin_name(enum pim_ifjoin_state ifjoin_state,
141 int flags);
12e41d03
DL
142const char *pim_ifchannel_ifassert_name(enum pim_ifassert_state ifassert_state);
143
144int pim_ifchannel_isin_oiflist(struct pim_ifchannel *ch);
145
146void reset_ifassert_state(struct pim_ifchannel *ch);
147
148void pim_ifchannel_update_could_assert(struct pim_ifchannel *ch);
149void pim_ifchannel_update_my_assert_metric(struct pim_ifchannel *ch);
150void pim_ifchannel_update_assert_tracking_desired(struct pim_ifchannel *ch);
151
d62a17ae 152void pim_ifchannel_scan_forward_start(struct interface *new_ifp);
153void pim_ifchannel_set_star_g_join_state(struct pim_ifchannel *ch, int eom,
c206937b 154 uint8_t join);
3fdfd943 155
ad7b74c4
DS
156int pim_ifchannel_compare(const struct pim_ifchannel *ch1,
157 const struct pim_ifchannel *ch2);
a625e937 158
d62a17ae 159unsigned int pim_ifchannel_hash_key(void *arg);
12e41d03 160#endif /* PIM_IFCHANNEL_H */