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