2 *------------------------------------------------------------------
3 * Copyright (c) 2017 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 *------------------------------------------------------------------
21 #include <vlib/vlib.h>
22 #include <vnet/ip/ip.h>
23 #include <vlibapi/api_helper_macros.h>
24 #include <vnet/ip/igmp_packet.h>
25 #include <vnet/adj/adj_mcast.h>
26 #include <igmp/igmp_types.h>
27 #include <igmp/igmp_format.h>
28 #include <igmp/igmp_timer.h>
29 #include <igmp/igmp_group.h>
30 #include <igmp/igmp_config.h>
33 * RFC 3376 Section 8.1
35 #define IGMP_DEFAULT_ROBUSTNESS_VARIABLE (2)
37 #define IGMP_DBG(...) \
38 vlib_log_debug (igmp_main.logger, __VA_ARGS__);
41 * General Query address - 224.0.0.1
42 * Membership Report address - 224.0.0.22
43 * SSM default range 232/8
45 #if CLIB_ARCH_IS_BIG_ENDIAN
46 #define IGMP_GENERAL_QUERY_ADDRESS (0xE0000001)
47 #define IGMP_MEMBERSHIP_REPORT_ADDRESS (0xE0000016)
48 #define IGMP_SSM_DEFAULT (0xE8000000)
50 #define IGMP_GENERAL_QUERY_ADDRESS (0x010000E0)
51 #define IGMP_MEMBERSHIP_REPORT_ADDRESS (0x160000E0)
52 #define IGMP_SSM_DEFAULT (0x000000E8)
55 /** helper macro to get igmp membership group from pointer plus offset */
56 #define group_ptr(p, l) ((igmp_membership_group_v3_t *)((u8*)(p) + (l)))
57 #define group_cptr(p, l) ((const igmp_membership_group_v3_t *)((u8*)(p) + (l)))
60 * collection of data related to IGMP
62 typedef struct igmp_main_t_
69 uword *igmp_api_client_by_client_index;
72 * API client registered for events
74 vpe_client_registration_t *api_clients;
77 * per-interface DB of configs
79 u32 *igmp_config_by_sw_if_index;
82 * the number of igmp configs for each mfib_index (VRF)
84 u32 *n_configs_per_mfib_index;
87 * logger - VLIB log class
89 vlib_log_class_t logger;
94 igmp_config_t *configs;
106 extern igmp_main_t igmp_main;
109 * @brief IGMP interface enable/disable
110 * @param sw_if_index - Interface
111 * @param enable - enable/disable
112 * @param mode - Host or router
114 int igmp_enable_disable (u32 sw_if_index, u8 enable, igmp_mode_t mode);
118 * Called by a host to request reception of multicast packets
119 * @param vm - vlib main
120 * @param filter - Filter mode
121 * @param sw_if_index - interface sw_if_index
122 * @param saddr - source address
123 * @param gaddr - group address
125 * Add/del (S,G) on an interface.
126 * send a status change report from the interface.
128 int igmp_listen (vlib_main_t * vm,
129 igmp_filter_mode_t filter,
131 const ip46_address_t * saddr, const ip46_address_t * gaddr);
134 * @brief Send an IGMP event to listening parties
140 void igmp_event (igmp_filter_mode_t filter,
142 const ip46_address_t * saddr, const ip46_address_t * gaddr);
144 #endif /* _IGMP_H_ */
147 * fd.io coding-style-patch-verification: ON
150 * eval: (c-set-style "gnu")