pim_ifchannel.h 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. /*
  2. PIM for Quagga
  3. Copyright (C) 2008 Everton da Silva Marques
  4. This program is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation; either version 2 of the License, or
  7. (at your option) any later version.
  8. This program is distributed in the hope that it will be useful, but
  9. WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with this program; see the file COPYING; if not, write to the
  14. Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
  15. MA 02110-1301 USA
  16. $QuaggaId: $Format:%an, %ai, %h$ $
  17. */
  18. #ifndef PIM_IFCHANNEL_H
  19. #define PIM_IFCHANNEL_H
  20. #include <zebra.h>
  21. #include "if.h"
  22. #include "pim_upstream.h"
  23. enum pim_ifmembership {
  24. PIM_IFMEMBERSHIP_NOINFO,
  25. PIM_IFMEMBERSHIP_INCLUDE
  26. };
  27. enum pim_ifjoin_state {
  28. PIM_IFJOIN_NOINFO,
  29. PIM_IFJOIN_JOIN,
  30. PIM_IFJOIN_PRUNE_PENDING
  31. };
  32. enum pim_ifassert_state {
  33. PIM_IFASSERT_NOINFO,
  34. PIM_IFASSERT_I_AM_WINNER,
  35. PIM_IFASSERT_I_AM_LOSER
  36. };
  37. struct pim_assert_metric {
  38. uint32_t rpt_bit_flag;
  39. uint32_t metric_preference;
  40. uint32_t route_metric;
  41. struct in_addr ip_address; /* neighbor router that sourced the Assert message */
  42. };
  43. /*
  44. Flag to detect change in CouldAssert(S,G,I)
  45. */
  46. #define PIM_IF_FLAG_MASK_COULD_ASSERT (1 << 0)
  47. #define PIM_IF_FLAG_TEST_COULD_ASSERT(flags) ((flags) & PIM_IF_FLAG_MASK_COULD_ASSERT)
  48. #define PIM_IF_FLAG_SET_COULD_ASSERT(flags) ((flags) |= PIM_IF_FLAG_MASK_COULD_ASSERT)
  49. #define PIM_IF_FLAG_UNSET_COULD_ASSERT(flags) ((flags) &= ~PIM_IF_FLAG_MASK_COULD_ASSERT)
  50. /*
  51. Flag to detect change in AssertTrackingDesired(S,G,I)
  52. */
  53. #define PIM_IF_FLAG_MASK_ASSERT_TRACKING_DESIRED (1 << 1)
  54. #define PIM_IF_FLAG_TEST_ASSERT_TRACKING_DESIRED(flags) ((flags) & PIM_IF_FLAG_MASK_ASSERT_TRACKING_DESIRED)
  55. #define PIM_IF_FLAG_SET_ASSERT_TRACKING_DESIRED(flags) ((flags) |= PIM_IF_FLAG_MASK_ASSERT_TRACKING_DESIRED)
  56. #define PIM_IF_FLAG_UNSET_ASSERT_TRACKING_DESIRED(flags) ((flags) &= ~PIM_IF_FLAG_MASK_ASSERT_TRACKING_DESIRED)
  57. /*
  58. Per-interface (S,G) state
  59. */
  60. struct pim_ifchannel {
  61. struct in_addr source_addr; /* (S,G) source key */
  62. struct in_addr group_addr; /* (S,G) group key */
  63. struct interface *interface; /* backpointer to interface */
  64. uint32_t flags;
  65. /* IGMPv3 determined interface has local members for (S,G) ? */
  66. enum pim_ifmembership local_ifmembership;
  67. /* Per-interface (S,G) Join/Prune State (Section 4.1.4 of RFC4601) */
  68. enum pim_ifjoin_state ifjoin_state;
  69. struct thread *t_ifjoin_expiry_timer;
  70. struct thread *t_ifjoin_prune_pending_timer;
  71. int64_t ifjoin_creation; /* Record uptime of ifjoin state */
  72. /* Per-interface (S,G) Assert State (Section 4.6.1 of RFC4601) */
  73. enum pim_ifassert_state ifassert_state;
  74. struct thread *t_ifassert_timer;
  75. struct in_addr ifassert_winner;
  76. struct pim_assert_metric ifassert_winner_metric;
  77. int64_t ifassert_creation; /* Record uptime of ifassert state */
  78. struct pim_assert_metric ifassert_my_metric;
  79. /* Upstream (S,G) state */
  80. struct pim_upstream *upstream;
  81. };
  82. void pim_ifchannel_free(struct pim_ifchannel *ch);
  83. void pim_ifchannel_delete(struct pim_ifchannel *ch);
  84. void pim_ifchannel_membership_clear(struct interface *ifp);
  85. void pim_ifchannel_delete_on_noinfo(struct interface *ifp);
  86. struct pim_ifchannel *pim_ifchannel_find(struct interface *ifp,
  87. struct in_addr source_addr,
  88. struct in_addr group_addr);
  89. struct pim_ifchannel *pim_ifchannel_add(struct interface *ifp,
  90. struct in_addr source_addr,
  91. struct in_addr group_addr);
  92. void pim_ifchannel_join_add(struct interface *ifp,
  93. struct in_addr neigh_addr,
  94. struct in_addr upstream,
  95. struct in_addr source_addr,
  96. struct in_addr group_addr,
  97. uint8_t source_flags,
  98. uint16_t holdtime);
  99. void pim_ifchannel_prune(struct interface *ifp,
  100. struct in_addr upstream,
  101. struct in_addr source_addr,
  102. struct in_addr group_addr,
  103. uint8_t source_flags,
  104. uint16_t holdtime);
  105. void pim_ifchannel_local_membership_add(struct interface *ifp,
  106. struct in_addr source_addr,
  107. struct in_addr group_addr);
  108. void pim_ifchannel_local_membership_del(struct interface *ifp,
  109. struct in_addr source_addr,
  110. struct in_addr group_addr);
  111. void pim_ifchannel_ifjoin_switch(const char *caller,
  112. struct pim_ifchannel *ch,
  113. enum pim_ifjoin_state new_state);
  114. const char *pim_ifchannel_ifjoin_name(enum pim_ifjoin_state ifjoin_state);
  115. const char *pim_ifchannel_ifassert_name(enum pim_ifassert_state ifassert_state);
  116. int pim_ifchannel_isin_oiflist(struct pim_ifchannel *ch);
  117. void reset_ifassert_state(struct pim_ifchannel *ch);
  118. void pim_ifchannel_update_could_assert(struct pim_ifchannel *ch);
  119. void pim_ifchannel_update_my_assert_metric(struct pim_ifchannel *ch);
  120. void pim_ifchannel_update_assert_tracking_desired(struct pim_ifchannel *ch);
  121. #endif /* PIM_IFCHANNEL_H */