pim_upstream.h 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  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_UPSTREAM_H
  19. #define PIM_UPSTREAM_H
  20. #include <zebra.h>
  21. #define PIM_UPSTREAM_FLAG_MASK_DR_JOIN_DESIRED (1 << 0)
  22. #define PIM_UPSTREAM_FLAG_MASK_DR_JOIN_DESIRED_UPDATED (2 << 0)
  23. #define PIM_UPSTREAM_FLAG_TEST_DR_JOIN_DESIRED(flags) ((flags) & PIM_UPSTREAM_FLAG_MASK_DR_JOIN_DESIRED)
  24. #define PIM_UPSTREAM_FLAG_TEST_DR_JOIN_DESIRED_UPDATED(flags) ((flags) & PIM_UPSTREAM_FLAG_MASK_DR_JOIN_DESIRED_UPDATED)
  25. #define PIM_UPSTREAM_FLAG_SET_DR_JOIN_DESIRED(flags) ((flags) |= PIM_UPSTREAM_FLAG_MASK_DR_JOIN_DESIRED)
  26. #define PIM_UPSTREAM_FLAG_SET_DR_JOIN_DESIRED_UPDATED(flags) ((flags) |= PIM_UPSTREAM_FLAG_MASK_DR_JOIN_DESIRED_UPDATED)
  27. #define PIM_UPSTREAM_FLAG_UNSET_DR_JOIN_DESIRED(flags) ((flags) &= ~PIM_UPSTREAM_FLAG_MASK_DR_JOIN_DESIRED)
  28. #define PIM_UPSTREAM_FLAG_UNSET_DR_JOIN_DESIRED_UPDATED(flags) ((flags) &= ~PIM_UPSTREAM_FLAG_MASK_DR_JOIN_DESIRED_UPDATED)
  29. /*
  30. RFC 4601:
  31. Metric Preference
  32. Preference value assigned to the unicast routing protocol that
  33. provided the route to the multicast source or Rendezvous-Point.
  34. Metric
  35. The unicast routing table metric associated with the route used to
  36. reach the multicast source or Rendezvous-Point. The metric is in
  37. units applicable to the unicast routing protocol used.
  38. */
  39. struct pim_nexthop {
  40. struct interface *interface; /* RPF_interface(S) */
  41. struct in_addr mrib_nexthop_addr; /* MRIB.next_hop(S) */
  42. uint32_t mrib_metric_preference; /* MRIB.pref(S) */
  43. uint32_t mrib_route_metric; /* MRIB.metric(S) */
  44. };
  45. struct pim_rpf {
  46. struct pim_nexthop source_nexthop;
  47. struct in_addr rpf_addr; /* RPF'(S,G) */
  48. };
  49. enum pim_rpf_result {
  50. PIM_RPF_OK = 0,
  51. PIM_RPF_CHANGED,
  52. PIM_RPF_FAILURE
  53. };
  54. enum pim_upstream_state {
  55. PIM_UPSTREAM_NOTJOINED,
  56. PIM_UPSTREAM_JOINED
  57. };
  58. /*
  59. Upstream (S,G) channel in Joined state
  60. (S,G) in the "Not Joined" state is not represented
  61. See RFC 4601: 4.5.7. Sending (S,G) Join/Prune Message
  62. */
  63. struct pim_upstream {
  64. struct in_addr source_addr; /* (S,G) source key */
  65. struct in_addr group_addr; /* (S,G) group key */
  66. uint32_t flags;
  67. struct channel_oil *channel_oil;
  68. enum pim_upstream_state join_state;
  69. int ref_count;
  70. struct pim_rpf rpf;
  71. struct thread *t_join_timer;
  72. int64_t state_transition; /* Record current state uptime */
  73. };
  74. void pim_upstream_free(struct pim_upstream *up);
  75. void pim_upstream_delete(struct pim_upstream *up);
  76. struct pim_upstream *pim_upstream_find(struct in_addr source_addr,
  77. struct in_addr group_addr);
  78. struct pim_upstream *pim_upstream_add(struct in_addr source_addr,
  79. struct in_addr group_addr);
  80. void pim_upstream_del(struct pim_upstream *up);
  81. int pim_upstream_evaluate_join_desired(struct pim_upstream *up);
  82. void pim_upstream_update_join_desired(struct pim_upstream *up);
  83. void pim_upstream_join_suppress(struct pim_upstream *up,
  84. struct in_addr rpf_addr,
  85. int holdtime);
  86. void pim_upstream_join_timer_decrease_to_t_override(const char *debug_label,
  87. struct pim_upstream *up,
  88. struct in_addr rpf_addr);
  89. void pim_upstream_join_timer_restart(struct pim_upstream *up);
  90. void pim_upstream_rpf_genid_changed(struct in_addr neigh_addr);
  91. void pim_upstream_rpf_interface_changed(struct pim_upstream *up,
  92. struct interface *old_rpf_ifp);
  93. void pim_upstream_update_could_assert(struct pim_upstream *up);
  94. void pim_upstream_update_my_assert_metric(struct pim_upstream *up);
  95. #endif /* PIM_UPSTREAM_H */