pimd.h 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  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 PIMD_H
  19. #define PIMD_H
  20. #include <stdint.h>
  21. #include "pim_mroute.h"
  22. #include "pim_assert.h"
  23. #define PIMD_PROGNAME "pimd"
  24. #define PIMD_DEFAULT_CONFIG "pimd.conf"
  25. #define PIMD_VTY_PORT 2611
  26. #define PIMD_BUG_ADDRESS "http://savannah.nongnu.org/projects/qpimd"
  27. #define PIM_IP_HEADER_MIN_LEN (20)
  28. #define PIM_IP_HEADER_MAX_LEN (60)
  29. #define PIM_IP_PROTO_IGMP (2)
  30. #define PIM_IP_PROTO_PIM (103)
  31. #define PIM_IGMP_MIN_LEN (8)
  32. #define PIM_MSG_HEADER_LEN (4)
  33. #define PIM_PIM_MIN_LEN PIM_MSG_HEADER_LEN
  34. #define PIM_PROTO_VERSION (2)
  35. #define MCAST_ALL_SYSTEMS "224.0.0.1"
  36. #define MCAST_ALL_ROUTERS "224.0.0.2"
  37. #define MCAST_ALL_PIM_ROUTERS "224.0.0.13"
  38. #define MCAST_ALL_IGMP_ROUTERS "224.0.0.22"
  39. #define PIM_FORCE_BOOLEAN(expr) ((expr) != 0)
  40. #define PIM_NET_INADDR_ANY (htonl(INADDR_ANY))
  41. #define PIM_INADDR_IS_ANY(addr) ((addr).s_addr == PIM_NET_INADDR_ANY) /* struct in_addr addr */
  42. #define PIM_INADDR_ISNOT_ANY(addr) ((addr).s_addr != PIM_NET_INADDR_ANY) /* struct in_addr addr */
  43. #define PIM_MASK_PIM_EVENTS (1 << 0)
  44. #define PIM_MASK_PIM_PACKETS (1 << 1)
  45. #define PIM_MASK_PIM_TRACE (1 << 2)
  46. #define PIM_MASK_IGMP_EVENTS (1 << 3)
  47. #define PIM_MASK_IGMP_PACKETS (1 << 4)
  48. #define PIM_MASK_IGMP_TRACE (1 << 5)
  49. #define PIM_MASK_ZEBRA (1 << 6)
  50. #define PIM_MASK_SSMPINGD (1 << 7)
  51. const char *const PIM_ALL_SYSTEMS;
  52. const char *const PIM_ALL_ROUTERS;
  53. const char *const PIM_ALL_PIM_ROUTERS;
  54. const char *const PIM_ALL_IGMP_ROUTERS;
  55. struct thread_master *master;
  56. uint32_t qpim_debugs;
  57. int qpim_mroute_socket_fd;
  58. int64_t qpim_mroute_socket_creation; /* timestamp of creation */
  59. struct thread *qpim_mroute_socket_reader;
  60. int qpim_mroute_oif_highest_vif_index;
  61. struct list *qpim_channel_oil_list; /* list of struct channel_oil */
  62. struct in_addr qpim_all_pim_routers_addr;
  63. int qpim_t_periodic; /* Period between Join/Prune Messages */
  64. struct list *qpim_upstream_list; /* list of struct pim_upstream */
  65. struct zclient *qpim_zclient_lookup;
  66. struct pim_assert_metric qpim_infinite_assert_metric;
  67. long qpim_rpf_cache_refresh_delay_msec;
  68. struct thread *qpim_rpf_cache_refresher;
  69. int64_t qpim_rpf_cache_refresh_requests;
  70. int64_t qpim_rpf_cache_refresh_events;
  71. int64_t qpim_rpf_cache_refresh_last;
  72. struct in_addr qpim_inaddr_any;
  73. struct list *qpim_ssmpingd_list; /* list of struct ssmpingd_sock */
  74. #define PIM_JP_HOLDTIME (qpim_t_periodic * 7 / 2)
  75. #define PIM_MROUTE_IS_ENABLED (qpim_mroute_socket_fd >= 0)
  76. #define PIM_MROUTE_IS_DISABLED (qpim_mroute_socket_fd < 0)
  77. #define PIM_DEBUG_PIM_EVENTS (qpim_debugs & PIM_MASK_PIM_EVENTS)
  78. #define PIM_DEBUG_PIM_PACKETS (qpim_debugs & PIM_MASK_PIM_PACKETS)
  79. #define PIM_DEBUG_PIM_TRACE (qpim_debugs & PIM_MASK_PIM_TRACE)
  80. #define PIM_DEBUG_IGMP_EVENTS (qpim_debugs & PIM_MASK_IGMP_EVENTS)
  81. #define PIM_DEBUG_IGMP_PACKETS (qpim_debugs & PIM_MASK_IGMP_PACKETS)
  82. #define PIM_DEBUG_IGMP_TRACE (qpim_debugs & PIM_MASK_IGMP_TRACE)
  83. #define PIM_DEBUG_ZEBRA (qpim_debugs & PIM_MASK_ZEBRA)
  84. #define PIM_DEBUG_SSMPINGD (qpim_debugs & PIM_MASK_SSMPINGD)
  85. #define PIM_DEBUG_EVENTS (qpim_debugs & (PIM_MASK_PIM_EVENTS | PIM_MASK_IGMP_EVENTS))
  86. #define PIM_DEBUG_PACKETS (qpim_debugs & (PIM_MASK_PIM_PACKETS | PIM_MASK_IGMP_PACKETS))
  87. #define PIM_DEBUG_TRACE (qpim_debugs & (PIM_MASK_PIM_TRACE | PIM_MASK_IGMP_TRACE))
  88. #define PIM_DO_DEBUG_PIM_EVENTS (qpim_debugs |= PIM_MASK_PIM_EVENTS)
  89. #define PIM_DO_DEBUG_PIM_PACKETS (qpim_debugs |= PIM_MASK_PIM_PACKETS)
  90. #define PIM_DO_DEBUG_PIM_TRACE (qpim_debugs |= PIM_MASK_PIM_TRACE)
  91. #define PIM_DO_DEBUG_IGMP_EVENTS (qpim_debugs |= PIM_MASK_IGMP_EVENTS)
  92. #define PIM_DO_DEBUG_IGMP_PACKETS (qpim_debugs |= PIM_MASK_IGMP_PACKETS)
  93. #define PIM_DO_DEBUG_IGMP_TRACE (qpim_debugs |= PIM_MASK_IGMP_TRACE)
  94. #define PIM_DO_DEBUG_ZEBRA (qpim_debugs |= PIM_MASK_ZEBRA)
  95. #define PIM_DO_DEBUG_SSMPINGD (qpim_debugs |= PIM_MASK_SSMPINGD)
  96. #define PIM_DONT_DEBUG_PIM_EVENTS (qpim_debugs &= ~PIM_MASK_PIM_EVENTS)
  97. #define PIM_DONT_DEBUG_PIM_PACKETS (qpim_debugs &= ~PIM_MASK_PIM_PACKETS)
  98. #define PIM_DONT_DEBUG_PIM_TRACE (qpim_debugs &= ~PIM_MASK_PIM_TRACE)
  99. #define PIM_DONT_DEBUG_IGMP_EVENTS (qpim_debugs &= ~PIM_MASK_IGMP_EVENTS)
  100. #define PIM_DONT_DEBUG_IGMP_PACKETS (qpim_debugs &= ~PIM_MASK_IGMP_PACKETS)
  101. #define PIM_DONT_DEBUG_IGMP_TRACE (qpim_debugs &= ~PIM_MASK_IGMP_TRACE)
  102. #define PIM_DONT_DEBUG_ZEBRA (qpim_debugs &= ~PIM_MASK_ZEBRA)
  103. #define PIM_DONT_DEBUG_SSMPINGD (qpim_debugs &= ~PIM_MASK_SSMPINGD)
  104. void pim_init(void);
  105. void pim_terminate(void);
  106. #endif /* PIMD_H */