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_DUMP, igmp_dump) \ 57 _(IGMP_CLEAR_INTERFACE, igmp_clear_interface) \ 58 _(IGMP_CLEAR_INTERFACE, igmp_clear_interface) \ 59 _(IGMP_GROUP_PREFIX_SET, igmp_group_prefix_set) \ 60 _(IGMP_GROUP_PREFIX_DUMP, igmp_group_prefix_dump) \ 61 _(WANT_IGMP_EVENTS, want_igmp_events) \ 68 vl_api_igmp_listen_reply_t *rmp;
70 ip46_address_t gaddr, *saddrs =
NULL;
78 rv = VNET_API_ERROR_UNEXPECTED_INTF_STATE;
82 memset (&gaddr, 0,
sizeof (gaddr));
95 IGMP_FILTER_MODE_INCLUDE :
96 IGMP_FILTER_MODE_EXCLUDE),
109 vl_api_igmp_enable_disable_reply_t *rmp;
116 (mp->
mode ? IGMP_MODE_HOST : IGMP_MODE_ROUTER));
131 memset (mp, 0,
sizeof (*mp));
133 mp->_vl_msg_id = htons (
IGMP_MSG_ID (VL_API_IGMP_DETAILS));
174 if (~0 == sw_if_index)
179 igmp_config_dump(im, q, mp->context, config);
196 vl_api_igmp_clear_interface_reply_t *rmp;
207 static vl_api_group_prefix_type_t
212 case IGMP_GROUP_PREFIX_TYPE_ASM:
213 return (htonl (
ASM));
214 case IGMP_GROUP_PREFIX_TYPE_SSM:
215 return (htonl (
SSM));
227 return (IGMP_GROUP_PREFIX_TYPE_ASM);
229 return (IGMP_GROUP_PREFIX_TYPE_SSM);
232 return (IGMP_GROUP_PREFIX_TYPE_SSM);
238 vl_api_igmp_group_prefix_set_reply_t *rmp;
262 memset (mp, 0,
sizeof (*mp));
264 mp->_vl_msg_id = htons (
IGMP_MSG_ID (VL_API_IGMP_DETAILS));
309 vl_api_want_igmp_events_reply_t *rmp;
317 rv = VNET_API_ERROR_INVALID_REGISTRATION;
335 rv = VNET_API_ERROR_INVALID_REGISTRATION;
366 const ip46_address_t * saddr,
const ip46_address_t * gaddr)
369 memset (mp, 0,
sizeof (*mp));
374 mp->
filter = htonl (filter);
384 const ip46_address_t * saddr,
const ip46_address_t * gaddr)
402 q = vl_api_client_index_to_input_queue (api_client->client_index);
404 send_igmp_event (q, 0, filter, sw_if_index, saddr, gaddr);
409 #define vl_msg_name_crc_list 411 #undef vl_msg_name_crc_list 416 #define _(id,n,crc) \ 417 vl_msg_api_add_msg_name_crc (am, #n "_" #crc, id + im->msg_id_base); 418 foreach_vl_msg_name_crc_igmp;
431 name =
format (0,
"igmp_%08x%c", api_version, 0);
438 vl_msg_api_set_handlers((VL_API_##N + im->msg_id_base), \ 440 vl_api_##n##_t_handler, \ 442 vl_api_##n##_t_endian, \ 443 vl_api_##n##_t_print, \ 444 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 recption of IGMP packets.
#define vec_foreach_index(var, v)
Iterate over vector indices.
#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
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
igmp_config_t * configs
pool of configs
void send_igmp_event(unix_shared_memory_queue_t *q, u32 context, igmp_filter_mode_t filter, u32 sw_if_index, const ip46_address_t *saddr, const ip46_address_t *gaddr)
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.
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.
svm_queue_t unix_shared_memory_queue_t
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]
unix_shared_memory_queue_t * q
#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.
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.
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)
#define BAD_SW_IF_INDEX_LABEL
static void vl_api_igmp_group_prefix_set_t_handler(vl_api_igmp_group_prefix_set_t *mp)
void vl_msg_api_send_shmem(svm_queue_t *q, u8 *elem)
vl_api_igmp_group_t group
svm_queue_t * vl_api_client_index_to_input_queue(u32 index)
#define vec_free(V)
Free vector's memory (no header).
vpe_client_registration_t * api_clients
API client registered for events.
#define clib_memcpy(a, b, c)
enum igmp_filter_mode_t_ igmp_filter_mode_t
vl_api_ip4_address_t gaddr
void igmp_group_prefix_set(const fib_prefix_t *pfx, igmp_group_prefix_type_t type)
#define VNET_SW_INTERFACE_FLAG_ADMIN_UP
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 igmp_config_dump(igmp_main_t *im, unix_shared_memory_queue_t *q, u32 context, igmp_config_t *config)
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 void send_igmp_details(unix_shared_memory_queue_t *q, igmp_main_t *im, igmp_config_t *config, igmp_group_t *group, igmp_src_t *src, u32 context)
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
static uword vnet_sw_interface_get_flags(vnet_main_t *vnm, u32 sw_if_index)
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)