]> git.proxmox.com Git - mirror_frr.git/blob - pimd/pimd.h
Merge pull request #656 from qlyoung/fix-varhandler-reachable
[mirror_frr.git] / pimd / pimd.h
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 along
16 * with this program; see the file COPYING; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18 */
19
20 #ifndef PIMD_H
21 #define PIMD_H
22
23 #include <stdint.h>
24 #include "zebra.h"
25 #include "libfrr.h"
26 #include "prefix.h"
27 #include "vty.h"
28 #include "plist.h"
29
30 #include "pim_str.h"
31 #include "pim_memory.h"
32 #include "pim_assert.h"
33
34 #define PIMD_PROGNAME "pimd"
35 #define PIMD_DEFAULT_CONFIG "pimd.conf"
36 #define PIMD_VTY_PORT 2611
37
38 #define PIM_IP_PROTO_IGMP (2)
39 #define PIM_IP_PROTO_PIM (103)
40 #define PIM_IGMP_MIN_LEN (8)
41
42 /*
43 * PIM MSG Header Format
44 * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
45 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
46 * |PIM Ver| Type | Reserved | Checksum |
47 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
48 */
49 #define PIM_MSG_HEADER_LEN (4)
50 #define PIM_PIM_MIN_LEN PIM_MSG_HEADER_LEN
51
52 #define PIM_ENCODED_IPV4_UCAST_SIZE (6)
53 #define PIM_ENCODED_IPV4_GROUP_SIZE (8)
54 #define PIM_ENCODED_IPV4_SOURCE_SIZE (8)
55
56 /*
57 * J/P Message Format, Group Header
58 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
59 * | Upstream Neighbor Address (Encoded-Unicast format) |
60 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
61 * | Reserved | Num groups | Holdtime |
62 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
63 * | Multicast Group Address 1 (Encoded-Group format) |
64 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
65 * | Number of Joined Sources | Number of Pruned Sources |
66 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
67 */
68 #define PIM_JP_GROUP_HEADER_SIZE (PIM_ENCODED_IPV4_UCAST_SIZE + \
69 1 + 1 + 2 + \
70 PIM_ENCODED_IPV4_GROUP_SIZE + \
71 2 + 2)
72
73 #define PIM_PROTO_VERSION (2)
74
75 #define MCAST_ALL_SYSTEMS "224.0.0.1"
76 #define MCAST_ALL_ROUTERS "224.0.0.2"
77 #define MCAST_ALL_PIM_ROUTERS "224.0.0.13"
78 #define MCAST_ALL_IGMP_ROUTERS "224.0.0.22"
79
80 #define PIM_FORCE_BOOLEAN(expr) ((expr) != 0)
81
82 #define PIM_NET_INADDR_ANY (htonl(INADDR_ANY))
83 #define PIM_INADDR_IS_ANY(addr) (addr).s_addr == PIM_NET_INADDR_ANY
84 #define PIM_INADDR_ISNOT_ANY(addr) ((addr).s_addr != PIM_NET_INADDR_ANY) /* struct in_addr addr */
85
86 #define max(x,y) ((x) > (y) ? (x) : (y))
87
88 #define PIM_MASK_PIM_EVENTS (1 << 0)
89 #define PIM_MASK_PIM_EVENTS_DETAIL (1 << 1)
90 #define PIM_MASK_PIM_PACKETS (1 << 2)
91 #define PIM_MASK_PIM_PACKETDUMP_SEND (1 << 3)
92 #define PIM_MASK_PIM_PACKETDUMP_RECV (1 << 4)
93 #define PIM_MASK_PIM_TRACE (1 << 5)
94 #define PIM_MASK_PIM_TRACE_DETAIL (1 << 6)
95 #define PIM_MASK_IGMP_EVENTS (1 << 7)
96 #define PIM_MASK_IGMP_PACKETS (1 << 8)
97 #define PIM_MASK_IGMP_TRACE (1 << 9)
98 #define PIM_MASK_IGMP_TRACE_DETAIL (1 << 10)
99 #define PIM_MASK_ZEBRA (1 << 11)
100 #define PIM_MASK_SSMPINGD (1 << 12)
101 #define PIM_MASK_MROUTE (1 << 13)
102 #define PIM_MASK_MROUTE_DETAIL (1 << 14)
103 #define PIM_MASK_PIM_HELLO (1 << 15)
104 #define PIM_MASK_PIM_J_P (1 << 16)
105 #define PIM_MASK_STATIC (1 << 17)
106 #define PIM_MASK_PIM_REG (1 << 18)
107 #define PIM_MASK_MSDP_EVENTS (1 << 19)
108 #define PIM_MASK_MSDP_PACKETS (1 << 20)
109 #define PIM_MASK_MSDP_INTERNAL (1 << 21)
110
111
112 /* PIM error codes */
113 #define PIM_SUCCESS 0
114 #define PIM_MALLOC_FAIL -1
115 #define PIM_GROUP_BAD_ADDRESS -2
116 #define PIM_GROUP_OVERLAP -3
117 #define PIM_GROUP_PFXLIST_OVERLAP -4
118 #define PIM_RP_BAD_ADDRESS -5
119 #define PIM_RP_NO_PATH -6
120 #define PIM_RP_NOT_FOUND -7
121 #define PIM_RP_PFXLIST_IN_USE -8
122 #define PIM_IFACE_NOT_FOUND -9
123 #define PIM_UPDATE_SOURCE_DUP -10
124
125 const char *const PIM_ALL_SYSTEMS;
126 const char *const PIM_ALL_ROUTERS;
127 const char *const PIM_ALL_PIM_ROUTERS;
128 const char *const PIM_ALL_IGMP_ROUTERS;
129
130 extern struct thread_master *master;
131 extern struct zebra_privs_t pimd_privs;
132 uint32_t qpim_debugs;
133 int qpim_mroute_socket_fd;
134 int64_t qpim_mroute_socket_creation; /* timestamp of creation */
135 struct in_addr qpim_all_pim_routers_addr;
136 int qpim_t_periodic; /* Period between Join/Prune Messages */
137 struct pim_assert_metric qpim_infinite_assert_metric;
138 long qpim_rpf_cache_refresh_delay_msec;
139 struct thread *qpim_rpf_cache_refresher;
140 int64_t qpim_rpf_cache_refresh_requests;
141 int64_t qpim_rpf_cache_refresh_events;
142 int64_t qpim_rpf_cache_refresh_last;
143 struct list *qpim_ssmpingd_list; /* list of struct ssmpingd_sock */
144 struct in_addr qpim_ssmpingd_group_addr;
145 int64_t qpim_scan_oil_events;
146 int64_t qpim_scan_oil_last;
147 int64_t qpim_mroute_add_events;
148 int64_t qpim_mroute_add_last;
149 int64_t qpim_mroute_del_events;
150 int64_t qpim_mroute_del_last;
151 int64_t qpim_nexthop_lookups;
152 struct list *qpim_static_route_list; /* list of routes added statically */
153 extern unsigned int qpim_keep_alive_time;
154 extern signed int qpim_rp_keep_alive_time;
155 extern int qpim_packet_process;
156 extern uint8_t qpim_ecmp_enable;
157 extern uint8_t qpim_ecmp_rebalance_enable;
158
159 #define PIM_DEFAULT_PACKET_PROCESS 3
160
161 #define PIM_JP_HOLDTIME (qpim_t_periodic * 7 / 2)
162
163 /*
164 * Register-Stop Timer (RST(S,G))
165 * Default values
166 */
167 extern int32_t qpim_register_suppress_time;
168 extern int32_t qpim_register_probe_time;
169 #define PIM_REGISTER_SUPPRESSION_TIME_DEFAULT (60)
170 #define PIM_REGISTER_PROBE_TIME_DEFAULT (5)
171
172 #define PIM_DEBUG_PIM_EVENTS (qpim_debugs & PIM_MASK_PIM_EVENTS)
173 #define PIM_DEBUG_PIM_EVENTS_DETAIL (qpim_debugs & PIM_MASK_PIM_EVENTS_DETAIL)
174 #define PIM_DEBUG_PIM_PACKETS (qpim_debugs & PIM_MASK_PIM_PACKETS)
175 #define PIM_DEBUG_PIM_PACKETDUMP_SEND (qpim_debugs & PIM_MASK_PIM_PACKETDUMP_SEND)
176 #define PIM_DEBUG_PIM_PACKETDUMP_RECV (qpim_debugs & PIM_MASK_PIM_PACKETDUMP_RECV)
177 #define PIM_DEBUG_PIM_TRACE (qpim_debugs & PIM_MASK_PIM_TRACE)
178 #define PIM_DEBUG_PIM_TRACE_DETAIL (qpim_debugs & PIM_MASK_PIM_TRACE_DETAIL)
179 #define PIM_DEBUG_IGMP_EVENTS (qpim_debugs & PIM_MASK_IGMP_EVENTS)
180 #define PIM_DEBUG_IGMP_PACKETS (qpim_debugs & PIM_MASK_IGMP_PACKETS)
181 #define PIM_DEBUG_IGMP_TRACE (qpim_debugs & PIM_MASK_IGMP_TRACE)
182 #define PIM_DEBUG_IGMP_TRACE_DETAIL (qpim_debugs & PIM_MASK_IGMP_TRACE_DETAIL)
183 #define PIM_DEBUG_ZEBRA (qpim_debugs & PIM_MASK_ZEBRA)
184 #define PIM_DEBUG_SSMPINGD (qpim_debugs & PIM_MASK_SSMPINGD)
185 #define PIM_DEBUG_MROUTE (qpim_debugs & PIM_MASK_MROUTE)
186 #define PIM_DEBUG_MROUTE_DETAIL (qpim_debugs & PIM_MASK_MROUTE_DETAIL)
187 #define PIM_DEBUG_PIM_HELLO (qpim_debugs & PIM_MASK_PIM_HELLO)
188 #define PIM_DEBUG_PIM_J_P (qpim_debugs & PIM_MASK_PIM_J_P)
189 #define PIM_DEBUG_PIM_REG (qpim_debugs & PIM_MASK_PIM_REG)
190 #define PIM_DEBUG_STATIC (qpim_debugs & PIM_MASK_STATIC)
191 #define PIM_DEBUG_MSDP_EVENTS (qpim_debugs & PIM_MASK_MSDP_EVENTS)
192 #define PIM_DEBUG_MSDP_PACKETS (qpim_debugs & PIM_MASK_MSDP_PACKETS)
193 #define PIM_DEBUG_MSDP_INTERNAL (qpim_debugs & PIM_MASK_MSDP_INTERNAL)
194
195 #define PIM_DEBUG_EVENTS (qpim_debugs & (PIM_MASK_PIM_EVENTS | PIM_MASK_IGMP_EVENTS | PIM_MASK_MSDP_EVENTS))
196 #define PIM_DEBUG_PACKETS (qpim_debugs & (PIM_MASK_PIM_PACKETS | PIM_MASK_IGMP_PACKETS | PIM_MASK_MSDP_PACKETS))
197 #define PIM_DEBUG_TRACE (qpim_debugs & (PIM_MASK_PIM_TRACE | PIM_MASK_IGMP_TRACE))
198
199 #define PIM_DO_DEBUG_PIM_EVENTS (qpim_debugs |= PIM_MASK_PIM_EVENTS)
200 #define PIM_DO_DEBUG_PIM_PACKETS (qpim_debugs |= PIM_MASK_PIM_PACKETS)
201 #define PIM_DO_DEBUG_PIM_PACKETDUMP_SEND (qpim_debugs |= PIM_MASK_PIM_PACKETDUMP_SEND)
202 #define PIM_DO_DEBUG_PIM_PACKETDUMP_RECV (qpim_debugs |= PIM_MASK_PIM_PACKETDUMP_RECV)
203 #define PIM_DO_DEBUG_PIM_TRACE (qpim_debugs |= PIM_MASK_PIM_TRACE)
204 #define PIM_DO_DEBUG_IGMP_EVENTS (qpim_debugs |= PIM_MASK_IGMP_EVENTS)
205 #define PIM_DO_DEBUG_IGMP_PACKETS (qpim_debugs |= PIM_MASK_IGMP_PACKETS)
206 #define PIM_DO_DEBUG_IGMP_TRACE (qpim_debugs |= PIM_MASK_IGMP_TRACE)
207 #define PIM_DO_DEBUG_IGMP_TRACE_DETAIL (qpim_debugs |= PIM_MASK_IGMP_TRACE_DETAIL)
208 #define PIM_DO_DEBUG_ZEBRA (qpim_debugs |= PIM_MASK_ZEBRA)
209 #define PIM_DO_DEBUG_SSMPINGD (qpim_debugs |= PIM_MASK_SSMPINGD)
210 #define PIM_DO_DEBUG_MROUTE (qpim_debugs |= PIM_MASK_MROUTE)
211 #define PIM_DO_DEBUG_MROUTE_DETAIL (qpim_debugs |= PIM_MASK_MROUTE_DETAIL)
212 #define PIM_DO_DEBUG_PIM_HELLO (qpim_debugs |= PIM_MASK_PIM_HELLO)
213 #define PIM_DO_DEBUG_PIM_J_P (qpim_debugs |= PIM_MASK_PIM_J_P)
214 #define PIM_DO_DEBUG_PIM_REG (qpim_debugs |= PIM_MASK_PIM_REG)
215 #define PIM_DO_DEBUG_STATIC (qpim_debugs |= PIM_MASK_STATIC)
216 #define PIM_DO_DEBUG_MSDP_EVENTS (qpim_debugs |= PIM_MASK_MSDP_EVENTS)
217 #define PIM_DO_DEBUG_MSDP_PACKETS (qpim_debugs |= PIM_MASK_MSDP_PACKETS)
218 #define PIM_DO_DEBUG_MSDP_INTERNAL (qpim_debugs |= PIM_MASK_MSDP_INTERNAL)
219
220 #define PIM_DONT_DEBUG_PIM_EVENTS (qpim_debugs &= ~PIM_MASK_PIM_EVENTS)
221 #define PIM_DONT_DEBUG_PIM_PACKETS (qpim_debugs &= ~PIM_MASK_PIM_PACKETS)
222 #define PIM_DONT_DEBUG_PIM_PACKETDUMP_SEND (qpim_debugs &= ~PIM_MASK_PIM_PACKETDUMP_SEND)
223 #define PIM_DONT_DEBUG_PIM_PACKETDUMP_RECV (qpim_debugs &= ~PIM_MASK_PIM_PACKETDUMP_RECV)
224 #define PIM_DONT_DEBUG_PIM_TRACE (qpim_debugs &= ~PIM_MASK_PIM_TRACE)
225 #define PIM_DONT_DEBUG_IGMP_EVENTS (qpim_debugs &= ~PIM_MASK_IGMP_EVENTS)
226 #define PIM_DONT_DEBUG_IGMP_PACKETS (qpim_debugs &= ~PIM_MASK_IGMP_PACKETS)
227 #define PIM_DONT_DEBUG_IGMP_TRACE (qpim_debugs &= ~PIM_MASK_IGMP_TRACE)
228 #define PIM_DONT_DEBUG_IGMP_TRACE_DETAIL (qpim_debugs &= ~PIM_MASK_IGMP_TRACE_DETAIL)
229 #define PIM_DONT_DEBUG_ZEBRA (qpim_debugs &= ~PIM_MASK_ZEBRA)
230 #define PIM_DONT_DEBUG_SSMPINGD (qpim_debugs &= ~PIM_MASK_SSMPINGD)
231 #define PIM_DONT_DEBUG_MROUTE (qpim_debugs &= ~PIM_MASK_MROUTE)
232 #define PIM_DONT_DEBUG_MROUTE_DETAIL (qpim_debugs &= ~PIM_MASK_MROUTE_DETAIL)
233 #define PIM_DONT_DEBUG_PIM_HELLO (qpim_debugs &= ~PIM_MASK_PIM_HELLO)
234 #define PIM_DONT_DEBUG_PIM_J_P (qpim_debugs &= ~PIM_MASK_PIM_J_P)
235 #define PIM_DONT_DEBUG_PIM_REG (qpim_debugs &= ~PIM_MASK_PIM_REG)
236 #define PIM_DONT_DEBUG_STATIC (qpim_debugs &= ~PIM_MASK_STATIC)
237 #define PIM_DONT_DEBUG_MSDP_EVENTS (qpim_debugs &= ~PIM_MASK_MSDP_EVENTS)
238 #define PIM_DONT_DEBUG_MSDP_PACKETS (qpim_debugs &= ~PIM_MASK_MSDP_PACKETS)
239 #define PIM_DONT_DEBUG_MSDP_INTERNAL (qpim_debugs &= ~PIM_MASK_MSDP_INTERNAL)
240
241 enum pim_spt_switchover {
242 PIM_SPT_IMMEDIATE,
243 PIM_SPT_INFINITY,
244 };
245
246 /* Per VRF PIM DB */
247 struct pim_instance
248 {
249 afi_t afi;
250 vrf_id_t vrf_id;
251
252 struct {
253 enum pim_spt_switchover switchover;
254 char *plist;
255 } spt;
256
257 struct hash *rpf_hash;
258
259 void *ssm_info; /* per-vrf SSM configuration */
260
261 int send_v6_secondary;
262 };
263
264 extern struct pim_instance *pimg; //Pim Global Instance
265
266 void pim_init(void);
267 void pim_terminate(void);
268
269 extern void pim_route_map_init (void);
270 extern void pim_route_map_terminate(void);
271 void pim_vrf_init (void);
272 void pim_prefix_list_update (struct prefix_list *plist);
273
274 #endif /* PIMD_H */