2 *------------------------------------------------------------------
3 * Copyright (c) 2018 Cisco and/or its affiliates.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at:
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 *------------------------------------------------------------------
18 #ifndef __IGMP_GROUP_H__
19 #define __IGMP_GROUP_H__
21 #include <igmp/igmp_types.h>
22 #include <igmp/igmp_src.h>
25 * Types of timers maintained for each group
27 typedef enum igmp_group_timer_type_t_
30 * Timer running to reply to a G/SG specific query
32 IGMP_GROUP_TIMER_QUERY_REPLY,
34 * wait for response from a sent G/SG specific query.
35 * Sent when a host leaves a group
37 IGMP_GROUP_TIMER_QUERY_SENT,
39 * Timer running to resend report
41 IGMP_GROUP_TIMER_RESEND_REPORT,
43 * filter-mode change timer, to check if the group can swap to
44 * INCLUDE mode (section 6.2.2)
46 IGMP_GROUP_TIMER_FILTER_MODE_CHANGE,
47 } igmp_group_timer_type_t;
49 #define IGMP_GROUP_N_TIMERS (IGMP_GROUP_TIMER_FILTER_MODE_CHANGE + 1)
53 * A multicast group address for which reception has been requested.
55 typedef struct igmp_group_t_
57 /** The group's key within the per-interface config */
61 * A vector of running timers for the group. this can include:
62 * - group-specific query, sent on reception of a host 'leave'
63 * - filter-mode change timer, to check if the group can swap to
64 * INCLUDE mode (section 6.2.2)
66 u32 timers[IGMP_GROUP_N_TIMERS];
69 * The current filter mode of the group (see 6.2.1)
71 igmp_filter_mode_t router_filter_mode;
74 * The pool index of the config object this group is in
79 * The number of times the last report has been sent
84 * Source list per-filter mode
86 uword *igmp_src_by_key[IGMP_N_FILTER_MODES];
89 #define FOR_EACH_SRC(_src, _group, _filter, _body) \
91 igmp_key_t *__key__; \
93 hash_foreach_mem(__key__, __sid__, ((igmp_group_t*)_group)->igmp_src_by_key[(_filter)], \
95 _src = pool_elt_at_index(igmp_main.srcs, __sid__); \
96 do { _body; } while (0); \
101 * Forward declarations
103 struct igmp_config_t_;
105 extern void igmp_group_clear (igmp_group_t * group);
106 extern void igmp_group_free_all_srcs (igmp_group_t * group);
108 extern igmp_group_t *igmp_group_alloc (struct igmp_config_t_ *config,
109 const igmp_key_t * gkey,
110 igmp_filter_mode_t mode);
112 extern igmp_src_t *igmp_group_src_update (igmp_group_t * group,
113 const igmp_key_t * skey,
116 extern void igmp_group_src_remove (igmp_group_t * group, igmp_src_t * src);
118 extern ip46_address_t *igmp_group_present_minus_new (igmp_group_t * group,
119 igmp_filter_mode_t mode,
120 const ip46_address_t *
123 extern ip46_address_t *igmp_group_new_minus_present (igmp_group_t * group,
124 igmp_filter_mode_t mode,
125 const ip46_address_t *
128 extern ip46_address_t *igmp_group_new_intersect_present (igmp_group_t * group,
134 extern u32 igmp_group_n_srcs (const igmp_group_t * group,
135 igmp_filter_mode_t mode);
138 /** \brief igmp group lookup
139 @param group - igmp group
140 @param key - igmp key
142 extern igmp_src_t *igmp_src_lookup (igmp_group_t * group,
143 const igmp_key_t * key);
145 extern u32 igmp_group_index (const igmp_group_t * g);
146 extern igmp_group_t *igmp_group_get (u32 index);
151 * fd.io coding-style-patch-verification: ON
154 * eval: (c-set-style "gnu")