hs-test: clean up Makefile for compatibility with ci-management
[vpp.git] / src / plugins / igmp / igmp.h
1 /*
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:
7  *
8  *     http://www.apache.org/licenses/LICENSE-2.0
9  *
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  *------------------------------------------------------------------
16  */
17
18 #ifndef _IGMP_H_
19 #define _IGMP_H_
20
21 #include <vlib/vlib.h>
22 #include <vnet/ip/ip.h>
23 #define REPLY_MSG_ID_BASE (igmp_main.msg_id_base)
24 #include <vlibapi/api_helper_macros.h>
25 #include <vnet/ip/igmp_packet.h>
26 #include <vnet/adj/adj_mcast.h>
27 #include <igmp/igmp_types.h>
28 #include <igmp/igmp_format.h>
29 #include <igmp/igmp_timer.h>
30 #include <igmp/igmp_group.h>
31 #include <igmp/igmp_config.h>
32 #include <igmp/igmp_proxy.h>
33
34 /**
35  * RFC 3376 Section 8.1
36  */
37 #define IGMP_DEFAULT_ROBUSTNESS_VARIABLE        (2)
38
39 #define IGMP_DBG(...) \
40     vlib_log_debug (igmp_main.logger, __VA_ARGS__);
41
42 /**
43  * General Query address - 224.0.0.1
44  * Membership Report address - 224.0.0.22
45  * SSM default range 232/8
46  */
47 #if CLIB_ARCH_IS_BIG_ENDIAN
48 #define IGMP_GENERAL_QUERY_ADDRESS      (0xE0000001)
49 #define IGMP_MEMBERSHIP_REPORT_ADDRESS  (0xE0000016)
50 #define IGMP_SSM_DEFAULT                (0xE8000000)
51 #else
52 #define IGMP_GENERAL_QUERY_ADDRESS      (0x010000E0)
53 #define IGMP_MEMBERSHIP_REPORT_ADDRESS  (0x160000E0)
54 #define IGMP_SSM_DEFAULT                (0x000000E8)
55 #endif
56
57 /** helper macro to get igmp membership group from pointer plus offset */
58 #define group_ptr(p, l) ((igmp_membership_group_v3_t *)((u8*)(p) + (l)))
59 #define group_cptr(p, l) ((const igmp_membership_group_v3_t *)((u8*)(p) + (l)))
60
61 /**
62  * collection of data related to IGMP
63  */
64 typedef struct igmp_main_t_
65 {
66   /**
67    * API base message ID
68    */
69   u16 msg_id_base;
70
71   uword *igmp_api_client_by_client_index;
72
73   /**
74    * API client registered for events
75    */
76   vpe_client_registration_t *api_clients;
77
78   /**
79    * per-interface DB of configs
80    */
81   u32 *igmp_config_by_sw_if_index;
82
83   /**
84    * the number of igmp configs for each mfib_index (VRF)
85    */
86   u32 *n_configs_per_mfib_index;
87
88   /**
89    * logger - VLIB log class
90    */
91   vlib_log_class_t logger;
92
93   /**
94    * pool of configs
95    */
96   igmp_config_t *configs;
97
98   /**
99    * pool of groups
100    */
101   igmp_group_t *groups;
102   /**
103    * pool of sources
104    */
105   igmp_src_t *srcs;
106
107   /**
108    * per-vrf DB of proxy devices
109    */
110   u32 *igmp_proxy_device_by_vrf_id;
111
112   /**
113    * pool of proxy devices
114    */
115   igmp_proxy_device_t *proxy_devices;
116 } igmp_main_t;
117
118 extern igmp_main_t igmp_main;
119
120 /**
121  * @brief IGMP interface enable/disable
122  *  @param sw_if_index - Interface
123  *  @param enable - enable/disable
124  *  @param mode - Host or router
125  */
126 int igmp_enable_disable (u32 sw_if_index, u8 enable, igmp_mode_t mode);
127
128 /**
129  * @brief igmp listen
130  *  Called by a host to request reception of multicast packets
131  * @param vm - vlib main
132  * @param filter - Filter mode
133  * @param sw_if_index - interface sw_if_index
134  * @param saddr - source address
135  * @param gaddr - group address
136  *
137  *    Add/del (S,G) on an interface.
138  *   send a status change report from the interface.
139  */
140 int igmp_listen (vlib_main_t * vm,
141                  igmp_filter_mode_t filter,
142                  u32 sw_if_index,
143                  const ip46_address_t * saddr, const ip46_address_t * gaddr);
144
145 /**
146  * @brief Send an IGMP event to listening parties
147  * @param filter mode
148  * @param sw_if_index
149  * @param saddr
150  * @param gaddr
151  */
152 void igmp_event (igmp_filter_mode_t filter,
153                  u32 sw_if_index,
154                  const ip46_address_t * saddr, const ip46_address_t * gaddr);
155
156 #endif /* _IGMP_H_ */
157
158 /*
159  * fd.io coding-style-patch-verification: ON
160  *
161  * Local Variables:
162  * eval: (c-set-style "gnu")
163  * End:
164  */