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 PIMD_H |
| 24 | #define PIMD_H |
| 25 | |
| 26 | #include <stdint.h> |
| 27 | |
| 28 | #include "pim_mroute.h" |
| 29 | #include "pim_assert.h" |
| 30 | |
| 31 | #define PIMD_PROGNAME "pimd" |
| 32 | #define PIMD_DEFAULT_CONFIG "pimd.conf" |
| 33 | #define PIMD_VTY_PORT 2611 |
Everton Marques | 1f7a2b4 | 2014-04-01 18:38:50 -0300 | [diff] [blame] | 34 | #define PIMD_BUG_ADDRESS "https://github.com/udhos/qpimd" |
Everton Marques | 871dbcf | 2009-08-11 15:43:05 -0300 | [diff] [blame] | 35 | |
| 36 | #define PIM_IP_HEADER_MIN_LEN (20) |
| 37 | #define PIM_IP_HEADER_MAX_LEN (60) |
| 38 | #define PIM_IP_PROTO_IGMP (2) |
| 39 | #define PIM_IP_PROTO_PIM (103) |
| 40 | #define PIM_IGMP_MIN_LEN (8) |
| 41 | #define PIM_MSG_HEADER_LEN (4) |
| 42 | #define PIM_PIM_MIN_LEN PIM_MSG_HEADER_LEN |
| 43 | #define PIM_PROTO_VERSION (2) |
| 44 | |
| 45 | #define MCAST_ALL_SYSTEMS "224.0.0.1" |
| 46 | #define MCAST_ALL_ROUTERS "224.0.0.2" |
| 47 | #define MCAST_ALL_PIM_ROUTERS "224.0.0.13" |
| 48 | #define MCAST_ALL_IGMP_ROUTERS "224.0.0.22" |
| 49 | |
| 50 | #define PIM_FORCE_BOOLEAN(expr) ((expr) != 0) |
| 51 | |
| 52 | #define PIM_NET_INADDR_ANY (htonl(INADDR_ANY)) |
| 53 | #define PIM_INADDR_IS_ANY(addr) ((addr).s_addr == PIM_NET_INADDR_ANY) /* struct in_addr addr */ |
| 54 | #define PIM_INADDR_ISNOT_ANY(addr) ((addr).s_addr != PIM_NET_INADDR_ANY) /* struct in_addr addr */ |
| 55 | |
Everton Marques | 6273804 | 2009-11-18 10:44:13 -0200 | [diff] [blame] | 56 | #define PIM_MASK_PIM_EVENTS (1 << 0) |
| 57 | #define PIM_MASK_PIM_PACKETS (1 << 1) |
| 58 | #define PIM_MASK_PIM_PACKETDUMP_SEND (1 << 2) |
| 59 | #define PIM_MASK_PIM_PACKETDUMP_RECV (1 << 3) |
| 60 | #define PIM_MASK_PIM_TRACE (1 << 4) |
| 61 | #define PIM_MASK_IGMP_EVENTS (1 << 5) |
| 62 | #define PIM_MASK_IGMP_PACKETS (1 << 6) |
| 63 | #define PIM_MASK_IGMP_TRACE (1 << 7) |
| 64 | #define PIM_MASK_ZEBRA (1 << 8) |
| 65 | #define PIM_MASK_SSMPINGD (1 << 9) |
Everton Marques | 67faabc | 2010-02-23 12:11:11 -0300 | [diff] [blame] | 66 | #define PIM_MASK_MROUTE (1 << 10) |
Jafar Al-Gharaibeh | 030674d | 2015-06-11 18:29:02 -0500 | [diff] [blame] | 67 | #define PIM_MASK_PIM_HELLO (1 << 11) |
| 68 | #define PIM_MASK_PIM_J_P (1 << 12) |
| 69 | #define PIM_MASK_STATIC (1 << 13) |
Everton Marques | 871dbcf | 2009-08-11 15:43:05 -0300 | [diff] [blame] | 70 | |
| 71 | const char *const PIM_ALL_SYSTEMS; |
| 72 | const char *const PIM_ALL_ROUTERS; |
| 73 | const char *const PIM_ALL_PIM_ROUTERS; |
| 74 | const char *const PIM_ALL_IGMP_ROUTERS; |
| 75 | |
| 76 | struct thread_master *master; |
| 77 | uint32_t qpim_debugs; |
| 78 | int qpim_mroute_socket_fd; |
| 79 | int64_t qpim_mroute_socket_creation; /* timestamp of creation */ |
| 80 | struct thread *qpim_mroute_socket_reader; |
| 81 | int qpim_mroute_oif_highest_vif_index; |
| 82 | struct list *qpim_channel_oil_list; /* list of struct channel_oil */ |
| 83 | struct in_addr qpim_all_pim_routers_addr; |
| 84 | int qpim_t_periodic; /* Period between Join/Prune Messages */ |
| 85 | struct list *qpim_upstream_list; /* list of struct pim_upstream */ |
Everton Marques | 3456a80 | 2014-07-22 14:52:57 -0300 | [diff] [blame] | 86 | struct zclient *qpim_zclient_update; |
Everton Marques | 871dbcf | 2009-08-11 15:43:05 -0300 | [diff] [blame] | 87 | struct zclient *qpim_zclient_lookup; |
| 88 | struct pim_assert_metric qpim_infinite_assert_metric; |
| 89 | long qpim_rpf_cache_refresh_delay_msec; |
| 90 | struct thread *qpim_rpf_cache_refresher; |
Everton Marques | 613938d | 2009-08-13 15:39:31 -0300 | [diff] [blame] | 91 | int64_t qpim_rpf_cache_refresh_requests; |
| 92 | int64_t qpim_rpf_cache_refresh_events; |
Everton Marques | bcc4abe | 2009-08-17 18:18:59 -0300 | [diff] [blame] | 93 | int64_t qpim_rpf_cache_refresh_last; |
Everton Marques | 871dbcf | 2009-08-11 15:43:05 -0300 | [diff] [blame] | 94 | struct in_addr qpim_inaddr_any; |
Everton Marques | 96f91ae | 2009-10-07 18:41:45 -0300 | [diff] [blame] | 95 | struct list *qpim_ssmpingd_list; /* list of struct ssmpingd_sock */ |
Everton Marques | e8c11bb | 2009-10-08 15:06:32 -0300 | [diff] [blame] | 96 | struct in_addr qpim_ssmpingd_group_addr; |
Everton Marques | f24200d | 2014-02-14 16:40:34 -0200 | [diff] [blame] | 97 | int64_t qpim_scan_oil_events; |
| 98 | int64_t qpim_scan_oil_last; |
| 99 | int64_t qpim_mroute_add_events; |
| 100 | int64_t qpim_mroute_add_last; |
| 101 | int64_t qpim_mroute_del_events; |
| 102 | int64_t qpim_mroute_del_last; |
Jafar Al-Gharaibeh | 030674d | 2015-06-11 18:29:02 -0500 | [diff] [blame] | 103 | struct list *qpim_static_route_list; /* list of routes added statically */ |
Everton Marques | 871dbcf | 2009-08-11 15:43:05 -0300 | [diff] [blame] | 104 | |
| 105 | #define PIM_JP_HOLDTIME (qpim_t_periodic * 7 / 2) |
| 106 | |
| 107 | #define PIM_MROUTE_IS_ENABLED (qpim_mroute_socket_fd >= 0) |
| 108 | #define PIM_MROUTE_IS_DISABLED (qpim_mroute_socket_fd < 0) |
| 109 | |
Everton Marques | 6273804 | 2009-11-18 10:44:13 -0200 | [diff] [blame] | 110 | #define PIM_DEBUG_PIM_EVENTS (qpim_debugs & PIM_MASK_PIM_EVENTS) |
| 111 | #define PIM_DEBUG_PIM_PACKETS (qpim_debugs & PIM_MASK_PIM_PACKETS) |
| 112 | #define PIM_DEBUG_PIM_PACKETDUMP_SEND (qpim_debugs & PIM_MASK_PIM_PACKETDUMP_SEND) |
| 113 | #define PIM_DEBUG_PIM_PACKETDUMP_RECV (qpim_debugs & PIM_MASK_PIM_PACKETDUMP_RECV) |
| 114 | #define PIM_DEBUG_PIM_TRACE (qpim_debugs & PIM_MASK_PIM_TRACE) |
| 115 | #define PIM_DEBUG_IGMP_EVENTS (qpim_debugs & PIM_MASK_IGMP_EVENTS) |
| 116 | #define PIM_DEBUG_IGMP_PACKETS (qpim_debugs & PIM_MASK_IGMP_PACKETS) |
| 117 | #define PIM_DEBUG_IGMP_TRACE (qpim_debugs & PIM_MASK_IGMP_TRACE) |
| 118 | #define PIM_DEBUG_ZEBRA (qpim_debugs & PIM_MASK_ZEBRA) |
| 119 | #define PIM_DEBUG_SSMPINGD (qpim_debugs & PIM_MASK_SSMPINGD) |
Everton Marques | 67faabc | 2010-02-23 12:11:11 -0300 | [diff] [blame] | 120 | #define PIM_DEBUG_MROUTE (qpim_debugs & PIM_MASK_MROUTE) |
Jafar Al-Gharaibeh | 030674d | 2015-06-11 18:29:02 -0500 | [diff] [blame] | 121 | #define PIM_DEBUG_PIM_HELLO (qpim_debugs & PIM_MASK_PIM_HELLO) |
| 122 | #define PIM_DEBUG_PIM_J_P (qpim_debugs & PIM_MASK_PIM_J_P) |
| 123 | #define PIM_DEBUG_STATIC (qpim_debugs & PIM_MASK_STATIC) |
Everton Marques | 871dbcf | 2009-08-11 15:43:05 -0300 | [diff] [blame] | 124 | |
| 125 | #define PIM_DEBUG_EVENTS (qpim_debugs & (PIM_MASK_PIM_EVENTS | PIM_MASK_IGMP_EVENTS)) |
| 126 | #define PIM_DEBUG_PACKETS (qpim_debugs & (PIM_MASK_PIM_PACKETS | PIM_MASK_IGMP_PACKETS)) |
| 127 | #define PIM_DEBUG_TRACE (qpim_debugs & (PIM_MASK_PIM_TRACE | PIM_MASK_IGMP_TRACE)) |
| 128 | |
Everton Marques | 6273804 | 2009-11-18 10:44:13 -0200 | [diff] [blame] | 129 | #define PIM_DO_DEBUG_PIM_EVENTS (qpim_debugs |= PIM_MASK_PIM_EVENTS) |
| 130 | #define PIM_DO_DEBUG_PIM_PACKETS (qpim_debugs |= PIM_MASK_PIM_PACKETS) |
| 131 | #define PIM_DO_DEBUG_PIM_PACKETDUMP_SEND (qpim_debugs |= PIM_MASK_PIM_PACKETDUMP_SEND) |
| 132 | #define PIM_DO_DEBUG_PIM_PACKETDUMP_RECV (qpim_debugs |= PIM_MASK_PIM_PACKETDUMP_RECV) |
| 133 | #define PIM_DO_DEBUG_PIM_TRACE (qpim_debugs |= PIM_MASK_PIM_TRACE) |
| 134 | #define PIM_DO_DEBUG_IGMP_EVENTS (qpim_debugs |= PIM_MASK_IGMP_EVENTS) |
| 135 | #define PIM_DO_DEBUG_IGMP_PACKETS (qpim_debugs |= PIM_MASK_IGMP_PACKETS) |
| 136 | #define PIM_DO_DEBUG_IGMP_TRACE (qpim_debugs |= PIM_MASK_IGMP_TRACE) |
| 137 | #define PIM_DO_DEBUG_ZEBRA (qpim_debugs |= PIM_MASK_ZEBRA) |
| 138 | #define PIM_DO_DEBUG_SSMPINGD (qpim_debugs |= PIM_MASK_SSMPINGD) |
Everton Marques | 67faabc | 2010-02-23 12:11:11 -0300 | [diff] [blame] | 139 | #define PIM_DO_DEBUG_MROUTE (qpim_debugs |= PIM_MASK_MROUTE) |
Balaji.G | ed14fa0 | 2014-10-08 01:11:31 -0300 | [diff] [blame] | 140 | #define PIM_DO_DEBUG_PIM_HELLO (qpim_debugs |= PIM_MASK_PIM_HELLO) |
| 141 | #define PIM_DO_DEBUG_PIM_J_P (qpim_debugs |= PIM_MASK_PIM_J_P) |
Jafar Al-Gharaibeh | 030674d | 2015-06-11 18:29:02 -0500 | [diff] [blame] | 142 | #define PIM_DO_DEBUG_STATIC (qpim_debugs |= PIM_MASK_STATIC) |
Everton Marques | 871dbcf | 2009-08-11 15:43:05 -0300 | [diff] [blame] | 143 | |
Everton Marques | 6273804 | 2009-11-18 10:44:13 -0200 | [diff] [blame] | 144 | #define PIM_DONT_DEBUG_PIM_EVENTS (qpim_debugs &= ~PIM_MASK_PIM_EVENTS) |
| 145 | #define PIM_DONT_DEBUG_PIM_PACKETS (qpim_debugs &= ~PIM_MASK_PIM_PACKETS) |
| 146 | #define PIM_DONT_DEBUG_PIM_PACKETDUMP_SEND (qpim_debugs &= ~PIM_MASK_PIM_PACKETDUMP_SEND) |
| 147 | #define PIM_DONT_DEBUG_PIM_PACKETDUMP_RECV (qpim_debugs &= ~PIM_MASK_PIM_PACKETDUMP_RECV) |
| 148 | #define PIM_DONT_DEBUG_PIM_TRACE (qpim_debugs &= ~PIM_MASK_PIM_TRACE) |
| 149 | #define PIM_DONT_DEBUG_IGMP_EVENTS (qpim_debugs &= ~PIM_MASK_IGMP_EVENTS) |
| 150 | #define PIM_DONT_DEBUG_IGMP_PACKETS (qpim_debugs &= ~PIM_MASK_IGMP_PACKETS) |
| 151 | #define PIM_DONT_DEBUG_IGMP_TRACE (qpim_debugs &= ~PIM_MASK_IGMP_TRACE) |
| 152 | #define PIM_DONT_DEBUG_ZEBRA (qpim_debugs &= ~PIM_MASK_ZEBRA) |
| 153 | #define PIM_DONT_DEBUG_SSMPINGD (qpim_debugs &= ~PIM_MASK_SSMPINGD) |
Everton Marques | 67faabc | 2010-02-23 12:11:11 -0300 | [diff] [blame] | 154 | #define PIM_DONT_DEBUG_MROUTE (qpim_debugs &= ~PIM_MASK_MROUTE) |
Balaji.G | ed14fa0 | 2014-10-08 01:11:31 -0300 | [diff] [blame] | 155 | #define PIM_DONT_DEBUG_PIM_HELLO (qpim_debugs &= ~PIM_MASK_PIM_HELLO) |
| 156 | #define PIM_DONT_DEBUG_PIM_J_P (qpim_debugs &= ~PIM_MASK_PIM_J_P) |
Jafar Al-Gharaibeh | 030674d | 2015-06-11 18:29:02 -0500 | [diff] [blame] | 157 | #define PIM_DONT_DEBUG_STATIC (qpim_debugs &= ~PIM_MASK_STATIC) |
Everton Marques | 871dbcf | 2009-08-11 15:43:05 -0300 | [diff] [blame] | 158 | |
| 159 | void pim_init(void); |
| 160 | void pim_terminate(void); |
| 161 | |
Donald Sharp | 456cb63 | 2016-06-02 02:37:52 -0400 | [diff] [blame] | 162 | extern void pim_route_map_init (void); |
| 163 | |
Everton Marques | 871dbcf | 2009-08-11 15:43:05 -0300 | [diff] [blame] | 164 | #endif /* PIMD_H */ |