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