]> git.proxmox.com Git - mirror_frr.git/blob - pimd/pimd.h
pimd: Handle assignment of vif index better
[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
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
21 #ifndef PIMD_H
22 #define PIMD_H
23
24 #include <stdint.h>
25
26 #include "pim_str.h"
27 #include "pim_memory.h"
28 #include "pim_assert.h"
29
30 #define PIMD_PROGNAME "pimd"
31 #define PIMD_DEFAULT_CONFIG "pimd.conf"
32 #define PIMD_VTY_PORT 2611
33
34 #define PIM_IP_HEADER_MIN_LEN (20)
35 #define PIM_IP_HEADER_MAX_LEN (60)
36 #define PIM_IP_PROTO_IGMP (2)
37 #define PIM_IP_PROTO_PIM (103)
38 #define PIM_IGMP_MIN_LEN (8)
39 #define PIM_MSG_HEADER_LEN (4)
40 #define PIM_PIM_MIN_LEN PIM_MSG_HEADER_LEN
41 #define PIM_PROTO_VERSION (2)
42
43 #define MCAST_ALL_SYSTEMS "224.0.0.1"
44 #define MCAST_ALL_ROUTERS "224.0.0.2"
45 #define MCAST_ALL_PIM_ROUTERS "224.0.0.13"
46 #define MCAST_ALL_IGMP_ROUTERS "224.0.0.22"
47
48 #define PIM_FORCE_BOOLEAN(expr) ((expr) != 0)
49
50 #define PIM_NET_INADDR_ANY (htonl(INADDR_ANY))
51 #define PIM_INADDR_IS_ANY(addr) (addr).s_addr == PIM_NET_INADDR_ANY
52 #define PIM_INADDR_ISNOT_ANY(addr) ((addr).s_addr != PIM_NET_INADDR_ANY) /* struct in_addr addr */
53
54 #define max(x,y) ((x) > (y) ? (x) : (y))
55
56 #define PIM_MASK_PIM_EVENTS (1 << 0)
57 #define PIM_MASK_PIM_EVENTS_DETAIL (1 << 1)
58 #define PIM_MASK_PIM_PACKETS (1 << 2)
59 #define PIM_MASK_PIM_PACKETDUMP_SEND (1 << 3)
60 #define PIM_MASK_PIM_PACKETDUMP_RECV (1 << 4)
61 #define PIM_MASK_PIM_TRACE (1 << 5)
62 #define PIM_MASK_PIM_TRACE_DETAIL (1 << 6)
63 #define PIM_MASK_IGMP_EVENTS (1 << 7)
64 #define PIM_MASK_IGMP_PACKETS (1 << 8)
65 #define PIM_MASK_IGMP_TRACE (1 << 9)
66 #define PIM_MASK_IGMP_TRACE_DETAIL (1 << 10)
67 #define PIM_MASK_ZEBRA (1 << 11)
68 #define PIM_MASK_SSMPINGD (1 << 12)
69 #define PIM_MASK_MROUTE (1 << 13)
70 #define PIM_MASK_MROUTE_DETAIL (1 << 14)
71 #define PIM_MASK_PIM_HELLO (1 << 15)
72 #define PIM_MASK_PIM_J_P (1 << 16)
73 #define PIM_MASK_STATIC (1 << 17)
74 #define PIM_MASK_PIM_REG (1 << 18)
75 #define PIM_MASK_MSDP_EVENTS (1 << 19)
76 #define PIM_MASK_MSDP_PACKETS (1 << 20)
77 #define PIM_MASK_MSDP_INTERNAL (1 << 21)
78
79
80 /* PIM error codes */
81 #define PIM_SUCCESS 0
82 #define PIM_MALLOC_FAIL -1
83 #define PIM_GROUP_BAD_ADDRESS -2
84 #define PIM_GROUP_OVERLAP -3
85 #define PIM_GROUP_PFXLIST_OVERLAP -4
86 #define PIM_RP_BAD_ADDRESS -5
87 #define PIM_RP_NO_PATH -6
88 #define PIM_RP_NOT_FOUND -7
89 #define PIM_RP_PFXLIST_IN_USE -8
90 #define PIM_IFACE_NOT_FOUND -9
91 #define PIM_UPDATE_SOURCE_DUP -10
92
93 const char *const PIM_ALL_SYSTEMS;
94 const char *const PIM_ALL_ROUTERS;
95 const char *const PIM_ALL_PIM_ROUTERS;
96 const char *const PIM_ALL_IGMP_ROUTERS;
97
98 extern struct thread_master *master;
99 uint32_t qpim_debugs;
100 int qpim_mroute_socket_fd;
101 int64_t qpim_mroute_socket_creation; /* timestamp of creation */
102 struct in_addr qpim_all_pim_routers_addr;
103 int qpim_t_periodic; /* Period between Join/Prune Messages */
104 struct pim_assert_metric qpim_infinite_assert_metric;
105 long qpim_rpf_cache_refresh_delay_msec;
106 struct thread *qpim_rpf_cache_refresher;
107 int64_t qpim_rpf_cache_refresh_requests;
108 int64_t qpim_rpf_cache_refresh_events;
109 int64_t qpim_rpf_cache_refresh_last;
110 struct in_addr qpim_inaddr_any;
111 struct list *qpim_ssmpingd_list; /* list of struct ssmpingd_sock */
112 struct in_addr qpim_ssmpingd_group_addr;
113 int64_t qpim_scan_oil_events;
114 int64_t qpim_scan_oil_last;
115 int64_t qpim_mroute_add_events;
116 int64_t qpim_mroute_add_last;
117 int64_t qpim_mroute_del_events;
118 int64_t qpim_mroute_del_last;
119 int64_t qpim_nexthop_lookups;
120 struct list *qpim_static_route_list; /* list of routes added statically */
121 extern unsigned int qpim_keep_alive_time;
122 extern signed int qpim_rp_keep_alive_time;
123 extern int qpim_packet_process;
124 #define PIM_DEFAULT_PACKET_PROCESS 3
125
126 #define PIM_JP_HOLDTIME (qpim_t_periodic * 7 / 2)
127
128 #define PIM_MROUTE_IS_ENABLED (qpim_mroute_socket_fd >= 0)
129 #define PIM_MROUTE_IS_DISABLED (qpim_mroute_socket_fd < 0)
130
131 /*
132 * Register-Stop Timer (RST(S,G))
133 * Default values
134 */
135 extern int32_t qpim_register_suppress_time;
136 extern int32_t qpim_register_probe_time;
137 #define PIM_REGISTER_SUPPRESSION_TIME_DEFAULT (60)
138 #define PIM_REGISTER_PROBE_TIME_DEFAULT (5)
139
140 #define PIM_DEBUG_PIM_EVENTS (qpim_debugs & PIM_MASK_PIM_EVENTS)
141 #define PIM_DEBUG_PIM_EVENTS_DETAIL (qpim_debugs & PIM_MASK_PIM_EVENTS_DETAIL)
142 #define PIM_DEBUG_PIM_PACKETS (qpim_debugs & PIM_MASK_PIM_PACKETS)
143 #define PIM_DEBUG_PIM_PACKETDUMP_SEND (qpim_debugs & PIM_MASK_PIM_PACKETDUMP_SEND)
144 #define PIM_DEBUG_PIM_PACKETDUMP_RECV (qpim_debugs & PIM_MASK_PIM_PACKETDUMP_RECV)
145 #define PIM_DEBUG_PIM_TRACE (qpim_debugs & PIM_MASK_PIM_TRACE)
146 #define PIM_DEBUG_PIM_TRACE_DETAIL (qpim_debugs & PIM_MASK_PIM_TRACE_DETAIL)
147 #define PIM_DEBUG_IGMP_EVENTS (qpim_debugs & PIM_MASK_IGMP_EVENTS)
148 #define PIM_DEBUG_IGMP_PACKETS (qpim_debugs & PIM_MASK_IGMP_PACKETS)
149 #define PIM_DEBUG_IGMP_TRACE (qpim_debugs & PIM_MASK_IGMP_TRACE)
150 #define PIM_DEBUG_IGMP_TRACE_DETAIL (qpim_debugs & PIM_MASK_IGMP_TRACE_DETAIL)
151 #define PIM_DEBUG_ZEBRA (qpim_debugs & PIM_MASK_ZEBRA)
152 #define PIM_DEBUG_SSMPINGD (qpim_debugs & PIM_MASK_SSMPINGD)
153 #define PIM_DEBUG_MROUTE (qpim_debugs & PIM_MASK_MROUTE)
154 #define PIM_DEBUG_MROUTE_DETAIL (qpim_debugs & PIM_MASK_MROUTE_DETAIL)
155 #define PIM_DEBUG_PIM_HELLO (qpim_debugs & PIM_MASK_PIM_HELLO)
156 #define PIM_DEBUG_PIM_J_P (qpim_debugs & PIM_MASK_PIM_J_P)
157 #define PIM_DEBUG_PIM_REG (qpim_debugs & PIM_MASK_PIM_REG)
158 #define PIM_DEBUG_STATIC (qpim_debugs & PIM_MASK_STATIC)
159 #define PIM_DEBUG_MSDP_EVENTS (qpim_debugs & PIM_MASK_MSDP_EVENTS)
160 #define PIM_DEBUG_MSDP_PACKETS (qpim_debugs & PIM_MASK_MSDP_PACKETS)
161 #define PIM_DEBUG_MSDP_INTERNAL (qpim_debugs & PIM_MASK_MSDP_INTERNAL)
162
163 #define PIM_DEBUG_EVENTS (qpim_debugs & (PIM_MASK_PIM_EVENTS | PIM_MASK_IGMP_EVENTS | PIM_MASK_MSDP_EVENTS))
164 #define PIM_DEBUG_PACKETS (qpim_debugs & (PIM_MASK_PIM_PACKETS | PIM_MASK_IGMP_PACKETS | PIM_MASK_MSDP_PACKETS))
165 #define PIM_DEBUG_TRACE (qpim_debugs & (PIM_MASK_PIM_TRACE | PIM_MASK_IGMP_TRACE))
166
167 #define PIM_DO_DEBUG_PIM_EVENTS (qpim_debugs |= PIM_MASK_PIM_EVENTS)
168 #define PIM_DO_DEBUG_PIM_PACKETS (qpim_debugs |= PIM_MASK_PIM_PACKETS)
169 #define PIM_DO_DEBUG_PIM_PACKETDUMP_SEND (qpim_debugs |= PIM_MASK_PIM_PACKETDUMP_SEND)
170 #define PIM_DO_DEBUG_PIM_PACKETDUMP_RECV (qpim_debugs |= PIM_MASK_PIM_PACKETDUMP_RECV)
171 #define PIM_DO_DEBUG_PIM_TRACE (qpim_debugs |= PIM_MASK_PIM_TRACE)
172 #define PIM_DO_DEBUG_IGMP_EVENTS (qpim_debugs |= PIM_MASK_IGMP_EVENTS)
173 #define PIM_DO_DEBUG_IGMP_PACKETS (qpim_debugs |= PIM_MASK_IGMP_PACKETS)
174 #define PIM_DO_DEBUG_IGMP_TRACE (qpim_debugs |= PIM_MASK_IGMP_TRACE)
175 #define PIM_DO_DEBUG_IGMP_TRACE_DETAIL (qpim_debugs |= PIM_MASK_IGMP_TRACE_DETAIL)
176 #define PIM_DO_DEBUG_ZEBRA (qpim_debugs |= PIM_MASK_ZEBRA)
177 #define PIM_DO_DEBUG_SSMPINGD (qpim_debugs |= PIM_MASK_SSMPINGD)
178 #define PIM_DO_DEBUG_MROUTE (qpim_debugs |= PIM_MASK_MROUTE)
179 #define PIM_DO_DEBUG_MROUTE_DETAIL (qpim_debugs |= PIM_MASK_MROUTE_DETAIL)
180 #define PIM_DO_DEBUG_PIM_HELLO (qpim_debugs |= PIM_MASK_PIM_HELLO)
181 #define PIM_DO_DEBUG_PIM_J_P (qpim_debugs |= PIM_MASK_PIM_J_P)
182 #define PIM_DO_DEBUG_PIM_REG (qpim_debugs |= PIM_MASK_PIM_REG)
183 #define PIM_DO_DEBUG_STATIC (qpim_debugs |= PIM_MASK_STATIC)
184 #define PIM_DO_DEBUG_MSDP_EVENTS (qpim_debugs |= PIM_MASK_MSDP_EVENTS)
185 #define PIM_DO_DEBUG_MSDP_PACKETS (qpim_debugs |= PIM_MASK_MSDP_PACKETS)
186 #define PIM_DO_DEBUG_MSDP_INTERNAL (qpim_debugs |= PIM_MASK_MSDP_INTERNAL)
187
188 #define PIM_DONT_DEBUG_PIM_EVENTS (qpim_debugs &= ~PIM_MASK_PIM_EVENTS)
189 #define PIM_DONT_DEBUG_PIM_PACKETS (qpim_debugs &= ~PIM_MASK_PIM_PACKETS)
190 #define PIM_DONT_DEBUG_PIM_PACKETDUMP_SEND (qpim_debugs &= ~PIM_MASK_PIM_PACKETDUMP_SEND)
191 #define PIM_DONT_DEBUG_PIM_PACKETDUMP_RECV (qpim_debugs &= ~PIM_MASK_PIM_PACKETDUMP_RECV)
192 #define PIM_DONT_DEBUG_PIM_TRACE (qpim_debugs &= ~PIM_MASK_PIM_TRACE)
193 #define PIM_DONT_DEBUG_IGMP_EVENTS (qpim_debugs &= ~PIM_MASK_IGMP_EVENTS)
194 #define PIM_DONT_DEBUG_IGMP_PACKETS (qpim_debugs &= ~PIM_MASK_IGMP_PACKETS)
195 #define PIM_DONT_DEBUG_IGMP_TRACE (qpim_debugs &= ~PIM_MASK_IGMP_TRACE)
196 #define PIM_DONT_DEBUG_IGMP_TRACE_DETAIL (qpim_debugs &= ~PIM_MASK_IGMP_TRACE_DETAIL)
197 #define PIM_DONT_DEBUG_ZEBRA (qpim_debugs &= ~PIM_MASK_ZEBRA)
198 #define PIM_DONT_DEBUG_SSMPINGD (qpim_debugs &= ~PIM_MASK_SSMPINGD)
199 #define PIM_DONT_DEBUG_MROUTE (qpim_debugs &= ~PIM_MASK_MROUTE)
200 #define PIM_DONT_DEBUG_MROUTE_DETAIL (qpim_debugs &= ~PIM_MASK_MROUTE_DETAIL)
201 #define PIM_DONT_DEBUG_PIM_HELLO (qpim_debugs &= ~PIM_MASK_PIM_HELLO)
202 #define PIM_DONT_DEBUG_PIM_J_P (qpim_debugs &= ~PIM_MASK_PIM_J_P)
203 #define PIM_DONT_DEBUG_PIM_REG (qpim_debugs &= ~PIM_MASK_PIM_REG)
204 #define PIM_DONT_DEBUG_STATIC (qpim_debugs &= ~PIM_MASK_STATIC)
205 #define PIM_DONT_DEBUG_MSDP_EVENTS (qpim_debugs &= ~PIM_MASK_MSDP_EVENTS)
206 #define PIM_DONT_DEBUG_MSDP_PACKETS (qpim_debugs &= ~PIM_MASK_MSDP_PACKETS)
207 #define PIM_DONT_DEBUG_MSDP_INTERNAL (qpim_debugs &= ~PIM_MASK_MSDP_INTERNAL)
208
209 void pim_init(void);
210 void pim_terminate(void);
211
212 extern void pim_route_map_init (void);
213 extern void pim_route_map_terminate(void);
214
215 #endif /* PIMD_H */