]> git.proxmox.com Git - mirror_frr.git/blame - pimd/pim_upstream.h
pimd: Fix debugs to be more logical
[mirror_frr.git] / pimd / pim_upstream.h
CommitLineData
12e41d03
DL
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
12e41d03
DL
20*/
21
22#ifndef PIM_UPSTREAM_H
23#define PIM_UPSTREAM_H
24
25#include <zebra.h>
05e451f8 26#include <prefix.h>
12e41d03
DL
27
28#define PIM_UPSTREAM_FLAG_MASK_DR_JOIN_DESIRED (1 << 0)
29#define PIM_UPSTREAM_FLAG_MASK_DR_JOIN_DESIRED_UPDATED (2 << 0)
30
31#define PIM_UPSTREAM_FLAG_TEST_DR_JOIN_DESIRED(flags) ((flags) & PIM_UPSTREAM_FLAG_MASK_DR_JOIN_DESIRED)
32#define PIM_UPSTREAM_FLAG_TEST_DR_JOIN_DESIRED_UPDATED(flags) ((flags) & PIM_UPSTREAM_FLAG_MASK_DR_JOIN_DESIRED_UPDATED)
33
34#define PIM_UPSTREAM_FLAG_SET_DR_JOIN_DESIRED(flags) ((flags) |= PIM_UPSTREAM_FLAG_MASK_DR_JOIN_DESIRED)
35#define PIM_UPSTREAM_FLAG_SET_DR_JOIN_DESIRED_UPDATED(flags) ((flags) |= PIM_UPSTREAM_FLAG_MASK_DR_JOIN_DESIRED_UPDATED)
36
37#define PIM_UPSTREAM_FLAG_UNSET_DR_JOIN_DESIRED(flags) ((flags) &= ~PIM_UPSTREAM_FLAG_MASK_DR_JOIN_DESIRED)
38#define PIM_UPSTREAM_FLAG_UNSET_DR_JOIN_DESIRED_UPDATED(flags) ((flags) &= ~PIM_UPSTREAM_FLAG_MASK_DR_JOIN_DESIRED_UPDATED)
39
40/*
41 RFC 4601:
42
43 Metric Preference
44 Preference value assigned to the unicast routing protocol that
45 provided the route to the multicast source or Rendezvous-Point.
46
47 Metric
48 The unicast routing table metric associated with the route used to
49 reach the multicast source or Rendezvous-Point. The metric is in
50 units applicable to the unicast routing protocol used.
51*/
52struct pim_nexthop {
53 struct interface *interface; /* RPF_interface(S) */
54 struct in_addr mrib_nexthop_addr; /* MRIB.next_hop(S) */
55 uint32_t mrib_metric_preference; /* MRIB.pref(S) */
56 uint32_t mrib_route_metric; /* MRIB.metric(S) */
57};
58
59struct pim_rpf {
60 struct pim_nexthop source_nexthop;
61 struct in_addr rpf_addr; /* RPF'(S,G) */
62};
63
64enum pim_rpf_result {
65 PIM_RPF_OK = 0,
66 PIM_RPF_CHANGED,
67 PIM_RPF_FAILURE
68};
69
70enum pim_upstream_state {
71 PIM_UPSTREAM_NOTJOINED,
d7259eac
DS
72 PIM_UPSTREAM_JOINED,
73 PIM_UPSTREAM_JOIN_PENDING,
74 PIM_UPSTREAM_PRUNE,
12e41d03
DL
75};
76
d99764f6
DS
77enum pim_upstream_sptbit {
78 PIM_UPSTREAM_SPTBIT_FALSE,
79 PIM_UPSTREAM_SPTBIT_TRUE
80};
81
12e41d03
DL
82/*
83 Upstream (S,G) channel in Joined state
84
85 (S,G) in the "Not Joined" state is not represented
86
87 See RFC 4601: 4.5.7. Sending (S,G) Join/Prune Message
88*/
89struct pim_upstream {
4d99418b 90 struct pim_upstream *parent;
56638739 91 int fhr;
8f5f5e91 92 struct in_addr upstream_addr;/* Who we are talking to */
8e38a2cf 93 struct in_addr upstream_register; /*Who we received a register from*/
4ed0af70 94 struct prefix_sg sg; /* (S,G) group key */
12e41d03
DL
95 uint32_t flags;
96 struct channel_oil *channel_oil;
97
98 enum pim_upstream_state join_state;
d99764f6
DS
99 enum pim_upstream_sptbit sptbit;
100
12e41d03
DL
101 int ref_count;
102
103 struct pim_rpf rpf;
104
105 struct thread *t_join_timer;
4a4c4a07 106
2ddab288
DS
107 /*
108 * RST(S,G)
109 */
110 struct thread *t_rs_timer;
111#define PIM_REGISTER_SUPPRESSION_PERIOD (60)
112#define PIM_REGISTER_PROBE_PERIOD (5)
113
4a4c4a07
DS
114 /*
115 * KAT(S,G)
116 */
117 struct thread *t_ka_timer;
118#define PIM_KEEPALIVE_PERIOD (210)
119#define PIM_RP_KEEPALIVE_PERIOD ( 3 * qpim_register_suppress_time + qpim_register_probe_time )
120
12e41d03
DL
121 int64_t state_transition; /* Record current state uptime */
122};
123
124void pim_upstream_free(struct pim_upstream *up);
125void pim_upstream_delete(struct pim_upstream *up);
4ed0af70
DS
126struct pim_upstream *pim_upstream_find (struct prefix_sg *sg);
127struct pim_upstream *pim_upstream_find_non_any (struct prefix_sg *sg);
128struct pim_upstream *pim_upstream_add (struct prefix_sg *sg,
651d0f71 129 struct interface *ifp);
12e41d03
DL
130void pim_upstream_del(struct pim_upstream *up);
131
132int pim_upstream_evaluate_join_desired(struct pim_upstream *up);
133void pim_upstream_update_join_desired(struct pim_upstream *up);
134
135void pim_upstream_join_suppress(struct pim_upstream *up,
136 struct in_addr rpf_addr,
137 int holdtime);
138void pim_upstream_join_timer_decrease_to_t_override(const char *debug_label,
139 struct pim_upstream *up,
140 struct in_addr rpf_addr);
141void pim_upstream_join_timer_restart(struct pim_upstream *up);
142void pim_upstream_rpf_genid_changed(struct in_addr neigh_addr);
143void pim_upstream_rpf_interface_changed(struct pim_upstream *up,
144 struct interface *old_rpf_ifp);
145
146void pim_upstream_update_could_assert(struct pim_upstream *up);
147void pim_upstream_update_my_assert_metric(struct pim_upstream *up);
148
f14248dd 149void pim_upstream_keep_alive_timer_start (struct pim_upstream *up, uint32_t time);
cb40b272 150
4ed0af70 151int pim_upstream_switch_to_spt_desired (struct prefix_sg *sg);
ad410c6c 152#define SwitchToSptDesired(sg) pim_upstream_switch_to_spt_desired (sg)
cb40b272 153
627ed2a3
DS
154void pim_upstream_start_register_stop_timer (struct pim_upstream *up, int null_register);
155
56638739
DS
156void pim_upstream_send_join (struct pim_upstream *up);
157
7fcdfb34
DS
158void pim_upstream_switch (struct pim_upstream *up, enum pim_upstream_state new_state);
159
c9802954 160const char *pim_upstream_state2str (enum pim_upstream_state join_state);
4fdc8f36
DS
161
162int pim_upstream_inherited_olist (struct pim_upstream *up);
12e41d03 163#endif /* PIM_UPSTREAM_H */