pim_iface.h 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  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_IFACE_H
  19. #define PIM_IFACE_H
  20. #include <zebra.h>
  21. #include "if.h"
  22. #include "vty.h"
  23. #include "pim_igmp.h"
  24. #include "pim_upstream.h"
  25. #define PIM_IF_MASK_PIM (1 << 0)
  26. #define PIM_IF_MASK_IGMP (1 << 1)
  27. #define PIM_IF_MASK_IGMP_LISTEN_ALLROUTERS (1 << 2)
  28. #define PIM_IF_MASK_PIM_CAN_DISABLE_JOIN_SUPRESSION (1 << 3)
  29. #define PIM_IF_IS_DELETED(ifp) ((ifp)->ifindex == IFINDEX_INTERNAL)
  30. #define PIM_IF_TEST_PIM(options) (PIM_IF_MASK_PIM & (options))
  31. #define PIM_IF_TEST_IGMP(options) (PIM_IF_MASK_IGMP & (options))
  32. #define PIM_IF_TEST_IGMP_LISTEN_ALLROUTERS(options) (PIM_IF_MASK_IGMP_LISTEN_ALLROUTERS & (options))
  33. #define PIM_IF_TEST_PIM_CAN_DISABLE_JOIN_SUPRESSION(options) (PIM_IF_MASK_PIM_CAN_DISABLE_JOIN_SUPRESSION & (options))
  34. #define PIM_IF_DO_PIM(options) ((options) |= PIM_IF_MASK_PIM)
  35. #define PIM_IF_DO_IGMP(options) ((options) |= PIM_IF_MASK_IGMP)
  36. #define PIM_IF_DO_IGMP_LISTEN_ALLROUTERS(options) ((options) |= PIM_IF_MASK_IGMP_LISTEN_ALLROUTERS)
  37. #define PIM_IF_DO_PIM_CAN_DISABLE_JOIN_SUPRESSION(options) ((options) |= PIM_IF_MASK_PIM_CAN_DISABLE_JOIN_SUPRESSION)
  38. #define PIM_IF_DONT_PIM(options) ((options) &= ~PIM_IF_MASK_PIM)
  39. #define PIM_IF_DONT_IGMP(options) ((options) &= ~PIM_IF_MASK_IGMP)
  40. #define PIM_IF_DONT_IGMP_LISTEN_ALLROUTERS(options) ((options) &= ~PIM_IF_MASK_IGMP_LISTEN_ALLROUTERS)
  41. #define PIM_IF_DONT_PIM_CAN_DISABLE_JOIN_SUPRESSION(options) ((options) &= ~PIM_IF_MASK_PIM_CAN_DISABLE_JOIN_SUPRESSION)
  42. struct pim_interface {
  43. uint32_t options; /* bit vector */
  44. int mroute_vif_index;
  45. struct in_addr primary_address; /* remember addr to detect change */
  46. int igmp_default_robustness_variable; /* IGMPv3 QRV */
  47. int igmp_default_query_interval; /* IGMPv3 secs between general queries */
  48. int igmp_query_max_response_time_dsec; /* IGMPv3 Max Response Time in dsecs for general queries */
  49. int igmp_specific_query_max_response_time_dsec; /* IGMPv3 Max Response Time in dsecs for specific queries */
  50. struct list *igmp_socket_list; /* list of struct igmp_sock */
  51. struct list *igmp_join_list; /* list of struct igmp_join */
  52. int pim_sock_fd; /* PIM socket file descriptor */
  53. struct thread *t_pim_sock_read; /* thread for reading PIM socket */
  54. int64_t pim_sock_creation; /* timestamp of PIM socket creation */
  55. struct thread *t_pim_hello_timer;
  56. int pim_hello_period;
  57. int pim_default_holdtime;
  58. int pim_triggered_hello_delay;
  59. uint32_t pim_generation_id;
  60. uint16_t pim_propagation_delay_msec; /* config */
  61. uint16_t pim_override_interval_msec; /* config */
  62. struct list *pim_neighbor_list; /* list of struct pim_neighbor */
  63. struct list *pim_ifchannel_list; /* list of struct pim_ifchannel */
  64. /* neighbors without lan_delay */
  65. int pim_number_of_nonlandelay_neighbors;
  66. uint16_t pim_neighbors_highest_propagation_delay_msec;
  67. uint16_t pim_neighbors_highest_override_interval_msec;
  68. /* DR Election */
  69. int64_t pim_dr_election_last; /* timestamp */
  70. int pim_dr_election_count;
  71. int pim_dr_election_changes;
  72. struct in_addr pim_dr_addr;
  73. uint32_t pim_dr_priority; /* config */
  74. int pim_dr_num_nondrpri_neighbors; /* neighbors without dr_pri */
  75. int64_t pim_ifstat_start; /* start timestamp for stats */
  76. uint32_t pim_ifstat_hello_sent;
  77. uint32_t pim_ifstat_hello_sendfail;
  78. uint32_t pim_ifstat_hello_recv;
  79. uint32_t pim_ifstat_hello_recvfail;
  80. };
  81. /*
  82. if default_holdtime is set (>= 0), use it;
  83. otherwise default_holdtime is 3.5 * hello_period
  84. */
  85. #define PIM_IF_DEFAULT_HOLDTIME(pim_ifp) \
  86. (((pim_ifp)->pim_default_holdtime < 0) ? \
  87. ((pim_ifp)->pim_hello_period * 7 / 2) : \
  88. ((pim_ifp)->pim_default_holdtime))
  89. struct pim_interface *pim_if_new(struct interface *ifp, int igmp, int pim);
  90. void pim_if_delete(struct interface *ifp);
  91. void pim_if_addr_add(struct connected *ifc);
  92. void pim_if_addr_del(struct connected *ifc, int force_prim_as_any);
  93. void pim_if_addr_add_all(struct interface *ifp);
  94. void pim_if_addr_del_all(struct interface *ifp);
  95. void pim_if_addr_del_all_igmp(struct interface *ifp);
  96. void pim_if_addr_del_all_pim(struct interface *ifp);
  97. int pim_if_add_vif(struct interface *ifp);
  98. int pim_if_del_vif(struct interface *ifp);
  99. void pim_if_add_vif_all(void);
  100. void pim_if_del_vif_all(void);
  101. struct interface *pim_if_find_by_vif_index(ifindex_t vif_index);
  102. int pim_if_find_vifindex_by_ifindex(ifindex_t ifindex);
  103. int pim_if_lan_delay_enabled(struct interface *ifp);
  104. uint16_t pim_if_effective_propagation_delay_msec(struct interface *ifp);
  105. uint16_t pim_if_effective_override_interval_msec(struct interface *ifp);
  106. uint16_t pim_if_jp_override_interval_msec(struct interface *ifp);
  107. struct pim_neighbor *pim_if_find_neighbor(struct interface *ifp,
  108. struct in_addr addr);
  109. long pim_if_t_suppressed_msec(struct interface *ifp);
  110. int pim_if_t_override_msec(struct interface *ifp);
  111. struct in_addr pim_find_primary_addr(struct interface *ifp);
  112. int pim_if_igmp_join_add(struct interface *ifp,
  113. struct in_addr group_addr,
  114. struct in_addr source_addr);
  115. int pim_if_igmp_join_del(struct interface *ifp,
  116. struct in_addr group_addr,
  117. struct in_addr source_addr);
  118. void pim_if_update_could_assert(struct interface *ifp);
  119. void pim_if_assert_on_neighbor_down(struct interface *ifp,
  120. struct in_addr neigh_addr);
  121. void pim_if_rpf_interface_changed(struct interface *old_rpf_ifp,
  122. struct pim_upstream *up);
  123. void pim_if_update_join_desired(struct pim_interface *pim_ifp);
  124. void pim_if_update_assert_tracking_desired(struct interface *ifp);
  125. #endif /* PIM_IFACE_H */