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_CONFIG_H__
19 #define __IGMP_CONFIG_H__
21 #include <igmp/igmp_types.h>
22 #include <igmp/igmp_timer.h>
23 #include <igmp/igmp_group.h>
26 * GENERAL_REPORT = On expiry send a general report
27 * GENERAL_QUERY = On expiry send a general query
29 #define foreach_igmp_config_timer_type \
30 _(GENERAL_REPORT, "general-report") \
31 _(GENERAL_QUERY, "general-query")
33 typedef enum igmp_config_timer_type_t_
35 #define _(v,s) IGMP_CONFIG_TIMER_##v,
36 foreach_igmp_config_timer_type
38 } igmp_config_timer_type_t;
40 #define IGMP_CONFIG_N_TIMERS (IGMP_CONFIG_TIMER_GENERAL_QUERY + 1)
42 extern u8 *format_igmp_config_timer_type (u8 * s, va_list * args);
45 * @brief IGMP interface configuration
47 typedef struct igmp_config_t_
50 * @param sw_if_index - interface sw_if_index
55 * @param adj_index - multicast adjacency index on the link
57 adj_index_t adj_index;
60 * @param mode - host or router
65 * Robustness variable (section 5.1)
70 * Database of groups joined on the link
72 uword *igmp_group_by_key;
75 * A vector of scheduled query-response timers
77 igmp_timer_id_t timers[IGMP_CONFIG_N_TIMERS];
80 * ID of a proxy device this configuration is on
85 #define FOR_EACH_GROUP(_group, _config, _body) \
87 igmp_key_t *__key__; \
89 hash_foreach_mem(__key__, __gid__, _config->igmp_group_by_key, \
91 _group = pool_elt_at_index(igmp_main.groups, __gid__); \
92 do { _body; } while (0); \
97 * @brief igmp clear config
98 * @param config - igmp configuration
100 * Clear all (S,G)s on specified config and remove this config from pool.
102 extern void igmp_clear_config (igmp_config_t * config);
105 * @brief igmp config lookup
106 * @param sw_if_index - interface sw_if_index
108 extern igmp_config_t *igmp_config_lookup (u32 sw_if_index);
111 * Get the pool index for a config
113 extern u32 igmp_config_index (const igmp_config_t * c);
116 * Get the config from the pool index
118 extern igmp_config_t *igmp_config_get (u32 index);
121 * @brief igmp group lookup
122 * @param config - igmp configuration
123 * @param key - igmp key
125 extern igmp_group_t *igmp_group_lookup (igmp_config_t * config,
126 const igmp_key_t * key);
128 extern u8 *format_igmp_config (u8 * s, va_list * args);
133 * fd.io coding-style-patch-verification: ON
136 * eval: (c-set-style "gnu")