39 #define vl_print(handle, ...) vlib_cli_output (handle, __VA_ARGS__) 45 #define vl_api_version(n,v) static u32 api_version=(v); 51 #define IGMP_MSG_ID(_id) (_id + igmp_main.msg_id_base) 53 #define foreach_igmp_plugin_api_msg \ 54 _(IGMP_LISTEN, igmp_listen) \ 55 _(IGMP_ENABLE_DISABLE, igmp_enable_disable) \ 56 _(IGMP_PROXY_DEVICE_ADD_DEL, igmp_proxy_device_add_del) \ 57 _(IGMP_PROXY_DEVICE_ADD_DEL_INTERFACE, igmp_proxy_device_add_del_interface) \ 58 _(IGMP_DUMP, igmp_dump) \ 59 _(IGMP_CLEAR_INTERFACE, igmp_clear_interface) \ 60 _(IGMP_CLEAR_INTERFACE, igmp_clear_interface) \ 61 _(IGMP_GROUP_PREFIX_SET, igmp_group_prefix_set) \ 62 _(IGMP_GROUP_PREFIX_DUMP, igmp_group_prefix_dump) \ 63 _(WANT_IGMP_EVENTS, want_igmp_events) \ 70 vl_api_igmp_listen_reply_t *rmp;
72 ip46_address_t gaddr, *saddrs =
NULL;
80 rv = VNET_API_ERROR_UNEXPECTED_INTF_STATE;
97 IGMP_FILTER_MODE_INCLUDE :
98 IGMP_FILTER_MODE_EXCLUDE),
111 vl_api_igmp_enable_disable_reply_t *rmp;
118 (mp->
mode ? IGMP_MODE_HOST : IGMP_MODE_ROUTER));
129 vl_api_igmp_proxy_device_add_del_reply_t *rmp;
147 vl_api_igmp_proxy_device_add_del_interface_reply_t *rmp;
159 (VL_API_IGMP_PROXY_DEVICE_ADD_DEL_INTERFACE_REPLY));
172 mp->_vl_msg_id = htons (
IGMP_MSG_ID (VL_API_IGMP_DETAILS));
213 if (~0 == sw_if_index)
218 igmp_config_dump(im, rp, mp->context, config);
235 vl_api_igmp_clear_interface_reply_t *rmp;
246 static vl_api_group_prefix_type_t
251 case IGMP_GROUP_PREFIX_TYPE_ASM:
252 return (htonl (
ASM));
253 case IGMP_GROUP_PREFIX_TYPE_SSM:
254 return (htonl (
SSM));
266 return (IGMP_GROUP_PREFIX_TYPE_ASM);
268 return (IGMP_GROUP_PREFIX_TYPE_SSM);
271 return (IGMP_GROUP_PREFIX_TYPE_SSM);
277 vl_api_igmp_group_prefix_set_reply_t *rmp;
303 mp->_vl_msg_id = htons (
IGMP_MSG_ID (VL_API_IGMP_DETAILS));
348 vl_api_want_igmp_events_reply_t *rmp;
356 rv = VNET_API_ERROR_INVALID_REGISTRATION;
374 rv = VNET_API_ERROR_INVALID_REGISTRATION;
405 const ip46_address_t * saddr,
const ip46_address_t * gaddr)
413 mp->
filter = htonl (filter);
423 const ip46_address_t * saddr,
const ip46_address_t * gaddr)
441 rp = vl_api_client_index_to_registration (api_client->client_index);
443 send_igmp_event (rp, 0, filter, sw_if_index, saddr, gaddr);
448 #define vl_msg_name_crc_list 450 #undef vl_msg_name_crc_list 455 #define _(id,n,crc) \ 456 vl_msg_api_add_msg_name_crc (am, #n "_" #crc, id + im->msg_id_base); 457 foreach_vl_msg_name_crc_igmp;
470 name =
format (0,
"igmp_%08x%c", api_version, 0);
477 vl_msg_api_set_handlers((VL_API_##N + im->msg_id_base), \ 479 vl_api_##n##_t_handler, \ 481 vl_api_##n##_t_endian, \ 482 vl_api_##n##_t_print, \ 483 sizeof(vl_api_##n##_t), 1); int igmp_listen(vlib_main_t *vm, igmp_filter_mode_t mode, u32 sw_if_index, const ip46_address_t *saddrs, const ip46_address_t *gaddr)
igmp listen Called by a host to request reception of multicast packets
#define vec_validate(V, I)
Make sure vector is long enough for given index (no header, unspecified alignment) ...
#define foreach_igmp_plugin_api_msg
static clib_error_t * igmp_plugin_api_hookup(vlib_main_t *vm)
vl_api_filter_mode_t filter
Used by a 'router' and 'host' to enable the reception of IGMP packets.
#define vec_foreach_index(var, v)
Iterate over vector indices.
static void vl_api_igmp_proxy_device_add_del_t_handler(vl_api_igmp_proxy_device_add_del_t *mp)
#define hash_set(h, key, value)
#define hash_unset(h, key)
void ip_prefix_decode(const vl_api_prefix_t *in, fib_prefix_t *out)
remove all (S,G)s from an interface
int igmp_proxy_device_add_del_interface(u32 vrf_id, u32 sw_if_index, u8 add)
IGMP proxy device add/del interface.
vnet_main_t * vnet_get_main(void)
void igmp_ssm_range_walk(igmp_ssm_range_walk_t fn, void *ctx)
vl_api_filter_mode_t filter
clib_memset(h->entries, 0, sizeof(h->entries[0]) *entries)
igmp_config_t * configs
pool of configs
static void vl_api_send_msg(vl_api_registration_t *rp, u8 *elem)
dump (S,G)s from interface
#define pool_get(P, E)
Allocate an object E from a pool P (unspecified alignment).
void * vl_msg_api_alloc(int nbytes)
vl_api_ip4_address_t gaddr
format_function_t format_vnet_sw_if_index_name
u16 msg_id_base
API base message ID.
#define clib_memcpy(d, s, n)
void igmp_clear_config(igmp_config_t *config)
igmp clear config
enum walk_rc_t_ walk_rc_t
Walk return code.
#define pool_foreach(VAR, POOL, BODY)
Iterate through pool.
static igmp_group_prefix_type_t igmp_group_type_api_to_int(vl_api_group_prefix_type_t t)
#define vec_elt_at_index(v, i)
Get vector value at index i checking that i is in bounds.
Aggregrate type for a prefix.
vl_api_ip4_address_t saddrs[n_srcs]
#define FOR_EACH_GROUP(_group, _config, _body)
struct igmp_ssm_range_walk_ctx_t_ igmp_ssm_range_walk_ctx_t
igmp_config_t * igmp_config_lookup(u32 sw_if_index)
igmp config lookup
static clib_error_t * want_igmp_events_reaper(u32 client_index)
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
static walk_rc_t igmp_ssm_range_walk_dump(const fib_prefix_t *pfx, igmp_group_prefix_type_t type, void *args)
int igmp_enable_disable(u32 sw_if_index, u8 enable, igmp_mode_t mode)
IGMP interface enable/disable.
void send_igmp_event(vl_api_registration_t *rp, u32 context, igmp_filter_mode_t filter, u32 sw_if_index, const ip46_address_t *saddr, const ip46_address_t *gaddr)
vl_api_ip4_address_t saddr
Configure a prefix for SSM or ASM semantics.
#define pool_put(P, E)
Free an object E in pool P.
static void igmp_config_dump(igmp_main_t *im, vl_api_registration_t *rp, u32 context, igmp_config_t *config)
VLIB_API_INIT_FUNCTION(igmp_plugin_api_hookup)
static void vl_api_igmp_group_prefix_dump_t_handler(vl_api_igmp_dump_t *mp)
collection of data related to IGMP
API main structure, used by both vpp and binary API clients.
static void setup_message_id_table(igmp_main_t *im, api_main_t *am)
An API client registration, only in vpp/vlib.
#define BAD_SW_IF_INDEX_LABEL
static void vl_api_igmp_group_prefix_set_t_handler(vl_api_igmp_group_prefix_set_t *mp)
vl_api_igmp_group_t group
#define vec_free(V)
Free vector's memory (no header).
vpe_client_registration_t * api_clients
API client registered for events.
enum igmp_filter_mode_t_ igmp_filter_mode_t
static vl_api_registration_t * vl_api_client_index_to_registration(u32 index)
vl_api_ip4_address_t gaddr
void igmp_group_prefix_set(const fib_prefix_t *pfx, igmp_group_prefix_type_t type)
static void send_igmp_details(vl_api_registration_t *rp, igmp_main_t *im, igmp_config_t *config, igmp_group_t *group, igmp_src_t *src, u32 context)
vl_api_registration_t * rp
Add/del downstream interface to/from proxy device.
static void vl_api_igmp_proxy_device_add_del_interface_t_handler(vl_api_igmp_proxy_device_add_del_interface_t *mp)
Add/del proxy device on specified VRF.
vl_api_ip4_address_t gaddr
static vlib_main_t * vlib_get_main(void)
IGMP interface configuration.
static vl_api_group_prefix_type_t igmp_group_type_int_to_api(igmp_group_prefix_type_t t)
void ip_prefix_encode(const fib_prefix_t *in, vl_api_prefix_t *out)
VL_MSG_API_REAPER_FUNCTION(want_igmp_events_reaper)
void igmp_event(igmp_filter_mode_t filter, u32 sw_if_index, const ip46_address_t *saddr, const ip46_address_t *gaddr)
Send an IGMP event to listening parties.
#define FOR_EACH_SRC(_src, _group, _filter, _body)
igmp_key_t * key
The group's key within the per-interface config.
static void vl_api_want_igmp_events_t_handler(vl_api_want_igmp_events_t *mp)
vl_api_ip4_address_t saddr
IGMP group A multicast group address for which reception has been requested.
static void vl_api_igmp_listen_t_handler(vl_api_igmp_listen_t *mp)
igmp_key_t * key
The source's key.
static void vl_api_igmp_enable_disable_t_handler(vl_api_igmp_enable_disable_t *mp)
static vnet_sw_interface_flags_t vnet_sw_interface_get_flags(vnet_main_t *vnm, u32 sw_if_index)
enum igmp_group_prefix_type_t_ igmp_group_prefix_type_t
static void vl_api_igmp_dump_t_handler(vl_api_igmp_dump_t *mp)
static vpe_client_registration_t * igmp_api_client_lookup(igmp_main_t *im, u32 client_index)
uword * igmp_api_client_by_client_index
int igmp_proxy_device_add_del(u32 vrf_id, u32 sw_if_index, u8 add)
IGMP proxy device add/del.
static void vl_api_igmp_clear_interface_t_handler(vl_api_igmp_clear_interface_t *mp)
IGMP source The representation of a specified source address with in multicast group.
#define VALIDATE_SW_IF_INDEX(mp)
u16 vl_msg_api_get_msg_ids(const char *name, int n)