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