]> git.proxmox.com Git - mirror_frr.git/blob - pimd/pim_ifchannel.h
Merge pull request #82 from opensourcerouting/queue/ldp-xml2cli-build
[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
28 #include "pim_upstream.h"
29
30 enum pim_ifmembership {
31 PIM_IFMEMBERSHIP_NOINFO,
32 PIM_IFMEMBERSHIP_INCLUDE
33 };
34
35 enum pim_ifjoin_state {
36 PIM_IFJOIN_NOINFO,
37 PIM_IFJOIN_JOIN,
38 PIM_IFJOIN_PRUNE_PENDING
39 };
40
41 enum pim_ifassert_state {
42 PIM_IFASSERT_NOINFO,
43 PIM_IFASSERT_I_AM_WINNER,
44 PIM_IFASSERT_I_AM_LOSER
45 };
46
47 struct pim_assert_metric {
48 uint32_t rpt_bit_flag;
49 uint32_t metric_preference;
50 uint32_t route_metric;
51 struct in_addr ip_address; /* neighbor router that sourced the Assert message */
52 };
53
54 /*
55 Flag to detect change in CouldAssert(S,G,I)
56 */
57 #define PIM_IF_FLAG_MASK_COULD_ASSERT (1 << 0)
58 #define PIM_IF_FLAG_TEST_COULD_ASSERT(flags) ((flags) & PIM_IF_FLAG_MASK_COULD_ASSERT)
59 #define PIM_IF_FLAG_SET_COULD_ASSERT(flags) ((flags) |= PIM_IF_FLAG_MASK_COULD_ASSERT)
60 #define PIM_IF_FLAG_UNSET_COULD_ASSERT(flags) ((flags) &= ~PIM_IF_FLAG_MASK_COULD_ASSERT)
61 /*
62 Flag to detect change in AssertTrackingDesired(S,G,I)
63 */
64 #define PIM_IF_FLAG_MASK_ASSERT_TRACKING_DESIRED (1 << 1)
65 #define PIM_IF_FLAG_TEST_ASSERT_TRACKING_DESIRED(flags) ((flags) & PIM_IF_FLAG_MASK_ASSERT_TRACKING_DESIRED)
66 #define PIM_IF_FLAG_SET_ASSERT_TRACKING_DESIRED(flags) ((flags) |= PIM_IF_FLAG_MASK_ASSERT_TRACKING_DESIRED)
67 #define PIM_IF_FLAG_UNSET_ASSERT_TRACKING_DESIRED(flags) ((flags) &= ~PIM_IF_FLAG_MASK_ASSERT_TRACKING_DESIRED)
68
69 /*
70 Per-interface (S,G) state
71 */
72 struct pim_ifchannel {
73 struct in_addr source_addr; /* (S,G) source key */
74 struct in_addr group_addr; /* (S,G) group key */
75 struct interface *interface; /* backpointer to interface */
76 uint32_t flags;
77
78 /* IGMPv3 determined interface has local members for (S,G) ? */
79 enum pim_ifmembership local_ifmembership;
80
81 /* Per-interface (S,G) Join/Prune State (Section 4.1.4 of RFC4601) */
82 enum pim_ifjoin_state ifjoin_state;
83 struct thread *t_ifjoin_expiry_timer;
84 struct thread *t_ifjoin_prune_pending_timer;
85 int64_t ifjoin_creation; /* Record uptime of ifjoin state */
86
87 /* Per-interface (S,G) Assert State (Section 4.6.1 of RFC4601) */
88 enum pim_ifassert_state ifassert_state;
89 struct thread *t_ifassert_timer;
90 struct in_addr ifassert_winner;
91 struct pim_assert_metric ifassert_winner_metric;
92 int64_t ifassert_creation; /* Record uptime of ifassert state */
93 struct pim_assert_metric ifassert_my_metric;
94
95 /* Upstream (S,G) state */
96 struct pim_upstream *upstream;
97 };
98
99 void pim_ifchannel_free(struct pim_ifchannel *ch);
100 void pim_ifchannel_delete(struct pim_ifchannel *ch);
101 void pim_ifchannel_membership_clear(struct interface *ifp);
102 void pim_ifchannel_delete_on_noinfo(struct interface *ifp);
103 struct pim_ifchannel *pim_ifchannel_find(struct interface *ifp,
104 struct in_addr source_addr,
105 struct in_addr group_addr);
106 struct pim_ifchannel *pim_ifchannel_add(struct interface *ifp,
107 struct in_addr source_addr,
108 struct in_addr group_addr);
109 void pim_ifchannel_join_add(struct interface *ifp,
110 struct in_addr neigh_addr,
111 struct in_addr upstream,
112 struct in_addr source_addr,
113 struct in_addr group_addr,
114 uint8_t source_flags,
115 uint16_t holdtime);
116 void pim_ifchannel_prune(struct interface *ifp,
117 struct in_addr upstream,
118 struct in_addr source_addr,
119 struct in_addr group_addr,
120 uint8_t source_flags,
121 uint16_t holdtime);
122 void pim_ifchannel_local_membership_add(struct interface *ifp,
123 struct in_addr source_addr,
124 struct in_addr group_addr);
125 void pim_ifchannel_local_membership_del(struct interface *ifp,
126 struct in_addr source_addr,
127 struct in_addr group_addr);
128
129 void pim_ifchannel_ifjoin_switch(const char *caller,
130 struct pim_ifchannel *ch,
131 enum pim_ifjoin_state new_state);
132 const char *pim_ifchannel_ifjoin_name(enum pim_ifjoin_state ifjoin_state);
133 const char *pim_ifchannel_ifassert_name(enum pim_ifassert_state ifassert_state);
134
135 int pim_ifchannel_isin_oiflist(struct pim_ifchannel *ch);
136
137 void reset_ifassert_state(struct pim_ifchannel *ch);
138
139 void pim_ifchannel_update_could_assert(struct pim_ifchannel *ch);
140 void pim_ifchannel_update_my_assert_metric(struct pim_ifchannel *ch);
141 void pim_ifchannel_update_assert_tracking_desired(struct pim_ifchannel *ch);
142
143 #endif /* PIM_IFCHANNEL_H */