Everton Marques | 871dbcf | 2009-08-11 15:43:05 -0300 | [diff] [blame] | 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 | $QuaggaId: $Format:%an, %ai, %h$ $ |
| 21 | */ |
| 22 | |
| 23 | #ifndef PIM_IFCHANNEL_H |
| 24 | #define PIM_IFCHANNEL_H |
| 25 | |
| 26 | #include <zebra.h> |
| 27 | |
| 28 | #include "if.h" |
| 29 | |
| 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_PENDING |
| 41 | }; |
| 42 | |
| 43 | enum pim_ifassert_state { |
| 44 | PIM_IFASSERT_NOINFO, |
| 45 | PIM_IFASSERT_I_AM_WINNER, |
| 46 | PIM_IFASSERT_I_AM_LOSER |
| 47 | }; |
| 48 | |
| 49 | struct pim_assert_metric { |
| 50 | uint32_t rpt_bit_flag; |
| 51 | uint32_t metric_preference; |
| 52 | uint32_t route_metric; |
| 53 | struct in_addr ip_address; /* neighbor router that sourced the Assert message */ |
| 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 | |
| 71 | /* |
| 72 | Per-interface (S,G) state |
| 73 | */ |
| 74 | struct pim_ifchannel { |
| 75 | struct in_addr source_addr; /* (S,G) source key */ |
| 76 | struct in_addr group_addr; /* (S,G) group key */ |
| 77 | struct interface *interface; /* backpointer to interface */ |
| 78 | uint32_t flags; |
| 79 | |
| 80 | /* IGMPv3 determined interface has local members for (S,G) ? */ |
| 81 | enum pim_ifmembership local_ifmembership; |
| 82 | |
| 83 | /* Per-interface (S,G) Join/Prune State (Section 4.1.4 of RFC4601) */ |
| 84 | enum pim_ifjoin_state ifjoin_state; |
| 85 | struct thread *t_ifjoin_expiry_timer; |
| 86 | struct thread *t_ifjoin_prune_pending_timer; |
| 87 | int64_t ifjoin_creation; /* Record uptime of ifjoin state */ |
| 88 | |
| 89 | /* Per-interface (S,G) Assert State (Section 4.6.1 of RFC4601) */ |
| 90 | enum pim_ifassert_state ifassert_state; |
| 91 | struct thread *t_ifassert_timer; |
| 92 | struct in_addr ifassert_winner; |
| 93 | struct pim_assert_metric ifassert_winner_metric; |
| 94 | int64_t ifassert_creation; /* Record uptime of ifassert state */ |
| 95 | struct pim_assert_metric ifassert_my_metric; |
| 96 | |
| 97 | /* Upstream (S,G) state */ |
| 98 | struct pim_upstream *upstream; |
| 99 | }; |
| 100 | |
| 101 | void pim_ifchannel_free(struct pim_ifchannel *ch); |
| 102 | void pim_ifchannel_delete(struct pim_ifchannel *ch); |
| 103 | void pim_ifchannel_membership_clear(struct interface *ifp); |
| 104 | void pim_ifchannel_delete_on_noinfo(struct interface *ifp); |
| 105 | struct pim_ifchannel *pim_ifchannel_find(struct interface *ifp, |
| 106 | struct in_addr source_addr, |
| 107 | struct in_addr group_addr); |
| 108 | struct pim_ifchannel *pim_ifchannel_add(struct interface *ifp, |
| 109 | struct in_addr source_addr, |
| 110 | struct in_addr group_addr); |
| 111 | void pim_ifchannel_join_add(struct interface *ifp, |
| 112 | struct in_addr neigh_addr, |
| 113 | struct in_addr upstream, |
| 114 | struct in_addr source_addr, |
| 115 | struct in_addr group_addr, |
| 116 | uint8_t source_flags, |
| 117 | uint16_t holdtime); |
| 118 | void pim_ifchannel_prune(struct interface *ifp, |
| 119 | struct in_addr upstream, |
| 120 | struct in_addr source_addr, |
| 121 | struct in_addr group_addr, |
| 122 | uint8_t source_flags, |
| 123 | uint16_t holdtime); |
| 124 | void pim_ifchannel_local_membership_add(struct interface *ifp, |
| 125 | struct in_addr source_addr, |
| 126 | struct in_addr group_addr); |
| 127 | void pim_ifchannel_local_membership_del(struct interface *ifp, |
| 128 | struct in_addr source_addr, |
| 129 | struct in_addr group_addr); |
| 130 | |
| 131 | void pim_ifchannel_ifjoin_switch(const char *caller, |
| 132 | struct pim_ifchannel *ch, |
| 133 | enum pim_ifjoin_state new_state); |
| 134 | const char *pim_ifchannel_ifjoin_name(enum pim_ifjoin_state ifjoin_state); |
| 135 | const char *pim_ifchannel_ifassert_name(enum pim_ifassert_state ifassert_state); |
| 136 | |
| 137 | int pim_ifchannel_isin_oiflist(struct pim_ifchannel *ch); |
| 138 | |
| 139 | void reset_ifassert_state(struct pim_ifchannel *ch); |
| 140 | |
| 141 | void pim_ifchannel_update_could_assert(struct pim_ifchannel *ch); |
| 142 | void pim_ifchannel_update_my_assert_metric(struct pim_ifchannel *ch); |
| 143 | void pim_ifchannel_update_assert_tracking_desired(struct pim_ifchannel *ch); |
| 144 | |
| 145 | #endif /* PIM_IFCHANNEL_H */ |