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 #include <igmp/igmp_config.h>
19 #include <igmp/igmp.h>
22 igmp_clear_config (igmp_config_t * config)
27 IGMP_DBG ("clear-config: %U",
28 format_vnet_sw_if_index_name,
29 vnet_get_main (), config->sw_if_index);
32 FOR_EACH_GROUP (group, config,
34 igmp_group_clear (&group);
38 for (ii = 0; ii < IGMP_CONFIG_N_TIMERS; ii++)
40 igmp_timer_retire (&config->timers[ii]);
45 igmp_config_lookup (u32 sw_if_index)
51 if (vec_len (im->igmp_config_by_sw_if_index) > sw_if_index)
55 index = im->igmp_config_by_sw_if_index[sw_if_index];
58 return (vec_elt_at_index (im->configs, index));
64 igmp_config_index (const igmp_config_t * c)
66 return (c - igmp_main.configs);
70 igmp_config_get (u32 index)
72 return (pool_elt_at_index (igmp_main.configs, index));
76 igmp_group_lookup (igmp_config_t * config, const igmp_key_t * key)
79 igmp_group_t *group = NULL;
83 p = hash_get_mem (config->igmp_group_by_key, key);
85 group = pool_elt_at_index (igmp_main.groups, p[0]);
91 format_igmp_config_timer_type (u8 * s, va_list * args)
93 igmp_config_timer_type_t type = va_arg (*args, igmp_config_timer_type_t);
97 #define _(v,t) case IGMP_CONFIG_TIMER_##v: return (format (s, "%s", t));
98 foreach_igmp_config_timer_type
106 format_igmp_config (u8 * s, va_list * args)
108 igmp_config_t *config;
113 config = va_arg (*args, igmp_config_t *);
114 vnm = vnet_get_main ();
116 s = format (s, "interface: %U mode: %U %U",
117 format_vnet_sw_if_index_name, vnm, config->sw_if_index,
118 format_igmp_mode, config->mode,
119 format_igmp_proxy_device_id, config->proxy_device_id);
121 for (ii = 0; ii < IGMP_CONFIG_N_TIMERS; ii++)
123 s = format (s, "\n %U:%U",
124 format_igmp_config_timer_type, ii,
125 format_igmp_timer_id, config->timers[ii]);
129 FOR_EACH_GROUP (group, config,
131 s = format (s, "\n%U", format_igmp_group, group, 4);
139 * fd.io coding-style-patch-verification: ON
142 * eval: (c-set-style "gnu")