]> git.proxmox.com Git - mirror_frr.git/blob - pimd/pim_igmp.h
lib: enforce vrf_name_to_id by returning default_vrf when name is null
[mirror_frr.git] / pimd / pim_igmp.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 PIM_IGMP_H
21 #define PIM_IGMP_H
22
23 #include <netinet/in.h>
24
25 #include <zebra.h>
26 #include "vty.h"
27 #include "linklist.h"
28 #include "pim_igmp_stats.h"
29
30 /*
31 The following sizes are likely to support
32 any message sent within local MTU.
33 */
34 #define PIM_IGMP_BUFSIZE_READ (20000)
35 #define PIM_IGMP_BUFSIZE_WRITE (20000)
36
37 #define PIM_IGMP_MEMBERSHIP_QUERY (0x11)
38 #define PIM_IGMP_V1_MEMBERSHIP_REPORT (0x12)
39 #define PIM_IGMP_V2_MEMBERSHIP_REPORT (0x16)
40 #define PIM_IGMP_V2_LEAVE_GROUP (0x17)
41 #define PIM_IGMP_MTRACE_RESPONSE (0x1E)
42 #define PIM_IGMP_MTRACE_QUERY_REQUEST (0x1F)
43 #define PIM_IGMP_V3_MEMBERSHIP_REPORT (0x22)
44
45 #define IGMP_V3_REPORT_HEADER_SIZE (8)
46 #define IGMP_V3_GROUP_RECORD_MIN_SIZE (8)
47 #define IGMP_V3_MSG_MIN_SIZE \
48 (IGMP_V3_REPORT_HEADER_SIZE + IGMP_V3_GROUP_RECORD_MIN_SIZE)
49 #define IGMP_V12_MSG_SIZE (8)
50
51 #define IGMP_V3_GROUP_RECORD_TYPE_OFFSET (0)
52 #define IGMP_V3_GROUP_RECORD_AUXDATALEN_OFFSET (1)
53 #define IGMP_V3_GROUP_RECORD_NUMSOURCES_OFFSET (2)
54 #define IGMP_V3_GROUP_RECORD_GROUP_OFFSET (4)
55 #define IGMP_V3_GROUP_RECORD_SOURCE_OFFSET (8)
56 #define IGMP_CHECKSUM_OFFSET (2)
57
58 /* RFC 3376: 8.1. Robustness Variable - Default: 2 */
59 #define IGMP_DEFAULT_ROBUSTNESS_VARIABLE (2)
60
61 /* RFC 3376: 8.2. Query Interval - Default: 125 seconds */
62 #define IGMP_GENERAL_QUERY_INTERVAL (125)
63
64 /* RFC 3376: 8.3. Query Response Interval - Default: 100 deciseconds */
65 #define IGMP_QUERY_MAX_RESPONSE_TIME_DSEC (100)
66
67 /* RFC 3376: 8.8. Last Member Query Interval - Default: 10 deciseconds */
68 #define IGMP_SPECIFIC_QUERY_MAX_RESPONSE_TIME_DSEC (10)
69
70 #define IGMP_DEFAULT_VERSION (3)
71
72 struct igmp_join {
73 struct in_addr group_addr;
74 struct in_addr source_addr;
75 int sock_fd;
76 time_t sock_creation;
77 };
78
79 struct igmp_sock {
80 int fd;
81 struct interface *interface;
82 struct in_addr ifaddr;
83 time_t sock_creation;
84
85 struct thread *t_igmp_read; /* read: IGMP sockets */
86 struct thread
87 *t_igmp_query_timer; /* timer: issue IGMP general queries */
88 struct thread *t_other_querier_timer; /* timer: other querier present */
89
90 int querier_query_interval; /* QQI */
91 int querier_robustness_variable; /* QRV */
92 int startup_query_count;
93
94 bool mtrace_only;
95
96 struct list *igmp_group_list; /* list of struct igmp_group */
97 struct hash *igmp_group_hash;
98
99 struct igmp_stats rx_stats;
100 };
101
102 struct igmp_sock *pim_igmp_sock_lookup_ifaddr(struct list *igmp_sock_list,
103 struct in_addr ifaddr);
104 struct igmp_sock *igmp_sock_lookup_by_fd(struct list *igmp_sock_list, int fd);
105 struct igmp_sock *pim_igmp_sock_add(struct list *igmp_sock_list,
106 struct in_addr ifaddr,
107 struct interface *ifp,
108 bool mtrace_only);
109 void igmp_sock_delete(struct igmp_sock *igmp);
110 void igmp_sock_free(struct igmp_sock *igmp);
111 void igmp_sock_delete_all(struct interface *ifp);
112 int pim_igmp_packet(struct igmp_sock *igmp, char *buf, size_t len);
113
114 void pim_igmp_general_query_on(struct igmp_sock *igmp);
115 void pim_igmp_general_query_off(struct igmp_sock *igmp);
116 void pim_igmp_other_querier_timer_on(struct igmp_sock *igmp);
117 void pim_igmp_other_querier_timer_off(struct igmp_sock *igmp);
118
119 #define IGMP_SOURCE_MASK_FORWARDING (1 << 0)
120 #define IGMP_SOURCE_MASK_DELETE (1 << 1)
121 #define IGMP_SOURCE_MASK_SEND (1 << 2)
122 #define IGMP_SOURCE_TEST_FORWARDING(flags) ((flags) & IGMP_SOURCE_MASK_FORWARDING)
123 #define IGMP_SOURCE_TEST_DELETE(flags) ((flags) & IGMP_SOURCE_MASK_DELETE)
124 #define IGMP_SOURCE_TEST_SEND(flags) ((flags) & IGMP_SOURCE_MASK_SEND)
125 #define IGMP_SOURCE_DO_FORWARDING(flags) ((flags) |= IGMP_SOURCE_MASK_FORWARDING)
126 #define IGMP_SOURCE_DO_DELETE(flags) ((flags) |= IGMP_SOURCE_MASK_DELETE)
127 #define IGMP_SOURCE_DO_SEND(flags) ((flags) |= IGMP_SOURCE_MASK_SEND)
128 #define IGMP_SOURCE_DONT_FORWARDING(flags) ((flags) &= ~IGMP_SOURCE_MASK_FORWARDING)
129 #define IGMP_SOURCE_DONT_DELETE(flags) ((flags) &= ~IGMP_SOURCE_MASK_DELETE)
130 #define IGMP_SOURCE_DONT_SEND(flags) ((flags) &= ~IGMP_SOURCE_MASK_SEND)
131
132 struct igmp_source {
133 struct in_addr source_addr;
134 struct thread *t_source_timer;
135 struct igmp_group *source_group; /* back pointer */
136 time_t source_creation;
137 uint32_t source_flags;
138 struct channel_oil *source_channel_oil;
139
140 /*
141 RFC 3376: 6.6.3.2. Building and Sending Group and Source Specific
142 Queries
143 */
144 int source_query_retransmit_count;
145 };
146
147 struct igmp_group {
148 /*
149 RFC 3376: 6.2.2. Definition of Group Timers
150
151 The group timer is only used when a group is in EXCLUDE mode and it
152 represents the time for the *filter-mode* of the group to expire and
153 switch to INCLUDE mode.
154 */
155 struct thread *t_group_timer;
156
157 /* Shared between group-specific and
158 group-and-source-specific retransmissions */
159 struct thread *t_group_query_retransmit_timer;
160
161 /* Counter exclusive for group-specific retransmissions
162 (not used by group-and-source-specific retransmissions,
163 since sources have their counters) */
164 int group_specific_query_retransmit_count;
165
166 /* compatibility mode - igmp v1, v2 or v3 */
167 int igmp_version;
168
169 struct in_addr group_addr;
170 int group_filtermode_isexcl; /* 0=INCLUDE, 1=EXCLUDE */
171 struct list *group_source_list; /* list of struct igmp_source */
172 time_t group_creation;
173 struct igmp_sock *group_igmp_sock; /* back pointer */
174 int64_t last_igmp_v1_report_dsec;
175 int64_t last_igmp_v2_report_dsec;
176 };
177
178 struct igmp_group *find_group_by_addr(struct igmp_sock *igmp,
179 struct in_addr group_addr);
180 struct igmp_group *igmp_add_group_by_addr(struct igmp_sock *igmp,
181 struct in_addr group_addr);
182
183 void igmp_group_delete_empty_include(struct igmp_group *group);
184
185 void igmp_startup_mode_on(struct igmp_sock *igmp);
186
187 void igmp_group_timer_on(struct igmp_group *group, long interval_msec,
188 const char *ifname);
189
190 struct igmp_source *source_new(struct igmp_group *group,
191 struct in_addr src_addr);
192
193 void igmp_send_query(int igmp_version, struct igmp_group *group, int fd,
194 const char *ifname, char *query_buf, int query_buf_size,
195 int num_sources, struct in_addr dst_addr,
196 struct in_addr group_addr,
197 int query_max_response_time_dsec, uint8_t s_flag,
198 uint8_t querier_robustness_variable,
199 uint16_t querier_query_interval);
200 #endif /* PIM_IGMP_H */