]>
Commit | Line | Data |
---|---|---|
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 | |
12e41d03 DL |
19 | */ |
20 | ||
21 | #ifndef PIM_UPSTREAM_H | |
22 | #define PIM_UPSTREAM_H | |
23 | ||
24 | #include <zebra.h> | |
25 | ||
26 | #define PIM_UPSTREAM_FLAG_MASK_DR_JOIN_DESIRED (1 << 0) | |
27 | #define PIM_UPSTREAM_FLAG_MASK_DR_JOIN_DESIRED_UPDATED (2 << 0) | |
28 | ||
29 | #define PIM_UPSTREAM_FLAG_TEST_DR_JOIN_DESIRED(flags) ((flags) & PIM_UPSTREAM_FLAG_MASK_DR_JOIN_DESIRED) | |
30 | #define PIM_UPSTREAM_FLAG_TEST_DR_JOIN_DESIRED_UPDATED(flags) ((flags) & PIM_UPSTREAM_FLAG_MASK_DR_JOIN_DESIRED_UPDATED) | |
31 | ||
32 | #define PIM_UPSTREAM_FLAG_SET_DR_JOIN_DESIRED(flags) ((flags) |= PIM_UPSTREAM_FLAG_MASK_DR_JOIN_DESIRED) | |
33 | #define PIM_UPSTREAM_FLAG_SET_DR_JOIN_DESIRED_UPDATED(flags) ((flags) |= PIM_UPSTREAM_FLAG_MASK_DR_JOIN_DESIRED_UPDATED) | |
34 | ||
35 | #define PIM_UPSTREAM_FLAG_UNSET_DR_JOIN_DESIRED(flags) ((flags) &= ~PIM_UPSTREAM_FLAG_MASK_DR_JOIN_DESIRED) | |
36 | #define PIM_UPSTREAM_FLAG_UNSET_DR_JOIN_DESIRED_UPDATED(flags) ((flags) &= ~PIM_UPSTREAM_FLAG_MASK_DR_JOIN_DESIRED_UPDATED) | |
37 | ||
38 | /* | |
39 | RFC 4601: | |
40 | ||
41 | Metric Preference | |
42 | Preference value assigned to the unicast routing protocol that | |
43 | provided the route to the multicast source or Rendezvous-Point. | |
44 | ||
45 | Metric | |
46 | The unicast routing table metric associated with the route used to | |
47 | reach the multicast source or Rendezvous-Point. The metric is in | |
48 | units applicable to the unicast routing protocol used. | |
49 | */ | |
50 | struct pim_nexthop { | |
51 | struct interface *interface; /* RPF_interface(S) */ | |
52 | struct in_addr mrib_nexthop_addr; /* MRIB.next_hop(S) */ | |
53 | uint32_t mrib_metric_preference; /* MRIB.pref(S) */ | |
54 | uint32_t mrib_route_metric; /* MRIB.metric(S) */ | |
55 | }; | |
56 | ||
57 | struct pim_rpf { | |
58 | struct pim_nexthop source_nexthop; | |
59 | struct in_addr rpf_addr; /* RPF'(S,G) */ | |
60 | }; | |
61 | ||
62 | enum pim_rpf_result { | |
63 | PIM_RPF_OK = 0, | |
64 | PIM_RPF_CHANGED, | |
65 | PIM_RPF_FAILURE | |
66 | }; | |
67 | ||
68 | enum pim_upstream_state { | |
69 | PIM_UPSTREAM_NOTJOINED, | |
70 | PIM_UPSTREAM_JOINED | |
71 | }; | |
72 | ||
d99764f6 DS |
73 | enum pim_upstream_sptbit { |
74 | PIM_UPSTREAM_SPTBIT_FALSE, | |
75 | PIM_UPSTREAM_SPTBIT_TRUE | |
76 | }; | |
77 | ||
12e41d03 DL |
78 | /* |
79 | Upstream (S,G) channel in Joined state | |
80 | ||
81 | (S,G) in the "Not Joined" state is not represented | |
82 | ||
83 | See RFC 4601: 4.5.7. Sending (S,G) Join/Prune Message | |
84 | */ | |
85 | struct pim_upstream { | |
8f5f5e91 | 86 | struct in_addr upstream_addr;/* Who we are talking to */ |
12e41d03 DL |
87 | struct in_addr source_addr; /* (S,G) source key */ |
88 | struct in_addr group_addr; /* (S,G) group key */ | |
89 | uint32_t flags; | |
90 | struct channel_oil *channel_oil; | |
91 | ||
92 | enum pim_upstream_state join_state; | |
d99764f6 DS |
93 | enum pim_upstream_sptbit sptbit; |
94 | ||
12e41d03 DL |
95 | int ref_count; |
96 | ||
97 | struct pim_rpf rpf; | |
98 | ||
99 | struct thread *t_join_timer; | |
4a4c4a07 DS |
100 | |
101 | /* | |
102 | * KAT(S,G) | |
103 | */ | |
104 | struct thread *t_ka_timer; | |
105 | #define PIM_KEEPALIVE_PERIOD (210) | |
106 | #define PIM_RP_KEEPALIVE_PERIOD ( 3 * qpim_register_suppress_time + qpim_register_probe_time ) | |
107 | ||
12e41d03 DL |
108 | int64_t state_transition; /* Record current state uptime */ |
109 | }; | |
110 | ||
111 | void pim_upstream_free(struct pim_upstream *up); | |
112 | void pim_upstream_delete(struct pim_upstream *up); | |
113 | struct pim_upstream *pim_upstream_find(struct in_addr source_addr, | |
114 | struct in_addr group_addr); | |
115 | struct pim_upstream *pim_upstream_add(struct in_addr source_addr, | |
651d0f71 DS |
116 | struct in_addr group_addr, |
117 | struct interface *ifp); | |
12e41d03 DL |
118 | void pim_upstream_del(struct pim_upstream *up); |
119 | ||
120 | int pim_upstream_evaluate_join_desired(struct pim_upstream *up); | |
121 | void pim_upstream_update_join_desired(struct pim_upstream *up); | |
122 | ||
123 | void pim_upstream_join_suppress(struct pim_upstream *up, | |
124 | struct in_addr rpf_addr, | |
125 | int holdtime); | |
126 | void pim_upstream_join_timer_decrease_to_t_override(const char *debug_label, | |
127 | struct pim_upstream *up, | |
128 | struct in_addr rpf_addr); | |
129 | void pim_upstream_join_timer_restart(struct pim_upstream *up); | |
130 | void pim_upstream_rpf_genid_changed(struct in_addr neigh_addr); | |
131 | void pim_upstream_rpf_interface_changed(struct pim_upstream *up, | |
132 | struct interface *old_rpf_ifp); | |
133 | ||
134 | void pim_upstream_update_could_assert(struct pim_upstream *up); | |
135 | void pim_upstream_update_my_assert_metric(struct pim_upstream *up); | |
136 | ||
f14248dd | 137 | void pim_upstream_keep_alive_timer_start (struct pim_upstream *up, uint32_t time); |
cb40b272 DS |
138 | |
139 | int pim_upstream_switch_to_spt_desired (struct in_addr source, struct in_addr group); | |
140 | #define SwitchToSptDesired(S,G) pim_upstream_switch_to_spt_desired ((S), (G)) | |
141 | ||
12e41d03 | 142 | #endif /* PIM_UPSTREAM_H */ |